mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-02-04 02:51:18 +01:00
partial revert
This commit is contained in:
@@ -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);
|
||||
case InputGenericLoadOp::None:
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}();
|
||||
}
|
||||
switch (attr) {
|
||||
|
||||
@@ -204,7 +204,8 @@ Id GetAttributeType(EmitContext& ctx, AttributeType type) {
|
||||
case AttributeType::UnsignedInt:
|
||||
return ctx.U32[4];
|
||||
case AttributeType::SignedScaled:
|
||||
return ctx.profile.support_scaled_attributes ? ctx.F32[4] : ctx.TypeVector(ctx.TypeInt(32, true), 4);
|
||||
return ctx.profile.support_scaled_attributes ? ctx.F32[4]
|
||||
: ctx.TypeVector(ctx.TypeInt(32, true), 4);
|
||||
case AttributeType::UnsignedScaled:
|
||||
return ctx.profile.support_scaled_attributes ? ctx.F32[4] : ctx.U32[4];
|
||||
case AttributeType::Disabled:
|
||||
@@ -220,15 +221,17 @@ InputGenericInfo GetAttributeInfo(EmitContext& ctx, AttributeType type, Id id) {
|
||||
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{};
|
||||
}
|
||||
@@ -774,9 +777,9 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) {
|
||||
return OpConvertSToF(F32[1], value);
|
||||
case InputGenericLoadOp::UToF:
|
||||
return OpConvertUToF(F32[1], value);
|
||||
case InputGenericLoadOp::None:
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}()};
|
||||
OpReturnValue(result);
|
||||
++label_index;
|
||||
@@ -1564,7 +1567,9 @@ void EmitContext::DefineInputs(const IR::Program& program) {
|
||||
if (stage != Stage::Fragment) {
|
||||
continue;
|
||||
}
|
||||
if (input_type == AttributeType::SignedInt || input_type == AttributeType::UnsignedInt) {
|
||||
const bool is_integer = input_type == AttributeType::SignedInt ||
|
||||
input_type == AttributeType::UnsignedInt;
|
||||
if (is_integer) {
|
||||
Decorate(id, spv::Decoration::Flat);
|
||||
} else {
|
||||
switch (info.interpolation[index]) {
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
namespace Shader {
|
||||
|
||||
enum class AttributeType : u8 {
|
||||
Disabled,
|
||||
Float,
|
||||
SignedInt,
|
||||
UnsignedInt,
|
||||
SignedScaled,
|
||||
UnsignedScaled,
|
||||
Float,
|
||||
Disabled,
|
||||
};
|
||||
|
||||
enum class InputTopology {
|
||||
|
||||
@@ -111,16 +111,14 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
|
||||
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 : 1; // non-constant equates invalid
|
||||
u32 const type = u32(attrs[i].type.Value());
|
||||
attribute_types[0] |= u32((type >> 0) & mask) << i;
|
||||
attribute_types[1] |= u32((type >> 1) & mask) << i;
|
||||
attribute_types[2] |= u32((type >> 2) & mask) << i;
|
||||
u32 const type = attrs[i].constant != 0 ? 0 : u32(attrs[i].type.Value()); // non-constant equates invalid
|
||||
attribute_types[0] |= u32((type >> 0) & 1) << i;
|
||||
attribute_types[1] |= u32((type >> 1) & 1) << i;
|
||||
attribute_types[2] |= u32((type >> 2) & 1) << i;
|
||||
}
|
||||
} else {
|
||||
maxwell3d.dirty.flags[Dirty::VertexInput] = false;
|
||||
enabled_divisors[0] = 0;
|
||||
enabled_divisors[1] = 0;
|
||||
enabled_divisors = {0, 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;
|
||||
|
||||
@@ -104,23 +104,45 @@ Shader::CompareFunction MaxwellToCompareFunction(Maxwell::ComparisonOp compariso
|
||||
case Maxwell::ComparisonOp::Always_GL:
|
||||
return Shader::CompareFunction::Always;
|
||||
}
|
||||
UNIMPLEMENTED_MSG("op={}", comparison);
|
||||
UNIMPLEMENTED_MSG("Unimplemented comparison op={}", comparison);
|
||||
return {};
|
||||
}
|
||||
|
||||
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;
|
||||
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 CastAttributeType(const FixedPipelineState::VertexAttribute& attr) {
|
||||
if (attr.enabled == 0) {
|
||||
return Shader::AttributeType::Disabled;
|
||||
}
|
||||
switch (attr.Type()) {
|
||||
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway:
|
||||
ASSERT_MSG(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;
|
||||
}
|
||||
return Shader::AttributeType::Float;
|
||||
}
|
||||
UNIMPLEMENTED_MSG("op={}", index);
|
||||
return Shader::AttributeType::Disabled;
|
||||
|
||||
Shader::AttributeType AttributeType(const FixedPipelineState& state, size_t index) {
|
||||
switch (state.DynamicAttributeType(index)) {
|
||||
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;
|
||||
default:
|
||||
return Shader::AttributeType::Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> programs,
|
||||
@@ -161,12 +183,12 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program
|
||||
info.convert_depth_mode = gl_ndc;
|
||||
}
|
||||
if (key.state.dynamic_vertex_input) {
|
||||
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i)
|
||||
info.generic_input_types[i] = MaxwellToAttributeType(key.state.DynamicAttributeType(i));
|
||||
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
||||
info.generic_input_types[index] = AttributeType(key.state, index);
|
||||
}
|
||||
} else {
|
||||
std::ranges::transform(key.state.attributes, info.generic_input_types.begin(), [](auto const attr) {
|
||||
return attr.enabled ? MaxwellToAttributeType(attr.Type()) : Shader::AttributeType::Disabled;
|
||||
});
|
||||
std::ranges::transform(key.state.attributes, info.generic_input_types.begin(),
|
||||
&CastAttributeType);
|
||||
}
|
||||
break;
|
||||
case Shader::Stage::TessellationEval:
|
||||
|
||||
Reference in New Issue
Block a user