Commit df066e9c by Shahbaz Youssefi Committed by Commit Bot

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/1333970Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent efe061bd
......@@ -354,14 +354,13 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
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 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
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 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
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 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
}
}
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 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
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 @@ void ProgramVk::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum
}
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 @@ void ProgramVk::getUniformImpl(GLint location, T *v, GLenum entryPointType) cons
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 @@ void ProgramVk::setUniformMatrixfv(GLint location,
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 @@ angle::Result ProgramVk::updateUniforms(ContextVk *contextVk)
// 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::updateUniforms(ContextVk *contextVk)
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 @@ angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk,
// 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
{
......
......@@ -167,9 +167,9 @@ class ProgramVk : public ProgramImpl
std::vector<sh::BlockMemberInfo> uniformLayout;
};
vk::ShaderMap<DefaultUniformBlock> mDefaultUniformBlocks;
vk::ShaderBitSet mDefaultUniformBlocksDirty;
vk::ShaderMap<uint32_t> mUniformBlocksOffsets;
gl::ShaderMap<DefaultUniformBlock> mDefaultUniformBlocks;
gl::ShaderBitSet mDefaultUniformBlocksDirty;
gl::ShaderMap<uint32_t> mUniformBlocksOffsets;
// This is a special "empty" placeholder buffer for when a shader has no uniforms.
// It is necessary because we want to keep a compatible pipeline layout in all cases,
......
......@@ -743,22 +743,6 @@ angle::Result AllocateImageMemory(vk::Context *context,
using ShaderAndSerial = ObjectAndSerial<ShaderModule>;
// TODO(jmadill): Use gl::ShaderType when possible. http://anglebug.com/2522
enum class ShaderType
{
VertexShader,
FragmentShader,
EnumCount,
InvalidEnum = EnumCount,
};
template <typename T>
using ShaderMap = angle::PackedEnumMap<ShaderType, T>;
using ShaderBitSet = angle::PackedEnumBitSet<ShaderType>;
using AllShaderTypes = angle::AllEnums<vk::ShaderType>;
angle::Result InitShaderAndSerial(Context *context,
ShaderAndSerial *shaderAndSerial,
const uint32_t *shaderCode,
......
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