swapchain: fix swapchain image view format not being converted to unorm

This commit is contained in:
Vinicius Rangel 2025-01-15 23:54:42 -03:00
parent 421acfcf4e
commit 6fbcdcf925
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
3 changed files with 12 additions and 12 deletions

View File

@ -106,17 +106,6 @@ static vk::Rect2D FitImage(s32 frame_width, s32 frame_height, s32 swapchain_widt
dst_rect.offset.x, dst_rect.offset.y);
}
static vk::Format FormatToUnorm(vk::Format fmt) {
switch (fmt) {
case vk::Format::eR8G8B8A8Srgb:
return vk::Format::eR8G8B8A8Unorm;
case vk::Format::eB8G8R8A8Srgb:
return vk::Format::eB8G8R8A8Unorm;
default:
UNREACHABLE();
}
}
void Presenter::CreatePostProcessPipeline() {
static const std::array pp_shaders{
HostShaders::FS_TRI_VERT,

View File

@ -262,7 +262,7 @@ void Swapchain::SetupImages() {
auto [im_view_result, im_view] = device.createImageView(vk::ImageViewCreateInfo{
.image = images[i],
.viewType = vk::ImageViewType::e2D,
.format = surface_format.format,
.format = FormatToUnorm(surface_format.format),
.subresourceRange =
{
.aspectMask = vk::ImageAspectFlagBits::eColor,

View File

@ -17,6 +17,17 @@ namespace Vulkan {
class Instance;
class Scheduler;
inline vk::Format FormatToUnorm(vk::Format fmt) {
switch (fmt) {
case vk::Format::eR8G8B8A8Srgb:
return vk::Format::eR8G8B8A8Unorm;
case vk::Format::eB8G8R8A8Srgb:
return vk::Format::eB8G8R8A8Unorm;
default:
UNREACHABLE();
}
}
class Swapchain {
public:
explicit Swapchain(const Instance& instance, const Frontend::WindowSDL& window);