This commit is contained in:
lizzie 2026-01-25 01:09:24 +00:00 committed by crueter
parent 6927d8b661
commit bf559148b9
5 changed files with 39 additions and 37 deletions

View file

@ -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), return InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::Bitcast};
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_f32, ctx.F32[1], InputGenericLoadOp::None}
: InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), : InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::SToF};
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_f32, ctx.F32[1], InputGenericLoadOp::None}
: InputGenericInfo{id, ctx.input_u32, ctx.U32[1], InputGenericLoadOp::UToF}; : 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 || if (input_type == AttributeType::SignedInt || input_type == AttributeType::UnsignedInt) {
input_type == AttributeType::UnsignedInt;
if (is_integer) {
Decorate(id, spv::Decoration::Flat); Decorate(id, spv::Decoration::Flat);
} else { } else {
switch (info.interpolation[index]) { switch (info.interpolation[index]) {

View file

@ -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 {

View file

@ -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];

View file

@ -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 union {
u64 enabled_divisors; 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;

View file

@ -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::SNorm: return Shader::AttributeType::SignedNorm;
case Maxwell::VertexAttribute::Type::UNorm: case Maxwell::VertexAttribute::Type::UNorm: return Shader::AttributeType::UnsignedNorm;
case Maxwell::VertexAttribute::Type::Float: case Maxwell::VertexAttribute::Type::Float: return Shader::AttributeType::Float;
return Shader::AttributeType::Float; case Maxwell::VertexAttribute::Type::SInt: return Shader::AttributeType::SignedInt;
case Maxwell::VertexAttribute::Type::SInt: case Maxwell::VertexAttribute::Type::UInt: return Shader::AttributeType::UnsignedInt;
return Shader::AttributeType::SignedInt; case Maxwell::VertexAttribute::Type::UScaled: return Shader::AttributeType::UnsignedScaled;
case Maxwell::VertexAttribute::Type::UInt: case Maxwell::VertexAttribute::Type::SScaled: return Shader::AttributeType::SignedScaled;
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: case 0: return Shader::AttributeType::Disabled;
return Shader::AttributeType::Disabled; case 1: return Shader::AttributeType::SignedNorm;
case 1: case 2: return Shader::AttributeType::UnsignedNorm;
return Shader::AttributeType::Float; case 3: return Shader::AttributeType::SignedInt;
case 2: case 4: return Shader::AttributeType::UnsignedInt;
return Shader::AttributeType::SignedInt; case 5: return Shader::AttributeType::UnsignedScaled;
case 3: case 6: return Shader::AttributeType::SignedScaled;
return Shader::AttributeType::UnsignedInt; case 7: return Shader::AttributeType::Float;
} }
return Shader::AttributeType::Disabled; return Shader::AttributeType::Disabled;
} }