summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-07-12 09:25:47 -0400
committerGravatar FernandoS272019-07-17 17:29:50 -0400
commit0d3db58657ce5352d90a70ee8d6c0334d9119366 (patch)
treee4e95780f6c5a050a8fb0a4b4d1f6af94dad3a16 /src
parentMaxwell3D: Rework the dirty system to be more consistant and scaleable (diff)
downloadyuzu-0d3db58657ce5352d90a70ee8d6c0334d9119366.tar.gz
yuzu-0d3db58657ce5352d90a70ee8d6c0334d9119366.tar.xz
yuzu-0d3db58657ce5352d90a70ee8d6c0334d9119366.zip
Maxwell3D: Rework CBData Upload
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp42
-rw-r--r--src/video_core/engines/maxwell_3d.h11
2 files changed, 45 insertions, 8 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index a55915fd3..7d3a550f8 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -183,6 +183,14 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
183 183
184 const u32 method = method_call.method; 184 const u32 method = method_call.method;
185 185
186 if (method == cb_data_state.current) {
187 regs.reg_array[method] = method_call.argument;
188 ProcessCBData(method_call.argument);
189 return;
190 } else if (cb_data_state.current != null_cb_data) {
191 FinishCBData();
192 }
193
186 // It is an error to write to a register other than the current macro's ARG register before it 194 // It is an error to write to a register other than the current macro's ARG register before it
187 // has finished execution. 195 // has finished execution.
188 if (executing_macro != 0) { 196 if (executing_macro != 0) {
@@ -259,7 +267,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
259 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[13]): 267 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[13]):
260 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[14]): 268 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[14]):
261 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[15]): { 269 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[15]): {
262 ProcessCBData(method_call.argument); 270 StartCBData(method);
263 break; 271 break;
264 } 272 }
265 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): { 273 case MAXWELL3D_REG_INDEX(cb_bind[0].raw_config): {
@@ -449,21 +457,39 @@ void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) {
449} 457}
450 458
451void Maxwell3D::ProcessCBData(u32 value) { 459void Maxwell3D::ProcessCBData(u32 value) {
460 const u32 id = cb_data_state.id;
461 cb_data_state.buff[id][cb_data_state.counter] = value;
462 // Increment the current buffer position.
463 regs.const_buffer.cb_pos = regs.const_buffer.cb_pos + 4;
464 cb_data_state.counter++;
465}
466
467void Maxwell3D::StartCBData(u32 method) {
468 constexpr u32 first_cb_data = MAXWELL3D_REG_INDEX(const_buffer.cb_data[0]);
469 cb_data_state.start_pos = regs.const_buffer.cb_pos;
470 cb_data_state.id = method - first_cb_data;
471 cb_data_state.current = method;
472 cb_data_state.counter = 0;
473 ProcessCBData(regs.const_buffer.cb_data[cb_data_state.id]);
474}
475
476void Maxwell3D::FinishCBData() {
452 // Write the input value to the current const buffer at the current position. 477 // Write the input value to the current const buffer at the current position.
453 const GPUVAddr buffer_address = regs.const_buffer.BufferAddress(); 478 const GPUVAddr buffer_address = regs.const_buffer.BufferAddress();
454 ASSERT(buffer_address != 0); 479 ASSERT(buffer_address != 0);
455 480
456 // Don't allow writing past the end of the buffer. 481 // Don't allow writing past the end of the buffer.
457 ASSERT(regs.const_buffer.cb_pos + sizeof(u32) <= regs.const_buffer.cb_size); 482 ASSERT(regs.const_buffer.cb_pos <= regs.const_buffer.cb_size);
458 483
459 const GPUVAddr address{buffer_address + regs.const_buffer.cb_pos}; 484 const GPUVAddr address{buffer_address + cb_data_state.start_pos};
485 const std::size_t size = regs.const_buffer.cb_pos - cb_data_state.start_pos;
460 486
461 u8* ptr{memory_manager.GetPointer(address)}; 487 const u32 id = cb_data_state.id;
462 rasterizer.InvalidateRegion(ToCacheAddr(ptr), sizeof(u32)); 488 memory_manager.WriteBlock(address, cb_data_state.buff[id].data(), size);
463 memory_manager.Write<u32>(address, value); 489 dirty.ResetRenderTargets();
464 490
465 // Increment the current buffer position. 491 cb_data_state.id = null_cb_data;
466 regs.const_buffer.cb_pos = regs.const_buffer.cb_pos + 4; 492 cb_data_state.current = null_cb_data;
467} 493}
468 494
469Texture::TICEntry Maxwell3D::GetTICEntry(u32 tic_index) const { 495Texture::TICEntry Maxwell3D::GetTICEntry(u32 tic_index) const {
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 84e6ca145..318078f36 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1244,6 +1244,15 @@ private:
1244 1244
1245 Upload::State upload_state; 1245 Upload::State upload_state;
1246 1246
1247 static constexpr u32 null_cb_data = 0xFFFFFFFF;
1248 struct {
1249 std::array<std::array<u32, 0x4000>, 16> buff;
1250 u32 current{null_cb_data};
1251 u32 id{null_cb_data};
1252 u32 start_pos{};
1253 u32 counter{};
1254 } cb_data_state;
1255
1247 /// Retrieves information about a specific TIC entry from the TIC buffer. 1256 /// Retrieves information about a specific TIC entry from the TIC buffer.
1248 Texture::TICEntry GetTICEntry(u32 tic_index) const; 1257 Texture::TICEntry GetTICEntry(u32 tic_index) const;
1249 1258
@@ -1275,7 +1284,9 @@ private:
1275 void ProcessSyncPoint(); 1284 void ProcessSyncPoint();
1276 1285
1277 /// Handles a write to the CB_DATA[i] register. 1286 /// Handles a write to the CB_DATA[i] register.
1287 void StartCBData(u32 method);
1278 void ProcessCBData(u32 value); 1288 void ProcessCBData(u32 value);
1289 void FinishCBData();
1279 1290
1280 /// Handles a write to the CB_BIND register. 1291 /// Handles a write to the CB_BIND register.
1281 void ProcessCBBind(Regs::ShaderStage stage); 1292 void ProcessCBBind(Regs::ShaderStage stage);