mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-01 14:17:06 +02:00
[vk] Hotfix for DepthBounds and StencilMask.
This commit is contained in:
parent
05b067a18f
commit
9c7be0fafd
3 changed files with 46 additions and 10 deletions
|
|
@ -165,7 +165,7 @@ struct FormatTuple {
|
||||||
{VK_FORMAT_R16G16_SINT, Attachable | Storage}, // R16G16_SINT
|
{VK_FORMAT_R16G16_SINT, Attachable | Storage}, // R16G16_SINT
|
||||||
{VK_FORMAT_R16G16_SNORM, Attachable | Storage}, // R16G16_SNORM
|
{VK_FORMAT_R16G16_SNORM, Attachable | Storage}, // R16G16_SNORM
|
||||||
{VK_FORMAT_R32G32B32_SFLOAT}, // R32G32B32_FLOAT
|
{VK_FORMAT_R32G32B32_SFLOAT}, // R32G32B32_FLOAT
|
||||||
{VK_FORMAT_A8B8G8R8_SRGB_PACK32, Attachable}, // A8B8G8R8_SRGB
|
{VK_FORMAT_A8B8G8R8_SRGB_PACK32, Attachable | Storage}, // A8B8G8R8_SRGB
|
||||||
{VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // R8G8_UNORM
|
{VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // R8G8_UNORM
|
||||||
{VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // R8G8_SNORM
|
{VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // R8G8_SNORM
|
||||||
{VK_FORMAT_R8G8_SINT, Attachable | Storage}, // R8G8_SINT
|
{VK_FORMAT_R8G8_SINT, Attachable | Storage}, // R8G8_SINT
|
||||||
|
|
@ -177,7 +177,7 @@ struct FormatTuple {
|
||||||
{VK_FORMAT_ASTC_8x8_UNORM_BLOCK}, // ASTC_2D_8X8_UNORM
|
{VK_FORMAT_ASTC_8x8_UNORM_BLOCK}, // ASTC_2D_8X8_UNORM
|
||||||
{VK_FORMAT_ASTC_8x5_UNORM_BLOCK}, // ASTC_2D_8X5_UNORM
|
{VK_FORMAT_ASTC_8x5_UNORM_BLOCK}, // ASTC_2D_8X5_UNORM
|
||||||
{VK_FORMAT_ASTC_5x4_UNORM_BLOCK}, // ASTC_2D_5X4_UNORM
|
{VK_FORMAT_ASTC_5x4_UNORM_BLOCK}, // ASTC_2D_5X4_UNORM
|
||||||
{VK_FORMAT_B8G8R8A8_SRGB, Attachable}, // B8G8R8A8_SRGB
|
{VK_FORMAT_B8G8R8A8_SRGB, Attachable | Storage}, // B8G8R8A8_SRGB
|
||||||
{VK_FORMAT_BC1_RGBA_SRGB_BLOCK}, // BC1_RGBA_SRGB
|
{VK_FORMAT_BC1_RGBA_SRGB_BLOCK}, // BC1_RGBA_SRGB
|
||||||
{VK_FORMAT_BC2_SRGB_BLOCK}, // BC2_SRGB
|
{VK_FORMAT_BC2_SRGB_BLOCK}, // BC2_SRGB
|
||||||
{VK_FORMAT_BC3_SRGB_BLOCK}, // BC3_SRGB
|
{VK_FORMAT_BC3_SRGB_BLOCK}, // BC3_SRGB
|
||||||
|
|
|
||||||
|
|
@ -1262,6 +1262,9 @@ void RasterizerVulkan::UpdateBlendConstants(Tegra::Engines::Maxwell3D::Regs& reg
|
||||||
if (!state_tracker.TouchBlendConstants()) {
|
if (!state_tracker.TouchBlendConstants()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!device.UsesAdvancedCoreDynamicState()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const std::array<float, 4> blend_constants{
|
const std::array<float, 4> blend_constants{
|
||||||
regs.blend_color.r,
|
regs.blend_color.r,
|
||||||
regs.blend_color.g,
|
regs.blend_color.g,
|
||||||
|
|
@ -1280,6 +1283,9 @@ void RasterizerVulkan::UpdateDepthBounds(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
if (!device.IsDepthBoundsSupported()) {
|
if (!device.IsDepthBoundsSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!device.UsesAdvancedCoreDynamicState()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const bool unrestricted = device.IsExtDepthRangeUnrestrictedSupported();
|
const bool unrestricted = device.IsExtDepthRangeUnrestrictedSupported();
|
||||||
const float min_depth = unrestricted ? regs.depth_bounds[0]
|
const float min_depth = unrestricted ? regs.depth_bounds[0]
|
||||||
: std::clamp(regs.depth_bounds[0], 0.0f, 1.0f);
|
: std::clamp(regs.depth_bounds[0], 0.0f, 1.0f);
|
||||||
|
|
@ -1307,6 +1313,11 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!device.UsesAdvancedCoreDynamicState()) {
|
||||||
|
state_tracker.ClearStencilReset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (update_references) {
|
if (update_references) {
|
||||||
if (two_sided) {
|
if (two_sided) {
|
||||||
const bool front_dirty =
|
const bool front_dirty =
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,6 @@ constexpr std::array VK_FORMAT_A4B4G4R4_UNORM_PACK16{
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array B10G11R11_UFLOAT_PACK32{
|
constexpr std::array B10G11R11_UFLOAT_PACK32{
|
||||||
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
|
|
||||||
VK_FORMAT_B8G8R8A8_UNORM,
|
|
||||||
VK_FORMAT_R16G16B16A16_SFLOAT,
|
VK_FORMAT_R16G16B16A16_SFLOAT,
|
||||||
VK_FORMAT_R16G16B16A16_UNORM,
|
VK_FORMAT_R16G16B16A16_UNORM,
|
||||||
VK_FORMAT_UNDEFINED,
|
VK_FORMAT_UNDEFINED,
|
||||||
|
|
@ -806,7 +804,7 @@ VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags
|
||||||
if (IsFormatSupported(wanted_format, wanted_usage, format_type)) {
|
if (IsFormatSupported(wanted_format, wanted_usage, format_type)) {
|
||||||
return wanted_format;
|
return wanted_format;
|
||||||
}
|
}
|
||||||
// The wanted format is not supported by hardware, search for alternatives
|
|
||||||
const VkFormat* alternatives = GetFormatAlternatives(wanted_format);
|
const VkFormat* alternatives = GetFormatAlternatives(wanted_format);
|
||||||
if (alternatives == nullptr) {
|
if (alternatives == nullptr) {
|
||||||
LOG_ERROR(Render_Vulkan,
|
LOG_ERROR(Render_Vulkan,
|
||||||
|
|
@ -816,18 +814,45 @@ VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags
|
||||||
return wanted_format;
|
return wanted_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t i = 0;
|
#if defined(ANDROID)
|
||||||
for (VkFormat alternative = *alternatives; alternative; alternative = alternatives[++i]) {
|
const auto downgrade_r16_to_ldr = [&](VkFormat candidate) -> VkFormat {
|
||||||
|
if (wanted_format != VK_FORMAT_B10G11R11_UFLOAT_PACK32) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
if (candidate != VK_FORMAT_R16G16B16A16_SFLOAT &&
|
||||||
|
candidate != VK_FORMAT_R16G16B16A16_UNORM) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
static constexpr std::array ldr_candidates{
|
||||||
|
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
|
||||||
|
VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
VK_FORMAT_B8G8R8A8_SRGB,
|
||||||
|
};
|
||||||
|
for (const VkFormat format : ldr_candidates) {
|
||||||
|
if (IsFormatSupported(format, wanted_usage, format_type)) {
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return candidate;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (std::size_t i = 0; VkFormat alternative = alternatives[i]; ++i) {
|
||||||
if (!IsFormatSupported(alternative, wanted_usage, format_type)) {
|
if (!IsFormatSupported(alternative, wanted_usage, format_type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#if defined(ANDROID)
|
||||||
|
const VkFormat selected = downgrade_r16_to_ldr(alternative);
|
||||||
|
#else
|
||||||
|
const VkFormat selected = alternative;
|
||||||
|
#endif
|
||||||
LOG_DEBUG(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, selected, wanted_usage, format_type);
|
||||||
return alternative;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No alternatives found, panic
|
|
||||||
LOG_ERROR(Render_Vulkan,
|
LOG_ERROR(Render_Vulkan,
|
||||||
"Format={} with usage={} and type={} is not supported by the host hardware and "
|
"Format={} with usage={} and type={} is not supported by the host hardware and "
|
||||||
"doesn't support any of the alternatives",
|
"doesn't support any of the alternatives",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue