mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 03:40:15 +00:00
Preparation for compiling the shader epilogue as well.
This commit is contained in:
parent
545db99381
commit
4f802f8d26
@ -40,7 +40,8 @@ void Setup() {
|
|||||||
u64 cache_key =
|
u64 cache_key =
|
||||||
Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^
|
Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^
|
||||||
Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)) ^
|
Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)) ^
|
||||||
Common::ComputeHash64(&attribute_register_map, sizeof(attribute_register_map));
|
Common::ComputeHash64(&attribute_register_map, sizeof(attribute_register_map)) ^
|
||||||
|
Common::ComputeHash64(&g_state.regs.vs_output_attributes, sizeof(g_state.regs.vs_output_attributes));
|
||||||
|
|
||||||
auto iter = shader_map.find(cache_key);
|
auto iter = shader_map.find(cache_key);
|
||||||
if (iter != shader_map.end()) {
|
if (iter != shader_map.end()) {
|
||||||
@ -64,25 +65,25 @@ void Shutdown() {
|
|||||||
MICROPROFILE_DEFINE(GPU_VertexShader, "GPU", "Vertex Shader", MP_RGB(50, 50, 240));
|
MICROPROFILE_DEFINE(GPU_VertexShader, "GPU", "Vertex Shader", MP_RGB(50, 50, 240));
|
||||||
|
|
||||||
OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attributes) {
|
OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attributes) {
|
||||||
auto& config = g_state.regs.vs;
|
|
||||||
|
|
||||||
MICROPROFILE_SCOPE(GPU_VertexShader);
|
MICROPROFILE_SCOPE(GPU_VertexShader);
|
||||||
|
|
||||||
state.program_counter = config.main_offset;
|
|
||||||
state.debug.max_offset = 0;
|
state.debug.max_offset = 0;
|
||||||
state.debug.max_opdesc_id = 0;
|
state.debug.max_opdesc_id = 0;
|
||||||
|
|
||||||
// Setup input register table
|
// Setup output data
|
||||||
|
OutputVertex ret;
|
||||||
state.conditional_code[0] = false;
|
|
||||||
state.conditional_code[1] = false;
|
|
||||||
|
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
if (VideoCore::g_shader_jit_enabled) {
|
if (VideoCore::g_shader_jit_enabled) {
|
||||||
jit_shader->Run(&state.registers, &input.attr[0], g_state.regs.vs.main_offset);
|
jit_shader->Run(&state.registers, &input.attr[0], g_state.regs.vs.main_offset, &ret);
|
||||||
} else
|
} else
|
||||||
#endif // ARCHITECTURE_x86_64
|
#endif // ARCHITECTURE_x86_64
|
||||||
{
|
{
|
||||||
|
auto& config = g_state.regs.vs;
|
||||||
|
// Setup input register table
|
||||||
|
state.program_counter = config.main_offset;
|
||||||
|
state.conditional_code[0] = false;
|
||||||
|
state.conditional_code[1] = false;
|
||||||
const auto& attribute_register_map = config.input_register_map;
|
const auto& attribute_register_map = config.input_register_map;
|
||||||
// TODO: Instead of this cumbersome logic, just load the input data directly like
|
// TODO: Instead of this cumbersome logic, just load the input data directly like
|
||||||
// for (int attr = 0; attr < num_attributes; ++attr) { input_attr[0] = state.registers.input[attribute_register_map.attribute0_register]; }
|
// for (int attr = 0; attr < num_attributes; ++attr) { input_attr[0] = state.registers.input[attribute_register_map.attribute0_register]; }
|
||||||
@ -106,13 +107,10 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr
|
|||||||
RunInterpreter(state);
|
RunInterpreter(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup output data
|
|
||||||
OutputVertex ret;
|
|
||||||
// TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to
|
// TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to
|
||||||
// figure out what those circumstances are and enable the remaining outputs then.
|
// figure out what those circumstances are and enable the remaining outputs then.
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
for (unsigned i = 0; i < 7; ++i) {
|
for (unsigned i = 0; i < 7; ++i) {
|
||||||
|
|
||||||
if (index >= g_state.regs.vs_output_total)
|
if (index >= g_state.regs.vs_output_total)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -581,7 +581,6 @@ void JitShader::Compile_NOP(Instruction instr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JitShader::Compile_END(Instruction instr) {
|
void JitShader::Compile_END(Instruction instr) {
|
||||||
ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
|
||||||
RET();
|
RET();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,7 +824,7 @@ void JitShader::Compile() {
|
|||||||
// The stack pointer is 8 modulo 16 at the entry of a procedure
|
// The stack pointer is 8 modulo 16 at the entry of a procedure
|
||||||
ABI_PushRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
ABI_PushRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
||||||
|
|
||||||
// Load inputs
|
// Prologue: Scatter inputs into registers according to map
|
||||||
MOV(PTRBITS, R(REGISTERS), R(ABI_PARAM1));
|
MOV(PTRBITS, R(REGISTERS), R(ABI_PARAM1));
|
||||||
MOV(PTRBITS, R(INPUT), R(ABI_PARAM2));
|
MOV(PTRBITS, R(INPUT), R(ABI_PARAM2));
|
||||||
for (int i = 0; i < num_attributes; i++) {
|
for (int i = 0; i < num_attributes; i++) {
|
||||||
@ -849,9 +848,12 @@ void JitShader::Compile() {
|
|||||||
static const __m128 neg = { -0.f, -0.f, -0.f, -0.f };
|
static const __m128 neg = { -0.f, -0.f, -0.f, -0.f };
|
||||||
MOV(PTRBITS, R(RAX), ImmPtr(&neg));
|
MOV(PTRBITS, R(RAX), ImmPtr(&neg));
|
||||||
MOVAPS(NEGBIT, MatR(RAX));
|
MOVAPS(NEGBIT, MatR(RAX));
|
||||||
|
// Call the start of the shader program.
|
||||||
|
CALLptr(R(ABI_PARAM3));
|
||||||
|
// Alright, back from the program. Now we can do the epilogue.
|
||||||
|
|
||||||
// Jump to start of the shader program
|
ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
||||||
JMPptr(R(ABI_PARAM3));
|
RET();
|
||||||
|
|
||||||
// Compile entire program
|
// Compile entire program
|
||||||
Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size()));
|
Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size()));
|
||||||
|
@ -33,8 +33,8 @@ class JitShader : public Gen::XCodeBlock {
|
|||||||
public:
|
public:
|
||||||
JitShader();
|
JitShader();
|
||||||
|
|
||||||
void Run(void* registers, const void *input, unsigned offset) const {
|
void Run(void* registers, const void *input, unsigned int offset, void *output) const {
|
||||||
program(registers, input, code_ptr[offset]);
|
program(registers, input, code_ptr[offset], output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compile();
|
void Compile();
|
||||||
@ -114,7 +114,7 @@ private:
|
|||||||
/// Branches that need to be fixed up once the entire shader program is compiled
|
/// Branches that need to be fixed up once the entire shader program is compiled
|
||||||
std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches;
|
std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches;
|
||||||
|
|
||||||
using CompiledShader = void(void* registers, const void *input, const u8* start_addr);
|
using CompiledShader = void(void* registers, const void *input, const u8* start_addr, void *output);
|
||||||
CompiledShader* program = nullptr;
|
CompiledShader* program = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user