-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulkan check for 16bit format support. Fixes running under MoltenVK. #12661
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -565,13 +565,16 @@ VkFormat DataFormatToVulkan(DataFormat format) { | |
case DataFormat::R8G8B8_UNORM: return VK_FORMAT_R8G8B8_UNORM; | ||
case DataFormat::R8G8B8A8_UNORM: return VK_FORMAT_R8G8B8A8_UNORM; | ||
case DataFormat::R4G4_UNORM_PACK8: return VK_FORMAT_R4G4_UNORM_PACK8; | ||
|
||
// Note: A4R4G4B4_UNORM_PACK16 is not supported. | ||
case DataFormat::R4G4B4A4_UNORM_PACK16: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; | ||
case DataFormat::B4G4R4A4_UNORM_PACK16: return VK_FORMAT_B4G4R4A4_UNORM_PACK16; | ||
case DataFormat::R5G5B5A1_UNORM_PACK16: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; | ||
case DataFormat::B5G5R5A1_UNORM_PACK16: return VK_FORMAT_B5G5R5A1_UNORM_PACK16; | ||
case DataFormat::R5G6B5_UNORM_PACK16: return VK_FORMAT_R5G6B5_UNORM_PACK16; | ||
case DataFormat::B5G6R5_UNORM_PACK16: return VK_FORMAT_B5G6R5_UNORM_PACK16; | ||
case DataFormat::A1R5G5B5_UNORM_PACK16: return VK_FORMAT_A1R5G5B5_UNORM_PACK16; | ||
|
||
case DataFormat::R32_FLOAT: return VK_FORMAT_R32_SFLOAT; | ||
case DataFormat::R32G32_FLOAT: return VK_FORMAT_R32G32_SFLOAT; | ||
case DataFormat::R32G32B32_FLOAT: return VK_FORMAT_R32G32B32_SFLOAT; | ||
|
@@ -740,7 +743,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) | |
caps_.framebufferDepthCopySupported = true; // Will pretty much always be the case. | ||
caps_.preferredDepthBufferFormat = DataFormat::D24_S8; // TODO: Ask vulkan. | ||
|
||
auto deviceProps = vulkan->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDevice()).properties; | ||
auto deviceProps = vulkan->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDeviceIndex()).properties; | ||
switch (deviceProps.vendorID) { | ||
case VULKAN_VENDOR_AMD: caps_.vendor = GPUVendor::VENDOR_AMD; break; | ||
case VULKAN_VENDOR_ARM: caps_.vendor = GPUVendor::VENDOR_ARM; break; | ||
|
@@ -1346,41 +1349,25 @@ std::vector<std::string> VKContext::GetExtensionList() const { | |
} | ||
|
||
uint32_t VKContext::GetDataFormatSupport(DataFormat fmt) const { | ||
// TODO: Actually do proper checks | ||
switch (fmt) { | ||
case DataFormat::B8G8R8A8_UNORM: | ||
return FMT_RENDERTARGET | FMT_TEXTURE; | ||
case DataFormat::B4G4R4A4_UNORM_PACK16: | ||
// This is the one that's guaranteed to be supported. | ||
// A four-component, 16-bit packed unsigned normalized format that has a 4-bit B component in bits 12..15, a 4-bit | ||
// G component in bits 8..11, a 4 - bit R component in bits 4..7, and a 4 - bit A component in bits 0..3 | ||
return FMT_RENDERTARGET | FMT_TEXTURE; | ||
case DataFormat::R4G4B4A4_UNORM_PACK16: | ||
return 0; | ||
case DataFormat::A4R4G4B4_UNORM_PACK16: | ||
return 0; | ||
case DataFormat::A1R5G5B5_UNORM_PACK16: | ||
return FMT_RENDERTARGET | FMT_TEXTURE; | ||
|
||
case DataFormat::R8G8B8A8_UNORM: | ||
return FMT_RENDERTARGET | FMT_TEXTURE | FMT_INPUTLAYOUT; | ||
|
||
case DataFormat::R32_FLOAT: | ||
case DataFormat::R32G32_FLOAT: | ||
case DataFormat::R32G32B32_FLOAT: | ||
case DataFormat::R32G32B32A32_FLOAT: | ||
return FMT_INPUTLAYOUT; | ||
VkFormat vulkan_format = DataFormatToVulkan(fmt); | ||
// TODO: Actually do proper check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still a TODO? -[Unknown] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eh, nope. |
||
VkFormatProperties properties; | ||
vkGetPhysicalDeviceFormatProperties(vulkan_->GetCurrentPhysicalDevice(), vulkan_format, &properties); | ||
|
||
case DataFormat::R8_UNORM: | ||
return FMT_TEXTURE; | ||
|
||
case DataFormat::BC1_RGBA_UNORM_BLOCK: | ||
case DataFormat::BC2_UNORM_BLOCK: | ||
case DataFormat::BC3_UNORM_BLOCK: | ||
return FMT_TEXTURE; | ||
default: | ||
return 0; | ||
uint32_t flags = 0; | ||
if (properties.optimalTilingFeatures & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { | ||
flags |= FMT_RENDERTARGET; | ||
} | ||
if (properties.optimalTilingFeatures & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { | ||
flags |= FMT_DEPTHSTENCIL; | ||
} | ||
if (properties.optimalTilingFeatures & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { | ||
flags |= FMT_TEXTURE; | ||
} | ||
if (properties.bufferFeatures & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) { | ||
flags |= FMT_INPUTLAYOUT; | ||
} | ||
return flags; | ||
} | ||
|
||
// A VKFramebuffer is a VkFramebuffer (note caps difference) plus all the textures it owns. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation faux pas?
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about faux pas, but definitely a silly mistake. Being sloppy after burning a lot of energy on the atlas stuff yesterday...