Add compute program compilation and linking support
Compute shaders can be now compiled and linked to create programs.
Some tests are added to verify successful and unsuccessful compute
shader linking.
The patch also replaces std::array<int, 3> with a custom struct
WorkGroupSize.
BUG=angleproject:1442
TEST=angle_end2end_tests
TEST=angle_unittests
Change-Id: I4ab0ac05755d0167a6d2a798f8d7f1516cf54d84
Reviewed-on: https://chromium-review.googlesource.com/366740
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/Shader.cpp b/src/libANGLE/Shader.cpp
index bf0f742..904345d 100644
--- a/src/libANGLE/Shader.cpp
+++ b/src/libANGLE/Shader.cpp
@@ -75,6 +75,7 @@
ShaderState::ShaderState(GLenum shaderType) : mLabel(), mShaderType(shaderType), mShaderVersion(100)
{
+ mLocalSize.fill(-1);
}
ShaderState::~ShaderState()
@@ -306,18 +307,28 @@
mState.mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle));
mState.mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle));
- if (mState.mShaderType == GL_VERTEX_SHADER)
+ switch (mState.mShaderType)
{
- mState.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle));
- }
- else
- {
- ASSERT(mState.mShaderType == GL_FRAGMENT_SHADER);
-
- // TODO(jmadill): Figure out why we only sort in the FS, and if we need to.
- std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar);
- mState.mActiveOutputVariables =
- GetActiveShaderVariables(ShGetOutputVariables(compilerHandle));
+ case GL_COMPUTE_SHADER:
+ {
+ mState.mLocalSize = ShGetComputeShaderLocalGroupSize(compilerHandle);
+ break;
+ }
+ case GL_VERTEX_SHADER:
+ {
+ mState.mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle));
+ break;
+ }
+ case GL_FRAGMENT_SHADER:
+ {
+ // TODO(jmadill): Figure out why we only sort in the FS, and if we need to.
+ std::sort(mState.mVaryings.begin(), mState.mVaryings.end(), CompareShaderVar);
+ mState.mActiveOutputVariables =
+ GetActiveShaderVariables(ShGetOutputVariables(compilerHandle));
+ break;
+ }
+ default:
+ UNREACHABLE();
}
ASSERT(!mState.mTranslatedSource.empty());