8#ifndef GrD3DUtil_DEFINED
9#define GrD3DUtil_DEFINED
18#define GR_D3D_CALL_ERRCHECK(X) \
21 SkASSERT(SUCCEEDED(result)); \
22 if (!SUCCEEDED(result)) { \
23 SkDebugf("Failed Direct3D call. Error: 0x%08lx\n", result); \
27static constexpr bool operator==(
const D3D12_CPU_DESCRIPTOR_HANDLE & first,
28 const D3D12_CPU_DESCRIPTOR_HANDLE & second) {
29 return first.ptr == second.ptr;
54 case DXGI_FORMAT_D24_UNORM_S8_UINT:
return 0;
55 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
return 0;
63 case DXGI_FORMAT_R8G8B8A8_UNORM:
65 case DXGI_FORMAT_R8_UNORM:
67 case DXGI_FORMAT_B8G8R8A8_UNORM:
69 case DXGI_FORMAT_B5G6R5_UNORM:
71 case DXGI_FORMAT_R16G16B16A16_FLOAT:
73 case DXGI_FORMAT_R16_FLOAT:
75 case DXGI_FORMAT_R8G8_UNORM:
77 case DXGI_FORMAT_R10G10B10A2_UNORM:
79 case DXGI_FORMAT_B4G4R4A4_UNORM:
81 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
83 case DXGI_FORMAT_R16_UNORM:
85 case DXGI_FORMAT_R16G16_UNORM:
87 case DXGI_FORMAT_R16G16B16A16_UNORM:
89 case DXGI_FORMAT_R16G16_FLOAT:
105 case DXGI_FORMAT_R8G8B8A8_UNORM:
return 4;
106 case DXGI_FORMAT_R8_UNORM:
return 1;
107 case DXGI_FORMAT_B8G8R8A8_UNORM:
return 4;
108 case DXGI_FORMAT_B5G6R5_UNORM:
return 2;
109 case DXGI_FORMAT_R16G16B16A16_FLOAT:
return 8;
110 case DXGI_FORMAT_R16_FLOAT:
return 2;
111 case DXGI_FORMAT_R8G8_UNORM:
return 2;
112 case DXGI_FORMAT_R10G10B10A2_UNORM:
return 4;
113 case DXGI_FORMAT_B4G4R4A4_UNORM:
return 2;
114 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
return 4;
115 case DXGI_FORMAT_BC1_UNORM:
return 8;
116 case DXGI_FORMAT_R16_UNORM:
return 2;
117 case DXGI_FORMAT_R16G16_UNORM:
return 4;
118 case DXGI_FORMAT_R16G16B16A16_UNORM:
return 8;
119 case DXGI_FORMAT_R16G16_FLOAT:
return 4;
120 case DXGI_FORMAT_D24_UNORM_S8_UINT:
return 4;
121 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
return 8;
129 case DXGI_FORMAT_D24_UNORM_S8_UINT:
131 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
138#if defined(SK_DEBUG) || defined(GR_TEST_UTILS)
139static constexpr const char* GrDxgiFormatToStr(DXGI_FORMAT dxgiFormat) {
140 switch (dxgiFormat) {
141 case DXGI_FORMAT_R8G8B8A8_UNORM:
return "R8G8B8A8_UNORM";
142 case DXGI_FORMAT_R8_UNORM:
return "R8_UNORM";
143 case DXGI_FORMAT_B8G8R8A8_UNORM:
return "B8G8R8A8_UNORM";
144 case DXGI_FORMAT_B5G6R5_UNORM:
return "R5G6B5_UNORM";
145 case DXGI_FORMAT_R16G16B16A16_FLOAT:
return "R16G16B16A16_FLOAT";
146 case DXGI_FORMAT_R16_FLOAT:
return "R16_FLOAT";
147 case DXGI_FORMAT_R8G8_UNORM:
return "R8G8_UNORM";
148 case DXGI_FORMAT_R10G10B10A2_UNORM:
return "R10G10B10A2_UNORM";
149 case DXGI_FORMAT_B4G4R4A4_UNORM:
return "B4G4R4A4_UNORM";
150 case DXGI_FORMAT_R32G32B32A32_FLOAT:
return "R32G32B32A32_FLOAT";
151 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
return "R8G8B8A8_UNORM_SRGB";
152 case DXGI_FORMAT_BC1_UNORM:
return "BC1_UNORM";
153 case DXGI_FORMAT_R16_UNORM:
return "R16_UNORM";
154 case DXGI_FORMAT_R16G16_UNORM:
return "R16G16_UNORM";
155 case DXGI_FORMAT_R16G16B16A16_UNORM:
return "R16G16B16A16_UNORM";
156 case DXGI_FORMAT_R16G16_FLOAT:
return "R16G16_FLOAT";
157 case DXGI_FORMAT_D24_UNORM_S8_UINT:
return "D24_UNORM_S8_UINT";
158 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
return "D32_FLOAT_S8X24_UINT";
160 default:
return "Unknown";
std::wstring GrD3DMultiByteToWide(const std::string &str)
bool GrDxgiFormatIsCompressed(DXGI_FORMAT)
static constexpr bool operator==(const D3D12_CPU_DESCRIPTOR_HANDLE &first, const D3D12_CPU_DESCRIPTOR_HANDLE &second)
static constexpr uint32_t GrDxgiFormatChannels(DXGI_FORMAT format)
static constexpr size_t GrDxgiFormatBytesPerBlock(DXGI_FORMAT format)
static constexpr int GrDxgiFormatStencilBits(DXGI_FORMAT format)
static constexpr GrColorFormatDesc GrDxgiFormatDesc(DXGI_FORMAT format)
@ kRGB_SkColorChannelFlags
@ kRGBA_SkColorChannelFlags
@ kRed_SkColorChannelFlag
@ kRG_SkColorChannelFlags
uint32_t uint32_t * format