mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-29 02:40:15 +00:00
Videocore: Replace std::stack in shader interpreter with static_vector
Shaves off 1/3rd of the vertex shader time in Fire Emblem
This commit is contained in:
parent
392c7feba0
commit
877d2a0e48
1 changed files with 6 additions and 6 deletions
|
@ -2,8 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <stack>
|
#include <boost/container/static_vector.hpp>
|
||||||
|
|
||||||
#include <boost/range/algorithm.hpp>
|
#include <boost/range/algorithm.hpp>
|
||||||
|
|
||||||
#include <common/file_util.h>
|
#include <common/file_util.h>
|
||||||
|
@ -53,7 +52,7 @@ struct VertexShaderState {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Is there a maximal size for this?
|
// TODO: Is there a maximal size for this?
|
||||||
std::stack<CallStackElement> call_stack;
|
boost::container::static_vector<CallStackElement, 16> call_stack;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u32 max_offset; // maximum program counter ever reached
|
u32 max_offset; // maximum program counter ever reached
|
||||||
|
@ -71,13 +70,13 @@ static void ProcessShaderCode(VertexShaderState& state) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!state.call_stack.empty()) {
|
if (!state.call_stack.empty()) {
|
||||||
auto& top = state.call_stack.top();
|
auto& top = state.call_stack.back();
|
||||||
if (state.program_counter - program_code.data() == top.final_address) {
|
if (state.program_counter - program_code.data() == top.final_address) {
|
||||||
state.address_registers[2] += top.loop_increment;
|
state.address_registers[2] += top.loop_increment;
|
||||||
|
|
||||||
if (top.repeat_counter-- == 0) {
|
if (top.repeat_counter-- == 0) {
|
||||||
state.program_counter = &program_code[top.return_address];
|
state.program_counter = &program_code[top.return_address];
|
||||||
state.call_stack.pop();
|
state.call_stack.pop_back();
|
||||||
} else {
|
} else {
|
||||||
state.program_counter = &program_code[top.loop_address];
|
state.program_counter = &program_code[top.loop_address];
|
||||||
}
|
}
|
||||||
|
@ -94,7 +93,8 @@ static void ProcessShaderCode(VertexShaderState& state) {
|
||||||
static auto call = [&program_code](VertexShaderState& state, u32 offset, u32 num_instructions,
|
static auto call = [&program_code](VertexShaderState& state, u32 offset, u32 num_instructions,
|
||||||
u32 return_offset, u8 repeat_count, u8 loop_increment) {
|
u32 return_offset, u8 repeat_count, u8 loop_increment) {
|
||||||
state.program_counter = &program_code[offset] - 1; // -1 to make sure when incrementing the PC we end up at the correct offset
|
state.program_counter = &program_code[offset] - 1; // -1 to make sure when incrementing the PC we end up at the correct offset
|
||||||
state.call_stack.push({ offset + num_instructions, return_offset, repeat_count, loop_increment, offset });
|
ASSERT(state.call_stack.size() < state.call_stack.capacity());
|
||||||
|
state.call_stack.push_back({ offset + num_instructions, return_offset, repeat_count, loop_increment, offset });
|
||||||
};
|
};
|
||||||
u32 binary_offset = state.program_counter - program_code.data();
|
u32 binary_offset = state.program_counter - program_code.data();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue