early-access version 2885

This commit is contained in:
pineappleEA 2022-08-02 04:50:20 +02:00
parent 07efbe6a88
commit d431b7d2f6
6 changed files with 307 additions and 173 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 2884. This is the source code for early-access 2885.
## Legal Notice ## Legal Notice

View file

@ -317,28 +317,40 @@ VkPrimitiveTopology PrimitiveTopology([[maybe_unused]] const Device& device,
} }
} }
VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribute::Size size) { VkFormat VertexFormat(const Device& device, Maxwell::VertexAttribute::Type type,
Maxwell::VertexAttribute::Size size) {
auto format = VK_FORMAT_UNDEFINED;
switch (type) { switch (type) {
case Maxwell::VertexAttribute::Type::UnsignedNorm: case Maxwell::VertexAttribute::Type::UnsignedNorm:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_UNORM; format = VK_FORMAT_R8_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_UNORM; format = VK_FORMAT_R8G8_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_UNORM; format = VK_FORMAT_R8G8B8_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_UNORM; format = VK_FORMAT_R8G8B8A8_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_UNORM; format = VK_FORMAT_R16_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_UNORM; format = VK_FORMAT_R16G16_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_UNORM; format = VK_FORMAT_R16G16B16_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_UNORM; format = VK_FORMAT_R16G16B16A16_UNORM;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_UNORM_PACK32; format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
break;
default: default:
break; break;
} }
@ -346,23 +358,32 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::SignedNorm: case Maxwell::VertexAttribute::Type::SignedNorm:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_SNORM; format = VK_FORMAT_R8_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_SNORM; format = VK_FORMAT_R8G8_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_SNORM; format = VK_FORMAT_R8G8B8_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_SNORM; format = VK_FORMAT_R8G8B8A8_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_SNORM; format = VK_FORMAT_R16_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_SNORM; format = VK_FORMAT_R16G16_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_SNORM; format = VK_FORMAT_R16G16B16_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_SNORM; format = VK_FORMAT_R16G16B16A16_SNORM;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_SNORM_PACK32; format = VK_FORMAT_A2B10G10R10_SNORM_PACK32;
break;
default: default:
break; break;
} }
@ -370,23 +391,32 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::UnsignedScaled: case Maxwell::VertexAttribute::Type::UnsignedScaled:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_USCALED; format = VK_FORMAT_R8_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_USCALED; format = VK_FORMAT_R8G8_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_USCALED; format = VK_FORMAT_R8G8B8_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_USCALED; format = VK_FORMAT_R8G8B8A8_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_USCALED; format = VK_FORMAT_R16_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_USCALED; format = VK_FORMAT_R16G16_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_USCALED; format = VK_FORMAT_R16G16B16_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_USCALED; format = VK_FORMAT_R16G16B16A16_USCALED;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_USCALED_PACK32; format = VK_FORMAT_A2B10G10R10_USCALED_PACK32;
break;
default: default:
break; break;
} }
@ -394,23 +424,32 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::SignedScaled: case Maxwell::VertexAttribute::Type::SignedScaled:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_SSCALED; format = VK_FORMAT_R8_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_SSCALED; format = VK_FORMAT_R8G8_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_SSCALED; format = VK_FORMAT_R8G8B8_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_SSCALED; format = VK_FORMAT_R8G8B8A8_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_SSCALED; format = VK_FORMAT_R16_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_SSCALED; format = VK_FORMAT_R16G16_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_SSCALED; format = VK_FORMAT_R16G16B16_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_SSCALED; format = VK_FORMAT_R16G16B16A16_SSCALED;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_SSCALED_PACK32; format = VK_FORMAT_A2B10G10R10_SSCALED_PACK32;
break;
default: default:
break; break;
} }
@ -418,31 +457,44 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::UnsignedInt: case Maxwell::VertexAttribute::Type::UnsignedInt:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_UINT; format = VK_FORMAT_R8_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_UINT; format = VK_FORMAT_R8G8_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_UINT; format = VK_FORMAT_R8G8B8_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_UINT; format = VK_FORMAT_R8G8B8A8_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_UINT; format = VK_FORMAT_R16_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_UINT; format = VK_FORMAT_R16G16_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_UINT; format = VK_FORMAT_R16G16B16_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_UINT; format = VK_FORMAT_R16G16B16A16_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_32: case Maxwell::VertexAttribute::Size::Size_32:
return VK_FORMAT_R32_UINT; format = VK_FORMAT_R32_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32: case Maxwell::VertexAttribute::Size::Size_32_32:
return VK_FORMAT_R32G32_UINT; format = VK_FORMAT_R32G32_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32:
return VK_FORMAT_R32G32B32_UINT; format = VK_FORMAT_R32G32B32_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32_32:
return VK_FORMAT_R32G32B32A32_UINT; format = VK_FORMAT_R32G32B32A32_UINT;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_UINT_PACK32; format = VK_FORMAT_A2B10G10R10_UINT_PACK32;
break;
default: default:
break; break;
} }
@ -450,31 +502,44 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::SignedInt: case Maxwell::VertexAttribute::Type::SignedInt:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_8: case Maxwell::VertexAttribute::Size::Size_8:
return VK_FORMAT_R8_SINT; format = VK_FORMAT_R8_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8: case Maxwell::VertexAttribute::Size::Size_8_8:
return VK_FORMAT_R8G8_SINT; format = VK_FORMAT_R8G8_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8:
return VK_FORMAT_R8G8B8_SINT; format = VK_FORMAT_R8G8B8_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_8_8_8_8: case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
return VK_FORMAT_R8G8B8A8_SINT; format = VK_FORMAT_R8G8B8A8_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_SINT; format = VK_FORMAT_R16_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_SINT; format = VK_FORMAT_R16G16_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_SINT; format = VK_FORMAT_R16G16B16_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_SINT; format = VK_FORMAT_R16G16B16A16_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_32: case Maxwell::VertexAttribute::Size::Size_32:
return VK_FORMAT_R32_SINT; format = VK_FORMAT_R32_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32: case Maxwell::VertexAttribute::Size::Size_32_32:
return VK_FORMAT_R32G32_SINT; format = VK_FORMAT_R32G32_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32:
return VK_FORMAT_R32G32B32_SINT; format = VK_FORMAT_R32G32B32_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32_32:
return VK_FORMAT_R32G32B32A32_SINT; format = VK_FORMAT_R32G32B32A32_SINT;
break;
case Maxwell::VertexAttribute::Size::Size_10_10_10_2: case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
return VK_FORMAT_A2B10G10R10_SINT_PACK32; format = VK_FORMAT_A2B10G10R10_SINT_PACK32;
break;
default: default:
break; break;
} }
@ -482,30 +547,44 @@ VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttrib
case Maxwell::VertexAttribute::Type::Float: case Maxwell::VertexAttribute::Type::Float:
switch (size) { switch (size) {
case Maxwell::VertexAttribute::Size::Size_16: case Maxwell::VertexAttribute::Size::Size_16:
return VK_FORMAT_R16_SFLOAT; format = VK_FORMAT_R16_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16: case Maxwell::VertexAttribute::Size::Size_16_16:
return VK_FORMAT_R16G16_SFLOAT; format = VK_FORMAT_R16G16_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16:
return VK_FORMAT_R16G16B16_SFLOAT; format = VK_FORMAT_R16G16B16_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_16_16_16_16: case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
return VK_FORMAT_R16G16B16A16_SFLOAT; format = VK_FORMAT_R16G16B16A16_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_32: case Maxwell::VertexAttribute::Size::Size_32:
return VK_FORMAT_R32_SFLOAT; format = VK_FORMAT_R32_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32: case Maxwell::VertexAttribute::Size::Size_32_32:
return VK_FORMAT_R32G32_SFLOAT; format = VK_FORMAT_R32G32_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32:
return VK_FORMAT_R32G32B32_SFLOAT; format = VK_FORMAT_R32G32B32_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_32_32_32_32: case Maxwell::VertexAttribute::Size::Size_32_32_32_32:
return VK_FORMAT_R32G32B32A32_SFLOAT; format = VK_FORMAT_R32G32B32A32_SFLOAT;
break;
case Maxwell::VertexAttribute::Size::Size_11_11_10: case Maxwell::VertexAttribute::Size::Size_11_11_10:
return VK_FORMAT_B10G11R11_UFLOAT_PACK32; format = VK_FORMAT_B10G11R11_UFLOAT_PACK32;
break;
default: default:
break; break;
} }
break; break;
} }
if (format == VK_FORMAT_UNDEFINED) {
UNIMPLEMENTED_MSG("Unimplemented vertex format of type={} and size={}", type, size); UNIMPLEMENTED_MSG("Unimplemented vertex format of type={} and size={}", type, size);
return {}; }
return device.GetSupportedFormat(format, VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT,
FormatType::Buffer);
} }
VkCompareOp ComparisonOp(Maxwell::ComparisonOp comparison) { VkCompareOp ComparisonOp(Maxwell::ComparisonOp comparison) {

View file

@ -48,7 +48,8 @@ VkShaderStageFlagBits ShaderStage(Shader::Stage stage);
VkPrimitiveTopology PrimitiveTopology(const Device& device, Maxwell::PrimitiveTopology topology); VkPrimitiveTopology PrimitiveTopology(const Device& device, Maxwell::PrimitiveTopology topology);
VkFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribute::Size size); VkFormat VertexFormat(const Device& device, Maxwell::VertexAttribute::Type type,
Maxwell::VertexAttribute::Size size);
VkCompareOp ComparisonOp(Maxwell::ComparisonOp comparison); VkCompareOp ComparisonOp(Maxwell::ComparisonOp comparison);

View file

@ -559,7 +559,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
vertex_attributes.push_back({ vertex_attributes.push_back({
.location = static_cast<u32>(index), .location = static_cast<u32>(index),
.binding = attribute.buffer, .binding = attribute.buffer,
.format = MaxwellToVK::VertexFormat(attribute.Type(), attribute.Size()), .format = MaxwellToVK::VertexFormat(device, attribute.Type(), attribute.Size()),
.offset = attribute.offset, .offset = attribute.offset,
}); });
} }

View file

@ -935,7 +935,7 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
.pNext = nullptr, .pNext = nullptr,
.location = static_cast<u32>(index), .location = static_cast<u32>(index),
.binding = binding, .binding = binding,
.format = MaxwellToVK::VertexFormat(attribute.type, attribute.size), .format = MaxwellToVK::VertexFormat(device, attribute.type, attribute.size),
.offset = attribute.offset, .offset = attribute.offset,
}); });
} }

View file

@ -50,6 +50,21 @@ constexpr std::array R4G4_UNORM_PACK8{
VK_FORMAT_UNDEFINED, VK_FORMAT_UNDEFINED,
}; };
constexpr std::array R16G16B16_SFLOAT{
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_UNDEFINED,
};
constexpr std::array R16G16B16_SSCALED{
VK_FORMAT_R16G16B16A16_SSCALED,
VK_FORMAT_UNDEFINED,
};
constexpr std::array R8G8B8_SSCALED{
VK_FORMAT_R8G8B8A8_SSCALED,
VK_FORMAT_UNDEFINED,
};
} // namespace Alternatives } // namespace Alternatives
enum class NvidiaArchitecture { enum class NvidiaArchitecture {
@ -102,6 +117,12 @@ constexpr const VkFormat* GetFormatAlternatives(VkFormat format) {
return Alternatives::B5G6R5_UNORM_PACK16.data(); return Alternatives::B5G6R5_UNORM_PACK16.data();
case VK_FORMAT_R4G4_UNORM_PACK8: case VK_FORMAT_R4G4_UNORM_PACK8:
return Alternatives::R4G4_UNORM_PACK8.data(); return Alternatives::R4G4_UNORM_PACK8.data();
case VK_FORMAT_R16G16B16_SFLOAT:
return Alternatives::R16G16B16_SFLOAT.data();
case VK_FORMAT_R16G16B16_SSCALED:
return Alternatives::R16G16B16_SSCALED.data();
case VK_FORMAT_R8G8B8_SSCALED:
return Alternatives::R8G8B8_SSCALED.data();
default: default:
return nullptr; return nullptr;
} }
@ -122,109 +143,142 @@ VkFormatFeatureFlags GetFormatFeatures(VkFormatProperties properties, FormatType
std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::PhysicalDevice physical) { std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::PhysicalDevice physical) {
static constexpr std::array formats{ static constexpr std::array formats{
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
VK_FORMAT_A8B8G8R8_UINT_PACK32,
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
VK_FORMAT_A8B8G8R8_SINT_PACK32,
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
VK_FORMAT_R5G6B5_UNORM_PACK16,
VK_FORMAT_B5G6R5_UNORM_PACK16,
VK_FORMAT_R5G5B5A1_UNORM_PACK16,
VK_FORMAT_B5G5R5A1_UNORM_PACK16,
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
VK_FORMAT_A2B10G10R10_UINT_PACK32,
VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16,
VK_FORMAT_A2B10G10R10_SINT_PACK32,
VK_FORMAT_A2B10G10R10_SNORM_PACK32,
VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
VK_FORMAT_A2B10G10R10_UINT_PACK32,
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
VK_FORMAT_A2B10G10R10_USCALED_PACK32,
VK_FORMAT_A8B8G8R8_SINT_PACK32,
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
VK_FORMAT_A8B8G8R8_UINT_PACK32,
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
VK_FORMAT_AST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ORMAT_BC5_SNORM_BLOCK,
VK_FORMAT_BC5_UNORM_BLOCK,
VK_FORMAT_BC6H_SFLOAT_BLOCK,
VK_FORMAT_BC6H_UFLOAT_BLOCK,
VK_FORMAT_BC7_SRGB_BLOCK,
VK_FORMAT_BC7_UNORM_BLOCK,
VK_FORMAT_D16_UNORM,
VK_FORMAT_D16_UNORM_S8_UINT,
VK_FORMAT_D24_UNORM_S8_UINT,
VK_FORMAT_D32_SFLOAT,
VK_FORMAT_D32_SFLOAT_S8_UINT,
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_R16G16B16A16_SINT,
VK_FORMAT_R16G16B16A16_SNORM,
VK_FORMAT_R16G16B16A16_SSCALED,
VK_FORMAT_R16G16B16A16_UINT,
VK_FORMAT_R16G16B16A16_UNORM,
VK_FORMAT_R16G16B16A16_USCALED,
VK_FORMAT_R16G16B16_SFLOAT,
VK_FORMAT_R16G16B16_SINT,
VK_FORMAT_R16G16B16_SNORM,
VK_FORMAT_R16G16B16_SSCALED,
VK_FORMAT_R16G16B16_UINT,
VK_FORMAT_R16G16B16_UNORM,
VK_FORMAT_R16G16B16_USCALED,
VK_FORMAT_R16G16_SFLOAT,
VK_FORMAT_R16G16_SINT,
VK_FORMAT_R16G16_SNORM,
VK_FORMAT_R16G16_SSCALED,
VK_FORMAT_R16G16_UINT,
VK_FORMAT_R16G16_UNORM,
VK_FORMAT_R16G16_USCALED,
VK_FORMAT_R16_SFLOAT,
VK_FORMAT_R16_SINT,
VK_FORMAT_R16_SNORM,
VK_FORMAT_R16_SSCALED,
VK_FORMAT_R16_UINT,
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16_USCALED,
VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SINT,
VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_UINT,
VK_FORMAT_R32G32B32_SFLOAT,
VK_FORMAT_R32G32B32_SINT,
VK_FORMAT_R32G32B32_UINT,
VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32_SFLOAT,
VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SINT,
VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_UINT,
VK_FORMAT_R16G16B16A16_SINT,
VK_FORMAT_R16G16B16A16_UINT,
VK_FORMAT_R16G16B16A16_SNORM,
VK_FORMAT_R16G16B16A16_UNORM,
VK_FORMAT_R16G16_UNORM,
VK_FORMAT_R16G16_SNORM,
VK_FORMAT_R16G16_SFLOAT,
VK_FORMAT_R16G16_UINT,
VK_FORMAT_R16G16_SINT,
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16_SNORM,
VK_FORMAT_R16_UINT,
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_R8G8_UNORM,
VK_FORMAT_R8G8_SNORM,
VK_FORMAT_R8G8_SINT,
VK_FORMAT_R8G8_UINT,
VK_FORMAT_R8_UNORM,
VK_FORMAT_R8_SNORM,
VK_FORMAT_R8_SINT,
VK_FORMAT_R8_UINT,
VK_FORMAT_B10G11R11_UFLOAT_PACK32,
VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SFLOAT,
VK_FORMAT_R32_UINT,
VK_FORMAT_R32_SINT, VK_FORMAT_R32_SINT,
VK_FORMAT_R16_SFLOAT, VK_FORMAT_R32_UINT,
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_B8G8R8A8_SRGB,
VK_FORMAT_R4G4_UNORM_PACK8,
VK_FORMAT_R4G4B4A4_UNORM_PACK16, VK_FORMAT_R4G4B4A4_UNORM_PACK16,
VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_R4G4_UNORM_PACK8,
VK_FORMAT_D32_SFLOAT, VK_FORMAT_R5G5B5A1_UNORM_PACK16,
VK_FORMAT_D16_UNORM, VK_FORMAT_R5G6B5_UNORM_PACK16,
VK_FORMAT_R8G8B8A8_SINT,
VK_FORMAT_R8G8B8A8_SNORM,
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_R8G8B8A8_SSCALED,
VK_FORMAT_R8G8B8A8_UINT,
VK_FORMAT_R8G8B8A8_UNORM,
VK_FORMAT_R8G8B8A8_USCALED,
VK_FORMAT_R8G8B8_SINT,
VK_FORMAT_R8G8B8_SNORM,
VK_FORMAT_R8G8B8_SSCALED,
VK_FORMAT_R8G8B8_UINT,
VK_FORMAT_R8G8B8_UNORM,
VK_FORMAT_R8G8B8_USCALED,
VK_FORMAT_R8G8_SINT,
VK_FORMAT_R8G8_SNORM,
VK_FORMAT_R8G8_SSCALED,
VK_FORMAT_R8G8_UINT,
VK_FORMAT_R8G8_UNORM,
VK_FORMAT_R8G8_USCALED,
VK_FORMAT_R8_SINT,
VK_FORMAT_R8_SNORM,
VK_FORMAT_R8_SSCALED,
VK_FORMAT_R8_UINT,
VK_FORMAT_R8_UNORM,
VK_FORMAT_R8_USCALED,
VK_FORMAT_S8_UINT, VK_FORMAT_S8_UINT,
VK_FORMAT_D16_UNORM_S8_UINT,
VK_FORMAT_D24_UNORM_S8_UINT,
VK_FORMAT_D32_SFLOAT_S8_UINT,
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
VK_FORMAT_BC2_UNORM_BLOCK,
VK_FORMAT_BC3_UNORM_BLOCK,
VK_FORMAT_BC4_UNORM_BLOCK,
VK_FORMAT_BC4_SNORM_BLOCK,
VK_FORMAT_BC5_UNORM_BLOCK,
VK_FORMAT_BC5_SNORM_BLOCK,
VK_FORMAT_BC7_UNORM_BLOCK,
VK_FORMAT_BC6H_UFLOAT_BLOCK,
VK_FORMAT_BC6H_SFLOAT_BLOCK,
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
VK_FORMAT_BC2_SRGB_BLOCK,
VK_FORMAT_BC3_SRGB_BLOCK,
VK_FORMAT_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, VkFormatProperties> format_properties; std::unordered_map<VkFormat, VkFormatProperties> format_properties;
for (const auto format : formats) { for (const auto format : formats) {
@ -739,7 +793,7 @@ VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags
if (!IsFormatSupported(alternative, wanted_usage, format_type)) { if (!IsFormatSupported(alternative, wanted_usage, format_type)) {
continue; continue;
} }
LOG_WARNING(Render_Vulkan, LOG_DEBUG(Render_Vulkan,
"Emulating format={} with alternative format={} with usage={} and type={}", "Emulating format={} with alternative format={} with usage={} and type={}",
wanted_format, alternative, wanted_usage, format_type); wanted_format, alternative, wanted_usage, format_type);
return alternative; return alternative;