Commit 0e2c39f2 by Qin Jiajia Committed by Commit Bot

Fix that uniform can't be used as the index of buffer variable

ssbo.a[uniformBlock.index] should be a valid usage. So in this change, we forward EOpIndexDirectInterfaceBlock to OutputHLSL to process when the left node is not a SSBO. Bug: angleproject:3280 Change-Id: I2696d5b1cf420db133a8ba0728116261dd9e9f1e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1531980Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jiajia Qin <jiajia.qin@intel.com>
parent f455f756
...@@ -634,6 +634,11 @@ bool ShaderStorageBlockOutputHLSL::visitBinary(Visit visit, TIntermBinary *node) ...@@ -634,6 +634,11 @@ bool ShaderStorageBlockOutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
break; break;
} }
case EOpIndexDirectInterfaceBlock: case EOpIndexDirectInterfaceBlock:
if (!IsInShaderStorageBlock(node->getLeft()))
{
return mOutputHLSL->visitBinary(visit, node);
}
if (visit == InVisit) if (visit == InVisit)
{ {
ASSERT(IsInShaderStorageBlock(node->getLeft())); ASSERT(IsInShaderStorageBlock(node->getLeft()));
......
...@@ -2043,6 +2043,35 @@ void main() ...@@ -2043,6 +2043,35 @@ void main()
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Test that uniform can be used as the index of buffer variable.
TEST_P(ShaderStorageBufferTest31, UniformUsedAsIndexOfBufferVariable)
{
constexpr char kComputeShaderSource[] =
R"(#version 310 es
layout (local_size_x=4) in;
layout(std140, binding = 0) uniform CB
{
uint index;
} cb;
layout(binding=0, std140) buffer Storage0
{
uint data[];
} sb_load;
layout(binding=1, std140) buffer Storage1
{
uint data[];
} sb_store;
void main()
{
sb_store.data[gl_LocalInvocationIndex] = sb_load.data[gl_LocalInvocationID.x + cb.index];
}
)";
ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);
EXPECT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST(ShaderStorageBufferTest31, ES31_OPENGL(), ES31_OPENGLES(), ES31_D3D11()); ANGLE_INSTANTIATE_TEST(ShaderStorageBufferTest31, ES31_OPENGL(), ES31_OPENGLES(), ES31_D3D11());
} // namespace } // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment