From 4bc2d821300354e0d178c520b4b3520afbf8ff20 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:09:59 -0500 Subject: video_core: Add usages of ScratchBuffer --- src/video_core/host1x/vic.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/video_core/host1x') diff --git a/src/video_core/host1x/vic.h b/src/video_core/host1x/vic.h index 2b78786e8..3d9753047 100644 --- a/src/video_core/host1x/vic.h +++ b/src/video_core/host1x/vic.h @@ -4,8 +4,9 @@ #pragma once #include -#include + #include "common/common_types.h" +#include "common/scratch_buffer.h" struct SwsContext; @@ -49,8 +50,8 @@ private: /// size does not change during a stream using AVMallocPtr = std::unique_ptr; AVMallocPtr converted_frame_buffer; - std::vector luma_buffer; - std::vector chroma_buffer; + Common::ScratchBuffer luma_buffer; + Common::ScratchBuffer chroma_buffer; GPUVAddr config_struct_address{}; GPUVAddr output_surface_luma_address{}; -- cgit v1.2.3 From c6590ad07b384762fd90ee8852796ec681a69286 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Mon, 19 Dec 2022 22:40:50 -0500 Subject: scratch_buffer: Explicitly defing resize and resize_destructive functions resize keeps previous data intact when the buffer grows resize_destructive destroys the previous data when the buffer grows --- src/video_core/host1x/vic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/video_core/host1x') diff --git a/src/video_core/host1x/vic.cpp b/src/video_core/host1x/vic.cpp index ac0b7d20e..36a04e4e0 100644 --- a/src/video_core/host1x/vic.cpp +++ b/src/video_core/host1x/vic.cpp @@ -155,7 +155,7 @@ void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) { // swizzle pitch linear to block linear const u32 block_height = static_cast(config.block_linear_height_log2); const auto size = Texture::CalculateSize(true, 4, width, height, 1, block_height, 0); - luma_buffer.resize(size); + luma_buffer.resize_destructive(size); std::span frame_buff(converted_frame_buf_addr, 4 * width * height); Texture::SwizzleSubrect(luma_buffer, frame_buff, 4, width, height, 1, 0, 0, width, height, block_height, 0, width * 4); @@ -181,8 +181,8 @@ void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) { const auto stride = static_cast(frame->linesize[0]); - luma_buffer.resize(aligned_width * surface_height); - chroma_buffer.resize(aligned_width * surface_height / 2); + luma_buffer.resize_destructive(aligned_width * surface_height); + chroma_buffer.resize_destructive(aligned_width * surface_height / 2); // Populate luma buffer const u8* luma_src = frame->data[0]; -- cgit v1.2.3