From e8f0fd8a69014d355c5ac4e069befa25ad652c14 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 25 Jan 2026 02:28:34 +0000 Subject: [PATCH] test1 --- .../spirv/emit_spirv_context_get_set.cpp | 4 +- .../backend/spirv/spirv_emit_context.cpp | 20 +------- .../backend/spirv/spirv_emit_context.h | 2 - src/shader_recompiler/runtime_info.h | 2 - .../renderer_vulkan/fixed_pipeline_state.cpp | 20 ++------ .../renderer_vulkan/fixed_pipeline_state.h | 4 +- .../renderer_vulkan/vk_pipeline_cache.cpp | 46 ++++++------------- 7 files changed, 25 insertions(+), 73 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index db11def7b2..36ddeffb16 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -327,9 +327,9 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { return ctx.OpConvertSToF(ctx.F32[1], value); case InputGenericLoadOp::UToF: return ctx.OpConvertUToF(ctx.F32[1], value); - default: + case InputGenericLoadOp::None: return value; - }; + } }(); } switch (attr) { diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index a89344b0f3..9337e294fc 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -200,10 +200,8 @@ Id GetAttributeType(EmitContext& ctx, AttributeType type) { case AttributeType::Float: return ctx.F32[4]; case AttributeType::SignedInt: - case AttributeType::SignedNorm: return ctx.TypeVector(ctx.TypeInt(32, true), 4); case AttributeType::UnsignedInt: - case AttributeType::UnsignedNorm: return ctx.U32[4]; case AttributeType::SignedScaled: return ctx.profile.support_scaled_attributes ? ctx.F32[4] : ctx.TypeVector(ctx.TypeInt(32, true), 4); @@ -219,10 +217,6 @@ InputGenericInfo GetAttributeInfo(EmitContext& ctx, AttributeType type, Id id) { switch (type) { case AttributeType::Float: return InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None}; - case AttributeType::UnsignedNorm: - return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::UNorm}; - case AttributeType::SignedNorm: - return InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::SNorm}; case AttributeType::UnsignedInt: return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::Bitcast}; case AttributeType::SignedInt: @@ -780,19 +774,9 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) { return OpConvertSToF(F32[1], value); case InputGenericLoadOp::UToF: return OpConvertUToF(F32[1], value); - case InputGenericLoadOp::SNorm: { - Id const fp16_value = OpShiftRightArithmetic(U32[1], value, Const(16U)); - Id const max_value = Const(unsigned(std::numeric_limits::max())); - return OpFDiv(F32[1], OpConvertSToF(F32[1], fp16_value), max_value); - } - case InputGenericLoadOp::UNorm: { - Id const fp16_value = OpShiftRightLogical(U32[1], value, Const(16U)); - Id const max_value = Const(unsigned(std::numeric_limits::max())); - return OpFDiv(F32[1], OpConvertSToF(F32[1], fp16_value), max_value); - } - default: + case InputGenericLoadOp::None: return value; - }; + } }()}; OpReturnValue(result); ++label_index; diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index fd4277300d..80ac79f2d6 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h @@ -143,8 +143,6 @@ enum class InputGenericLoadOp { Bitcast, SToF, UToF, - SNorm, - UNorm, }; struct InputGenericInfo { diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index b8ef0200ee..09169358a8 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -18,8 +18,6 @@ namespace Shader { enum class AttributeType : u8 { Disabled, - SignedNorm, - UnsignedNorm, SignedInt, UnsignedInt, SignedScaled, diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 79209b5f15..5c36c9a9ea 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp @@ -105,27 +105,17 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe if (maxwell3d.dirty.flags[Dirty::VertexInput]) { if (features.has_dynamic_vertex_input) { // Dirty flag will be reset by the command buffer update - // 0u, // Invalid - // 1u, // SignedNorm - // 2u, // UnsignedNorm - // 3u, // SignedInt - // 4u, // UnsignedInt - // 5u, // UnsignedScaled - // 6u, // SignedScaled - // 7u, // Float // We sparsely store the bits for each of them, so if they clash we don't deal // with the fixed pipeline taking in invalid vertices! :) const auto& attrs = regs.vertex_attrib_format; - attribute_types[0] = 0; - attribute_types[1] = 0; - attribute_types[2] = 0; + attribute_types = {0, 0, 0}; static_assert(Maxwell::NumVertexAttributes == 32); for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) { - u32 const mask = attrs[i].constant != 0 ? 0 : 0x07; // non-constant equates invalid + u32 const mask = attrs[i].constant != 0 ? 0 : 1; // non-constant equates invalid u32 const type = u32(attrs[i].type.Value()); - attribute_types[0] |= u64((type >> 0) & 1) << i; - attribute_types[1] |= u64((type >> 1) & 1) << i; - attribute_types[2] |= u64((type >> 2) & 1) << i; + attribute_types[0] |= u32((type >> 0) & mask) << i; + attribute_types[1] |= u32((type >> 1) & mask) << i; + attribute_types[2] |= u32((type >> 2) & mask) << i; } } else { maxwell3d.dirty.flags[Dirty::VertexInput] = false; diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index d5c1d2135d..94496b7ee4 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h @@ -278,8 +278,8 @@ struct FixedPipelineState { return offsetof(FixedPipelineState, xfb_state); } - u32 DynamicAttributeType(size_t i) const noexcept { - return u32((((attribute_types[0] >> i) & 1) << 0) + [[nodiscard]] inline Maxwell::VertexAttribute::Type DynamicAttributeType(size_t i) const noexcept { + return Maxwell::VertexAttribute::Type((((attribute_types[0] >> i) & 1) << 0) | (((attribute_types[1] >> i) & 1) << 1) | (((attribute_types[2] >> i) & 1) << 2)); } diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 20221709bc..3b621d7509 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -104,40 +104,22 @@ Shader::CompareFunction MaxwellToCompareFunction(Maxwell::ComparisonOp compariso case Maxwell::ComparisonOp::Always_GL: return Shader::CompareFunction::Always; } - UNIMPLEMENTED_MSG("Unimplemented comparison op={}", comparison); + UNIMPLEMENTED_MSG("op={}", comparison); return {}; } -Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) { - if (attr.enabled == 0) { - return Shader::AttributeType::Disabled; - } - switch (attr.Type()) { - case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway: - ASSERT(false && "Invalid vertex attribute type!"); - return Shader::AttributeType::Disabled; - case Maxwell::VertexAttribute::Type::SNorm: return Shader::AttributeType::SignedNorm; - case Maxwell::VertexAttribute::Type::UNorm: return Shader::AttributeType::UnsignedNorm; - case Maxwell::VertexAttribute::Type::Float: return Shader::AttributeType::Float; - case Maxwell::VertexAttribute::Type::SInt: return Shader::AttributeType::SignedInt; +Shader::AttributeType MaxwellToAttributeType(Maxwell::VertexAttribute::Type type) noexcept { + switch (type) { + case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway: return Shader::AttributeType::Disabled; case Maxwell::VertexAttribute::Type::UInt: return Shader::AttributeType::UnsignedInt; + case Maxwell::VertexAttribute::Type::SInt: return Shader::AttributeType::SignedInt; case Maxwell::VertexAttribute::Type::UScaled: return Shader::AttributeType::UnsignedScaled; case Maxwell::VertexAttribute::Type::SScaled: return Shader::AttributeType::SignedScaled; - } - return Shader::AttributeType::Float; + case Maxwell::VertexAttribute::Type::Float: return Shader::AttributeType::Float; + case Maxwell::VertexAttribute::Type::UNorm: return Shader::AttributeType::Float; + case Maxwell::VertexAttribute::Type::SNorm: return Shader::AttributeType::Float; } - -Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t index) { - switch (state.DynamicAttributeType(index)) { - case 0: return Shader::AttributeType::Disabled; - case 1: return Shader::AttributeType::SignedNorm; - case 2: return Shader::AttributeType::UnsignedNorm; - case 3: return Shader::AttributeType::SignedInt; - case 4: return Shader::AttributeType::UnsignedInt; - case 5: return Shader::AttributeType::UnsignedScaled; - case 6: return Shader::AttributeType::SignedScaled; - case 7: return Shader::AttributeType::Float; - } + UNIMPLEMENTED_MSG("op={}", index); return Shader::AttributeType::Disabled; } @@ -179,12 +161,12 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span program info.convert_depth_mode = gl_ndc; } if (key.state.dynamic_vertex_input) { - for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { - info.generic_input_types[index] = AttributeType(key.state, index); - } + for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) + info.generic_input_types[i] = MaxwellToAttributeType(key.state.DynamicAttributeType(i)); } else { - std::ranges::transform(key.state.attributes, info.generic_input_types.begin(), - &CastAttributeType); + std::ranges::transform(key.state.attributes, info.generic_input_types.begin(), [](auto const attr) { + return attr.enabled ? MaxwellToAttributeType(attr.Type()) : Shader::AttributeType::Disabled; + }); } break; case Shader::Stage::TessellationEval: