Commit 87dc17b5 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Generalize buffers desc set name to include images

And atomic counter buffers which are emulated with storage buffers. Bug: angleproject:3566 Change-Id: I102763900c779c3a84661491bad53aec384461f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1713086Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent a71549b1
......@@ -206,13 +206,13 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_TEXTURES);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_INDEX_BUFFER);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_PIPELINE);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_TEXTURES);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mGraphicsDirtyBitHandlers[DIRTY_BIT_DEFAULT_ATTRIBS] =
......@@ -224,8 +224,8 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mGraphicsDirtyBitHandlers[DIRTY_BIT_INDEX_BUFFER] = &ContextVk::handleDirtyGraphicsIndexBuffer;
mGraphicsDirtyBitHandlers[DIRTY_BIT_DRIVER_UNIFORMS] =
&ContextVk::handleDirtyGraphicsDriverUniforms;
mGraphicsDirtyBitHandlers[DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS] =
&ContextVk::handleDirtyGraphicsUniformAndStorageBuffers;
mGraphicsDirtyBitHandlers[DIRTY_BIT_SHADER_RESOURCES] =
&ContextVk::handleDirtyGraphicsShaderResources;
mGraphicsDirtyBitHandlers[DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS] =
&ContextVk::handleDirtyGraphicsTransformFeedbackBuffers;
mGraphicsDirtyBitHandlers[DIRTY_BIT_DESCRIPTOR_SETS] =
......@@ -233,8 +233,8 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mComputeDirtyBitHandlers[DIRTY_BIT_PIPELINE] = &ContextVk::handleDirtyComputePipeline;
mComputeDirtyBitHandlers[DIRTY_BIT_TEXTURES] = &ContextVk::handleDirtyComputeTextures;
mComputeDirtyBitHandlers[DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS] =
&ContextVk::handleDirtyComputeUniformAndStorageBuffers;
mComputeDirtyBitHandlers[DIRTY_BIT_SHADER_RESOURCES] =
&ContextVk::handleDirtyComputeShaderResources;
mComputeDirtyBitHandlers[DIRTY_BIT_DESCRIPTOR_SETS] =
&ContextVk::handleDirtyComputeDescriptorSets;
......@@ -678,31 +678,29 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte
return angle::Result::Continue;
}
ANGLE_INLINE angle::Result ContextVk::handleDirtyUniformAndStorageBuffersImpl(
ANGLE_INLINE angle::Result ContextVk::handleDirtyShaderResourcesImpl(
const gl::Context *context,
vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder)
{
if (mProgram->hasUniformBuffers() || mProgram->hasStorageBuffers())
{
ANGLE_TRY(mProgram->updateUniformAndStorageBuffersDescriptorSet(this, recorder));
ANGLE_TRY(mProgram->updateShaderResourcesDescriptorSet(this, recorder));
}
return angle::Result::Continue;
}
angle::Result ContextVk::handleDirtyGraphicsUniformAndStorageBuffers(
const gl::Context *context,
vk::CommandBuffer *commandBuffer)
angle::Result ContextVk::handleDirtyGraphicsShaderResources(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
{
return handleDirtyUniformAndStorageBuffersImpl(context, commandBuffer,
mDrawFramebuffer->getFramebuffer());
return handleDirtyShaderResourcesImpl(context, commandBuffer,
mDrawFramebuffer->getFramebuffer());
}
angle::Result ContextVk::handleDirtyComputeUniformAndStorageBuffers(
const gl::Context *context,
vk::CommandBuffer *commandBuffer)
angle::Result ContextVk::handleDirtyComputeShaderResources(const gl::Context *context,
vk::CommandBuffer *commandBuffer)
{
return handleDirtyUniformAndStorageBuffersImpl(context, commandBuffer, &mDispatcher);
return handleDirtyShaderResourcesImpl(context, commandBuffer, &mDispatcher);
}
angle::Result ContextVk::handleDirtyGraphicsTransformFeedbackBuffers(
......@@ -1698,7 +1696,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
case gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE:
{
invalidateCurrentTextures();
invalidateCurrentUniformAndStorageBuffers();
invalidateCurrentShaderResources();
if (glState.getProgram()->isCompute())
{
invalidateCurrentComputePipeline();
......@@ -1726,12 +1724,13 @@ angle::Result ContextVk::syncState(const gl::Context *context,
// Nothing to do.
break;
case gl::State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING:
invalidateCurrentUniformAndStorageBuffers();
invalidateCurrentShaderResources();
break;
case gl::State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS:
invalidateCurrentUniformAndStorageBuffers();
invalidateCurrentShaderResources();
break;
case gl::State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING:
invalidateCurrentShaderResources();
break;
case gl::State::DIRTY_BIT_IMAGE_BINDINGS:
break;
......@@ -1951,14 +1950,14 @@ void ContextVk::invalidateCurrentTextures()
}
}
void ContextVk::invalidateCurrentUniformAndStorageBuffers()
void ContextVk::invalidateCurrentShaderResources()
{
ASSERT(mProgram);
if (mProgram->hasUniformBuffers() || mProgram->hasStorageBuffers())
{
mGraphicsDirtyBits.set(DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS);
mGraphicsDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mGraphicsDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mComputeDirtyBits.set(DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS);
mComputeDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mComputeDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
}
}
......
......@@ -319,7 +319,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
DIRTY_BIT_VERTEX_BUFFERS,
DIRTY_BIT_INDEX_BUFFER,
DIRTY_BIT_DRIVER_UNIFORMS,
DIRTY_BIT_UNIFORM_AND_STORAGE_BUFFERS,
DIRTY_BIT_SHADER_RESOURCES, // excluding textures, which are handled separately.
DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS,
DIRTY_BIT_DESCRIPTOR_SETS,
DIRTY_BIT_MAX,
......@@ -384,7 +384,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
}
void invalidateCurrentTextures();
void invalidateCurrentUniformAndStorageBuffers();
void invalidateCurrentShaderResources();
void invalidateDriverUniforms();
// Handlers for graphics pipeline dirty bits.
......@@ -400,8 +400,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyGraphicsDriverUniforms(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyGraphicsUniformAndStorageBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyGraphicsShaderResources(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyGraphicsTransformFeedbackBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyGraphicsDescriptorSets(const gl::Context *context,
......@@ -412,8 +412,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyComputeTextures(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyComputeUniformAndStorageBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyComputeShaderResources(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyComputeDescriptorSets(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
......@@ -421,9 +421,9 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
angle::Result handleDirtyTexturesImpl(const gl::Context *context,
vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder);
angle::Result handleDirtyUniformAndStorageBuffersImpl(const gl::Context *context,
vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder);
angle::Result handleDirtyShaderResourcesImpl(const gl::Context *context,
vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder);
angle::Result submitFrame(const VkSubmitInfo &submitInfo,
vk::PrimaryCommandBuffer &&commandBuffer);
......
......@@ -717,7 +717,7 @@ uint32_t AssignInterfaceBlockBindings(const std::vector<gl::InterfaceBlock> &blo
uint32_t bindingStart,
gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{
const std::string buffersDescriptorSet = "set = " + Str(kBufferDescriptorSetIndex);
const std::string resourcesDescriptorSet = "set = " + Str(kShaderResourceDescriptorSetIndex);
uint32_t bindingIndex = bindingStart;
for (const gl::InterfaceBlock &block : blocks)
......@@ -725,7 +725,7 @@ uint32_t AssignInterfaceBlockBindings(const std::vector<gl::InterfaceBlock> &blo
if (!block.isArray || block.arrayElement == 0)
{
const std::string bindingString =
buffersDescriptorSet + ", binding = " + Str(bindingIndex++);
resourcesDescriptorSet + ", binding = " + Str(bindingIndex++);
AssignResourceBinding(block.activeShaders(), block.name, bindingString, qualifier,
kUnusedBlockSubstitution, shaderSources);
......
......@@ -444,8 +444,8 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, gl::InfoLog &inf
getStorageBlockBindingsOffset(),
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &buffersSetDesc);
ANGLE_TRY(renderer->getDescriptorSetLayout(contextVk, buffersSetDesc,
&mDescriptorSetLayouts[kBufferDescriptorSetIndex]));
ANGLE_TRY(renderer->getDescriptorSetLayout(
contextVk, buffersSetDesc, &mDescriptorSetLayouts[kShaderResourceDescriptorSetIndex]));
// Textures:
vk::DescriptorSetLayoutDesc texturesSetDesc;
......@@ -479,7 +479,7 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, gl::InfoLog &inf
vk::PipelineLayoutDesc pipelineLayoutDesc;
pipelineLayoutDesc.updateDescriptorSetLayout(kUniformsAndXfbDescriptorSetIndex,
uniformsAndXfbSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(kBufferDescriptorSetIndex, buffersSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(kShaderResourceDescriptorSetIndex, buffersSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(kTextureDescriptorSetIndex, texturesSetDesc);
pipelineLayoutDesc.updateDescriptorSetLayout(kDriverUniformsDescriptorSetIndex,
driverUniformsSetDesc);
......@@ -520,7 +520,7 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, gl::InfoLog &inf
contextVk, uniformAndXfbSetSize.data(), uniformAndXfbSetSize.size()));
if (bufferSetSize.size() > 0)
{
ANGLE_TRY(mDynamicDescriptorPools[kBufferDescriptorSetIndex].init(
ANGLE_TRY(mDynamicDescriptorPools[kShaderResourceDescriptorSetIndex].init(
contextVk, bufferSetSize.data(), bufferSetSize.size()));
}
if (textureCount > 0)
......@@ -1089,7 +1089,7 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
const std::vector<gl::InterfaceBlock> &blocks,
VkDescriptorType descriptorType)
{
VkDescriptorSet descriptorSet = mDescriptorSets[kBufferDescriptorSetIndex];
VkDescriptorSet descriptorSet = mDescriptorSets[kShaderResourceDescriptorSetIndex];
ASSERT(descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
......@@ -1192,11 +1192,10 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
vkUpdateDescriptorSets(device, writeCount, writeDescriptorInfo.data(), 0, nullptr);
}
angle::Result ProgramVk::updateUniformAndStorageBuffersDescriptorSet(
ContextVk *contextVk,
vk::CommandGraphResource *recorder)
angle::Result ProgramVk::updateShaderResourcesDescriptorSet(ContextVk *contextVk,
vk::CommandGraphResource *recorder)
{
ANGLE_TRY(allocateDescriptorSet(contextVk, kBufferDescriptorSetIndex));
ANGLE_TRY(allocateDescriptorSet(contextVk, kShaderResourceDescriptorSetIndex));
updateBuffersDescriptorSet(contextVk, recorder, mState.getUniformBlocks(),
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
......
......@@ -107,8 +107,8 @@ class ProgramVk : public ProgramImpl
angle::Result updateUniforms(ContextVk *contextVk);
angle::Result updateTexturesDescriptorSet(ContextVk *contextVk);
angle::Result updateUniformAndStorageBuffersDescriptorSet(ContextVk *contextVk,
vk::CommandGraphResource *recorder);
angle::Result updateShaderResourcesDescriptorSet(ContextVk *contextVk,
vk::CommandGraphResource *recorder);
angle::Result updateTransformFeedbackDescriptorSet(ContextVk *contextVk,
vk::FramebufferHelper *framebuffer);
......
......@@ -897,7 +897,7 @@ class PipelineLayoutCache final : angle::NonCopyable
// correspond to default uniforms in the vertex and fragment shaders respectively. Additionally,
// transform feedback buffers are bound from binding 2 and up.
// - Set 1 contains all textures.
// - Set 2 contains all uniform and storage blocks.
// - Set 2 contains all other shader resources.
// - Set 3 contains the ANGLE driver uniforms at binding 0. Note that driver uniforms are updated
// only under rare circumstances, such as viewport or depth range change. However, there is only
// one binding in this set.
......@@ -906,8 +906,8 @@ class PipelineLayoutCache final : angle::NonCopyable
constexpr uint32_t kUniformsAndXfbDescriptorSetIndex = 0;
// Textures set index:
constexpr uint32_t kTextureDescriptorSetIndex = 1;
// Uniform blocks set index:
constexpr uint32_t kBufferDescriptorSetIndex = 2;
// Other shader resources set index:
constexpr uint32_t kShaderResourceDescriptorSetIndex = 2;
// ANGLE driver uniforms set index (binding is always 3):
constexpr uint32_t kDriverUniformsDescriptorSetIndex = 3;
......
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