2013-03-25 18:19:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#ifndef GrDrawTargetCaps_DEFINED
|
|
|
|
#define GrDrawTargetCaps_DEFINED
|
|
|
|
|
2013-11-21 15:23:15 +00:00
|
|
|
#include "GrTypes.h"
|
2014-12-09 17:00:49 +00:00
|
|
|
#include "GrTypesPriv.h"
|
|
|
|
#include "GrShaderVar.h"
|
2013-11-21 15:23:15 +00:00
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
/**
|
|
|
|
* Represents the draw target capabilities.
|
|
|
|
*/
|
|
|
|
class GrDrawTargetCaps : public SkRefCnt {
|
|
|
|
public:
|
2014-07-25 18:52:47 +00:00
|
|
|
SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2014-12-09 17:00:49 +00:00
|
|
|
/** Info about shader variable precision within a given shader stage. That is, this info
|
2014-12-09 18:04:14 +00:00
|
|
|
is relevant to a float (or vecNf) variable declared with a GrSLPrecision
|
2014-12-09 17:00:49 +00:00
|
|
|
in a given GrShaderType. The info here is hoisted from the OpenGL spec. */
|
|
|
|
struct PrecisionInfo {
|
|
|
|
PrecisionInfo() {
|
|
|
|
fLogRangeLow = 0;
|
|
|
|
fLogRangeHigh = 0;
|
|
|
|
fBits = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Is this precision level allowed in the shader stage? */
|
|
|
|
bool supported() const { return 0 != fBits; }
|
|
|
|
|
|
|
|
bool operator==(const PrecisionInfo& that) const {
|
|
|
|
return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fLogRangeHigh &&
|
|
|
|
fBits == that.fBits;
|
|
|
|
}
|
|
|
|
bool operator!=(const PrecisionInfo& that) const { return !(*this == that); }
|
|
|
|
|
|
|
|
/** floor(log2(|min_value|)) */
|
|
|
|
int fLogRangeLow;
|
|
|
|
/** floor(log2(|max_value|)) */
|
|
|
|
int fLogRangeHigh;
|
|
|
|
/** Number of bits of precision. As defined in OpenGL (with names modified to reflect this
|
|
|
|
struct) :
|
|
|
|
"""
|
|
|
|
If the smallest representable value greater than 1 is 1 + e, then fBits will
|
|
|
|
contain floor(log2(e)), and every value in the range [2^fLogRangeLow,
|
|
|
|
2^fLogRangeHigh] can be represented to at least one part in 2^fBits.
|
|
|
|
"""
|
|
|
|
*/
|
|
|
|
int fBits;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-09-19 19:07:43 +00:00
|
|
|
GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) {
|
|
|
|
this->reset();
|
|
|
|
}
|
|
|
|
GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(CreateUniqueID()) {
|
|
|
|
*this = other;
|
|
|
|
}
|
2013-03-25 18:19:00 +00:00
|
|
|
GrDrawTargetCaps& operator= (const GrDrawTargetCaps&);
|
|
|
|
|
|
|
|
virtual void reset();
|
2013-11-21 15:23:15 +00:00
|
|
|
virtual SkString dump() const;
|
2013-03-25 18:19:00 +00:00
|
|
|
|
|
|
|
bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
|
2013-12-19 16:18:01 +00:00
|
|
|
/** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
|
|
|
|
only for POT textures) */
|
|
|
|
bool mipMapSupport() const { return fMipMapSupport; }
|
2013-03-25 18:19:00 +00:00
|
|
|
bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
|
|
|
|
bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
|
|
|
|
bool hwAALineSupport() const { return fHWAALineSupport; }
|
|
|
|
bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; }
|
|
|
|
bool geometryShaderSupport() const { return fGeometryShaderSupport; }
|
|
|
|
bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
|
2013-10-09 14:11:33 +00:00
|
|
|
bool pathRenderingSupport() const { return fPathRenderingSupport; }
|
2013-05-03 13:35:14 +00:00
|
|
|
bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
|
2014-03-28 16:08:05 +00:00
|
|
|
bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
|
2014-02-21 18:45:30 +00:00
|
|
|
bool gpuTracingSupport() const { return fGpuTracingSupport; }
|
2014-07-30 18:25:44 +00:00
|
|
|
bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
|
2013-10-30 21:30:43 +00:00
|
|
|
|
2014-11-05 15:05:34 +00:00
|
|
|
bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; }
|
|
|
|
|
2014-05-05 12:32:37 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
|
|
|
|
* textures allows partial mappings or full mappings.
|
|
|
|
*/
|
|
|
|
enum MapFlags {
|
|
|
|
kNone_MapFlags = 0x0, //<! Cannot map the resource.
|
|
|
|
|
|
|
|
kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of
|
|
|
|
// the other flags to have meaning.k
|
|
|
|
kSubset_MapFlag = 0x2, //<! The resource can be partially mapped.
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t mapBufferFlags() const { return fMapBufferFlags; }
|
|
|
|
|
2013-10-30 21:30:43 +00:00
|
|
|
// Scratch textures not being reused means that those scratch textures
|
2013-10-31 07:01:53 +00:00
|
|
|
// that we upload to (i.e., don't have a render target) will not be
|
2013-10-30 21:30:43 +00:00
|
|
|
// recycled in the texture cache. This is to prevent ghosting by drivers
|
|
|
|
// (in particular for deferred architectures).
|
2013-07-18 22:26:39 +00:00
|
|
|
bool reuseScratchTextures() const { return fReuseScratchTextures; }
|
2013-03-25 18:19:00 +00:00
|
|
|
|
|
|
|
int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
|
|
|
|
int maxTextureSize() const { return fMaxTextureSize; }
|
|
|
|
// Will be 0 if MSAA is not supported
|
|
|
|
int maxSampleCount() const { return fMaxSampleCount; }
|
|
|
|
|
2013-10-15 14:18:16 +00:00
|
|
|
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
|
2013-10-14 15:33:45 +00:00
|
|
|
SkASSERT(kGrPixelConfigCnt > config);
|
2013-10-15 14:18:16 +00:00
|
|
|
return fConfigRenderSupport[config][withMSAA];
|
2013-10-14 15:33:45 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 13:55:58 +00:00
|
|
|
bool isConfigTexturable(GrPixelConfig config) const {
|
|
|
|
SkASSERT(kGrPixelConfigCnt > config);
|
|
|
|
return fConfigTextureSupport[config];
|
2014-05-27 19:26:59 +00:00
|
|
|
}
|
|
|
|
|
2014-12-09 17:00:49 +00:00
|
|
|
/**
|
|
|
|
* Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a
|
|
|
|
* given shader type. If the shader type is not supported or the precision level is not
|
|
|
|
* supported in that shader type then the returned struct will report false when supported() is
|
|
|
|
* called.
|
|
|
|
*/
|
|
|
|
const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
|
2014-12-09 18:04:14 +00:00
|
|
|
GrSLPrecision precision) const {
|
2014-12-09 17:00:49 +00:00
|
|
|
return fFloatPrecisions[shaderType][precision];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is there any difference between the float shader variable precision types? If this is true
|
|
|
|
* then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would
|
|
|
|
* report the same info for all precisions in all shader types.
|
|
|
|
*/
|
|
|
|
bool floatPrecisionVaries() const { return fShaderPrecisionVaries; }
|
|
|
|
|
2014-09-19 19:07:43 +00:00
|
|
|
/**
|
|
|
|
* Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does
|
|
|
|
* not change when the content of the GrDrawTargetCaps object changes. This will never return
|
|
|
|
* 0.
|
|
|
|
*/
|
|
|
|
uint32_t getUniqueID() const { return fUniqueID; }
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
protected:
|
|
|
|
bool fNPOTTextureTileSupport : 1;
|
2013-12-19 16:18:01 +00:00
|
|
|
bool fMipMapSupport : 1;
|
2013-03-25 18:19:00 +00:00
|
|
|
bool fTwoSidedStencilSupport : 1;
|
|
|
|
bool fStencilWrapOpsSupport : 1;
|
|
|
|
bool fHWAALineSupport : 1;
|
|
|
|
bool fShaderDerivativeSupport : 1;
|
|
|
|
bool fGeometryShaderSupport : 1;
|
|
|
|
bool fDualSourceBlendingSupport : 1;
|
2013-10-09 14:11:33 +00:00
|
|
|
bool fPathRenderingSupport : 1;
|
2013-05-03 13:35:14 +00:00
|
|
|
bool fDstReadInShaderSupport : 1;
|
2014-03-28 16:08:05 +00:00
|
|
|
bool fDiscardRenderTargetSupport: 1;
|
2013-07-18 22:26:39 +00:00
|
|
|
bool fReuseScratchTextures : 1;
|
2014-02-21 18:45:30 +00:00
|
|
|
bool fGpuTracingSupport : 1;
|
2014-07-30 18:25:44 +00:00
|
|
|
bool fCompressedTexSubImageSupport : 1;
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2014-11-05 15:05:34 +00:00
|
|
|
// Driver workaround
|
|
|
|
bool fUseDrawInsteadOfClear : 1;
|
|
|
|
|
2014-05-05 12:32:37 +00:00
|
|
|
uint32_t fMapBufferFlags;
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
int fMaxRenderTargetSize;
|
|
|
|
int fMaxTextureSize;
|
|
|
|
int fMaxSampleCount;
|
|
|
|
|
2013-10-15 14:18:16 +00:00
|
|
|
// The first entry for each config is without msaa and the second is with.
|
|
|
|
bool fConfigRenderSupport[kGrPixelConfigCnt][2];
|
2014-05-30 13:55:58 +00:00
|
|
|
bool fConfigTextureSupport[kGrPixelConfigCnt];
|
2014-05-27 19:26:59 +00:00
|
|
|
|
2014-12-09 17:00:49 +00:00
|
|
|
bool fShaderPrecisionVaries;
|
2014-12-09 18:04:14 +00:00
|
|
|
PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
|
2014-12-09 17:00:49 +00:00
|
|
|
|
2014-09-19 19:07:43 +00:00
|
|
|
private:
|
|
|
|
static uint32_t CreateUniqueID();
|
|
|
|
|
|
|
|
const uint32_t fUniqueID;
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|