ES31: Support bindImageTexture on Texture2D for compute shaders on D3D
BUG=angleproject:1987
TEST=angle_end2end_tests
Change-Id: I3b0afb441a41dbd7f204b1d1bba7884c8d203ce1
Reviewed-on: https://chromium-review.googlesource.com/749004
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/ComputeShaderTest.cpp b/src/tests/gl_tests/ComputeShaderTest.cpp
index 1e8b855..1c5d7e2 100644
--- a/src/tests/gl_tests/ComputeShaderTest.cpp
+++ b/src/tests/gl_tests/ComputeShaderTest.cpp
@@ -346,8 +346,6 @@
// Use image uniform to write texture in compute shader, and verify the content is expected.
TEST_P(ComputeShaderTest, BindImageTexture)
{
- ANGLE_SKIP_TEST_IF(IsD3D11());
-
GLTexture mTexture[2];
GLFramebuffer mFramebuffer;
const std::string csSource =
@@ -528,6 +526,88 @@
EXPECT_GL_NO_ERROR();
}
+// Use image uniform to read and write textures in compute shader, and verify the contents.
+TEST_P(ComputeShaderTest, BindImageTextureWithTexture2D)
+{
+ GLTexture texture[2];
+ GLFramebuffer framebuffer;
+ const std::string csSource =
+ R"(#version 310 es
+ layout(local_size_x=4, local_size_y=2, local_size_z=1) in;
+ layout(r32ui, binding = 0) readonly uniform highp uimage2D uImage_1;
+ layout(r32ui, binding = 1) writeonly uniform highp uimage2D uImage_2;
+ void main()
+ {
+ uvec4 value = imageLoad(uImage_1, ivec2(gl_LocalInvocationID.xy));
+ imageStore(uImage_2, ivec2(gl_LocalInvocationID.xy), value);
+ })";
+
+ constexpr int kWidth = 4, kHeight = 2;
+ constexpr GLuint kInputValues[2][8] = {{200, 200, 200, 200, 200, 200, 200, 200},
+ {100, 100, 100, 100, 100, 100, 100, 100}};
+
+ glBindTexture(GL_TEXTURE_2D, texture[0]);
+ glTexStorage2D(GL_TEXTURE_2D, 1, GL_R32UI, kWidth, kHeight);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT,
+ kInputValues[0]);
+ EXPECT_GL_NO_ERROR();
+
+ glBindTexture(GL_TEXTURE_2D, texture[1]);
+ glTexStorage2D(GL_TEXTURE_2D, 1, GL_R32UI, kWidth, kHeight);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT,
+ kInputValues[1]);
+ EXPECT_GL_NO_ERROR();
+
+ glUseProgram(0);
+ GLuint outputValues[8];
+ constexpr GLuint expectedValue_1 = 200;
+ constexpr GLuint expectedValue_2 = 100;
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
+
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
+ EXPECT_GL_NO_ERROR();
+ glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
+
+ for (int i = 0; i < kWidth * kHeight; i++)
+ {
+ EXPECT_EQ(expectedValue_1, outputValues[i]);
+ }
+
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
+ EXPECT_GL_NO_ERROR();
+ glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
+
+ for (int i = 0; i < kWidth * kHeight; i++)
+ {
+ EXPECT_EQ(expectedValue_2, outputValues[i]);
+ }
+
+ ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
+ glUseProgram(program.get());
+
+ glBindImageTexture(0, texture[0], 0, GL_FALSE, 0, GL_READ_ONLY, GL_R32UI);
+ EXPECT_GL_NO_ERROR();
+
+ glBindImageTexture(1, texture[1], 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32UI);
+ EXPECT_GL_NO_ERROR();
+
+ glDispatchCompute(1, 1, 1);
+ EXPECT_GL_NO_ERROR();
+
+ glUseProgram(0);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
+
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
+ EXPECT_GL_NO_ERROR();
+ glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
+ EXPECT_GL_NO_ERROR();
+
+ for (int i = 0; i < kWidth * kHeight; i++)
+ {
+ EXPECT_EQ(expectedValue_1, outputValues[i]);
+ }
+}
+
// Check that it is not possible to create a compute shader when the context does not support ES
// 3.10
TEST_P(ComputeShaderTestES3, NotSupported)