summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-02-08 22:07:34 -0800
committerGravatar GitHub2017-02-08 22:07:34 -0800
commit2889372e47624e368df0d0361cb38b8100f047dd (patch)
tree183cd1cd6edb60ab566bd1fe181b712643bef30c /src/video_core/shader
parentMerge pull request #2539 from Kloen/re-killing-warnings (diff)
parentVideoCore: Move Regs to its own file (diff)
downloadyuzu-2889372e47624e368df0d0361cb38b8100f047dd.tar.gz
yuzu-2889372e47624e368df0d0361cb38b8100f047dd.tar.xz
yuzu-2889372e47624e368df0d0361cb38b8100f047dd.zip
Merge pull request #2482 from yuriks/pica-refactor
Split up monolithic Regs struct
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/shader.cpp14
-rw-r--r--src/video_core/shader/shader.h24
-rw-r--r--src/video_core/shader/shader_interpreter.cpp2
-rw-r--r--src/video_core/shader/shader_interpreter.h2
4 files changed, 21 insertions, 21 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index f5f7ea61d..c860375a1 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -7,8 +7,8 @@
7#include "common/bit_set.h" 7#include "common/bit_set.h"
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "common/microprofile.h" 9#include "common/microprofile.h"
10#include "video_core/pica.h"
11#include "video_core/pica_state.h" 10#include "video_core/pica_state.h"
11#include "video_core/regs.h"
12#include "video_core/shader/shader.h" 12#include "video_core/shader/shader.h"
13#include "video_core/shader/shader_interpreter.h" 13#include "video_core/shader/shader_interpreter.h"
14#ifdef ARCHITECTURE_x86_64 14#ifdef ARCHITECTURE_x86_64
@@ -20,7 +20,7 @@ namespace Pica {
20 20
21namespace Shader { 21namespace Shader {
22 22
23OutputVertex OutputVertex::FromAttributeBuffer(const Regs& regs, AttributeBuffer& input) { 23OutputVertex OutputVertex::FromAttributeBuffer(const RasterizerRegs& regs, AttributeBuffer& input) {
24 // Setup output data 24 // Setup output data
25 union { 25 union {
26 OutputVertex ret{}; 26 OutputVertex ret{};
@@ -33,16 +33,16 @@ OutputVertex OutputVertex::FromAttributeBuffer(const Regs& regs, AttributeBuffer
33 for (unsigned int i = 0; i < num_attributes; ++i) { 33 for (unsigned int i = 0; i < num_attributes; ++i) {
34 const auto& output_register_map = regs.vs_output_attributes[i]; 34 const auto& output_register_map = regs.vs_output_attributes[i];
35 35
36 Regs::VSOutputAttributes::Semantic semantics[4] = { 36 RasterizerRegs::VSOutputAttributes::Semantic semantics[4] = {
37 output_register_map.map_x, output_register_map.map_y, output_register_map.map_z, 37 output_register_map.map_x, output_register_map.map_y, output_register_map.map_z,
38 output_register_map.map_w}; 38 output_register_map.map_w};
39 39
40 for (unsigned comp = 0; comp < 4; ++comp) { 40 for (unsigned comp = 0; comp < 4; ++comp) {
41 Regs::VSOutputAttributes::Semantic semantic = semantics[comp]; 41 RasterizerRegs::VSOutputAttributes::Semantic semantic = semantics[comp];
42 float24* out = &vertex_slots[semantic]; 42 float24* out = &vertex_slots[semantic];
43 if (semantic < vertex_slots.size()) { 43 if (semantic < vertex_slots.size()) {
44 *out = input.attr[i][comp]; 44 *out = input.attr[i][comp];
45 } else if (semantic != Regs::VSOutputAttributes::INVALID) { 45 } else if (semantic != RasterizerRegs::VSOutputAttributes::INVALID) {
46 LOG_ERROR(HW_GPU, "Invalid/unknown semantic id: %u", (unsigned int)semantic); 46 LOG_ERROR(HW_GPU, "Invalid/unknown semantic id: %u", (unsigned int)semantic);
47 } 47 }
48 } 48 }
@@ -66,7 +66,7 @@ OutputVertex OutputVertex::FromAttributeBuffer(const Regs& regs, AttributeBuffer
66 return ret; 66 return ret;
67} 67}
68 68
69void UnitState::LoadInput(const Regs::ShaderConfig& config, const AttributeBuffer& input) { 69void UnitState::LoadInput(const ShaderRegs& config, const AttributeBuffer& input) {
70 const unsigned max_attribute = config.max_input_attribute_index; 70 const unsigned max_attribute = config.max_input_attribute_index;
71 71
72 for (unsigned attr = 0; attr <= max_attribute; ++attr) { 72 for (unsigned attr = 0; attr <= max_attribute; ++attr) {
@@ -75,7 +75,7 @@ void UnitState::LoadInput(const Regs::ShaderConfig& config, const AttributeBuffe
75 } 75 }
76} 76}
77 77
78void UnitState::WriteOutput(const Regs::ShaderConfig& config, AttributeBuffer& output) { 78void UnitState::WriteOutput(const ShaderRegs& config, AttributeBuffer& output) {
79 unsigned int output_i = 0; 79 unsigned int output_i = 0;
80 for (unsigned int reg : Common::BitSet<u32>(config.output_mask)) { 80 for (unsigned int reg : Common::BitSet<u32>(config.output_mask)) {
81 output.attr[output_i++] = registers.output[reg]; 81 output.attr[output_i++] = registers.output[reg];
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h
index b188d3edf..d52682479 100644
--- a/src/video_core/shader/shader.h
+++ b/src/video_core/shader/shader.h
@@ -12,8 +12,8 @@
12#include "common/common_funcs.h" 12#include "common/common_funcs.h"
13#include "common/common_types.h" 13#include "common/common_types.h"
14#include "common/vector_math.h" 14#include "common/vector_math.h"
15#include "video_core/pica.h"
16#include "video_core/pica_types.h" 15#include "video_core/pica_types.h"
16#include "video_core/regs.h"
17 17
18using nihstro::RegisterType; 18using nihstro::RegisterType;
19using nihstro::SourceRegister; 19using nihstro::SourceRegister;
@@ -39,19 +39,19 @@ struct OutputVertex {
39 INSERT_PADDING_WORDS(1); 39 INSERT_PADDING_WORDS(1);
40 Math::Vec2<float24> tc2; 40 Math::Vec2<float24> tc2;
41 41
42 static OutputVertex FromAttributeBuffer(const Regs& regs, AttributeBuffer& output); 42 static OutputVertex FromAttributeBuffer(const RasterizerRegs& regs, AttributeBuffer& output);
43}; 43};
44#define ASSERT_POS(var, pos) \ 44#define ASSERT_POS(var, pos) \
45 static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \ 45 static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \
46 "offset.") 46 "offset.")
47ASSERT_POS(pos, Regs::VSOutputAttributes::POSITION_X); 47ASSERT_POS(pos, RasterizerRegs::VSOutputAttributes::POSITION_X);
48ASSERT_POS(quat, Regs::VSOutputAttributes::QUATERNION_X); 48ASSERT_POS(quat, RasterizerRegs::VSOutputAttributes::QUATERNION_X);
49ASSERT_POS(color, Regs::VSOutputAttributes::COLOR_R); 49ASSERT_POS(color, RasterizerRegs::VSOutputAttributes::COLOR_R);
50ASSERT_POS(tc0, Regs::VSOutputAttributes::TEXCOORD0_U); 50ASSERT_POS(tc0, RasterizerRegs::VSOutputAttributes::TEXCOORD0_U);
51ASSERT_POS(tc1, Regs::VSOutputAttributes::TEXCOORD1_U); 51ASSERT_POS(tc1, RasterizerRegs::VSOutputAttributes::TEXCOORD1_U);
52ASSERT_POS(tc0_w, Regs::VSOutputAttributes::TEXCOORD0_W); 52ASSERT_POS(tc0_w, RasterizerRegs::VSOutputAttributes::TEXCOORD0_W);
53ASSERT_POS(view, Regs::VSOutputAttributes::VIEW_X); 53ASSERT_POS(view, RasterizerRegs::VSOutputAttributes::VIEW_X);
54ASSERT_POS(tc2, Regs::VSOutputAttributes::TEXCOORD2_U); 54ASSERT_POS(tc2, RasterizerRegs::VSOutputAttributes::TEXCOORD2_U);
55#undef ASSERT_POS 55#undef ASSERT_POS
56static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD"); 56static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD");
57static_assert(sizeof(OutputVertex) == 24 * sizeof(float), "OutputVertex has invalid size"); 57static_assert(sizeof(OutputVertex) == 24 * sizeof(float), "OutputVertex has invalid size");
@@ -116,9 +116,9 @@ struct UnitState {
116 * @param config Shader configuration registers corresponding to the unit. 116 * @param config Shader configuration registers corresponding to the unit.
117 * @param input Attribute buffer to load into the input registers. 117 * @param input Attribute buffer to load into the input registers.
118 */ 118 */
119 void LoadInput(const Regs::ShaderConfig& config, const AttributeBuffer& input); 119 void LoadInput(const ShaderRegs& config, const AttributeBuffer& input);
120 120
121 void WriteOutput(const Regs::ShaderConfig& config, AttributeBuffer& output); 121 void WriteOutput(const ShaderRegs& config, AttributeBuffer& output);
122}; 122};
123 123
124struct ShaderSetup { 124struct ShaderSetup {
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index 81522b8f5..f4d1c46c5 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -669,7 +669,7 @@ void InterpreterEngine::Run(const ShaderSetup& setup, UnitState& state) const {
669 669
670DebugData<true> InterpreterEngine::ProduceDebugInfo(const ShaderSetup& setup, 670DebugData<true> InterpreterEngine::ProduceDebugInfo(const ShaderSetup& setup,
671 const AttributeBuffer& input, 671 const AttributeBuffer& input,
672 const Regs::ShaderConfig& config) const { 672 const ShaderRegs& config) const {
673 UnitState state; 673 UnitState state;
674 DebugData<true> debug_data; 674 DebugData<true> debug_data;
675 675
diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h
index d7a61e122..5682b3a39 100644
--- a/src/video_core/shader/shader_interpreter.h
+++ b/src/video_core/shader/shader_interpreter.h
@@ -23,7 +23,7 @@ public:
23 * @return Debug information for this shader with regards to the given vertex 23 * @return Debug information for this shader with regards to the given vertex
24 */ 24 */
25 DebugData<true> ProduceDebugInfo(const ShaderSetup& setup, const AttributeBuffer& input, 25 DebugData<true> ProduceDebugInfo(const ShaderSetup& setup, const AttributeBuffer& input,
26 const Regs::ShaderConfig& config) const; 26 const ShaderRegs& config) const;
27}; 27};
28 28
29} // namespace 29} // namespace