[Test] (IntegrationTest): read cube faces back through a per-face FBO, which glGetTexImage's face token does not distinguish on DirectVulkan

This commit is contained in:
2026-08-27 05:07:38 -04:00
parent de09646d5e
commit 0e0882cfc6
@@ -881,15 +881,26 @@ void main()
DrawSampling(program, scratchFbo, GL_TEXTURE_CUBE_MAP, cube); DrawSampling(program, scratchFbo, GL_TEXTURE_CUBE_MAP, cube);
EXPECT_EQ(FirstGLError(), 0u) << "the sampling draw errored"; EXPECT_EQ(FirstGLError(), 0u) << "the sampling draw errored";
// Every face, read back one at a time - the per-face spelling is what names the // Every face, read back through an FBO that names THAT face.
// offender when only +X was cleared. //
// Not glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face): measured against a tree
// where only +X had been cleared, that spelling returned the cleared colour for all
// six faces, so it cannot see per-face state on DirectVulkan and the case built on it
// was unfalsifiable. glFramebufferTexture2D + glReadPixels names one face and nothing
// else, and the pending clear is long gone by now (materialised and popped above), so
// this readback cannot alter what it is measuring.
static const char* const kFaceNames[6] = {"+X", "-X", "+Y", "-Y", "+Z", "-Z"}; static const char* const kFaceNames[6] = {"+X", "-X", "+Y", "-Y", "+Z", "-Z"};
glBindTexture(GL_TEXTURE_CUBE_MAP, cube);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
for (int face = 0; face < 6; ++face) { for (int face = 0; face < 6; ++face) {
const GLuint faceFbo = TrackFramebuffer();
glBindFramebuffer(GL_FRAMEBUFFER, faceFbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), cube, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
ASSERT_TRUE(FramebufferIsComplete()) << "cube face " << kFaceNames[face] << " is not attachable";
std::vector<Rgba8> texels(static_cast<std::size_t>(kExtent) * kExtent, Rgba8{}); std::vector<Rgba8> texels(static_cast<std::size_t>(kExtent) * kExtent, Rgba8{});
glGetTexImage(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, GL_RGBA, glPixelStorei(GL_PACK_ALIGNMENT, 1);
GL_UNSIGNED_BYTE, texels.data()); glReadPixels(0, 0, kExtent, kExtent, GL_RGBA, GL_UNSIGNED_BYTE, texels.data());
glBindFramebuffer(GL_FRAMEBUFFER, 0);
EXPECT_EQ(FirstGLError(), 0u) << "reading cube face " << kFaceNames[face] << " back errored"; EXPECT_EQ(FirstGLError(), 0u) << "reading cube face " << kFaceNames[face] << " back errored";
ExpectAllCleared(texels, kExtent * kExtent, ExpectAllCleared(texels, kExtent * kExtent,
(std::string("layered GL_TEXTURE_CUBE_MAP glClear materialised by sampling, " (std::string("layered GL_TEXTURE_CUBE_MAP glClear materialised by sampling, "
@@ -897,7 +908,6 @@ void main()
kFaceNames[face]) kFaceNames[face])
.c_str()); .c_str());
} }
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
Gl().EndFrame(); Gl().EndFrame();
} }