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