summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-17 00:34:17 -0400
committerGravatar GitHub2018-03-17 00:34:17 -0400
commit516ef4f19fc46a7e482a5a56892e74c0aaa17c8e (patch)
tree0e6fa7a11330d262b3e35e16425e287eccfc4989 /src
parentMerge pull request #243 from Subv/vertex_buffer (diff)
parentGPU: Handle the SetShader method call (0xE24) and store the shader config. (diff)
downloadyuzu-516ef4f19fc46a7e482a5a56892e74c0aaa17c8e.tar.gz
yuzu-516ef4f19fc46a7e482a5a56892e74c0aaa17c8e.tar.xz
yuzu-516ef4f19fc46a7e482a5a56892e74c0aaa17c8e.zip
Merge pull request #242 from Subv/set_shader
GPU: Handle the SetShader method call (0xE24) and store the shader config.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp24
-rw-r--r--src/video_core/engines/maxwell_3d.h18
2 files changed, 38 insertions, 4 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 1b963e87e..603a2edaf 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -9,7 +9,7 @@ namespace Tegra {
9namespace Engines { 9namespace Engines {
10 10
11const std::unordered_map<u32, Maxwell3D::MethodInfo> Maxwell3D::method_handlers = { 11const std::unordered_map<u32, Maxwell3D::MethodInfo> Maxwell3D::method_handlers = {
12 {0xE24, {"PrepareShader", 5, &Maxwell3D::PrepareShader}}, 12 {0xE24, {"SetShader", 5, &Maxwell3D::SetShader}},
13}; 13};
14 14
15Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} 15Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {}
@@ -79,7 +79,27 @@ void Maxwell3D::DrawArrays() {
79 LOG_WARNING(HW_GPU, "Game requested a DrawArrays, ignoring"); 79 LOG_WARNING(HW_GPU, "Game requested a DrawArrays, ignoring");
80} 80}
81 81
82void Maxwell3D::PrepareShader(const std::vector<u32>& parameters) {} 82void Maxwell3D::SetShader(const std::vector<u32>& parameters) {
83 /**
84 * Parameters description:
85 * [0] = Shader Program.
86 * [1] = Unknown.
87 * [2] = Offset to the start of the shader, after the 0x30 bytes header.
88 * [3] = Shader Type.
89 * [4] = Shader End Address >> 8.
90 */
91 auto shader_program = static_cast<Regs::ShaderProgram>(parameters[0]);
92 // TODO(Subv): This address is probably an offset from the CODE_ADDRESS register.
93 GPUVAddr begin_address = parameters[2];
94 auto shader_type = static_cast<Regs::ShaderType>(parameters[3]);
95 GPUVAddr end_address = parameters[4] << 8;
96
97 auto& shader = state.shaders[static_cast<size_t>(shader_program)];
98 shader.program = shader_program;
99 shader.type = shader_type;
100 shader.begin_address = begin_address;
101 shader.end_address = end_address;
102}
83 103
84} // namespace Engines 104} // namespace Engines
85} // namespace Tegra 105} // namespace Tegra
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index b3f45c85b..c979d4e61 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <unordered_map> 8#include <unordered_map>
8#include <vector> 9#include <vector>
9#include "common/bit_field.h" 10#include "common/bit_field.h"
@@ -133,7 +134,7 @@ public:
133 u32 gpr_alloc; 134 u32 gpr_alloc;
134 ShaderType type; 135 ShaderType type;
135 INSERT_PADDING_WORDS(9); 136 INSERT_PADDING_WORDS(9);
136 } shader_config[6]; 137 } shader_config[MaxShaderProgram];
137 138
138 INSERT_PADDING_WORDS(0x5D0); 139 INSERT_PADDING_WORDS(0x5D0);
139 140
@@ -149,6 +150,19 @@ public:
149 150
150 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); 151 static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
151 152
153 struct State {
154 struct ShaderInfo {
155 Regs::ShaderType type;
156 Regs::ShaderProgram program;
157 GPUVAddr begin_address;
158 GPUVAddr end_address;
159 };
160
161 std::array<ShaderInfo, Regs::MaxShaderProgram> shaders;
162 };
163
164 State state;
165
152private: 166private:
153 MemoryManager& memory_manager; 167 MemoryManager& memory_manager;
154 168
@@ -159,7 +173,7 @@ private:
159 void DrawArrays(); 173 void DrawArrays();
160 174
161 /// Method call handlers 175 /// Method call handlers
162 void PrepareShader(const std::vector<u32>& parameters); 176 void SetShader(const std::vector<u32>& parameters);
163 177
164 struct MethodInfo { 178 struct MethodInfo {
165 const char* name; 179 const char* name;