1 /* 2 * Copyright 2019 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrProgramInfo_DEFINED 9 #define GrProgramInfo_DEFINED 10 11 #include "include/gpu/GrTypes.h" 12 #include "src/gpu/ganesh/GrGeometryProcessor.h" 13 #include "src/gpu/ganesh/GrPipeline.h" 14 15 class GrStencilSettings; 16 17 class GrProgramInfo { 18 public: 19 GrProgramInfo(const GrCaps& caps, 20 const GrSurfaceProxyView& targetView, 21 bool usesMSAASurface, 22 const GrPipeline* pipeline, 23 const GrUserStencilSettings* userStencilSettings, 24 const GrGeometryProcessor* geomProc, 25 GrPrimitiveType primitiveType, 26 GrXferBarrierFlags renderPassXferBarriers, 27 GrLoadOp colorLoadOp); 28 numSamples()29 int numSamples() const { return fNumSamples; } needsStencil()30 int needsStencil() const { return fNeedsStencil; } isStencilEnabled()31 bool isStencilEnabled() const { 32 return fUserStencilSettings != &GrUserStencilSettings::kUnused || 33 fPipeline->hasStencilClip(); 34 } userStencilSettings()35 const GrUserStencilSettings* userStencilSettings() const { return fUserStencilSettings; } 36 // The backend format of the destination render target [proxy] backendFormat()37 const GrBackendFormat& backendFormat() const { return fBackendFormat; } origin()38 GrSurfaceOrigin origin() const { return fOrigin; } pipeline()39 const GrPipeline& pipeline() const { return *fPipeline; } geomProc()40 const GrGeometryProcessor& geomProc() const { return *fGeomProc; } 41 primitiveType()42 GrPrimitiveType primitiveType() const { return fPrimitiveType; } 43 targetHasVkResolveAttachmentWithInput()44 bool targetHasVkResolveAttachmentWithInput() const { 45 return fTargetHasVkResolveAttachmentWithInput; 46 } 47 targetsNumSamples()48 int targetsNumSamples() const { return fTargetsNumSamples; } 49 renderPassBarriers()50 GrXferBarrierFlags renderPassBarriers() const { return fRenderPassXferBarriers; } 51 colorLoadOp()52 GrLoadOp colorLoadOp() const { return fColorLoadOp; } 53 primitiveTypeKey()54 uint16_t primitiveTypeKey() const { 55 return (uint16_t) fPrimitiveType; 56 } 57 58 // For Dawn, Metal and Vulkan the number of stencil bits is known a priori so we can 59 // create the stencil settings here. 60 GrStencilSettings nonGLStencilSettings() const; 61 62 // Invokes the visitor function on all FP proxies in the pipeline. The caller is responsible 63 // to call the visitor on its own primProc proxies. visitFPProxies(const GrVisitProxyFunc & func)64 void visitFPProxies(const GrVisitProxyFunc& func) const { fPipeline->visitProxies(func); } 65 66 #ifdef SK_DEBUG 67 void validate(bool flushTime) const; 68 void checkAllInstantiated() const; 69 void checkMSAAAndMIPSAreResolved() const; 70 #endif 71 72 private: 73 int fNumSamples; 74 bool fNeedsStencil; 75 GrBackendFormat fBackendFormat; 76 GrSurfaceOrigin fOrigin; 77 bool fTargetHasVkResolveAttachmentWithInput; 78 int fTargetsNumSamples; 79 const GrPipeline* fPipeline; 80 const GrUserStencilSettings* fUserStencilSettings; 81 const GrGeometryProcessor* fGeomProc; 82 GrPrimitiveType fPrimitiveType; 83 GrXferBarrierFlags fRenderPassXferBarriers; 84 GrLoadOp fColorLoadOp; 85 }; 86 87 #endif 88