mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-16 21:16:59 +02:00
partial revert
This commit is contained in:
parent
e8f0fd8a69
commit
e7707ea1ca
5 changed files with 63 additions and 38 deletions
|
|
@ -327,9 +327,9 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) {
|
||||||
return ctx.OpConvertSToF(ctx.F32[1], value);
|
return ctx.OpConvertSToF(ctx.F32[1], value);
|
||||||
case InputGenericLoadOp::UToF:
|
case InputGenericLoadOp::UToF:
|
||||||
return ctx.OpConvertUToF(ctx.F32[1], value);
|
return ctx.OpConvertUToF(ctx.F32[1], value);
|
||||||
case InputGenericLoadOp::None:
|
default:
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,8 @@ Id GetAttributeType(EmitContext& ctx, AttributeType type) {
|
||||||
case AttributeType::UnsignedInt:
|
case AttributeType::UnsignedInt:
|
||||||
return ctx.U32[4];
|
return ctx.U32[4];
|
||||||
case AttributeType::SignedScaled:
|
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:
|
case AttributeType::UnsignedScaled:
|
||||||
return ctx.profile.support_scaled_attributes ? ctx.F32[4] : ctx.U32[4];
|
return ctx.profile.support_scaled_attributes ? ctx.F32[4] : ctx.U32[4];
|
||||||
case AttributeType::Disabled:
|
case AttributeType::Disabled:
|
||||||
|
|
@ -220,15 +221,17 @@ InputGenericInfo GetAttributeInfo(EmitContext& ctx, AttributeType type, Id id) {
|
||||||
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_f32, ctx.F32[1], InputGenericLoadOp::None}
|
||||||
: InputGenericInfo{id, ctx.input_s32, ctx.TypeInt(32, true), InputGenericLoadOp::SToF};
|
: 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_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{};
|
||||||
}
|
}
|
||||||
|
|
@ -774,9 +777,9 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) {
|
||||||
return OpConvertSToF(F32[1], value);
|
return OpConvertSToF(F32[1], value);
|
||||||
case InputGenericLoadOp::UToF:
|
case InputGenericLoadOp::UToF:
|
||||||
return OpConvertUToF(F32[1], value);
|
return OpConvertUToF(F32[1], value);
|
||||||
case InputGenericLoadOp::None:
|
default:
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
}()};
|
}()};
|
||||||
OpReturnValue(result);
|
OpReturnValue(result);
|
||||||
++label_index;
|
++label_index;
|
||||||
|
|
@ -1564,7 +1567,9 @@ void EmitContext::DefineInputs(const IR::Program& program) {
|
||||||
if (stage != Stage::Fragment) {
|
if (stage != Stage::Fragment) {
|
||||||
continue;
|
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);
|
Decorate(id, spv::Decoration::Flat);
|
||||||
} else {
|
} else {
|
||||||
switch (info.interpolation[index]) {
|
switch (info.interpolation[index]) {
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
namespace Shader {
|
namespace Shader {
|
||||||
|
|
||||||
enum class AttributeType : u8 {
|
enum class AttributeType : u8 {
|
||||||
Disabled,
|
Float,
|
||||||
SignedInt,
|
SignedInt,
|
||||||
UnsignedInt,
|
UnsignedInt,
|
||||||
SignedScaled,
|
SignedScaled,
|
||||||
UnsignedScaled,
|
UnsignedScaled,
|
||||||
Float,
|
Disabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class InputTopology {
|
enum class InputTopology {
|
||||||
|
|
|
||||||
|
|
@ -111,16 +111,14 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
|
||||||
attribute_types = {0, 0, 0};
|
attribute_types = {0, 0, 0};
|
||||||
static_assert(Maxwell::NumVertexAttributes == 32);
|
static_assert(Maxwell::NumVertexAttributes == 32);
|
||||||
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) {
|
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 = attrs[i].constant != 0 ? 0 : u32(attrs[i].type.Value()); // non-constant equates invalid
|
||||||
u32 const type = u32(attrs[i].type.Value());
|
attribute_types[0] |= u32((type >> 0) & 1) << i;
|
||||||
attribute_types[0] |= u32((type >> 0) & mask) << i;
|
attribute_types[1] |= u32((type >> 1) & 1) << i;
|
||||||
attribute_types[1] |= u32((type >> 1) & mask) << i;
|
attribute_types[2] |= u32((type >> 2) & 1) << i;
|
||||||
attribute_types[2] |= u32((type >> 2) & mask) << i;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
maxwell3d.dirty.flags[Dirty::VertexInput] = false;
|
maxwell3d.dirty.flags[Dirty::VertexInput] = false;
|
||||||
enabled_divisors[0] = 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;
|
||||||
|
|
|
||||||
|
|
@ -104,23 +104,45 @@ Shader::CompareFunction MaxwellToCompareFunction(Maxwell::ComparisonOp compariso
|
||||||
case Maxwell::ComparisonOp::Always_GL:
|
case Maxwell::ComparisonOp::Always_GL:
|
||||||
return Shader::CompareFunction::Always;
|
return Shader::CompareFunction::Always;
|
||||||
}
|
}
|
||||||
UNIMPLEMENTED_MSG("op={}", comparison);
|
UNIMPLEMENTED_MSG("Unimplemented comparison op={}", comparison);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Shader::AttributeType MaxwellToAttributeType(Maxwell::VertexAttribute::Type type) noexcept {
|
Shader::AttributeType CastAttributeType(const FixedPipelineState::VertexAttribute& attr) {
|
||||||
switch (type) {
|
if (attr.enabled == 0) {
|
||||||
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway: return Shader::AttributeType::Disabled;
|
return Shader::AttributeType::Disabled;
|
||||||
case Maxwell::VertexAttribute::Type::UInt: return Shader::AttributeType::UnsignedInt;
|
}
|
||||||
case Maxwell::VertexAttribute::Type::SInt: return Shader::AttributeType::SignedInt;
|
switch (attr.Type()) {
|
||||||
case Maxwell::VertexAttribute::Type::UScaled: return Shader::AttributeType::UnsignedScaled;
|
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway:
|
||||||
case Maxwell::VertexAttribute::Type::SScaled: return Shader::AttributeType::SignedScaled;
|
ASSERT_MSG(false, "Invalid vertex attribute type!");
|
||||||
case Maxwell::VertexAttribute::Type::Float: return Shader::AttributeType::Float;
|
return Shader::AttributeType::Disabled;
|
||||||
case Maxwell::VertexAttribute::Type::UNorm: return Shader::AttributeType::Float;
|
case Maxwell::VertexAttribute::Type::SNorm:
|
||||||
case Maxwell::VertexAttribute::Type::SNorm: return Shader::AttributeType::Float;
|
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,
|
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;
|
info.convert_depth_mode = gl_ndc;
|
||||||
}
|
}
|
||||||
if (key.state.dynamic_vertex_input) {
|
if (key.state.dynamic_vertex_input) {
|
||||||
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i)
|
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
||||||
info.generic_input_types[i] = MaxwellToAttributeType(key.state.DynamicAttributeType(i));
|
info.generic_input_types[index] = AttributeType(key.state, index);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::ranges::transform(key.state.attributes, info.generic_input_types.begin(), [](auto const attr) {
|
std::ranges::transform(key.state.attributes, info.generic_input_types.begin(),
|
||||||
return attr.enabled ? MaxwellToAttributeType(attr.Type()) : Shader::AttributeType::Disabled;
|
&CastAttributeType);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Shader::Stage::TessellationEval:
|
case Shader::Stage::TessellationEval:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue