Skip to content

Commit 8cc5f19

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Always bind input attachment to all pipelines in subpasses that uses one.
The vulkan spec says that if a subpass has an input attachment that the input attachment descriptor set must be bound to all pipelines in that subpass. This includes pipelines that don't actually use the input attachment. Bug: chromium:1134454 Change-Id: I9a544a9a457dde80d315010a626ae74eb422bb9b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321779 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
1 parent 3636620 commit 8cc5f19

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

src/gpu/vk/GrVkOpsRenderPass.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,11 @@ bool GrVkOpsRenderPass::onBindTextures(const GrPrimitiveProcessor& primProc,
563563
this->currentCommandBuffer())) {
564564
return false;
565565
}
566-
return fCurrentPipelineState->setAndBindInputAttachment(
567-
fGpu, static_cast<GrVkRenderTarget*>(fRenderTarget), pipeline,
568-
this->currentCommandBuffer());
566+
if (fSelfDependencyFlags == SelfDependencyFlags::kForInputAttachment) {
567+
return fCurrentPipelineState->setAndBindInputAttachment(
568+
fGpu, static_cast<GrVkRenderTarget*>(fRenderTarget), this->currentCommandBuffer());
569+
}
570+
return true;
569571
}
570572

571573
void GrVkOpsRenderPass::onBindBuffers(sk_sp<const GrBuffer> indexBuffer,

src/gpu/vk/GrVkPipelineState.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,19 @@ bool GrVkPipelineState::setAndBindTextures(GrVkGpu* gpu,
219219

220220
bool GrVkPipelineState::setAndBindInputAttachment(GrVkGpu* gpu,
221221
GrVkRenderTarget* renderTarget,
222-
const GrPipeline& pipeline,
223222
GrVkCommandBuffer* commandBuffer) {
224-
if (pipeline.usesInputAttachment()) {
225-
SkASSERT(renderTarget->supportsInputAttachmentUsage());
226-
const GrVkDescriptorSet* descriptorSet = renderTarget->inputDescSet(gpu);
227-
if (!descriptorSet) {
228-
return false;
229-
}
230-
commandBuffer->bindDescriptorSets(gpu, this, fPipeline->layout(),
231-
GrVkUniformHandler::kInputDescSet, /*setCount=*/1,
232-
descriptorSet->descriptorSet(),
233-
/*dynamicOffsetCount=*/0, /*dynamicOffsets=*/nullptr);
234-
// We don't add the input resource to the command buffer to track since the input will be
235-
// the same as the color attachment which is already tracked on the command buffer.
236-
commandBuffer->addRecycledResource(descriptorSet);
223+
SkASSERT(renderTarget->supportsInputAttachmentUsage());
224+
const GrVkDescriptorSet* descriptorSet = renderTarget->inputDescSet(gpu);
225+
if (!descriptorSet) {
226+
return false;
237227
}
228+
commandBuffer->bindDescriptorSets(gpu, this, fPipeline->layout(),
229+
GrVkUniformHandler::kInputDescSet, /*setCount=*/1,
230+
descriptorSet->descriptorSet(),
231+
/*dynamicOffsetCount=*/0, /*dynamicOffsets=*/nullptr);
232+
// We don't add the input resource to the command buffer to track since the input will be
233+
// the same as the color attachment which is already tracked on the command buffer.
234+
commandBuffer->addRecycledResource(descriptorSet);
238235
return true;
239236
}
240237

src/gpu/vk/GrVkPipelineState.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class GrVkPipelineState {
6262
const GrSurfaceProxy* const primitiveProcessorTextures[],
6363
GrVkCommandBuffer*);
6464

65-
bool setAndBindInputAttachment(GrVkGpu*, GrVkRenderTarget* renderTarget, const GrPipeline&,
66-
GrVkCommandBuffer*);
65+
bool setAndBindInputAttachment(GrVkGpu*, GrVkRenderTarget* renderTarget, GrVkCommandBuffer*);
6766

6867
void bindPipeline(const GrVkGpu* gpu, GrVkCommandBuffer* commandBuffer);
6968

src/gpu/vk/GrVkPipelineStateBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrProgramDesc& desc,
183183

184184
dsLayout[GrVkUniformHandler::kInputDescSet] = resourceProvider.getInputDSLayout();
185185

186-
bool usesInput = fProgramInfo.pipeline().usesInputAttachment();
186+
bool usesInput = SkToBool(fProgramInfo.renderPassBarriers() & GrXferBarrierFlags::kTexture);
187187
uint32_t layoutCount =
188188
usesInput ? GrVkUniformHandler::kDescSetCount : (GrVkUniformHandler::kDescSetCount - 1);
189189
// Create the VkPipelineLayout

0 commit comments

Comments
 (0)