diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/pica.h | 8 | ||||
| -rw-r--r-- | src/video_core/shader/shader.cpp | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 337cff8ce..4b783ac6b 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -71,7 +71,7 @@ struct Regs { | |||
| 71 | BitField<0, 24, u32> viewport_depth_range; // float24 | 71 | BitField<0, 24, u32> viewport_depth_range; // float24 |
| 72 | BitField<0, 24, u32> viewport_depth_far_plane; // float24 | 72 | BitField<0, 24, u32> viewport_depth_far_plane; // float24 |
| 73 | 73 | ||
| 74 | INSERT_PADDING_WORDS(0x1); | 74 | BitField<0, 3, u32> vs_output_total; |
| 75 | 75 | ||
| 76 | union VSOutputAttributes { | 76 | union VSOutputAttributes { |
| 77 | // Maps components of output vertex attributes to semantics | 77 | // Maps components of output vertex attributes to semantics |
| @@ -1157,8 +1157,10 @@ struct Regs { | |||
| 1157 | } | 1157 | } |
| 1158 | } input_register_map; | 1158 | } input_register_map; |
| 1159 | 1159 | ||
| 1160 | // OUTMAP_MASK, 0x28E, CODETRANSFER_END | 1160 | BitField<0, 16, u32> output_mask; |
| 1161 | INSERT_PADDING_WORDS(0x3); | 1161 | |
| 1162 | // 0x28E, CODETRANSFER_END | ||
| 1163 | INSERT_PADDING_WORDS(0x2); | ||
| 1162 | 1164 | ||
| 1163 | struct { | 1165 | struct { |
| 1164 | enum Format : u32 | 1166 | enum Format : u32 |
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 509558fc0..eb1db0778 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -121,15 +121,23 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 121 | OutputVertex ret; | 121 | OutputVertex ret; |
| 122 | // TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to | 122 | // TODO(neobrain): Under some circumstances, up to 16 attributes may be output. We need to |
| 123 | // figure out what those circumstances are and enable the remaining outputs then. | 123 | // figure out what those circumstances are and enable the remaining outputs then. |
| 124 | for (int i = 0; i < 7; ++i) { | 124 | unsigned index = 0; |
| 125 | const auto& output_register_map = g_state.regs.vs_output_attributes[i]; // TODO: Don't hardcode VS here | 125 | for (unsigned i = 0; i < 7; ++i) { |
| 126 | |||
| 127 | if (index >= g_state.regs.vs_output_total) | ||
| 128 | break; | ||
| 129 | |||
| 130 | if ((g_state.regs.vs.output_mask & (1 << i)) == 0) | ||
| 131 | continue; | ||
| 132 | |||
| 133 | const auto& output_register_map = g_state.regs.vs_output_attributes[index]; // TODO: Don't hardcode VS here | ||
| 126 | 134 | ||
| 127 | u32 semantics[4] = { | 135 | u32 semantics[4] = { |
| 128 | output_register_map.map_x, output_register_map.map_y, | 136 | output_register_map.map_x, output_register_map.map_y, |
| 129 | output_register_map.map_z, output_register_map.map_w | 137 | output_register_map.map_z, output_register_map.map_w |
| 130 | }; | 138 | }; |
| 131 | 139 | ||
| 132 | for (int comp = 0; comp < 4; ++comp) { | 140 | for (unsigned comp = 0; comp < 4; ++comp) { |
| 133 | float24* out = ((float24*)&ret) + semantics[comp]; | 141 | float24* out = ((float24*)&ret) + semantics[comp]; |
| 134 | if (semantics[comp] != Regs::VSOutputAttributes::INVALID) { | 142 | if (semantics[comp] != Regs::VSOutputAttributes::INVALID) { |
| 135 | *out = state.registers.output[i][comp]; | 143 | *out = state.registers.output[i][comp]; |
| @@ -139,10 +147,12 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 139 | memset(out, 0, sizeof(*out)); | 147 | memset(out, 0, sizeof(*out)); |
| 140 | } | 148 | } |
| 141 | } | 149 | } |
| 150 | |||
| 151 | index++; | ||
| 142 | } | 152 | } |
| 143 | 153 | ||
| 144 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing interpolation | 154 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing interpolation |
| 145 | for (int i = 0; i < 4; ++i) { | 155 | for (unsigned i = 0; i < 4; ++i) { |
| 146 | ret.color[i] = float24::FromFloat32( | 156 | ret.color[i] = float24::FromFloat32( |
| 147 | std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); | 157 | std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); |
| 148 | } | 158 | } |