Commit b717952e by Jamie Madill Committed by Commit Bot

Vulkan: Use packed enum map for descriptor set index.

This simplifies a lot of the data structure indexing in the program executable class. Also renames the "DriverUniforms" and "InternalShader" index into a single "Internal" index. Bug: angleproject:5736 Change-Id: I2a51d8b14d5b16b438dbe636f77b11bbc045ba9a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2773321 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 1b08cfcb
......@@ -3942,7 +3942,7 @@ void ContextVk::invalidateComputePipelineBinding()
void ContextVk::invalidateGraphicsDescriptorSet(DescriptorSetIndex usedDescriptorSet)
{
// UtilsVk currently only uses set 0
ASSERT(usedDescriptorSet == DescriptorSetIndex::DriverUniforms);
ASSERT(usedDescriptorSet == DescriptorSetIndex::Internal);
if (mDriverUniforms[PipelineType::Graphics].descriptorSet != VK_NULL_HANDLE)
{
mGraphicsDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
......@@ -3952,7 +3952,7 @@ void ContextVk::invalidateGraphicsDescriptorSet(DescriptorSetIndex usedDescripto
void ContextVk::invalidateComputeDescriptorSet(DescriptorSetIndex usedDescriptorSet)
{
// UtilsVk currently only uses set 0
ASSERT(usedDescriptorSet == DescriptorSetIndex::DriverUniforms);
ASSERT(usedDescriptorSet == DescriptorSetIndex::Internal);
if (mDriverUniforms[PipelineType::Compute].descriptorSet != VK_NULL_HANDLE)
{
mComputeDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
......@@ -4355,7 +4355,7 @@ void ContextVk::handleDirtyDriverUniformsBindingImpl(vk::CommandBuffer *commandB
}
commandBuffer->bindDescriptorSets(
mExecutable->getPipelineLayout(), bindPoint, DescriptorSetIndex::DriverUniforms, 1,
mExecutable->getPipelineLayout(), bindPoint, DescriptorSetIndex::Internal, 1,
&driverUniforms->descriptorSet, 1, &driverUniforms->dynamicOffset);
}
......
......@@ -51,7 +51,7 @@ void GlslangWrapperVk::ResetGlslangProgramInterfaceInfo(
ToUnderlying(DescriptorSetIndex::ShaderResource);
glslangProgramInterfaceInfo->currentShaderResourceBindingIndex = 0;
glslangProgramInterfaceInfo->driverUniformsDescriptorSetIndex =
ToUnderlying(DescriptorSetIndex::DriverUniforms);
ToUnderlying(DescriptorSetIndex::Internal);
glslangProgramInterfaceInfo->locationsUsedForXfbExtension = 0;
}
......
......@@ -102,7 +102,7 @@ struct DefaultUniformBlock final : private angle::NonCopyable
};
// Performance and resource counters.
using DescriptorSetCountList = std::array<uint32_t, DescriptorSetIndex::EnumCount>;
using DescriptorSetCountList = angle::PackedEnumMap<DescriptorSetIndex, uint32_t>;
struct ProgramExecutablePerfCounters
{
......
......@@ -124,12 +124,6 @@ class ProgramVk : public ProgramImpl
}
void onProgramBind();
// Used in testing only.
vk::DynamicDescriptorPool *getDynamicDescriptorPool(uint32_t poolIndex)
{
return &mExecutable.mDynamicDescriptorPools[poolIndex];
}
const ProgramExecutableVk &getExecutable() const { return mExecutable; }
ProgramExecutableVk &getExecutable() { return mExecutable; }
......
......@@ -17,12 +17,10 @@
namespace rx
{
enum DescriptorSetIndex : uint32_t;
enum class DescriptorSetIndex : uint32_t;
namespace vk
{
namespace priv
{
......
......@@ -666,7 +666,7 @@ void InsertInputDecorations(spirv::IdRef id,
angle::spirv::Blob *blobOut)
{
spirv::WriteDecorate(blobOut, id, spv::DecorationDescriptorSet,
{spirv::LiteralInteger(DescriptorSetIndex::InternalShader)});
{spirv::LiteralInteger(ToUnderlying(DescriptorSetIndex::Internal))});
spirv::WriteDecorate(blobOut, id, spv::DecorationBinding, {spirv::LiteralInteger(binding)});
spirv::WriteDecorate(blobOut, id, spv::DecorationInputAttachmentIndex,
{spirv::LiteralInteger(attachmentIndex)});
......@@ -1129,7 +1129,7 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *contextVk,
ANGLE_TRY(contextVk->getDescriptorSetLayoutCache().getDescriptorSetLayout(
contextVk, descriptorSetDesc,
&mDescriptorSetLayouts[function][ToUnderlying(DescriptorSetIndex::InternalShader)]));
&mDescriptorSetLayouts[function][DescriptorSetIndex::Internal]));
vk::DescriptorSetLayoutBindingVector bindingVector;
std::vector<VkSampler> immutableSamplers;
......@@ -1151,9 +1151,7 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *contextVk,
{
ANGLE_TRY(mDescriptorPools[function].init(
contextVk, descriptorPoolSizes.data(), descriptorPoolSizes.size(),
mDescriptorSetLayouts[function][ToUnderlying(DescriptorSetIndex::InternalShader)]
.get()
.getHandle()));
mDescriptorSetLayouts[function][DescriptorSetIndex::Internal].get().getHandle()));
}
gl::ShaderType pushConstantsShaderStage =
......@@ -1162,8 +1160,7 @@ angle::Result UtilsVk::ensureResourcesInitialized(ContextVk *contextVk,
// Corresponding pipeline layouts:
vk::PipelineLayoutDesc pipelineLayoutDesc;
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::InternalShader,
descriptorSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::Internal, descriptorSetDesc);
if (pushConstantsSize)
{
pipelineLayoutDesc.updatePushConstantRange(pushConstantsShaderStage, 0,
......@@ -1496,15 +1493,15 @@ angle::Result UtilsVk::setupProgram(ContextVk *contextVk,
if (descriptorSet != VK_NULL_HANDLE)
{
commandBuffer->bindDescriptorSets(pipelineLayout.get(), pipelineBindPoint,
DescriptorSetIndex::InternalShader, 1, &descriptorSet, 0,
DescriptorSetIndex::Internal, 1, &descriptorSet, 0,
nullptr);
if (isCompute)
{
contextVk->invalidateComputeDescriptorSet(DescriptorSetIndex::InternalShader);
contextVk->invalidateComputeDescriptorSet(DescriptorSetIndex::Internal);
}
else
{
contextVk->invalidateGraphicsDescriptorSet(DescriptorSetIndex::InternalShader);
contextVk->invalidateGraphicsDescriptorSet(DescriptorSetIndex::Internal);
}
}
......@@ -3440,11 +3437,8 @@ angle::Result UtilsVk::allocateDescriptorSet(ContextVk *contextVk,
VkDescriptorSet *descriptorSetOut)
{
ANGLE_TRY(mDescriptorPools[function].allocateSets(
contextVk,
mDescriptorSetLayouts[function][ToUnderlying(DescriptorSetIndex::InternalShader)]
.get()
.ptr(),
1, bindingOut, descriptorSetOut));
contextVk, mDescriptorSetLayouts[function][DescriptorSetIndex::Internal].get().ptr(), 1,
bindingOut, descriptorSetOut));
mObjectPerfCounters.descriptorSetsAllocated++;
......
......@@ -2879,8 +2879,7 @@ bool PipelineLayoutDesc::operator==(const PipelineLayoutDesc &other) const
void PipelineLayoutDesc::updateDescriptorSetLayout(DescriptorSetIndex setIndex,
const DescriptorSetLayoutDesc &desc)
{
ASSERT(ToUnderlying(setIndex) < mDescriptorSetLayouts.size());
mDescriptorSetLayouts[ToUnderlying(setIndex)] = desc;
mDescriptorSetLayouts[setIndex] = desc;
}
void PipelineLayoutDesc::updatePushConstantRange(gl::ShaderType shaderType,
......
......@@ -35,16 +35,12 @@ namespace rx
// - Set 3 contains all other shader resources, such as uniform and storage blocks, atomic counter
// buffers, images and image buffers.
// ANGLE driver uniforms set index (binding is always 0):
enum DescriptorSetIndex : uint32_t
enum class DescriptorSetIndex : uint32_t
{
// All internal shaders assume there is only one descriptor set, indexed at 0
InternalShader = 0,
DriverUniforms = 0, // ANGLE driver uniforms set index
UniformsAndXfb, // Uniforms set index
Texture, // Textures set index
ShaderResource, // Other shader resources set index
Internal, // ANGLE driver uniforms or internal shaders
UniformsAndXfb, // Uniforms set index
Texture, // Textures set index
ShaderResource, // Other shader resources set index
InvalidEnum,
EnumCount = InvalidEnum,
......@@ -839,7 +835,7 @@ struct PackedPushConstantRange
};
template <typename T>
using DescriptorSetLayoutArray = std::array<T, static_cast<size_t>(DescriptorSetIndex::EnumCount)>;
using DescriptorSetLayoutArray = angle::PackedEnumMap<DescriptorSetIndex, T>;
using DescriptorSetLayoutPointerArray =
DescriptorSetLayoutArray<BindingPointer<DescriptorSetLayout>>;
template <typename T>
......
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