Add 'numRasterSamples' and 'isMixedSampled' to GrProgramInfo
Replaces numSamples with numRasterSamples, and adds isMixedSampled. The sample count that vulkan and metal actually want to know is how many samples the rasterizer will compute, which may not match the number of samples in the render target when we have mixed samples. They will also need to know whether a program is mixed sampled in order to set up coverage modulation. Change-Id: I133c11f74b7dc6a7580818ef73d6deec1d201b64 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253550 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
654eb2ad04
commit
5e8cdfdd8b
@ -169,7 +169,8 @@ private:
|
||||
|
||||
ClockwiseTestProcessor primProc(fReadSkFragCoord);
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
primProc,
|
||||
|
@ -176,7 +176,8 @@ private:
|
||||
|
||||
FwidthSquircleTestProcessor primProc(fViewMatrix);
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
primProc,
|
||||
|
@ -237,7 +237,8 @@ private:
|
||||
|
||||
SampleLocationsTestProcessor primProc(fGradType);
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
primProc,
|
||||
|
@ -55,6 +55,7 @@ void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(
|
||||
}
|
||||
|
||||
GrProgramInfo programInfo(this->proxy()->numSamples(),
|
||||
this->proxy()->numStencilSamples(),
|
||||
this->proxy()->origin(),
|
||||
*pipeline,
|
||||
*fCurrDraw->fGeometryProcessor,
|
||||
|
@ -62,18 +62,17 @@ public:
|
||||
const GrXferProcessor::DstProxyView& dstProxyView)
|
||||
: fOp(op)
|
||||
, fSurfaceView(surfaceView)
|
||||
, fRenderTargetProxy(surfaceView->asRenderTargetProxy())
|
||||
, fAppliedClip(appliedClip)
|
||||
, fDstProxyView(dstProxyView) {
|
||||
SkASSERT(surfaceView->asRenderTargetProxy());
|
||||
}
|
||||
|
||||
int numSamples() const { return this->proxy()->numSamples(); }
|
||||
GrSurfaceOrigin origin() const { return fSurfaceView->origin(); }
|
||||
GrSwizzle outputSwizzle() const { return fSurfaceView->swizzle(); }
|
||||
|
||||
GrOp* op() { return fOp; }
|
||||
GrRenderTargetProxy* proxy() const { return fSurfaceView->asRenderTargetProxy(); }
|
||||
GrRenderTarget* renderTarget() const { return this->proxy()->peekRenderTarget(); }
|
||||
GrRenderTargetProxy* proxy() const { return fRenderTargetProxy; }
|
||||
GrAppliedClip* appliedClip() { return fAppliedClip; }
|
||||
const GrAppliedClip* appliedClip() const { return fAppliedClip; }
|
||||
const GrXferProcessor::DstProxyView& dstProxyView() const { return fDstProxyView; }
|
||||
@ -88,6 +87,7 @@ public:
|
||||
private:
|
||||
GrOp* fOp;
|
||||
GrSurfaceProxyView* fSurfaceView;
|
||||
GrRenderTargetProxy* fRenderTargetProxy;
|
||||
GrAppliedClip* fAppliedClip;
|
||||
GrXferProcessor::DstProxyView fDstProxyView; // TODO: do we still need the dst proxy here?
|
||||
};
|
||||
@ -129,11 +129,11 @@ public:
|
||||
int* actualIndexCount) final;
|
||||
void putBackIndices(int indexCount) final;
|
||||
void putBackVertices(int vertices, size_t vertexStride) final;
|
||||
GrRenderTargetProxy* proxy() const final { return fOpArgs->proxy(); }
|
||||
const GrAppliedClip* appliedClip() final { return fOpArgs->appliedClip(); }
|
||||
GrRenderTargetProxy* proxy() const final { return this->drawOpArgs().proxy(); }
|
||||
const GrAppliedClip* appliedClip() final { return this->drawOpArgs().appliedClip(); }
|
||||
GrAppliedClip detachAppliedClip() final;
|
||||
const GrXferProcessor::DstProxyView& dstProxyView() const final {
|
||||
return fOpArgs->dstProxyView();
|
||||
return this->drawOpArgs().dstProxyView();
|
||||
}
|
||||
GrDeferredUploadTarget* deferredUploadTarget() final { return this; }
|
||||
const GrCaps& caps() const final;
|
||||
|
@ -18,6 +18,7 @@ class GrStencilSettings;
|
||||
class GrProgramInfo {
|
||||
public:
|
||||
GrProgramInfo(int numSamples,
|
||||
int numStencilSamples,
|
||||
GrSurfaceOrigin origin,
|
||||
const GrPipeline& pipeline,
|
||||
const GrPrimitiveProcessor& primProc,
|
||||
@ -25,7 +26,8 @@ public:
|
||||
const GrPipeline::DynamicStateArrays* dynamicStateArrays,
|
||||
int numDynamicStateArrays,
|
||||
GrPrimitiveType primitiveType)
|
||||
: fNumSamples(numSamples)
|
||||
: fNumRasterSamples(pipeline.isStencilEnabled() ? numStencilSamples : numSamples)
|
||||
, fIsMixedSampled(fNumRasterSamples > numSamples)
|
||||
, fOrigin(origin)
|
||||
, fPipeline(pipeline)
|
||||
, fPrimProc(primProc)
|
||||
@ -33,6 +35,7 @@ public:
|
||||
, fDynamicStateArrays(dynamicStateArrays)
|
||||
, fNumDynamicStateArrays(numDynamicStateArrays)
|
||||
, fPrimitiveType(primitiveType) {
|
||||
SkASSERT(fNumRasterSamples > 0);
|
||||
fRequestedFeatures = fPrimProc.requestedFeatures();
|
||||
for (int i = 0; i < fPipeline.numFragmentProcessors(); ++i) {
|
||||
fRequestedFeatures |= fPipeline.getFragmentProcessor(i).requestedFeatures();
|
||||
@ -45,7 +48,8 @@ public:
|
||||
|
||||
GrProcessor::CustomFeatures requestedFeatures() const { return fRequestedFeatures; }
|
||||
|
||||
int numSamples() const { return fNumSamples; }
|
||||
int numRasterSamples() const { return fNumRasterSamples; }
|
||||
bool isMixedSampled() const { return fIsMixedSampled; }
|
||||
GrSurfaceOrigin origin() const { return fOrigin; }
|
||||
const GrPipeline& pipeline() const { return fPipeline; }
|
||||
const GrPrimitiveProcessor& primProc() const { return fPrimProc; }
|
||||
@ -111,7 +115,8 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
const int fNumSamples;
|
||||
const int fNumRasterSamples;
|
||||
const bool fIsMixedSampled;
|
||||
const GrSurfaceOrigin fOrigin;
|
||||
const GrPipeline& fPipeline;
|
||||
const GrPrimitiveProcessor& fPrimProc;
|
||||
|
@ -205,7 +205,8 @@ void GrCCCoverageProcessor::draw(
|
||||
|
||||
GrPrimitiveType primitiveType = this->primType();
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
*this,
|
||||
|
@ -141,7 +141,8 @@ void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline&
|
||||
baseInstance, enablePrimitiveRestart);
|
||||
mesh.setVertexData(resources.refVertexBuffer());
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
*this,
|
||||
|
@ -777,7 +777,8 @@ void GrCCStroker::flushBufferedMeshesAsStrokes(const GrPrimitiveProcessor& proce
|
||||
GrPipeline::DynamicStateArrays dynamicStateArrays;
|
||||
dynamicStateArrays.fScissorRects = fScissorsBuffer.begin();
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
processor,
|
||||
|
@ -151,7 +151,8 @@ void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chain
|
||||
|
||||
StencilResolveProcessor primProc;
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
resolvePipeline,
|
||||
primProc,
|
||||
|
@ -37,7 +37,6 @@ public:
|
||||
virtual const GrCaps* caps() const = 0;
|
||||
const GrShaderCaps* shaderCaps() const { return this->caps()->shaderCaps(); }
|
||||
|
||||
int numSamples() const { return fProgramInfo.numSamples(); }
|
||||
GrSurfaceOrigin origin() const { return fProgramInfo.origin(); }
|
||||
const GrPipeline& pipeline() const { return fProgramInfo.pipeline(); }
|
||||
const GrPrimitiveProcessor& primitiveProcessor() const { return fProgramInfo.primProc(); }
|
||||
|
@ -393,7 +393,7 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(GrRenderTarget* renderTa
|
||||
pipelineDescriptor.vertexDescriptor = create_vertex_descriptor(programInfo.primProc());
|
||||
pipelineDescriptor.colorAttachments[0] = create_color_attachment(renderTarget->config(),
|
||||
programInfo.pipeline());
|
||||
pipelineDescriptor.sampleCount = renderTarget->numSamples();
|
||||
pipelineDescriptor.sampleCount = programInfo.numRasterSamples();
|
||||
bool hasStencilAttachment = SkToBool(renderTarget->renderTargetPriv().getStencilAttachment());
|
||||
GrMtlCaps* mtlCaps = (GrMtlCaps*)this->caps();
|
||||
pipelineDescriptor.stencilAttachmentPixelFormat =
|
||||
@ -461,7 +461,7 @@ bool GrMtlPipelineStateBuilder::Desc::Build(Desc* desc,
|
||||
desc->fShaderKeyLength = SkToU32(keyLength);
|
||||
|
||||
b.add32(renderTarget->config());
|
||||
b.add32(renderTarget->numSamples());
|
||||
b.add32(programInfo.numRasterSamples());
|
||||
|
||||
bool hasStencilAttachment = SkToBool(renderTarget->renderTargetPriv().getStencilAttachment());
|
||||
SkASSERT(!programInfo.pipeline().isStencilEnabled() || hasStencilAttachment);
|
||||
|
@ -70,8 +70,9 @@ void init_stencil_pass_settings(const GrOpFlushState& flushState,
|
||||
GrPathRendering::FillType fillType, GrStencilSettings* stencil) {
|
||||
const GrAppliedClip* appliedClip = flushState.drawOpArgs().appliedClip();
|
||||
bool stencilClip = appliedClip && appliedClip->hasStencilClip();
|
||||
GrRenderTarget* rt = flushState.drawOpArgs().proxy()->peekRenderTarget();
|
||||
stencil->reset(GrPathRendering::GetStencilPassSettings(fillType), stencilClip,
|
||||
flushState.drawOpArgs().renderTarget()->renderTargetPriv().numStencilBits());
|
||||
rt->renderTargetPriv().numStencilBits());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -93,7 +94,8 @@ void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||
std::move(appliedClip));
|
||||
sk_sp<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->viewMatrix()));
|
||||
|
||||
GrProgramInfo programInfo(state->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(state->proxy()->numSamples(),
|
||||
state->proxy()->numStencilSamples(),
|
||||
state->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
*pathProc,
|
||||
@ -103,7 +105,7 @@ void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||
|
||||
GrStencilSettings stencil;
|
||||
init_stencil_pass_settings(*state, this->fillType(), &stencil);
|
||||
state->gpu()->pathRendering()->drawPath(state->drawOpArgs().renderTarget(),
|
||||
state->gpu()->pathRendering()->drawPath(state->drawOpArgs().proxy()->peekRenderTarget(),
|
||||
programInfo, stencil, fPath.get());
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,8 @@ void GrFillRRectOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBou
|
||||
std::move(fProcessors),
|
||||
std::move(clip));
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
*pipeline,
|
||||
*proc,
|
||||
|
@ -27,7 +27,7 @@ std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context,
|
||||
}
|
||||
|
||||
void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||
GrRenderTarget* rt = state->drawOpArgs().renderTarget();
|
||||
GrRenderTarget* rt = state->drawOpArgs().proxy()->peekRenderTarget();
|
||||
SkASSERT(rt);
|
||||
|
||||
int numStencilBits = rt->renderTargetPriv().numStencilBits();
|
||||
|
@ -288,7 +288,7 @@ static void setup_multisample_state(const GrProgramInfo& programInfo,
|
||||
multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
multisampleInfo->pNext = nullptr;
|
||||
multisampleInfo->flags = 0;
|
||||
SkAssertResult(GrSampleCountToVkSampleCount(programInfo.numSamples(),
|
||||
SkAssertResult(GrSampleCountToVkSampleCount(programInfo.numRasterSamples(),
|
||||
&multisampleInfo->rasterizationSamples));
|
||||
multisampleInfo->sampleShadingEnable = VK_FALSE;
|
||||
multisampleInfo->minSampleShading = 0.0f;
|
||||
@ -310,13 +310,13 @@ static void setup_all_sample_locations_at_pixel_center(
|
||||
sampleLocations->sampleLocationsInfo.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT;
|
||||
sampleLocations->sampleLocationsInfo.pNext = nullptr;
|
||||
SkAssertResult(GrSampleCountToVkSampleCount(
|
||||
programInfo.numSamples(),
|
||||
programInfo.numRasterSamples(),
|
||||
&sampleLocations->sampleLocationsInfo.sampleLocationsPerPixel));
|
||||
sampleLocations->sampleLocationsInfo.sampleLocationGridSize.width = 1;
|
||||
sampleLocations->sampleLocationsInfo.sampleLocationGridSize.height = 1;
|
||||
SkASSERT(programInfo.numSamples() < (int)SK_ARRAY_COUNT(kCenteredSampleLocations));
|
||||
SkASSERT(programInfo.numRasterSamples() < (int)SK_ARRAY_COUNT(kCenteredSampleLocations));
|
||||
sampleLocations->sampleLocationsInfo.sampleLocationsCount = std::min(
|
||||
programInfo.numSamples(), (int)SK_ARRAY_COUNT(kCenteredSampleLocations));
|
||||
programInfo.numRasterSamples(), (int)SK_ARRAY_COUNT(kCenteredSampleLocations));
|
||||
sampleLocations->sampleLocationsInfo.pSampleLocations = kCenteredSampleLocations;
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ GrVkPipeline* GrVkPipeline::Create(
|
||||
|
||||
VkPipelineSampleLocationsStateCreateInfoEXT sampleLocations;
|
||||
if (gpu->caps()->multisampleDisableSupport()) {
|
||||
if (programInfo.numSamples() > 1 && !programInfo.pipeline().isHWAntialiasState()) {
|
||||
if (programInfo.numRasterSamples() > 1 && !programInfo.pipeline().isHWAntialiasState()) {
|
||||
setup_all_sample_locations_at_pixel_center(programInfo, &sampleLocations);
|
||||
sampleLocations.pNext = multisampleInfo.pNext;
|
||||
multisampleInfo.pNext = &sampleLocations;
|
||||
|
@ -347,6 +347,7 @@ bool GrVkPipelineStateBuilder::Desc::Build(Desc* desc,
|
||||
stencil.genKey(&b);
|
||||
|
||||
programInfo.pipeline().genKey(&b, caps);
|
||||
b.add32(programInfo.numRasterSamples());
|
||||
|
||||
// Vulkan requires the full primitive type as part of its key
|
||||
b.add32((uint32_t)programInfo.primitiveType());
|
||||
|
@ -414,7 +414,8 @@ void DrawMeshHelper::drawMesh(const GrMesh& mesh, GrPrimitiveType primitiveType)
|
||||
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc, GrSwizzle::RGBA());
|
||||
GrMeshTestProcessor mtp(mesh.isInstanced(), mesh.hasVertexData());
|
||||
|
||||
GrProgramInfo programInfo(fState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(fState->proxy()->numSamples(),
|
||||
fState->proxy()->numStencilSamples(),
|
||||
fState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
mtp,
|
||||
|
@ -155,7 +155,8 @@ private:
|
||||
|
||||
GrPipelineDynamicStateTestProcessor primProc;
|
||||
|
||||
GrProgramInfo programInfo(flushState->drawOpArgs().numSamples(),
|
||||
GrProgramInfo programInfo(flushState->proxy()->numSamples(),
|
||||
flushState->proxy()->numStencilSamples(),
|
||||
flushState->drawOpArgs().origin(),
|
||||
pipeline,
|
||||
primProc,
|
||||
|
Loading…
Reference in New Issue
Block a user