summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2015-01-02 21:40:09 +0100
committerarchshift <admin@archshift.com>2015-01-13 00:47:21 +0100
commit2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f (patch)
treec01a4a23bce14590df298ca24c7b3e9f9fcba8c2 /src/video_core
parentMerge pull request #452 from darkf/mingwagain (diff)
downloadyuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar.gz
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar.bz2
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar.lz
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar.xz
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.tar.zst
yuzu-2b9a9a45b7412bd6ec2aca41d0721d8f938a5e4f.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/vertex_shader.cpp75
1 files changed, 52 insertions, 23 deletions
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp
index ff825e2e1..0c4827507 100644
--- a/src/video_core/vertex_shader.cpp
+++ b/src/video_core/vertex_shader.cpp
@@ -349,12 +349,44 @@ static void ProcessShaderCode(VertexShaderState& state) {
break;
}
default:
+ {
+ static auto evaluate_condition = [](const VertexShaderState& state, bool refx, bool refy, Instruction::FlowControlType flow_control) {
+ bool results[2] = { refx == state.conditional_code[0],
+ refy == state.conditional_code[1] };
+
+ switch (flow_control.op) {
+ case flow_control.Or:
+ return results[0] || results[1];
+
+ case flow_control.And:
+ return results[0] && results[1];
+
+ case flow_control.JustX:
+ return results[0];
+
+ case flow_control.JustY:
+ return results[1];
+ }
+ };
+
// Handle each instruction on its own
switch (instr.opcode) {
case Instruction::OpCode::END:
exit_loop = true;
break;
+ case Instruction::OpCode::JMPC:
+ if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy, instr.flow_control)) {
+ state.program_counter = &shader_memory[instr.flow_control.dest_offset] - 1;
+ }
+ break;
+
+ case Instruction::OpCode::JMPU:
+ if (shader_uniforms.b[instr.flow_control.bool_uniform_id]) {
+ state.program_counter = &shader_memory[instr.flow_control.dest_offset] - 1;
+ }
+ break;
+
case Instruction::OpCode::CALL:
call(state,
instr.flow_control.dest_offset,
@@ -362,6 +394,24 @@ static void ProcessShaderCode(VertexShaderState& state) {
binary_offset + 1);
break;
+ case Instruction::OpCode::CALLU:
+ if (shader_uniforms.b[instr.flow_control.bool_uniform_id]) {
+ call(state,
+ instr.flow_control.dest_offset,
+ instr.flow_control.num_instructions,
+ binary_offset + 1);
+ }
+ break;
+
+ case Instruction::OpCode::CALLC:
+ if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy, instr.flow_control)) {
+ call(state,
+ instr.flow_control.dest_offset,
+ instr.flow_control.num_instructions,
+ binary_offset + 1);
+ }
+ break;
+
case Instruction::OpCode::NOP:
break;
@@ -384,29 +434,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
{
// TODO: Do we need to consider swizzlers here?
- auto flow_control = instr.flow_control;
- bool results[3] = { (bool)flow_control.refx == state.conditional_code[0],
- (bool)flow_control.refy == state.conditional_code[1] };
-
- switch (flow_control.op) {
- case flow_control.Or:
- results[2] = results[0] || results[1];
- break;
-
- case flow_control.And:
- results[2] = results[0] && results[1];
- break;
-
- case flow_control.JustX:
- results[2] = results[0];
- break;
-
- case flow_control.JustY:
- results[2] = results[1];
- break;
- }
-
- if (results[2]) {
+ if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy, instr.flow_control)) {
call(state,
binary_offset + 1,
instr.flow_control.dest_offset - binary_offset - 1,
@@ -429,6 +457,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
break;
}
+ }
++state.program_counter;