mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
format_lookup_table: Address feedback
format_lookup_table: Drop bitfields format_lookup_table: Use std::array for definition table format_lookup_table: Include <limits> instead of <numeric>
This commit is contained in:
parent
80eacdf89b
commit
4681381a34
2 changed files with 23 additions and 29 deletions
|
@ -15,34 +15,31 @@ using VideoCore::Surface::PixelFormat;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static constexpr auto SNORM = ComponentType::SNORM;
|
constexpr auto SNORM = ComponentType::SNORM;
|
||||||
static constexpr auto UNORM = ComponentType::UNORM;
|
constexpr auto UNORM = ComponentType::UNORM;
|
||||||
static constexpr auto SINT = ComponentType::SINT;
|
constexpr auto SINT = ComponentType::SINT;
|
||||||
static constexpr auto UINT = ComponentType::UINT;
|
constexpr auto UINT = ComponentType::UINT;
|
||||||
static constexpr auto SNORM_FORCE_FP16 = ComponentType::SNORM_FORCE_FP16;
|
constexpr auto SNORM_FORCE_FP16 = ComponentType::SNORM_FORCE_FP16;
|
||||||
static constexpr auto UNORM_FORCE_FP16 = ComponentType::UNORM_FORCE_FP16;
|
constexpr auto UNORM_FORCE_FP16 = ComponentType::UNORM_FORCE_FP16;
|
||||||
static constexpr auto FLOAT = ComponentType::FLOAT;
|
constexpr auto FLOAT = ComponentType::FLOAT;
|
||||||
static constexpr bool C = false; // Normal color
|
constexpr bool C = false; // Normal color
|
||||||
static constexpr bool S = true; // Srgb
|
constexpr bool S = true; // Srgb
|
||||||
|
|
||||||
struct Table {
|
struct Table {
|
||||||
constexpr Table(TextureFormat texture_format, bool is_srgb, ComponentType red_component,
|
constexpr Table(TextureFormat texture_format, bool is_srgb, ComponentType red_component,
|
||||||
ComponentType green_component, ComponentType blue_component,
|
ComponentType green_component, ComponentType blue_component,
|
||||||
ComponentType alpha_component, PixelFormat pixel_format)
|
ComponentType alpha_component, PixelFormat pixel_format)
|
||||||
: texture_format{static_cast<u32>(texture_format)},
|
: texture_format{texture_format}, pixel_format{pixel_format}, red_component{red_component},
|
||||||
pixel_format{static_cast<u32>(pixel_format)}, red_component{static_cast<u32>(
|
green_component{green_component}, blue_component{blue_component},
|
||||||
red_component)},
|
alpha_component{alpha_component}, is_srgb{is_srgb} {}
|
||||||
green_component{static_cast<u32>(green_component)}, blue_component{static_cast<u32>(
|
|
||||||
blue_component)},
|
|
||||||
alpha_component{static_cast<u32>(alpha_component)}, is_srgb{is_srgb ? 1U : 0U} {}
|
|
||||||
|
|
||||||
u32 texture_format : 8;
|
TextureFormat texture_format;
|
||||||
u32 pixel_format : 8;
|
PixelFormat pixel_format;
|
||||||
u32 red_component : 3;
|
ComponentType red_component;
|
||||||
u32 green_component : 3;
|
ComponentType green_component;
|
||||||
u32 blue_component : 3;
|
ComponentType blue_component;
|
||||||
u32 alpha_component : 3;
|
ComponentType alpha_component;
|
||||||
u32 is_srgb : 1;
|
bool is_srgb;
|
||||||
};
|
};
|
||||||
constexpr std::array<Table, 74> DefinitionTable = {{
|
constexpr std::array<Table, 74> DefinitionTable = {{
|
||||||
{TextureFormat::A8R8G8B8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ABGR8U},
|
{TextureFormat::A8R8G8B8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ABGR8U},
|
||||||
|
@ -161,12 +158,9 @@ constexpr std::array<Table, 74> DefinitionTable = {{
|
||||||
FormatLookupTable::FormatLookupTable() {
|
FormatLookupTable::FormatLookupTable() {
|
||||||
table.fill(static_cast<u8>(PixelFormat::Invalid));
|
table.fill(static_cast<u8>(PixelFormat::Invalid));
|
||||||
|
|
||||||
for (const auto entry : DefinitionTable) {
|
for (const auto& entry : DefinitionTable) {
|
||||||
table[CalculateIndex(static_cast<TextureFormat>(entry.texture_format), entry.is_srgb != 0,
|
table[CalculateIndex(entry.texture_format, entry.is_srgb != 0, entry.red_component,
|
||||||
static_cast<ComponentType>(entry.red_component),
|
entry.green_component, entry.blue_component, entry.alpha_component)] =
|
||||||
static_cast<ComponentType>(entry.green_component),
|
|
||||||
static_cast<ComponentType>(entry.blue_component),
|
|
||||||
static_cast<ComponentType>(entry.alpha_component))] =
|
|
||||||
static_cast<u8>(entry.pixel_format);
|
static_cast<u8>(entry.pixel_format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <numeric>
|
#include <limits>
|
||||||
#include "video_core/surface.h"
|
#include "video_core/surface.h"
|
||||||
#include "video_core/textures/texture.h"
|
#include "video_core/textures/texture.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue