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:
Jim Van Verth 2019-03-19 12:18:31 -04:00 committed by Skia Commit-Bot
parent 29aa44353f
commit ba91f65f20
3 changed files with 24 additions and 13 deletions

View File

@ -148,12 +148,16 @@ void GrMtlGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
SkASSERT(fActiveRenderCmdEncoder);
// TODO: can we set this once somewhere at the beginning of the draw?
[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()];
pipelineState->bind(fActiveRenderCmdEncoder);
pipelineState->setBlendConstants(fActiveRenderCmdEncoder, fRenderTarget->config(),
pipeline.getXferProcessor());
pipelineState->setDepthStencilState(fActiveRenderCmdEncoder);
pipelineState->setDrawState(fActiveRenderCmdEncoder, fRenderTarget->config(),
pipeline.getXferProcessor());
bool dynamicScissor =
pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects;
@ -182,10 +186,8 @@ void GrMtlGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc,
}
[fActiveRenderCmdEncoder setRenderPipelineState:pipelineState->mtlPipelineState()];
pipelineState->bind(fActiveRenderCmdEncoder);
pipelineState->setBlendConstants(fActiveRenderCmdEncoder, fRenderTarget->config(),
pipeline.getXferProcessor());
pipelineState->setDepthStencilState(fActiveRenderCmdEncoder);
pipelineState->setDrawState(fActiveRenderCmdEncoder, fRenderTarget->config(),
pipeline.getXferProcessor());
}
if (dynamicScissor) {

View File

@ -51,11 +51,7 @@ public:
const GrPrimitiveProcessor& primPRoc, const GrPipeline& pipeline,
const GrTextureProxy* const primProcTextures[]);
void bind(id<MTLRenderCommandEncoder>);
void setBlendConstants(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
void setDepthStencilState(id<MTLRenderCommandEncoder> renderCmdEncoder);
void setDrawState(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
static void SetDynamicScissorRectState(id<MTLRenderCommandEncoder> renderCmdEncoder,
const GrRenderTarget* renderTarget,
@ -101,6 +97,12 @@ private:
void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin);
void bind(id<MTLRenderCommandEncoder>);
void setBlendConstants(id<MTLRenderCommandEncoder>, GrPixelConfig, const GrXferProcessor&);
void setDepthStencilState(id<MTLRenderCommandEncoder> renderCmdEncoder);
struct SamplerBindings {
id<MTLSamplerState> fSampler;
id<MTLTexture> fTexture;

View File

@ -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) {
if (fGeometryUniformBuffer) {
[renderCmdEncoder setVertexBuffer: fGeometryUniformBuffer->mtlBuffer()