diff options
| author | 2021-02-12 22:22:18 -0800 | |
|---|---|---|
| committer | 2021-02-12 22:22:18 -0800 | |
| commit | d3c7a7e7cf4bcabb171c98fe55e6e0291f8ee980 (patch) | |
| tree | 5c900d10847e1768a4951c1e6bec35f2618b5991 /src/video_core/engines | |
| parent | Merge pull request #5877 from ameerj/res-limit-usage (diff) | |
| parent | config: Make high GPU accuracy the default (diff) | |
| download | yuzu-d3c7a7e7cf4bcabb171c98fe55e6e0291f8ee980.tar.gz yuzu-d3c7a7e7cf4bcabb171c98fe55e6e0291f8ee980.tar.xz yuzu-d3c7a7e7cf4bcabb171c98fe55e6e0291f8ee980.zip | |
Merge pull request #5741 from ReinUsesLisp/new-bufcache
video_core: Reimplement the buffer cache
Diffstat (limited to 'src/video_core/engines')
| -rw-r--r-- | src/video_core/engines/fermi_2d.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/engines/fermi_2d.h | 2 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_compute.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_compute.h | 2 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_memory.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 21 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 14 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 3 |
8 files changed, 20 insertions, 32 deletions
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index a01d334ad..0f640fdae 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp | |||
| @@ -18,8 +18,8 @@ Fermi2D::Fermi2D() { | |||
| 18 | 18 | ||
| 19 | Fermi2D::~Fermi2D() = default; | 19 | Fermi2D::~Fermi2D() = default; |
| 20 | 20 | ||
| 21 | void Fermi2D::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) { | 21 | void Fermi2D::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { |
| 22 | rasterizer = &rasterizer_; | 22 | rasterizer = rasterizer_; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | 25 | void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h index 0de3280a2..c808a577d 100644 --- a/src/video_core/engines/fermi_2d.h +++ b/src/video_core/engines/fermi_2d.h | |||
| @@ -38,7 +38,7 @@ public: | |||
| 38 | ~Fermi2D(); | 38 | ~Fermi2D(); |
| 39 | 39 | ||
| 40 | /// Binds a rasterizer to this engine. | 40 | /// Binds a rasterizer to this engine. |
| 41 | void BindRasterizer(VideoCore::RasterizerInterface& rasterizer); | 41 | void BindRasterizer(VideoCore::RasterizerInterface* rasterizer); |
| 42 | 42 | ||
| 43 | /// Write the value to the register identified by method. | 43 | /// Write the value to the register identified by method. |
| 44 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; | 44 | void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; |
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index ba387506e..a9b75091e 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp | |||
| @@ -21,8 +21,8 @@ KeplerCompute::KeplerCompute(Core::System& system_, MemoryManager& memory_manage | |||
| 21 | 21 | ||
| 22 | KeplerCompute::~KeplerCompute() = default; | 22 | KeplerCompute::~KeplerCompute() = default; |
| 23 | 23 | ||
| 24 | void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) { | 24 | void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { |
| 25 | rasterizer = &rasterizer_; | 25 | rasterizer = rasterizer_; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | 28 | void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) { |
| @@ -39,7 +39,6 @@ void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_cal | |||
| 39 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { | 39 | case KEPLER_COMPUTE_REG_INDEX(data_upload): { |
| 40 | upload_state.ProcessData(method_argument, is_last_call); | 40 | upload_state.ProcessData(method_argument, is_last_call); |
| 41 | if (is_last_call) { | 41 | if (is_last_call) { |
| 42 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 43 | } | 42 | } |
| 44 | break; | 43 | break; |
| 45 | } | 44 | } |
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h index 9f0a7b76d..7c40cba38 100644 --- a/src/video_core/engines/kepler_compute.h +++ b/src/video_core/engines/kepler_compute.h | |||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | ~KeplerCompute(); | 46 | ~KeplerCompute(); |
| 47 | 47 | ||
| 48 | /// Binds a rasterizer to this engine. | 48 | /// Binds a rasterizer to this engine. |
| 49 | void BindRasterizer(VideoCore::RasterizerInterface& rasterizer); | 49 | void BindRasterizer(VideoCore::RasterizerInterface* rasterizer); |
| 50 | 50 | ||
| 51 | static constexpr std::size_t NumConstBuffers = 8; | 51 | static constexpr std::size_t NumConstBuffers = 8; |
| 52 | 52 | ||
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp index 9911140e9..560551157 100644 --- a/src/video_core/engines/kepler_memory.cpp +++ b/src/video_core/engines/kepler_memory.cpp | |||
| @@ -33,7 +33,6 @@ void KeplerMemory::CallMethod(u32 method, u32 method_argument, bool is_last_call | |||
| 33 | case KEPLERMEMORY_REG_INDEX(data): { | 33 | case KEPLERMEMORY_REG_INDEX(data): { |
| 34 | upload_state.ProcessData(method_argument, is_last_call); | 34 | upload_state.ProcessData(method_argument, is_last_call); |
| 35 | if (is_last_call) { | 35 | if (is_last_call) { |
| 36 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 37 | } | 36 | } |
| 38 | break; | 37 | break; |
| 39 | } | 38 | } |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 116ad1722..75517a4f7 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -30,8 +30,8 @@ Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_) | |||
| 30 | 30 | ||
| 31 | Maxwell3D::~Maxwell3D() = default; | 31 | Maxwell3D::~Maxwell3D() = default; |
| 32 | 32 | ||
| 33 | void Maxwell3D::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) { | 33 | void Maxwell3D::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { |
| 34 | rasterizer = &rasterizer_; | 34 | rasterizer = rasterizer_; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void Maxwell3D::InitializeRegisterDefaults() { | 37 | void Maxwell3D::InitializeRegisterDefaults() { |
| @@ -223,7 +223,6 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume | |||
| 223 | case MAXWELL3D_REG_INDEX(data_upload): | 223 | case MAXWELL3D_REG_INDEX(data_upload): |
| 224 | upload_state.ProcessData(argument, is_last_call); | 224 | upload_state.ProcessData(argument, is_last_call); |
| 225 | if (is_last_call) { | 225 | if (is_last_call) { |
| 226 | OnMemoryWrite(); | ||
| 227 | } | 226 | } |
| 228 | return; | 227 | return; |
| 229 | case MAXWELL3D_REG_INDEX(fragment_barrier): | 228 | case MAXWELL3D_REG_INDEX(fragment_barrier): |
| @@ -570,17 +569,18 @@ std::optional<u64> Maxwell3D::GetQueryResult() { | |||
| 570 | } | 569 | } |
| 571 | } | 570 | } |
| 572 | 571 | ||
| 573 | void Maxwell3D::ProcessCBBind(std::size_t stage_index) { | 572 | void Maxwell3D::ProcessCBBind(size_t stage_index) { |
| 574 | // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage. | 573 | // Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage. |
| 575 | auto& shader = state.shader_stages[stage_index]; | 574 | const auto& bind_data = regs.cb_bind[stage_index]; |
| 576 | auto& bind_data = regs.cb_bind[stage_index]; | 575 | auto& buffer = state.shader_stages[stage_index].const_buffers[bind_data.index]; |
| 577 | |||
| 578 | ASSERT(bind_data.index < Regs::MaxConstBuffers); | ||
| 579 | auto& buffer = shader.const_buffers[bind_data.index]; | ||
| 580 | |||
| 581 | buffer.enabled = bind_data.valid.Value() != 0; | 576 | buffer.enabled = bind_data.valid.Value() != 0; |
| 582 | buffer.address = regs.const_buffer.BufferAddress(); | 577 | buffer.address = regs.const_buffer.BufferAddress(); |
| 583 | buffer.size = regs.const_buffer.cb_size; | 578 | buffer.size = regs.const_buffer.cb_size; |
| 579 | |||
| 580 | const bool is_enabled = bind_data.valid.Value() != 0; | ||
| 581 | const GPUVAddr gpu_addr = is_enabled ? regs.const_buffer.BufferAddress() : 0; | ||
| 582 | const u32 size = is_enabled ? regs.const_buffer.cb_size : 0; | ||
| 583 | rasterizer->BindGraphicsUniformBuffer(stage_index, bind_data.index, gpu_addr, size); | ||
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | void Maxwell3D::ProcessCBData(u32 value) { | 586 | void Maxwell3D::ProcessCBData(u32 value) { |
| @@ -635,7 +635,6 @@ void Maxwell3D::FinishCBData() { | |||
| 635 | 635 | ||
| 636 | const u32 id = cb_data_state.id; | 636 | const u32 id = cb_data_state.id; |
| 637 | memory_manager.WriteBlock(address, cb_data_state.buffer[id].data(), size); | 637 | memory_manager.WriteBlock(address, cb_data_state.buffer[id].data(), size); |
| 638 | OnMemoryWrite(); | ||
| 639 | 638 | ||
| 640 | cb_data_state.id = null_cb_data; | 639 | cb_data_state.id = null_cb_data; |
| 641 | cb_data_state.current = null_cb_data; | 640 | cb_data_state.current = null_cb_data; |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 002d1b3f9..ffed42a29 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -55,7 +55,7 @@ public: | |||
| 55 | ~Maxwell3D(); | 55 | ~Maxwell3D(); |
| 56 | 56 | ||
| 57 | /// Binds a rasterizer to this engine. | 57 | /// Binds a rasterizer to this engine. |
| 58 | void BindRasterizer(VideoCore::RasterizerInterface& rasterizer); | 58 | void BindRasterizer(VideoCore::RasterizerInterface* rasterizer); |
| 59 | 59 | ||
| 60 | /// Register structure of the Maxwell3D engine. | 60 | /// Register structure of the Maxwell3D engine. |
| 61 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. | 61 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. |
| @@ -1314,8 +1314,7 @@ public: | |||
| 1314 | 1314 | ||
| 1315 | GPUVAddr LimitAddress() const { | 1315 | GPUVAddr LimitAddress() const { |
| 1316 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) | | 1316 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) | |
| 1317 | limit_low) + | 1317 | limit_low); |
| 1318 | 1; | ||
| 1319 | } | 1318 | } |
| 1320 | } vertex_array_limit[NumVertexArrays]; | 1319 | } vertex_array_limit[NumVertexArrays]; |
| 1321 | 1320 | ||
| @@ -1403,6 +1402,7 @@ public: | |||
| 1403 | }; | 1402 | }; |
| 1404 | 1403 | ||
| 1405 | std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages; | 1404 | std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages; |
| 1405 | |||
| 1406 | u32 current_instance = 0; ///< Current instance to be used to simulate instanced rendering. | 1406 | u32 current_instance = 0; ///< Current instance to be used to simulate instanced rendering. |
| 1407 | }; | 1407 | }; |
| 1408 | 1408 | ||
| @@ -1452,11 +1452,6 @@ public: | |||
| 1452 | return *rasterizer; | 1452 | return *rasterizer; |
| 1453 | } | 1453 | } |
| 1454 | 1454 | ||
| 1455 | /// Notify a memory write has happened. | ||
| 1456 | void OnMemoryWrite() { | ||
| 1457 | dirty.flags |= dirty.on_write_stores; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | enum class MMEDrawMode : u32 { | 1455 | enum class MMEDrawMode : u32 { |
| 1461 | Undefined, | 1456 | Undefined, |
| 1462 | Array, | 1457 | Array, |
| @@ -1478,7 +1473,6 @@ public: | |||
| 1478 | using Tables = std::array<Table, 2>; | 1473 | using Tables = std::array<Table, 2>; |
| 1479 | 1474 | ||
| 1480 | Flags flags; | 1475 | Flags flags; |
| 1481 | Flags on_write_stores; | ||
| 1482 | Tables tables{}; | 1476 | Tables tables{}; |
| 1483 | } dirty; | 1477 | } dirty; |
| 1484 | 1478 | ||
| @@ -1541,7 +1535,7 @@ private: | |||
| 1541 | void FinishCBData(); | 1535 | void FinishCBData(); |
| 1542 | 1536 | ||
| 1543 | /// Handles a write to the CB_BIND register. | 1537 | /// Handles a write to the CB_BIND register. |
| 1544 | void ProcessCBBind(std::size_t stage_index); | 1538 | void ProcessCBBind(size_t stage_index); |
| 1545 | 1539 | ||
| 1546 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. | 1540 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. |
| 1547 | void DrawArrays(); | 1541 | void DrawArrays(); |
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index ba750748c..a2f19559f 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -60,9 +60,6 @@ void MaxwellDMA::Launch() { | |||
| 60 | return; | 60 | return; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | // All copies here update the main memory, so mark all rasterizer states as invalid. | ||
| 64 | system.GPU().Maxwell3D().OnMemoryWrite(); | ||
| 65 | |||
| 66 | if (is_src_pitch && is_dst_pitch) { | 63 | if (is_src_pitch && is_dst_pitch) { |
| 67 | CopyPitchToPitch(); | 64 | CopyPitchToPitch(); |
| 68 | } else { | 65 | } else { |