Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrD3DCaps.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8
15#include "src/gpu/KeyBuilder.h"
27
28GrD3DCaps::GrD3DCaps(const GrContextOptions& contextOptions, IDXGIAdapter1* adapter,
29 ID3D12Device* device)
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}
71
72bool GrD3DCaps::canCopyTexture(DXGI_FORMAT dstFormat, int dstSampleCnt,
73 DXGI_FORMAT srcFormat, int srcSampleCnt) const {
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}
82
83bool GrD3DCaps::canCopyAsResolve(DXGI_FORMAT dstFormat, int dstSampleCnt,
84 DXGI_FORMAT srcFormat, int srcSampleCnt) const {
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}
104
105bool GrD3DCaps::onCanCopySurface(const GrSurfaceProxy* dst, const SkIRect& dstRect,
106 const GrSurfaceProxy* src, const SkIRect& srcRect) const {
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}
133
134void GrD3DCaps::init(const GrContextOptions& contextOptions, IDXGIAdapter1* adapter,
135 ID3D12Device* device) {
136 D3D_FEATURE_LEVEL featureLevels[] = {
137 D3D_FEATURE_LEVEL_11_0,
138 D3D_FEATURE_LEVEL_11_1,
139 D3D_FEATURE_LEVEL_12_0,
140 D3D_FEATURE_LEVEL_12_1,
141 };
142 D3D12_FEATURE_DATA_FEATURE_LEVELS flDesc = {};
143 flDesc.NumFeatureLevels = _countof(featureLevels);
144 flDesc.pFeatureLevelsRequested = featureLevels;
145 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &flDesc,
146 sizeof(flDesc)));
147 // This had better be true
148 SkASSERT(flDesc.MaxSupportedFeatureLevel >= D3D_FEATURE_LEVEL_11_0);
149
150 DXGI_ADAPTER_DESC adapterDesc;
151 GR_D3D_CALL_ERRCHECK(adapter->GetDesc(&adapterDesc));
152
153 D3D12_FEATURE_DATA_D3D12_OPTIONS optionsDesc;
154 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &optionsDesc,
155 sizeof(optionsDesc)));
156
157
158 // See https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-support
159 if (D3D12_RESOURCE_BINDING_TIER_1 == optionsDesc.ResourceBindingTier) {
160 fMaxPerStageShaderResourceViews = 128;
161 if (D3D_FEATURE_LEVEL_11_0 == flDesc.MaxSupportedFeatureLevel) {
162 fMaxPerStageUnorderedAccessViews = 8;
163 } else {
164 fMaxPerStageUnorderedAccessViews = 64;
165 }
166 } else {
167 // The doc above says "full heap", but practically it seems like it should be
168 // limited by the maximum number of samplers in a heap
169 fMaxPerStageUnorderedAccessViews = 2032;
170 fMaxPerStageShaderResourceViews = 2032;
171 }
172
173 fStandardSwizzleLayoutSupport = (optionsDesc.StandardSwizzle64KBSupported);
174
175 D3D12_FEATURE_DATA_D3D12_OPTIONS2 optionsDesc2;
176 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &optionsDesc2,
177 sizeof(optionsDesc2)));
178 fResolveSubresourceRegionSupport = (optionsDesc2.ProgrammableSamplePositionsTier !=
179 D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED);
180
181 this->initGrCaps(optionsDesc, device);
182 this->initShaderCaps(adapterDesc.VendorId, optionsDesc);
183
184 this->initFormatTable(adapterDesc, device);
185 this->initStencilFormat(device);
186
187 if (!contextOptions.fDisableDriverCorrectnessWorkarounds) {
188 this->applyDriverCorrectnessWorkarounds(adapterDesc.VendorId);
189 }
190
191 this->finishInitialization(contextOptions);
192}
193
194void GrD3DCaps::initGrCaps(const D3D12_FEATURE_DATA_D3D12_OPTIONS& optionsDesc,
195 ID3D12Device* device) {
196 // We assume a minimum of Shader Model 5.1, which allows at most 32 vertex inputs.
198
199 // Can use standard sample locations
201
202 if (D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED !=
203 optionsDesc.ConservativeRasterizationTier) {
205 }
206
207 fWireframeSupport = true;
208
209 // Feature level 11_0 and up support up to 16K in texture dimension
210 fMaxTextureSize = 16384;
211 // There's no specific cap for RT size, so use texture size
213 // Our render targets are always created with textures as the color
214 // attachment, hence this min:
216
218
219 // Assuming since we will always map in the end to upload the data we might as well just map
220 // from the get go. There is no hard data to suggest this is faster or slower.
222
224
226
228
229 // Advanced blend modes don't appear to be supported.
230}
231
232void GrD3DCaps::initShaderCaps(int vendorID, const D3D12_FEATURE_DATA_D3D12_OPTIONS& optionsDesc) {
234 shaderCaps->fVersionDeclString = "#version 330\n";
235
236 // Shader Model 5 supports all of the following:
239 // Flat interpolation appears to be slow on Qualcomm GPUs. This was tested in GL and is assumed
240 // to be true with D3D as well.
241 shaderCaps->fPreferFlatInterpolation = kQualcomm_D3DVendor != vendorID;
242
244
247
249
252 // TODO(skia:12352) HLSL does not expose asinh/acosh/atanh
258
261 D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE == optionsDesc.MinPrecisionSupport;
262
263 // See https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-support
264 // The maximum number of samplers in a shader-visible descriptor heap is 2048, but
265 // 16 of those are reserved for the driver.
267 (D3D12_RESOURCE_BINDING_TIER_1 == optionsDesc.ResourceBindingTier) ? 16 : 2032;
268}
269
270void GrD3DCaps::applyDriverCorrectnessWorkarounds(int vendorID) {
271 // Nothing yet.
272}
273
274
275bool stencil_format_supported(ID3D12Device* device, DXGI_FORMAT format) {
276 D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupportDesc;
277 formatSupportDesc.Format = format;
278 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
279 &formatSupportDesc,
280 sizeof(formatSupportDesc)));
281 return SkToBool(D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL & formatSupportDesc.Support1);
282}
283
284void GrD3DCaps::initStencilFormat(ID3D12Device* device) {
285 if (stencil_format_supported(device, DXGI_FORMAT_D24_UNORM_S8_UINT)) {
286 fPreferredStencilFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
287 } else {
288 SkASSERT(stencil_format_supported(device, DXGI_FORMAT_D32_FLOAT_S8X24_UINT));
289 fPreferredStencilFormat = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
290 }
291}
292
293// These are all the valid DXGI_FORMATs that we support in Skia. They are roughly ordered from most
294// frequently used to least to improve look up times in arrays.
295static constexpr DXGI_FORMAT kDxgiFormats[] = {
296 DXGI_FORMAT_R8G8B8A8_UNORM,
297 DXGI_FORMAT_R8_UNORM,
298 DXGI_FORMAT_B8G8R8A8_UNORM,
299 DXGI_FORMAT_B5G6R5_UNORM,
300 DXGI_FORMAT_R16G16B16A16_FLOAT,
301 DXGI_FORMAT_R16_FLOAT,
302 DXGI_FORMAT_R8G8_UNORM,
303 DXGI_FORMAT_R10G10B10A2_UNORM,
304 DXGI_FORMAT_B4G4R4A4_UNORM,
305 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
306 DXGI_FORMAT_BC1_UNORM,
307 DXGI_FORMAT_R16_UNORM,
308 DXGI_FORMAT_R16G16_UNORM,
309 DXGI_FORMAT_R16G16B16A16_UNORM,
310 DXGI_FORMAT_R16G16_FLOAT
311};
312
313void GrD3DCaps::setColorType(GrColorType colorType, std::initializer_list<DXGI_FORMAT> formats) {
314#ifdef SK_DEBUG
315 for (size_t i = 0; i < kNumDxgiFormats; ++i) {
316 const auto& formatInfo = fFormatTable[i];
317 for (int j = 0; j < formatInfo.fColorTypeInfoCount; ++j) {
318 const auto& ctInfo = formatInfo.fColorTypeInfos[j];
319 if (ctInfo.fColorType == colorType &&
320 !SkToBool(ctInfo.fFlags & ColorTypeInfo::kWrappedOnly_Flag)) {
321 bool found = false;
322 for (auto it = formats.begin(); it != formats.end(); ++it) {
323 if (kDxgiFormats[i] == *it) {
324 found = true;
325 }
326 }
327 SkASSERT(found);
328 }
329 }
330 }
331#endif
332 int idx = static_cast<int>(colorType);
333 for (auto it = formats.begin(); it != formats.end(); ++it) {
334 const auto& info = this->getFormatInfo(*it);
335 for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
336 if (info.fColorTypeInfos[i].fColorType == colorType) {
337 fColorTypeToFormatTable[idx] = *it;
338 return;
339 }
340 }
341 }
342}
343
344const GrD3DCaps::FormatInfo& GrD3DCaps::getFormatInfo(DXGI_FORMAT format) const {
345 GrD3DCaps* nonConstThis = const_cast<GrD3DCaps*>(this);
346 return nonConstThis->getFormatInfo(format);
347}
348
349GrD3DCaps::FormatInfo& GrD3DCaps::getFormatInfo(DXGI_FORMAT format) {
350 static_assert(std::size(kDxgiFormats) == GrD3DCaps::kNumDxgiFormats,
351 "Size of DXGI_FORMATs array must match static value in header");
352 for (size_t i = 0; i < std::size(kDxgiFormats); ++i) {
353 if (kDxgiFormats[i] == format) {
354 return fFormatTable[i];
355 }
356 }
357 static FormatInfo kInvalidFormat;
358 return kInvalidFormat;
359}
360
361void GrD3DCaps::initFormatTable(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Device* device) {
362 static_assert(std::size(kDxgiFormats) == GrD3DCaps::kNumDxgiFormats,
363 "Size of DXGI_FORMATs array must match static value in header");
364
365 std::fill_n(fColorTypeToFormatTable, kGrColorTypeCnt, DXGI_FORMAT_UNKNOWN);
366
367 // Go through all the formats and init their support surface and data GrColorTypes.
368 // Format: DXGI_FORMAT_R8G8B8A8_UNORM
369 {
370 constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM;
371 auto& info = this->getFormatInfo(format);
372 info.init(adapterDesc, device, format);
373 info.fFormatColorType = GrColorType::kRGBA_8888;
374 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
375 info.fColorTypeInfoCount = 2;
376 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
377 int ctIdx = 0;
378 // Format: DXGI_FORMAT_R8G8B8A8_UNORM, Surface: kRGBA_8888
379 {
381 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
382 ctInfo.fColorType = ct;
383 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
384 }
385 // Format: DXGI_FORMAT_R8G8B8A8_UNORM, Surface: kRGB_888x
386 {
387 constexpr GrColorType ct = GrColorType::kRGB_888x;
388 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
389 ctInfo.fColorType = ct;
390 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
391 ctInfo.fReadSwizzle = skgpu::Swizzle("rgb1");
392 }
393 }
394 }
395
396 // Format: DXGI_FORMAT_R8_UNORM
397 {
398 constexpr DXGI_FORMAT format = DXGI_FORMAT_R8_UNORM;
399 auto& info = this->getFormatInfo(format);
400 info.init(adapterDesc, device, format);
401 info.fFormatColorType = GrColorType::kR_8;
402 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
403 info.fColorTypeInfoCount = 3;
404 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
405 int ctIdx = 0;
406 // Format: DXGI_FORMAT_R8_UNORM, Surface: kR_8
407 {
408 constexpr GrColorType ct = GrColorType::kR_8;
409 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
410 ctInfo.fColorType = ct;
411 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
412 }
413 // Format: DXGI_FORMAT_R8_UNORM, Surface: kAlpha_8
414 {
415 constexpr GrColorType ct = GrColorType::kAlpha_8;
416 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
417 ctInfo.fColorType = ct;
418 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
419 ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
420 ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
421 }
422 // Format: DXGI_FORMAT_R8_UNORM, Surface: kGray_8
423 {
424 constexpr GrColorType ct = GrColorType::kGray_8;
425 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
426 ctInfo.fColorType = ct;
427 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
428 ctInfo.fReadSwizzle = skgpu::Swizzle("rrr1");
429 }
430 }
431 }
432 // Format: DXGI_FORMAT_B8G8R8A8_UNORM
433 {
434 constexpr DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM;
435 auto& info = this->getFormatInfo(format);
436 info.init(adapterDesc, device, format);
437 info.fFormatColorType = GrColorType::kBGRA_8888;
438 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
439 info.fColorTypeInfoCount = 1;
440 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
441 int ctIdx = 0;
442 // Format: DXGI_FORMAT_B8G8R8A8_UNORM, Surface: kBGRA_8888
443 {
445 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
446 ctInfo.fColorType = ct;
447 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
448 }
449 }
450 }
451 // Format: DXGI_FORMAT_B5G6R5_UNORM
452 {
453 constexpr DXGI_FORMAT format = DXGI_FORMAT_B5G6R5_UNORM;
454 auto& info = this->getFormatInfo(format);
455 info.init(adapterDesc, device, format);
456 info.fFormatColorType = GrColorType::kBGR_565;
457 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
458 info.fColorTypeInfoCount = 1;
459 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
460 int ctIdx = 0;
461 // Format: DXGI_FORMAT_B5G6R5_UNORM, Surface: kBGR_565
462 {
463 constexpr GrColorType ct = GrColorType::kBGR_565;
464 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
465 ctInfo.fColorType = ct;
466 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
467 }
468 }
469 }
470 // Format: DXGI_FORMAT_R16G16B16A16_FLOAT
471 {
472 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16G16B16A16_FLOAT;
473 auto& info = this->getFormatInfo(format);
474 info.init(adapterDesc, device, format);
475 info.fFormatColorType = GrColorType::kRGBA_F16;
476 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
477 info.fColorTypeInfoCount = 2;
478 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
479 int ctIdx = 0;
480 // Format: DXGI_FORMAT_R16G16B16A16_FLOAT, Surface: GrColorType::kRGBA_F16
481 {
482 constexpr GrColorType ct = GrColorType::kRGBA_F16;
483 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
484 ctInfo.fColorType = ct;
485 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
486 }
487 // Format: DXGI_FORMAT_R16G16B16A16_FLOAT, Surface: GrColorType::kRGBA_F16_Clamped
488 {
490 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
491 ctInfo.fColorType = ct;
492 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
493 }
494 }
495 }
496 // Format: DXGI_FORMAT_R16_FLOAT
497 {
498 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16_FLOAT;
499 auto& info = this->getFormatInfo(format);
500 info.init(adapterDesc, device, format);
501 info.fFormatColorType = GrColorType::kR_F16;
502 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
503 info.fColorTypeInfoCount = 1;
504 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
505 int ctIdx = 0;
506 // Format: DXGI_FORMAT_R16_FLOAT, Surface: kAlpha_F16
507 {
509 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
510 ctInfo.fColorType = ct;
511 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
512 ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
513 ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
514 }
515 }
516 }
517 // Format: DXGI_FORMAT_R8G8_UNORM
518 {
519 constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8_UNORM;
520 auto& info = this->getFormatInfo(format);
521 info.init(adapterDesc, device, format);
522 info.fFormatColorType = GrColorType::kRG_88;
523 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
524 info.fColorTypeInfoCount = 1;
525 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
526 int ctIdx = 0;
527 // Format: DXGI_FORMAT_R8G8_UNORM, Surface: kRG_88
528 {
529 constexpr GrColorType ct = GrColorType::kRG_88;
530 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
531 ctInfo.fColorType = ct;
532 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
533 }
534 }
535 }
536 // Format: DXGI_FORMAT_R10G10B10A2_UNORM
537 {
538 constexpr DXGI_FORMAT format = DXGI_FORMAT_R10G10B10A2_UNORM;
539 auto& info = this->getFormatInfo(format);
540 info.init(adapterDesc, device, format);
541 info.fFormatColorType = GrColorType::kRGBA_1010102;
542 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
543 info.fColorTypeInfoCount = 1;
544 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
545 int ctIdx = 0;
546 // Format: DXGI_FORMAT_R10G10B10A2_UNORM, Surface: kRGBA_1010102
547 {
549 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
550 ctInfo.fColorType = ct;
551 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
552 }
553 }
554 }
555 // Format: DXGI_FORMAT_B4G4R4A4_UNORM
556 {
557 constexpr DXGI_FORMAT format = DXGI_FORMAT_B4G4R4A4_UNORM;
558 auto& info = this->getFormatInfo(format);
559 info.init(adapterDesc, device, format);
560 info.fFormatColorType = GrColorType::kBGRA_4444;
561 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
562 info.fColorTypeInfoCount = 1;
563 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
564 int ctIdx = 0;
565 // Format: DXGI_FORMAT_B4G4R4A4_UNORM, Surface: kABGR_4444
566 {
568 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
569 ctInfo.fColorType = ct;
570 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
571 ctInfo.fReadSwizzle = skgpu::Swizzle("argb");
572 ctInfo.fWriteSwizzle = skgpu::Swizzle("gbar");
573 }
574 }
575 }
576 // Format: DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
577 {
578 constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
579 auto& info = this->getFormatInfo(format);
580 info.init(adapterDesc, device, format);
581 info.fFormatColorType = GrColorType::kRGBA_8888_SRGB;
582 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
583 info.fColorTypeInfoCount = 1;
584 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
585 int ctIdx = 0;
586 // Format: DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, Surface: kRGBA_8888_SRGB
587 {
589 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
590 ctInfo.fColorType = ct;
591 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
592 }
593 }
594 }
595 // Format: DXGI_FORMAT_R16_UNORM
596 {
597 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16_UNORM;
598 auto& info = this->getFormatInfo(format);
599 info.init(adapterDesc, device, format);
600 info.fFormatColorType = GrColorType::kR_16;
601 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
602 info.fColorTypeInfoCount = 1;
603 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
604 int ctIdx = 0;
605 // Format: DXGI_FORMAT_R16_UNORM, Surface: kAlpha_16
606 {
607 constexpr GrColorType ct = GrColorType::kAlpha_16;
608 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
609 ctInfo.fColorType = ct;
610 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
611 ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
612 ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
613 }
614 }
615 }
616 // Format: DXGI_FORMAT_R16G16_UNORM
617 {
618 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16G16_UNORM;
619 auto& info = this->getFormatInfo(format);
620 info.init(adapterDesc, device, format);
621 info.fFormatColorType = GrColorType::kRG_1616;
622 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
623 info.fColorTypeInfoCount = 1;
624 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
625 int ctIdx = 0;
626 // Format: DXGI_FORMAT_R16G16_UNORM, Surface: kRG_1616
627 {
628 constexpr GrColorType ct = GrColorType::kRG_1616;
629 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
630 ctInfo.fColorType = ct;
631 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
632 }
633 }
634 }
635 // Format: DXGI_FORMAT_R16G16B16A16_UNORM
636 {
637 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16G16B16A16_UNORM;
638 auto& info = this->getFormatInfo(format);
639 info.init(adapterDesc, device, format);
640 info.fFormatColorType = GrColorType::kRGBA_16161616;
641 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
642 info.fColorTypeInfoCount = 1;
643 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
644 int ctIdx = 0;
645 // Format: DXGI_FORMAT_R16G16B16A16_UNORM, Surface: kRGBA_16161616
646 {
648 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
649 ctInfo.fColorType = ct;
650 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
651 }
652 }
653 }
654 // Format: DXGI_FORMAT_R16G16_FLOAT
655 {
656 constexpr DXGI_FORMAT format = DXGI_FORMAT_R16G16_FLOAT;
657 auto& info = this->getFormatInfo(format);
658 info.init(adapterDesc, device, format);
659 info.fFormatColorType = GrColorType::kRG_F16;
660 if (SkToBool(info.fFlags & FormatInfo::kTexturable_Flag)) {
661 info.fColorTypeInfoCount = 1;
662 info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
663 int ctIdx = 0;
664 // Format: DXGI_FORMAT_R16G16_FLOAT, Surface: kRG_F16
665 {
666 constexpr GrColorType ct = GrColorType::kRG_F16;
667 auto& ctInfo = info.fColorTypeInfos[ctIdx++];
668 ctInfo.fColorType = ct;
669 ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
670 }
671 }
672 }
673
674 // Format: DXGI_FORMAT_BC1_UNORM
675 {
676 constexpr DXGI_FORMAT format = DXGI_FORMAT_BC1_UNORM;
677 auto& info = this->getFormatInfo(format);
678 info.init(adapterDesc, device, format);
679 // No supported GrColorTypes.
680 }
681
682 ////////////////////////////////////////////////////////////////////////////
683 // Map GrColorTypes (used for creating GrSurfaces) to DXGI_FORMATs. The order in which the
684 // formats are passed into the setColorType function indicates the priority in selecting which
685 // format we use for a given GrcolorType.
686
687 this->setColorType(GrColorType::kAlpha_8, { DXGI_FORMAT_R8_UNORM });
688 this->setColorType(GrColorType::kBGR_565, { DXGI_FORMAT_B5G6R5_UNORM });
689 this->setColorType(GrColorType::kABGR_4444, { DXGI_FORMAT_B4G4R4A4_UNORM });
690 this->setColorType(GrColorType::kRGBA_8888, { DXGI_FORMAT_R8G8B8A8_UNORM });
691 this->setColorType(GrColorType::kRGBA_8888_SRGB, { DXGI_FORMAT_R8G8B8A8_UNORM_SRGB });
692 this->setColorType(GrColorType::kRGB_888x, { DXGI_FORMAT_R8G8B8A8_UNORM });
693 this->setColorType(GrColorType::kRG_88, { DXGI_FORMAT_R8G8_UNORM });
694 this->setColorType(GrColorType::kBGRA_8888, { DXGI_FORMAT_B8G8R8A8_UNORM });
695 this->setColorType(GrColorType::kRGBA_1010102, { DXGI_FORMAT_R10G10B10A2_UNORM });
696 this->setColorType(GrColorType::kGray_8, { DXGI_FORMAT_R8_UNORM });
697 this->setColorType(GrColorType::kAlpha_F16, { DXGI_FORMAT_R16_FLOAT });
698 this->setColorType(GrColorType::kRGBA_F16, { DXGI_FORMAT_R16G16B16A16_FLOAT });
699 this->setColorType(GrColorType::kRGBA_F16_Clamped, { DXGI_FORMAT_R16G16B16A16_FLOAT });
700 this->setColorType(GrColorType::kAlpha_16, { DXGI_FORMAT_R16_UNORM });
701 this->setColorType(GrColorType::kRG_1616, { DXGI_FORMAT_R16G16_UNORM });
702 this->setColorType(GrColorType::kRGBA_16161616, { DXGI_FORMAT_R16G16B16A16_UNORM });
703 this->setColorType(GrColorType::kRG_F16, { DXGI_FORMAT_R16G16_FLOAT });
704}
705
706void GrD3DCaps::FormatInfo::InitFormatFlags(const D3D12_FEATURE_DATA_FORMAT_SUPPORT& formatSupport,
707 uint16_t* flags) {
708 if (SkToBool(D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE & formatSupport.Support1)) {
709 *flags = *flags | kTexturable_Flag;
710
711 // Ganesh assumes that all renderable surfaces are also texturable
712 if (SkToBool(D3D12_FORMAT_SUPPORT1_RENDER_TARGET & formatSupport.Support1) &&
713 SkToBool(D3D12_FORMAT_SUPPORT1_BLENDABLE & formatSupport.Support1)) {
714 *flags = *flags | kRenderable_Flag;
715 }
716 }
717
718 if (SkToBool(D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RENDERTARGET & formatSupport.Support1)) {
719 *flags = *flags | kMSAA_Flag;
720 }
721
722 if (SkToBool(D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE & formatSupport.Support1)) {
723 *flags = *flags | kResolve_Flag;
724 }
725
726 if (SkToBool(D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW & formatSupport.Support1)) {
727 *flags = *flags | kUnorderedAccess_Flag;
728 }
729}
730
731static bool multisample_count_supported(ID3D12Device* device, DXGI_FORMAT format, int sampleCount) {
732 D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msqLevels;
733 msqLevels.Format = format;
734 msqLevels.SampleCount = sampleCount;
735 msqLevels.Flags = D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE;
736 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
737 &msqLevels, sizeof(msqLevels)));
738
739 return msqLevels.NumQualityLevels > 0;
740}
741
742void GrD3DCaps::FormatInfo::initSampleCounts(const DXGI_ADAPTER_DESC& adapterDesc,
743 ID3D12Device* device, DXGI_FORMAT format) {
745 fColorSampleCounts.push_back(1);
746 }
747 // TODO: test these
748 //if (kImagination_D3DVendor == adapterDesc.VendorId) {
749 // // MSAA does not work on imagination
750 // return;
751 //}
752 //if (kIntel_D3DVendor == adapterDesc.VendorId) {
753 // // MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926
754 // return;
755 //}
757 fColorSampleCounts.push_back(2);
758 }
760 fColorSampleCounts.push_back(4);
761 }
763 fColorSampleCounts.push_back(8);
764 }
766 fColorSampleCounts.push_back(16);
767 }
768 // Standard sample locations are not defined for more than 16 samples, and we don't need more
769 // than 16. Omit 32 and 64.
770}
771
772void GrD3DCaps::FormatInfo::init(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Device* device,
773 DXGI_FORMAT format) {
774 D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupportDesc;
775 formatSupportDesc.Format = format;
776 GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
777 &formatSupportDesc,
778 sizeof(formatSupportDesc)));
779
780 InitFormatFlags(formatSupportDesc, &fFlags);
781 if (fFlags & kRenderable_Flag) {
782 this->initSampleCounts(adapterDesc, device, format);
783 }
784}
785
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}
799
801 DXGI_FORMAT dxgiFormat;
802 if (!format.asDxgiFormat(&dxgiFormat)) {
803 return false;
804 }
805
806 return this->isFormatTexturable(dxgiFormat);
807}
808
809bool GrD3DCaps::isFormatTexturable(DXGI_FORMAT format) const {
810 const FormatInfo& info = this->getFormatInfo(format);
811 return SkToBool(FormatInfo::kTexturable_Flag & info.fFlags);
812}
813
815 int sampleCount) const {
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}
829
830bool GrD3DCaps::isFormatRenderable(const GrBackendFormat& format, int sampleCount) const {
831 DXGI_FORMAT dxgiFormat;
832 if (!format.asDxgiFormat(&dxgiFormat)) {
833 return false;
834 }
835 return this->isFormatRenderable(dxgiFormat, sampleCount);
836}
837
838bool GrD3DCaps::isFormatRenderable(DXGI_FORMAT format, int sampleCount) const {
839 return sampleCount <= this->maxRenderTargetSampleCount(format);
840}
841
843 const FormatInfo& info = this->getFormatInfo(format);
844 return SkToBool(FormatInfo::kUnorderedAccess_Flag & info.fFlags);
845}
846
848 const GrBackendFormat& format) const {
849 DXGI_FORMAT dxgiFormat;
850 if (!format.asDxgiFormat(&dxgiFormat)) {
851 return 0;
852 }
853
854 return this->getRenderTargetSampleCount(requestedCount, dxgiFormat);
855}
856
857int GrD3DCaps::getRenderTargetSampleCount(int requestedCount, DXGI_FORMAT format) const {
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}
880
882 DXGI_FORMAT dxgiFormat;
883 if (!format.asDxgiFormat(&dxgiFormat)) {
884 return 0;
885 }
886 return this->maxRenderTargetSampleCount(dxgiFormat);
887}
888
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}
898
900 const FormatInfo& info = this->getFormatInfo(format);
901 return info.fFormatColorType;
902}
903
905 GrColorType surfaceColorType, const GrBackendFormat& surfaceFormat,
906 GrColorType srcColorType) const {
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}
925
927 const GrSurface* surface) const {
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}
945
947 if (auto rt = surface->asRenderTarget()) {
948 return rt->numSamples() <= 1 && SkToBool(surface->asTexture());
949 }
950 return true;
951}
952
954 const GrBackendFormat& format) const {
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}
968
970 DXGI_FORMAT format = this->getFormatFromColorType(ct);
971 if (format == DXGI_FORMAT_UNKNOWN) {
972 return {};
973 }
974 return GrBackendFormat::MakeDxgi(format);
975}
976
978 SkTextureCompressionType compressionType) const {
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}
991
993 GrColorType colorType) const {
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}
1007
1009 GrColorType colorType) const {
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}
1023
1025 DXGI_FORMAT dxgiFormat;
1026 SkAssertResult(format.asDxgiFormat(&dxgiFormat));
1027
1028 return (uint64_t)dxgiFormat;
1029}
1030
1032 GrColorType srcColorType, const GrBackendFormat& srcBackendFormat,
1033 GrColorType dstColorType) const {
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}
1057
1059 GrSamplerState samplerState,
1060 const GrBackendFormat& format) const {
1061 // TODO
1062}
1063
1064/**
1065 * TODO: Determine what goes in the ProgramDesc
1066 */
1068 const GrProgramInfo& programInfo,
1069 ProgramDescOverrideFlags overrideFlags) const {
1070 SkASSERT(overrideFlags == ProgramDescOverrideFlags::kNone);
1071 GrProgramDesc desc;
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}
1091
1092#if defined(GR_TEST_UTILS)
1093std::vector<GrTest::TestFormatColorTypeCombination> GrD3DCaps::getTestingCombinations() const {
1094 std::vector<GrTest::TestFormatColorTypeCombination> combos = {
1095 {GrColorType::kAlpha_8, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8_UNORM) },
1096 {GrColorType::kBGR_565, GrBackendFormat::MakeDxgi(DXGI_FORMAT_B5G6R5_UNORM) },
1097 {GrColorType::kABGR_4444, GrBackendFormat::MakeDxgi(DXGI_FORMAT_B4G4R4A4_UNORM) },
1098 {GrColorType::kRGBA_8888, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8G8B8A8_UNORM) },
1099 {GrColorType::kRGBA_8888_SRGB, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)},
1100 {GrColorType::kRGB_888x, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8G8B8A8_UNORM) },
1101 {GrColorType::kRG_88, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8G8_UNORM) },
1102 {GrColorType::kBGRA_8888, GrBackendFormat::MakeDxgi(DXGI_FORMAT_B8G8R8A8_UNORM) },
1103 {GrColorType::kRGBA_1010102, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R10G10B10A2_UNORM) },
1104 {GrColorType::kGray_8, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R8_UNORM) },
1105 {GrColorType::kAlpha_F16, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16_FLOAT) },
1106 {GrColorType::kRGBA_F16, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16G16B16A16_FLOAT) },
1107 {GrColorType::kRGBA_F16_Clamped, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16G16B16A16_FLOAT)},
1108 {GrColorType::kAlpha_16, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16_UNORM) },
1109 {GrColorType::kRG_1616, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16G16_UNORM) },
1110 {GrColorType::kRGBA_16161616, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16G16B16A16_UNORM) },
1111 {GrColorType::kRG_F16, GrBackendFormat::MakeDxgi(DXGI_FORMAT_R16G16_FLOAT) },
1112 {GrColorType::kRGBA_8888, GrBackendFormat::MakeDxgi(DXGI_FORMAT_BC1_UNORM) },
1113 };
1114
1115 return combos;
1116}
1117#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
int count
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
bool stencil_format_supported(ID3D12Device *device, DXGI_FORMAT format)
static constexpr DXGI_FORMAT kDxgiFormats[]
static bool multisample_count_supported(ID3D12Device *device, DXGI_FORMAT format, int sampleCount)
bool GrDxgiFormatIsCompressed(DXGI_FORMAT format)
Definition GrD3DUtil.cpp:15
static constexpr size_t GrDxgiFormatBytesPerBlock(DXGI_FORMAT format)
Definition GrD3DUtil.h:101
#define GR_D3D_CALL_ERRCHECK(X)
Definition GrD3DUtil.h:16
static const int kGrColorTypeCnt
GrTextureType
GrColorType
uint16_t fFlags
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
Definition SkAlign.h:33
#define SkAssertResult(cond)
Definition SkAssert.h:123
#define SkUNREACHABLE
Definition SkAssert.h:135
#define SkDEBUGFAILF(fmt,...)
Definition SkAssert.h:119
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
SI F table(const skcms_Curve *curve, F v)
SurfaceReadPixelsSupport
Definition GrCaps.h:296
bool fDynamicStateArrayGeometryProcessorTextureSupport
Definition GrCaps.h:646
int fMaxPreferredRenderTargetSize
Definition GrCaps.h:658
int fMaxVertexAttributes
Definition GrCaps.h:659
bool fFinishedProcAsyncCallbackSupport
Definition GrCaps.h:640
int fMaxRenderTargetSize
Definition GrCaps.h:657
bool fReadPixelsRowBytesSupport
Definition GrCaps.h:621
const GrShaderCaps * shaderCaps() const
Definition GrCaps.h:63
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
int fBufferMapThreshold
Definition GrCaps.h:655
bool fBackendSemaphoreSupport
Definition GrCaps.h:639
bool fHalfFloatVertexAttributeSupport
Definition GrCaps.h:610
bool fSampleLocationsSupport
Definition GrCaps.h:594
bool fGpuTracingSupport
Definition GrCaps.h:591
bool fOversizedStencilSupport
Definition GrCaps.h:592
bool fSemaphoreSupport
Definition GrCaps.h:638
bool fTwoSidedStencilRefsAndMasksMustMatch
Definition GrCaps.h:605
bool fMipmapSupport
Definition GrCaps.h:587
bool fWireframeSupport
Definition GrCaps.h:599
ProgramDescOverrideFlags
Definition GrCaps.h:511
uint32_t fMapBufferFlags
Definition GrCaps.h:654
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
void finishInitialization(const GrContextOptions &options)
Definition GrCaps.cpp:107
@ kCanMap_MapFlag
Definition GrCaps.h:199
@ kSubset_MapFlag
Definition GrCaps.h:201
@ kAsyncRead_MapFlag
Definition GrCaps.h:202
bool fConservativeRasterSupport
Definition GrCaps.h:598
bool fDrawInstancedSupport
Definition GrCaps.h:595
int fMaxTextureSize
Definition GrCaps.h:660
bool fCrossContextTextureSupport
Definition GrCaps.h:643
GrProgramDesc makeDesc(GrRenderTarget *, const GrProgramInfo &, ProgramDescOverrideFlags) const override
skgpu::Swizzle onGetReadSwizzle(const GrBackendFormat &, GrColorType) const override
GrColorType getFormatColorType(DXGI_FORMAT) const
DXGI_FORMAT getFormatFromColorType(GrColorType colorType) const
Definition GrD3DCaps.h:91
bool isFormatSRGB(const GrBackendFormat &) const override
bool canCopyTexture(DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
Definition GrD3DCaps.cpp:72
int maxRenderTargetSampleCount(const GrBackendFormat &) const override
GrD3DCaps(const GrContextOptions &contextOptions, IDXGIAdapter1 *, ID3D12Device *)
Definition GrD3DCaps.cpp:28
uint64_t computeFormatKey(const GrBackendFormat &) const override
bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const override
bool onCanCopySurface(const GrSurfaceProxy *dst, const SkIRect &dstRect, const GrSurfaceProxy *src, const SkIRect &srcRect) const override
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
void addExtraSamplerKey(skgpu::KeyBuilder *, GrSamplerState, const GrBackendFormat &) const override
SupportedRead onSupportedReadPixelsColorType(GrColorType, const GrBackendFormat &, GrColorType) const override
SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const override
bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat &) const override
GrBackendFormat onGetDefaultBackendFormat(GrColorType) const override
bool canCopyAsResolve(DXGI_FORMAT dstFormat, int dstSampleCnt, DXGI_FORMAT srcFormat, int srcSamplecnt) const
Definition GrD3DCaps.cpp:83
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
bool onSurfaceSupportsWritePixels(const GrSurface *) const override
GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const override
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface *) const override
int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const override
bool isFormatUnorderedAccessible(DXGI_FORMAT) const
skgpu::Swizzle getWriteSwizzle(const GrBackendFormat &, GrColorType) const override
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
VkDevice device
Definition main.cc:53
VkSurfaceKHR surface
Definition main.cc:49
static bool b
FlutterSemanticsFlag flags
uint32_t uint32_t * format
bool fDisableDriverCorrectnessWorkarounds
bool fBitManipulationSupport
int fMaxFragmentSamplers
bool fPreferFlatInterpolation
bool fVertexIDSupport
bool fNonconstantArrayIndexSupport
constexpr SkISize size() const
Definition SkRect.h:172
bool fSampleMaskSupport
Definition SkSLUtil.h:98
bool fExplicitTextureLodSupport
Definition SkSLUtil.h:87
bool fDualSourceBlendingSupport
Definition SkSLUtil.h:84
bool fInfinitySupport
Definition SkSLUtil.h:103
bool fShaderDerivativeSupport
Definition SkSLUtil.h:85
bool fFlatInterpolationSupport
Definition SkSLUtil.h:96
bool fIntegerSupport
Definition SkSLUtil.h:89
bool fInverseHyperbolicSupport
Definition SkSLUtil.h:92
const char * fVersionDeclString
Definition SkSLUtil.h:153
bool fNonsquareMatrixSupport
Definition SkSLUtil.h:90
bool fUsesPrecisionModifiers
Definition SkSLUtil.h:95