From 658112783d5719b95435170d00e63afb2ce75f28 Mon Sep 17 00:00:00 2001 From: namkazy Date: Sun, 22 Mar 2020 20:29:46 +0700 Subject: [PATCH] reimplement get component type, uncomment mistaken code --- src/video_core/shader/decode/image.cpp | 111 +++++++++++++++++++++---- 1 file changed, 93 insertions(+), 18 deletions(-) diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp index 6bfa71925..34010a162 100644 --- a/src/video_core/shader/decode/image.cpp +++ b/src/video_core/shader/decode/image.cpp @@ -29,22 +29,97 @@ using Tegra::Texture::TICEntry; namespace { ComponentType GetComponentType(TICEntry tic, std::size_t component) { - constexpr u8 R = 0b0001; - constexpr u8 G = 0b0010; - constexpr u8 B = 0b0100; - constexpr u8 A = 0b1000; - if (R & component) { - return tic.r_type; - } - if (G & component) { - return tic.g_type; - } - if (B & component) { - return tic.b_type; - } - if (A & component) { - return tic.a_type; + const TextureFormat format{tic.format}; + switch (format) { + case TextureFormat::R16_G16_B16_A16: + case TextureFormat::R32_G32_B32_A32: + case TextureFormat::R32_G32_B32: + case TextureFormat::R32_G32: + case TextureFormat::R16_G16: + case TextureFormat::R32: + case TextureFormat::R16: + case TextureFormat::R8: + case TextureFormat::R1: + if (0 == component) { + return tic.r_type; + } + if (1 == component) { + return tic.g_type; + } + if (2 == component) { + return tic.b_type; + } + if (3 == component) { + return tic.a_type; + } + break; + case TextureFormat::A8R8G8B8: + if (0 == component) { + return tic.a_type; + } + if (1 == component) { + return tic.r_type; + } + if (2 == component) { + return tic.g_type; + } + if (3 == component) { + return tic.b_type; + } + break; + case TextureFormat::A2B10G10R10: + case TextureFormat::A4B4G4R4: + case TextureFormat::A5B5G5R1: + case TextureFormat::A1B5G5R5: + if (0 == component) { + return tic.a_type; + } + if (1 == component) { + return tic.b_type; + } + if (2 == component) { + return tic.g_type; + } + if (3 == component) { + return tic.r_type; + } + break; + case TextureFormat::R32_B24G8: + if (0 == component) { + return tic.r_type; + } + if (1 == component) { + return tic.b_type; + } + if (2 == component) { + return tic.g_type; + } + break; + case TextureFormat::B5G6R5: + case TextureFormat::B6G5R5: + if (0 == component) { + return tic.b_type; + } + if (1 == component) { + return tic.g_type; + } + if (2 == component) { + return tic.r_type; + } + break; + case TextureFormat::G8R24: + case TextureFormat::G24R8: + case TextureFormat::G8R8: + case TextureFormat::G4R4: + if (0 == component) { + return tic.g_type; + } + if (1 == component) { + return tic.r_type; + } + break; } + UNIMPLEMENTED_MSG("texture format not implement={}", format); return ComponentType::FLOAT; } @@ -298,9 +373,9 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) { shifted_counter += component_size; const auto shifted = 32 - shifted_counter; if (shifted > 0) { - /* converted_value = - SignedOperation(OperationCode::ILogicalShiftLeft, is_signed, - std::move(converted_value), Immediate(shifted));*/ + converted_value = + SignedOperation(OperationCode::ILogicalShiftLeft, is_signed, + std::move(converted_value), Immediate(shifted)); } // add value into result