Commit c5b3cbdb by Charlie Lao Committed by Commit Bot

Vulkan: Use VK_FORMAT_D24_UNORM_S8_UINT for 24 bit depth if available

And if the format we picked has extra bits, try to clear it instead of load the value. Don't store these extra bits as values as well. Bug: angleproject:4459 Change-Id: If5d0e31aca1453deab970d0dbcf8886a5e6ed51c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2095850 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent 05710d54
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"src/libANGLE/renderer/gen_load_functions_table.py": "src/libANGLE/renderer/gen_load_functions_table.py":
"9b4ea6bcb4eb4c43f48a097a9ec920f1", "9b4ea6bcb4eb4c43f48a097a9ec920f1",
"src/libANGLE/renderer/load_functions_data.json": "src/libANGLE/renderer/load_functions_data.json":
"ca62fd90cb56197b2d3f78f8e2aba5e0", "7df64a5481f55f3096aff11649d9992d",
"src/libANGLE/renderer/load_functions_table_autogen.cpp": "src/libANGLE/renderer/load_functions_table_autogen.cpp":
"9500f5e87cc7ae604c40168895b41590" "82658e05a1019375501076c4043d6f82"
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py": "src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"d8a0f2278c09a49049a73930b9da3719", "d8a0f2278c09a49049a73930b9da3719",
"src/libANGLE/renderer/vulkan/vk_format_map.json": "src/libANGLE/renderer/vulkan/vk_format_map.json":
"cc593afd850712a04600c9badf1544a6", "893950f630c95c653ec907901939afd8",
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp": "src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"0b818cbddfa88311b853eb1c30eb137d" "4557259cadb45c9db3301039cda3a7bc"
} }
\ No newline at end of file
...@@ -650,6 +650,9 @@ ...@@ -650,6 +650,9 @@
} }
}, },
"GL_DEPTH_COMPONENT24": { "GL_DEPTH_COMPONENT24": {
"D24_UNORM_X8_UINT": {
"GL_UNSIGNED_INT": "LoadR32ToR24G8"
},
"D24_UNORM_S8_UINT": { "D24_UNORM_S8_UINT": {
"GL_UNSIGNED_INT": "LoadR32ToR24G8" "GL_UNSIGNED_INT": "LoadR32ToR24G8"
}, },
......
...@@ -1486,6 +1486,18 @@ LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT(GLenum type) ...@@ -1486,6 +1486,18 @@ LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT(GLenum type)
} }
} }
LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_X8_UINT(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_INT:
return LoadImageFunctionInfo(LoadR32ToR24G8, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT(GLenum type) LoadImageFunctionInfo DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT(GLenum type)
{ {
switch (type) switch (type)
...@@ -3563,6 +3575,8 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat) ...@@ -3563,6 +3575,8 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
{ {
case FormatID::D24_UNORM_S8_UINT: case FormatID::D24_UNORM_S8_UINT:
return DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT; return DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT;
case FormatID::D24_UNORM_X8_UINT:
return DEPTH_COMPONENT24_to_D24_UNORM_X8_UINT;
case FormatID::D32_FLOAT_S8X24_UINT: case FormatID::D32_FLOAT_S8X24_UINT:
return DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT; return DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT;
default: default:
......
...@@ -2233,6 +2233,25 @@ angle::Result ContextVk::clearWithRenderPassOp( ...@@ -2233,6 +2233,25 @@ angle::Result ContextVk::clearWithRenderPassOp(
RenderTargetVk *depthStencilRenderTarget = mDrawFramebuffer->getDepthStencilRenderTarget(); RenderTargetVk *depthStencilRenderTarget = mDrawFramebuffer->getDepthStencilRenderTarget();
if (depthStencilRenderTarget) if (depthStencilRenderTarget)
{ {
const vk::Format &format = depthStencilRenderTarget->getImageFormat();
if (format.hasEmulatedImageChannels())
{
if (format.intendedFormat().stencilBits == 0)
{
// If the format we picked has stencil but user did not ask for
// it due to hardware limitation, force clear the stencil so
// that no load will happen. Also don't try to store stencil
// value as well. Same logic for depth bits bellow.
mRenderPassCommands.invalidateRenderPassStencilAttachment(attachmentIndexVk);
clearStencil = true;
}
if (format.intendedFormat().depthBits == 0)
{
mRenderPassCommands.invalidateRenderPassDepthAttachment(attachmentIndexVk);
clearDepth = true;
}
}
if (clearDepth) if (clearDepth)
{ {
mRenderPassCommands.clearRenderPassDepthAttachment(attachmentIndexVk, mRenderPassCommands.clearRenderPassDepthAttachment(attachmentIndexVk,
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
"D32_FLOAT": "VK_FORMAT_D32_SFLOAT", "D32_FLOAT": "VK_FORMAT_D32_SFLOAT",
"S8_UINT": "VK_FORMAT_S8_UINT", "S8_UINT": "VK_FORMAT_S8_UINT",
"D24_UNORM_S8_UINT": "VK_FORMAT_D24_UNORM_S8_UINT", "D24_UNORM_S8_UINT": "VK_FORMAT_D24_UNORM_S8_UINT",
"D24_UNORM_X8_UINT": "VK_FORMAT_X8_D24_UNORM_PACK32",
"D32_FLOAT_S8X24_UINT": "VK_FORMAT_D32_SFLOAT_S8_UINT", "D32_FLOAT_S8X24_UINT": "VK_FORMAT_D32_SFLOAT_S8_UINT",
"BC1_RGB_UNORM_BLOCK": "VK_FORMAT_BC1_RGB_UNORM_BLOCK", "BC1_RGB_UNORM_BLOCK": "VK_FORMAT_BC1_RGB_UNORM_BLOCK",
"BC1_RGB_UNORM_SRGB_BLOCK": "VK_FORMAT_BC1_RGB_SRGB_BLOCK", "BC1_RGB_UNORM_SRGB_BLOCK": "VK_FORMAT_BC1_RGB_SRGB_BLOCK",
...@@ -209,7 +210,6 @@ ...@@ -209,7 +210,6 @@
"image": "B8G8R8A8_UNORM" "image": "B8G8R8A8_UNORM"
}, },
"D24_UNORM_X8_UINT": { "D24_UNORM_X8_UINT": {
"buffer": "NONE",
"image": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT"] "image": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT"]
}, },
"D32_UNORM": { "D32_UNORM": {
......
...@@ -854,15 +854,16 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat) ...@@ -854,15 +854,16 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat)
internalFormat = GL_DEPTH_COMPONENT24; internalFormat = GL_DEPTH_COMPONENT24;
{ {
static constexpr ImageFormatInitInfo kInfo[] = { static constexpr ImageFormatInitInfo kInfo[] = {
{angle::FormatID::D24_UNORM_X8_UINT, VK_FORMAT_X8_D24_UNORM_PACK32, nullptr},
{angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr}, {angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr},
{angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr}}; {angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr}};
initImageFallback(renderer, kInfo, ArraySize(kInfo)); initImageFallback(renderer, kInfo, ArraySize(kInfo));
} }
actualBufferFormatID = angle::FormatID::NONE; actualBufferFormatID = angle::FormatID::D24_UNORM_X8_UINT;
vkBufferFormat = VK_FORMAT_UNDEFINED; vkBufferFormat = VK_FORMAT_X8_D24_UNORM_PACK32;
vkBufferFormatIsPacked = false; vkBufferFormatIsPacked = true;
vertexLoadFunction = nullptr; vertexLoadFunction = CopyNativeVertexData<GLuint, 1, 1, 0>;
vertexLoadRequiresConversion = true; vertexLoadRequiresConversion = false;
break; break;
case angle::FormatID::D32_FLOAT: case angle::FormatID::D32_FLOAT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment