mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-20 09:13:22 +02:00
gl_rasterizer_cache: Use std::vector::assign in LoadGLBuffer() for the non-tiled case
resize() causes the vector to expand and zero out the added members to the vector, however we can avoid this zeroing by using assign(). Given we have the pointer to the data we want to copy, we can calculate the end pointer and directly copy the range of data without the need to perform the resize() beforehand.
This commit is contained in:
parent
557c466994
commit
434f352eb3
@ -451,16 +451,18 @@ void CachedSurface::LoadGLBuffer() {
|
||||
|
||||
ASSERT(texture_src_data);
|
||||
|
||||
gl_buffer.resize(params.width * params.height * GetGLBytesPerPixel(params.pixel_format));
|
||||
const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format);
|
||||
const u32 copy_size = params.width * params.height * bytes_per_pixel;
|
||||
|
||||
MICROPROFILE_SCOPE(OpenGL_SurfaceLoad);
|
||||
|
||||
if (!params.is_tiled) {
|
||||
const u32 bytes_per_pixel{params.GetFormatBpp() >> 3};
|
||||
const u8* const texture_src_data_end = texture_src_data + copy_size;
|
||||
|
||||
std::memcpy(gl_buffer.data(), texture_src_data,
|
||||
bytes_per_pixel * params.width * params.height);
|
||||
gl_buffer.assign(texture_src_data, texture_src_data_end);
|
||||
} else {
|
||||
gl_buffer.resize(copy_size);
|
||||
|
||||
morton_to_gl_fns[static_cast<size_t>(params.pixel_format)](
|
||||
params.width, params.block_height, params.height, gl_buffer.data(), params.addr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user