diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index c70f9ae934..c8727e3d06 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -218,20 +218,24 @@ InputGenericInfo GetAttributeInfo(EmitContext& ctx, AttributeType type, Id id) { switch (type) { case AttributeType::Float: return InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None}; + // TODO: properly impl this? + case AttributeType::UnsignedNorm: + return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::Bitcast}; + case AttributeType::SignedNorm: + return InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::Bitcast}; + // case AttributeType::UnsignedInt: return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::Bitcast}; case AttributeType::SignedInt: - return InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), - InputGenericLoadOp::Bitcast}; + return InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::Bitcast}; case AttributeType::SignedScaled: return ctx.profile.support_scaled_attributes - ? InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None} - : InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), - InputGenericLoadOp::SToF}; + ? InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None} + : InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::SToF}; case AttributeType::UnsignedScaled: return ctx.profile.support_scaled_attributes - ? InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None} - : InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::UToF}; + ? InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None} + : InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::UToF}; case AttributeType::Disabled: return InputGenericInfo{}; } @@ -1567,9 +1571,7 @@ void EmitContext::DefineInputs(const IR::Program& program) { if (stage != Stage::Fragment) { continue; } - const bool is_integer = input_type == AttributeType::SignedInt || - input_type == AttributeType::UnsignedInt; - if (is_integer) { + if (input_type == AttributeType::SignedInt || input_type == AttributeType::UnsignedInt) { Decorate(id, spv::Decoration::Flat); } else { switch (info.interpolation[index]) { diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index 613c598d0c..b8ef0200ee 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -17,12 +17,14 @@ namespace Shader { enum class AttributeType : u8 { - Float, + Disabled, + SignedNorm, + UnsignedNorm, SignedInt, UnsignedInt, SignedScaled, UnsignedScaled, - Disabled, + Float, }; enum class InputTopology { diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index dc3f471437..79209b5f15 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp @@ -129,11 +129,12 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe } } else { maxwell3d.dirty.flags[Dirty::VertexInput] = false; - enabled_divisors = 0; + enabled_divisors[0] = 0; + enabled_divisors[1] = 0; for (size_t index = 0; index < Maxwell::NumVertexArrays; ++index) { const bool is_enabled = regs.vertex_stream_instances.IsInstancingEnabled(index); binding_divisors[index] = is_enabled ? regs.vertex_streams[index].frequency : 0; - enabled_divisors |= (is_enabled ? u64{1} : 0) << index; + enabled_divisors[0] |= (is_enabled ? u64{1} : 0) << index; } for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { const auto& input = regs.vertex_attrib_format[index]; diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 1e4bd09da1..d5c1d2135d 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h @@ -227,8 +227,10 @@ struct FixedPipelineState { std::array viewport_swizzles; // TODO: this has to be trivially constructuible and both are mutually exclusive - std::array attribute_types; // Used with VK_EXT_vertex_input_dynamic_state - u64 enabled_divisors; + union { + std::array attribute_types; // Used with VK_EXT_vertex_input_dynamic_state + std::array enabled_divisors; + }; DynamicState dynamic_state; std::array attachments; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index f3dd0f90d8..20221709bc 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -114,34 +114,29 @@ Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribut } switch (attr.Type()) { case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway: - ASSERT_MSG(false, "Invalid vertex attribute type!"); + ASSERT(false && "Invalid vertex attribute type!"); return Shader::AttributeType::Disabled; - case Maxwell::VertexAttribute::Type::SNorm: - case Maxwell::VertexAttribute::Type::UNorm: - case Maxwell::VertexAttribute::Type::Float: - return Shader::AttributeType::Float; - case Maxwell::VertexAttribute::Type::SInt: - return Shader::AttributeType::SignedInt; - case Maxwell::VertexAttribute::Type::UInt: - return Shader::AttributeType::UnsignedInt; - case Maxwell::VertexAttribute::Type::UScaled: - return Shader::AttributeType::UnsignedScaled; - case Maxwell::VertexAttribute::Type::SScaled: - return Shader::AttributeType::SignedScaled; + 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; + case Maxwell::VertexAttribute::Type::UInt: return Shader::AttributeType::UnsignedInt; + case Maxwell::VertexAttribute::Type::UScaled: return Shader::AttributeType::UnsignedScaled; + case Maxwell::VertexAttribute::Type::SScaled: return Shader::AttributeType::SignedScaled; } 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::Float; - case 2: - return Shader::AttributeType::SignedInt; - case 3: - return Shader::AttributeType::UnsignedInt; + 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; } return Shader::AttributeType::Disabled; }