diff --git a/src/gpu/vk/GrVkOpsRenderPass.cpp b/src/gpu/vk/GrVkOpsRenderPass.cpp index 242ed2a68c..c2b7a99194 100644 --- a/src/gpu/vk/GrVkOpsRenderPass.cpp +++ b/src/gpu/vk/GrVkOpsRenderPass.cpp @@ -646,16 +646,19 @@ bool GrVkOpsRenderPass::onBindPipeline(const GrProgramInfo& programInfo, const S // same place (i.e., the target renderTargetProxy) they had best agree. SkASSERT(programInfo.origin() == fOrigin); - if (!fCurrentPipelineState->setAndBindUniforms(fGpu, fRenderTarget, programInfo, currentCB)) { + auto colorAttachment = fFramebuffer->colorAttachment(); + if (!fCurrentPipelineState->setAndBindUniforms(fGpu, colorAttachment->dimensions(), programInfo, + currentCB)) { return false; } if (!programInfo.pipeline().isScissorTestEnabled()) { // "Disable" scissor by setting it to the full pipeline bounds. - GrVkPipeline::SetDynamicScissorRectState(fGpu, currentCB, fRenderTarget, fOrigin, + GrVkPipeline::SetDynamicScissorRectState( + fGpu, currentCB, colorAttachment->dimensions(), fOrigin, fCurrentPipelineBounds); } - GrVkPipeline::SetDynamicViewportState(fGpu, currentCB, fRenderTarget); + GrVkPipeline::SetDynamicViewportState(fGpu, currentCB, colorAttachment->dimensions()); GrVkPipeline::SetDynamicBlendConstantState(fGpu, currentCB, programInfo.pipeline().writeSwizzle(), programInfo.pipeline().getXferProcessor()); @@ -668,13 +671,14 @@ void GrVkOpsRenderPass::onSetScissorRect(const SkIRect& scissor) { if (!combinedScissorRect.intersect(fCurrentPipelineBounds, scissor)) { combinedScissorRect = SkIRect::MakeEmpty(); } - GrVkPipeline::SetDynamicScissorRectState(fGpu, this->currentCommandBuffer(), fRenderTarget, + GrVkPipeline::SetDynamicScissorRectState(fGpu, this->currentCommandBuffer(), + fFramebuffer->colorAttachment()->dimensions(), fOrigin, combinedScissorRect); } #ifdef SK_DEBUG -void check_sampled_texture(GrTexture* tex, GrRenderTarget* rt, GrVkGpu* gpu) { - SkASSERT(!tex->isProtected() || (rt->isProtected() && gpu->protectedContext())); +void check_sampled_texture(GrTexture* tex, GrAttachment* colorAttachment, GrVkGpu* gpu) { + SkASSERT(!tex->isProtected() || (colorAttachment->isProtected() && gpu->protectedContext())); auto vkTex = static_cast(tex)->textureAttachment(); SkASSERT(vkTex->currentLayout() == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } @@ -685,14 +689,15 @@ bool GrVkOpsRenderPass::onBindTextures(const GrGeometryProcessor& geomProc, const GrPipeline& pipeline) { #ifdef SK_DEBUG SkASSERT(fCurrentPipelineState); + auto colorAttachment = fFramebuffer->colorAttachment(); for (int i = 0; i < geomProc.numTextureSamplers(); ++i) { - check_sampled_texture(geomProcTextures[i]->peekTexture(), fRenderTarget, fGpu); + check_sampled_texture(geomProcTextures[i]->peekTexture(), colorAttachment, fGpu); } pipeline.visitTextureEffects([&](const GrTextureEffect& te) { - check_sampled_texture(te.texture(), fRenderTarget, fGpu); + check_sampled_texture(te.texture(), colorAttachment, fGpu); }); if (GrTexture* dstTexture = pipeline.peekDstTexture()) { - check_sampled_texture(dstTexture, fRenderTarget, fGpu); + check_sampled_texture(dstTexture, colorAttachment, fGpu); } #endif if (!fCurrentPipelineState->setAndBindTextures(fGpu, geomProc, pipeline, geomProcTextures, diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp index 930d7d9fdd..377a83732c 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -670,11 +670,11 @@ void GrVkPipeline::freeGPUData() const { void GrVkPipeline::SetDynamicScissorRectState(GrVkGpu* gpu, GrVkCommandBuffer* cmdBuffer, - const GrRenderTarget* renderTarget, + SkISize colorAttachmentDimensions, GrSurfaceOrigin rtOrigin, const SkIRect& scissorRect) { SkASSERT(scissorRect.isEmpty() || - SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).contains(scissorRect)); + SkIRect::MakeSize(colorAttachmentDimensions).contains(scissorRect)); VkRect2D scissor; scissor.offset.x = scissorRect.fLeft; @@ -683,7 +683,7 @@ void GrVkPipeline::SetDynamicScissorRectState(GrVkGpu* gpu, scissor.offset.y = scissorRect.fTop; } else { SkASSERT(kBottomLeft_GrSurfaceOrigin == rtOrigin); - scissor.offset.y = renderTarget->height() - scissorRect.fBottom; + scissor.offset.y = colorAttachmentDimensions.height() - scissorRect.fBottom; } scissor.extent.height = scissorRect.height(); @@ -694,13 +694,13 @@ void GrVkPipeline::SetDynamicScissorRectState(GrVkGpu* gpu, void GrVkPipeline::SetDynamicViewportState(GrVkGpu* gpu, GrVkCommandBuffer* cmdBuffer, - const GrRenderTarget* renderTarget) { + SkISize colorAttachmentDimensions) { // We always use one viewport the size of the RT VkViewport viewport; viewport.x = 0.0f; viewport.y = 0.0f; - viewport.width = SkIntToScalar(renderTarget->width()); - viewport.height = SkIntToScalar(renderTarget->height()); + viewport.width = SkIntToScalar(colorAttachmentDimensions.width()); + viewport.height = SkIntToScalar(colorAttachmentDimensions.height()); viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; cmdBuffer->setViewport(gpu, 0, 1, &viewport); diff --git a/src/gpu/vk/GrVkPipeline.h b/src/gpu/vk/GrVkPipeline.h index 2f57ea5e42..6e4261ec13 100644 --- a/src/gpu/vk/GrVkPipeline.h +++ b/src/gpu/vk/GrVkPipeline.h @@ -61,9 +61,13 @@ public: return fPipelineLayout; } - static void SetDynamicScissorRectState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*, + static void SetDynamicScissorRectState(GrVkGpu*, + GrVkCommandBuffer*, + SkISize colorAttachmentDimensions, GrSurfaceOrigin, const SkIRect& scissorRect); - static void SetDynamicViewportState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*); + static void SetDynamicViewportState(GrVkGpu*, + GrVkCommandBuffer*, + SkISize colorAttachmentDimensions); static void SetDynamicBlendConstantState(GrVkGpu*, GrVkCommandBuffer*, const GrSwizzle& writeSwizzle, diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index b86101712b..d5fa5f0fb9 100644 --- a/src/gpu/vk/GrVkPipelineState.cpp +++ b/src/gpu/vk/GrVkPipelineState.cpp @@ -73,10 +73,10 @@ void GrVkPipelineState::freeGPUResources(GrVkGpu* gpu) { } bool GrVkPipelineState::setAndBindUniforms(GrVkGpu* gpu, - const GrRenderTarget* renderTarget, + SkISize colorAttachmentDimensions, const GrProgramInfo& programInfo, GrVkCommandBuffer* commandBuffer) { - this->setRenderTargetState(renderTarget, programInfo.origin()); + this->setRenderTargetState(colorAttachmentDimensions, programInfo.origin()); fGeometryProcessor->setData(fDataManager, *gpu->caps()->shaderCaps(), programInfo.geomProc()); for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) { @@ -247,20 +247,21 @@ bool GrVkPipelineState::setAndBindInputAttachment(GrVkGpu* gpu, return true; } -void GrVkPipelineState::setRenderTargetState(const GrRenderTarget* rt, GrSurfaceOrigin origin) { +void GrVkPipelineState::setRenderTargetState(SkISize colorAttachmentDimensions, + GrSurfaceOrigin origin) { // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && - fRenderTargetState.fRenderTargetSize.fHeight != rt->height()) { - fDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, SkIntToScalar(rt->height())); + fRenderTargetState.fRenderTargetSize.fHeight != colorAttachmentDimensions.height()) { + fDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, + SkIntToScalar(colorAttachmentDimensions.height())); } // set RT adjustment - SkISize dimensions = rt->dimensions(); SkASSERT(fBuiltinUniformHandles.fRTAdjustmentUni.isValid()); if (fRenderTargetState.fRenderTargetOrigin != origin || - fRenderTargetState.fRenderTargetSize != dimensions) { - fRenderTargetState.fRenderTargetSize = dimensions; + fRenderTargetState.fRenderTargetSize != colorAttachmentDimensions) { + fRenderTargetState.fRenderTargetSize = colorAttachmentDimensions; fRenderTargetState.fRenderTargetOrigin = origin; float rtAdjustmentVec[4]; diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h index fb4a5c3a43..53ffa67145 100644 --- a/src/gpu/vk/GrVkPipelineState.h +++ b/src/gpu/vk/GrVkPipelineState.h @@ -53,7 +53,7 @@ public: ~GrVkPipelineState(); - bool setAndBindUniforms(GrVkGpu*, const GrRenderTarget*, const GrProgramInfo&, + bool setAndBindUniforms(GrVkGpu*, SkISize colorAttachmentDimensions, const GrProgramInfo&, GrVkCommandBuffer*); /** * This must be called after setAndBindUniforms() since that function invalidates texture @@ -109,7 +109,7 @@ private: }; // Helper for setData() that sets the view matrix and loads the render target height uniform - void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin); + void setRenderTargetState(SkISize colorAttachmentDimensions, GrSurfaceOrigin); // GrManagedResources sk_sp fPipeline;