Commit 19603b9e by Qin Jiajia Committed by Commit Bot

ES31: Allow function call, unary, ternary operators in SSBO

When we meet function call, unary or ternary operator in SSBO access chain, we should transfer the process of them to OutputHLSL. Bug: angleproject:1951 Change-Id: I740940ac4eee4c5ed52239f14b1d32b1f9cf9385 Reviewed-on: https://chromium-review.googlesource.com/c/1290470Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jiajia Qin <jiajia.qin@intel.com>
parent 5a206950
...@@ -221,8 +221,22 @@ void ShaderStorageBlockOutputHLSL::visitSymbol(TIntermSymbol *node) ...@@ -221,8 +221,22 @@ void ShaderStorageBlockOutputHLSL::visitSymbol(TIntermSymbol *node)
void ShaderStorageBlockOutputHLSL::visitConstantUnion(TIntermConstantUnion *node) void ShaderStorageBlockOutputHLSL::visitConstantUnion(TIntermConstantUnion *node)
{ {
TInfoSinkBase &out = mOutputHLSL->getInfoSink(); mOutputHLSL->visitConstantUnion(node);
mOutputHLSL->writeConstantUnion(out, node->getType(), node->getConstantValue()); }
bool ShaderStorageBlockOutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
return mOutputHLSL->visitAggregate(visit, node);
}
bool ShaderStorageBlockOutputHLSL::visitTernary(Visit visit, TIntermTernary *node)
{
return mOutputHLSL->visitTernary(visit, node);
}
bool ShaderStorageBlockOutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
{
return mOutputHLSL->visitUnary(visit, node);
} }
bool ShaderStorageBlockOutputHLSL::visitSwizzle(Visit visit, TIntermSwizzle *node) bool ShaderStorageBlockOutputHLSL::visitSwizzle(Visit visit, TIntermSwizzle *node)
......
...@@ -53,6 +53,9 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser ...@@ -53,6 +53,9 @@ class ShaderStorageBlockOutputHLSL : public TIntermTraverser
void visitConstantUnion(TIntermConstantUnion *) override; void visitConstantUnion(TIntermConstantUnion *) override;
bool visitSwizzle(Visit visit, TIntermSwizzle *node) override; bool visitSwizzle(Visit visit, TIntermSwizzle *node) override;
bool visitBinary(Visit visit, TIntermBinary *) override; bool visitBinary(Visit visit, TIntermBinary *) override;
bool visitAggregate(Visit visit, TIntermAggregate *node) override;
bool visitTernary(Visit visit, TIntermTernary *) override;
bool visitUnary(Visit visit, TIntermUnary *) override;
private: private:
void traverseSSBOAccess(TIntermTyped *node, SSBOMethod method); void traverseSSBOAccess(TIntermTyped *node, SSBOMethod method);
......
...@@ -462,6 +462,75 @@ TEST_P(ShaderStorageBufferTest31, MultiStorageBuffersForMultiPrograms) ...@@ -462,6 +462,75 @@ TEST_P(ShaderStorageBufferTest31, MultiStorageBuffersForMultiPrograms)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Test that function calling is supported in SSBO access chain.
TEST_P(ShaderStorageBufferTest31, FunctionCallInSSBOAccessChain)
{
constexpr char kComputeShaderSource[] =
R"(#version 310 es
layout (local_size_x=4) in;
highp uint getIndex (in highp uvec2 localID, uint element)
{
return localID.x + element;
}
layout(binding=0, std430) buffer Storage
{
highp uint values[];
} sb_store;
void main()
{
sb_store.values[getIndex(gl_LocalInvocationID.xy, 0u)] = gl_LocalInvocationIndex;
}
)";
ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);
EXPECT_GL_NO_ERROR();
}
// Test that unary operator is supported in SSBO access chain.
TEST_P(ShaderStorageBufferTest31, UnaryOperatorInSSBOAccessChain)
{
constexpr char kComputeShaderSource[] =
R"(#version 310 es
layout (local_size_x=4) in;
layout(binding=0, std430) buffer Storage
{
highp uint values[];
} sb_store;
void main()
{
uint invocationNdx = gl_LocalInvocationIndex;
sb_store.values[++invocationNdx] = invocationNdx;
}
)";
ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);
EXPECT_GL_NO_ERROR();
}
// Test that ternary operator is supported in SSBO access chain.
TEST_P(ShaderStorageBufferTest31, TernaryOperatorInSSBOAccessChain)
{
constexpr char kComputeShaderSource[] =
R"(#version 310 es
layout (local_size_x=4) in;
layout(binding=0, std430) buffer Storage
{
highp uint values[];
} sb_store;
void main()
{
sb_store.values[gl_LocalInvocationIndex > 2u ? gl_NumWorkGroups.x : gl_NumWorkGroups.y]
= gl_LocalInvocationIndex;
}
)";
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