Improve current multisampled renderbuffer/texture support
This is split off from a change to implement multisampled textures for
the Vulkan back-end, and will come before that change. The changes
include:
- Make a common utility rx::GetSamplePosition() function. D3D11 and
Vulkan use the same standard sample positions/locations for 1, 2, 4,
8, and 16 samples. The D3D11 back-end has a utility function for
this, which is being moved to a common location--for use by both the
D3D11 and Vulkan back-ends.
- Texture::setStorageMultisample() handles converting the "requested number of
samples" to the actual number of samples used (e.g. converting 3 to 4),
supported by the underlying back-end). The actual number used is stored in
gl::TextureState::mImageDescs, for use by other GLES commands.
- Change some end2end tests to not make assumptions about the supported number
of samples, but to properly query what is supported.
Bug: angleproject:3565
Bug: angleproject:4196
Change-Id: I1dc12fedd0f8fb4975f90d87486e443b069b7141
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1948535
Commit-Queue: Ian Elliott <ianelliott@google.com>
Reviewed-by: Ian Elliott <ianelliott@google.com>
diff --git a/src/tests/gl_tests/FramebufferTest.cpp b/src/tests/gl_tests/FramebufferTest.cpp
index bf69a6c..1968e2f 100644
--- a/src/tests/gl_tests/FramebufferTest.cpp
+++ b/src/tests/gl_tests/FramebufferTest.cpp
@@ -889,13 +889,26 @@
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
+ // Lookup the supported number of sample counts (rely on fact that ANGLE uses the same set of
+ // sample counts for textures and renderbuffers)
+ GLint numSampleCounts = 0;
+ std::vector<GLint> sampleCounts;
+ GLsizei queryBufferSize = 1;
+ glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_NUM_SAMPLE_COUNTS,
+ queryBufferSize, &numSampleCounts);
+ ANGLE_SKIP_TEST_IF((numSampleCounts < 2));
+ sampleCounts.resize(numSampleCounts);
+ queryBufferSize = numSampleCounts;
+ glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_SAMPLES, queryBufferSize,
+ sampleCounts.data());
+
GLTexture mTexture;
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture.get());
- glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, true);
+ glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[0], GL_RGBA8, 1, 1, true);
GLRenderbuffer mRenderbuffer;
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer.get());
- glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_RGBA8, 1, 1);
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCounts[1], GL_RGBA8, 1, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTexture.get(), 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER,
@@ -915,11 +928,23 @@
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
+ // Lookup the supported number of sample counts
+ GLint numSampleCounts = 0;
+ std::vector<GLint> sampleCounts;
+ GLsizei queryBufferSize = 1;
+ glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_NUM_SAMPLE_COUNTS,
+ queryBufferSize, &numSampleCounts);
+ ANGLE_SKIP_TEST_IF((numSampleCounts < 2));
+ sampleCounts.resize(numSampleCounts);
+ queryBufferSize = numSampleCounts;
+ glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_SAMPLES, queryBufferSize,
+ sampleCounts.data());
+
GLTexture mTextures[2];
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[0].get());
- glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, true);
+ glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[0], GL_RGBA8, 1, 1, true);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[1].get());
- glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, GL_RGBA8, 1, 1, true);
+ glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[1], GL_RGBA8, 1, 1, true);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTextures[0].get(), 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE,