Add vk_pica translation unit

Intended for conversions and utils between PICA definitions and Vulkan.
This commit is contained in:
Wunkolo 2023-07-27 10:05:43 -07:00
parent d19b8cf364
commit bf8bb5d459
3 changed files with 39 additions and 0 deletions

View file

@ -240,10 +240,12 @@ if(ENABLE_VULKAN)
set(RENDERER_VK_INCLUDE_FILES include/renderer_vk/renderer_vk.hpp
include/renderer_vk/vk_api.hpp include/renderer_vk/vk_debug.hpp include/renderer_vk/vk_memory.hpp
include/renderer_vk/vk_pica.hpp
)
set(RENDERER_VK_SOURCE_FILES src/core/renderer_vk/renderer_vk.cpp
src/core/renderer_vk/vk_api.cpp src/core/renderer_vk/vk_debug.cpp src/core/renderer_vk/vk_memory.cpp
src/core/renderer_vk/vk_pica.cpp
)
set(HEADER_FILES ${HEADER_FILES} ${RENDERER_VK_INCLUDE_FILES})

View file

@ -0,0 +1,12 @@
#pragma once
#include "PICA/gpu.hpp"
#include "helpers.hpp"
#include "vk_api.hpp"
namespace Vulkan {
vk::Format colorFormatToVulkan(PICA::ColorFmt colorFormat);
vk::Format depthFormatToVulkan(PICA::DepthFmt depthFormat);
} // namespace Vulkan

View file

@ -0,0 +1,25 @@
#include "renderer_vk/vk_pica.hpp"
namespace Vulkan {
vk::Format colorFormatToVulkan(PICA::ColorFmt colorFormat) {
switch (colorFormat) {
case PICA::ColorFmt::RGBA8: return vk::Format::eR8G8B8A8Unorm;
case PICA::ColorFmt::RGB8: return vk::Format::eR8G8B8Unorm;
case PICA::ColorFmt::RGBA5551: return vk::Format::eR5G5B5A1UnormPack16;
case PICA::ColorFmt::RGB565: return vk::Format::eR5G6B5UnormPack16;
case PICA::ColorFmt::RGBA4: return vk::Format::eR4G4B4A4UnormPack16;
}
return vk::Format::eUndefined;
}
vk::Format depthFormatToVulkan(PICA::DepthFmt depthFormat) {
switch (depthFormat) {
case PICA::DepthFmt::Depth16: return vk::Format::eD16Unorm;
case PICA::DepthFmt::Unknown1: return vk::Format::eUndefined;
case PICA::DepthFmt::Depth24: return vk::Format::eX8D24UnormPack32;
case PICA::DepthFmt::Depth24Stencil8: return vk::Format::eD24UnormS8Uint;
}
return vk::Format::eUndefined;
}
} // namespace Vulkan