early-access version 2006

This commit is contained in:
pineappleEA
2021-08-21 07:18:09 +02:00
parent bcb0d9cd4f
commit 26b17a7d5c
14 changed files with 293 additions and 301 deletions

View File

@@ -216,6 +216,7 @@ add_library(shader_recompiler STATIC
ir_opt/constant_propagation_pass.cpp
ir_opt/dead_code_elimination_pass.cpp
ir_opt/dual_vertex_pass.cpp
ir_opt/get_attribute_reorder_pass.cpp
ir_opt/global_memory_to_storage_buffer_pass.cpp
ir_opt/identity_removal_pass.cpp
ir_opt/lower_fp16_to_fp32.cpp

View File

@@ -178,6 +178,7 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
Optimization::ConstantPropagationPass(program);
Optimization::DeadCodeEliminationPass(program);
Optimization::GetAttributeReorderPass(program);
if (Settings::values.renderer_debug) {
Optimization::VerificationPass(program);
}

View File

@@ -0,0 +1,40 @@
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/value.h"
#include "shader_recompiler/ir_opt/passes.h"
namespace Shader::Optimization {
static bool CanBeReordered(const IR::Inst& inst) {
switch (inst.GetOpcode()) {
case IR::Opcode::GetAttribute:
return inst.AreAllArgsImmediates();
default:
return false;
}
}
void GetAttributeReorderPass(IR::Program& program) {
auto& first_block_list{program.blocks[0]->Instructions()};
auto& prologue{first_block_list.front()};
first_block_list.pop_front();
for (IR::Block* const block : program.blocks) {
auto& instrucions{block->Instructions()};
auto it = instrucions.begin();
while (it != instrucions.end()) {
if (!CanBeReordered(*it)) {
++it;
continue;
}
auto& removed_val{*it};
it = instrucions.erase(it);
first_block_list.push_front(removed_val);
}
}
first_block_list.push_front(prologue);
}
} // namespace Shader::Optimization

View File

@@ -4,8 +4,6 @@
#pragma once
#include <span>
#include "shader_recompiler/environment.h"
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/program.h"
@@ -15,6 +13,7 @@ namespace Shader::Optimization {
void CollectShaderInfoPass(Environment& env, IR::Program& program);
void ConstantPropagationPass(IR::Program& program);
void DeadCodeEliminationPass(IR::Program& program);
void GetAttributeReorderPass(IR::Program& program);
void GlobalMemoryToStorageBufferPass(IR::Program& program);
void IdentityRemovalPass(IR::Program& program);
void LowerFp16ToFp32(IR::Program& program);