bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2013 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 8 | #ifndef GrDrawTargetCaps_DEFINED |
| 9 | #define GrDrawTargetCaps_DEFINED |
| 10 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 11 | #include "GrTypes.h" |
| 12 | #include "SkRefCnt.h" |
| 13 | #include "SkString.h" |
| 14 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 15 | /** |
| 16 | * Represents the draw target capabilities. |
| 17 | */ |
| 18 | class GrDrawTargetCaps : public SkRefCnt { |
| 19 | public: |
bungeman | d6aeb6d | 2014-07-25 11:52:47 -0700 | [diff] [blame] | 20 | SK_DECLARE_INST_COUNT(GrDrawTargetCaps) |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 21 | |
egdaniel | bc127a3 | 2014-09-19 12:07:43 -0700 | [diff] [blame] | 22 | GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) { |
| 23 | this->reset(); |
| 24 | } |
| 25 | GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) { |
| 26 | *this = other; |
| 27 | } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 28 | GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); |
| 29 | |
| 30 | virtual void reset(); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 31 | virtual SkString dump() const; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 32 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 33 | bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 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; } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 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; } |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 43 | bool pathRenderingSupport() const { return fPathRenderingSupport; } |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 44 | bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 45 | bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; } |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 46 | bool gpuTracingSupport() const { return fGpuTracingSupport; } |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 47 | bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; } |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 48 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame^] | 49 | bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; } |
| 50 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 51 | /** |
| 52 | * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and |
| 53 | * textures allows partial mappings or full mappings. |
| 54 | */ |
| 55 | enum MapFlags { |
| 56 | kNone_MapFlags = 0x0, //<! Cannot map the resource. |
| 57 | |
| 58 | kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of |
| 59 | // the other flags to have meaning.k |
| 60 | kSubset_MapFlag = 0x2, //<! The resource can be partially mapped. |
| 61 | }; |
| 62 | |
| 63 | uint32_t mapBufferFlags() const { return fMapBufferFlags; } |
| 64 | |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 65 | // Scratch textures not being reused means that those scratch textures |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 66 | // that we upload to (i.e., don't have a render target) will not be |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 67 | // recycled in the texture cache. This is to prevent ghosting by drivers |
| 68 | // (in particular for deferred architectures). |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 69 | bool reuseScratchTextures() const { return fReuseScratchTextures; } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 70 | |
| 71 | int maxRenderTargetSize() const { return fMaxRenderTargetSize; } |
| 72 | int maxTextureSize() const { return fMaxTextureSize; } |
| 73 | // Will be 0 if MSAA is not supported |
| 74 | int maxSampleCount() const { return fMaxSampleCount; } |
| 75 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 76 | bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 77 | SkASSERT(kGrPixelConfigCnt > config); |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 78 | return fConfigRenderSupport[config][withMSAA]; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 79 | } |
| 80 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 81 | bool isConfigTexturable(GrPixelConfig config) const { |
| 82 | SkASSERT(kGrPixelConfigCnt > config); |
| 83 | return fConfigTextureSupport[config]; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 84 | } |
| 85 | |
egdaniel | bc127a3 | 2014-09-19 12:07:43 -0700 | [diff] [blame] | 86 | /** |
| 87 | * Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does |
| 88 | * not change when the content of the GrDrawTargetCaps object changes. This will never return |
| 89 | * 0. |
| 90 | */ |
| 91 | uint32_t getUniqueID() const { return fUniqueID; } |
| 92 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 93 | protected: |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 94 | bool fNPOTTextureTileSupport : 1; |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 95 | bool fMipMapSupport : 1; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 96 | bool fTwoSidedStencilSupport : 1; |
| 97 | bool fStencilWrapOpsSupport : 1; |
| 98 | bool fHWAALineSupport : 1; |
| 99 | bool fShaderDerivativeSupport : 1; |
| 100 | bool fGeometryShaderSupport : 1; |
| 101 | bool fDualSourceBlendingSupport : 1; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 102 | bool fPathRenderingSupport : 1; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 103 | bool fDstReadInShaderSupport : 1; |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 104 | bool fDiscardRenderTargetSupport: 1; |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 105 | bool fReuseScratchTextures : 1; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 106 | bool fGpuTracingSupport : 1; |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 107 | bool fCompressedTexSubImageSupport : 1; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 108 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame^] | 109 | // Driver workaround |
| 110 | bool fUseDrawInsteadOfClear : 1; |
| 111 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 112 | uint32_t fMapBufferFlags; |
| 113 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 114 | int fMaxRenderTargetSize; |
| 115 | int fMaxTextureSize; |
| 116 | int fMaxSampleCount; |
| 117 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 118 | // The first entry for each config is without msaa and the second is with. |
| 119 | bool fConfigRenderSupport[kGrPixelConfigCnt][2]; |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 120 | bool fConfigTextureSupport[kGrPixelConfigCnt]; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 121 | |
egdaniel | bc127a3 | 2014-09-19 12:07:43 -0700 | [diff] [blame] | 122 | private: |
| 123 | static uint32_t CreateUniqueID(); |
| 124 | |
| 125 | const uint32_t fUniqueID; |
| 126 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 127 | typedef SkRefCnt INHERITED; |
| 128 | }; |
| 129 | |
| 130 | #endif |