summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-09-14 18:17:38 +0200
committerbunnei <bunneidev@gmail.com>2018-09-30 20:31:58 +0200
commited2e0e85c962c611af0aa6c929a4e56807b6563f (patch)
tree8447329f30b12fdab6b1cc79258d7cbd00680208
parentgl_rasterizer_cache: Implement LoadGLBuffer for Texture2DArray. (diff)
downloadyuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar.gz
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar.bz2
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar.lz
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar.xz
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.tar.zst
yuzu-ed2e0e85c962c611af0aa6c929a4e56807b6563f.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp35
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h2
2 files changed, 36 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 022561d43..bd4330327 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -60,6 +60,9 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
case SurfaceTarget::Texture2D:
params.depth = 1;
break;
+ case SurfaceTarget::TextureCubemap:
+ params.depth = config.tic.Depth() * 6;
+ break;
case SurfaceTarget::Texture3D:
params.depth = config.tic.Depth();
break;
@@ -562,6 +565,7 @@ CachedSurface::CachedSurface(const SurfaceParams& params)
rect.GetWidth());
break;
case SurfaceParams::SurfaceTarget::Texture2D:
+ case SurfaceParams::SurfaceTarget::TextureCubemap:
glTexStorage2D(SurfaceTargetToGL(params.target), 1, format_tuple.internal_format,
rect.GetWidth(), rect.GetHeight());
break;
@@ -680,6 +684,7 @@ void CachedSurface::LoadGLBuffer() {
// Pass impl. to the fallback code below
break;
case SurfaceParams::SurfaceTarget::Texture2DArray:
+ case SurfaceParams::SurfaceTarget::TextureCubemap:
for (std::size_t index = 0; index < params.depth; ++index) {
const std::size_t offset{index * copy_size};
morton_to_gl_fns[static_cast<std::size_t>(params.pixel_format)](
@@ -724,7 +729,7 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
// Load data from memory to the surface
const GLint x0 = static_cast<GLint>(rect.left);
const GLint y0 = static_cast<GLint>(rect.bottom);
- const std::size_t buffer_offset =
+ std::size_t buffer_offset =
static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width +
static_cast<std::size_t>(x0)) *
GetGLBytesPerPixel(params.pixel_format);
@@ -763,6 +768,16 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
static_cast<GLsizei>(params.depth), 0,
static_cast<GLsizei>(params.size_in_bytes_total), &gl_buffer[buffer_offset]);
break;
+ case SurfaceParams::SurfaceTarget::TextureCubemap:
+ for (std::size_t face = 0; face < params.depth; ++face) {
+ glCompressedTexImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face),
+ 0, tuple.internal_format, static_cast<GLsizei>(params.width),
+ static_cast<GLsizei>(params.height), 0,
+ static_cast<GLsizei>(params.size_in_bytes_2d),
+ &gl_buffer[buffer_offset]);
+ buffer_offset += params.size_in_bytes_2d;
+ }
+ break;
default:
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
static_cast<u32>(params.target));
@@ -793,6 +808,15 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format,
tuple.type, &gl_buffer[buffer_offset]);
break;
+ case SurfaceParams::SurfaceTarget::TextureCubemap:
+ for (std::size_t face = 0; face < params.depth; ++face) {
+ glTexSubImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, x0,
+ y0, static_cast<GLsizei>(rect.GetWidth()),
+ static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
+ &gl_buffer[buffer_offset]);
+ buffer_offset += params.size_in_bytes_2d;
+ }
+ break;
default:
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
static_cast<u32>(params.target));
@@ -989,6 +1013,15 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
static_cast<GLsizei>(new_params.depth), dest_format.format,
dest_format.type, nullptr);
break;
+ case SurfaceParams::SurfaceTarget::TextureCubemap:
+ for (std::size_t face = 0; face < new_params.depth; ++face) {
+ glTextureSubImage3D(
+ new_surface->Texture().handle, 0, 0, 0, static_cast<GLint>(face),
+ static_cast<GLsizei>(dest_rect.GetWidth()),
+ static_cast<GLsizei>(dest_rect.GetHeight()), static_cast<GLsizei>(1),
+ dest_format.format, dest_format.type, nullptr);
+ }
+ break;
default:
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
static_cast<u32>(new_params.target));
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 2aed83bbc..e2fd0009e 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -127,6 +127,8 @@ struct SurfaceParams {
case Tegra::Texture::TextureType::Texture2D:
case Tegra::Texture::TextureType::Texture2DNoMipmap:
return SurfaceTarget::Texture2D;
+ case Tegra::Texture::TextureType::TextureCubemap:
+ return SurfaceTarget::TextureCubemap;
case Tegra::Texture::TextureType::Texture1DArray:
return SurfaceTarget::Texture1DArray;
case Tegra::Texture::TextureType::Texture2DArray: