Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrD3DCaps Class Reference

#include <GrD3DCaps.h>

Inheritance diagram for GrD3DCaps:
GrCaps SkCapabilities SkRefCnt SkRefCntBase

Public Member Functions

 GrD3DCaps (const GrContextOptions &contextOptions, IDXGIAdapter1 *, ID3D12Device *)
 
bool isFormatSRGB (const GrBackendFormat &) const override
 
bool isFormatTexturable (const GrBackendFormat &, GrTextureType) const override
 
bool isFormatTexturable (DXGI_FORMAT) const
 
bool isFormatCopyable (const GrBackendFormat &) const override
 
bool isFormatAsColorTypeRenderable (GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
 
bool isFormatRenderable (const GrBackendFormat &format, int sampleCount) const override
 
bool isFormatRenderable (DXGI_FORMAT, int sampleCount) const
 
bool isFormatUnorderedAccessible (DXGI_FORMAT) const
 
int getRenderTargetSampleCount (int requestedCount, const GrBackendFormat &) const override
 
int getRenderTargetSampleCount (int requestedCount, DXGI_FORMAT) const
 
int maxRenderTargetSampleCount (const GrBackendFormat &) const override
 
int maxRenderTargetSampleCount (DXGI_FORMAT) const
 
GrColorType getFormatColorType (DXGI_FORMAT) const
 
SupportedWrite supportedWritePixelsColorType (GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const override
 
SurfaceReadPixelsSupport surfaceSupportsReadPixels (const GrSurface *) const override
 
DXGI_FORMAT preferredStencilFormat () const
 
bool canCopyTexture (DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
 
bool canCopyAsResolve (DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
 
GrBackendFormat getBackendFormatFromCompressionType (SkTextureCompressionType) const override
 
DXGI_FORMAT getFormatFromColorType (GrColorType colorType) const
 
skgpu::Swizzle getWriteSwizzle (const GrBackendFormat &, GrColorType) const override
 
uint64_t computeFormatKey (const GrBackendFormat &) const override
 
void addExtraSamplerKey (skgpu::KeyBuilder *, GrSamplerState, const GrBackendFormat &) const override
 
GrProgramDesc makeDesc (GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
 
bool resolveSubresourceRegionSupport () const
 
bool standardSwizzleLayoutSupport () const
 
- Public Member Functions inherited from GrCaps
 GrCaps (const GrContextOptions &)
 
void dumpJSON (SkJSONWriter *) const
 
const GrShaderCapsshaderCaps () const
 
bool npotTextureTileSupport () const
 
bool mipmapSupport () const
 
bool anisoSupport () const
 
bool gpuTracingSupport () const
 
bool oversizedStencilSupport () const
 
bool textureBarrierSupport () const
 
bool sampleLocationsSupport () const
 
bool drawInstancedSupport () const
 
bool nativeDrawIndirectSupport () const
 
bool useClientSideIndirectBuffers () const
 
bool conservativeRasterSupport () const
 
bool wireframeSupport () const
 
bool msaaResolvesAutomatically () const
 
bool preferDiscardableMSAAAttachment () const
 
bool halfFloatVertexAttributeSupport () const
 
bool usePrimitiveRestart () const
 
bool preferClientSideDynamicBuffers () const
 
bool preferFullscreenClears () const
 
bool discardStencilValuesAfterRenderPass () const
 
bool twoSidedStencilRefsAndMasksMustMatch () const
 
bool preferVRAMUseOverFlushes () const
 
bool avoidStencilBuffers () const
 
bool avoidWritePixelsFastPath () const
 
bool nativeDrawIndexedIndirectIsBroken () const
 
BlendEquationSupport blendEquationSupport () const
 
bool advancedBlendEquationSupport () const
 
bool advancedCoherentBlendEquationSupport () const
 
bool isAdvancedBlendEquationDisabled (skgpu::BlendEquation equation) const
 
bool shouldCollapseSrcOverToSrcWhenAble () const
 
bool mustSyncGpuDuringAbandon () const
 
bool reducedShaderMode () const
 
uint32_t mapBufferFlags () const
 
bool reuseScratchTextures () const
 
bool reuseScratchBuffers () const
 
int maxVertexAttributes () const
 maximum number of attribute values per vertex More...
 
int maxRenderTargetSize () const
 
int maxPreferredRenderTargetSize () const
 
int maxTextureSize () const
 
int maxWindowRectangles () const
 
bool isWindowRectanglesSupportedForRT (const GrBackendRenderTarget &rt) const
 
uint32_t maxPushConstantsSize () const
 
size_t transferBufferRowBytesAlignment () const
 
size_t transferFromBufferToBufferAlignment () const
 
size_t bufferUpdateDataPreserveAlignment () const
 
virtual bool isFormatSRGB (const GrBackendFormat &) const =0
 
bool isFormatCompressed (const GrBackendFormat &format) const
 
virtual bool isFormatTexturable (const GrBackendFormat &, GrTextureType) const =0
 
virtual bool isFormatCopyable (const GrBackendFormat &) const =0
 
virtual int maxRenderTargetSampleCount (const GrBackendFormat &) const =0
 
int internalMultisampleCount (const GrBackendFormat &format) const
 
virtual bool isFormatAsColorTypeRenderable (GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
 
virtual bool isFormatRenderable (const GrBackendFormat &format, int sampleCount) const =0
 
virtual int getRenderTargetSampleCount (int requestedCount, const GrBackendFormat &) const =0
 
bool surfaceSupportsWritePixels (const GrSurface *) const
 
virtual SurfaceReadPixelsSupport surfaceSupportsReadPixels (const GrSurface *) const =0
 
virtual SupportedWrite supportedWritePixelsColorType (GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const =0
 
SupportedRead supportedReadPixelsColorType (GrColorType srcColorType, const GrBackendFormat &srcFormat, GrColorType dstColorType) const
 
bool writePixelsRowBytesSupport () const
 
bool transferPixelsToRowBytesSupport () const
 
bool readPixelsRowBytesSupport () const
 
bool transferFromSurfaceToBufferSupport () const
 
bool transferFromBufferToTextureSupport () const
 
bool transferFromBufferToBufferSupport () const
 
bool suppressPrints () const
 
size_t bufferMapThreshold () const
 
bool mustClearUploadedBufferData () const
 
bool shouldInitializeTextures () const
 
bool buffersAreInitiallyZero () const
 
bool supportsAHardwareBufferImages () const
 
bool wireframeMode () const
 
bool semaphoreSupport () const
 
bool backendSemaphoreSupport () const
 
bool finishedProcAsyncCallbackSupport () const
 
bool crossContextTextureSupport () const
 
bool canCopySurface (const GrSurfaceProxy *dst, const SkIRect &dstRect, const GrSurfaceProxy *src, const SkIRect &srcRect) const
 
bool dynamicStateArrayGeometryProcessorTextureSupport () const
 
bool supportsProtectedContent () const
 
bool performPartialClearsAsDraws () const
 
bool performColorClearsAsDraws () const
 
bool avoidLargeIndexBufferDraws () const
 
bool performStencilClearsAsDraws () const
 
bool disableTessellationPathRenderer () const
 
GrDstSampleFlags getDstSampleFlagsForProxy (const GrRenderTargetProxy *, bool drawUsesMSAA) const
 
virtual DstCopyRestrictions getDstCopyRestrictions (const GrRenderTargetProxy *src, GrColorType ct) const
 
bool validateSurfaceParams (const SkISize &, const GrBackendFormat &, GrRenderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped, GrTextureType) const
 
bool areColorTypeAndFormatCompatible (GrColorType grCT, const GrBackendFormat &format) const
 
GrBackendFormat getDefaultBackendFormat (GrColorType, GrRenderable) const
 
virtual GrBackendFormat getBackendFormatFromCompressionType (SkTextureCompressionType) const =0
 
bool clampToBorderSupport () const
 
skgpu::Swizzle getReadSwizzle (const GrBackendFormat &format, GrColorType colorType) const
 
virtual skgpu::Swizzle getWriteSwizzle (const GrBackendFormat &, GrColorType) const =0
 
virtual uint64_t computeFormatKey (const GrBackendFormat &) const =0
 
const GrDriverBugWorkaroundsworkarounds () const
 
virtual void addExtraSamplerKey (skgpu::KeyBuilder *, GrSamplerState, const GrBackendFormat &) const
 
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (ProgramDescOverrideFlags)
 
virtual GrProgramDesc makeDesc (GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags overrideFlags=ProgramDescOverrideFlags::kNone) const =0
 
virtual GrInternalSurfaceFlags getExtraSurfaceFlagsForDeferredRT () const
 
bool supportsDynamicMSAA (const GrRenderTargetProxy *) const
 
virtual bool dmsaaResolveCanBeUsedAsTextureInSameRenderPass () const
 
bool avoidReorderingRenderTasks () const
 
bool avoidDithering () const
 
bool disablePerspectiveSDFText () const
 
bool avoidLineDraws () const
 
std::tuple< GrColorType, GrBackendFormatgetFallbackColorTypeAndFormat (GrColorType, int sampleCount) const
 
- Public Member Functions inherited from SkCapabilities
SkSL::Version skslVersion () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static int GetStencilFormatTotalBitCount (DXGI_FORMAT format)
 
- Static Public Member Functions inherited from SkCapabilities
static sk_sp< const SkCapabilitiesRasterBackend ()
 

Additional Inherited Members

- Public Types inherited from GrCaps
enum  BlendEquationSupport { kBasic_BlendEquationSupport , kAdvanced_BlendEquationSupport , kAdvancedCoherent_BlendEquationSupport , kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport }
 
enum  MapFlags { kNone_MapFlags = 0x0 , kCanMap_MapFlag = 0x1 , kSubset_MapFlag = 0x2 , kAsyncRead_MapFlag = 0x4 }
 
enum class  SurfaceReadPixelsSupport { kSupported , kCopyToTexture2D , kUnsupported }
 
enum class  ProgramDescOverrideFlags { kNone = 0 , kVulkanHasResolveLoadSubpass = 0x1 }
 
- Protected Member Functions inherited from GrCaps
void finishInitialization (const GrContextOptions &options)
 
virtual bool onSupportsDynamicMSAA (const GrRenderTargetProxy *) const
 
- Protected Member Functions inherited from SkCapabilities
 SkCapabilities ()=default
 
void initSkCaps (const SkSL::ShaderCaps *)
 
- Protected Attributes inherited from GrCaps
std::unique_ptr< GrShaderCapsfShaderCaps
 
bool fNPOTTextureTileSupport: 1
 
bool fMipmapSupport: 1
 
bool fAnisoSupport: 1
 
bool fReuseScratchTextures: 1
 
bool fReuseScratchBuffers: 1
 
bool fGpuTracingSupport: 1
 
bool fOversizedStencilSupport: 1
 
bool fTextureBarrierSupport: 1
 
bool fSampleLocationsSupport: 1
 
bool fDrawInstancedSupport: 1
 
bool fNativeDrawIndirectSupport: 1
 
bool fUseClientSideIndirectBuffers: 1
 
bool fConservativeRasterSupport: 1
 
bool fWireframeSupport: 1
 
bool fMSAAResolvesAutomatically: 1
 
bool fPreferDiscardableMSAAAttachment: 1
 
bool fUsePrimitiveRestart: 1
 
bool fPreferClientSideDynamicBuffers: 1
 
bool fPreferFullscreenClears: 1
 
bool fTwoSidedStencilRefsAndMasksMustMatch: 1
 
bool fMustClearUploadedBufferData: 1
 
bool fBuffersAreInitiallyZero: 1
 
bool fShouldInitializeTextures: 1
 
bool fSupportsAHardwareBufferImages: 1
 
bool fHalfFloatVertexAttributeSupport: 1
 
bool fClampToBorderSupport: 1
 
bool fPerformPartialClearsAsDraws: 1
 
bool fPerformColorClearsAsDraws: 1
 
bool fAvoidLargeIndexBufferDraws: 1
 
bool fPerformStencilClearsAsDraws: 1
 
bool fTransferFromBufferToTextureSupport: 1
 
bool fTransferFromSurfaceToBufferSupport: 1
 
bool fTransferFromBufferToBufferSupport: 1
 
bool fWritePixelsRowBytesSupport: 1
 
bool fTransferPixelsToRowBytesSupport: 1
 
bool fReadPixelsRowBytesSupport: 1
 
bool fShouldCollapseSrcOverToSrcWhenAble: 1
 
bool fMustSyncGpuDuringAbandon: 1
 
bool fDisableTessellationPathRenderer: 1
 
bool fAvoidStencilBuffers: 1
 
bool fAvoidWritePixelsFastPath: 1
 
bool fNativeDrawIndexedIndirectIsBroken: 1
 
bool fAvoidReorderingRenderTasks: 1
 
bool fAvoidDithering: 1
 
bool fDisablePerspectiveSDFText: 1
 
bool fAvoidLineDraws: 1
 
bool fPreferVRAMUseOverFlushes: 1
 
bool fSemaphoreSupport: 1
 
bool fBackendSemaphoreSupport: 1
 
bool fFinishedProcAsyncCallbackSupport: 1
 
bool fCrossContextTextureSupport: 1
 
bool fDynamicStateArrayGeometryProcessorTextureSupport: 1
 
bool fSupportsProtectedContent: 1
 
BlendEquationSupport fBlendEquationSupport
 
uint32_t fAdvBlendEqDisableFlags
 
uint32_t fMapBufferFlags
 
int fBufferMapThreshold
 
int fMaxRenderTargetSize
 
int fMaxPreferredRenderTargetSize
 
int fMaxVertexAttributes
 
int fMaxTextureSize
 
int fMaxWindowRectangles
 
int fInternalMultisampleCount
 
uint32_t fMaxPushConstantsSize = 0
 
size_t fTransferBufferRowBytesAlignment = 1
 
size_t fTransferFromBufferToBufferAlignment = 1
 
size_t fBufferUpdateDataPreserveAlignment = 1
 
GrDriverBugWorkarounds fDriverBugWorkarounds
 
- Protected Attributes inherited from SkCapabilities
SkSL::Version fSkSLVersion = SkSL::Version::k100
 

Detailed Description

Stores some capabilities of a D3D backend.

Definition at line 23 of file GrD3DCaps.h.

Constructor & Destructor Documentation

◆ GrD3DCaps()

GrD3DCaps::GrD3DCaps ( const GrContextOptions contextOptions,
IDXGIAdapter1 *  adapter,
ID3D12Device *  device 
)

Creates a GrD3DCaps that is set such that nothing is supported. The init function should be called to fill out the caps.

Definition at line 28 of file GrD3DCaps.cpp.

30 : INHERITED(contextOptions) {
31 /**************************************************************************
32 * GrCaps fields
33 **************************************************************************/
34 fNPOTTextureTileSupport = true; // available in feature level 10_0 and up
35 fMipmapSupport = true; // always available in Direct3D
36 fAnisoSupport = true; // always available in Direct3D
37 fReuseScratchTextures = true; //TODO: figure this out
38 fGpuTracingSupport = false; //TODO: figure this out
39 fOversizedStencilSupport = false; //TODO: figure this out
42
43 fSemaphoreSupport = true;
46 // TODO: implement these
49
50 // We always copy in/out of a transfer buffer so it's trivial to support row bytes.
54
58
59 fMaxRenderTargetSize = 16384; // minimum required by feature level 11_0
60 fMaxTextureSize = 16384; // minimum required by feature level 11_0
61
62 fTransferBufferRowBytesAlignment = D3D12_TEXTURE_DATA_PITCH_ALIGNMENT;
63
64 // TODO: implement
66
67 fShaderCaps = std::make_unique<GrShaderCaps>();
68
69 this->init(contextOptions, adapter, device);
70}
bool fDynamicStateArrayGeometryProcessorTextureSupport
Definition: GrCaps.h:646
bool fFinishedProcAsyncCallbackSupport
Definition: GrCaps.h:640
int fMaxRenderTargetSize
Definition: GrCaps.h:657
bool fReadPixelsRowBytesSupport
Definition: GrCaps.h:621
std::unique_ptr< GrShaderCaps > fShaderCaps
Definition: GrCaps.h:584
bool fReuseScratchTextures
Definition: GrCaps.h:589
bool fNativeDrawIndirectSupport
Definition: GrCaps.h:596
bool fAnisoSupport
Definition: GrCaps.h:588
bool fTransferFromBufferToBufferSupport
Definition: GrCaps.h:618
bool fTransferFromBufferToTextureSupport
Definition: GrCaps.h:616
bool fTransferPixelsToRowBytesSupport
Definition: GrCaps.h:620
bool fBackendSemaphoreSupport
Definition: GrCaps.h:639
bool fHalfFloatVertexAttributeSupport
Definition: GrCaps.h:610
bool fGpuTracingSupport
Definition: GrCaps.h:591
bool fOversizedStencilSupport
Definition: GrCaps.h:592
bool fSemaphoreSupport
Definition: GrCaps.h:638
bool fMipmapSupport
Definition: GrCaps.h:587
bool fWritePixelsRowBytesSupport
Definition: GrCaps.h:619
size_t fTransferBufferRowBytesAlignment
Definition: GrCaps.h:664
bool fNPOTTextureTileSupport
Definition: GrCaps.h:586
bool fTransferFromSurfaceToBufferSupport
Definition: GrCaps.h:617
bool fDrawInstancedSupport
Definition: GrCaps.h:595
int fMaxTextureSize
Definition: GrCaps.h:660
bool fCrossContextTextureSupport
Definition: GrCaps.h:643
VkDevice device
Definition: main.cc:53

Member Function Documentation

◆ addExtraSamplerKey()

void GrD3DCaps::addExtraSamplerKey ( skgpu::KeyBuilder ,
GrSamplerState  ,
const GrBackendFormat  
) const
overridevirtual

Adds fields to the key to represent the sampler that will be created for the passed in parameters. Currently this extra keying is only needed when building a vulkan pipeline with immutable samplers.

Reimplemented from GrCaps.

Definition at line 1058 of file GrD3DCaps.cpp.

1060 {
1061 // TODO
1062}

◆ canCopyAsResolve()

bool GrD3DCaps::canCopyAsResolve ( DXGI_FORMAT  dstFormat,
int  dstSampleCnt,
DXGI_FORMAT  srcFormat,
int  srcSamplecnt 
) const

Definition at line 83 of file GrD3DCaps.cpp.

84 {
85 // The src surface must be multisampled.
86 if (srcSampleCnt <= 1) {
87 return false;
88 }
89
90 // The dst must not be multisampled.
91 if (dstSampleCnt > 1) {
92 return false;
93 }
94
95 // Surfaces must have the same format.
96 // D3D12 can resolve between typeless and non-typeless formats, but we are not using
97 // typeless formats. It's not possible to resolve within the same format family otherwise.
98 if (srcFormat != dstFormat) {
99 return false;
100 }
101
102 return true;
103}

◆ canCopyTexture()

bool GrD3DCaps::canCopyTexture ( DXGI_FORMAT  dstFormat,
int  dstSampleCnt,
DXGI_FORMAT  srcFormat,
int  srcSamplecnt 
) const

Helpers used by canCopySurface. In all cases if the SampleCnt parameter is zero that means the surface is not a render target, otherwise it is the number of samples in the render target.

Definition at line 72 of file GrD3DCaps.cpp.

73 {
74 if ((dstSampleCnt > 1 || srcSampleCnt > 1) && dstSampleCnt != srcSampleCnt) {
75 return false;
76 }
77
78 // D3D allows us to copy within the same format family but doesn't do conversions
79 // so we require strict identity.
80 return srcFormat == dstFormat;
81}

◆ computeFormatKey()

uint64_t GrD3DCaps::computeFormatKey ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 1024 of file GrD3DCaps.cpp.

1024 {
1025 DXGI_FORMAT dxgiFormat;
1026 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
1027
1028 return (uint64_t)dxgiFormat;
1029}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
uint32_t uint32_t * format

◆ getBackendFormatFromCompressionType()

GrBackendFormat GrD3DCaps::getBackendFormatFromCompressionType ( SkTextureCompressionType  compressionType) const
overridevirtual

Implements GrCaps.

Definition at line 977 of file GrD3DCaps.cpp.

978 {
979 switch (compressionType) {
981 if (this->isFormatTexturable(DXGI_FORMAT_BC1_UNORM)) {
982 return GrBackendFormat::MakeDxgi(DXGI_FORMAT_BC1_UNORM);
983 }
984 return {};
985 default:
986 return {};
987 }
988
990}
#define SkUNREACHABLE
Definition: SkAssert.h:135
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
Definition: GrD3DCaps.cpp:800

◆ getFormatColorType()

GrColorType GrD3DCaps::getFormatColorType ( DXGI_FORMAT  format) const

Definition at line 899 of file GrD3DCaps.cpp.

899 {
900 const FormatInfo& info = this->getFormatInfo(format);
901 return info.fFormatColorType;
902}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213

◆ getFormatFromColorType()

DXGI_FORMAT GrD3DCaps::getFormatFromColorType ( GrColorType  colorType) const
inline

Definition at line 91 of file GrD3DCaps.h.

91 {
92 int idx = static_cast<int>(colorType);
93 return fColorTypeToFormatTable[idx];
94 }
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)

◆ getRenderTargetSampleCount() [1/2]

int GrD3DCaps::getRenderTargetSampleCount ( int  requestedCount,
const GrBackendFormat format 
) const
overridevirtual

Implements GrCaps.

Definition at line 847 of file GrD3DCaps.cpp.

848 {
849 DXGI_FORMAT dxgiFormat;
850 if (!format.asDxgiFormat(&dxgiFormat)) {
851 return 0;
852 }
853
854 return this->getRenderTargetSampleCount(requestedCount, dxgiFormat);
855}
int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const override
Definition: GrD3DCaps.cpp:847

◆ getRenderTargetSampleCount() [2/2]

int GrD3DCaps::getRenderTargetSampleCount ( int  requestedCount,
DXGI_FORMAT  format 
) const

Definition at line 857 of file GrD3DCaps.cpp.

857 {
858 requestedCount = std::max(1, requestedCount);
859
860 const FormatInfo& info = this->getFormatInfo(format);
861
862 int count = info.fColorSampleCounts.size();
863
864 if (!count) {
865 return 0;
866 }
867
868 if (1 == requestedCount) {
869 SkASSERT(info.fColorSampleCounts.size() && info.fColorSampleCounts[0] == 1);
870 return 1;
871 }
872
873 for (int i = 0; i < count; ++i) {
874 if (info.fColorSampleCounts[i] >= requestedCount) {
875 return info.fColorSampleCounts[i];
876 }
877 }
878 return 0;
879}
int count
Definition: FontMgrTest.cpp:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ GetStencilFormatTotalBitCount()

static int GrD3DCaps::GetStencilFormatTotalBitCount ( DXGI_FORMAT  format)
inlinestatic

Definition at line 65 of file GrD3DCaps.h.

65 {
66 switch (format) {
67 case DXGI_FORMAT_D24_UNORM_S8_UINT:
68 return 32;
69 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
70 // DXGI_FORMAT_D32_FLOAT_S8X24_UINT has 24 unused bits at the end so total bits is 64.
71 return 64;
72 default:
73 SkASSERT(false);
74 return 0;
75 }
76 }

◆ getWriteSwizzle()

skgpu::Swizzle GrD3DCaps::getWriteSwizzle ( const GrBackendFormat ,
GrColorType   
) const
overridevirtual

Returns the skgpu::Swizzle to use when writing colors to a surface with the passed in GrBackendFormat and GrColorType.

Implements GrCaps.

Definition at line 1008 of file GrD3DCaps.cpp.

1009 {
1010 DXGI_FORMAT dxgiFormat;
1011 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
1012 const auto& info = this->getFormatInfo(dxgiFormat);
1013 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1014 const auto& ctInfo = info.fColorTypeInfos[i];
1015 if (ctInfo.fColorType == colorType) {
1016 return ctInfo.fWriteSwizzle;
1017 }
1018 }
1019 SkDEBUGFAILF("Illegal color type (%d) and format (%d) combination.",
1020 (int)colorType, (int)dxgiFormat);
1021 return {};
1022}
#define SkDEBUGFAILF(fmt,...)
Definition: SkAssert.h:119

◆ isFormatAsColorTypeRenderable()

bool GrD3DCaps::isFormatAsColorTypeRenderable ( GrColorType  ct,
const GrBackendFormat format,
int  sampleCount = 1 
) const
overridevirtual

Implements GrCaps.

Definition at line 814 of file GrD3DCaps.cpp.

815 {
816 DXGI_FORMAT dxgiFormat;
817 if (!format.asDxgiFormat(&dxgiFormat)) {
818 return false;
819 }
820 if (!this->isFormatRenderable(dxgiFormat, sampleCount)) {
821 return false;
822 }
823 const auto& info = this->getFormatInfo(dxgiFormat);
824 if (!SkToBool(info.colorTypeFlags(ct) & ColorTypeInfo::kRenderable_Flag)) {
825 return false;
826 }
827 return true;
828}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const override
Definition: GrD3DCaps.cpp:830

◆ isFormatCopyable()

bool GrD3DCaps::isFormatCopyable ( const GrBackendFormat ) const
inlineoverridevirtual

Implements GrCaps.

Definition at line 36 of file GrD3DCaps.h.

36{ return true; }

◆ isFormatRenderable() [1/2]

bool GrD3DCaps::isFormatRenderable ( const GrBackendFormat format,
int  sampleCount 
) const
overridevirtual

Implements GrCaps.

Definition at line 830 of file GrD3DCaps.cpp.

830 {
831 DXGI_FORMAT dxgiFormat;
832 if (!format.asDxgiFormat(&dxgiFormat)) {
833 return false;
834 }
835 return this->isFormatRenderable(dxgiFormat, sampleCount);
836}

◆ isFormatRenderable() [2/2]

bool GrD3DCaps::isFormatRenderable ( DXGI_FORMAT  format,
int  sampleCount 
) const

Definition at line 838 of file GrD3DCaps.cpp.

838 {
839 return sampleCount <= this->maxRenderTargetSampleCount(format);
840}
int maxRenderTargetSampleCount(const GrBackendFormat &) const override
Definition: GrD3DCaps.cpp:881

◆ isFormatSRGB()

bool GrD3DCaps::isFormatSRGB ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 786 of file GrD3DCaps.cpp.

786 {
787 DXGI_FORMAT dxgiFormat;
788 if (!format.asDxgiFormat(&dxgiFormat)) {
789 return false;
790 }
791
792 switch (dxgiFormat) {
793 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
794 return true;
795 default:
796 return false;
797 }
798}

◆ isFormatTexturable() [1/2]

bool GrD3DCaps::isFormatTexturable ( const GrBackendFormat format,
GrTextureType   
) const
overridevirtual

Implements GrCaps.

Definition at line 800 of file GrD3DCaps.cpp.

800 {
801 DXGI_FORMAT dxgiFormat;
802 if (!format.asDxgiFormat(&dxgiFormat)) {
803 return false;
804 }
805
806 return this->isFormatTexturable(dxgiFormat);
807}

◆ isFormatTexturable() [2/2]

bool GrD3DCaps::isFormatTexturable ( DXGI_FORMAT  format) const

Definition at line 809 of file GrD3DCaps.cpp.

809 {
810 const FormatInfo& info = this->getFormatInfo(format);
811 return SkToBool(FormatInfo::kTexturable_Flag & info.fFlags);
812}

◆ isFormatUnorderedAccessible()

bool GrD3DCaps::isFormatUnorderedAccessible ( DXGI_FORMAT  format) const

Definition at line 842 of file GrD3DCaps.cpp.

842 {
843 const FormatInfo& info = this->getFormatInfo(format);
844 return SkToBool(FormatInfo::kUnorderedAccess_Flag & info.fFlags);
845}

◆ makeDesc()

GrProgramDesc GrD3DCaps::makeDesc ( GrRenderTarget rt,
const GrProgramInfo programInfo,
ProgramDescOverrideFlags  overrideFlags 
) const
overridevirtual

TODO: Determine what goes in the ProgramDesc

Implements GrCaps.

Definition at line 1067 of file GrD3DCaps.cpp.

1069 {
1070 SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
1072 GrProgramDesc::Build(&desc, programInfo, *this);
1073
1074 skgpu::KeyBuilder b(desc.key());
1075
1076 GrD3DRenderTarget* d3dRT = (GrD3DRenderTarget*) rt;
1077 d3dRT->genKey(&b);
1078
1079 GrStencilSettings stencil = programInfo.nonGLStencilSettings();
1080 stencil.genKey(&b, false);
1081
1082 programInfo.pipeline().genKey(&b, *this);
1083 // The num samples is already added in the render target key so we don't need to add it here.
1084
1085 // D3D requires the full primitive type as part of its key
1086 b.add32(programInfo.primitiveTypeKey());
1087
1088 b.flush();
1089 return desc;
1090}
void genKey(skgpu::KeyBuilder *b) const
void genKey(skgpu::KeyBuilder *, const GrCaps &) const
Definition: GrPipeline.cpp:79
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint16_t primitiveTypeKey() const
Definition: GrProgramInfo.h:54
const GrPipeline & pipeline() const
Definition: GrProgramInfo.h:39
GrStencilSettings nonGLStencilSettings() const
void genKey(skgpu::KeyBuilder *b, bool includeRefsAndMasks) const
static bool b

◆ maxRenderTargetSampleCount() [1/2]

int GrD3DCaps::maxRenderTargetSampleCount ( const GrBackendFormat format) const
overridevirtual

Implements GrCaps.

Definition at line 881 of file GrD3DCaps.cpp.

881 {
882 DXGI_FORMAT dxgiFormat;
883 if (!format.asDxgiFormat(&dxgiFormat)) {
884 return 0;
885 }
886 return this->maxRenderTargetSampleCount(dxgiFormat);
887}

◆ maxRenderTargetSampleCount() [2/2]

int GrD3DCaps::maxRenderTargetSampleCount ( DXGI_FORMAT  format) const

Definition at line 889 of file GrD3DCaps.cpp.

889 {
890 const FormatInfo& info = this->getFormatInfo(format);
891
892 const auto& table = info.fColorSampleCounts;
893 if (!table.size()) {
894 return 0;
895 }
896 return table[table.size() - 1];
897}
SI F table(const skcms_Curve *curve, F v)

◆ preferredStencilFormat()

DXGI_FORMAT GrD3DCaps::preferredStencilFormat ( ) const
inline

Returns both a supported and most preferred stencil format to use in draws.

Definition at line 62 of file GrD3DCaps.h.

62 {
63 return fPreferredStencilFormat;
64 }

◆ resolveSubresourceRegionSupport()

bool GrD3DCaps::resolveSubresourceRegionSupport ( ) const
inline

Definition at line 108 of file GrD3DCaps.h.

108{ return fResolveSubresourceRegionSupport; }

◆ standardSwizzleLayoutSupport()

bool GrD3DCaps::standardSwizzleLayoutSupport ( ) const
inline

Definition at line 109 of file GrD3DCaps.h.

109{ return fStandardSwizzleLayoutSupport; }

◆ supportedWritePixelsColorType()

GrCaps::SupportedWrite GrD3DCaps::supportedWritePixelsColorType ( GrColorType  surfaceColorType,
const GrBackendFormat surfaceFormat,
GrColorType  srcColorType 
) const
overridevirtual

Given a dst pixel config and a src color type what color type must the caller coax the the data into in order to use GrGpu::writePixels().

Implements GrCaps.

Definition at line 904 of file GrD3DCaps.cpp.

906 {
907 DXGI_FORMAT dxgiFormat;
908 if (!surfaceFormat.asDxgiFormat(&dxgiFormat)) {
909 return { GrColorType::kUnknown, 0 };
910 }
911
912 // Any buffer data needs to be aligned to 512 bytes and that of a single texel.
913 size_t offsetAlignment = SkAlignTo(GrDxgiFormatBytesPerBlock(dxgiFormat),
914 D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
915
916 const auto& info = this->getFormatInfo(dxgiFormat);
917 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
918 const auto& ctInfo = info.fColorTypeInfos[i];
919 if (ctInfo.fColorType == surfaceColorType) {
920 return { surfaceColorType, offsetAlignment };
921 }
922 }
923 return { GrColorType::kUnknown, 0 };
924}
static constexpr size_t GrDxgiFormatBytesPerBlock(DXGI_FORMAT format)
Definition: GrD3DUtil.h:103
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
Definition: SkAlign.h:33

◆ surfaceSupportsReadPixels()

GrCaps::SurfaceReadPixelsSupport GrD3DCaps::surfaceSupportsReadPixels ( const GrSurface ) const
overridevirtual

Backends may have restrictions on what types of surfaces support GrGpu::readPixels(). We may either be able to read directly from the surface, read from a copy of the surface, or not read at all.

Implements GrCaps.

Definition at line 926 of file GrD3DCaps.cpp.

927 {
928 if (surface->isProtected()) {
930 }
931 if (auto tex = static_cast<const GrD3DTexture*>(surface->asTexture())) {
932 // We can't directly read from a compressed format
933 if (GrDxgiFormatIsCompressed(tex->dxgiFormat())) {
935 }
937 } else if (auto rt = static_cast<const GrD3DRenderTarget*>(surface->asRenderTarget())) {
938 if (rt->numSamples() > 1) {
940 }
942 }
944}
bool GrDxgiFormatIsCompressed(DXGI_FORMAT format)
Definition: GrD3DUtil.cpp:15
VkSurfaceKHR surface
Definition: main.cc:49

The documentation for this class was generated from the following files: