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