mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-11-24 16:50:06 +01:00
[TEST] Add varyings to the legacy fallback when no gemoetry shader passthrough is available
This commit is contained in:
parent
945d5c373b
commit
b0a01ca629
3 changed files with 67 additions and 33 deletions
|
|
@ -144,12 +144,15 @@ std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings(
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
mapping.insert({attr + i, previous_stage_mapping.at(attr + i)});
|
mapping.insert({attr + i, previous_stage_mapping.at(attr + i)});
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
mapping.insert({attr + i, unused_generics.front() + i});
|
|
||||||
}
|
|
||||||
unused_generics.pop();
|
|
||||||
}
|
}
|
||||||
|
if (unused_generics.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
mapping.insert({attr + i, unused_generics.front() + i});
|
||||||
|
}
|
||||||
|
unused_generics.pop();
|
||||||
};
|
};
|
||||||
for (size_t index = 0; index < 4; ++index) {
|
for (size_t index = 0; index < 4; ++index) {
|
||||||
auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4;
|
auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4;
|
||||||
|
|
@ -199,26 +202,46 @@ void EmitGeometryPassthrough(IR::IREmitter& ir, const IR::Program& program,
|
||||||
const PassthroughVertices vertices{GetPassthroughVertices(input_topology)};
|
const PassthroughVertices vertices{GetPassthroughVertices(input_topology)};
|
||||||
for (u32 vertex = 0; vertex < vertices.count; vertex++) {
|
for (u32 vertex = 0; vertex < vertices.count; vertex++) {
|
||||||
const u32 i = vertices.first + vertex * vertices.stride;
|
const u32 i = vertices.first + vertex * vertices.stride;
|
||||||
// Assign generics from input
|
const auto copy_vec4{[&ir, i](IR::Attribute attr) {
|
||||||
for (u32 j = 0; j < 32; j++) {
|
|
||||||
if (!passthrough_mask.Generic(j)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const IR::Attribute attr = IR::Attribute::Generic0X + (j * 4);
|
|
||||||
ir.SetAttribute(attr + 0, ir.GetAttribute(attr + 0, ir.Imm32(i)), ir.Imm32(0));
|
ir.SetAttribute(attr + 0, ir.GetAttribute(attr + 0, ir.Imm32(i)), ir.Imm32(0));
|
||||||
ir.SetAttribute(attr + 1, ir.GetAttribute(attr + 1, ir.Imm32(i)), ir.Imm32(0));
|
ir.SetAttribute(attr + 1, ir.GetAttribute(attr + 1, ir.Imm32(i)), ir.Imm32(0));
|
||||||
ir.SetAttribute(attr + 2, ir.GetAttribute(attr + 2, ir.Imm32(i)), ir.Imm32(0));
|
ir.SetAttribute(attr + 2, ir.GetAttribute(attr + 2, ir.Imm32(i)), ir.Imm32(0));
|
||||||
ir.SetAttribute(attr + 3, ir.GetAttribute(attr + 3, ir.Imm32(i)), ir.Imm32(0));
|
ir.SetAttribute(attr + 3, ir.GetAttribute(attr + 3, ir.Imm32(i)), ir.Imm32(0));
|
||||||
|
}};
|
||||||
|
|
||||||
|
// Assign generics from input
|
||||||
|
for (u32 j = 0; j < IR::NUM_GENERICS; j++) {
|
||||||
|
if (!passthrough_mask.Generic(j)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
copy_vec4(IR::Attribute::Generic0X + (j * 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 j = 0; j < 4; j++) {
|
||||||
|
const IR::Attribute attr = IR::Attribute::ColorFrontDiffuseR + (j * 4);
|
||||||
|
if (!passthrough_mask.AnyComponent(attr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
copy_vec4(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passthrough_mask[IR::Attribute::FogCoordinate]) {
|
||||||
|
ir.SetAttribute(IR::Attribute::FogCoordinate,
|
||||||
|
ir.GetAttribute(IR::Attribute::FogCoordinate, ir.Imm32(i)),
|
||||||
|
ir.Imm32(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 j = 0; j < IR::NUM_FIXEDFNCTEXTURE; j++) {
|
||||||
|
const IR::Attribute attr = IR::Attribute::FixedFncTexture0S + (j * 4);
|
||||||
|
if (!passthrough_mask.AnyComponent(attr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
copy_vec4(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passthrough_position) {
|
if (passthrough_position) {
|
||||||
// Assign position from input
|
// Assign position from input
|
||||||
const IR::Attribute attr = IR::Attribute::PositionX;
|
copy_vec4(IR::Attribute::PositionX);
|
||||||
ir.SetAttribute(attr + 0, ir.GetAttribute(attr + 0, ir.Imm32(i)), ir.Imm32(0));
|
|
||||||
ir.SetAttribute(attr + 1, ir.GetAttribute(attr + 1, ir.Imm32(i)), ir.Imm32(0));
|
|
||||||
ir.SetAttribute(attr + 2, ir.GetAttribute(attr + 2, ir.Imm32(i)), ir.Imm32(0));
|
|
||||||
ir.SetAttribute(attr + 3, ir.GetAttribute(attr + 3, ir.Imm32(i)), ir.Imm32(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passthrough_layer_attr) {
|
if (passthrough_layer_attr) {
|
||||||
|
|
@ -380,19 +403,24 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run
|
||||||
program.info.legacy_stores_mapping =
|
program.info.legacy_stores_mapping =
|
||||||
GenerateLegacyToGenericMappings(stores, unused_output_generics, {});
|
GenerateLegacyToGenericMappings(stores, unused_output_generics, {});
|
||||||
for (IR::Block* const block : program.post_order_blocks) {
|
for (IR::Block* const block : program.post_order_blocks) {
|
||||||
for (IR::Inst& inst : block->Instructions()) {
|
auto it{block->begin()};
|
||||||
switch (inst.GetOpcode()) {
|
while (it != block->end()) {
|
||||||
case IR::Opcode::SetAttribute: {
|
IR::Inst& inst{*it};
|
||||||
const auto attr = inst.Arg(0).Attribute();
|
if (inst.GetOpcode() != IR::Opcode::SetAttribute ||
|
||||||
if (IsLegacyAttribute(attr)) {
|
!IsLegacyAttribute(inst.Arg(0).Attribute())) {
|
||||||
stores.Set(program.info.legacy_stores_mapping[attr], true);
|
++it;
|
||||||
inst.SetArg(0, Shader::IR::Value(program.info.legacy_stores_mapping[attr]));
|
continue;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
const auto& mapping{program.info.legacy_stores_mapping};
|
||||||
break;
|
const auto mapped{mapping.find(inst.Arg(0).Attribute())};
|
||||||
|
if (mapped == mapping.end()) {
|
||||||
|
inst.Invalidate();
|
||||||
|
it = block->Instructions().erase(it);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
stores.Set(mapped->second, true);
|
||||||
|
inst.SetArg(0, Shader::IR::Value(mapped->second));
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -414,10 +442,16 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run
|
||||||
switch (inst.GetOpcode()) {
|
switch (inst.GetOpcode()) {
|
||||||
case IR::Opcode::GetAttribute: {
|
case IR::Opcode::GetAttribute: {
|
||||||
const auto attr = inst.Arg(0).Attribute();
|
const auto attr = inst.Arg(0).Attribute();
|
||||||
if (IsLegacyAttribute(attr)) {
|
if (!IsLegacyAttribute(attr)) {
|
||||||
loads.Set(mappings[attr], true);
|
break;
|
||||||
inst.SetArg(0, Shader::IR::Value(mappings[attr]));
|
|
||||||
}
|
}
|
||||||
|
const auto mapped{mappings.find(attr)};
|
||||||
|
if (mapped == mappings.end()) {
|
||||||
|
inst.ReplaceUsesWith(IR::Value{0.0f});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
loads.Set(mapped->second, true);
|
||||||
|
inst.SetArg(0, Shader::IR::Value(mapped->second));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ using VideoCommon::LoadPipelines;
|
||||||
using VideoCommon::SerializePipeline;
|
using VideoCommon::SerializePipeline;
|
||||||
using Context = ShaderContext::Context;
|
using Context = ShaderContext::Context;
|
||||||
|
|
||||||
constexpr u32 CACHE_VERSION = 16;
|
constexpr u32 CACHE_VERSION = 17;
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
auto MakeSpan(Container& container) {
|
auto MakeSpan(Container& container) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ using VideoCommon::FileEnvironment;
|
||||||
using VideoCommon::GenericEnvironment;
|
using VideoCommon::GenericEnvironment;
|
||||||
using VideoCommon::GraphicsEnvironment;
|
using VideoCommon::GraphicsEnvironment;
|
||||||
|
|
||||||
constexpr u32 CACHE_VERSION = 19;
|
constexpr u32 CACHE_VERSION = 20;
|
||||||
constexpr size_t VULKAN_CACHE_FLUSH_PIPELINES = 128;
|
constexpr size_t VULKAN_CACHE_FLUSH_PIPELINES = 128;
|
||||||
constexpr size_t VULKAN_CACHE_FLUSH_MIN_SECONDS = 30;
|
constexpr size_t VULKAN_CACHE_FLUSH_MIN_SECONDS = 30;
|
||||||
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'};
|
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue