diff options
Diffstat (limited to 'src/video_core/shader/shader.cpp')
| -rw-r--r-- | src/video_core/shader/shader.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index dbad167e9..99a22c2dd 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <cmath> | 5 | #include <cmath> |
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include "common/bit_set.h" | ||
| 7 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 8 | #include "common/microprofile.h" | 9 | #include "common/microprofile.h" |
| 9 | #include "video_core/pica.h" | 10 | #include "video_core/pica.h" |
| @@ -19,22 +20,13 @@ namespace Pica { | |||
| 19 | 20 | ||
| 20 | namespace Shader { | 21 | namespace Shader { |
| 21 | 22 | ||
| 22 | OutputVertex OutputVertex::FromRegisters(Math::Vec4<float24> output_regs[16], const Regs& regs, | 23 | OutputVertex OutputVertex::FromAttributeBuffer(const Regs& regs, AttributeBuffer& input) { |
| 23 | u32 output_mask) { | ||
| 24 | // Setup output data | 24 | // Setup output data |
| 25 | OutputVertex ret; | 25 | OutputVertex ret; |
| 26 | // TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to | ||
| 27 | // figure out what those circumstances are and enable the remaining outputs then. | ||
| 28 | unsigned index = 0; | ||
| 29 | for (unsigned i = 0; i < 7; ++i) { | ||
| 30 | 26 | ||
| 31 | if (index >= regs.vs_output_total) | 27 | unsigned int num_attributes = regs.vs_output_total; |
| 32 | break; | 28 | for (unsigned int i = 0; i < num_attributes; ++i) { |
| 33 | 29 | const auto& output_register_map = regs.vs_output_attributes[i]; | |
| 34 | if ((output_mask & (1 << i)) == 0) | ||
| 35 | continue; | ||
| 36 | |||
| 37 | const auto& output_register_map = regs.vs_output_attributes[index]; | ||
| 38 | 30 | ||
| 39 | u32 semantics[4] = {output_register_map.map_x, output_register_map.map_y, | 31 | u32 semantics[4] = {output_register_map.map_x, output_register_map.map_y, |
| 40 | output_register_map.map_z, output_register_map.map_w}; | 32 | output_register_map.map_z, output_register_map.map_w}; |
| @@ -42,15 +34,13 @@ OutputVertex OutputVertex::FromRegisters(Math::Vec4<float24> output_regs[16], co | |||
| 42 | for (unsigned comp = 0; comp < 4; ++comp) { | 34 | for (unsigned comp = 0; comp < 4; ++comp) { |
| 43 | float24* out = ((float24*)&ret) + semantics[comp]; | 35 | float24* out = ((float24*)&ret) + semantics[comp]; |
| 44 | if (semantics[comp] != Regs::VSOutputAttributes::INVALID) { | 36 | if (semantics[comp] != Regs::VSOutputAttributes::INVALID) { |
| 45 | *out = output_regs[i][comp]; | 37 | *out = input.attr[i][comp]; |
| 46 | } else { | 38 | } else { |
| 47 | // Zero output so that attributes which aren't output won't have denormals in them, | 39 | // Zero output so that attributes which aren't output won't have denormals in them, |
| 48 | // which would slow us down later. | 40 | // which would slow us down later. |
| 49 | memset(out, 0, sizeof(*out)); | 41 | memset(out, 0, sizeof(*out)); |
| 50 | } | 42 | } |
| 51 | } | 43 | } |
| 52 | |||
| 53 | index++; | ||
| 54 | } | 44 | } |
| 55 | 45 | ||
| 56 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing | 46 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing |
| @@ -80,6 +70,13 @@ void UnitState::LoadInput(const Regs::ShaderConfig& config, const AttributeBuffe | |||
| 80 | } | 70 | } |
| 81 | } | 71 | } |
| 82 | 72 | ||
| 73 | void UnitState::WriteOutput(const Regs::ShaderConfig& config, AttributeBuffer& output) { | ||
| 74 | unsigned int output_i = 0; | ||
| 75 | for (unsigned int reg : Common::BitSet<u32>(config.output_mask)) { | ||
| 76 | output.attr[output_i++] = registers.output[reg]; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 83 | MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240)); | 80 | MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240)); |
| 84 | 81 | ||
| 85 | #ifdef ARCHITECTURE_x86_64 | 82 | #ifdef ARCHITECTURE_x86_64 |