aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpuCommandBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-06-06 12:27:16 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-07 18:26:11 +0000
commit46983b7dd88603bb2a9a3c3e1ce3e147f5615f2f (patch)
treecb2dccc7b6d44b1100dc34af92c60d7b243d01c7 /src/gpu/vk/GrVkGpuCommandBuffer.cpp
parent912e6b883782cd6a53348056012ff7ed38658c79 (diff)
Introduce dynamic pipeline state
Adds a DynamicState struct to GrPipeline that has a field for the scissor rect. Eventually this should become the only way to specify a scissor rectangle and may grow to contain more fields. Adds an array of DynamicStates to GrGpuCommandBuffer::draw and implements support in GL and Vulkan. Bug: skia: Change-Id: If5aebbf9da5d192acf7e68e7def4674ffc7ec310 Reviewed-on: https://skia-review.googlesource.com/18510 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkGpuCommandBuffer.cpp')
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 6f39cfa545..6e9c292f04 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -468,7 +468,8 @@ void GrVkGpuCommandBuffer::bindGeometry(const GrPrimitiveProcessor& primProc,
sk_sp<GrVkPipelineState> GrVkGpuCommandBuffer::prepareDrawState(
const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- GrPrimitiveType primitiveType) {
+ GrPrimitiveType primitiveType,
+ bool hasDynamicState) {
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
SkASSERT(cbInfo.fRenderPass);
@@ -492,7 +493,18 @@ sk_sp<GrVkPipelineState> GrVkGpuCommandBuffer::prepareDrawState(
pipelineState->bind(fGpu, cbInfo.currentCmdBuf());
- GrVkPipeline::SetDynamicState(fGpu, cbInfo.currentCmdBuf(), pipeline);
+ GrRenderTarget* rt = pipeline.getRenderTarget();
+
+ if (!pipeline.getScissorState().enabled()) {
+ GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(), rt,
+ SkIRect::MakeWH(rt->width(), rt->height()));
+ } else if (!hasDynamicState) {
+ GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(), rt,
+ pipeline.getScissorState().rect());
+ }
+ GrVkPipeline::SetDynamicViewportState(fGpu, cbInfo.currentCmdBuf(), rt);
+ GrVkPipeline::SetDynamicBlendConstantState(fGpu, cbInfo.currentCmdBuf(), rt->config(),
+ pipeline.getXferProcessor());
return pipelineState;
}
@@ -533,7 +545,8 @@ static void prepare_sampled_images(const GrResourceIOProcessor& processor, GrVkG
void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrMesh* meshes,
+ const GrMesh meshes[],
+ const GrPipeline::DynamicState dynamicStates[],
int meshCount,
const SkRect& bounds) {
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(pipeline.getRenderTarget());
@@ -557,11 +570,14 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
GrPrimitiveType primitiveType = meshes[0].primitiveType();
sk_sp<GrVkPipelineState> pipelineState = this->prepareDrawState(pipeline,
primProc,
- primitiveType);
+ primitiveType,
+ SkToBool(dynamicStates));
if (!pipelineState) {
return;
}
+ CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
+
for (int i = 0; i < meshCount; ++i) {
const GrMesh& mesh = meshes[i];
if (mesh.primitiveType() != primitiveType) {
@@ -573,17 +589,24 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
primitiveType = mesh.primitiveType();
pipelineState = this->prepareDrawState(pipeline,
primProc,
- primitiveType);
+ primitiveType,
+ SkToBool(dynamicStates));
if (!pipelineState) {
return;
}
}
+ if (dynamicStates) {
+ if (pipeline.getScissorState().enabled()) {
+ GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
+ target, dynamicStates[i].fScissorRect);
+ }
+ }
+
SkASSERT(pipelineState);
mesh.sendToGpu(primProc, this);
}
- CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
cbInfo.fBounds.join(bounds);
cbInfo.fIsEmpty = false;