Store GrRenderTarget in GrGpuCommandBuffer
Change-Id: I545d53ffb5f9d450b87a360516b03bdd47232a70 Reviewed-on: https://skia-review.googlesource.com/32460 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
69fd008199
commit
19e51dcd1e
@ -21,20 +21,19 @@ void GrGpuCommandBuffer::submit() {
|
||||
this->onSubmit();
|
||||
}
|
||||
|
||||
void GrGpuCommandBuffer::clear(GrRenderTargetProxy* proxy, const GrFixedClip& clip, GrColor color) {
|
||||
void GrGpuCommandBuffer::clear(const GrFixedClip& clip, GrColor color) {
|
||||
#ifdef SK_DEBUG
|
||||
GrRenderTarget* rt = proxy->priv().peekRenderTarget();
|
||||
GrRenderTarget* rt = fRenderTarget;
|
||||
SkASSERT(rt);
|
||||
SkASSERT(!clip.scissorEnabled() ||
|
||||
(SkIRect::MakeWH(rt->width(), rt->height()).contains(clip.scissorRect()) &&
|
||||
SkIRect::MakeWH(rt->width(), rt->height()) != clip.scissorRect()));
|
||||
#endif
|
||||
this->onClear(proxy, clip, color);
|
||||
this->onClear(clip, color);
|
||||
}
|
||||
|
||||
void GrGpuCommandBuffer::clearStencilClip(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
|
||||
bool insideStencilMask) {
|
||||
this->onClearStencilClip(proxy, clip, insideStencilMask);
|
||||
void GrGpuCommandBuffer::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
|
||||
this->onClearStencilClip(clip, insideStencilMask);
|
||||
}
|
||||
|
||||
bool GrGpuCommandBuffer::draw(const GrPipeline& pipeline,
|
||||
|
@ -27,12 +27,6 @@ struct SkRect;
|
||||
* the same render target. It is possible that these commands execute immediately (GL), or get
|
||||
* buffered up for later execution (Vulkan). GrOps will execute their draw commands into a
|
||||
* GrGpuCommandBuffer.
|
||||
*
|
||||
* Ideally we'd know the GrRenderTarget, or at least its properties when the GrGpuCommandBuffer, is
|
||||
* created. We also then wouldn't include it in the GrPipeline or as a parameter to the clear and
|
||||
* discard methods. The logical place for that will be in GrRenderTargetOpList post-MDB. For now
|
||||
* the render target is redundantly passed to each operation, though it will always be the same
|
||||
* render target for a given command buffer even pre-MDB.
|
||||
*/
|
||||
class GrGpuCommandBuffer {
|
||||
public:
|
||||
@ -60,7 +54,10 @@ public:
|
||||
StoreOp fStoreOp;
|
||||
};
|
||||
|
||||
GrGpuCommandBuffer() {}
|
||||
GrGpuCommandBuffer(GrRenderTarget* rt, GrSurfaceOrigin origin)
|
||||
: fRenderTarget(rt)
|
||||
, fOrigin(origin) {
|
||||
}
|
||||
virtual ~GrGpuCommandBuffer() {}
|
||||
|
||||
virtual void begin() = 0;
|
||||
@ -83,28 +80,29 @@ public:
|
||||
const SkRect& bounds);
|
||||
|
||||
// Performs an upload of vertex data in the middle of a set of a set of draws
|
||||
virtual void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&,
|
||||
GrRenderTargetProxy*) = 0;
|
||||
virtual void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&) = 0;
|
||||
|
||||
/**
|
||||
* Clear the passed in render target. Ignores the draw state and clip.
|
||||
* Clear the owned render target. Ignores the draw state and clip.
|
||||
*/
|
||||
void clear(GrRenderTargetProxy*, const GrFixedClip&, GrColor);
|
||||
void clear(const GrFixedClip&, GrColor);
|
||||
|
||||
void clearStencilClip(GrRenderTargetProxy*, const GrFixedClip&, bool insideStencilMask);
|
||||
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
|
||||
|
||||
/**
|
||||
* Discards the contents render target. nullptr indicates that the current render target should
|
||||
* be discarded.
|
||||
* Discards the contents render target.
|
||||
*/
|
||||
// TODO: This should be removed in the future to favor using the load and store ops for discard
|
||||
virtual void discard(GrRenderTargetProxy*) = 0;
|
||||
virtual void discard() = 0;
|
||||
|
||||
virtual void insertEventMarker(GrRenderTargetProxy*, const char*) = 0;
|
||||
virtual void insertEventMarker(const char*) = 0;
|
||||
|
||||
protected:
|
||||
GrRenderTarget* fRenderTarget;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
|
||||
private:
|
||||
virtual GrGpu* gpu() = 0;
|
||||
virtual GrRenderTarget* renderTarget() = 0;
|
||||
|
||||
virtual void onSubmit() = 0;
|
||||
|
||||
@ -117,11 +115,9 @@ private:
|
||||
const SkRect& bounds) = 0;
|
||||
|
||||
// overridden by backend-specific derived class to perform the clear.
|
||||
virtual void onClear(GrRenderTargetProxy*, const GrFixedClip&, GrColor) = 0;
|
||||
|
||||
virtual void onClearStencilClip(GrRenderTargetProxy*, const GrFixedClip&,
|
||||
bool insideStencilMask) = 0;
|
||||
virtual void onClear(const GrFixedClip&, GrColor) = 0;
|
||||
|
||||
virtual void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
struct DrawOpArgs {
|
||||
GrRenderTarget* renderTarget() const { return fProxy->priv().peekRenderTarget(); }
|
||||
|
||||
// TODO: do we still need the dst proxy here?
|
||||
GrRenderTargetProxy* fProxy;
|
||||
const GrAppliedClip* fAppliedClip;
|
||||
GrXferProcessor::DstProxy fDstProxy;
|
||||
|
@ -237,6 +237,7 @@ private:
|
||||
|
||||
DstTextureProxy fDstTextureProxy;
|
||||
SkIPoint fDstTextureOffset;
|
||||
// MDB TODO: do we still need the destination proxy here?
|
||||
RenderTargetProxy fProxy;
|
||||
GrScissorState fScissorState;
|
||||
GrWindowRectsState fWindowRectsState;
|
||||
|
@ -1972,7 +1972,8 @@ void GrGLGpu::disableScissor() {
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* target) {
|
||||
void GrGLGpu::clear(const GrFixedClip& clip, GrColor color,
|
||||
GrRenderTarget* target, GrSurfaceOrigin origin) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
// parent class should never let us get here with no RT
|
||||
@ -1980,7 +1981,7 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
|
||||
|
||||
this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() : nullptr);
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin());
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glRT);
|
||||
|
||||
GrGLfloat r, g, b, a;
|
||||
@ -2022,7 +2023,7 @@ void GrGLGpu::clearStencil(GrRenderTarget* target, int clearValue) {
|
||||
|
||||
void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
|
||||
bool insideStencilMask,
|
||||
GrRenderTarget* target) {
|
||||
GrRenderTarget* target, GrSurfaceOrigin origin) {
|
||||
SkASSERT(target);
|
||||
this->handleDirtyContext();
|
||||
|
||||
@ -2056,7 +2057,7 @@ void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
|
||||
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
|
||||
this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
|
||||
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin());
|
||||
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
|
||||
this->flushWindowRectangles(clip.windowRectsState(), glRT);
|
||||
|
||||
GL_CALL(StencilMask((uint32_t) clipStencilMask));
|
||||
@ -2448,10 +2449,10 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
|
||||
}
|
||||
|
||||
GrGpuCommandBuffer* GrGLGpu::createCommandBuffer(
|
||||
GrRenderTarget* rt, GrSurfaceOrigin,
|
||||
GrRenderTarget* rt, GrSurfaceOrigin origin,
|
||||
const GrGpuCommandBuffer::LoadAndStoreInfo&,
|
||||
const GrGpuCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
|
||||
return new GrGLGpuCommandBuffer(this, rt, stencilInfo);
|
||||
return new GrGLGpuCommandBuffer(this, rt, origin, stencilInfo);
|
||||
}
|
||||
|
||||
void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds, bool disableSRGB) {
|
||||
|
@ -131,12 +131,13 @@ public:
|
||||
// The GrGLGpuCommandBuffer does not buffer up draws before submitting them to the gpu.
|
||||
// Thus this is the implementation of the clear call for the corresponding passthrough function
|
||||
// on GrGLGpuCommandBuffer.
|
||||
void clear(const GrFixedClip&, GrColor, GrRenderTarget*);
|
||||
void clear(const GrFixedClip&, GrColor, GrRenderTarget*, GrSurfaceOrigin);
|
||||
|
||||
// The GrGLGpuCommandBuffer does not buffer up draws before submitting them to the gpu.
|
||||
// Thus this is the implementation of the clearStencil call for the corresponding passthrough
|
||||
// function on GrGLGpuCommandBuffer.
|
||||
void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTarget*);
|
||||
void clearStencilClip(const GrFixedClip&, bool insideStencilMask,
|
||||
GrRenderTarget*, GrSurfaceOrigin);
|
||||
|
||||
const GrGLContext* glContextForTesting() const override {
|
||||
return &this->glContext();
|
||||
|
@ -24,10 +24,10 @@ class GrGLGpuCommandBuffer : public GrGpuCommandBuffer {
|
||||
* pass through functions to corresponding calls in the GrGLGpu class.
|
||||
*/
|
||||
public:
|
||||
GrGLGpuCommandBuffer(GrGLGpu* gpu, GrRenderTarget* rt,
|
||||
GrGLGpuCommandBuffer(GrGLGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin,
|
||||
const GrGpuCommandBuffer::StencilLoadAndStoreInfo& stencilInfo)
|
||||
: fGpu(gpu)
|
||||
, fRenderTarget(static_cast<GrGLRenderTarget*>(rt)) {
|
||||
: INHERITED(rt, origin)
|
||||
, fGpu(gpu) {
|
||||
fClearSB = LoadOp::kClear == stencilInfo.fLoadOp;
|
||||
}
|
||||
|
||||
@ -40,32 +40,18 @@ public:
|
||||
}
|
||||
void end() override {}
|
||||
|
||||
void discard(GrRenderTargetProxy* proxy) override {
|
||||
GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
fRenderTarget = target;
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
}
|
||||
|
||||
void insertEventMarker(GrRenderTargetProxy* proxy, const char* msg) override {
|
||||
GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
fRenderTarget = target;
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
void discard() override { }
|
||||
|
||||
void insertEventMarker(const char* msg) override {
|
||||
fGpu->insertEventMarker(msg);
|
||||
}
|
||||
|
||||
void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload,
|
||||
GrRenderTargetProxy*) override {
|
||||
void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override {
|
||||
state->doUpload(upload);
|
||||
}
|
||||
|
||||
private:
|
||||
GrGpu* gpu() override { return fGpu; }
|
||||
GrRenderTarget* renderTarget() override { return fRenderTarget; }
|
||||
|
||||
void onSubmit() override {}
|
||||
|
||||
@ -75,35 +61,19 @@ private:
|
||||
const GrPipeline::DynamicState dynamicStates[],
|
||||
int meshCount,
|
||||
const SkRect& bounds) override {
|
||||
GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(pipeline.renderTarget());
|
||||
if (!fRenderTarget) {
|
||||
fRenderTarget = target;
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
SkASSERT(pipeline.renderTarget() == fRenderTarget);
|
||||
fGpu->draw(pipeline, primProc, mesh, dynamicStates, meshCount);
|
||||
}
|
||||
|
||||
void onClear(GrRenderTargetProxy* proxy, const GrFixedClip& clip, GrColor color) override {
|
||||
GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
fRenderTarget = target;
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
fGpu->clear(clip, color, fRenderTarget);
|
||||
void onClear(const GrFixedClip& clip, GrColor color) override {
|
||||
fGpu->clear(clip, color, fRenderTarget, fOrigin);
|
||||
}
|
||||
|
||||
void onClearStencilClip(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
|
||||
bool insideStencilMask) override {
|
||||
GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
fRenderTarget = target;
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget);
|
||||
void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override {
|
||||
fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget, fOrigin);
|
||||
}
|
||||
|
||||
GrGLGpu* fGpu;
|
||||
GrGLRenderTarget* fRenderTarget;
|
||||
bool fClearSB;
|
||||
|
||||
typedef GrGpuCommandBuffer INHERITED;
|
||||
|
@ -40,10 +40,10 @@ GrGpu* GrMockGpu::Create(const GrMockOptions* mockOptions, const GrContextOption
|
||||
|
||||
|
||||
GrGpuCommandBuffer* GrMockGpu::createCommandBuffer(
|
||||
GrRenderTarget*, GrSurfaceOrigin,
|
||||
GrRenderTarget* rt, GrSurfaceOrigin origin,
|
||||
const GrGpuCommandBuffer::LoadAndStoreInfo&,
|
||||
const GrGpuCommandBuffer::StencilLoadAndStoreInfo&) {
|
||||
return new GrMockGpuCommandBuffer(this);
|
||||
return new GrMockGpuCommandBuffer(this, rt, origin);
|
||||
}
|
||||
|
||||
void GrMockGpu::submitCommandBuffer(const GrMockGpuCommandBuffer* cmdBuffer) {
|
||||
|
@ -13,13 +13,15 @@
|
||||
|
||||
class GrMockGpuCommandBuffer : public GrGpuCommandBuffer {
|
||||
public:
|
||||
GrMockGpuCommandBuffer(GrMockGpu* gpu) : fGpu(gpu) {}
|
||||
GrMockGpuCommandBuffer(GrMockGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin)
|
||||
: INHERITED(rt, origin)
|
||||
, fGpu(gpu) {
|
||||
}
|
||||
|
||||
GrGpu* gpu() override { return fGpu; }
|
||||
void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&,
|
||||
GrRenderTargetProxy*) override {}
|
||||
void discard(GrRenderTargetProxy*) override {}
|
||||
void insertEventMarker(GrRenderTargetProxy*, const char*) override {}
|
||||
void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&) override {}
|
||||
void discard() override {}
|
||||
void insertEventMarker(const char*) override {}
|
||||
void begin() override {}
|
||||
void end() override {}
|
||||
|
||||
@ -31,10 +33,8 @@ private:
|
||||
const GrPipeline::DynamicState[], int meshCount, const SkRect& bounds) override {
|
||||
++fNumDraws;
|
||||
}
|
||||
void onClear(GrRenderTargetProxy*, const GrFixedClip&, GrColor) override {}
|
||||
void onClearStencilClip(GrRenderTargetProxy*, const GrFixedClip&,
|
||||
bool insideStencilMask) override {}
|
||||
GrRenderTarget* renderTarget() override { return nullptr; }
|
||||
void onClear(const GrFixedClip&, GrColor) override {}
|
||||
void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override {}
|
||||
|
||||
GrMockGpu* fGpu;
|
||||
int fNumDraws = 0;
|
||||
|
@ -32,7 +32,5 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro
|
||||
}
|
||||
|
||||
void GrClearOp::onExecute(GrOpFlushState* state) {
|
||||
SkASSERT(state->drawOpArgs().renderTarget());
|
||||
|
||||
state->commandBuffer()->clear(state->drawOpArgs().fProxy, fClip, fColor);
|
||||
state->commandBuffer()->clear(fClip, fColor);
|
||||
}
|
||||
|
@ -55,10 +55,7 @@ private:
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
||||
void onExecute(GrOpFlushState* state) override {
|
||||
SkASSERT(state->drawOpArgs().renderTarget());
|
||||
|
||||
GrRenderTargetProxy* proxy = state->drawOpArgs().fProxy;
|
||||
state->commandBuffer()->clearStencilClip(proxy, fClip, fInsideStencilMask);
|
||||
state->commandBuffer()->clearStencilClip(fClip, fInsideStencilMask);
|
||||
}
|
||||
|
||||
const GrFixedClip fClip;
|
||||
|
@ -42,11 +42,9 @@ private:
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
||||
void onExecute(GrOpFlushState* state) override {
|
||||
SkASSERT(state->drawOpArgs().renderTarget());
|
||||
|
||||
//SkDebugf("%s\n", fStr.c_str());
|
||||
if (state->caps().gpuTracingSupport()) {
|
||||
state->commandBuffer()->insertEventMarker(state->drawOpArgs().fProxy, fStr.c_str());
|
||||
state->commandBuffer()->insertEventMarker(fStr.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,7 @@ private:
|
||||
void onPrepare(GrOpFlushState*) override {}
|
||||
|
||||
void onExecute(GrOpFlushState* state) override {
|
||||
SkASSERT(state->drawOpArgs().renderTarget());
|
||||
|
||||
state->commandBuffer()->discard(state->drawOpArgs().fProxy);
|
||||
state->commandBuffer()->discard();
|
||||
}
|
||||
|
||||
typedef GrOp INHERITED;
|
||||
|
@ -69,8 +69,7 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state) {
|
||||
GrDrawOpUploadToken drawToken = state->nextTokenToFlush();
|
||||
while (currUploadIdx < fInlineUploads.count() &&
|
||||
fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) {
|
||||
state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload,
|
||||
state->drawOpArgs().fProxy);
|
||||
state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload);
|
||||
}
|
||||
const QueuedDraw& draw = fQueuedDraws[currDrawIdx];
|
||||
SkASSERT(draw.fPipeline->proxy() == state->drawOpArgs().fProxy);
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "GrOpFlushState.h"
|
||||
|
||||
void GrStencilPathOp::onExecute(GrOpFlushState* state) {
|
||||
SkASSERT(state->drawOpArgs().renderTarget());
|
||||
|
||||
GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
|
||||
&fViewMatrix, &fScissor, &fStencil);
|
||||
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
|
||||
|
@ -57,11 +57,10 @@ GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu,
|
||||
GrRenderTarget* rt, GrSurfaceOrigin origin,
|
||||
const LoadAndStoreInfo& colorInfo,
|
||||
const StencilLoadAndStoreInfo& stencilInfo)
|
||||
: fGpu(gpu)
|
||||
, fRenderTarget(nullptr)
|
||||
, fOrigin(kTopLeft_GrSurfaceOrigin)
|
||||
, fClearColor(GrColor4f::FromGrColor(colorInfo.fClearColor))
|
||||
, fLastPipelineState(nullptr) {
|
||||
: INHERITED(rt, origin)
|
||||
, fGpu(gpu)
|
||||
, fClearColor(GrColor4f::FromGrColor(colorInfo.fClearColor))
|
||||
, fLastPipelineState(nullptr) {
|
||||
get_vk_load_store_ops(colorInfo.fLoadOp, colorInfo.fStoreOp,
|
||||
&fVkColorLoadOp, &fVkColorStoreOp);
|
||||
|
||||
@ -69,14 +68,10 @@ GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu,
|
||||
&fVkStencilLoadOp, &fVkStencilStoreOp);
|
||||
fCurrentCmdInfo = -1;
|
||||
|
||||
this->init(static_cast<GrVkRenderTarget*>(rt), origin);
|
||||
this->init();
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin) {
|
||||
SkASSERT(!fRenderTarget);
|
||||
fRenderTarget = target;
|
||||
fOrigin = origin;
|
||||
|
||||
void GrVkGpuCommandBuffer::init() {
|
||||
GrVkRenderPass::LoadStoreOps vkColorOps(fVkColorLoadOp, fVkColorStoreOp);
|
||||
GrVkRenderPass::LoadStoreOps vkStencilOps(fVkStencilLoadOp, fVkStencilStoreOp);
|
||||
|
||||
@ -84,13 +79,14 @@ void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin
|
||||
SkASSERT(fCommandBufferInfos.count() == 1);
|
||||
fCurrentCmdInfo = 0;
|
||||
|
||||
const GrVkResourceProvider::CompatibleRPHandle& rpHandle = target->compatibleRenderPassHandle();
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
const GrVkResourceProvider::CompatibleRPHandle& rpHandle = vkRT->compatibleRenderPassHandle();
|
||||
if (rpHandle.isValid()) {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
} else {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*target,
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
}
|
||||
@ -108,7 +104,7 @@ void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin
|
||||
cbInfo.fStartsWithClear = false;
|
||||
|
||||
cbInfo.fCommandBuffers.push_back(fGpu->resourceProvider().findOrCreateSecondaryCommandBuffer());
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, target->framebuffer(), cbInfo.fRenderPass);
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +119,6 @@ GrVkGpuCommandBuffer::~GrVkGpuCommandBuffer() {
|
||||
}
|
||||
|
||||
GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; }
|
||||
GrRenderTarget* GrVkGpuCommandBuffer::renderTarget() { return fRenderTarget; }
|
||||
|
||||
void GrVkGpuCommandBuffer::begin() {
|
||||
// TODO: remove this - see skbug.com/6936
|
||||
@ -142,10 +137,12 @@ void GrVkGpuCommandBuffer::onSubmit() {
|
||||
if (!fRenderTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
|
||||
// Change layout of our render target so it can be used as the color attachment. Currently
|
||||
// we don't attach the resolve to the framebuffer so no need to change its layout.
|
||||
GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaImage()
|
||||
: fRenderTarget;
|
||||
GrVkImage* targetImage = vkRT->msaaImage() ? vkRT->msaaImage() : vkRT;
|
||||
|
||||
// Change layout of our render target so it can be used as the color attachment
|
||||
targetImage->setImageLayout(fGpu,
|
||||
@ -194,17 +191,13 @@ void GrVkGpuCommandBuffer::onSubmit() {
|
||||
fGpu->submitSecondaryCommandBuffer(cbInfo.fCommandBuffers, cbInfo.fRenderPass,
|
||||
&cbInfo.fColorClearValue,
|
||||
&cbInfo.fStencilClearValue,
|
||||
fRenderTarget, iBounds);
|
||||
vkRT, iBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
|
||||
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
this->init(target, proxy->origin());
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
void GrVkGpuCommandBuffer::discard() {
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
|
||||
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
|
||||
if (cbInfo.fIsEmpty) {
|
||||
@ -217,13 +210,13 @@ void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
|
||||
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
|
||||
|
||||
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
|
||||
fRenderTarget->compatibleRenderPassHandle();
|
||||
vkRT->compatibleRenderPassHandle();
|
||||
if (rpHandle.isValid()) {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
} else {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
}
|
||||
@ -235,20 +228,13 @@ void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::insertEventMarker(GrRenderTargetProxy* proxy, const char* msg) {
|
||||
void GrVkGpuCommandBuffer::insertEventMarker(const char* msg) {
|
||||
// TODO: does Vulkan have a correlate?
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
|
||||
bool insideStencilMask) {
|
||||
void GrVkGpuCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
|
||||
SkASSERT(!clip.hasWindowRectangles());
|
||||
|
||||
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
this->init(target, proxy->origin());
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
|
||||
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
|
||||
|
||||
GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
|
||||
@ -306,17 +292,12 @@ void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTargetProxy* proxy, const
|
||||
}
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
|
||||
GrColor color) {
|
||||
void GrVkGpuCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
|
||||
// parent class should never let us get here with no RT
|
||||
SkASSERT(!clip.hasWindowRectangles());
|
||||
|
||||
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
this->init(target, proxy->origin());
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
|
||||
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
|
||||
|
||||
VkClearColorValue vkColor;
|
||||
@ -332,13 +313,13 @@ void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip
|
||||
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
|
||||
|
||||
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
|
||||
fRenderTarget->compatibleRenderPassHandle();
|
||||
vkRT->compatibleRenderPassHandle();
|
||||
if (rpHandle.isValid()) {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
} else {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
}
|
||||
@ -393,13 +374,17 @@ void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::addAdditionalCommandBuffer() {
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
|
||||
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
|
||||
cbInfo.currentCmdBuf()->end(fGpu);
|
||||
cbInfo.fCommandBuffers.push_back(fGpu->resourceProvider().findOrCreateSecondaryCommandBuffer());
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass);
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
|
||||
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
|
||||
|
||||
fCommandBufferInfos[fCurrentCmdInfo].currentCmdBuf()->end(fGpu);
|
||||
|
||||
CommandBufferInfo& cbInfo = fCommandBufferInfos.push_back();
|
||||
@ -411,13 +396,13 @@ void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
|
||||
VK_ATTACHMENT_STORE_OP_STORE);
|
||||
|
||||
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
|
||||
fRenderTarget->compatibleRenderPassHandle();
|
||||
vkRT->compatibleRenderPassHandle();
|
||||
if (rpHandle.isValid()) {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
} else {
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
|
||||
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
|
||||
vkColorOps,
|
||||
vkStencilOps);
|
||||
}
|
||||
@ -431,15 +416,11 @@ void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
|
||||
cbInfo.fIsEmpty = true;
|
||||
cbInfo.fStartsWithClear = false;
|
||||
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass);
|
||||
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
|
||||
}
|
||||
|
||||
void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload,
|
||||
GrRenderTargetProxy* proxy) {
|
||||
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
|
||||
if (!fRenderTarget) {
|
||||
this->init(target, proxy->origin());
|
||||
}
|
||||
void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) {
|
||||
|
||||
if (!fCommandBufferInfos[fCurrentCmdInfo].fIsEmpty) {
|
||||
this->addAdditionalRenderPass();
|
||||
}
|
||||
@ -573,11 +554,7 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
|
||||
const GrPipeline::DynamicState dynamicStates[],
|
||||
int meshCount,
|
||||
const SkRect& bounds) {
|
||||
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(pipeline.renderTarget());
|
||||
if (!fRenderTarget) {
|
||||
this->init(target, pipeline.proxy()->origin());
|
||||
}
|
||||
SkASSERT(target == fRenderTarget);
|
||||
SkASSERT(pipeline.renderTarget() == fRenderTarget);
|
||||
|
||||
if (!meshCount) {
|
||||
return;
|
||||
@ -623,7 +600,8 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
|
||||
if (dynamicStates) {
|
||||
if (pipeline.getScissorState().enabled()) {
|
||||
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
|
||||
target, dynamicStates[i].fScissorRect);
|
||||
fRenderTarget,
|
||||
dynamicStates[i].fScissorRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,18 +32,15 @@ public:
|
||||
void begin() override;
|
||||
void end() override;
|
||||
|
||||
void discard(GrRenderTargetProxy*) override;
|
||||
void insertEventMarker(GrRenderTargetProxy*, const char*) override;
|
||||
void discard() override;
|
||||
void insertEventMarker(const char*) override;
|
||||
|
||||
void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload,
|
||||
GrRenderTargetProxy*) override;
|
||||
void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override;
|
||||
|
||||
private:
|
||||
// Performs lazy initialization on the first operation seen by the command buffer.
|
||||
void init(GrVkRenderTarget*, GrSurfaceOrigin);
|
||||
void init();
|
||||
|
||||
GrGpu* gpu() override;
|
||||
GrRenderTarget* renderTarget() override;
|
||||
|
||||
void onSubmit() override;
|
||||
|
||||
@ -92,10 +89,9 @@ private:
|
||||
const GrBuffer* instanceBuffer, int instanceCount,
|
||||
int baseInstance) final;
|
||||
|
||||
void onClear(GrRenderTargetProxy*, const GrFixedClip&, GrColor color) override;
|
||||
void onClear(const GrFixedClip&, GrColor color) override;
|
||||
|
||||
void onClearStencilClip(GrRenderTargetProxy*, const GrFixedClip&,
|
||||
bool insideStencilMask) override;
|
||||
void onClearStencilClip(const GrFixedClip&, bool insideStencilMask) override;
|
||||
|
||||
void addAdditionalCommandBuffer();
|
||||
void addAdditionalRenderPass();
|
||||
@ -127,8 +123,6 @@ private:
|
||||
int fCurrentCmdInfo;
|
||||
|
||||
GrVkGpu* fGpu;
|
||||
GrVkRenderTarget* fRenderTarget;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
VkAttachmentLoadOp fVkColorLoadOp;
|
||||
VkAttachmentStoreOp fVkColorStoreOp;
|
||||
VkAttachmentLoadOp fVkStencilLoadOp;
|
||||
|
Loading…
Reference in New Issue
Block a user