From 7bea39b39e9978ca8461adf68a2c28535719c48e Mon Sep 17 00:00:00 2001 From: iwubcode Date: Fri, 27 Jan 2023 18:46:53 -0600 Subject: VideoBackends: add a way to load data into a specific level AND layer, default to layer 0 --- Source/Core/VideoBackends/OGL/OGLTexture.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/OGLTexture.cpp') diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp index 8c1b14cd08..68d9009ac6 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp +++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp @@ -221,11 +221,14 @@ void OGLTexture::ResolveFromTexture(const AbstractTexture* src, } void OGLTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer, - size_t buffer_size) + size_t buffer_size, u32 layer) { if (level >= m_config.levels) PanicAlertFmt("Texture only has {} levels, can't update level {}", m_config.levels, level); + if (layer >= m_config.layers) + PanicAlertFmt("Texture only has {} layer, can't update layer {}", m_config.layers, layer); + const auto expected_width = std::max(1U, m_config.width >> level); const auto expected_height = std::max(1U, m_config.height >> level); if (width != expected_width || height != expected_height) @@ -246,7 +249,7 @@ void OGLTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8 { if (g_ogl_config.bSupportsTextureStorage) { - glCompressedTexSubImage3D(target, level, 0, 0, 0, width, height, 1, gl_internal_format, + glCompressedTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_internal_format, static_cast(buffer_size), buffer); } else @@ -261,7 +264,7 @@ void OGLTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8 GLenum gl_type = GetGLTypeForTextureFormat(m_config.format); if (g_ogl_config.bSupportsTextureStorage) { - glTexSubImage3D(target, level, 0, 0, 0, width, height, 1, gl_format, gl_type, buffer); + glTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_format, gl_type, buffer); } else { -- cgit v1.2.3