Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: src/gpu/vk/GrVkGpu.cpp

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/vk/GrVkGpu.cpp
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index fce7173effeabaa33a2f49f0ff9e687fa3ffa26f..40e8d8dc697ad9230260b89dd81f7f5c7a792105 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -681,14 +681,6 @@ void GrVkGpu::bindGeometry(const GrPrimitiveProcessor& primProc,
}
}
-void GrVkGpu::buildProgramDesc(GrProgramDesc* desc,
- const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline) const {
- if (!GrVkProgramDescBuilder::Build(desc, primProc, pipeline, *this->vkCaps().glslCaps())) {
- SkDEBUGFAIL("Failed to generate GL program descriptor");
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
GrStencilAttachment* GrVkGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
@@ -1323,28 +1315,38 @@ bool GrVkGpu::onReadPixels(GrSurface* surface,
return true;
}
-void GrVkGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertices) {
- GrRenderTarget* rt = args.fPipeline->getRenderTarget();
+void GrVkGpu::onDraw(const GrPipeline& pipeline,
+ const GrPrimitiveProcessor& primProc,
+ GrPrimitiveType primitiveType,
+ const GrVertices* vertArray,
+ int drawCount) {
+ GrRenderTarget* rt = pipeline.getRenderTarget();
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(rt);
const GrVkRenderPass* renderPass = vkRT->simpleRenderPass();
SkASSERT(renderPass);
- GrVkProgram* program = GrVkProgramBuilder::CreateProgram(this, args,
- vertices.primitiveType(),
+
+ // Get GrGLProgramDesc
bsalomon 2016/03/16 20:07:22 ?
egdaniel 2016/03/17 15:09:36 Done.
+ GrVkProgramDesc desc;
+ if (!GrVkProgramDescBuilder::Build(&desc, primProc, pipeline, *this->vkCaps().glslCaps())) {
+ GrCapsDebugf(this->caps(), "Failed to vk program descriptor!\n");
+ return;
+ }
+ GrVkProgram* program = GrVkProgramBuilder::CreateProgram(this,
+ pipeline,
+ primProc,
+ primitiveType,
+ desc,
*renderPass);
if (!program) {
return;
}
- program->setData(this, *args.fPrimitiveProcessor, *args.fPipeline);
-
- fCurrentCmdBuffer->beginRenderPass(this, renderPass, *vkRT);
+ program->setData(this, primProc, pipeline);
program->bind(this, fCurrentCmdBuffer);
- this->bindGeometry(*args.fPrimitiveProcessor, vertices);
-
// Change layout of our render target so it can be used as the color attachment
VkImageLayout layout = vkRT->currentLayout();
// Our color attachment is purely a destination and won't be read so don't need to flush or
@@ -1362,13 +1364,13 @@ void GrVkGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
false);
// If we are using a stencil attachment we also need to update its layout
- if (!args.fPipeline->getStencil().isDisabled()) {
+ if (!pipeline.getStencil().isDisabled()) {
GrStencilAttachment* stencil = vkRT->renderTargetPriv().getStencilAttachment();
GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil;
VkImageLayout origDstLayout = vkStencil->currentLayout();
VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(origDstLayout);
VkAccessFlags dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
- VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
VkPipelineStageFlags srcStageMask =
GrVkMemory::LayoutToPipelineStageFlags(origDstLayout);
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
@@ -1381,15 +1383,33 @@ void GrVkGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertice
false);
}
- if (vertices.isIndexed()) {
- fCurrentCmdBuffer->drawIndexed(this,
- vertices.indexCount(),
- 1,
- vertices.startIndex(),
- vertices.startVertex(),
- 0);
- } else {
- fCurrentCmdBuffer->draw(this, vertices.vertexCount(), 1, vertices.startVertex(), 0);
+ fCurrentCmdBuffer->beginRenderPass(this, renderPass, *vkRT);
+
+ for (int i = 0; i < drawCount; ++i) {
+ if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps())) {
+ this->xferBarrier(pipeline.getRenderTarget(), barrierType);
+ }
+
+ const GrVertices& vertices = vertArray[i];
+ GrVertices::Iterator iter;
+ const GrNonInstancedVertices* verts = iter.init(vertices);
+ do {
+
+ this->bindGeometry(primProc, *verts);
+
+ if (vertices.isIndexed()) {
+ fCurrentCmdBuffer->drawIndexed(this,
+ verts->indexCount(),
+ 1,
+ verts->startIndex(),
+ verts->startVertex(),
+ 0);
+ } else {
+ fCurrentCmdBuffer->draw(this, verts->vertexCount(), 1, verts->startVertex(), 0);
+ }
+
+ fStats.incNumDraws();
+ } while ((verts = iter.next()));
}
fCurrentCmdBuffer->endRenderPass(this);

Powered by Google App Engine
This is Rietveld 408576698