Author :
Cody Northrop
Date :
2021-08-04 17:24:02
Hash :f9c287f0 Message :Capture/Replay: Fix reset for immutable textures
Before this CL, we were including TexStorage in the calls to reset an
immutable texture. This throws an error in GL, as you can only call
TexStorage once on a texture.
Example from ResetReplay():
glBindTexture(GL_TEXTURE_2D, gTextureMap[52]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 9729);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, 6403);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, 256, 512); // <== ERROR
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 512,
GL_RED, GL_UNSIGNED_BYTE, ...);
To fix this, move TexStorage into the calls used to regen the
texture rather than restore its contents. This means ResetReplay will
only call TexStorage again if the texture was actually deleted.
Example new regen sequence, if the texture had been deleted:
const GLuint deleteTexturesPacked[] = { gTextureMap[52] };
glDeleteTextures(1, deleteTexturesPacked);
glGenTextures(1, reinterpret_cast<GLuint *>(gReadBuffer));
UpdateTextureID(52, 0);
glBindTexture(GL_TEXTURE_2D, gTextureMap[52]);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, 256, 512);
Also rename texCalls to texSetupCalls to more easily distinguish
from texGenCalls, now that they intermingle.
Test: Final Fantasy MEC
Bug: b/195607411
Bug: angleproject:6246
Change-Id: I37daaeb6ea4337969cb241a20256fec07dce514e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3073379
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Cody Northrop <cnorthrop@google.com>