3 * Copyright 2013 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
8 #ifndef GrDrawTargetCaps_DEFINED
9 #define GrDrawTargetCaps_DEFINED
16 * Represents the draw target capabilities.
18 class GrDrawTargetCaps : public SkRefCnt {
20 SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
22 GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) {
25 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) {
28 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
31 virtual SkString dump() const;
33 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
34 /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
35 only for POT textures) */
36 bool mipMapSupport() const { return fMipMapSupport; }
37 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
38 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
39 bool hwAALineSupport() const { return fHWAALineSupport; }
40 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
41 bool geometryShaderSupport() const { return fGeometryShaderSupport; }
42 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
43 bool pathRenderingSupport() const { return fPathRenderingSupport; }
44 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
45 bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
46 bool gpuTracingSupport() const { return fGpuTracingSupport; }
47 bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
50 * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
51 * textures allows partial mappings or full mappings.
54 kNone_MapFlags = 0x0, //<! Cannot map the resource.
56 kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of
57 // the other flags to have meaning.k
58 kSubset_MapFlag = 0x2, //<! The resource can be partially mapped.
61 uint32_t mapBufferFlags() const { return fMapBufferFlags; }
63 // Scratch textures not being reused means that those scratch textures
64 // that we upload to (i.e., don't have a render target) will not be
65 // recycled in the texture cache. This is to prevent ghosting by drivers
66 // (in particular for deferred architectures).
67 bool reuseScratchTextures() const { return fReuseScratchTextures; }
69 int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
70 int maxTextureSize() const { return fMaxTextureSize; }
71 // Will be 0 if MSAA is not supported
72 int maxSampleCount() const { return fMaxSampleCount; }
74 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
75 SkASSERT(kGrPixelConfigCnt > config);
76 return fConfigRenderSupport[config][withMSAA];
79 bool isConfigTexturable(GrPixelConfig config) const {
80 SkASSERT(kGrPixelConfigCnt > config);
81 return fConfigTextureSupport[config];
85 * Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does
86 * not change when the content of the GrDrawTargetCaps object changes. This will never return
89 uint32_t getUniqueID() const { return fUniqueID; }
92 bool fNPOTTextureTileSupport : 1;
93 bool fMipMapSupport : 1;
94 bool fTwoSidedStencilSupport : 1;
95 bool fStencilWrapOpsSupport : 1;
96 bool fHWAALineSupport : 1;
97 bool fShaderDerivativeSupport : 1;
98 bool fGeometryShaderSupport : 1;
99 bool fDualSourceBlendingSupport : 1;
100 bool fPathRenderingSupport : 1;
101 bool fDstReadInShaderSupport : 1;
102 bool fDiscardRenderTargetSupport: 1;
103 bool fReuseScratchTextures : 1;
104 bool fGpuTracingSupport : 1;
105 bool fCompressedTexSubImageSupport : 1;
107 uint32_t fMapBufferFlags;
109 int fMaxRenderTargetSize;
113 // The first entry for each config is without msaa and the second is with.
114 bool fConfigRenderSupport[kGrPixelConfigCnt][2];
115 bool fConfigTextureSupport[kGrPixelConfigCnt];
118 static uint32_t CreateUniqueID();
120 const uint32_t fUniqueID;
122 typedef SkRefCnt INHERITED;