mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-23 15:47:06 +02:00
[vk] Adjusting Custom Border Color
This commit is contained in:
parent
583ab59bbf
commit
0973d90af5
3 changed files with 36 additions and 8 deletions
|
|
@ -2233,18 +2233,26 @@ vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_
|
||||||
|
|
||||||
Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) {
|
Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) {
|
||||||
const auto& device = runtime.device;
|
const auto& device = runtime.device;
|
||||||
const bool arbitrary_borders = runtime.device.IsExtCustomBorderColorSupported();
|
// Check if custom border colors are supported
|
||||||
|
const bool has_custom_border_colors = runtime.device.IsCustomBorderColorsSupported();
|
||||||
|
const bool has_format_undefined = runtime.device.IsCustomBorderColorWithoutFormatSupported();
|
||||||
const auto color = tsc.BorderColor();
|
const auto color = tsc.BorderColor();
|
||||||
|
|
||||||
|
// Determine border format based on available features:
|
||||||
|
// - If customBorderColorWithoutFormat is available: use VK_FORMAT_UNDEFINED (most flexible)
|
||||||
|
// - If only customBorderColors is available: use concrete format (R8G8B8A8_UNORM)
|
||||||
|
// - If neither is available: use standard border colors (handled by ConvertBorderColor)
|
||||||
|
const VkFormat border_format = has_format_undefined ? VK_FORMAT_UNDEFINED
|
||||||
|
: VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
|
||||||
const VkSamplerCustomBorderColorCreateInfoEXT border_ci{
|
const VkSamplerCustomBorderColorCreateInfoEXT border_ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT,
|
.sType = VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
// TODO: Make use of std::bit_cast once libc++ supports it.
|
|
||||||
.customBorderColor = std::bit_cast<VkClearColorValue>(color),
|
.customBorderColor = std::bit_cast<VkClearColorValue>(color),
|
||||||
.format = VK_FORMAT_UNDEFINED,
|
.format = border_format,
|
||||||
};
|
};
|
||||||
const void* pnext = nullptr;
|
const void* pnext = nullptr;
|
||||||
if (arbitrary_borders) {
|
if (has_custom_border_colors) {
|
||||||
pnext = &border_ci;
|
pnext = &border_ci;
|
||||||
}
|
}
|
||||||
const VkSamplerReductionModeCreateInfoEXT reduction_ci{
|
const VkSamplerReductionModeCreateInfoEXT reduction_ci{
|
||||||
|
|
@ -2278,8 +2286,8 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t
|
||||||
.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func),
|
.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func),
|
||||||
.minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(),
|
.minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(),
|
||||||
.maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(),
|
.maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(),
|
||||||
.borderColor =
|
.borderColor = has_custom_border_colors ? VK_BORDER_COLOR_FLOAT_CUSTOM_EXT
|
||||||
arbitrary_borders ? VK_BORDER_COLOR_FLOAT_CUSTOM_EXT : ConvertBorderColor(color),
|
: ConvertBorderColor(color),
|
||||||
.unnormalizedCoordinates = VK_FALSE,
|
.unnormalizedCoordinates = VK_FALSE,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1233,8 +1233,18 @@ bool Device::GetSuitability(bool requires_swapchain) {
|
||||||
|
|
||||||
void Device::RemoveUnsuitableExtensions() {
|
void Device::RemoveUnsuitableExtensions() {
|
||||||
// VK_EXT_custom_border_color
|
// VK_EXT_custom_border_color
|
||||||
extensions.custom_border_color = features.custom_border_color.customBorderColors &&
|
// Enable extension if driver supports it, then check individual features
|
||||||
features.custom_border_color.customBorderColorWithoutFormat;
|
// - customBorderColors: Required to use VK_BORDER_COLOR_FLOAT_CUSTOM_EXT
|
||||||
|
// - customBorderColorWithoutFormat: Optional, allows VK_FORMAT_UNDEFINED
|
||||||
|
// If only customBorderColors is available, we must provide a specific format
|
||||||
|
if (extensions.custom_border_color) {
|
||||||
|
// Verify that at least customBorderColors is available
|
||||||
|
if (!features.custom_border_color.customBorderColors) {
|
||||||
|
LOG_WARNING(Render_Vulkan,
|
||||||
|
"VK_EXT_custom_border_color reported but customBorderColors feature not available, disabling");
|
||||||
|
extensions.custom_border_color = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color,
|
RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color,
|
||||||
VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
|
VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,16 @@ public:
|
||||||
return extensions.custom_border_color;
|
return extensions.custom_border_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if customBorderColors feature is available (required for custom colors).
|
||||||
|
bool IsCustomBorderColorsSupported() const {
|
||||||
|
return features.custom_border_color.customBorderColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns true if customBorderColorWithoutFormat feature is available (allows VK_FORMAT_UNDEFINED).
|
||||||
|
bool IsCustomBorderColorWithoutFormatSupported() const {
|
||||||
|
return features.custom_border_color.customBorderColorWithoutFormat;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_extended_dynamic_state.
|
/// Returns true if the device supports VK_EXT_extended_dynamic_state.
|
||||||
bool IsExtExtendedDynamicStateSupported() const {
|
bool IsExtExtendedDynamicStateSupported() const {
|
||||||
return extensions.extended_dynamic_state;
|
return extensions.extended_dynamic_state;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue