video_core: Add usages of ScratchBuffer
This commit is contained in:
parent
cfc34dd41d
commit
4bc2d82130
|
@ -4,9 +4,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
class MemoryManager;
|
class MemoryManager;
|
||||||
|
@ -73,8 +74,8 @@ private:
|
||||||
|
|
||||||
u32 write_offset = 0;
|
u32 write_offset = 0;
|
||||||
u32 copy_size = 0;
|
u32 copy_size = 0;
|
||||||
std::vector<u8> inner_buffer;
|
Common::ScratchBuffer<u8> inner_buffer;
|
||||||
std::vector<u8> tmp_buffer;
|
Common::ScratchBuffer<u8> tmp_buffer;
|
||||||
bool is_linear = false;
|
bool is_linear = false;
|
||||||
Registers& regs;
|
Registers& regs;
|
||||||
MemoryManager& memory_manager;
|
MemoryManager& memory_manager;
|
||||||
|
|
|
@ -184,12 +184,8 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
|
||||||
const size_t src_size =
|
const size_t src_size =
|
||||||
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
||||||
|
|
||||||
if (read_buffer.size() < src_size) {
|
read_buffer.resize(src_size);
|
||||||
read_buffer.resize(src_size);
|
write_buffer.resize(dst_size);
|
||||||
}
|
|
||||||
if (write_buffer.size() < dst_size) {
|
|
||||||
write_buffer.resize(dst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
||||||
memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size);
|
memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size);
|
||||||
|
@ -235,12 +231,8 @@ void MaxwellDMA::CopyPitchToBlockLinear() {
|
||||||
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
||||||
const size_t src_size = static_cast<size_t>(regs.pitch_in) * regs.line_count;
|
const size_t src_size = static_cast<size_t>(regs.pitch_in) * regs.line_count;
|
||||||
|
|
||||||
if (read_buffer.size() < src_size) {
|
read_buffer.resize(src_size);
|
||||||
read_buffer.resize(src_size);
|
write_buffer.resize(dst_size);
|
||||||
}
|
|
||||||
if (write_buffer.size() < dst_size) {
|
|
||||||
write_buffer.resize(dst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
||||||
if (Settings::IsGPULevelExtreme()) {
|
if (Settings::IsGPULevelExtreme()) {
|
||||||
|
@ -269,12 +261,8 @@ void MaxwellDMA::FastCopyBlockLinearToPitch() {
|
||||||
pos_x = pos_x % x_in_gob;
|
pos_x = pos_x % x_in_gob;
|
||||||
pos_y = pos_y % 8;
|
pos_y = pos_y % 8;
|
||||||
|
|
||||||
if (read_buffer.size() < src_size) {
|
read_buffer.resize(src_size);
|
||||||
read_buffer.resize(src_size);
|
write_buffer.resize(dst_size);
|
||||||
}
|
|
||||||
if (write_buffer.size() < dst_size) {
|
|
||||||
write_buffer.resize(dst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings::IsGPULevelExtreme()) {
|
if (Settings::IsGPULevelExtreme()) {
|
||||||
memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size);
|
memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size);
|
||||||
|
@ -333,12 +321,8 @@ void MaxwellDMA::CopyBlockLinearToBlockLinear() {
|
||||||
const u32 pitch = x_elements * bytes_per_pixel;
|
const u32 pitch = x_elements * bytes_per_pixel;
|
||||||
const size_t mid_buffer_size = pitch * regs.line_count;
|
const size_t mid_buffer_size = pitch * regs.line_count;
|
||||||
|
|
||||||
if (read_buffer.size() < src_size) {
|
read_buffer.resize(src_size);
|
||||||
read_buffer.resize(src_size);
|
write_buffer.resize(dst_size);
|
||||||
}
|
|
||||||
if (write_buffer.size() < dst_size) {
|
|
||||||
write_buffer.resize(dst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
intermediate_buffer.resize(mid_buffer_size);
|
intermediate_buffer.resize(mid_buffer_size);
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "video_core/engines/engine_interface.h"
|
#include "video_core/engines/engine_interface.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
@ -234,9 +236,9 @@ private:
|
||||||
MemoryManager& memory_manager;
|
MemoryManager& memory_manager;
|
||||||
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
||||||
|
|
||||||
std::vector<u8> read_buffer;
|
Common::ScratchBuffer<u8> read_buffer;
|
||||||
std::vector<u8> write_buffer;
|
Common::ScratchBuffer<u8> write_buffer;
|
||||||
std::vector<u8> intermediate_buffer;
|
Common::ScratchBuffer<u8> intermediate_buffer;
|
||||||
|
|
||||||
static constexpr std::size_t NUM_REGS = 0x800;
|
static constexpr std::size_t NUM_REGS = 0x800;
|
||||||
struct Regs {
|
struct Regs {
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
|
|
||||||
struct SwsContext;
|
struct SwsContext;
|
||||||
|
|
||||||
|
@ -49,8 +50,8 @@ private:
|
||||||
/// size does not change during a stream
|
/// size does not change during a stream
|
||||||
using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>;
|
using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>;
|
||||||
AVMallocPtr converted_frame_buffer;
|
AVMallocPtr converted_frame_buffer;
|
||||||
std::vector<u8> luma_buffer;
|
Common::ScratchBuffer<u8> luma_buffer;
|
||||||
std::vector<u8> chroma_buffer;
|
Common::ScratchBuffer<u8> chroma_buffer;
|
||||||
|
|
||||||
GPUVAddr config_struct_address{};
|
GPUVAddr config_struct_address{};
|
||||||
GPUVAddr output_surface_luma_address{};
|
GPUVAddr output_surface_luma_address{};
|
||||||
|
|
Loading…
Reference in New Issue