Home | History | Annotate | Download | only in gpu
      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  */
      8 #ifndef GrDrawTargetCaps_DEFINED
      9 #define GrDrawTargetCaps_DEFINED
     10 
     11 #include "GrTypes.h"
     12 #include "SkRefCnt.h"
     13 #include "SkString.h"
     14 
     15 /**
     16  * Represents the draw target capabilities.
     17  */
     18 class GrDrawTargetCaps : public SkRefCnt {
     19 public:
     20     SK_DECLARE_INST_COUNT(Caps)
     21 
     22     GrDrawTargetCaps() { this->reset(); }
     23     GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { *this = other; }
     24     GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
     25 
     26     virtual void reset();
     27     virtual SkString dump() const;
     28 
     29     bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
     30     /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
     31         only for POT textures) */
     32     bool mipMapSupport() const { return fMipMapSupport; }
     33     bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
     34     bool stencilWrapOpsSupport() const { return  fStencilWrapOpsSupport; }
     35     bool hwAALineSupport() const { return fHWAALineSupport; }
     36     bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
     37     bool geometryShaderSupport() const { return fGeometryShaderSupport; }
     38     bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
     39     bool pathRenderingSupport() const { return fPathRenderingSupport; }
     40     bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
     41     bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
     42     bool gpuTracingSupport() const { return fGpuTracingSupport; }
     43 
     44     /**
     45      * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
     46      * textures allows partial mappings or full mappings.
     47      */
     48     enum MapFlags {
     49         kNone_MapFlags   = 0x0,       //<! Cannot map the resource.
     50 
     51         kCanMap_MapFlag  = 0x1,       //<! The resource can be mapped. Must be set for any of
     52                                       //   the other flags to have meaning.k
     53         kSubset_MapFlag  = 0x2,       //<! The resource can be partially mapped.
     54     };
     55 
     56     uint32_t mapBufferFlags() const { return fMapBufferFlags; }
     57 
     58     // Scratch textures not being reused means that those scratch textures
     59     // that we upload to (i.e., don't have a render target) will not be
     60     // recycled in the texture cache. This is to prevent ghosting by drivers
     61     // (in particular for deferred architectures).
     62     bool reuseScratchTextures() const { return fReuseScratchTextures; }
     63 
     64     int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
     65     int maxTextureSize() const { return fMaxTextureSize; }
     66     // Will be 0 if MSAA is not supported
     67     int maxSampleCount() const { return fMaxSampleCount; }
     68 
     69     bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
     70         SkASSERT(kGrPixelConfigCnt > config);
     71         return fConfigRenderSupport[config][withMSAA];
     72     }
     73 
     74     bool isConfigTexturable(GrPixelConfig config) const {
     75         SkASSERT(kGrPixelConfigCnt > config);
     76         return fConfigTextureSupport[config];
     77     }
     78 
     79 protected:
     80     bool fNPOTTextureTileSupport    : 1;
     81     bool fMipMapSupport             : 1;
     82     bool fTwoSidedStencilSupport    : 1;
     83     bool fStencilWrapOpsSupport     : 1;
     84     bool fHWAALineSupport           : 1;
     85     bool fShaderDerivativeSupport   : 1;
     86     bool fGeometryShaderSupport     : 1;
     87     bool fDualSourceBlendingSupport : 1;
     88     bool fPathRenderingSupport      : 1;
     89     bool fDstReadInShaderSupport    : 1;
     90     bool fDiscardRenderTargetSupport: 1;
     91     bool fReuseScratchTextures      : 1;
     92     bool fGpuTracingSupport         : 1;
     93 
     94     uint32_t fMapBufferFlags;
     95 
     96     int fMaxRenderTargetSize;
     97     int fMaxTextureSize;
     98     int fMaxSampleCount;
     99 
    100     // The first entry for each config is without msaa and the second is with.
    101     bool fConfigRenderSupport[kGrPixelConfigCnt][2];
    102     bool fConfigTextureSupport[kGrPixelConfigCnt];
    103 
    104     typedef SkRefCnt INHERITED;
    105 };
    106 
    107 #endif
    108