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;
}
......
......@@ -426,11 +426,11 @@ angle::Result ProgramExecutableVk::allocUniformAndXfbDescriptorSet(
VkDescriptorSet descriptorSet = VK_NULL_HANDLE;
if (mUniformsAndXfbDescriptorSetCache.get(xfbBufferDesc, &descriptorSet))
{
*newDescriptorSetAllocated = false;
mDescriptorSets[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)] = descriptorSet;
*newDescriptorSetAllocated = false;
mDescriptorSets[DescriptorSetIndex::UniformsAndXfb] = descriptorSet;
// The descriptor pool that this descriptor set was allocated from needs to be retained each
// time the descriptor set is used in a new command.
mDescriptorPoolBindings[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)].get().retain(
mDescriptorPoolBindings[DescriptorSetIndex::UniformsAndXfb].get().retain(
&contextVk->getResourceUseList());
return angle::Result::Continue;
}
......@@ -446,8 +446,8 @@ angle::Result ProgramExecutableVk::allocUniformAndXfbDescriptorSet(
}
// Add the descriptor set into cache
mUniformsAndXfbDescriptorSetCache.insert(
xfbBufferDesc, mDescriptorSets[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)]);
mUniformsAndXfbDescriptorSetCache.insert(xfbBufferDesc,
mDescriptorSets[DescriptorSetIndex::UniformsAndXfb]);
*newDescriptorSetAllocated = true;
return angle::Result::Continue;
......@@ -465,18 +465,16 @@ angle::Result ProgramExecutableVk::allocateDescriptorSetAndGetInfo(
DescriptorSetIndex descriptorSetIndex,
bool *newPoolAllocatedOut)
{
vk::DynamicDescriptorPool &dynamicDescriptorPool =
mDynamicDescriptorPools[ToUnderlying(descriptorSetIndex)];
vk::DynamicDescriptorPool &dynamicDescriptorPool = mDynamicDescriptorPools[descriptorSetIndex];
const vk::DescriptorSetLayout &descriptorSetLayout =
mDescriptorSetLayouts[ToUnderlying(descriptorSetIndex)].get();
mDescriptorSetLayouts[descriptorSetIndex].get();
ANGLE_TRY(dynamicDescriptorPool.allocateSetsAndGetInfo(
contextVk, descriptorSetLayout.ptr(), 1,
&mDescriptorPoolBindings[ToUnderlying(descriptorSetIndex)],
&mDescriptorSets[ToUnderlying(descriptorSetIndex)], newPoolAllocatedOut));
mEmptyDescriptorSets[ToUnderlying(descriptorSetIndex)] = VK_NULL_HANDLE;
contextVk, descriptorSetLayout.ptr(), 1, &mDescriptorPoolBindings[descriptorSetIndex],
&mDescriptorSets[descriptorSetIndex], newPoolAllocatedOut));
mEmptyDescriptorSets[descriptorSetIndex] = VK_NULL_HANDLE;
++mObjectPerfCounters.descriptorSetsAllocated[ToUnderlying(descriptorSetIndex)];
++mObjectPerfCounters.descriptorSetsAllocated[descriptorSetIndex];
return angle::Result::Continue;
}
......@@ -845,7 +843,7 @@ angle::Result ProgramExecutableVk::initDynamicDescriptorPools(
if (!descriptorPoolSizes.empty())
{
ANGLE_TRY(mDynamicDescriptorPools[ToUnderlying(descriptorSetIndex)].init(
ANGLE_TRY(mDynamicDescriptorPools[descriptorSetIndex].init(
contextVk, descriptorPoolSizes.data(), descriptorPoolSizes.size(),
descriptorSetLayout));
}
......@@ -904,7 +902,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
ANGLE_TRY(contextVk->getDescriptorSetLayoutCache().getDescriptorSetLayout(
contextVk, uniformsAndXfbSetDesc,
&mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)]));
&mDescriptorSetLayouts[DescriptorSetIndex::UniformsAndXfb]));
// Uniform and storage buffers, atomic counter buffers and images:
vk::DescriptorSetLayoutDesc resourcesSetDesc;
......@@ -932,8 +930,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
}
ANGLE_TRY(contextVk->getDescriptorSetLayoutCache().getDescriptorSetLayout(
contextVk, resourcesSetDesc,
&mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::ShaderResource)]));
contextVk, resourcesSetDesc, &mDescriptorSetLayouts[DescriptorSetIndex::ShaderResource]));
// Textures:
vk::DescriptorSetLayoutDesc texturesSetDesc;
......@@ -946,8 +943,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
}
ANGLE_TRY(contextVk->getDescriptorSetLayoutCache().getDescriptorSetLayout(
contextVk, texturesSetDesc,
&mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::Texture)]));
contextVk, texturesSetDesc, &mDescriptorSetLayouts[DescriptorSetIndex::Texture]));
// Driver uniforms:
VkShaderStageFlags driverUniformsStages =
......@@ -955,8 +951,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
vk::DescriptorSetLayoutDesc driverUniformsSetDesc =
contextVk->getDriverUniformsDescriptorSetDesc(driverUniformsStages);
ANGLE_TRY(contextVk->getDescriptorSetLayoutCache().getDescriptorSetLayout(
contextVk, driverUniformsSetDesc,
&mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::DriverUniforms)]));
contextVk, driverUniformsSetDesc, &mDescriptorSetLayouts[DescriptorSetIndex::Internal]));
// Create pipeline layout with these 4 descriptor sets.
vk::PipelineLayoutDesc pipelineLayoutDesc;
......@@ -965,7 +960,7 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::ShaderResource,
resourcesSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::Texture, texturesSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::DriverUniforms,
pipelineLayoutDesc.updateDescriptorSetLayout(DescriptorSetIndex::Internal,
driverUniformsSetDesc);
ANGLE_TRY(contextVk->getPipelineLayoutCache().getPipelineLayout(
......@@ -974,16 +969,16 @@ angle::Result ProgramExecutableVk::createPipelineLayout(
// Initialize descriptor pools.
ANGLE_TRY(initDynamicDescriptorPools(
contextVk, uniformsAndXfbSetDesc, DescriptorSetIndex::UniformsAndXfb,
mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)].get().getHandle()));
mDescriptorSetLayouts[DescriptorSetIndex::UniformsAndXfb].get().getHandle()));
ANGLE_TRY(initDynamicDescriptorPools(
contextVk, resourcesSetDesc, DescriptorSetIndex::ShaderResource,
mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::ShaderResource)].get().getHandle()));
mDescriptorSetLayouts[DescriptorSetIndex::ShaderResource].get().getHandle()));
ANGLE_TRY(initDynamicDescriptorPools(
contextVk, texturesSetDesc, DescriptorSetIndex::Texture,
mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::Texture)].get().getHandle()));
mDescriptorSetLayouts[DescriptorSetIndex::Texture].get().getHandle()));
ANGLE_TRY(initDynamicDescriptorPools(
contextVk, driverUniformsSetDesc, DescriptorSetIndex::DriverUniforms,
mDescriptorSetLayouts[ToUnderlying(DescriptorSetIndex::DriverUniforms)].get().getHandle()));
contextVk, driverUniformsSetDesc, DescriptorSetIndex::Internal,
mDescriptorSetLayouts[DescriptorSetIndex::Internal].get().getHandle()));
mDynamicBufferOffsets.resize(glExecutable.getLinkedShaderStageCount());
......@@ -1060,7 +1055,7 @@ void ProgramExecutableVk::updateDefaultUniformsDescriptorSet(
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = mDescriptorSets[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)];
writeInfo.dstSet = mDescriptorSets[DescriptorSetIndex::UniformsAndXfb];
writeInfo.dstBinding = info.binding;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
......@@ -1075,11 +1070,11 @@ angle::Result ProgramExecutableVk::getOrAllocateShaderResourcesDescriptorSet(
ContextVk *contextVk,
VkDescriptorSet *descriptorSetOut)
{
if (mDescriptorSets[ToUnderlying(DescriptorSetIndex::ShaderResource)] == VK_NULL_HANDLE)
if (mDescriptorSets[DescriptorSetIndex::ShaderResource] == VK_NULL_HANDLE)
{
ANGLE_TRY(allocateDescriptorSet(contextVk, DescriptorSetIndex::ShaderResource));
}
*descriptorSetOut = mDescriptorSets[ToUnderlying(DescriptorSetIndex::ShaderResource)];
*descriptorSetOut = mDescriptorSets[DescriptorSetIndex::ShaderResource];
ASSERT(*descriptorSetOut != VK_NULL_HANDLE);
return angle::Result::Continue;
}
......@@ -1395,8 +1390,8 @@ angle::Result ProgramExecutableVk::updateShaderResourcesDescriptorSet(
fillProgramStateMap(contextVk, &programStates);
// Reset the descriptor set handles so we only allocate a new one when necessary.
mDescriptorSets[ToUnderlying(DescriptorSetIndex::ShaderResource)] = VK_NULL_HANDLE;
mEmptyDescriptorSets[ToUnderlying(DescriptorSetIndex::ShaderResource)] = VK_NULL_HANDLE;
mDescriptorSets[DescriptorSetIndex::ShaderResource] = VK_NULL_HANDLE;
mEmptyDescriptorSets[DescriptorSetIndex::ShaderResource] = VK_NULL_HANDLE;
for (const gl::ShaderType shaderType : executable->getLinkedShaderStages())
{
......@@ -1524,15 +1519,14 @@ void ProgramExecutableVk::updateTransformFeedbackDescriptorSetImpl(
TransformFeedbackVk *transformFeedbackVk = vk::GetImpl(transformFeedback);
transformFeedbackVk->initDescriptorSet(
contextVk, mVariableInfoMap, executable.getTransformFeedbackBufferCount(),
mDescriptorSets[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)]);
mDescriptorSets[DescriptorSetIndex::UniformsAndXfb]);
}
return;
}
TransformFeedbackVk *transformFeedbackVk = vk::GetImpl(glState.getCurrentTransformFeedback());
transformFeedbackVk->updateDescriptorSet(
contextVk, programState, mVariableInfoMap,
mDescriptorSets[ToUnderlying(DescriptorSetIndex::UniformsAndXfb)]);
transformFeedbackVk->updateDescriptorSet(contextVk, programState, mVariableInfoMap,
mDescriptorSets[DescriptorSetIndex::UniformsAndXfb]);
}
angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(ContextVk *contextVk)
......@@ -1549,10 +1543,10 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(ContextVk *contex
VkDescriptorSet descriptorSet = VK_NULL_HANDLE;
if (mTextureDescriptorsCache.get(texturesDesc, &descriptorSet))
{
mDescriptorSets[ToUnderlying(DescriptorSetIndex::Texture)] = descriptorSet;
mDescriptorSets[DescriptorSetIndex::Texture] = descriptorSet;
// The descriptor pool that this descriptor set was allocated from needs to be retained each
// time the descriptor set is used in a new command.
mDescriptorPoolBindings[ToUnderlying(DescriptorSetIndex::Texture)].get().retain(
mDescriptorPoolBindings[DescriptorSetIndex::Texture].get().retain(
&contextVk->getResourceUseList());
return angle::Result::Continue;
}
......@@ -1596,7 +1590,7 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(ContextVk *contex
mTextureDescriptorsCache.destroy(contextVk->getRenderer());
}
descriptorSet = mDescriptorSets[ToUnderlying(DescriptorSetIndex::Texture)];
descriptorSet = mDescriptorSets[DescriptorSetIndex::Texture];
mTextureDescriptorsCache.insert(texturesDesc, descriptorSet);
}
ASSERT(descriptorSet != VK_NULL_HANDLE);
......@@ -1704,14 +1698,16 @@ angle::Result ProgramExecutableVk::updateDescriptorSets(ContextVk *contextVk,
// Find the maximum non-null descriptor set. This is used in conjunction with a driver
// workaround to bind empty descriptor sets only for gaps in between 0 and max and avoid
// binding unnecessary empty descriptor sets for the sets beyond max.
const size_t descriptorSetStart = ToUnderlying(DescriptorSetIndex::UniformsAndXfb);
size_t descriptorSetRange = 0;
for (size_t descriptorSetIndex = descriptorSetStart;
descriptorSetIndex < mDescriptorSets.size(); ++descriptorSetIndex)
DescriptorSetIndex lastNonNullDescriptorSetIndex = DescriptorSetIndex::InvalidEnum;
for (DescriptorSetIndex descriptorSetIndex : angle::AllEnums<DescriptorSetIndex>())
{
if (descriptorSetIndex == DescriptorSetIndex::Internal)
{
continue;
}
if (mDescriptorSets[descriptorSetIndex] != VK_NULL_HANDLE)
{
descriptorSetRange = descriptorSetIndex + 1;
lastNonNullDescriptorSetIndex = descriptorSetIndex;
}
}
......@@ -1720,9 +1716,14 @@ angle::Result ProgramExecutableVk::updateDescriptorSets(ContextVk *contextVk,
? VK_PIPELINE_BIND_POINT_COMPUTE
: VK_PIPELINE_BIND_POINT_GRAPHICS;
for (uint32_t descriptorSetIndex = descriptorSetStart; descriptorSetIndex < descriptorSetRange;
++descriptorSetIndex)
for (DescriptorSetIndex descriptorSetIndex : angle::AllEnums<DescriptorSetIndex>())
{
if (descriptorSetIndex == DescriptorSetIndex::Internal ||
ToUnderlying(descriptorSetIndex) > ToUnderlying(lastNonNullDescriptorSetIndex))
{
continue;
}
VkDescriptorSet descSet = mDescriptorSets[descriptorSetIndex];
if (descSet == VK_NULL_HANDLE)
{
......@@ -1752,7 +1753,7 @@ angle::Result ProgramExecutableVk::updateDescriptorSets(ContextVk *contextVk,
// through dynamic uniform buffers (requiring dynamic offsets). No other descriptor
// requires a dynamic offset.
const uint32_t uniformBlockOffsetCount =
descriptorSetIndex == ToUnderlying(DescriptorSetIndex::UniformsAndXfb)
descriptorSetIndex == DescriptorSetIndex::UniformsAndXfb
? static_cast<uint32_t>(mNumDefaultUniformDescriptors)
: 0;
......@@ -1773,34 +1774,31 @@ void ProgramExecutableVk::outputCumulativePerfCounters()
return;
}
{
std::ostringstream text;
std::ostringstream text;
for (size_t descriptorSetIndex = 0;
descriptorSetIndex < mObjectPerfCounters.descriptorSetsAllocated.size();
++descriptorSetIndex)
for (DescriptorSetIndex descriptorSetIndex : angle::AllEnums<DescriptorSetIndex>())
{
uint32_t count = mObjectPerfCounters.descriptorSetsAllocated[descriptorSetIndex];
if (count > 0)
{
uint32_t count = mObjectPerfCounters.descriptorSetsAllocated[descriptorSetIndex];
if (count > 0)
{
text << " DescriptorSetIndex " << descriptorSetIndex << ": " << count << "\n";
}
text << " DescriptorSetIndex " << ToUnderlying(descriptorSetIndex) << ": " << count
<< "\n";
}
}
// Only output information for programs that allocated descriptor sets.
std::string textStr = text.str();
if (!textStr.empty())
{
INFO() << "ProgramExecutable: " << this << ":";
// Only output information for programs that allocated descriptor sets.
std::string textStr = text.str();
if (!textStr.empty())
{
INFO() << "ProgramExecutable: " << this << ":";
// Output each descriptor set allocation on a single line, so they're prefixed with the
// INFO information (file, line number, etc.).
// https://stackoverflow.com/a/12514641
std::istringstream iss(textStr);
for (std::string line; std::getline(iss, line);)
{
INFO() << line;
}
// Output each descriptor set allocation on a single line, so they're prefixed with the
// INFO information (file, line number, etc.).
// https://stackoverflow.com/a/12514641
std::istringstream iss(textStr);
for (std::string line; std::getline(iss, line);)
{
INFO() << line;
}
}
}
......
......@@ -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