Tweaks to Metal pipeline state.
Bug: skia:8243 Change-Id: If2a0d38eedb197175b69d3c3b8422e4dfbfa8e02 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201610 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
29aa44353f
commit
ba91f65f20
@ -148,12 +148,16 @@ void GrMtlGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
|
|||||||
SkASSERT(fActiveRenderCmdEncoder);
|
SkASSERT(fActiveRenderCmdEncoder);
|
||||||
// TODO: can we set this once somewhere at the beginning of the draw?
|
// TODO: can we set this once somewhere at the beginning of the draw?
|
||||||
[fActiveRenderCmdEncoder setFrontFacingWinding:MTLWindingCounterClockwise];
|
[fActiveRenderCmdEncoder setFrontFacingWinding:MTLWindingCounterClockwise];
|
||||||
|
// Strictly speaking we shouldn't have to set this, as the default viewport is the size of
|
||||||
|
// the drawable used to generate the renderCommandEncoder -- but just in case.
|
||||||
|
MTLViewport viewport = { 0.0, 0.0,
|
||||||
|
(double) fRenderTarget->width(), (double) fRenderTarget->height(),
|
||||||
|
0.0, 1.0 };
|
||||||
|
[fActiveRenderCmdEncoder setViewport:viewport];
|
||||||
|
|
||||||
[fActiveRenderCmdEncoder setRenderPipelineState:pipelineState->mtlPipelineState()];
|
[fActiveRenderCmdEncoder setRenderPipelineState:pipelineState->mtlPipelineState()];
|
||||||
pipelineState->bind(fActiveRenderCmdEncoder);
|
pipelineState->setDrawState(fActiveRenderCmdEncoder, fRenderTarget->config(),
|
||||||
pipelineState->setBlendConstants(fActiveRenderCmdEncoder, fRenderTarget->config(),
|
pipeline.getXferProcessor());
|
||||||
pipeline.getXferProcessor());
|
|
||||||
pipelineState->setDepthStencilState(fActiveRenderCmdEncoder);
|
|
||||||
|
|
||||||
bool dynamicScissor =
|
bool dynamicScissor =
|
||||||
pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects;
|
pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects;
|
||||||
@ -182,10 +186,8 @@ void GrMtlGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
[fActiveRenderCmdEncoder setRenderPipelineState:pipelineState->mtlPipelineState()];
|
[fActiveRenderCmdEncoder setRenderPipelineState:pipelineState->mtlPipelineState()];
|
||||||
pipelineState->bind(fActiveRenderCmdEncoder);
|
pipelineState->setDrawState(fActiveRenderCmdEncoder, fRenderTarget->config(),
|
||||||
pipelineState->setBlendConstants(fActiveRenderCmdEncoder, fRenderTarget->config(),
|
pipeline.getXferProcessor());
|
||||||
pipeline.getXferProcessor());
|
|
||||||
pipelineState->setDepthStencilState(fActiveRenderCmdEncoder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamicScissor) {
|
if (dynamicScissor) {
|
||||||
|
@ -51,11 +51,7 @@ public:
|
|||||||
const GrPrimitiveProcessor& primPRoc, const GrPipeline& pipeline,
|
const GrPrimitiveProcessor& primPRoc, const GrPipeline& pipeline,
|
||||||
const GrTextureProxy* const primProcTextures[]);
|
const GrTextureProxy* const primProcTextures[]);
|
||||||
|
|
||||||
void bind(id<MTLRenderCommandEncoder>);
|
void setDrawState(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
|
||||||
|
|
||||||
void setBlendConstants(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
|
|
||||||
|
|
||||||
void setDepthStencilState(id<MTLRenderCommandEncoder> renderCmdEncoder);
|
|
||||||
|
|
||||||
static void SetDynamicScissorRectState(id<MTLRenderCommandEncoder> renderCmdEncoder,
|
static void SetDynamicScissorRectState(id<MTLRenderCommandEncoder> renderCmdEncoder,
|
||||||
const GrRenderTarget* renderTarget,
|
const GrRenderTarget* renderTarget,
|
||||||
@ -101,6 +97,12 @@ private:
|
|||||||
|
|
||||||
void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin);
|
void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin);
|
||||||
|
|
||||||
|
void bind(id<MTLRenderCommandEncoder>);
|
||||||
|
|
||||||
|
void setBlendConstants(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
|
||||||
|
|
||||||
|
void setDepthStencilState(id<MTLRenderCommandEncoder> renderCmdEncoder);
|
||||||
|
|
||||||
struct SamplerBindings {
|
struct SamplerBindings {
|
||||||
id<MTLSamplerState> fSampler;
|
id<MTLSamplerState> fSampler;
|
||||||
id<MTLTexture> fTexture;
|
id<MTLTexture> fTexture;
|
||||||
|
@ -118,6 +118,13 @@ void GrMtlPipelineState::setData(const GrRenderTarget* renderTarget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GrMtlPipelineState::setDrawState(id<MTLRenderCommandEncoder> renderCmdEncoder,
|
||||||
|
GrPixelConfig config, const GrXferProcessor& xferProcessor) {
|
||||||
|
this->bind(renderCmdEncoder);
|
||||||
|
this->setBlendConstants(renderCmdEncoder, config, xferProcessor);
|
||||||
|
this->setDepthStencilState(renderCmdEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
void GrMtlPipelineState::bind(id<MTLRenderCommandEncoder> renderCmdEncoder) {
|
void GrMtlPipelineState::bind(id<MTLRenderCommandEncoder> renderCmdEncoder) {
|
||||||
if (fGeometryUniformBuffer) {
|
if (fGeometryUniformBuffer) {
|
||||||
[renderCmdEncoder setVertexBuffer: fGeometryUniformBuffer->mtlBuffer()
|
[renderCmdEncoder setVertexBuffer: fGeometryUniformBuffer->mtlBuffer()
|
||||||
|
Loading…
Reference in New Issue
Block a user