float clear values (num_bits=16)

This commit is contained in:
Lander Gallastegi 2024-10-13 21:30:51 +02:00
parent bd9f82df94
commit bac1488ff4
3 changed files with 31 additions and 9 deletions

View File

@ -771,7 +771,7 @@ endif()
create_target_directory_groups(shadps4) create_target_directory_groups(shadps4)
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half)
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3 pugixml::pugixml) target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3 pugixml::pugixml)
target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h") target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
@ -794,9 +794,6 @@ if (APPLE)
# Replacement for std::chrono::time_zone # Replacement for std::chrono::time_zone
target_link_libraries(shadps4 PRIVATE date::date-tz) target_link_libraries(shadps4 PRIVATE date::date-tz)
# Half float conversions for F16C patches
target_link_libraries(shadps4 PRIVATE half)
endif() endif()
if (NOT ENABLE_QT_GUI) if (NOT ENABLE_QT_GUI)

View File

@ -141,11 +141,11 @@ if (WIN32)
target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument") target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument")
endif() endif()
if (APPLE) # half
# half add_library(half INTERFACE)
add_library(half INTERFACE) target_include_directories(half INTERFACE half/include)
target_include_directories(half INTERFACE half/include)
if (APPLE)
# date # date
if (NOT TARGET date::date-tz) if (NOT TARGET date::date-tz)
option(BUILD_TZ_LIB "" ON) option(BUILD_TZ_LIB "" ON)

View File

@ -5,10 +5,13 @@
#include "video_core/amdgpu/pixel_format.h" #include "video_core/amdgpu/pixel_format.h"
#include "video_core/renderer_vulkan/liverpool_to_vk.h" #include "video_core/renderer_vulkan/liverpool_to_vk.h"
#include <half.hpp>
#include <magic_enum.hpp> #include <magic_enum.hpp>
namespace Vulkan::LiverpoolToVK { namespace Vulkan::LiverpoolToVK {
using half_float::half;
using half_float::half_cast;
using DepthBuffer = Liverpool::DepthBuffer; using DepthBuffer = Liverpool::DepthBuffer;
vk::StencilOp StencilOp(Liverpool::StencilFunc op) { vk::StencilOp StencilOp(Liverpool::StencilFunc op) {
@ -730,6 +733,10 @@ static constexpr float U8ToUnorm(u8 v) {
return float(v * c); return float(v * c);
} }
static float F16BitsToFloat(u16 v) {
return half_cast<float>(*(reinterpret_cast<half*>(&v)));
}
vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color_buffer) { vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color_buffer) {
const auto comp_swap = color_buffer.info.comp_swap.Value(); const auto comp_swap = color_buffer.info.comp_swap.Value();
ASSERT_MSG(comp_swap == Liverpool::ColorBuffer::SwapMode::Standard || ASSERT_MSG(comp_swap == Liverpool::ColorBuffer::SwapMode::Standard ||
@ -762,7 +769,25 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color
break; break;
} }
default: { default: {
LOG_ERROR(Render_Vulkan, "Missing clear color conversion for bits {}", num_bits); LOG_ERROR(Render_Vulkan, "Missing clear color conversion for uint and bits {}", num_bits);
break;
}
}
break;
}
case AmdGpu::NumberFormat::Float: {
switch (num_bits) {
case 64: {
color.float32 = std::array{
F16BitsToFloat((comp_swap_alt ? c1 : c0) & 0xffff),
F16BitsToFloat((c0 >> 16) & 0xffff),
F16BitsToFloat((comp_swap_alt ? c0 : c1) & 0xffff),
F16BitsToFloat((c1 >> 16) & 0xffff),
};
break;
}
default: {
LOG_ERROR(Render_Vulkan, "Missing clear color conversion for float and bits {}", num_bits);
break; break;
} }
} }