summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/OGLTexture.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2023-07-21 19:09:40 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2023-07-21 19:09:40 -0500
commite892b7f1ac426fdc8a3ac1fa28026b86cc06279b (patch)
treecc63449c3ab8ff924a39f23624bbaa9efddd3279 /Source/Core/VideoBackends/OGL/OGLTexture.cpp
parent2764978bebce9cedf0e329c320951ff0508f7139 (diff)
VideoBackends: add support for cube maps for OGL, Vulkan, and D3D
Diffstat (limited to 'Source/Core/VideoBackends/OGL/OGLTexture.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/OGLTexture.cpp57
1 files changed, 47 insertions, 10 deletions
diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp
index f8894a365b..70c38d14ff 100644
--- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp
+++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp
@@ -140,7 +140,11 @@ OGLTexture::OGLTexture(const TextureConfig& tex_config, std::string_view name)
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, m_config.levels - 1);
GLenum gl_internal_format = GetGLInternalFormatForTextureFormat(m_config.format, true);
- if (tex_config.IsMultisampled())
+ if (g_ogl_config.bSupportsTextureStorage && m_config.IsCubeMap())
+ {
+ glTexStorage2D(target, m_config.levels, gl_internal_format, m_config.width, m_config.height);
+ }
+ else if (tex_config.IsMultisampled())
{
ASSERT(g_ogl_config.bSupportsMSAA);
if (g_ogl_config.SupportedMultisampleTexStorage != MultisampleTexStorageType::TexStorageNone)
@@ -267,29 +271,62 @@ void OGLTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8
GLenum gl_internal_format = GetGLInternalFormatForTextureFormat(m_config.format, false);
if (IsCompressedFormat(m_config.format))
{
- if (g_ogl_config.bSupportsTextureStorage)
+ if (m_config.IsCubeMap())
{
- glCompressedTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_internal_format,
- static_cast<GLsizei>(buffer_size), buffer);
+ if (g_ogl_config.bSupportsTextureStorage)
+ {
+ glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, level, 0, 0, width,
+ height, gl_internal_format, static_cast<GLsizei>(buffer_size),
+ buffer);
+ }
+ else
+ {
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, level, gl_internal_format,
+ width, height, 0, static_cast<GLsizei>(buffer_size), buffer);
+ }
}
else
{
- glCompressedTexImage3D(target, level, gl_internal_format, width, height, 1, 0,
- static_cast<GLsizei>(buffer_size), buffer);
+ if (g_ogl_config.bSupportsTextureStorage)
+ {
+ glCompressedTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_internal_format,
+ static_cast<GLsizei>(buffer_size), buffer);
+ }
+ else
+ {
+ glCompressedTexImage3D(target, level, gl_internal_format, width, height, 1, 0,
+ static_cast<GLsizei>(buffer_size), buffer);
+ }
}
}
else
{
GLenum gl_format = GetGLFormatForTextureFormat(m_config.format);
GLenum gl_type = GetGLTypeForTextureFormat(m_config.format);
- if (g_ogl_config.bSupportsTextureStorage)
+ if (m_config.IsCubeMap())
{
- glTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_format, gl_type, buffer);
+ if (g_ogl_config.bSupportsTextureStorage)
+ {
+ glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, level, 0, 0, width, height,
+ gl_format, gl_type, buffer);
+ }
+ else
+ {
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, level, gl_internal_format, width,
+ height, 0, gl_format, gl_type, buffer);
+ }
}
else
{
- glTexImage3D(target, level, gl_internal_format, width, height, 1, 0, gl_format, gl_type,
- buffer);
+ if (g_ogl_config.bSupportsTextureStorage)
+ {
+ glTexSubImage3D(target, level, 0, 0, layer, width, height, 1, gl_format, gl_type, buffer);
+ }
+ else
+ {
+ glTexImage3D(target, level, gl_internal_format, width, height, 1, 0, gl_format, gl_type,
+ buffer);
+ }
}
}