From c59d5eef45634c08ec1999b8fdb1cc6b6cca3566 Mon Sep 17 00:00:00 2001 From: baggins183 Date: Sun, 2 Mar 2025 19:17:11 -0800 Subject: [PATCH] Specialize vertex attributes on dst_sel (#2580) * Specialize vertex attributes on dst_sel * compare vs attrib specs by default, ignore NumberFmt when vertex input dynamic state is supported * specialize data_format when attribute uses step rates * use num_components in data fmt instead of fmt itself --- src/shader_recompiler/specialization.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/specialization.h b/src/shader_recompiler/specialization.h index 1c3bfc60a..e40309aaf 100644 --- a/src/shader_recompiler/specialization.h +++ b/src/shader_recompiler/specialization.h @@ -13,7 +13,9 @@ namespace Shader { struct VsAttribSpecialization { + s32 num_components{}; AmdGpu::NumberClass num_class{}; + AmdGpu::CompMapping dst_select{}; auto operator<=>(const VsAttribSpecialization&) const = default; }; @@ -89,12 +91,17 @@ struct StageSpecialization { Backend::Bindings start_) : info{&info_}, runtime_info{runtime_info_}, start{start_} { fetch_shader_data = Gcn::ParseFetchShader(info_); - if (info_.stage == Stage::Vertex && fetch_shader_data && - !profile_.support_legacy_vertex_attributes) { + if (info_.stage == Stage::Vertex && fetch_shader_data) { // Specialize shader on VS input number types to follow spec. ForEachSharp(vs_attribs, fetch_shader_data->attributes, - [](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { - spec.num_class = AmdGpu::GetNumberClass(sharp.GetNumberFmt()); + [&profile_](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { + spec.num_components = desc.UsesStepRates() + ? AmdGpu::NumComponents(sharp.GetDataFmt()) + : 0; + spec.num_class = profile_.support_legacy_vertex_attributes + ? AmdGpu::NumberClass{} + : AmdGpu::GetNumberClass(sharp.GetNumberFmt()); + spec.dst_select = sharp.DstSelect(); }); } u32 binding{};