summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Subv2018-03-18 15:19:47 -0500
committerGravatar Subv2018-03-18 15:23:24 -0500
commit85d820b1b45396a593e30b7b267ac2001c4f82b7 (patch)
tree96d1a0f5e6433a9de674c1280625045cc97d2b5e /src/video_core
parentGPU: Move the GPU's class constructor and destructors to a cpp file. (diff)
downloadyuzu-85d820b1b45396a593e30b7b267ac2001c4f82b7.tar.gz
yuzu-85d820b1b45396a593e30b7b267ac2001c4f82b7.tar.xz
yuzu-85d820b1b45396a593e30b7b267ac2001c4f82b7.zip
GPU: Handle writes to the CB_DATA method.
Writing to this method will cause the written value to be stored in the currently-set ConstBuffer plus CB_POS. This method is usually used to upload uniforms or other shader-visible data.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp36
-rw-r--r--src/video_core/engines/maxwell_3d.h3
2 files changed, 39 insertions, 0 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 49a138c1d..9985e0d50 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -83,6 +83,25 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) {
83 ASSERT_MSG(regs.code_address.CodeAddress() == 0, "Unexpected CODE_ADDRESS register value."); 83 ASSERT_MSG(regs.code_address.CodeAddress() == 0, "Unexpected CODE_ADDRESS register value.");
84 break; 84 break;
85 } 85 }
86 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[0]):
87 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[1]):
88 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[2]):
89 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[3]):
90 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[4]):
91 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[5]):
92 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[6]):
93 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[7]):
94 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[8]):
95 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[9]):
96 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[10]):
97 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[11]):
98 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[12]):
99 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[13]):
100 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[14]):
101 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[15]): {
102 ProcessCBData(value);
103 break;
104 }
86 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): { 105 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): {
87 ProcessCBBind(Regs::ShaderStage::Vertex); 106 ProcessCBBind(Regs::ShaderStage::Vertex);
88 break; 107 break;
@@ -194,5 +213,22 @@ void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) {
194 buffer.size = regs.const_buffer.cb_size; 213 buffer.size = regs.const_buffer.cb_size;
195} 214}
196 215
216void Maxwell3D::ProcessCBData(u32 value) {
217 // Write the input value to the current const buffer at the current position.
218 GPUVAddr buffer_address = regs.const_buffer.BufferAddress();
219 ASSERT(buffer_address != 0);
220
221 // Don't allow writing past the end of the buffer.
222 ASSERT(regs.const_buffer.cb_pos + sizeof(u32) <= regs.const_buffer.cb_size);
223
224 VAddr address =
225 memory_manager.PhysicalToVirtualAddress(buffer_address + regs.const_buffer.cb_pos);
226
227 Memory::Write32(address, value);
228
229 // Increment the current buffer position.
230 regs.const_buffer.cb_pos = regs.const_buffer.cb_pos + 4;
231}
232
197} // namespace Engines 233} // namespace Engines
198} // namespace Tegra 234} // namespace Tegra
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 05820a21e..93b42b53c 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -218,6 +218,9 @@ private:
218 /// Handles a write to the QUERY_GET register. 218 /// Handles a write to the QUERY_GET register.
219 void ProcessQueryGet(); 219 void ProcessQueryGet();
220 220
221 /// Handles a write to the CB_DATA[i] register.
222 void ProcessCBData(u32 value);
223
221 /// Handles a write to the CB_BIND register. 224 /// Handles a write to the CB_BIND register.
222 void ProcessCBBind(Regs::ShaderStage stage); 225 void ProcessCBBind(Regs::ShaderStage stage);
223 226