Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private 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
 
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
 
bool isFormatCompressed (const GrBackendFormat &format) const
 
int internalMultisampleCount (const GrBackendFormat &format) const
 
bool surfaceSupportsWritePixels (const GrSurface *) const
 
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
 
bool clampToBorderSupport () const
 
skgpu::Swizzle getReadSwizzle (const GrBackendFormat &format, GrColorType colorType) const
 
const GrDriverBugWorkaroundsworkarounds () const
 
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (ProgramDescOverrideFlags)
 
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 ()
 

Private Member Functions

bool onSurfaceSupportsWritePixels (const GrSurface *) const override
 
bool onCanCopySurface (const GrSurfaceProxy *dst, const SkIRect &dstRect, const GrSurfaceProxy *src, const SkIRect &srcRect) const override
 
GrBackendFormat onGetDefaultBackendFormat (GrColorType) const override
 
bool onAreColorTypeAndFormatCompatible (GrColorType, const GrBackendFormat &) const override
 
SupportedRead onSupportedReadPixelsColorType (GrColorType, const GrBackendFormat &, GrColorType) const override
 
skgpu::Swizzle onGetReadSwizzle (const GrBackendFormat &, GrColorType) const override
 

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}
#define SkAssertResult(cond)
Definition SkAssert.h:123
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

◆ 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

◆ 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
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ 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

◆ 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

◆ 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
static void Build(GrProgramDesc *, const GrProgramInfo &, const GrCaps &)
uint16_t primitiveTypeKey() const
const GrPipeline & pipeline() const
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)

◆ onAreColorTypeAndFormatCompatible()

bool GrD3DCaps::onAreColorTypeAndFormatCompatible ( GrColorType  ct,
const GrBackendFormat format 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 953 of file GrD3DCaps.cpp.

954 {
955 DXGI_FORMAT dxgiFormat;
956 if (!format.asDxgiFormat(&dxgiFormat)) {
957 return false;
958 }
959
960 const auto& info = this->getFormatInfo(dxgiFormat);
961 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
962 if (info.fColorTypeInfos[i].fColorType == ct) {
963 return true;
964 }
965 }
966 return false;
967}

◆ onCanCopySurface()

bool GrD3DCaps::onCanCopySurface ( const GrSurfaceProxy dst,
const SkIRect dstRect,
const GrSurfaceProxy src,
const SkIRect srcRect 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 105 of file GrD3DCaps.cpp.

106 {
107 // D3D12 does not support scaling copies
108 if (srcRect.size() != dstRect.size()) {
109 return false;
110 }
111 if (src->isProtected() == GrProtected::kYes && dst->isProtected() != GrProtected::kYes) {
112 return false;
113 }
114
115 int dstSampleCnt = 0;
116 int srcSampleCnt = 0;
117 if (const GrRenderTargetProxy* rtProxy = dst->asRenderTargetProxy()) {
118 dstSampleCnt = rtProxy->numSamples();
119 }
120 if (const GrRenderTargetProxy* rtProxy = src->asRenderTargetProxy()) {
121 srcSampleCnt = rtProxy->numSamples();
122 }
123 SkASSERT((dstSampleCnt > 0) == SkToBool(dst->asRenderTargetProxy()));
124 SkASSERT((srcSampleCnt > 0) == SkToBool(src->asRenderTargetProxy()));
125
126 DXGI_FORMAT dstFormat, srcFormat;
127 SkAssertResult(dst->backendFormat().asDxgiFormat(&dstFormat));
128 SkAssertResult(src->backendFormat().asDxgiFormat(&srcFormat));
129
130 return this->canCopyTexture(dstFormat, dstSampleCnt, srcFormat, srcSampleCnt) ||
131 this->canCopyAsResolve(dstFormat, dstSampleCnt, srcFormat, srcSampleCnt);
132}
bool canCopyTexture(DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
Definition GrD3DCaps.cpp:72
bool canCopyAsResolve(DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
Definition GrD3DCaps.cpp:83
dst
Definition cp.py:12
constexpr SkISize size() const
Definition SkRect.h:172

◆ onGetDefaultBackendFormat()

GrBackendFormat GrD3DCaps::onGetDefaultBackendFormat ( GrColorType  ct) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 969 of file GrD3DCaps.cpp.

969 {
970 DXGI_FORMAT format = this->getFormatFromColorType(ct);
971 if (format == DXGI_FORMAT_UNKNOWN) {
972 return {};
973 }
974 return GrBackendFormat::MakeDxgi(format);
975}
DXGI_FORMAT getFormatFromColorType(GrColorType colorType) const
Definition GrD3DCaps.h:91

◆ onGetReadSwizzle()

skgpu::Swizzle GrD3DCaps::onGetReadSwizzle ( const GrBackendFormat format,
GrColorType  colorType 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 992 of file GrD3DCaps.cpp.

993 {
994 DXGI_FORMAT dxgiFormat;
995 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
996 const auto& info = this->getFormatInfo(dxgiFormat);
997 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
998 const auto& ctInfo = info.fColorTypeInfos[i];
999 if (ctInfo.fColorType == colorType) {
1000 return ctInfo.fReadSwizzle;
1001 }
1002 }
1003 SkDEBUGFAILF("Illegal color type (%d) and format (%d) combination.",
1004 (int)colorType, (int)dxgiFormat);
1005 return {};
1006}

◆ onSupportedReadPixelsColorType()

GrCaps::SupportedRead GrD3DCaps::onSupportedReadPixelsColorType ( GrColorType  srcColorType,
const GrBackendFormat srcBackendFormat,
GrColorType  dstColorType 
) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 1031 of file GrD3DCaps.cpp.

1033 {
1034 DXGI_FORMAT dxgiFormat;
1035 if (!srcBackendFormat.asDxgiFormat(&dxgiFormat)) {
1036 return { GrColorType::kUnknown, 0 };
1037 }
1038
1039 SkTextureCompressionType compression = GrBackendFormatToCompressionType(srcBackendFormat);
1040 if (compression != SkTextureCompressionType::kNone) {
1043 }
1044
1045 // Any subresource buffer data offset we copy to needs to be aligned to 512 bytes.
1046 size_t offsetAlignment = D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT;
1047
1048 const auto& info = this->getFormatInfo(dxgiFormat);
1049 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
1050 const auto& ctInfo = info.fColorTypeInfos[i];
1051 if (ctInfo.fColorType == srcColorType) {
1052 return { srcColorType, offsetAlignment };
1053 }
1054 }
1055 return { GrColorType::kUnknown, 0 };
1056}
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression)

◆ onSurfaceSupportsWritePixels()

bool GrD3DCaps::onSurfaceSupportsWritePixels ( const GrSurface surface) const
overrideprivatevirtual

Implements GrCaps.

Definition at line 946 of file GrD3DCaps.cpp.

946 {
947 if (auto rt = surface->asRenderTarget()) {
948 return rt->numSamples() <= 1 && SkToBool(surface->asTexture());
949 }
950 return true;
951}
VkSurfaceKHR surface
Definition main.cc:49

◆ 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:101
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

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