Vulkan: Remove vk::ShaderType
Use gl::ShaderType instead. For now, only GLES2 shaders are supported
in ProgramVk.
Bug: angleproject:2522
Change-Id: I17bc9afddb6d39cf45fb4dd37f34c7263a3ed515
Reviewed-on: https://chromium-review.googlesource.com/c/1333970
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/ProgramVk.cpp b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
index 2845d08..a40ae69 100644
--- a/src/libANGLE/renderer/vulkan/ProgramVk.cpp
+++ b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
@@ -354,14 +354,13 @@
RendererVk *renderer = contextVk->getRenderer();
// Process vertex and fragment uniforms into std140 packing.
- vk::ShaderMap<sh::BlockLayoutMap> layoutMap;
- vk::ShaderMap<size_t> requiredBufferSize;
+ gl::ShaderMap<sh::BlockLayoutMap> layoutMap;
+ gl::ShaderMap<size_t> requiredBufferSize;
requiredBufferSize.fill(0);
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
- gl::ShaderType glShaderType = static_cast<gl::ShaderType>(shaderType);
- gl::Shader *shader = mState.getAttachedShader(glShaderType);
+ gl::Shader *shader = mState.getAttachedShader(shaderType);
const std::vector<sh::Uniform> &uniforms = shader->getUniforms();
InitDefaultUniformBlock(uniforms, shader, &layoutMap[shaderType],
&requiredBufferSize[shaderType]);
@@ -371,7 +370,7 @@
const auto &uniforms = mState.getUniforms();
for (const gl::VariableLocation &location : mState.getUniformLocations())
{
- vk::ShaderMap<sh::BlockMemberInfo> layoutInfo;
+ gl::ShaderMap<sh::BlockMemberInfo> layoutInfo;
if (location.used() && !location.ignored)
{
@@ -387,7 +386,7 @@
bool found = false;
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
auto it = layoutMap[shaderType].find(uniformName);
if (it != layoutMap[shaderType].end())
@@ -401,13 +400,13 @@
}
}
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
mDefaultUniformBlocks[shaderType].uniformLayout.push_back(layoutInfo[shaderType]);
}
}
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
if (requiredBufferSize[shaderType] > 0)
{
@@ -478,7 +477,7 @@
if (linkedUniform.typeInfo->type == entryPointType)
{
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
@@ -497,7 +496,7 @@
}
else
{
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
@@ -543,8 +542,7 @@
const gl::ShaderType shaderType = linkedUniform.getFirstShaderTypeWhereActive();
ASSERT(shaderType != gl::ShaderType::InvalidEnum);
- const DefaultUniformBlock &uniformBlock =
- mDefaultUniformBlocks[static_cast<vk::ShaderType>(shaderType)];
+ const DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
ASSERT(linkedUniform.typeInfo->componentType == entryPointType ||
@@ -632,7 +630,7 @@
const gl::VariableLocation &locationInfo = mState.getUniformLocations()[location];
const gl::LinkedUniform &linkedUniform = mState.getUniforms()[locationInfo.index];
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
const sh::BlockMemberInfo &layoutInfo = uniformBlock.uniformLayout[location];
@@ -799,7 +797,7 @@
// Update buffer memory by immediate mapping. This immediate update only works once.
bool anyNewBufferAllocated = false;
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
@@ -831,10 +829,10 @@
angle::Result ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
{
- vk::ShaderMap<VkDescriptorBufferInfo> descriptorBufferInfo;
- vk::ShaderMap<VkWriteDescriptorSet> writeDescriptorInfo;
+ gl::ShaderMap<VkDescriptorBufferInfo> descriptorBufferInfo;
+ gl::ShaderMap<VkWriteDescriptorSet> writeDescriptorInfo;
- for (vk::ShaderType shaderType : vk::AllShaderTypes())
+ for (gl::ShaderType shaderType : gl::AllGLES2ShaderTypes())
{
DefaultUniformBlock &uniformBlock = mDefaultUniformBlocks[shaderType];
VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[shaderType];
@@ -953,10 +951,12 @@
// No uniforms descriptor set means no need to specify dynamic buffer offsets.
if (mUsedDescriptorSetRange.contains(kUniformsDescriptorSetIndex))
{
+ constexpr uint32_t kShaderTypeMin = static_cast<uint32_t>(gl::kGLES2ShaderTypeMin);
+ constexpr uint32_t kShaderTypeMax = static_cast<uint32_t>(gl::kGLES2ShaderTypeMax);
commandBuffer->bindDescriptorSets(
VK_PIPELINE_BIND_POINT_GRAPHICS, mPipelineLayout.get(), low,
mUsedDescriptorSetRange.length(), &mDescriptorSets[low],
- static_cast<uint32_t>(mUniformBlocksOffsets.size()), mUniformBlocksOffsets.data());
+ kShaderTypeMax - kShaderTypeMin + 1, mUniformBlocksOffsets.data() + kShaderTypeMin);
}
else
{