Expand AllowFormatReinterpretationWithoutFlag to consider ETC2/ASTC
Bug: dawn:1176 Change-Id: Iae674fb1c5198ca8767b71e2d5553e0a4a06b475 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117178 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
13d14525c4
commit
785ccde2f5
|
@ -139,6 +139,12 @@ bool RequiresCreatingNewTextureView(const TextureBase* texture,
|
||||||
// rgba8Unorm_srgb texture view on rgab8Unorm texture.
|
// rgba8Unorm_srgb texture view on rgab8Unorm texture.
|
||||||
bool AllowFormatReinterpretationWithoutFlag(MTLPixelFormat origin,
|
bool AllowFormatReinterpretationWithoutFlag(MTLPixelFormat origin,
|
||||||
MTLPixelFormat reinterpretation) {
|
MTLPixelFormat reinterpretation) {
|
||||||
|
#define SRGB_PAIR(a, b) \
|
||||||
|
case a: \
|
||||||
|
return reinterpretation == b; \
|
||||||
|
case b: \
|
||||||
|
return reinterpretation == a
|
||||||
|
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case MTLPixelFormatRGBA8Unorm:
|
case MTLPixelFormatRGBA8Unorm:
|
||||||
return reinterpretation == MTLPixelFormatBGRA8Unorm ||
|
return reinterpretation == MTLPixelFormatBGRA8Unorm ||
|
||||||
|
@ -152,28 +158,44 @@ bool AllowFormatReinterpretationWithoutFlag(MTLPixelFormat origin,
|
||||||
case MTLPixelFormatBGRA8Unorm_sRGB:
|
case MTLPixelFormatBGRA8Unorm_sRGB:
|
||||||
return reinterpretation == MTLPixelFormatRGBA8Unorm_sRGB ||
|
return reinterpretation == MTLPixelFormatRGBA8Unorm_sRGB ||
|
||||||
reinterpretation == MTLPixelFormatBGRA8Unorm;
|
reinterpretation == MTLPixelFormatBGRA8Unorm;
|
||||||
|
|
||||||
#if DAWN_PLATFORM_IS(MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
case MTLPixelFormatBC1_RGBA:
|
SRGB_PAIR(MTLPixelFormatBC1_RGBA, MTLPixelFormatBC1_RGBA_sRGB);
|
||||||
return reinterpretation == MTLPixelFormatBC1_RGBA_sRGB;
|
SRGB_PAIR(MTLPixelFormatBC2_RGBA, MTLPixelFormatBC2_RGBA_sRGB);
|
||||||
case MTLPixelFormatBC1_RGBA_sRGB:
|
SRGB_PAIR(MTLPixelFormatBC3_RGBA, MTLPixelFormatBC3_RGBA_sRGB);
|
||||||
return reinterpretation == MTLPixelFormatBC1_RGBA;
|
SRGB_PAIR(MTLPixelFormatBC7_RGBAUnorm, MTLPixelFormatBC7_RGBAUnorm_sRGB);
|
||||||
case MTLPixelFormatBC2_RGBA:
|
|
||||||
return reinterpretation == MTLPixelFormatBC2_RGBA_sRGB;
|
|
||||||
case MTLPixelFormatBC2_RGBA_sRGB:
|
|
||||||
return reinterpretation == MTLPixelFormatBC2_RGBA;
|
|
||||||
case MTLPixelFormatBC3_RGBA:
|
|
||||||
return reinterpretation == MTLPixelFormatBC3_RGBA_sRGB;
|
|
||||||
case MTLPixelFormatBC3_RGBA_sRGB:
|
|
||||||
return reinterpretation == MTLPixelFormatBC3_RGBA;
|
|
||||||
case MTLPixelFormatBC7_RGBAUnorm:
|
|
||||||
return reinterpretation == MTLPixelFormatBC7_RGBAUnorm_sRGB;
|
|
||||||
case MTLPixelFormatBC7_RGBAUnorm_sRGB:
|
|
||||||
return reinterpretation == MTLPixelFormatBC7_RGBAUnorm;
|
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
if (@available(macOS 11.0, iOS 8.0, *)) {
|
||||||
|
switch (origin) {
|
||||||
|
SRGB_PAIR(MTLPixelFormatEAC_RGBA8, MTLPixelFormatEAC_RGBA8_sRGB);
|
||||||
|
|
||||||
|
SRGB_PAIR(MTLPixelFormatETC2_RGB8, MTLPixelFormatETC2_RGB8_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatETC2_RGB8A1, MTLPixelFormatETC2_RGB8A1_sRGB);
|
||||||
|
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_4x4_LDR, MTLPixelFormatASTC_4x4_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_5x4_LDR, MTLPixelFormatASTC_5x4_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_5x5_LDR, MTLPixelFormatASTC_5x5_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_6x5_LDR, MTLPixelFormatASTC_6x5_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_6x6_LDR, MTLPixelFormatASTC_6x6_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_8x5_LDR, MTLPixelFormatASTC_8x5_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_8x6_LDR, MTLPixelFormatASTC_8x6_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_8x8_LDR, MTLPixelFormatASTC_8x8_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_10x5_LDR, MTLPixelFormatASTC_10x5_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_10x6_LDR, MTLPixelFormatASTC_10x6_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_10x8_LDR, MTLPixelFormatASTC_10x8_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_10x10_LDR, MTLPixelFormatASTC_10x10_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_12x10_LDR, MTLPixelFormatASTC_12x10_sRGB);
|
||||||
|
SRGB_PAIR(MTLPixelFormatASTC_12x12_LDR, MTLPixelFormatASTC_12x12_sRGB);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#undef SRGB_PAIR
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<wgpu::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
|
ResultOrError<wgpu::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
|
||||||
|
|
Loading…
Reference in New Issue