diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-05-26 15:17:19 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-30 16:02:36 +0000 |
commit | 114a3c0b2b26c84b9d0907a99fd8ab7938631246 (patch) | |
tree | a243fad112a79f3375ae98f0c916db63d9cdc9c0 /src/gpu/vk/GrVkGpuCommandBuffer.cpp | |
parent | 8cc933104b0e965c4226c91701cee7586587409f (diff) |
Fix glDrawRangeElements
Adds explicit min/max index value fields to GrMesh. This eliminates the
previous assumption that the index values were within the range
[0..vertexCount-1]. In the pattern case we still maintain this
assumption.
Updates GrMesh to hide its fields and handle its new complexity using a
"helper" interface instead.
Adds a unit test for GrMesh.
Bug: skia:
Change-Id: Ia23de72d510f8827cee56072b727fb70a6e46b8d
Reviewed-on: https://skia-review.googlesource.com/17964
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkGpuCommandBuffer.cpp')
-rw-r--r-- | src/gpu/vk/GrVkGpuCommandBuffer.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index ad2dc0c06f..2e9373b130 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -544,8 +544,6 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline, return; } - CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; - for (int i = 0; i < meshCount; ++i) { const GrMesh& mesh = meshes[i]; if (mesh.primitiveType() != primitiveType) { @@ -564,32 +562,12 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline, } SkASSERT(pipelineState); - this->bindGeometry(primProc, mesh.indexBuffer(), mesh.vertexBuffer()); - - if (mesh.isIndexed()) { - for (const GrMesh::PatternBatch batch : mesh) { - cbInfo.currentCmdBuf()->drawIndexed(fGpu, - mesh.indexCount() * batch.fRepeatCount, - 1, - mesh.baseIndex(), - batch.fBaseVertex, - 0); - cbInfo.fIsEmpty = false; - fGpu->stats()->incNumDraws(); - } - } else { - cbInfo.currentCmdBuf()->draw(fGpu, - mesh.vertexCount(), - 1, - mesh.baseVertex(), - 0); - cbInfo.fIsEmpty = false; - fGpu->stats()->incNumDraws(); - } + mesh.sendToGpu(primProc, this); } - // Update command buffer bounds + CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; cbInfo.fBounds.join(bounds); + cbInfo.fIsEmpty = false; // Technically we don't have to call this here (since there is a safety check in // pipelineState:setData but this will allow for quicker freeing of resources if the @@ -597,3 +575,29 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline, pipelineState->freeTempResources(fGpu); } +void GrVkGpuCommandBuffer::sendMeshToGpu(const GrPrimitiveProcessor& primProc, + GrPrimitiveType, + const GrBuffer* vertexBuffer, + int vertexCount, + int baseVertex) { + CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; + this->bindGeometry(primProc, nullptr, vertexBuffer); + cbInfo.currentCmdBuf()->draw(fGpu, vertexCount, 1, baseVertex, 0); + fGpu->stats()->incNumDraws(); +} + +void GrVkGpuCommandBuffer::sendIndexedMeshToGpu(const GrPrimitiveProcessor& primProc, + GrPrimitiveType, + const GrBuffer* indexBuffer, + int indexCount, + int baseIndex, + uint16_t /*minIndexValue*/, + uint16_t /*maxIndexValue*/, + const GrBuffer* vertexBuffer, + int baseVertex) { + CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; + this->bindGeometry(primProc, indexBuffer, vertexBuffer); + cbInfo.currentCmdBuf()->drawIndexed(fGpu, indexCount, 1, baseIndex, baseVertex, 0); + fGpu->stats()->incNumDraws(); +} + |