Commit 01e8b675 by Shahbaz Youssefi Committed by Commit Bot

Fix ordering of stages in gl::ShaderType

When iterating over a bitset of stages, they are now processed in the same order as the rendering pipeline. Bug: angleproject:5405 Change-Id: If9e0f24be047b060f759e0e1db622a91e24e9646 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2564008Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 619ae003
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
"src/common/PackedEGLEnums_autogen.h": "src/common/PackedEGLEnums_autogen.h":
"085d82d2003f02345abc4986523127d4", "085d82d2003f02345abc4986523127d4",
"src/common/PackedGLEnums_autogen.cpp": "src/common/PackedGLEnums_autogen.cpp":
"1e1f2629f8212723659bb58bb0973968", "d466b72e054f7a4b15dc033b0a10d3a0",
"src/common/PackedGLEnums_autogen.h": "src/common/PackedGLEnums_autogen.h":
"6f731e9c90cbfc06d6193431ab4e2e11", "432cef0647efc392813438f486991f1f",
"src/common/gen_packed_gl_enums.py": "src/common/gen_packed_gl_enums.py":
"b3e96ea44f52ec23ee893bd843dfd2cb", "b3e96ea44f52ec23ee893bd843dfd2cb",
"src/common/packed_egl_enums.json": "src/common/packed_egl_enums.json":
"76e1b814421e121164d60a0d89cb16c1", "76e1b814421e121164d60a0d89cb16c1",
"src/common/packed_gl_enums.json": "src/common/packed_gl_enums.json":
"a9ad05af71f6c8378147dc5e41728822" "5e9956ad129fc6f2ed4ce5b8a094f157"
} }
\ No newline at end of file
...@@ -187,15 +187,8 @@ struct AllCubeFaceTextureTargets ...@@ -187,15 +187,8 @@ struct AllCubeFaceTextureTargets
angle::EnumIterator<TextureTarget> end() const { return kAfterCubeMapTextureTargetMax; } angle::EnumIterator<TextureTarget> end() const { return kAfterCubeMapTextureTargetMax; }
}; };
constexpr ShaderType kGLES2ShaderTypeMin = ShaderType::Vertex; constexpr std::array<ShaderType, 2> kAllGLES2ShaderTypes = {ShaderType::Vertex,
constexpr ShaderType kGLES2ShaderTypeMax = ShaderType::Fragment; ShaderType::Fragment};
constexpr ShaderType kAfterGLES2ShaderTypeMax =
static_cast<ShaderType>(static_cast<uint8_t>(kGLES2ShaderTypeMax) + 1);
struct AllGLES2ShaderTypes
{
angle::EnumIterator<ShaderType> begin() const { return kGLES2ShaderTypeMin; }
angle::EnumIterator<ShaderType> end() const { return kAfterGLES2ShaderTypeMax; }
};
constexpr ShaderType kShaderTypeMin = ShaderType::Vertex; constexpr ShaderType kShaderTypeMin = ShaderType::Vertex;
constexpr ShaderType kShaderTypeMax = ShaderType::Compute; constexpr ShaderType kShaderTypeMax = ShaderType::Compute;
......
...@@ -1392,14 +1392,14 @@ ShaderType FromGLenum<ShaderType>(GLenum from) ...@@ -1392,14 +1392,14 @@ ShaderType FromGLenum<ShaderType>(GLenum from)
{ {
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
return ShaderType::Vertex; return ShaderType::Vertex;
case GL_FRAGMENT_SHADER:
return ShaderType::Fragment;
case GL_GEOMETRY_SHADER_EXT:
return ShaderType::Geometry;
case GL_TESS_CONTROL_SHADER_EXT: case GL_TESS_CONTROL_SHADER_EXT:
return ShaderType::TessControl; return ShaderType::TessControl;
case GL_TESS_EVALUATION_SHADER_EXT: case GL_TESS_EVALUATION_SHADER_EXT:
return ShaderType::TessEvaluation; return ShaderType::TessEvaluation;
case GL_GEOMETRY_SHADER_EXT:
return ShaderType::Geometry;
case GL_FRAGMENT_SHADER:
return ShaderType::Fragment;
case GL_COMPUTE_SHADER: case GL_COMPUTE_SHADER:
return ShaderType::Compute; return ShaderType::Compute;
default: default:
...@@ -1413,14 +1413,14 @@ GLenum ToGLenum(ShaderType from) ...@@ -1413,14 +1413,14 @@ GLenum ToGLenum(ShaderType from)
{ {
case ShaderType::Vertex: case ShaderType::Vertex:
return GL_VERTEX_SHADER; return GL_VERTEX_SHADER;
case ShaderType::Fragment:
return GL_FRAGMENT_SHADER;
case ShaderType::Geometry:
return GL_GEOMETRY_SHADER_EXT;
case ShaderType::TessControl: case ShaderType::TessControl:
return GL_TESS_CONTROL_SHADER_EXT; return GL_TESS_CONTROL_SHADER_EXT;
case ShaderType::TessEvaluation: case ShaderType::TessEvaluation:
return GL_TESS_EVALUATION_SHADER_EXT; return GL_TESS_EVALUATION_SHADER_EXT;
case ShaderType::Geometry:
return GL_GEOMETRY_SHADER_EXT;
case ShaderType::Fragment:
return GL_FRAGMENT_SHADER;
case ShaderType::Compute: case ShaderType::Compute:
return GL_COMPUTE_SHADER; return GL_COMPUTE_SHADER;
default: default:
...@@ -1436,18 +1436,18 @@ std::ostream &operator<<(std::ostream &os, ShaderType value) ...@@ -1436,18 +1436,18 @@ std::ostream &operator<<(std::ostream &os, ShaderType value)
case ShaderType::Vertex: case ShaderType::Vertex:
os << "GL_VERTEX_SHADER"; os << "GL_VERTEX_SHADER";
break; break;
case ShaderType::Fragment:
os << "GL_FRAGMENT_SHADER";
break;
case ShaderType::Geometry:
os << "GL_GEOMETRY_SHADER_EXT";
break;
case ShaderType::TessControl: case ShaderType::TessControl:
os << "GL_TESS_CONTROL_SHADER_EXT"; os << "GL_TESS_CONTROL_SHADER_EXT";
break; break;
case ShaderType::TessEvaluation: case ShaderType::TessEvaluation:
os << "GL_TESS_EVALUATION_SHADER_EXT"; os << "GL_TESS_EVALUATION_SHADER_EXT";
break; break;
case ShaderType::Geometry:
os << "GL_GEOMETRY_SHADER_EXT";
break;
case ShaderType::Fragment:
os << "GL_FRAGMENT_SHADER";
break;
case ShaderType::Compute: case ShaderType::Compute:
os << "GL_COMPUTE_SHADER"; os << "GL_COMPUTE_SHADER";
break; break;
......
...@@ -360,10 +360,10 @@ std::ostream &operator<<(std::ostream &os, QueryType value); ...@@ -360,10 +360,10 @@ std::ostream &operator<<(std::ostream &os, QueryType value);
enum class ShaderType : uint8_t enum class ShaderType : uint8_t
{ {
Vertex = 0, Vertex = 0,
Fragment = 1, TessControl = 1,
Geometry = 2, TessEvaluation = 2,
TessControl = 3, Geometry = 3,
TessEvaluation = 4, Fragment = 4,
Compute = 5, Compute = 5,
InvalidEnum = 6, InvalidEnum = 6,
......
...@@ -110,10 +110,10 @@ ...@@ -110,10 +110,10 @@
"ShaderType": "ShaderType":
{ {
"Vertex": "GL_VERTEX_SHADER", "Vertex": "GL_VERTEX_SHADER",
"Fragment": "GL_FRAGMENT_SHADER",
"Geometry": "GL_GEOMETRY_SHADER_EXT",
"TessControl": "GL_TESS_CONTROL_SHADER_EXT", "TessControl": "GL_TESS_CONTROL_SHADER_EXT",
"TessEvaluation": "GL_TESS_EVALUATION_SHADER_EXT", "TessEvaluation": "GL_TESS_EVALUATION_SHADER_EXT",
"Geometry": "GL_GEOMETRY_SHADER_EXT",
"Fragment": "GL_FRAGMENT_SHADER",
"Compute": "GL_COMPUTE_SHADER" "Compute": "GL_COMPUTE_SHADER"
}, },
"ShadingModel": "ShadingModel":
......
...@@ -346,7 +346,7 @@ angle::Result ProgramMtl::linkImpl(const gl::Context *glContext, ...@@ -346,7 +346,7 @@ angle::Result ProgramMtl::linkImpl(const gl::Context *glContext,
&xfbOnlyShaderCodes[gl::ShaderType::Vertex], &xfbOnlyShaderCodes[gl::ShaderType::Vertex],
&mMslShaderTranslateInfo, &mMslXfbOnlyVertexShaderInfo)); &mMslShaderTranslateInfo, &mMslXfbOnlyVertexShaderInfo));
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
// Create actual Metal shader library // Create actual Metal shader library
ANGLE_TRY(createMslShaderLib(contextMtl, shaderType, infoLog, ANGLE_TRY(createMslShaderLib(contextMtl, shaderType, infoLog,
...@@ -373,7 +373,7 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext) ...@@ -373,7 +373,7 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext)
gl::ShaderMap<size_t> requiredBufferSize; gl::ShaderMap<size_t> requiredBufferSize;
requiredBufferSize.fill(0); requiredBufferSize.fill(0);
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
gl::Shader *shader = mState.getAttachedShader(shaderType); gl::Shader *shader = mState.getAttachedShader(shaderType);
if (shader) if (shader)
...@@ -406,7 +406,7 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext) ...@@ -406,7 +406,7 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext)
bool found = false; bool found = false;
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
auto it = layoutMap[shaderType].find(uniformName); auto it = layoutMap[shaderType].find(uniformName);
if (it != layoutMap[shaderType].end()) if (it != layoutMap[shaderType].end())
...@@ -420,13 +420,13 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext) ...@@ -420,13 +420,13 @@ angle::Result ProgramMtl::initDefaultUniformBlocks(const gl::Context *glContext)
} }
} }
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
mDefaultUniformBlocks[shaderType].uniformLayout.push_back(layoutInfo[shaderType]); mDefaultUniformBlocks[shaderType].uniformLayout.push_back(layoutInfo[shaderType]);
} }
} }
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
if (requiredBufferSize[shaderType] > 0) if (requiredBufferSize[shaderType] > 0)
{ {
...@@ -613,7 +613,7 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu ...@@ -613,7 +613,7 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu
if (linkedUniform.typeInfo->type == entryPointType) if (linkedUniform.typeInfo->type == entryPointType)
{ {
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType]; DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location]; const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
...@@ -632,7 +632,7 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu ...@@ -632,7 +632,7 @@ void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenu
} }
else else
{ {
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType]; DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location]; const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
...@@ -766,7 +766,7 @@ void ProgramMtl::setUniformMatrixfv(GLint location, ...@@ -766,7 +766,7 @@ void ProgramMtl::setUniformMatrixfv(GLint location,
const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location]; const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location];
const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index]; const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index];
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType]; DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location]; const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
...@@ -923,7 +923,7 @@ angle::Result ProgramMtl::setupDraw(const gl::Context *glContext, ...@@ -923,7 +923,7 @@ angle::Result ProgramMtl::setupDraw(const gl::Context *glContext,
angle::Result ProgramMtl::commitUniforms(ContextMtl *context, mtl::RenderCommandEncoder *cmdEncoder) angle::Result ProgramMtl::commitUniforms(ContextMtl *context, mtl::RenderCommandEncoder *cmdEncoder)
{ {
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
if (!mDefaultUniformBlocksDirty[shaderType] || !mCurrentShaderVariants[shaderType]) if (!mDefaultUniformBlocksDirty[shaderType] || !mCurrentShaderVariants[shaderType])
{ {
...@@ -953,7 +953,7 @@ angle::Result ProgramMtl::updateTextures(const gl::Context *glContext, ...@@ -953,7 +953,7 @@ angle::Result ProgramMtl::updateTextures(const gl::Context *glContext,
const gl::ActiveTexturesCache &completeTextures = glState.getActiveTexturesCache(); const gl::ActiveTexturesCache &completeTextures = glState.getActiveTexturesCache();
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
if ((!mSamplerBindingsDirty[shaderType] && !forceUpdate) || if ((!mSamplerBindingsDirty[shaderType] && !forceUpdate) ||
!mCurrentShaderVariants[shaderType]) !mCurrentShaderVariants[shaderType])
...@@ -1038,7 +1038,7 @@ angle::Result ProgramMtl::updateUniformBuffers(ContextMtl *context, ...@@ -1038,7 +1038,7 @@ angle::Result ProgramMtl::updateUniformBuffers(ContextMtl *context,
const gl::State &glState = context->getState(); const gl::State &glState = context->getState();
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
if (!mCurrentShaderVariants[shaderType]) if (!mCurrentShaderVariants[shaderType])
{ {
...@@ -1199,12 +1199,12 @@ angle::Result ProgramMtl::encodeUniformBuffersInfoArgumentBuffer( ...@@ -1199,12 +1199,12 @@ angle::Result ProgramMtl::encodeUniformBuffersInfoArgumentBuffer(
[bufferEncoder.metalArgBufferEncoder setArgumentBuffer:argumentBuffer->get() [bufferEncoder.metalArgBufferEncoder setArgumentBuffer:argumentBuffer->get()
offset:argumentBufferOffset]; offset:argumentBufferOffset];
static_assert(MTLRenderStageVertex == (0x1 << static_cast<uint32_t>(gl::ShaderType::Vertex)), constexpr gl::ShaderMap<MTLRenderStages> kShaderStageMap = {
"Expected gl ShaderType enum and Metal enum to relative to each other"); {gl::ShaderType::Vertex, mtl::kRenderStageVertex},
static_assert( {gl::ShaderType::Fragment, mtl::kRenderStageFragment},
MTLRenderStageFragment == (0x1 << static_cast<uint32_t>(gl::ShaderType::Fragment)), };
"Expected gl ShaderType enum and Metal enum to relative to each other");
auto mtlRenderStage = static_cast<MTLRenderStages>(0x1 << static_cast<uint32_t>(shaderType)); auto mtlRenderStage = kShaderStageMap[shaderType];
for (uint32_t bufferIndex = 0; bufferIndex < blocks.size(); ++bufferIndex) for (uint32_t bufferIndex = 0; bufferIndex < blocks.size(); ++bufferIndex)
{ {
......
...@@ -515,7 +515,7 @@ angle::Result SpirvCodeToMsl(Context *context, ...@@ -515,7 +515,7 @@ angle::Result SpirvCodeToMsl(Context *context,
} }
// Do the actual translation // Do the actual translation
for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes()) for (gl::ShaderType shaderType : gl::kAllGLES2ShaderTypes)
{ {
std::vector<uint32_t> &sprivCode = spirvShaderCode->at(shaderType); std::vector<uint32_t> &sprivCode = spirvShaderCode->at(shaderType);
ANGLE_TRY(ConvertSpirvToMsl(context, shaderType, uboOriginalBindings, xfbOriginalBindings, ANGLE_TRY(ConvertSpirvToMsl(context, shaderType, uboOriginalBindings, xfbOriginalBindings,
......
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