Commit d6d59936 by Antonio Maiorano

Don't fail build if Vulkan headers are different

If a project that uses SwiftShader already imports the Vulkan::Headers target, and these are different from the version in SwiftShader, we fail to build because we have a static_assert to match the exact version. Replace compile-time assert with a runtime assert to make sure our code still works with different versions of the headers. This fixes Amber building against SwiftShader. Bug: b/154215163 Change-Id: I39e32370b51c702ab6d0a9790d06c31537f27472 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43973Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 31038eae
......@@ -2601,7 +2601,6 @@ static constexpr uint8_t pack(VkFormat format)
return 0;
}
static_assert(VK_HEADER_VERSION == 128, "Update VkFormat to uint8_t mapping if needed");
static_assert(pack(VK_FORMAT_UNDEFINED) == 0, "Incorrect VkFormat packed value");
static_assert(pack(VK_FORMAT_ASTC_12x12_SRGB_BLOCK) == 184, "Incorrect VkFormat packed value");
static_assert(pack(VK_FORMAT_G8B8G8R8_422_UNORM) == 185, "Incorrect VkFormat packed value");
......@@ -2614,8 +2613,9 @@ static_assert(pack(VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT) == 240, "Incorrect VkF
uint8_t Format::mapTo8bit(VkFormat format)
{
ASSERT(format <= VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM);
return pack(format);
uint8_t packed = pack(format);
ASSERT_MSG(packed > 0, "Update VkFormat to uint8_t mapping");
return packed;
}
} // namespace vk
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