Browse Source

fix

lizzie/vids-ratatata
lizzie 2 months ago
committed by crueter
parent
commit
bf559148b9
  1. 22
      src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
  2. 6
      src/shader_recompiler/runtime_info.h
  3. 5
      src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
  4. 6
      src/video_core/renderer_vulkan/fixed_pipeline_state.h
  5. 37
      src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

22
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp

@ -218,20 +218,24 @@ InputGenericInfo GetAttributeInfo(EmitContext& ctx, AttributeType type, Id id) {
switch (type) { switch (type) {
case AttributeType::Float: case AttributeType::Float:
return InputGenericInfo{id, ctx.input_f32, ctx.F32[1], InputGenericLoadOp::None}; 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: case AttributeType::UnsignedInt:
return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::Bitcast}; return InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::Bitcast};
case AttributeType::SignedInt: 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: case AttributeType::SignedScaled:
return ctx.profile.support_scaled_attributes 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: case AttributeType::UnsignedScaled:
return ctx.profile.support_scaled_attributes 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: case AttributeType::Disabled:
return InputGenericInfo{}; return InputGenericInfo{};
} }
@ -1567,9 +1571,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
if (stage != Stage::Fragment) { if (stage != Stage::Fragment) {
continue; 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); Decorate(id, spv::Decoration::Flat);
} else { } else {
switch (info.interpolation[index]) { switch (info.interpolation[index]) {

6
src/shader_recompiler/runtime_info.h

@ -17,12 +17,14 @@
namespace Shader { namespace Shader {
enum class AttributeType : u8 { enum class AttributeType : u8 {
Float,
Disabled,
SignedNorm,
UnsignedNorm,
SignedInt, SignedInt,
UnsignedInt, UnsignedInt,
SignedScaled, SignedScaled,
UnsignedScaled, UnsignedScaled,
Disabled,
Float,
}; };
enum class InputTopology { enum class InputTopology {

5
src/video_core/renderer_vulkan/fixed_pipeline_state.cpp

@ -129,11 +129,12 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
} }
} else { } else {
maxwell3d.dirty.flags[Dirty::VertexInput] = false; 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) { for (size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
const bool is_enabled = regs.vertex_stream_instances.IsInstancingEnabled(index); const bool is_enabled = regs.vertex_stream_instances.IsInstancingEnabled(index);
binding_divisors[index] = is_enabled ? regs.vertex_streams[index].frequency : 0; 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) { for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
const auto& input = regs.vertex_attrib_format[index]; const auto& input = regs.vertex_attrib_format[index];

6
src/video_core/renderer_vulkan/fixed_pipeline_state.h

@ -227,8 +227,10 @@ struct FixedPipelineState {
std::array<u16, Maxwell::NumViewports> viewport_swizzles; std::array<u16, Maxwell::NumViewports> viewport_swizzles;
// TODO: this has to be trivially constructuible and both are mutually exclusive // TODO: this has to be trivially constructuible and both are mutually exclusive
std::array<u32, 4> attribute_types; // Used with VK_EXT_vertex_input_dynamic_state
u64 enabled_divisors;
union {
std::array<u32, 4> attribute_types; // Used with VK_EXT_vertex_input_dynamic_state
std::array<u64, 2> enabled_divisors;
};
DynamicState dynamic_state; DynamicState dynamic_state;
std::array<BlendingAttachment, Maxwell::NumRenderTargets> attachments; std::array<BlendingAttachment, Maxwell::NumRenderTargets> attachments;

37
src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

@ -114,34 +114,29 @@ Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribut
} }
switch (attr.Type()) { switch (attr.Type()) {
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway: case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway:
ASSERT_MSG(false, "Invalid vertex attribute type!");
ASSERT(false && "Invalid vertex attribute type!");
return Shader::AttributeType::Disabled; 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; return Shader::AttributeType::Float;
} }
Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t index) { Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t index) {
switch (state.DynamicAttributeType(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; return Shader::AttributeType::Disabled;
} }

Loading…
Cancel
Save