Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c5b3cbd

Browse files
cclaoCommit Bot
authored and
Commit Bot
committed
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 <[email protected]> Reviewed-by: Tobin Ehlis <[email protected]>
1 parent 05710d5 commit c5b3cbd

File tree

7 files changed

+47
-10
lines changed

7 files changed

+47
-10
lines changed

scripts/code_generation_hashes/ANGLE_load_functions_table.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"src/libANGLE/renderer/gen_load_functions_table.py":
55
"9b4ea6bcb4eb4c43f48a097a9ec920f1",
66
"src/libANGLE/renderer/load_functions_data.json":
7-
"ca62fd90cb56197b2d3f78f8e2aba5e0",
7+
"7df64a5481f55f3096aff11649d9992d",
88
"src/libANGLE/renderer/load_functions_table_autogen.cpp":
9-
"9500f5e87cc7ae604c40168895b41590"
9+
"82658e05a1019375501076c4043d6f82"
1010
}

scripts/code_generation_hashes/Vulkan_format.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
77
"d8a0f2278c09a49049a73930b9da3719",
88
"src/libANGLE/renderer/vulkan/vk_format_map.json":
9-
"cc593afd850712a04600c9badf1544a6",
9+
"893950f630c95c653ec907901939afd8",
1010
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
11-
"0b818cbddfa88311b853eb1c30eb137d"
11+
"4557259cadb45c9db3301039cda3a7bc"
1212
}

src/libANGLE/renderer/load_functions_data.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@
650650
}
651651
},
652652
"GL_DEPTH_COMPONENT24": {
653+
"D24_UNORM_X8_UINT": {
654+
"GL_UNSIGNED_INT": "LoadR32ToR24G8"
655+
},
653656
"D24_UNORM_S8_UINT": {
654657
"GL_UNSIGNED_INT": "LoadR32ToR24G8"
655658
},

src/libANGLE/renderer/load_functions_table_autogen.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,18 @@ LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT(GLenum type)
14861486
}
14871487
}
14881488

1489+
LoadImageFunctionInfo DEPTH_COMPONENT24_to_D24_UNORM_X8_UINT(GLenum type)
1490+
{
1491+
switch (type)
1492+
{
1493+
case GL_UNSIGNED_INT:
1494+
return LoadImageFunctionInfo(LoadR32ToR24G8, true);
1495+
default:
1496+
UNREACHABLE();
1497+
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
1498+
}
1499+
}
1500+
14891501
LoadImageFunctionInfo DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT(GLenum type)
14901502
{
14911503
switch (type)
@@ -3563,6 +3575,8 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
35633575
{
35643576
case FormatID::D24_UNORM_S8_UINT:
35653577
return DEPTH_COMPONENT24_to_D24_UNORM_S8_UINT;
3578+
case FormatID::D24_UNORM_X8_UINT:
3579+
return DEPTH_COMPONENT24_to_D24_UNORM_X8_UINT;
35663580
case FormatID::D32_FLOAT_S8X24_UINT:
35673581
return DEPTH_COMPONENT24_to_D32_FLOAT_S8X24_UINT;
35683582
default:

src/libANGLE/renderer/vulkan/ContextVk.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,25 @@ angle::Result ContextVk::clearWithRenderPassOp(
22332233
RenderTargetVk *depthStencilRenderTarget = mDrawFramebuffer->getDepthStencilRenderTarget();
22342234
if (depthStencilRenderTarget)
22352235
{
2236+
const vk::Format &format = depthStencilRenderTarget->getImageFormat();
2237+
if (format.hasEmulatedImageChannels())
2238+
{
2239+
if (format.intendedFormat().stencilBits == 0)
2240+
{
2241+
// If the format we picked has stencil but user did not ask for
2242+
// it due to hardware limitation, force clear the stencil so
2243+
// that no load will happen. Also don't try to store stencil
2244+
// value as well. Same logic for depth bits bellow.
2245+
mRenderPassCommands.invalidateRenderPassStencilAttachment(attachmentIndexVk);
2246+
clearStencil = true;
2247+
}
2248+
if (format.intendedFormat().depthBits == 0)
2249+
{
2250+
mRenderPassCommands.invalidateRenderPassDepthAttachment(attachmentIndexVk);
2251+
clearDepth = true;
2252+
}
2253+
}
2254+
22362255
if (clearDepth)
22372256
{
22382257
mRenderPassCommands.clearRenderPassDepthAttachment(attachmentIndexVk,

src/libANGLE/renderer/vulkan/vk_format_map.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"D32_FLOAT": "VK_FORMAT_D32_SFLOAT",
108108
"S8_UINT": "VK_FORMAT_S8_UINT",
109109
"D24_UNORM_S8_UINT": "VK_FORMAT_D24_UNORM_S8_UINT",
110+
"D24_UNORM_X8_UINT": "VK_FORMAT_X8_D24_UNORM_PACK32",
110111
"D32_FLOAT_S8X24_UINT": "VK_FORMAT_D32_SFLOAT_S8_UINT",
111112
"BC1_RGB_UNORM_BLOCK": "VK_FORMAT_BC1_RGB_UNORM_BLOCK",
112113
"BC1_RGB_UNORM_SRGB_BLOCK": "VK_FORMAT_BC1_RGB_SRGB_BLOCK",
@@ -209,7 +210,6 @@
209210
"image": "B8G8R8A8_UNORM"
210211
},
211212
"D24_UNORM_X8_UINT": {
212-
"buffer": "NONE",
213213
"image": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT"]
214214
},
215215
"D32_UNORM": {

src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -854,15 +854,16 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat)
854854
internalFormat = GL_DEPTH_COMPONENT24;
855855
{
856856
static constexpr ImageFormatInitInfo kInfo[] = {
857+
{angle::FormatID::D24_UNORM_X8_UINT, VK_FORMAT_X8_D24_UNORM_PACK32, nullptr},
857858
{angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr},
858859
{angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr}};
859860
initImageFallback(renderer, kInfo, ArraySize(kInfo));
860861
}
861-
actualBufferFormatID = angle::FormatID::NONE;
862-
vkBufferFormat = VK_FORMAT_UNDEFINED;
863-
vkBufferFormatIsPacked = false;
864-
vertexLoadFunction = nullptr;
865-
vertexLoadRequiresConversion = true;
862+
actualBufferFormatID = angle::FormatID::D24_UNORM_X8_UINT;
863+
vkBufferFormat = VK_FORMAT_X8_D24_UNORM_PACK32;
864+
vkBufferFormatIsPacked = true;
865+
vertexLoadFunction = CopyNativeVertexData<GLuint, 1, 1, 0>;
866+
vertexLoadRequiresConversion = false;
866867
break;
867868

868869
case angle::FormatID::D32_FLOAT:

0 commit comments

Comments
 (0)