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.
|
|
|
|
*/
|
2015-05-19 16:29:46 +00:00
|
|
|
#ifndef GrCaps_DEFINED
|
|
|
|
#define GrCaps_DEFINED
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2013-11-21 15:23:15 +00:00
|
|
|
#include "GrTypes.h"
|
2014-12-09 17:00:49 +00:00
|
|
|
#include "GrTypesPriv.h"
|
2015-06-12 16:01:18 +00:00
|
|
|
#include "GrBlend.h"
|
2014-12-09 17:00:49 +00:00
|
|
|
#include "GrShaderVar.h"
|
2016-11-29 18:43:05 +00:00
|
|
|
#include "GrShaderCaps.h"
|
2013-11-21 15:23:15 +00:00
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
|
2015-05-22 21:01:46 +00:00
|
|
|
struct GrContextOptions;
|
|
|
|
|
2015-04-29 18:18:05 +00:00
|
|
|
|
|
|
|
/**
|
2015-05-19 16:29:46 +00:00
|
|
|
* Represents the capabilities of a GrContext.
|
2015-04-29 18:18:05 +00:00
|
|
|
*/
|
2015-05-19 16:29:46 +00:00
|
|
|
class GrCaps : public SkRefCnt {
|
2015-04-29 18:18:05 +00:00
|
|
|
public:
|
2015-05-22 21:01:46 +00:00
|
|
|
GrCaps(const GrContextOptions&);
|
2015-05-22 17:37:30 +00:00
|
|
|
|
2013-11-21 15:23:15 +00:00
|
|
|
virtual SkString dump() const;
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2016-11-29 18:43:05 +00:00
|
|
|
const GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
|
2015-04-29 18:18:05 +00:00
|
|
|
|
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; }
|
2016-03-25 13:01:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Skia convention is that a device only has sRGB support if it supports sRGB formats for both
|
|
|
|
* textures and framebuffers. In addition:
|
|
|
|
* Decoding to linear of an sRGB texture can be disabled.
|
|
|
|
*/
|
2016-03-21 13:55:37 +00:00
|
|
|
bool srgbSupport() const { return fSRGBSupport; }
|
2016-05-05 18:52:53 +00:00
|
|
|
/**
|
|
|
|
* Is there support for enabling/disabling sRGB writes for sRGB-capable color buffers?
|
|
|
|
*/
|
|
|
|
bool srgbWriteControl() const { return fSRGBWriteControl; }
|
2013-03-25 18:19:00 +00:00
|
|
|
bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
|
|
|
|
bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
|
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; }
|
2015-02-20 14:58:13 +00:00
|
|
|
bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
|
2015-04-21 18:45:56 +00:00
|
|
|
bool textureBarrierSupport() const { return fTextureBarrierSupport; }
|
2016-02-26 18:39:34 +00:00
|
|
|
bool sampleLocationsSupport() const { return fSampleLocationsSupport; }
|
2016-06-10 21:06:32 +00:00
|
|
|
bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
|
2016-01-15 19:36:18 +00:00
|
|
|
bool usesMixedSamples() const { return fUsesMixedSamples; }
|
2016-07-13 17:16:32 +00:00
|
|
|
bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; }
|
2013-10-30 21:30:43 +00:00
|
|
|
|
2014-11-05 15:05:34 +00:00
|
|
|
bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; }
|
2015-06-18 21:18:02 +00:00
|
|
|
bool useDrawInsteadOfPartialRenderTargetWrite() const {
|
|
|
|
return fUseDrawInsteadOfPartialRenderTargetWrite;
|
|
|
|
}
|
2014-11-05 15:05:34 +00:00
|
|
|
|
2016-02-16 19:36:47 +00:00
|
|
|
bool useDrawInsteadOfAllRenderTargetWrites() const {
|
|
|
|
return fUseDrawInsteadOfAllRenderTargetWrites;
|
|
|
|
}
|
|
|
|
|
2015-08-20 16:39:02 +00:00
|
|
|
bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; }
|
|
|
|
|
2016-07-29 15:14:20 +00:00
|
|
|
/**
|
|
|
|
* Indicates the level of support for gr_instanced::* functionality. A higher level includes
|
|
|
|
* all functionality from the levels below it.
|
|
|
|
*/
|
|
|
|
enum class InstancedSupport {
|
|
|
|
kNone,
|
|
|
|
kBasic,
|
|
|
|
kMultisampled,
|
|
|
|
kMixedSampled
|
|
|
|
};
|
|
|
|
|
|
|
|
InstancedSupport instancedSupport() const { return fInstancedSupport; }
|
|
|
|
|
|
|
|
bool avoidInstancedDrawsToFPTargets() const { return fAvoidInstancedDrawsToFPTargets; }
|
|
|
|
|
2015-05-06 20:40:21 +00:00
|
|
|
/**
|
|
|
|
* Indicates the capabilities of the fixed function blend unit.
|
|
|
|
*/
|
|
|
|
enum BlendEquationSupport {
|
|
|
|
kBasic_BlendEquationSupport, //<! Support to select the operator that
|
|
|
|
// combines src and dst terms.
|
|
|
|
kAdvanced_BlendEquationSupport, //<! Additional fixed function support for specific
|
|
|
|
// SVG/PDF blend modes. Requires blend barriers.
|
|
|
|
kAdvancedCoherent_BlendEquationSupport, //<! Advanced blend equation support that does not
|
|
|
|
// require blend barriers, and permits overlap.
|
|
|
|
|
|
|
|
kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport
|
|
|
|
};
|
|
|
|
|
|
|
|
BlendEquationSupport blendEquationSupport() const { return fBlendEquationSupport; }
|
|
|
|
|
|
|
|
bool advancedBlendEquationSupport() const {
|
|
|
|
return fBlendEquationSupport >= kAdvanced_BlendEquationSupport;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool advancedCoherentBlendEquationSupport() const {
|
|
|
|
return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport;
|
|
|
|
}
|
|
|
|
|
2015-06-12 16:01:18 +00:00
|
|
|
bool canUseAdvancedBlendEquation(GrBlendEquation equation) const {
|
|
|
|
SkASSERT(GrBlendEquationIsAdvanced(equation));
|
|
|
|
return SkToBool(fAdvBlendEqBlacklist & (1 << equation));
|
|
|
|
}
|
|
|
|
|
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; }
|
2015-06-24 13:54:10 +00:00
|
|
|
bool reuseScratchBuffers() const { return fReuseScratchBuffers; }
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2016-03-23 17:40:53 +00:00
|
|
|
/// maximum number of attribute values per vertex
|
|
|
|
int maxVertexAttributes() const { return fMaxVertexAttributes; }
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
|
|
|
|
int maxTextureSize() const { return fMaxTextureSize; }
|
2015-11-02 19:36:52 +00:00
|
|
|
/** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps.
|
|
|
|
It is usually the max texture size, unless we're overriding it for testing. */
|
|
|
|
int maxTileSize() const { SkASSERT(fMaxTileSize <= fMaxTextureSize); return fMaxTileSize; }
|
2015-06-01 14:13:42 +00:00
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
// Will be 0 if MSAA is not supported
|
2016-01-15 19:36:18 +00:00
|
|
|
int maxColorSampleCount() const { return fMaxColorSampleCount; }
|
|
|
|
// Will be 0 if MSAA is not supported
|
|
|
|
int maxStencilSampleCount() const { return fMaxStencilSampleCount; }
|
2016-02-05 17:35:20 +00:00
|
|
|
// Will be 0 if raster multisample is not supported. Raster multisample is a special HW mode
|
|
|
|
// where the rasterizer runs with more samples than are in the target framebuffer.
|
|
|
|
int maxRasterSamples() const { return fMaxRasterSamples; }
|
2016-01-15 19:36:18 +00:00
|
|
|
// We require the sample count to be less than maxColorSampleCount and maxStencilSampleCount.
|
|
|
|
// If we are using mixed samples, we only care about stencil.
|
|
|
|
int maxSampleCount() const {
|
|
|
|
if (this->usesMixedSamples()) {
|
|
|
|
return this->maxStencilSampleCount();
|
|
|
|
} else {
|
|
|
|
return SkTMin(this->maxColorSampleCount(), this->maxStencilSampleCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 19:42:47 +00:00
|
|
|
int maxWindowRectangles() const { return fMaxWindowRectangles; }
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2016-01-08 17:12:44 +00:00
|
|
|
virtual bool isConfigTexturable(GrPixelConfig config) const = 0;
|
|
|
|
virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
|
2016-11-29 16:59:17 +00:00
|
|
|
virtual bool canConfigBeImageStorage(GrPixelConfig config) const = 0;
|
2014-05-27 19:26:59 +00:00
|
|
|
|
2015-11-11 21:18:11 +00:00
|
|
|
bool suppressPrints() const { return fSuppressPrints; }
|
|
|
|
|
|
|
|
bool immediateFlush() const { return fImmediateFlush; }
|
2015-05-22 21:01:46 +00:00
|
|
|
|
2016-03-25 19:15:03 +00:00
|
|
|
size_t bufferMapThreshold() const {
|
|
|
|
SkASSERT(fBufferMapThreshold >= 0);
|
|
|
|
return fBufferMapThreshold;
|
2015-05-29 13:46:47 +00:00
|
|
|
}
|
2015-05-22 21:01:46 +00:00
|
|
|
|
2015-08-06 17:54:13 +00:00
|
|
|
bool fullClearIsFree() const { return fFullClearIsFree; }
|
|
|
|
|
2016-09-27 13:34:10 +00:00
|
|
|
/** True in environments that will issue errors if memory uploaded to buffers
|
2015-08-19 15:26:51 +00:00
|
|
|
is not initialized (even if not read by draw calls). */
|
|
|
|
bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; }
|
|
|
|
|
2016-03-25 16:26:03 +00:00
|
|
|
bool sampleShadingSupport() const { return fSampleShadingSupport; }
|
|
|
|
|
2016-09-30 15:39:02 +00:00
|
|
|
bool fenceSyncSupport() const { return fFenceSyncSupport; }
|
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
protected:
|
2015-05-27 20:23:23 +00:00
|
|
|
/** Subclasses must call this at the end of their constructors in order to apply caps
|
|
|
|
overrides requested by the client. Note that overrides will only reduce the caps never
|
|
|
|
expand them. */
|
|
|
|
void applyOptionsOverrides(const GrContextOptions& options);
|
|
|
|
|
2016-10-27 16:30:08 +00:00
|
|
|
sk_sp<GrShaderCaps> fShaderCaps;
|
2015-04-29 18:18:05 +00:00
|
|
|
|
2015-06-18 21:18:02 +00:00
|
|
|
bool fNPOTTextureTileSupport : 1;
|
|
|
|
bool fMipMapSupport : 1;
|
2016-03-21 13:55:37 +00:00
|
|
|
bool fSRGBSupport : 1;
|
2016-05-05 18:52:53 +00:00
|
|
|
bool fSRGBWriteControl : 1;
|
2015-06-18 21:18:02 +00:00
|
|
|
bool fTwoSidedStencilSupport : 1;
|
|
|
|
bool fStencilWrapOpsSupport : 1;
|
|
|
|
bool fDiscardRenderTargetSupport : 1;
|
|
|
|
bool fReuseScratchTextures : 1;
|
2015-06-24 13:54:10 +00:00
|
|
|
bool fReuseScratchBuffers : 1;
|
2015-06-18 21:18:02 +00:00
|
|
|
bool fGpuTracingSupport : 1;
|
|
|
|
bool fCompressedTexSubImageSupport : 1;
|
|
|
|
bool fOversizedStencilSupport : 1;
|
|
|
|
bool fTextureBarrierSupport : 1;
|
2016-02-26 18:39:34 +00:00
|
|
|
bool fSampleLocationsSupport : 1;
|
2016-06-10 21:06:32 +00:00
|
|
|
bool fMultisampleDisableSupport : 1;
|
2016-01-15 19:36:18 +00:00
|
|
|
bool fUsesMixedSamples : 1;
|
2016-07-13 17:16:32 +00:00
|
|
|
bool fPreferClientSideDynamicBuffers : 1;
|
2015-08-06 17:54:13 +00:00
|
|
|
bool fFullClearIsFree : 1;
|
2015-08-19 15:26:51 +00:00
|
|
|
bool fMustClearUploadedBufferData : 1;
|
2015-06-24 13:54:10 +00:00
|
|
|
|
2014-11-05 15:05:34 +00:00
|
|
|
// Driver workaround
|
2015-06-18 21:18:02 +00:00
|
|
|
bool fUseDrawInsteadOfClear : 1;
|
|
|
|
bool fUseDrawInsteadOfPartialRenderTargetWrite : 1;
|
2016-02-16 19:36:47 +00:00
|
|
|
bool fUseDrawInsteadOfAllRenderTargetWrites : 1;
|
2016-07-29 15:14:20 +00:00
|
|
|
bool fAvoidInstancedDrawsToFPTargets : 1;
|
2014-11-05 15:05:34 +00:00
|
|
|
|
2015-08-20 16:39:02 +00:00
|
|
|
// ANGLE workaround
|
|
|
|
bool fPreferVRAMUseOverFlushes : 1;
|
|
|
|
|
2016-03-25 16:26:03 +00:00
|
|
|
bool fSampleShadingSupport : 1;
|
2016-09-30 15:39:02 +00:00
|
|
|
// TODO: this may need to be an enum to support different fence types
|
|
|
|
bool fFenceSyncSupport : 1;
|
2016-03-25 16:26:03 +00:00
|
|
|
|
2016-07-29 15:14:20 +00:00
|
|
|
InstancedSupport fInstancedSupport;
|
|
|
|
|
2015-05-06 20:40:21 +00:00
|
|
|
BlendEquationSupport fBlendEquationSupport;
|
2015-06-12 16:01:18 +00:00
|
|
|
uint32_t fAdvBlendEqBlacklist;
|
|
|
|
GR_STATIC_ASSERT(kLast_GrBlendEquation < 32);
|
|
|
|
|
2014-05-05 12:32:37 +00:00
|
|
|
uint32_t fMapBufferFlags;
|
2016-03-25 19:15:03 +00:00
|
|
|
int fBufferMapThreshold;
|
2014-05-05 12:32:37 +00:00
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
int fMaxRenderTargetSize;
|
2016-03-23 17:40:53 +00:00
|
|
|
int fMaxVertexAttributes;
|
2013-03-25 18:19:00 +00:00
|
|
|
int fMaxTextureSize;
|
2015-11-02 19:36:52 +00:00
|
|
|
int fMaxTileSize;
|
2016-01-15 19:36:18 +00:00
|
|
|
int fMaxColorSampleCount;
|
|
|
|
int fMaxStencilSampleCount;
|
2016-02-05 17:35:20 +00:00
|
|
|
int fMaxRasterSamples;
|
2016-08-09 19:42:47 +00:00
|
|
|
int fMaxWindowRectangles;
|
2013-03-25 18:19:00 +00:00
|
|
|
|
2014-09-19 19:07:43 +00:00
|
|
|
private:
|
2016-09-27 13:34:10 +00:00
|
|
|
virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
|
2015-11-04 12:23:53 +00:00
|
|
|
|
2015-11-11 21:18:11 +00:00
|
|
|
bool fSuppressPrints : 1;
|
|
|
|
bool fImmediateFlush: 1;
|
2015-05-22 21:01:46 +00:00
|
|
|
|
2013-03-25 18:19:00 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|