зеркало из https://github.com/AvaloniaUI/angle.git
Metal: Use Depth32F for DEPTH_COMPONENT16
depth16unorm is broken on Metal. This is a workaround. Bug: angleproject:6597 Change-Id: I1748f9fab587b22980d13e8a141fa880eb6f9db0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3255666 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
This commit is contained in:
Родитель
88ca3b18ab
Коммит
604610b410
|
@ -4,7 +4,7 @@
|
|||
"src/libANGLE/renderer/gen_load_functions_table.py":
|
||||
"c131c494e7e0b35b65a8a097b4b8e5ce",
|
||||
"src/libANGLE/renderer/load_functions_data.json":
|
||||
"131d397629034f557404c68dacf9387d",
|
||||
"31f065e8280e8735d933af01ff0c72bb",
|
||||
"src/libANGLE/renderer/load_functions_table_autogen.cpp":
|
||||
"18822b0045629f386fd5cc2ddb0a28ac"
|
||||
"3590083272e85a45ef80163da81f166b"
|
||||
}
|
|
@ -4,9 +4,9 @@
|
|||
"src/libANGLE/renderer/angle_format_map.json":
|
||||
"947527a1b07dd14da6179eb98d7883c0",
|
||||
"src/libANGLE/renderer/metal/gen_mtl_format_table.py":
|
||||
"4b9bc5e4c59175d30de4a42fd110c3b5",
|
||||
"53a6031892c837248553609f48c4c538",
|
||||
"src/libANGLE/renderer/metal/mtl_format_map.json":
|
||||
"9ece5385adebf0ea86e9d3f3d96e7645",
|
||||
"9199f9f2cf9bd7eb218a2bba3a7c0177",
|
||||
"src/libANGLE/renderer/metal/mtl_format_table_autogen.mm":
|
||||
"ff5572b5db8d8e6206697faf7354aef2"
|
||||
"93c65a26637e7e92b804e90d192863e5"
|
||||
}
|
|
@ -1718,6 +1718,67 @@ void LoadR32ToR24G8(size_t width,
|
|||
}
|
||||
}
|
||||
|
||||
// This conversion was added to support using a 32F depth buffer
|
||||
// as emulation for 16unorm depth buffer in Metal.
|
||||
// See angleproject:6597
|
||||
void LoadUNorm16To32F(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
const uint8_t *input,
|
||||
size_t inputRowPitch,
|
||||
size_t inputDepthPitch,
|
||||
uint8_t *output,
|
||||
size_t outputRowPitch,
|
||||
size_t outputDepthPitch)
|
||||
{
|
||||
for (size_t z = 0; z < depth; z++)
|
||||
{
|
||||
for (size_t y = 0; y < height; y++)
|
||||
{
|
||||
const uint16_t *source =
|
||||
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
|
||||
float *dest =
|
||||
priv::OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
|
||||
for (size_t x = 0; x < width; x++)
|
||||
{
|
||||
dest[x] = static_cast<float>(source[x]) / 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This conversion was added to support using a 32F depth buffer
|
||||
// as emulation for 16unorm depth buffer in Metal. In OpenGL ES 3.0
|
||||
// you're allowed to pass UNSIGNED_INT as input to texImage2D and
|
||||
// so this conversion is neccasary.
|
||||
//
|
||||
// See angleproject:6597
|
||||
void LoadUNorm32To32F(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
const uint8_t *input,
|
||||
size_t inputRowPitch,
|
||||
size_t inputDepthPitch,
|
||||
uint8_t *output,
|
||||
size_t outputRowPitch,
|
||||
size_t outputDepthPitch)
|
||||
{
|
||||
for (size_t z = 0; z < depth; z++)
|
||||
{
|
||||
for (size_t y = 0; y < height; y++)
|
||||
{
|
||||
const uint16_t *source =
|
||||
priv::OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
|
||||
float *dest =
|
||||
priv::OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
|
||||
for (size_t x = 0; x < width; x++)
|
||||
{
|
||||
dest[x] = static_cast<float>(source[x]) / static_cast<float>(0xFFFFFFFFU);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadYuvToNative(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
|
|
|
@ -588,6 +588,26 @@ inline void Load32FTo16F(size_t width,
|
|||
size_t outputRowPitch,
|
||||
size_t outputDepthPitch);
|
||||
|
||||
void LoadUNorm16To32F(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
const uint8_t *input,
|
||||
size_t inputRowPitch,
|
||||
size_t inputDepthPitch,
|
||||
uint8_t *output,
|
||||
size_t outputRowPitch,
|
||||
size_t outputDepthPitch);
|
||||
|
||||
void LoadUNorm32To32F(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
const uint8_t *input,
|
||||
size_t inputRowPitch,
|
||||
size_t inputDepthPitch,
|
||||
uint8_t *output,
|
||||
size_t outputRowPitch,
|
||||
size_t outputDepthPitch);
|
||||
|
||||
void LoadRGB32FToRGBA16F(size_t width,
|
||||
size_t height,
|
||||
size_t depth,
|
||||
|
|
|
@ -256,6 +256,10 @@
|
|||
"D16_UNORM": {
|
||||
"GL_UNSIGNED_INT": "LoadR32ToR16",
|
||||
"GL_UNSIGNED_SHORT": "LoadToNative<GLushort, 1>"
|
||||
},
|
||||
"D32_FLOAT": {
|
||||
"GL_UNSIGNED_SHORT": "LoadUNorm16To32F",
|
||||
"GL_UNSIGNED_INT": "LoadUNorm32To32F"
|
||||
}
|
||||
},
|
||||
"GL_RGB32I": {
|
||||
|
|
|
@ -1486,6 +1486,20 @@ LoadImageFunctionInfo DEPTH_COMPONENT16_to_D16_UNORM(GLenum type)
|
|||
}
|
||||
}
|
||||
|
||||
LoadImageFunctionInfo DEPTH_COMPONENT16_to_D32_FLOAT(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_UNSIGNED_INT:
|
||||
return LoadImageFunctionInfo(LoadUNorm32To32F, true);
|
||||
case GL_UNSIGNED_SHORT:
|
||||
return LoadImageFunctionInfo(LoadUNorm16To32F, true);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
|
||||
}
|
||||
}
|
||||
|
||||
LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -3695,6 +3709,8 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
|
|||
{
|
||||
case FormatID::D16_UNORM:
|
||||
return DEPTH_COMPONENT16_to_D16_UNORM;
|
||||
case FormatID::D32_FLOAT:
|
||||
return DEPTH_COMPONENT16_to_D32_FLOAT;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ def gen_image_map_switch_astc_case(angle_format, angle_to_gl, angle_to_mtl_map):
|
|||
|
||||
def gen_image_map_switch_string(image_table, angle_to_gl):
|
||||
angle_override = image_table["override"]
|
||||
mac_override = image_table["override_mac"]
|
||||
mac_override_es3 = image_table["override_mac_es3"]
|
||||
mac_override_bc1 = image_table["override_mac_bc1"]
|
||||
ios_override = image_table["override_ios"]
|
||||
|
@ -393,6 +394,9 @@ def gen_image_map_switch_string(image_table, angle_to_gl):
|
|||
for angle_format in sorted(mac_specific_map.keys()):
|
||||
switch_data += gen_image_map_switch_mac_case(angle_format, angle_format, angle_to_gl,
|
||||
mac_angle_to_mtl, mac_d24s8_fallbacks)
|
||||
for angle_format in sorted(mac_override.keys()):
|
||||
switch_data += gen_image_map_switch_simple_case(angle_format, mac_override[angle_format],
|
||||
angle_to_gl, mac_angle_to_mtl)
|
||||
for angle_format in sorted(mac_override_bc1.keys()):
|
||||
switch_data += gen_image_map_switch_simple_case(angle_format,
|
||||
mac_override_bc1[angle_format],
|
||||
|
|
|
@ -78,8 +78,7 @@
|
|||
"R10G10B10A2_UINT": "MTLPixelFormatRGB10A2Uint",
|
||||
"R10G10B10A2_UNORM": "MTLPixelFormatRGB10A2Unorm",
|
||||
"R11G11B10_FLOAT": "MTLPixelFormatRG11B10Float",
|
||||
"R9G9B9E5_SHAREDEXP": "MTLPixelFormatRGB9E5Float",
|
||||
"D16_UNORM": "MTLPixelFormatDepth16Unorm"
|
||||
"R9G9B9E5_SHAREDEXP": "MTLPixelFormatRGB9E5Float"
|
||||
},
|
||||
"map_ios": {
|
||||
"R8_UNORM_SRGB": "MTLPixelFormatR8Unorm_sRGB",
|
||||
|
@ -220,6 +219,9 @@
|
|||
"D24_UNORM_X8_UINT": "D32_FLOAT",
|
||||
"D32_UNORM": "D32_FLOAT"
|
||||
},
|
||||
"override_mac": {
|
||||
"D16_UNORM": "D32_FLOAT"
|
||||
},
|
||||
"override_ios": {
|
||||
"D24_UNORM_S8_UINT": "D32_FLOAT_S8X24_UINT",
|
||||
"D16_UNORM": "D32_FLOAT"
|
||||
|
@ -1086,4 +1088,4 @@
|
|||
"R8G8B8_SSCALED": "R8G8B8A8_SINT"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ angle::FormatID Format::MetalToAngleFormatID(MTLPixelFormat formatMtl)
|
|||
return angle::FormatID::B8G8R8A8_UNORM;
|
||||
case MTLPixelFormatBGRA8Unorm_sRGB:
|
||||
return angle::FormatID::B8G8R8A8_UNORM_SRGB;
|
||||
case MTLPixelFormatDepth16Unorm:
|
||||
return angle::FormatID::D16_UNORM;
|
||||
case MTLPixelFormatDepth32Float:
|
||||
return angle::FormatID::D32_FLOAT;
|
||||
case MTLPixelFormatDepth32Float_Stencil8:
|
||||
|
@ -344,15 +342,6 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
|
|||
this->swizzled = false;
|
||||
break;
|
||||
|
||||
case angle::FormatID::D16_UNORM:
|
||||
|
||||
this->metalFormat = MTLPixelFormatDepth16Unorm;
|
||||
this->actualFormatId = angle::FormatID::D16_UNORM;
|
||||
this->initFunction = nullptr;
|
||||
|
||||
this->swizzled = false;
|
||||
break;
|
||||
|
||||
case angle::FormatID::D32_FLOAT:
|
||||
|
||||
this->metalFormat = MTLPixelFormatDepth32Float;
|
||||
|
@ -1117,6 +1106,15 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
|
|||
this->swizzled = false;
|
||||
break;
|
||||
|
||||
case angle::FormatID::D16_UNORM:
|
||||
|
||||
this->metalFormat = MTLPixelFormatDepth32Float;
|
||||
this->actualFormatId = angle::FormatID::D32_FLOAT;
|
||||
this->initFunction = nullptr;
|
||||
|
||||
this->swizzled = false;
|
||||
break;
|
||||
|
||||
case angle::FormatID::BC1_RGB_UNORM_BLOCK:
|
||||
# if defined(__IPHONE_13_0) || defined(__MAC_10_15)
|
||||
if (display->getFeatures().hasTextureSwizzle.enabled)
|
||||
|
|
|
@ -563,8 +563,6 @@
|
|||
5232 MAC METAL AMD : dEQP-GLES3.functional.shaders.builtin_functions.pack_unpack.unpacksnorm2x16_fragment = FAIL
|
||||
5232 MAC METAL AMD : dEQP-GLES3.functional.shaders.builtin_functions.pack_unpack.unpackunorm2x16_fragment = FAIL
|
||||
|
||||
// Metal doesn't support attribute alias yet
|
||||
|
||||
// Texture swizzle is not always available on host machine
|
||||
// Depth sampling requires texture swizzle to correctly return (red, 0, 0, 1) per GLES3 spec
|
||||
5243 MAC METAL : dEQP-GLES3.*texture.specification*depth* = FAIL
|
||||
|
@ -577,9 +575,6 @@
|
|||
6589 MAC METAL AMD : dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_center = FAIL
|
||||
6589 MAC METAL AMD : dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_corner = FAIL
|
||||
|
||||
// Polygon offset bug
|
||||
6467 MAC METAL : dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units = FAIL
|
||||
|
||||
// Texture filtering bug (mostly failing a few pixels)
|
||||
6467 MAC METAL : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.isampler3d_vertex = FAIL
|
||||
6467 MAC METAL : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.usampler3d_vertex = FAIL
|
||||
|
@ -712,6 +707,7 @@
|
|||
|
||||
// Failures introduced after switching to the direct Metal backend
|
||||
|
||||
// Metal doesn't support attribute alias yet
|
||||
6297 MAC METAL : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL
|
||||
6297 MAC METAL : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = FAIL
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче