mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-25 20:41:21 -08:00
Implement linear textures (#2089)
This commit is contained in:
parent
504aafedd2
commit
e543320129
@ -125,6 +125,9 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
|
|||||||
|
|
||||||
params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format));
|
params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format));
|
||||||
params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
|
params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
|
||||||
|
if (!params.is_tiled) {
|
||||||
|
params.pitch = config.tic.Pitch();
|
||||||
|
}
|
||||||
params.unaligned_height = config.tic.Height();
|
params.unaligned_height = config.tic.Height();
|
||||||
params.target = SurfaceTargetFromTextureType(config.tic.texture_type);
|
params.target = SurfaceTargetFromTextureType(config.tic.texture_type);
|
||||||
params.identity = SurfaceClass::Uploaded;
|
params.identity = SurfaceClass::Uploaded;
|
||||||
@ -191,7 +194,13 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
|
|||||||
config.format == Tegra::RenderTargetFormat::RGBA8_SRGB;
|
config.format == Tegra::RenderTargetFormat::RGBA8_SRGB;
|
||||||
params.component_type = ComponentTypeFromRenderTarget(config.format);
|
params.component_type = ComponentTypeFromRenderTarget(config.format);
|
||||||
params.type = GetFormatType(params.pixel_format);
|
params.type = GetFormatType(params.pixel_format);
|
||||||
params.width = config.width;
|
if (params.is_tiled) {
|
||||||
|
params.width = config.width;
|
||||||
|
} else {
|
||||||
|
params.pitch = config.width;
|
||||||
|
const u32 bpp = params.GetFormatBpp() / 8;
|
||||||
|
params.width = params.pitch / bpp;
|
||||||
|
}
|
||||||
params.height = config.height;
|
params.height = config.height;
|
||||||
params.unaligned_height = config.height;
|
params.unaligned_height = config.height;
|
||||||
params.target = SurfaceTarget::Texture2D;
|
params.target = SurfaceTarget::Texture2D;
|
||||||
@ -688,9 +697,20 @@ void CachedSurface::LoadGLBuffer() {
|
|||||||
for (u32 i = 0; i < params.max_mip_level; i++)
|
for (u32 i = 0; i < params.max_mip_level; i++)
|
||||||
SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i);
|
SwizzleFunc(MortonSwizzleMode::MortonToLinear, params, gl_buffer[i], i);
|
||||||
} else {
|
} else {
|
||||||
const auto texture_src_data{Memory::GetPointer(params.addr)};
|
const u32 bpp = params.GetFormatBpp() / 8;
|
||||||
const auto texture_src_data_end{texture_src_data + params.size_in_bytes_gl};
|
const u32 copy_size = params.width * bpp;
|
||||||
gl_buffer[0].assign(texture_src_data, texture_src_data_end);
|
if (params.pitch == copy_size) {
|
||||||
|
std::memcpy(gl_buffer[0].data(), Memory::GetPointer(params.addr),
|
||||||
|
params.size_in_bytes_gl);
|
||||||
|
} else {
|
||||||
|
const u8* start = Memory::GetPointer(params.addr);
|
||||||
|
u8* write_to = gl_buffer[0].data();
|
||||||
|
for (u32 h = params.height; h > 0; h--) {
|
||||||
|
std::memcpy(write_to, start, copy_size);
|
||||||
|
start += params.pitch;
|
||||||
|
write_to += copy_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (u32 i = 0; i < params.max_mip_level; i++) {
|
for (u32 i = 0; i < params.max_mip_level; i++) {
|
||||||
ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer[i], params.pixel_format, params.MipWidth(i),
|
ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer[i], params.pixel_format, params.MipWidth(i),
|
||||||
@ -727,7 +747,19 @@ void CachedSurface::FlushGLBuffer() {
|
|||||||
|
|
||||||
SwizzleFunc(MortonSwizzleMode::LinearToMorton, params, gl_buffer[0], 0);
|
SwizzleFunc(MortonSwizzleMode::LinearToMorton, params, gl_buffer[0], 0);
|
||||||
} else {
|
} else {
|
||||||
std::memcpy(Memory::GetPointer(GetAddr()), gl_buffer[0].data(), GetSizeInBytes());
|
const u32 bpp = params.GetFormatBpp() / 8;
|
||||||
|
const u32 copy_size = params.width * bpp;
|
||||||
|
if (params.pitch == copy_size) {
|
||||||
|
std::memcpy(Memory::GetPointer(params.addr), gl_buffer[0].data(), GetSizeInBytes());
|
||||||
|
} else {
|
||||||
|
u8* start = Memory::GetPointer(params.addr);
|
||||||
|
const u8* read_to = gl_buffer[0].data();
|
||||||
|
for (u32 h = params.height; h > 0; h--) {
|
||||||
|
std::memcpy(start, read_to, copy_size);
|
||||||
|
start += params.pitch;
|
||||||
|
read_to += copy_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
@ -272,6 +273,7 @@ struct SurfaceParams {
|
|||||||
u32 height;
|
u32 height;
|
||||||
u32 depth;
|
u32 depth;
|
||||||
u32 unaligned_height;
|
u32 unaligned_height;
|
||||||
|
u32 pitch;
|
||||||
SurfaceTarget target;
|
SurfaceTarget target;
|
||||||
SurfaceClass identity;
|
SurfaceClass identity;
|
||||||
u32 max_mip_level;
|
u32 max_mip_level;
|
||||||
|
Loading…
Reference in New Issue
Block a user