From 7356ab1de6ab7336da426b9176daafb3ebb503f5 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 6 Nov 2022 15:19:08 +0100 Subject: GPU: Implement additional render target formats. --- src/video_core/engines/sw_blitter/converter.cpp | 106 +++++++++++++++++++++++- 1 file changed, 102 insertions(+), 4 deletions(-) (limited to 'src/video_core/engines') diff --git a/src/video_core/engines/sw_blitter/converter.cpp b/src/video_core/engines/sw_blitter/converter.cpp index 408d87944..37c5eff69 100644 --- a/src/video_core/engines/sw_blitter/converter.cpp +++ b/src/video_core/engines/sw_blitter/converter.cpp @@ -133,13 +133,13 @@ constexpr std::array RGB_TO_SRGB_LUT = { } // namespace -struct R32B32G32A32_FLOATTraits { +struct R32G32B32A32_FLOATTraits { static constexpr size_t num_components = 4; static constexpr std::array component_types = { ComponentType::FLOAT, ComponentType::FLOAT, ComponentType::FLOAT, ComponentType::FLOAT}; static constexpr std::array component_sizes = {32, 32, 32, 32}; static constexpr std::array component_swizzle = { - Swizzle::R, Swizzle::B, Swizzle::G, Swizzle::A}; + Swizzle::R, Swizzle::G, Swizzle::B, Swizzle::A}; }; struct R32G32B32A32_SINTTraits { @@ -160,6 +160,33 @@ struct R32G32B32A32_UINTTraits { Swizzle::R, Swizzle::G, Swizzle::B, Swizzle::A}; }; +struct R32G32B32X32_FLOATTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::FLOAT, ComponentType::FLOAT, ComponentType::FLOAT, ComponentType::FLOAT}; + static constexpr std::array component_sizes = {32, 32, 32, 32}; + static constexpr std::array component_swizzle = { + Swizzle::R, Swizzle::G, Swizzle::B, Swizzle::None}; +}; + +struct R32G32B32X32_SINTTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::SINT, ComponentType::SINT, ComponentType::SINT, ComponentType::SINT}; + static constexpr std::array component_sizes = {32, 32, 32, 32}; + static constexpr std::array component_swizzle = { + Swizzle::R, Swizzle::G, Swizzle::B, Swizzle::None}; +}; + +struct R32G32B32X32_UINTTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::UINT, ComponentType::UINT, ComponentType::UINT, ComponentType::UINT}; + static constexpr std::array component_sizes = {32, 32, 32, 32}; + static constexpr std::array component_swizzle = { + Swizzle::R, Swizzle::G, Swizzle::B, Swizzle::None}; +}; + struct R16G16B16A16_UNORMTraits { static constexpr size_t num_components = 4; static constexpr std::array component_types = { @@ -277,6 +304,15 @@ struct A2B10G10R10_UINTTraits { Swizzle::A, Swizzle::B, Swizzle::G, Swizzle::R}; }; +struct A2R10G10B10_UNORMTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM}; + static constexpr std::array component_sizes = {2, 10, 10, 10}; + static constexpr std::array component_swizzle = { + Swizzle::A, Swizzle::R, Swizzle::G, Swizzle::B}; +}; + struct A8B8G8R8_UNORMTraits { static constexpr size_t num_components = 4; static constexpr std::array component_types = { @@ -544,6 +580,33 @@ struct R8_UINTTraits { static constexpr std::array component_swizzle = {Swizzle::R}; }; +struct X1R5G5B5_UNORMTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM}; + static constexpr std::array component_sizes = {1, 5, 5, 5}; + static constexpr std::array component_swizzle = { + Swizzle::None, Swizzle::R, Swizzle::G, Swizzle::B}; +}; + +struct X8B8G8R8_UNORMTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM, ComponentType::UNORM}; + static constexpr std::array component_sizes = {8, 8, 8, 8}; + static constexpr std::array component_swizzle = { + Swizzle::None, Swizzle::B, Swizzle::G, Swizzle::R}; +}; + +struct X8B8G8R8_SRGBTraits { + static constexpr size_t num_components = 4; + static constexpr std::array component_types = { + ComponentType::SRGB, ComponentType::SRGB, ComponentType::SRGB, ComponentType::SRGB}; + static constexpr std::array component_sizes = {8, 8, 8, 8}; + static constexpr std::array component_swizzle = { + Swizzle::None, Swizzle::B, Swizzle::G, Swizzle::R}; +}; + template class ConverterImpl : public Converter { private: @@ -884,9 +947,9 @@ public: Converter* ConverterFactory::BuildConverter(RenderTargetFormat format) { switch (format) { - case RenderTargetFormat::R32B32G32A32_FLOAT: + case RenderTargetFormat::R32G32B32A32_FLOAT: return impl->converters_cache - .emplace(format, std::make_unique>()) + .emplace(format, std::make_unique>()) .first->second.get(); break; case RenderTargetFormat::R32G32B32A32_SINT: @@ -899,6 +962,21 @@ Converter* ConverterFactory::BuildConverter(RenderTargetFormat format) { .emplace(format, std::make_unique>()) .first->second.get(); break; + case RenderTargetFormat::R32G32B32X32_FLOAT: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; + case RenderTargetFormat::R32G32B32X32_SINT: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; + case RenderTargetFormat::R32G32B32X32_UINT: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; case RenderTargetFormat::R16G16B16A16_UNORM: return impl->converters_cache .emplace(format, std::make_unique>()) @@ -964,6 +1042,11 @@ Converter* ConverterFactory::BuildConverter(RenderTargetFormat format) { .emplace(format, std::make_unique>()) .first->second.get(); break; + case RenderTargetFormat::A2R10G10B10_UNORM: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; case RenderTargetFormat::A8B8G8R8_UNORM: return impl->converters_cache .emplace(format, std::make_unique>()) @@ -1119,6 +1202,21 @@ Converter* ConverterFactory::BuildConverter(RenderTargetFormat format) { .emplace(format, std::make_unique>()) .first->second.get(); break; + case RenderTargetFormat::X1R5G5B5_UNORM: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; + case RenderTargetFormat::X8B8G8R8_UNORM: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; + case RenderTargetFormat::X8B8G8R8_SRGB: + return impl->converters_cache + .emplace(format, std::make_unique>()) + .first->second.get(); + break; default: { UNIMPLEMENTED_MSG("This format {} converter is not implemented", format); return impl->converters_cache.emplace(format, std::make_unique()) -- cgit v1.2.3