Commit 6a4cad87 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Tighten descriptor stage usage hints

Per-stage uniform buffers are marked with the specific stage. Program uniform buffers and images are specified to be used in all graphics stages. Descriptors used in internal shaders are marked for use in either compute or fragment stages. Bug: angleproject:3220 Change-Id: Ifcac36a1224f0392ba5fba50660514e498256401 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1595439 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent 09eabed9
...@@ -1302,7 +1302,7 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context, ...@@ -1302,7 +1302,7 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
if (!mDriverUniformsSetLayout.valid()) if (!mDriverUniformsSetLayout.valid())
{ {
vk::DescriptorSetLayoutDesc desc; vk::DescriptorSetLayoutDesc desc;
desc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1); desc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL_GRAPHICS);
ANGLE_TRY(mRenderer->getDescriptorSetLayout(this, desc, &mDriverUniformsSetLayout)); ANGLE_TRY(mRenderer->getDescriptorSetLayout(this, desc, &mDriverUniformsSetLayout));
} }
......
...@@ -311,9 +311,9 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, ...@@ -311,9 +311,9 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext,
// don't already exist in the cache. // don't already exist in the cache.
vk::DescriptorSetLayoutDesc uniformsSetDesc; vk::DescriptorSetLayoutDesc uniformsSetDesc;
uniformsSetDesc.update(kVertexUniformsBindingIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, uniformsSetDesc.update(kVertexUniformsBindingIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
1); 1, VK_SHADER_STAGE_VERTEX_BIT);
uniformsSetDesc.update(kFragmentUniformsBindingIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, uniformsSetDesc.update(kFragmentUniformsBindingIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
1); 1, VK_SHADER_STAGE_FRAGMENT_BIT);
ANGLE_TRY(renderer->getDescriptorSetLayout( ANGLE_TRY(renderer->getDescriptorSetLayout(
contextVk, uniformsSetDesc, &mDescriptorSetLayouts[kUniformsDescriptorSetIndex])); contextVk, uniformsSetDesc, &mDescriptorSetLayouts[kUniformsDescriptorSetIndex]));
...@@ -325,7 +325,8 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, ...@@ -325,7 +325,8 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext,
{ {
const uint32_t arraySize = GetUniformBlockArraySize(uniformBlocks, bufferIndex); const uint32_t arraySize = GetUniformBlockArraySize(uniformBlocks, bufferIndex);
uniformBlocksSetDesc.update(bufferIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, arraySize); uniformBlocksSetDesc.update(bufferIndex, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, arraySize,
VK_SHADER_STAGE_ALL_GRAPHICS);
bufferIndex += arraySize; bufferIndex += arraySize;
} }
...@@ -342,14 +343,16 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, ...@@ -342,14 +343,16 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext,
// The front-end always binds array sampler units sequentially. // The front-end always binds array sampler units sequentially.
const uint32_t count = static_cast<uint32_t>(samplerBinding.boundTextureUnits.size()); const uint32_t count = static_cast<uint32_t>(samplerBinding.boundTextureUnits.size());
texturesSetDesc.update(textureIndex, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count); texturesSetDesc.update(textureIndex, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count,
VK_SHADER_STAGE_ALL_GRAPHICS);
} }
ANGLE_TRY(renderer->getDescriptorSetLayout(contextVk, texturesSetDesc, ANGLE_TRY(renderer->getDescriptorSetLayout(contextVk, texturesSetDesc,
&mDescriptorSetLayouts[kTextureDescriptorSetIndex])); &mDescriptorSetLayouts[kTextureDescriptorSetIndex]));
vk::DescriptorSetLayoutDesc driverUniformsSetDesc; vk::DescriptorSetLayoutDesc driverUniformsSetDesc;
driverUniformsSetDesc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1); driverUniformsSetDesc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1,
VK_SHADER_STAGE_ALL_GRAPHICS);
ANGLE_TRY(renderer->getDescriptorSetLayout( ANGLE_TRY(renderer->getDescriptorSetLayout(
contextVk, driverUniformsSetDesc, contextVk, driverUniformsSetDesc,
&mDescriptorSetLayouts[kDriverUniformsDescriptorSetIndex])); &mDescriptorSetLayouts[kDriverUniformsDescriptorSetIndex]));
......
...@@ -221,11 +221,14 @@ angle::Result UtilsVk::ensureResourcesInitialized(vk::Context *context, ...@@ -221,11 +221,14 @@ angle::Result UtilsVk::ensureResourcesInitialized(vk::Context *context,
vk::DescriptorSetLayoutDesc descriptorSetDesc; vk::DescriptorSetLayoutDesc descriptorSetDesc;
bool isCompute = function >= Function::ComputeStartIndex; bool isCompute = function >= Function::ComputeStartIndex;
const VkShaderStageFlags descStages =
isCompute ? VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_FRAGMENT_BIT;
uint32_t currentBinding = 0; uint32_t currentBinding = 0;
for (size_t i = 0; i < setSizesCount; ++i) for (size_t i = 0; i < setSizesCount; ++i)
{ {
descriptorSetDesc.update(currentBinding, setSizes[i].type, setSizes[i].descriptorCount); descriptorSetDesc.update(currentBinding, setSizes[i].type, setSizes[i].descriptorCount,
descStages);
currentBinding += setSizes[i].descriptorCount; currentBinding += setSizes[i].descriptorCount;
} }
......
...@@ -1286,7 +1286,10 @@ bool DescriptorSetLayoutDesc::operator==(const DescriptorSetLayoutDesc &other) c ...@@ -1286,7 +1286,10 @@ bool DescriptorSetLayoutDesc::operator==(const DescriptorSetLayoutDesc &other) c
sizeof(mPackedDescriptorSetLayout)) == 0); sizeof(mPackedDescriptorSetLayout)) == 0);
} }
void DescriptorSetLayoutDesc::update(uint32_t bindingIndex, VkDescriptorType type, uint32_t count) void DescriptorSetLayoutDesc::update(uint32_t bindingIndex,
VkDescriptorType type,
uint32_t count,
VkShaderStageFlags stages)
{ {
ASSERT(static_cast<size_t>(type) < std::numeric_limits<uint16_t>::max()); ASSERT(static_cast<size_t>(type) < std::numeric_limits<uint16_t>::max());
ASSERT(count < std::numeric_limits<uint16_t>::max()); ASSERT(count < std::numeric_limits<uint16_t>::max());
...@@ -1295,6 +1298,7 @@ void DescriptorSetLayoutDesc::update(uint32_t bindingIndex, VkDescriptorType typ ...@@ -1295,6 +1298,7 @@ void DescriptorSetLayoutDesc::update(uint32_t bindingIndex, VkDescriptorType typ
SetBitField(packedBinding.type, type); SetBitField(packedBinding.type, type);
SetBitField(packedBinding.count, count); SetBitField(packedBinding.count, count);
SetBitField(packedBinding.stages, stages);
} }
void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *bindings) const void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *bindings) const
...@@ -1309,7 +1313,7 @@ void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *b ...@@ -1309,7 +1313,7 @@ void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *b
binding.binding = bindingIndex; binding.binding = bindingIndex;
binding.descriptorCount = packedBinding.count; binding.descriptorCount = packedBinding.count;
binding.descriptorType = static_cast<VkDescriptorType>(packedBinding.type); binding.descriptorType = static_cast<VkDescriptorType>(packedBinding.type);
binding.stageFlags = VK_SHADER_STAGE_ALL; binding.stageFlags = static_cast<VkShaderStageFlags>(packedBinding.stages);
binding.pImmutableSamplers = nullptr; binding.pImmutableSamplers = nullptr;
bindings->push_back(binding); bindings->push_back(binding);
......
...@@ -496,14 +496,18 @@ class DescriptorSetLayoutDesc final ...@@ -496,14 +496,18 @@ class DescriptorSetLayoutDesc final
size_t hash() const; size_t hash() const;
bool operator==(const DescriptorSetLayoutDesc &other) const; bool operator==(const DescriptorSetLayoutDesc &other) const;
void update(uint32_t bindingIndex, VkDescriptorType type, uint32_t count); void update(uint32_t bindingIndex,
VkDescriptorType type,
uint32_t count,
VkShaderStageFlags stages);
void unpackBindings(DescriptorSetLayoutBindingVector *bindings) const; void unpackBindings(DescriptorSetLayoutBindingVector *bindings) const;
private: private:
struct PackedDescriptorSetBinding struct PackedDescriptorSetBinding
{ {
uint16_t type; // Stores a packed VkDescriptorType descriptorType. uint8_t type; // Stores a packed VkDescriptorType descriptorType.
uint8_t stages; // Stores a packed VkShaderStageFlags.
uint16_t count; // Stores a packed uint32_t descriptorCount. uint16_t count; // Stores a packed uint32_t descriptorCount.
}; };
......
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