diff --git a/CMakeLists.txt b/CMakeLists.txt index c49fa564..6d15bbe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/include/renderer_vk/vk_pica.hpp b/include/renderer_vk/vk_pica.hpp new file mode 100644 index 00000000..affd3aa8 --- /dev/null +++ b/include/renderer_vk/vk_pica.hpp @@ -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 \ No newline at end of file diff --git a/src/core/renderer_vk/vk_pica.cpp b/src/core/renderer_vk/vk_pica.cpp new file mode 100644 index 00000000..8e72b51c --- /dev/null +++ b/src/core/renderer_vk/vk_pica.cpp @@ -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 \ No newline at end of file