From 73b4c61bdd9325778164f34a9d66649d027807b5 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Thu, 24 Mar 2022 03:40:39 +0100 Subject: [PATCH] early-access version 2596 --- README.md | 2 +- src/core/memory.cpp | 2 +- .../frontend/ir/microinstruction.cpp | 2 +- src/video_core/buffer_cache/buffer_base.h | 3 +- src/video_core/engines/maxwell_3d.cpp | 75 ------------------- src/video_core/engines/maxwell_3d.h | 18 ----- src/video_core/memory_manager.cpp | 14 ---- src/video_core/memory_manager.h | 2 - 8 files changed, 5 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index c34da8168..284592b06 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2595. +This is the source code for early-access 2596. ## Legal Notice diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 3fed51400..28d30eee2 100755 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -322,7 +322,7 @@ struct Memory::Impl { } if (Settings::IsFastmemEnabled()) { - const bool is_read_enable = !Settings::IsGPULevelExtreme() || !cached; + const bool is_read_enable = Settings::IsGPULevelHigh() || !cached; system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); } diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 504ed0b2d..4a2564f47 100755 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp @@ -327,7 +327,7 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) { } void Inst::ErasePhiOperand(size_t index) { - const auto operand_it{phi_args.begin() + static_cast(index)}; + const auto operand_it{phi_args.begin() + static_cast(index)}; phi_args.erase(operand_it); } diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h index be2113f5a..10975884b 100755 --- a/src/video_core/buffer_cache/buffer_base.h +++ b/src/video_core/buffer_cache/buffer_base.h @@ -212,7 +212,7 @@ public: void FlushCachedWrites() noexcept { flags &= ~BufferFlagBits::CachedWrites; const u64 num_words = NumWords(); - const u64* const cached_words = Array(); + u64* const cached_words = Array(); u64* const untracked_words = Array(); u64* const cpu_words = Array(); for (u64 word_index = 0; word_index < num_words; ++word_index) { @@ -220,6 +220,7 @@ public: NotifyRasterizer(word_index, untracked_words[word_index], cached_bits); untracked_words[word_index] |= cached_bits; cpu_words[word_index] |= cached_bits; + cached_words[word_index] = 0; } } diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 45bd96395..54a902f56 100755 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -2,13 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include #include #include - -#include "common/alignment.h" #include "common/assert.h" -#include "common/settings.h" #include "core/core.h" #include "core/core_timing.h" #include "video_core/dirty_flags.h" @@ -30,7 +26,6 @@ Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_) upload_state{memory_manager, regs.upload} { dirty.flags.flip(); InitializeRegisterDefaults(); - accelerated_reads = Settings::IsFastmemEnabled(); } Maxwell3D::~Maxwell3D() = default; @@ -218,9 +213,6 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume regs.index_array.count = regs.small_index.count; regs.index_array.first = regs.small_index.first; dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; - if (!Settings::IsGPULevelExtreme()) { - RecalculateVertexArrayLimit(); - } return DrawArrays(); case MAXWELL3D_REG_INDEX(topology_override): use_topology_override = true; @@ -675,71 +667,4 @@ void Maxwell3D::ProcessClearBuffers() { rasterizer->Clear(); } -void Maxwell3D::RecalculateVertexArrayLimit() { - GPUVAddr start_address = regs.index_array.StartAddress(); - auto& vn_state = vertex_num_approx_state; - if (start_address != vn_state.last_index_array_start || - vn_state.current_min_index != regs.index_array.first) { - vn_state.last_index_array_start = start_address; - vn_state.current_max_index = regs.index_array.first; - vn_state.current_min_index = regs.index_array.first; - vn_state.current_num_vertices = 0; - } - const u32 index_count = regs.index_array.first + regs.index_array.count; - if (index_count <= vn_state.current_max_index) { - return; - } - const u32 max_base = std::max(regs.index_array.first, vn_state.current_max_index); - const u32 num_indices = index_count - max_base; - const size_t size_index = regs.index_array.FormatSizeInBytes(); - const size_t expected_size = num_indices * size_index; - const size_t offset = max_base * size_index; - - auto maybe_ptr = memory_manager.GpuToHostPointer(start_address + offset); - u8* ptr; - if (accelerated_reads && maybe_ptr) { - ptr = *maybe_ptr; - } else { - vn_state.index_buffer_cache.resize(Common::DivideUp(expected_size, sizeof(u32))); - ptr = reinterpret_cast(vn_state.index_buffer_cache.data()); - memory_manager.ReadBlockUnsafe(start_address + offset, ptr, expected_size); - } - vn_state.current_max_index = index_count; - - u32 new_num_vertices{}; - switch (regs.index_array.format) { - case Regs::IndexFormat::UnsignedByte: { - std::span span{ptr, num_indices}; - const auto max = std::max_element(span.begin(), span.end()); - new_num_vertices = *max + 1; - break; - } - case Regs::IndexFormat::UnsignedShort: { - std::span span{reinterpret_cast(ptr), num_indices}; - const auto max = std::max_element(span.begin(), span.end()); - new_num_vertices = *max + 1; - break; - } - case Regs::IndexFormat::UnsignedInt: { - std::span span{reinterpret_cast(ptr), num_indices}; - const auto max = std::max_element(span.begin(), span.end()); - new_num_vertices = *max + 1; - break; - } - } - if (new_num_vertices > vn_state.current_num_vertices) { - vn_state.current_num_vertices = new_num_vertices; - for (size_t i = 0; i < Regs::NumVertexArrays; i++) { - if (!regs.vertex_array[i].enable) { - continue; - } - const u32 stride = regs.vertex_array[i].stride; - const GPUVAddr gpu_addr_begin = regs.vertex_array[i].StartAddress(); - const GPUVAddr gpu_addr_end = gpu_addr_begin + new_num_vertices * stride - 1; - regs.vertex_array_limit[i].SetAddress(gpu_addr_end); - dirty.flags[VideoCommon::Dirty::VertexBuffer0 + i] = true; - } - } -} - } // namespace Tegra::Engines diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 4c4bbb1fe..3f5b38e55 100755 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -1348,12 +1348,6 @@ public: return static_cast((static_cast(limit_high) << 32) | limit_low); } - - void SetAddress(GPUVAddr address) { - limit_low = static_cast(address); - limit_high = static_cast(address >> 32); - } - } vertex_array_limit[NumVertexArrays]; struct { @@ -1497,16 +1491,6 @@ public: Tables tables{}; } dirty; - struct VertexNumApproxState { - GPUVAddr last_index_array_start; - u32 current_max_index; - u32 current_min_index; - u32 current_num_vertices; - std::vector index_buffer_cache; - } vertex_num_approx_state; - - bool accelerated_reads{}; - private: void InitializeRegisterDefaults(); @@ -1575,8 +1559,6 @@ private: // Handles a instance drawcall from MME void StepInstance(MMEDrawMode expected_mode, u32 count); - void RecalculateVertexArrayLimit(); - /// Returns a query's value or an empty object if the value will be deferred through a cache. std::optional GetQueryResult(); diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 0a376dedb..722ebd9ad 100755 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -6,7 +6,6 @@ #include "common/alignment.h" #include "common/assert.h" -#include "common/host_memory.h" #include "common/logging/log.h" #include "core/core.h" #include "core/hle/kernel/k_page_table.h" @@ -186,19 +185,6 @@ std::optional MemoryManager::GpuToCpuAddress(GPUVAddr gpu_addr) const { return page_entry.ToAddress() + (gpu_addr & page_mask); } -std::optional MemoryManager::GpuToHostPointer(GPUVAddr gpu_addr) const { - auto cpu_addr = GpuToCpuAddress(gpu_addr); - if (!cpu_addr) { - return std::nullopt; - } - auto& device_memory = system.DeviceMemory(); - auto base = device_memory.buffer.VirtualBasePointer(); - if (!base) { - return std::nullopt; - } - return base + *cpu_addr; -} - std::optional MemoryManager::GpuToCpuAddress(GPUVAddr addr, std::size_t size) const { size_t page_index{addr >> page_bits}; const size_t page_last{(addr + size + page_size - 1) >> page_bits}; diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index 8774c405f..61bfe47c7 100755 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h @@ -76,8 +76,6 @@ public: [[nodiscard]] std::optional GpuToCpuAddress(GPUVAddr addr) const; - [[nodiscard]] std::optional GpuToHostPointer(GPUVAddr addr) const; - [[nodiscard]] std::optional GpuToCpuAddress(GPUVAddr addr, std::size_t size) const; template