Browse Source
Merge pull request #9559 from FernandoS27/cached-writes
Merge pull request #9559 from FernandoS27/cached-writes
VideoCore: Implement Cached Writes, use fastmem for reading GPU memory and eliminate old stuffsnce_cpp
committed by
GitHub
15 changed files with 233 additions and 53 deletions
-
2src/core/memory.cpp
-
2src/tests/video_core/buffer_base.cpp
-
1src/video_core/CMakeLists.txt
-
14src/video_core/buffer_cache/buffer_base.h
-
2src/video_core/engines/engine_upload.cpp
-
6src/video_core/engines/fermi_2d.cpp
-
1src/video_core/engines/fermi_2d.h
-
7src/video_core/engines/maxwell_3d.cpp
-
21src/video_core/engines/maxwell_dma.cpp
-
79src/video_core/invalidation_accumulator.h
-
102src/video_core/memory_manager.cpp
-
18src/video_core/memory_manager.h
-
7src/video_core/rasterizer_interface.h
-
23src/video_core/renderer_vulkan/vk_rasterizer.cpp
-
1src/video_core/renderer_vulkan/vk_rasterizer.h
@ -0,0 +1,79 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include <utility> |
|||
#include <vector> |
|||
|
|||
#include "common/common_types.h" |
|||
|
|||
namespace VideoCommon { |
|||
|
|||
class InvalidationAccumulator { |
|||
public: |
|||
InvalidationAccumulator() = default; |
|||
~InvalidationAccumulator() = default; |
|||
|
|||
void Add(GPUVAddr address, size_t size) { |
|||
const auto reset_values = [&]() { |
|||
if (has_collected) { |
|||
buffer.emplace_back(start_address, accumulated_size); |
|||
} |
|||
start_address = address; |
|||
accumulated_size = size; |
|||
last_collection = start_address + size; |
|||
}; |
|||
if (address >= start_address && address + size <= last_collection) [[likely]] { |
|||
return; |
|||
} |
|||
size = ((address + size + atomicity_size_mask) & atomicity_mask) - address; |
|||
address = address & atomicity_mask; |
|||
if (!has_collected) [[unlikely]] { |
|||
reset_values(); |
|||
has_collected = true; |
|||
return; |
|||
} |
|||
if (address != last_collection) [[unlikely]] { |
|||
reset_values(); |
|||
return; |
|||
} |
|||
accumulated_size += size; |
|||
last_collection += size; |
|||
} |
|||
|
|||
void Clear() { |
|||
buffer.clear(); |
|||
start_address = 0; |
|||
last_collection = 0; |
|||
has_collected = false; |
|||
} |
|||
|
|||
bool AnyAccumulated() const { |
|||
return has_collected; |
|||
} |
|||
|
|||
template <typename Func> |
|||
void Callback(Func&& func) { |
|||
if (!has_collected) { |
|||
return; |
|||
} |
|||
buffer.emplace_back(start_address, accumulated_size); |
|||
for (auto& [address, size] : buffer) { |
|||
func(address, size); |
|||
} |
|||
} |
|||
|
|||
private: |
|||
static constexpr size_t atomicity_bits = 5; |
|||
static constexpr size_t atomicity_size = 1ULL << atomicity_bits; |
|||
static constexpr size_t atomicity_size_mask = atomicity_size - 1; |
|||
static constexpr size_t atomicity_mask = ~atomicity_size_mask; |
|||
GPUVAddr start_address{}; |
|||
GPUVAddr last_collection{}; |
|||
size_t accumulated_size{}; |
|||
bool has_collected{}; |
|||
std::vector<std::pair<VAddr, size_t>> buffer; |
|||
}; |
|||
|
|||
} // namespace VideoCommon |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue