blob: e468bc41ab39cf62b1c678b6ce65dd6ae6f15fb9 [file] [log] [blame]
bsalomon@google.comc26d94f2013-03-25 18:19:00 +00001
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.comc26d94f2013-03-25 18:19:00 +00008#ifndef GrDrawTargetCaps_DEFINED
9#define GrDrawTargetCaps_DEFINED
10
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +000011#include "GrTypes.h"
12#include "SkRefCnt.h"
13#include "SkString.h"
14
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000015/**
16 * Represents the draw target capabilities.
17 */
18class GrDrawTargetCaps : public SkRefCnt {
19public:
bungemand6aeb6d2014-07-25 11:52:47 -070020 SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000021
egdanielbc127a32014-09-19 12:07:43 -070022 GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) {
23 this->reset();
24 }
25 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) {
26 *this = other;
27 }
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000028 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
29
30 virtual void reset();
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +000031 virtual SkString dump() const;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000032
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000033 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
commit-bot@chromium.org47442312013-12-19 16:18:01 +000034 /** 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.comc26d94f2013-03-25 18:19:00 +000037 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.orgc4dc0ad2013-10-09 14:11:33 +000043 bool pathRenderingSupport() const { return fPathRenderingSupport; }
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000044 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +000045 bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000046 bool gpuTracingSupport() const { return fGpuTracingSupport; }
krajcevski786978162014-07-30 11:25:44 -070047 bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
robertphillips@google.com2d2e5c42013-10-30 21:30:43 +000048
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000049 /**
50 * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
51 * textures allows partial mappings or full mappings.
52 */
53 enum MapFlags {
54 kNone_MapFlags = 0x0, //<! Cannot map the resource.
55
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.
59 };
60
61 uint32_t mapBufferFlags() const { return fMapBufferFlags; }
62
robertphillips@google.com2d2e5c42013-10-30 21:30:43 +000063 // Scratch textures not being reused means that those scratch textures
skia.committer@gmail.com7ed98df2013-10-31 07:01:53 +000064 // that we upload to (i.e., don't have a render target) will not be
robertphillips@google.com2d2e5c42013-10-30 21:30:43 +000065 // recycled in the texture cache. This is to prevent ghosting by drivers
66 // (in particular for deferred architectures).
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +000067 bool reuseScratchTextures() const { return fReuseScratchTextures; }
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000068
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; }
73
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +000074 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
commit-bot@chromium.org73880512013-10-14 15:33:45 +000075 SkASSERT(kGrPixelConfigCnt > config);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +000076 return fConfigRenderSupport[config][withMSAA];
commit-bot@chromium.org73880512013-10-14 15:33:45 +000077 }
78
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +000079 bool isConfigTexturable(GrPixelConfig config) const {
80 SkASSERT(kGrPixelConfigCnt > config);
81 return fConfigTextureSupport[config];
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +000082 }
83
egdanielbc127a32014-09-19 12:07:43 -070084 /**
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
87 * 0.
88 */
89 uint32_t getUniqueID() const { return fUniqueID; }
90
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000091protected:
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000092 bool fNPOTTextureTileSupport : 1;
commit-bot@chromium.org47442312013-12-19 16:18:01 +000093 bool fMipMapSupport : 1;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000094 bool fTwoSidedStencilSupport : 1;
95 bool fStencilWrapOpsSupport : 1;
96 bool fHWAALineSupport : 1;
97 bool fShaderDerivativeSupport : 1;
98 bool fGeometryShaderSupport : 1;
99 bool fDualSourceBlendingSupport : 1;
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000100 bool fPathRenderingSupport : 1;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000101 bool fDstReadInShaderSupport : 1;
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000102 bool fDiscardRenderTargetSupport: 1;
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000103 bool fReuseScratchTextures : 1;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000104 bool fGpuTracingSupport : 1;
krajcevski786978162014-07-30 11:25:44 -0700105 bool fCompressedTexSubImageSupport : 1;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000106
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000107 uint32_t fMapBufferFlags;
108
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000109 int fMaxRenderTargetSize;
110 int fMaxTextureSize;
111 int fMaxSampleCount;
112
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000113 // The first entry for each config is without msaa and the second is with.
114 bool fConfigRenderSupport[kGrPixelConfigCnt][2];
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000115 bool fConfigTextureSupport[kGrPixelConfigCnt];
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000116
egdanielbc127a32014-09-19 12:07:43 -0700117private:
118 static uint32_t CreateUniqueID();
119
120 const uint32_t fUniqueID;
121
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000122 typedef SkRefCnt INHERITED;
123};
124
125#endif