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) {
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]) {

View File

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

View File

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

View File

@@ -227,8 +227,10 @@ struct FixedPipelineState {
std::array<u16, Maxwell::NumViewports> viewport_swizzles;
// 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;
std::array<BlendingAttachment, Maxwell::NumRenderTargets> attachments;

View File

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