From 4681381a3413554b861f44a768fca83e8ea74cff Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 11 Nov 2019 18:11:14 -0300 Subject: format_lookup_table: Address feedback format_lookup_table: Drop bitfields format_lookup_table: Use std::array for definition table format_lookup_table: Include instead of --- .../texture_cache/format_lookup_table.cpp | 52 ++++++++++------------ src/video_core/texture_cache/format_lookup_table.h | 2 +- 2 files changed, 24 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index ee050cc31..271e67533 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp @@ -15,34 +15,31 @@ using VideoCore::Surface::PixelFormat; namespace { -static constexpr auto SNORM = ComponentType::SNORM; -static constexpr auto UNORM = ComponentType::UNORM; -static constexpr auto SINT = ComponentType::SINT; -static constexpr auto UINT = ComponentType::UINT; -static constexpr auto SNORM_FORCE_FP16 = ComponentType::SNORM_FORCE_FP16; -static constexpr auto UNORM_FORCE_FP16 = ComponentType::UNORM_FORCE_FP16; -static constexpr auto FLOAT = ComponentType::FLOAT; -static constexpr bool C = false; // Normal color -static constexpr bool S = true; // Srgb +constexpr auto SNORM = ComponentType::SNORM; +constexpr auto UNORM = ComponentType::UNORM; +constexpr auto SINT = ComponentType::SINT; +constexpr auto UINT = ComponentType::UINT; +constexpr auto SNORM_FORCE_FP16 = ComponentType::SNORM_FORCE_FP16; +constexpr auto UNORM_FORCE_FP16 = ComponentType::UNORM_FORCE_FP16; +constexpr auto FLOAT = ComponentType::FLOAT; +constexpr bool C = false; // Normal color +constexpr bool S = true; // Srgb struct Table { constexpr Table(TextureFormat texture_format, bool is_srgb, ComponentType red_component, ComponentType green_component, ComponentType blue_component, ComponentType alpha_component, PixelFormat pixel_format) - : texture_format{static_cast(texture_format)}, - pixel_format{static_cast(pixel_format)}, red_component{static_cast( - red_component)}, - green_component{static_cast(green_component)}, blue_component{static_cast( - blue_component)}, - alpha_component{static_cast(alpha_component)}, is_srgb{is_srgb ? 1U : 0U} {} - - u32 texture_format : 8; - u32 pixel_format : 8; - u32 red_component : 3; - u32 green_component : 3; - u32 blue_component : 3; - u32 alpha_component : 3; - u32 is_srgb : 1; + : texture_format{texture_format}, pixel_format{pixel_format}, red_component{red_component}, + green_component{green_component}, blue_component{blue_component}, + alpha_component{alpha_component}, is_srgb{is_srgb} {} + + TextureFormat texture_format; + PixelFormat pixel_format; + ComponentType red_component; + ComponentType green_component; + ComponentType blue_component; + ComponentType alpha_component; + bool is_srgb; }; constexpr std::array DefinitionTable = {{ {TextureFormat::A8R8G8B8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ABGR8U}, @@ -161,12 +158,9 @@ constexpr std::array DefinitionTable = {{ FormatLookupTable::FormatLookupTable() { table.fill(static_cast(PixelFormat::Invalid)); - for (const auto entry : DefinitionTable) { - table[CalculateIndex(static_cast(entry.texture_format), entry.is_srgb != 0, - static_cast(entry.red_component), - static_cast(entry.green_component), - static_cast(entry.blue_component), - static_cast(entry.alpha_component))] = + for (const auto& entry : DefinitionTable) { + table[CalculateIndex(entry.texture_format, entry.is_srgb != 0, entry.red_component, + entry.green_component, entry.blue_component, entry.alpha_component)] = static_cast(entry.pixel_format); } } diff --git a/src/video_core/texture_cache/format_lookup_table.h b/src/video_core/texture_cache/format_lookup_table.h index 8da7481cd..aa77e0a5a 100644 --- a/src/video_core/texture_cache/format_lookup_table.h +++ b/src/video_core/texture_cache/format_lookup_table.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include "video_core/surface.h" #include "video_core/textures/texture.h" -- cgit v1.2.3