summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-16 21:09:35 -0400
committerGravatar GitHub2018-03-16 21:09:35 -0400
commit0eff7752648473a1672df1d1ef9fdefd4dbde580 (patch)
tree7766b7e8f29e7674f1adf333c0f8f2a267a2999d /src
parentMerge pull request #238 from bunnei/fix-buffer-check (diff)
parentGPU: Assert that we get a 0 CODE_ADDRESS register in the 3D engine. (diff)
downloadyuzu-0eff7752648473a1672df1d1ef9fdefd4dbde580.tar.gz
yuzu-0eff7752648473a1672df1d1ef9fdefd4dbde580.tar.xz
yuzu-0eff7752648473a1672df1d1ef9fdefd4dbde580.zip
Merge pull request #239 from Subv/shaders
GPU: Added some shader-related registers.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp8
-rw-r--r--src/video_core/engines/maxwell_3d.h57
2 files changed, 63 insertions, 2 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 842c5a014..8c6d1172c 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -19,6 +19,14 @@ void Maxwell3D::WriteReg(u32 method, u32 value) {
19#define MAXWELL3D_REG_INDEX(field_name) (offsetof(Regs, field_name) / sizeof(u32)) 19#define MAXWELL3D_REG_INDEX(field_name) (offsetof(Regs, field_name) / sizeof(u32))
20 20
21 switch (method) { 21 switch (method) {
22 case MAXWELL3D_REG_INDEX(code_address.code_address_high):
23 case MAXWELL3D_REG_INDEX(code_address.code_address_low): {
24 // Note: For some reason games (like Puyo Puyo Tetris) seem to write 0 to the CODE_ADDRESS
25 // register, we do not currently know if that's intended or a bug, so we assert it lest
26 // stuff breaks in other places (like the shader address calculation).
27 ASSERT_MSG(regs.code_address.CodeAddress() == 0, "Unexpected CODE_ADDRESS register value.");
28 break;
29 }
22 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): { 30 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): {
23 DrawArrays(); 31 DrawArrays();
24 break; 32 break;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 93f7698a0..a2ad28732 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -30,9 +30,37 @@ public:
30 Sync = 1, 30 Sync = 1,
31 }; 31 };
32 32
33 static constexpr size_t MaxShaderProgram = 6;
34 enum class ShaderProgram : u32 {
35 VertexA = 0,
36 VertexB = 1,
37 TesselationControl = 2,
38 TesselationEval = 3,
39 Geometry = 4,
40 Fragment = 5,
41 };
42
43 enum class ShaderType : u32 {
44 Vertex = 0,
45 TesselationControl = 1,
46 TesselationEval = 2,
47 Geometry = 3,
48 Fragment = 4,
49 };
50
33 union { 51 union {
34 struct { 52 struct {
35 INSERT_PADDING_WORDS(0x585); 53 INSERT_PADDING_WORDS(0x582);
54 struct {
55 u32 code_address_high;
56 u32 code_address_low;
57
58 GPUVAddr CodeAddress() const {
59 return static_cast<GPUVAddr>(
60 (static_cast<GPUVAddr>(code_address_high) << 32) | code_address_low);
61 }
62 } code_address;
63 INSERT_PADDING_WORDS(1);
36 struct { 64 struct {
37 u32 vertex_end_gl; 65 u32 vertex_end_gl;
38 u32 vertex_begin_gl; 66 u32 vertex_begin_gl;
@@ -54,7 +82,28 @@ public:
54 (static_cast<GPUVAddr>(query_address_high) << 32) | query_address_low); 82 (static_cast<GPUVAddr>(query_address_high) << 32) | query_address_low);
55 } 83 }
56 } query; 84 } query;
57 INSERT_PADDING_WORDS(0x772); 85
86 INSERT_PADDING_WORDS(0x13C);
87
88 struct {
89 union {
90 BitField<0, 1, u32> enable;
91 BitField<4, 4, ShaderProgram> program;
92 };
93 u32 start_id;
94 INSERT_PADDING_WORDS(1);
95 u32 gpr_alloc;
96 ShaderType type;
97 INSERT_PADDING_WORDS(9);
98 } shader_config[6];
99
100 INSERT_PADDING_WORDS(0x5D0);
101
102 struct {
103 u32 shader_code_call;
104 u32 shader_code_args;
105 } shader_code;
106 INSERT_PADDING_WORDS(0x10);
58 }; 107 };
59 std::array<u32, NUM_REGS> reg_array; 108 std::array<u32, NUM_REGS> reg_array;
60 }; 109 };
@@ -76,7 +125,11 @@ private:
76 static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \ 125 static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \
77 "Field " #field_name " has invalid position") 126 "Field " #field_name " has invalid position")
78 127
128ASSERT_REG_POSITION(code_address, 0x582);
129ASSERT_REG_POSITION(draw, 0x585);
79ASSERT_REG_POSITION(query, 0x6C0); 130ASSERT_REG_POSITION(query, 0x6C0);
131ASSERT_REG_POSITION(shader_config[0], 0x800);
132ASSERT_REG_POSITION(shader_code, 0xE24);
80 133
81#undef ASSERT_REG_POSITION 134#undef ASSERT_REG_POSITION
82 135