mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 21:07:52 +00:00
Support compressed formats on linear textures.
This commit is contained in:
parent
1f4dfb3998
commit
773d955dfa
1 changed files with 5 additions and 2 deletions
|
@ -643,13 +643,16 @@ void CachedSurface::LoadGLBuffer() {
|
||||||
SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i);
|
SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i);
|
||||||
} else {
|
} else {
|
||||||
const u32 bpp = params.GetFormatBpp() / 8;
|
const u32 bpp = params.GetFormatBpp() / 8;
|
||||||
const u32 copy_size = params.width * bpp;
|
const u32 copy_size = (params.width * bpp + GetDefaultBlockWidth(params.pixel_format) - 1) /
|
||||||
|
GetDefaultBlockWidth(params.pixel_format);
|
||||||
if (params.pitch == copy_size) {
|
if (params.pitch == copy_size) {
|
||||||
std::memcpy(gl_buffer[0].data(), params.host_ptr, params.size_in_bytes_gl);
|
std::memcpy(gl_buffer[0].data(), params.host_ptr, params.size_in_bytes_gl);
|
||||||
} else {
|
} else {
|
||||||
|
const u32 height = (params.height + GetDefaultBlockHeight(params.pixel_format) - 1) /
|
||||||
|
GetDefaultBlockHeight(params.pixel_format);
|
||||||
const u8* start{params.host_ptr};
|
const u8* start{params.host_ptr};
|
||||||
u8* write_to = gl_buffer[0].data();
|
u8* write_to = gl_buffer[0].data();
|
||||||
for (u32 h = params.height; h > 0; h--) {
|
for (u32 h = height; h > 0; h--) {
|
||||||
std::memcpy(write_to, start, copy_size);
|
std::memcpy(write_to, start, copy_size);
|
||||||
start += params.pitch;
|
start += params.pitch;
|
||||||
write_to += copy_size;
|
write_to += copy_size;
|
||||||
|
|
Loading…
Reference in a new issue