mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-24 00:05:48 +01:00
GLCache: Support uploading compressed textures to the GPU.
Compressed texture formats like DXT1, DXT2, DXT3, etc will use this to ease the load on the CPU.
This commit is contained in:
parent
73eaef9c05
commit
65ea52394b
@ -134,8 +134,11 @@ static void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tup
|
|||||||
cur_state.Apply();
|
cur_state.Apply();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
|
if (!format_tuple.compressed) {
|
||||||
format_tuple.format, format_tuple.type, nullptr);
|
// Only pre-create the texture for non-compressed textures.
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
|
||||||
|
format_tuple.format, format_tuple.type, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -565,9 +568,18 @@ void CachedSurface::UploadGLTexture(const MathUtil::Rectangle<u32>& rect, GLuint
|
|||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(stride));
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(stride));
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()),
|
if (tuple.compressed) {
|
||||||
static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
|
glCompressedTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format,
|
||||||
&gl_buffer[buffer_offset]);
|
static_cast<GLsizei>(rect.GetWidth()),
|
||||||
|
static_cast<GLsizei>(rect.GetHeight()), 0,
|
||||||
|
rect.GetWidth() * rect.GetHeight() *
|
||||||
|
GetGLBytesPerPixel(pixel_format) / tuple.compression_factor,
|
||||||
|
&gl_buffer[buffer_offset]);
|
||||||
|
} else {
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()),
|
||||||
|
static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
|
||||||
|
&gl_buffer[buffer_offset]);
|
||||||
|
}
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user