runtime_info: Pack PsColorBuffer into 8 bytes

* Drops the size of the total structure by half from 396 to 204 bytes. Also should make comparison of the array a bit faster, since its a hot path done every draw
This commit is contained in:
IndecisiveTurtle 2025-02-13 22:03:53 +02:00
parent dd8fb9dd4b
commit 1a6d0c8d0a
4 changed files with 21 additions and 21 deletions

View File

@ -283,14 +283,3 @@ constexpr AmdGpu::Image FMaskResource::GetSharp(const Info& info) const noexcept
} }
} // namespace Shader } // namespace Shader
template <>
struct fmt::formatter<Shader::Stage> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
auto format(const Shader::Stage stage, format_context& ctx) const {
constexpr static std::array names = {"fs", "vs", "gs", "es", "hs", "ls", "cs"};
return fmt::format_to(ctx.out(), "{}", names[static_cast<size_t>(stage)]);
}
};

View File

@ -185,11 +185,11 @@ struct FragmentRuntimeInfo {
u32 num_inputs; u32 num_inputs;
std::array<PsInput, 32> inputs; std::array<PsInput, 32> inputs;
struct PsColorBuffer { struct PsColorBuffer {
AmdGpu::NumberFormat num_format; AmdGpu::NumberFormat num_format : 4;
AmdGpu::NumberConversion num_conversion; AmdGpu::NumberConversion num_conversion : 2;
AmdGpu::Liverpool::ShaderExportFormat export_format : 4;
u32 needs_unorm_fixup : 1;
AmdGpu::CompMapping swizzle; AmdGpu::CompMapping swizzle;
AmdGpu::Liverpool::ShaderExportFormat export_format;
bool needs_unorm_fixup;
auto operator<=>(const PsColorBuffer&) const noexcept = default; auto operator<=>(const PsColorBuffer&) const noexcept = default;
}; };
@ -264,3 +264,14 @@ struct RuntimeInfo {
}; };
} // namespace Shader } // namespace Shader
template <>
struct fmt::formatter<Shader::Stage> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
auto format(const Shader::Stage stage, format_context& ctx) const {
constexpr static std::array names = {"fs", "vs", "gs", "es", "hs", "ls", "cs"};
return fmt::format_to(ctx.out(), "{}", names[static_cast<size_t>(stage)]);
}
};

View File

@ -183,7 +183,7 @@ enum class NumberFormat : u32 {
Ubscaled = 13, Ubscaled = 13,
}; };
enum class CompSwizzle : u32 { enum class CompSwizzle : u8 {
Zero = 0, Zero = 0,
One = 1, One = 1,
Red = 4, Red = 4,
@ -193,10 +193,10 @@ enum class CompSwizzle : u32 {
}; };
enum class NumberConversion : u32 { enum class NumberConversion : u32 {
None, None = 0,
UintToUscaled, UintToUscaled = 1,
SintToSscaled, SintToSscaled = 2,
UnormToUbnorm, UnormToUbnorm = 3,
}; };
struct CompMapping { struct CompMapping {

View File

@ -348,9 +348,9 @@ bool PipelineCache::RefreshGraphicsKey() {
key.color_buffers[remapped_cb] = { key.color_buffers[remapped_cb] = {
.num_format = col_buf.GetNumberFmt(), .num_format = col_buf.GetNumberFmt(),
.num_conversion = col_buf.GetNumberConversion(), .num_conversion = col_buf.GetNumberConversion(),
.swizzle = col_buf.Swizzle(),
.export_format = regs.color_export_format.GetFormat(cb), .export_format = regs.color_export_format.GetFormat(cb),
.needs_unorm_fixup = needs_unorm_fixup, .needs_unorm_fixup = needs_unorm_fixup,
.swizzle = col_buf.Swizzle(),
}; };
} }