-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: Add vk_format_utils.h to UtilityHeaders
The library originates from Vulkan-ValidationLayers, but is being moved into this repo to make it easier for others to use it. The library has also been modified to be header only and C compatible, which allows more developers to be able to use it. This does require some changes, but only affects the vkuFormatElementSize and vkuFormatTexelSize functions which used default parameters. Two new functions, vkuFormatElementSizeWithAspect and vkuFormatTexelSizeWithAspect have been added to handle the non-default image aspect case (the default was COLOR_BIT). Renaming was done using the following convention: * public header files begin with `vk_` * enums begin with VKU_FORMAT_ * functions begin with vku
- Loading branch information
1 parent
2f464cf
commit c903525
Showing
12 changed files
with
3,660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2023 The Khronos Group Inc. | ||
// Copyright 2023 Valve Corporation | ||
// Copyright 2023 LunarG, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#include <vulkan/utility/vk_format_utils.h> | ||
|
||
bool check_format_utils() { | ||
vkuGetPlaneIndex(VK_IMAGE_ASPECT_PLANE_1_BIT); | ||
vkuFormatHasGreen(VK_FORMAT_R8G8B8A8_UNORM); | ||
vkuFormatElementSizeWithAspect(VK_FORMAT_ASTC_5x4_SRGB_BLOCK, VK_IMAGE_ASPECT_STENCIL_BIT); | ||
struct VKU_FORMAT_INFO f = vkuGetFormatInfo(VK_FORMAT_R8G8B8A8_SRGB); | ||
if (f.component_count != 4) { | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2023 The Khronos Group Inc. | ||
// Copyright 2023 Valve Corporation | ||
// Copyright 2023 LunarG, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#include <vulkan/utility/vk_format_utils.h> | ||
|
||
// Need two translation units to test if header file behaves correctly. | ||
bool check_format_utils_2() { | ||
vkuGetPlaneIndex(VK_IMAGE_ASPECT_PLANE_1_BIT); | ||
vkuFormatHasGreen(VK_FORMAT_R8G8B8A8_UNORM); | ||
vkuFormatElementSizeWithAspect(VK_FORMAT_ASTC_5x4_SRGB_BLOCK, VK_IMAGE_ASPECT_STENCIL_BIT); | ||
struct VKU_FORMAT_INFO f = vkuGetFormatInfo(VK_FORMAT_R8G8B8A8_SRGB); | ||
if (f.component_count != 4) { | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2023 The Khronos Group Inc. | ||
# Copyright 2023 Valve Corporation | ||
# Copyright 2023 LunarG, Inc. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
find_package(GTest REQUIRED CONFIG) | ||
find_package(magic_enum REQUIRED CONFIG) | ||
|
||
include(GoogleTest) | ||
|
||
add_executable(test_format_utils test_formats.cpp) | ||
|
||
target_link_libraries(test_format_utils PRIVATE | ||
GTest::gtest | ||
GTest::gtest_main | ||
magic_enum::magic_enum | ||
Vulkan::UtilityHeaders | ||
) | ||
|
||
if(${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") | ||
add_compile_options(-Wpedantic -Wall -Wextra -Werror) | ||
endif() | ||
|
||
gtest_discover_tests(test_format_utils) |
Oops, something went wrong.