Dawn: update for GrGpuCommandBuffer -> GrOpsRenderPass change.

Change-Id: Ifbe4bcd40bcf316868d23c2edf73b2371c6cb312
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237119
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2019-08-26 15:19:42 -04:00 committed by Skia Commit-Bot
parent 7c73d2c5ed
commit ef2dc90172
5 changed files with 66 additions and 115 deletions

View File

@ -715,8 +715,8 @@ skia_dawn_sources = [
"$_src/gpu/dawn/GrDawnCaps.h", "$_src/gpu/dawn/GrDawnCaps.h",
"$_src/gpu/dawn/GrDawnGpu.cpp", "$_src/gpu/dawn/GrDawnGpu.cpp",
"$_src/gpu/dawn/GrDawnGpu.h", "$_src/gpu/dawn/GrDawnGpu.h",
"$_src/gpu/dawn/GrDawnGpuCommandBuffer.cpp", "$_src/gpu/dawn/GrDawnOpsRenderPass.cpp",
"$_src/gpu/dawn/GrDawnGpuCommandBuffer.h", "$_src/gpu/dawn/GrDawnOpsRenderPass.h",
"$_src/gpu/dawn/GrDawnProgramDataManager.cpp", "$_src/gpu/dawn/GrDawnProgramDataManager.cpp",
"$_src/gpu/dawn/GrDawnProgramDataManager.h", "$_src/gpu/dawn/GrDawnProgramDataManager.h",
"$_src/gpu/dawn/GrDawnProgramBuilder.cpp", "$_src/gpu/dawn/GrDawnProgramBuilder.cpp",

View File

@ -19,7 +19,7 @@
#include "src/gpu/GrTexturePriv.h" #include "src/gpu/GrTexturePriv.h"
#include "src/gpu/dawn/GrDawnBuffer.h" #include "src/gpu/dawn/GrDawnBuffer.h"
#include "src/gpu/dawn/GrDawnCaps.h" #include "src/gpu/dawn/GrDawnCaps.h"
#include "src/gpu/dawn/GrDawnGpuCommandBuffer.h" #include "src/gpu/dawn/GrDawnOpsRenderPass.h"
#include "src/gpu/dawn/GrDawnRenderTarget.h" #include "src/gpu/dawn/GrDawnRenderTarget.h"
#include "src/gpu/dawn/GrDawnStencilAttachment.h" #include "src/gpu/dawn/GrDawnStencilAttachment.h"
#include "src/gpu/dawn/GrDawnTexture.h" #include "src/gpu/dawn/GrDawnTexture.h"
@ -64,18 +64,12 @@ void GrDawnGpu::disconnect(DisconnectType type) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
GrGpuRTCommandBuffer* GrDawnGpu::getCommandBuffer( GrOpsRenderPass* GrDawnGpu::getOpsRenderPass(
GrRenderTarget* rt, GrSurfaceOrigin origin, const SkRect& bounds, GrRenderTarget* rt, GrSurfaceOrigin origin, const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo, const GrOpsRenderPass::LoadAndStoreInfo& colorInfo,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) { const GrOpsRenderPass::StencilLoadAndStoreInfo& stencilInfo) {
fRTCommandBuffer.reset(new GrDawnGpuRTCommandBuffer(this, rt, origin, colorInfo, stencilInfo)); fOpsRenderPass.reset(new GrDawnOpsRenderPass(this, rt, origin, colorInfo, stencilInfo));
return fRTCommandBuffer.get(); return fOpsRenderPass.get();
}
GrGpuTextureCommandBuffer* GrDawnGpu::getCommandBuffer(GrTexture* texture,
GrSurfaceOrigin origin) {
fTextureCommandBuffer.reset(new GrDawnGpuTextureCommandBuffer(this, texture, origin));
return fTextureCommandBuffer.get();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -512,14 +506,8 @@ bool GrDawnGpu::onRegenerateMipMapLevels(GrTexture*) {
return false; return false;
} }
void GrDawnGpu::submit(GrGpuCommandBuffer* buffer) { void GrDawnGpu::submit(GrOpsRenderPass* renderPass) {
if (buffer->asRTCommandBuffer()) { static_cast<GrDawnOpsRenderPass*>(renderPass)->submit();
SkASSERT(fRTCommandBuffer.get() == buffer);
fRTCommandBuffer->submit();
} else {
SkASSERT(fTextureCommandBuffer.get() == buffer);
fTextureCommandBuffer->submit();
}
} }
GrFence SK_WARN_UNUSED_RESULT GrDawnGpu::insertFence() { GrFence SK_WARN_UNUSED_RESULT GrDawnGpu::insertFence() {

View File

@ -12,9 +12,8 @@
#include "dawn/dawncpp.h" #include "dawn/dawncpp.h"
#include "src/gpu/dawn/GrDawnRingBuffer.h" #include "src/gpu/dawn/GrDawnRingBuffer.h"
class GrDawnOpsRenderPass;
class GrPipeline; class GrPipeline;
class GrDawnGpuRTCommandBuffer;
class GrDawnGpuTextureCommandBuffer;
namespace SkSL { namespace SkSL {
class Compiler; class Compiler;
@ -57,18 +56,17 @@ public:
int height, int height,
int numStencilSamples) override; int numStencilSamples) override;
GrGpuRTCommandBuffer* getCommandBuffer( GrOpsRenderPass* getOpsRenderPass(
GrRenderTarget*, GrSurfaceOrigin, const SkRect& bounds, GrRenderTarget*, GrSurfaceOrigin, const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&, const GrOpsRenderPass::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override; const GrOpsRenderPass::StencilLoadAndStoreInfo&) override;
GrGpuTextureCommandBuffer* getCommandBuffer(GrTexture*, GrSurfaceOrigin) override;
SkSL::Compiler* shaderCompiler() const { SkSL::Compiler* shaderCompiler() const {
return fCompiler.get(); return fCompiler.get();
} }
void submit(GrGpuCommandBuffer* cb) override; void submit(GrOpsRenderPass*) override;
GrFence SK_WARN_UNUSED_RESULT insertFence() override; GrFence SK_WARN_UNUSED_RESULT insertFence() override;
bool waitFence(GrFence, uint64_t timeout) override; bool waitFence(GrFence, uint64_t timeout) override;
void deleteFence(GrFence) const override; void deleteFence(GrFence) const override;
@ -147,8 +145,7 @@ private:
dawn::Device fDevice; dawn::Device fDevice;
dawn::Queue fQueue; dawn::Queue fQueue;
std::unique_ptr<SkSL::Compiler> fCompiler; std::unique_ptr<SkSL::Compiler> fCompiler;
std::unique_ptr<GrDawnGpuRTCommandBuffer> fRTCommandBuffer; std::unique_ptr<GrDawnOpsRenderPass> fOpsRenderPass;
std::unique_ptr<GrDawnGpuTextureCommandBuffer> fTextureCommandBuffer;
GrDawnRingBuffer fUniformRingBuffer; GrDawnRingBuffer fUniformRingBuffer;
typedef GrGpu INHERITED; typedef GrGpu INHERITED;

View File

@ -5,7 +5,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "src/gpu/dawn/GrDawnGpuCommandBuffer.h" #include "src/gpu/dawn/GrDawnOpsRenderPass.h"
#include "src/gpu/GrFixedClip.h" #include "src/gpu/GrFixedClip.h"
#include "src/gpu/GrMesh.h" #include "src/gpu/GrMesh.h"
@ -22,23 +22,6 @@
#include "src/gpu/dawn/GrDawnUtil.h" #include "src/gpu/dawn/GrDawnUtil.h"
#include "src/sksl/SkSLCompiler.h" #include "src/sksl/SkSLCompiler.h"
GrDawnGpuTextureCommandBuffer::GrDawnGpuTextureCommandBuffer(GrDawnGpu* gpu,
GrTexture* texture,
GrSurfaceOrigin origin)
: INHERITED(texture, origin)
, fGpu(gpu) {
fEncoder = fGpu->device().CreateCommandEncoder();
}
void GrDawnGpuTextureCommandBuffer::submit() {
dawn::CommandBuffer commandBuffer = fEncoder.Finish();
if (commandBuffer) {
fGpu->queue().Submit(1, &commandBuffer);
}
}
GrDawnGpuTextureCommandBuffer::~GrDawnGpuTextureCommandBuffer() {}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static dawn::LoadOp to_dawn_load_op(GrLoadOp loadOp) { static dawn::LoadOp to_dawn_load_op(GrLoadOp loadOp) {
@ -59,10 +42,9 @@ static dawn::LoadOp to_dawn_load_op(GrLoadOp loadOp) {
} }
} }
GrDawnGpuRTCommandBuffer::GrDawnGpuRTCommandBuffer(GrDawnGpu* gpu, GrDawnOpsRenderPass::GrDawnOpsRenderPass(GrDawnGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin,
GrRenderTarget* rt, GrSurfaceOrigin origin, const LoadAndStoreInfo& colorInfo,
const LoadAndStoreInfo& colorInfo, const StencilLoadAndStoreInfo& stencilInfo)
const StencilLoadAndStoreInfo& stencilInfo)
: INHERITED(rt, origin) : INHERITED(rt, origin)
, fGpu(gpu) , fGpu(gpu)
, fColorInfo(colorInfo) { , fColorInfo(colorInfo) {
@ -72,8 +54,8 @@ GrDawnGpuRTCommandBuffer::GrDawnGpuRTCommandBuffer(GrDawnGpu* gpu,
fPassEncoder = beginRenderPass(colorOp, stencilOp); fPassEncoder = beginRenderPass(colorOp, stencilOp);
} }
dawn::RenderPassEncoder GrDawnGpuRTCommandBuffer::beginRenderPass(dawn::LoadOp colorOp, dawn::RenderPassEncoder GrDawnOpsRenderPass::beginRenderPass(dawn::LoadOp colorOp,
dawn::LoadOp stencilOp) { dawn::LoadOp stencilOp) {
dawn::Texture texture = static_cast<GrDawnRenderTarget*>(fRenderTarget)->texture(); dawn::Texture texture = static_cast<GrDawnRenderTarget*>(fRenderTarget)->texture();
auto stencilAttachment = static_cast<GrDawnStencilAttachment*>( auto stencilAttachment = static_cast<GrDawnStencilAttachment*>(
fRenderTarget->renderTargetPriv().getStencilAttachment()); fRenderTarget->renderTargetPriv().getStencilAttachment());
@ -106,40 +88,40 @@ dawn::RenderPassEncoder GrDawnGpuRTCommandBuffer::beginRenderPass(dawn::LoadOp c
return fEncoder.BeginRenderPass(&renderPassDescriptor); return fEncoder.BeginRenderPass(&renderPassDescriptor);
} }
GrDawnGpuRTCommandBuffer::~GrDawnGpuRTCommandBuffer() { GrDawnOpsRenderPass::~GrDawnOpsRenderPass() {
} }
GrGpu* GrDawnGpuRTCommandBuffer::gpu() { return fGpu; } GrGpu* GrDawnOpsRenderPass::gpu() { return fGpu; }
void GrDawnGpuRTCommandBuffer::end() { void GrDawnOpsRenderPass::end() {
fPassEncoder.EndPass(); fPassEncoder.EndPass();
} }
void GrDawnGpuRTCommandBuffer::submit() { void GrDawnOpsRenderPass::submit() {
dawn::CommandBuffer commandBuffer = fEncoder.Finish(); dawn::CommandBuffer commandBuffer = fEncoder.Finish();
if (commandBuffer) { if (commandBuffer) {
fGpu->queue().Submit(1, &commandBuffer); fGpu->queue().Submit(1, &commandBuffer);
} }
} }
void GrDawnGpuRTCommandBuffer::insertEventMarker(const char* msg) { void GrDawnOpsRenderPass::insertEventMarker(const char* msg) {
SkASSERT(!"unimplemented"); SkASSERT(!"unimplemented");
} }
void GrDawnGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { void GrDawnOpsRenderPass::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
fPassEncoder.EndPass(); fPassEncoder.EndPass();
fPassEncoder = beginRenderPass(dawn::LoadOp::Load, dawn::LoadOp::Clear); fPassEncoder = beginRenderPass(dawn::LoadOp::Load, dawn::LoadOp::Clear);
} }
void GrDawnGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) { void GrDawnOpsRenderPass::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
fPassEncoder.EndPass(); fPassEncoder.EndPass();
fPassEncoder = beginRenderPass(dawn::LoadOp::Clear, dawn::LoadOp::Load); fPassEncoder = beginRenderPass(dawn::LoadOp::Clear, dawn::LoadOp::Load);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void GrDawnGpuRTCommandBuffer::inlineUpload(GrOpFlushState* state, void GrDawnOpsRenderPass::inlineUpload(GrOpFlushState* state,
GrDeferredTextureUploadFn& upload) { GrDeferredTextureUploadFn& upload) {
SkASSERT(!"unimplemented"); SkASSERT(!"unimplemented");
} }
@ -190,7 +172,7 @@ static dawn::PrimitiveTopology to_dawn_primitive_topology(GrPrimitiveType primit
} }
} }
void GrDawnGpuRTCommandBuffer::setScissorState( void GrDawnOpsRenderPass::setScissorState(
const GrPipeline& pipeline, const GrPipeline& pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState, const GrPipeline::FixedDynamicState* fixedDynamicState,
const GrPipeline::DynamicStateArrays* dynamicStateArrays) { const GrPipeline::DynamicStateArrays* dynamicStateArrays) {
@ -208,7 +190,7 @@ void GrDawnGpuRTCommandBuffer::setScissorState(
fPassEncoder.SetScissorRect(rect.x(), rect.y(), rect.width(), rect.height()); fPassEncoder.SetScissorRect(rect.x(), rect.y(), rect.width(), rect.height());
} }
void GrDawnGpuRTCommandBuffer::applyState(const GrPipeline& pipeline, void GrDawnOpsRenderPass::applyState(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc, const GrPrimitiveProcessor& primProc,
const GrTextureProxy* const primProcProxies[], const GrTextureProxy* const primProcProxies[],
const GrPipeline::FixedDynamicState* fixedDynamicState, const GrPipeline::FixedDynamicState* fixedDynamicState,
@ -316,13 +298,13 @@ void GrDawnGpuRTCommandBuffer::applyState(const GrPipeline& pipeline,
this->setScissorState(pipeline, fixedDynamicState, dynamicStateArrays); this->setScissorState(pipeline, fixedDynamicState, dynamicStateArrays);
} }
void GrDawnGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc, void GrDawnOpsRenderPass::onDraw(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline, const GrPipeline& pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState, const GrPipeline::FixedDynamicState* fixedDynamicState,
const GrPipeline::DynamicStateArrays* dynamicStateArrays, const GrPipeline::DynamicStateArrays* dynamicStateArrays,
const GrMesh meshes[], const GrMesh meshes[],
int meshCount, int meshCount,
const SkRect& bounds) { const SkRect& bounds) {
if (!meshCount) { if (!meshCount) {
return; return;
} }
@ -345,13 +327,13 @@ void GrDawnGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
} }
} }
void GrDawnGpuRTCommandBuffer::sendInstancedMeshToGpu(GrPrimitiveType, void GrDawnOpsRenderPass::sendInstancedMeshToGpu(GrPrimitiveType,
const GrBuffer* vertexBuffer, const GrBuffer* vertexBuffer,
int vertexCount, int vertexCount,
int baseVertex, int baseVertex,
const GrBuffer* instanceBuffer, const GrBuffer* instanceBuffer,
int instanceCount, int instanceCount,
int baseInstance) { int baseInstance) {
static const uint64_t vertexBufferOffsets[1] = {0}; static const uint64_t vertexBufferOffsets[1] = {0};
dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get(); dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();
fPassEncoder.SetVertexBuffers(0, 1, &vb, vertexBufferOffsets); fPassEncoder.SetVertexBuffers(0, 1, &vb, vertexBufferOffsets);
@ -359,16 +341,16 @@ void GrDawnGpuRTCommandBuffer::sendInstancedMeshToGpu(GrPrimitiveType,
fGpu->stats()->incNumDraws(); fGpu->stats()->incNumDraws();
} }
void GrDawnGpuRTCommandBuffer::sendIndexedInstancedMeshToGpu(GrPrimitiveType, void GrDawnOpsRenderPass::sendIndexedInstancedMeshToGpu(GrPrimitiveType,
const GrBuffer* indexBuffer, const GrBuffer* indexBuffer,
int indexCount, int indexCount,
int baseIndex, int baseIndex,
const GrBuffer* vertexBuffer, const GrBuffer* vertexBuffer,
int baseVertex, int baseVertex,
const GrBuffer* instanceBuffer, const GrBuffer* instanceBuffer,
int instanceCount, int instanceCount,
int baseInstance, int baseInstance,
GrPrimitiveRestart restart) { GrPrimitiveRestart restart) {
uint64_t vertexBufferOffsets[1]; uint64_t vertexBufferOffsets[1];
vertexBufferOffsets[0] = 0; vertexBufferOffsets[0] = 0;
dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get(); dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();

View File

@ -5,10 +5,10 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef GrDawnGpuCommandBuffer_DEFINED #ifndef GrDawnOpsRenderPass_DEFINED
#define GrDawnGpuCommandBuffer_DEFINED #define GrDawnOpsRenderPass_DEFINED
#include "src/gpu/GrGpuCommandBuffer.h" #include "src/gpu/GrOpsRenderPass.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "src/gpu/GrColor.h" #include "src/gpu/GrColor.h"
@ -18,28 +18,12 @@
class GrDawnGpu; class GrDawnGpu;
class GrDawnRenderTarget; class GrDawnRenderTarget;
class GrDawnGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer { class GrDawnOpsRenderPass : public GrOpsRenderPass, private GrMesh::SendToGpuImpl {
public: public:
GrDawnGpuTextureCommandBuffer(GrDawnGpu* gpu, GrTexture* texture, GrSurfaceOrigin origin); GrDawnOpsRenderPass(GrDawnGpu*, GrRenderTarget*, GrSurfaceOrigin,
~GrDawnGpuTextureCommandBuffer() override; const LoadAndStoreInfo&, const StencilLoadAndStoreInfo&);
void insertEventMarker(const char*) override {} ~GrDawnOpsRenderPass() override;
void submit();
private:
GrDawnGpu* fGpu;
dawn::CommandEncoder fEncoder;
typedef GrGpuTextureCommandBuffer INHERITED;
};
class GrDawnGpuRTCommandBuffer : public GrGpuRTCommandBuffer, private GrMesh::SendToGpuImpl {
public:
GrDawnGpuRTCommandBuffer(GrDawnGpu*, GrRenderTarget*, GrSurfaceOrigin,
const LoadAndStoreInfo&,
const StencilLoadAndStoreInfo&);
~GrDawnGpuRTCommandBuffer() override;
void begin() override { } void begin() override { }
void end() override; void end() override;
@ -116,7 +100,7 @@ private:
dawn::RenderPassEncoder fPassEncoder; dawn::RenderPassEncoder fPassEncoder;
LoadAndStoreInfo fColorInfo; LoadAndStoreInfo fColorInfo;
typedef GrGpuRTCommandBuffer INHERITED; typedef GrOpsRenderPass INHERITED;
}; };
#endif #endif