Commit c5c096aa by Tim Van Patten Committed by Commit Bot

Enable Compute Shader Program Input Queries

Compute shader inputs were not being tracked in the Shader or Program states, causing program interface queries to fail. This change treats compute shader inputs (all built-ins) as Attributes and pipes them through from the Compiler to the Program to enable input queries. While compute shader inputs are not technically attributes (or varyings), the ANGLE code understands and handles attributes and a program can never have both a vertex and compute shader, so there can't be any conflicts. The naming of these variable lists should probabaly be revisited at some point to better handle these different use-cases. Bug: angleproject:3596 Test: dEQP-GLES31.functional.program_interface_query.program_input.resource_list.compute.empty Change-Id: Ie52cd59041868cfdb5d3d759bb4ec53c8d5b38d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1919557Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 6fcc0bb8
......@@ -168,6 +168,13 @@ class CollectVariablesTraverser : public TIntermTraverser
// Shader uniforms
bool mDepthRangeAdded;
// Compute Shader builtins
bool mNumWorkGroupsAdded;
bool mWorkGroupIDAdded;
bool mLocalInvocationIDAdded;
bool mGlobalInvocationIDAdded;
bool mLocalInvocationIndexAdded;
// Vertex Shader builtins
bool mInstanceIDAdded;
bool mVertexIDAdded;
......@@ -230,6 +237,11 @@ CollectVariablesTraverser::CollectVariablesTraverser(
mShaderStorageBlocks(shaderStorageBlocks),
mInBlocks(inBlocks),
mDepthRangeAdded(false),
mNumWorkGroupsAdded(false),
mWorkGroupIDAdded(false),
mLocalInvocationIDAdded(false),
mGlobalInvocationIDAdded(false),
mLocalInvocationIndexAdded(false),
mInstanceIDAdded(false),
mVertexIDAdded(false),
mPointSizeAdded(false),
......@@ -478,6 +490,21 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
case EvqPointCoord:
recordBuiltInVaryingUsed(symbol->variable(), &mPointCoordAdded, mInputVaryings);
return;
case EvqNumWorkGroups:
recordBuiltInAttributeUsed(symbol->variable(), &mNumWorkGroupsAdded);
return;
case EvqWorkGroupID:
recordBuiltInAttributeUsed(symbol->variable(), &mWorkGroupIDAdded);
return;
case EvqLocalInvocationID:
recordBuiltInAttributeUsed(symbol->variable(), &mLocalInvocationIDAdded);
return;
case EvqGlobalInvocationID:
recordBuiltInAttributeUsed(symbol->variable(), &mGlobalInvocationIDAdded);
return;
case EvqLocalInvocationIndex:
recordBuiltInAttributeUsed(symbol->variable(), &mLocalInvocationIndexAdded);
return;
case EvqInstanceID:
// Whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is set,
// gl_InstanceID is added inside expressions to initialize ViewID_OVR and
......
......@@ -1768,21 +1768,39 @@ void ProgramState::updateProgramInterfaceInputs()
ASSERT(shader);
// Copy over each input varying, since the Shader could go away
for (const sh::ShaderVariable &varying : shader->getInputVaryings())
if (shader->getType() == ShaderType::Compute)
{
if (varying.isStruct())
for (const sh::ShaderVariable &attribute : shader->getAllAttributes())
{
for (const sh::ShaderVariable &field : varying.fields)
{
sh::ShaderVariable fieldVarying = sh::ShaderVariable(field);
fieldVarying.location = varying.location;
fieldVarying.name = varying.name + "." + field.name;
mProgramInputs.emplace_back(fieldVarying);
}
// Compute Shaders have the following built-in input variables.
//
// in uvec3 gl_NumWorkGroups;
// in uvec3 gl_WorkGroupID;
// in uvec3 gl_LocalInvocationID;
// in uvec3 gl_GlobalInvocationID;
// in uint gl_LocalInvocationIndex;
// They are all vecs or uints, so no special handling is required.
mProgramInputs.emplace_back(attribute);
}
else
}
else if (shader->getType() == ShaderType::Fragment)
{
for (const sh::ShaderVariable &varying : shader->getInputVaryings())
{
mProgramInputs.emplace_back(varying);
if (varying.isStruct())
{
for (const sh::ShaderVariable &field : varying.fields)
{
sh::ShaderVariable fieldVarying = sh::ShaderVariable(field);
fieldVarying.location = varying.location;
fieldVarying.name = varying.name + "." + field.name;
mProgramInputs.emplace_back(fieldVarying);
}
}
else
{
mProgramInputs.emplace_back(varying);
}
}
}
}
......
......@@ -433,7 +433,9 @@ void Shader::resolveCompile()
{
case ShaderType::Compute:
{
mState.mLocalSize = sh::GetComputeShaderLocalGroupSize(compilerHandle);
mState.mAllAttributes = GetShaderVariables(sh::GetAttributes(compilerHandle));
mState.mActiveAttributes = GetActiveShaderVariables(&mState.mAllAttributes);
mState.mLocalSize = sh::GetComputeShaderLocalGroupSize(compilerHandle);
if (mState.mLocalSize.isDeclared())
{
angle::CheckedNumeric<uint32_t> checked_local_size_product(mState.mLocalSize[0]);
......
......@@ -625,7 +625,6 @@
// General Vulkan failures
// Front-end query bugs:
3596 VULKAN : dEQP-GLES31.functional.program_interface_query.program_input.resource_list.compute.empty = FAIL
3596 VULKAN : dEQP-GLES31.functional.program_interface_query.shader_storage_block.buffer_data_size.* = FAIL
// Shader support:
......
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