Skip to content
Permalink
Browse files
TextureMtl.mm:108 (GetLayerMipIndex): \t! Unreachable reached
https://bugs.webkit.org/show_bug.cgi?id=240790

Reviewed by Darin Adler

Check texture valid before use.

* Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm:
(rx::mtl::Texture::MakeTexture):

Canonical link: https://commits.webkit.org/251435@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kpiddington committed Jun 9, 2022
1 parent ff6381f commit e7e584e5f648744e443d19cdbea2832634bffdea
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 12 deletions.
@@ -0,0 +1,14 @@
Test creating a max-size texture.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


Canvas.getContext
PASS context exists

PASS getError was one of: NO_ERROR or OUT_OF_MEMORY : unexpected result when creating MAX_TEXTURE_SIZE texture

PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WebGL Framebuffer Test</title>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="2" height="2"> </canvas>
<script>
description("Test creating a max-size texture.");

debug("");
debug("Canvas.getContext");

if (window.internals)
window.internals.settings.setWebGLErrorsToConsoleEnabled(false);

var canvas = document.getElementById("canvas");
var gl = create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");

debug("");

texSize = gl.getParameter(gl.MAX_TEXTURE_SIZE)
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D,
0, // level
gl.RGBA, // internalFormat
texSize, // width
texSize, // height
0, // border
gl.RGBA, // format
gl.FLOAT, // type
null); // data
err = gl.getError();
glErrorShouldBe(gl, [gl.NO_ERROR, gl.OUT_OF_MEMORY], "unexpected result when creating MAX_TEXTURE_SIZE texture")
}

debug("");

</script>
</body>
</html>

@@ -273,11 +273,10 @@ void EnsureCPUMemWillBeSynced(ContextMtl *context, const std::shared_ptr<T> &res
{
return angle::Result::Stop;
}
refOut->reset(new Texture(context, desc, mips, renderTargetOnly, allowFormatView, memoryLess));
if (!refOut || !refOut->get())
{
ANGLE_MTL_CHECK(context, false, GL_OUT_OF_MEMORY);
}
ASSERT(refOut);
Texture *newTexture = new Texture(context, desc, mips, renderTargetOnly, allowFormatView, memoryLess);
ANGLE_MTL_CHECK(context, newTexture->valid(), GL_OUT_OF_MEMORY);
refOut->reset(newTexture);
if (!mtlFormat.hasDepthAndStencilBits())
{
refOut->get()->setColorWritableMask(GetEmulatedColorWriteMask(mtlFormat));
@@ -301,13 +300,10 @@ void EnsureCPUMemWillBeSynced(ContextMtl *context, const std::shared_ptr<T> &res
bool renderTargetOnly,
TextureRef *refOut)
{

refOut->reset(new Texture(context, desc, surfaceRef, slice, renderTargetOnly));

if (!(*refOut) || !(*refOut)->get())
{
ANGLE_MTL_CHECK(context, false, GL_OUT_OF_MEMORY);
}
ASSERT(refOut);
Texture *newTexture = new Texture(context, desc, surfaceRef, slice, renderTargetOnly);
ANGLE_MTL_CHECK(context, newTexture->valid(), GL_OUT_OF_MEMORY);
refOut->reset(newTexture);
if (!mtlFormat.hasDepthAndStencilBits())
{
refOut->get()->setColorWritableMask(GetEmulatedColorWriteMask(mtlFormat));

0 comments on commit e7e584e

Please sign in to comment.