blob: b33217a125e528b62824a29a3f0a383ec7ea4e6e [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:
20 SK_DECLARE_INST_COUNT(Caps)
21
22 GrDrawTargetCaps() { this->reset(); }
commit-bot@chromium.orgfaa5ae42013-07-23 11:13:56 +000023 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { *this = other; }
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000024 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
25
26 virtual void reset();
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +000027 virtual SkString dump() const;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000028
29 bool eightBitPaletteSupport() const { return f8BitPaletteSupport; }
30 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
commit-bot@chromium.org47442312013-12-19 16:18:01 +000031 /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
32 only for POT textures) */
33 bool mipMapSupport() const { return fMipMapSupport; }
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000034 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
35 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
36 bool hwAALineSupport() const { return fHWAALineSupport; }
37 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
38 bool geometryShaderSupport() const { return fGeometryShaderSupport; }
39 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
40 bool bufferLockSupport() const { return fBufferLockSupport; }
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000041 bool pathRenderingSupport() const { return fPathRenderingSupport; }
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000042 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000043 bool gpuTracingSupport() const { return fGpuTracingSupport; }
robertphillips@google.com2d2e5c42013-10-30 21:30:43 +000044
45 // Scratch textures not being reused means that those scratch textures
skia.committer@gmail.com7ed98df2013-10-31 07:01:53 +000046 // that we upload to (i.e., don't have a render target) will not be
robertphillips@google.com2d2e5c42013-10-30 21:30:43 +000047 // recycled in the texture cache. This is to prevent ghosting by drivers
48 // (in particular for deferred architectures).
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +000049 bool reuseScratchTextures() const { return fReuseScratchTextures; }
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000050
51 int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
52 int maxTextureSize() const { return fMaxTextureSize; }
53 // Will be 0 if MSAA is not supported
54 int maxSampleCount() const { return fMaxSampleCount; }
55
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +000056 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
commit-bot@chromium.org73880512013-10-14 15:33:45 +000057 SkASSERT(kGrPixelConfigCnt > config);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +000058 return fConfigRenderSupport[config][withMSAA];
commit-bot@chromium.org73880512013-10-14 15:33:45 +000059 }
60
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000061protected:
62 bool f8BitPaletteSupport : 1;
63 bool fNPOTTextureTileSupport : 1;
commit-bot@chromium.org47442312013-12-19 16:18:01 +000064 bool fMipMapSupport : 1;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000065 bool fTwoSidedStencilSupport : 1;
66 bool fStencilWrapOpsSupport : 1;
67 bool fHWAALineSupport : 1;
68 bool fShaderDerivativeSupport : 1;
69 bool fGeometryShaderSupport : 1;
70 bool fDualSourceBlendingSupport : 1;
71 bool fBufferLockSupport : 1;
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000072 bool fPathRenderingSupport : 1;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000073 bool fDstReadInShaderSupport : 1;
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +000074 bool fReuseScratchTextures : 1;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +000075 bool fGpuTracingSupport : 1;
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000076
77 int fMaxRenderTargetSize;
78 int fMaxTextureSize;
79 int fMaxSampleCount;
80
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +000081 // The first entry for each config is without msaa and the second is with.
82 bool fConfigRenderSupport[kGrPixelConfigCnt][2];
commit-bot@chromium.org73880512013-10-14 15:33:45 +000083
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000084 typedef SkRefCnt INHERITED;
85};
86
87#endif