summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-03-17 17:08:26 -0500
committerGravatar Subv2018-03-17 18:32:57 -0500
commitccb8da15129bc04017eb5da2ee67f6cdce22e320 (patch)
tree371e67d6f7c303c7ddd9bbbbb090247bdc590a14 /src
parentGPU: Store shader constbuffer bindings in the GPU state. (diff)
downloadyuzu-ccb8da15129bc04017eb5da2ee67f6cdce22e320.tar.gz
yuzu-ccb8da15129bc04017eb5da2ee67f6cdce22e320.tar.xz
yuzu-ccb8da15129bc04017eb5da2ee67f6cdce22e320.zip
GPU: Renamed ShaderType to ShaderStage as that is less confusing.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp24
-rw-r--r--src/video_core/engines/maxwell_3d.h14
2 files changed, 19 insertions, 19 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 50153eff3..db12fc702 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -44,23 +44,23 @@ void Maxwell3D::WriteReg(u32 method, u32 value) {
44 break; 44 break;
45 } 45 }
46 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): { 46 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): {
47 ProcessCBBind(Regs::ShaderType::Vertex); 47 ProcessCBBind(Regs::ShaderStage::Vertex);
48 break; 48 break;
49 } 49 }
50 case MAXWELL3D_REG_INDEX(cb_bind[1].raw_config): { 50 case MAXWELL3D_REG_INDEX(cb_bind[1].raw_config): {
51 ProcessCBBind(Regs::ShaderType::TesselationControl); 51 ProcessCBBind(Regs::ShaderStage::TesselationControl);
52 break; 52 break;
53 } 53 }
54 case MAXWELL3D_REG_INDEX(cb_bind[2].raw_config): { 54 case MAXWELL3D_REG_INDEX(cb_bind[2].raw_config): {
55 ProcessCBBind(Regs::ShaderType::TesselationEval); 55 ProcessCBBind(Regs::ShaderStage::TesselationEval);
56 break; 56 break;
57 } 57 }
58 case MAXWELL3D_REG_INDEX(cb_bind[3].raw_config): { 58 case MAXWELL3D_REG_INDEX(cb_bind[3].raw_config): {
59 ProcessCBBind(Regs::ShaderType::Geometry); 59 ProcessCBBind(Regs::ShaderStage::Geometry);
60 break; 60 break;
61 } 61 }
62 case MAXWELL3D_REG_INDEX(cb_bind[4].raw_config): { 62 case MAXWELL3D_REG_INDEX(cb_bind[4].raw_config): {
63 ProcessCBBind(Regs::ShaderType::Fragment); 63 ProcessCBBind(Regs::ShaderStage::Fragment);
64 break; 64 break;
65 } 65 }
66 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): { 66 case MAXWELL3D_REG_INDEX(draw.vertex_end_gl): {
@@ -106,18 +106,18 @@ void Maxwell3D::SetShader(const std::vector<u32>& parameters) {
106 * [0] = Shader Program. 106 * [0] = Shader Program.
107 * [1] = Unknown, presumably the shader id. 107 * [1] = Unknown, presumably the shader id.
108 * [2] = Offset to the start of the shader, after the 0x30 bytes header. 108 * [2] = Offset to the start of the shader, after the 0x30 bytes header.
109 * [3] = Shader Type. 109 * [3] = Shader Stage.
110 * [4] = Const Buffer Address >> 8. 110 * [4] = Const Buffer Address >> 8.
111 */ 111 */
112 auto shader_program = static_cast<Regs::ShaderProgram>(parameters[0]); 112 auto shader_program = static_cast<Regs::ShaderProgram>(parameters[0]);
113 // TODO(Subv): This address is probably an offset from the CODE_ADDRESS register. 113 // TODO(Subv): This address is probably an offset from the CODE_ADDRESS register.
114 GPUVAddr address = parameters[2]; 114 GPUVAddr address = parameters[2];
115 auto shader_type = static_cast<Regs::ShaderType>(parameters[3]); 115 auto shader_stage = static_cast<Regs::ShaderStage>(parameters[3]);
116 GPUVAddr cb_address = parameters[4] << 8; 116 GPUVAddr cb_address = parameters[4] << 8;
117 117
118 auto& shader = state.shader_programs[static_cast<size_t>(shader_program)]; 118 auto& shader = state.shader_programs[static_cast<size_t>(shader_program)];
119 shader.program = shader_program; 119 shader.program = shader_program;
120 shader.type = shader_type; 120 shader.stage = shader_stage;
121 shader.address = address; 121 shader.address = address;
122 122
123 // Perform the same operations as the real macro code. 123 // Perform the same operations as the real macro code.
@@ -135,13 +135,13 @@ void Maxwell3D::SetShader(const std::vector<u32>& parameters) {
135 135
136 // Write a hardcoded 0x11 to CB_BIND, this binds the current const buffer to buffer c1[] in the 136 // Write a hardcoded 0x11 to CB_BIND, this binds the current const buffer to buffer c1[] in the
137 // shader. It's likely that these are the constants for the shader. 137 // shader. It's likely that these are the constants for the shader.
138 regs.cb_bind[static_cast<size_t>(shader_type)].valid.Assign(1); 138 regs.cb_bind[static_cast<size_t>(shader_stage)].valid.Assign(1);
139 regs.cb_bind[static_cast<size_t>(shader_type)].index.Assign(1); 139 regs.cb_bind[static_cast<size_t>(shader_stage)].index.Assign(1);
140 140
141 ProcessCBBind(shader_type); 141 ProcessCBBind(shader_stage);
142} 142}
143 143
144void Maxwell3D::ProcessCBBind(Regs::ShaderType stage) { 144void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) {
145 // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage. 145 // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage.
146 auto& shader = state.shader_stages[static_cast<size_t>(stage)]; 146 auto& shader = state.shader_stages[static_cast<size_t>(stage)];
147 auto& bind_data = regs.cb_bind[static_cast<size_t>(stage)]; 147 auto& bind_data = regs.cb_bind[static_cast<size_t>(stage)];
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 9e28d8319..98137f94b 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -38,7 +38,7 @@ public:
38 static constexpr size_t NumCBData = 16; 38 static constexpr size_t NumCBData = 16;
39 static constexpr size_t NumVertexArrays = 32; 39 static constexpr size_t NumVertexArrays = 32;
40 static constexpr size_t MaxShaderProgram = 6; 40 static constexpr size_t MaxShaderProgram = 6;
41 static constexpr size_t MaxShaderType = 5; 41 static constexpr size_t MaxShaderStage = 5;
42 // Maximum number of const buffers per shader stage. 42 // Maximum number of const buffers per shader stage.
43 static constexpr size_t MaxConstBuffers = 16; 43 static constexpr size_t MaxConstBuffers = 16;
44 44
@@ -56,7 +56,7 @@ public:
56 Fragment = 5, 56 Fragment = 5,
57 }; 57 };
58 58
59 enum class ShaderType : u32 { 59 enum class ShaderStage : u32 {
60 Vertex = 0, 60 Vertex = 0,
61 TesselationControl = 1, 61 TesselationControl = 1,
62 TesselationEval = 2, 62 TesselationEval = 2,
@@ -136,7 +136,7 @@ public:
136 u32 start_id; 136 u32 start_id;
137 INSERT_PADDING_WORDS(1); 137 INSERT_PADDING_WORDS(1);
138 u32 gpr_alloc; 138 u32 gpr_alloc;
139 ShaderType type; 139 ShaderStage type;
140 INSERT_PADDING_WORDS(9); 140 INSERT_PADDING_WORDS(9);
141 } shader_config[MaxShaderProgram]; 141 } shader_config[MaxShaderProgram];
142 142
@@ -164,7 +164,7 @@ public:
164 BitField<4, 5, u32> index; 164 BitField<4, 5, u32> index;
165 }; 165 };
166 INSERT_PADDING_WORDS(7); 166 INSERT_PADDING_WORDS(7);
167 } cb_bind[MaxShaderType]; 167 } cb_bind[MaxShaderStage];
168 168
169 INSERT_PADDING_WORDS(0x50A); 169 INSERT_PADDING_WORDS(0x50A);
170 }; 170 };
@@ -183,7 +183,7 @@ public:
183 }; 183 };
184 184
185 struct ShaderProgramInfo { 185 struct ShaderProgramInfo {
186 Regs::ShaderType type; 186 Regs::ShaderStage stage;
187 Regs::ShaderProgram program; 187 Regs::ShaderProgram program;
188 GPUVAddr address; 188 GPUVAddr address;
189 }; 189 };
@@ -192,7 +192,7 @@ public:
192 std::array<ConstBufferInfo, Regs::MaxConstBuffers> const_buffers; 192 std::array<ConstBufferInfo, Regs::MaxConstBuffers> const_buffers;
193 }; 193 };
194 194
195 std::array<ShaderStageInfo, Regs::MaxShaderType> shader_stages; 195 std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages;
196 std::array<ShaderProgramInfo, Regs::MaxShaderProgram> shader_programs; 196 std::array<ShaderProgramInfo, Regs::MaxShaderProgram> shader_programs;
197 }; 197 };
198 198
@@ -205,7 +205,7 @@ private:
205 void ProcessQueryGet(); 205 void ProcessQueryGet();
206 206
207 /// Handles a write to the CB_BIND register. 207 /// Handles a write to the CB_BIND register.
208 void ProcessCBBind(Regs::ShaderType stage); 208 void ProcessCBBind(Regs::ShaderStage stage);
209 209
210 /// Handles a write to the VERTEX_END_GL register, triggering a draw. 210 /// Handles a write to the VERTEX_END_GL register, triggering a draw.
211 void DrawArrays(); 211 void DrawArrays();