diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 35 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 2 |
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) { | |||
| 60 | case SurfaceTarget::Texture2D: | 60 | case SurfaceTarget::Texture2D: |
| 61 | params.depth = 1; | 61 | params.depth = 1; |
| 62 | break; | 62 | break; |
| 63 | case SurfaceTarget::TextureCubemap: | ||
| 64 | params.depth = config.tic.Depth() * 6; | ||
| 65 | break; | ||
| 63 | case SurfaceTarget::Texture3D: | 66 | case SurfaceTarget::Texture3D: |
| 64 | params.depth = config.tic.Depth(); | 67 | params.depth = config.tic.Depth(); |
| 65 | break; | 68 | break; |
| @@ -562,6 +565,7 @@ CachedSurface::CachedSurface(const SurfaceParams& params) | |||
| 562 | rect.GetWidth()); | 565 | rect.GetWidth()); |
| 563 | break; | 566 | break; |
| 564 | case SurfaceParams::SurfaceTarget::Texture2D: | 567 | case SurfaceParams::SurfaceTarget::Texture2D: |
| 568 | case SurfaceParams::SurfaceTarget::TextureCubemap: | ||
| 565 | glTexStorage2D(SurfaceTargetToGL(params.target), 1, format_tuple.internal_format, | 569 | glTexStorage2D(SurfaceTargetToGL(params.target), 1, format_tuple.internal_format, |
| 566 | rect.GetWidth(), rect.GetHeight()); | 570 | rect.GetWidth(), rect.GetHeight()); |
| 567 | break; | 571 | break; |
| @@ -680,6 +684,7 @@ void CachedSurface::LoadGLBuffer() { | |||
| 680 | // Pass impl. to the fallback code below | 684 | // Pass impl. to the fallback code below |
| 681 | break; | 685 | break; |
| 682 | case SurfaceParams::SurfaceTarget::Texture2DArray: | 686 | case SurfaceParams::SurfaceTarget::Texture2DArray: |
| 687 | case SurfaceParams::SurfaceTarget::TextureCubemap: | ||
| 683 | for (std::size_t index = 0; index < params.depth; ++index) { | 688 | for (std::size_t index = 0; index < params.depth; ++index) { |
| 684 | const std::size_t offset{index * copy_size}; | 689 | const std::size_t offset{index * copy_size}; |
| 685 | morton_to_gl_fns[static_cast<std::size_t>(params.pixel_format)]( | 690 | 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 | |||
| 724 | // Load data from memory to the surface | 729 | // Load data from memory to the surface |
| 725 | const GLint x0 = static_cast<GLint>(rect.left); | 730 | const GLint x0 = static_cast<GLint>(rect.left); |
| 726 | const GLint y0 = static_cast<GLint>(rect.bottom); | 731 | const GLint y0 = static_cast<GLint>(rect.bottom); |
| 727 | const std::size_t buffer_offset = | 732 | std::size_t buffer_offset = |
| 728 | static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width + | 733 | static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width + |
| 729 | static_cast<std::size_t>(x0)) * | 734 | static_cast<std::size_t>(x0)) * |
| 730 | GetGLBytesPerPixel(params.pixel_format); | 735 | GetGLBytesPerPixel(params.pixel_format); |
| @@ -763,6 +768,16 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 763 | static_cast<GLsizei>(params.depth), 0, | 768 | static_cast<GLsizei>(params.depth), 0, |
| 764 | static_cast<GLsizei>(params.size_in_bytes_total), &gl_buffer[buffer_offset]); | 769 | static_cast<GLsizei>(params.size_in_bytes_total), &gl_buffer[buffer_offset]); |
| 765 | break; | 770 | break; |
| 771 | case SurfaceParams::SurfaceTarget::TextureCubemap: | ||
| 772 | for (std::size_t face = 0; face < params.depth; ++face) { | ||
| 773 | glCompressedTexImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), | ||
| 774 | 0, tuple.internal_format, static_cast<GLsizei>(params.width), | ||
| 775 | static_cast<GLsizei>(params.height), 0, | ||
| 776 | static_cast<GLsizei>(params.size_in_bytes_2d), | ||
| 777 | &gl_buffer[buffer_offset]); | ||
| 778 | buffer_offset += params.size_in_bytes_2d; | ||
| 779 | } | ||
| 780 | break; | ||
| 766 | default: | 781 | default: |
| 767 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", | 782 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", |
| 768 | static_cast<u32>(params.target)); | 783 | static_cast<u32>(params.target)); |
| @@ -793,6 +808,15 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 793 | static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format, | 808 | static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format, |
| 794 | tuple.type, &gl_buffer[buffer_offset]); | 809 | tuple.type, &gl_buffer[buffer_offset]); |
| 795 | break; | 810 | break; |
| 811 | case SurfaceParams::SurfaceTarget::TextureCubemap: | ||
| 812 | for (std::size_t face = 0; face < params.depth; ++face) { | ||
| 813 | glTexSubImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, x0, | ||
| 814 | y0, static_cast<GLsizei>(rect.GetWidth()), | ||
| 815 | static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type, | ||
| 816 | &gl_buffer[buffer_offset]); | ||
| 817 | buffer_offset += params.size_in_bytes_2d; | ||
| 818 | } | ||
| 819 | break; | ||
| 796 | default: | 820 | default: |
| 797 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", | 821 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", |
| 798 | static_cast<u32>(params.target)); | 822 | static_cast<u32>(params.target)); |
| @@ -989,6 +1013,15 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, | |||
| 989 | static_cast<GLsizei>(new_params.depth), dest_format.format, | 1013 | static_cast<GLsizei>(new_params.depth), dest_format.format, |
| 990 | dest_format.type, nullptr); | 1014 | dest_format.type, nullptr); |
| 991 | break; | 1015 | break; |
| 1016 | case SurfaceParams::SurfaceTarget::TextureCubemap: | ||
| 1017 | for (std::size_t face = 0; face < new_params.depth; ++face) { | ||
| 1018 | glTextureSubImage3D( | ||
| 1019 | new_surface->Texture().handle, 0, 0, 0, static_cast<GLint>(face), | ||
| 1020 | static_cast<GLsizei>(dest_rect.GetWidth()), | ||
| 1021 | static_cast<GLsizei>(dest_rect.GetHeight()), static_cast<GLsizei>(1), | ||
| 1022 | dest_format.format, dest_format.type, nullptr); | ||
| 1023 | } | ||
| 1024 | break; | ||
| 992 | default: | 1025 | default: |
| 993 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", | 1026 | LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}", |
| 994 | static_cast<u32>(new_params.target)); | 1027 | 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 { | |||
| 127 | case Tegra::Texture::TextureType::Texture2D: | 127 | case Tegra::Texture::TextureType::Texture2D: |
| 128 | case Tegra::Texture::TextureType::Texture2DNoMipmap: | 128 | case Tegra::Texture::TextureType::Texture2DNoMipmap: |
| 129 | return SurfaceTarget::Texture2D; | 129 | return SurfaceTarget::Texture2D; |
| 130 | case Tegra::Texture::TextureType::TextureCubemap: | ||
| 131 | return SurfaceTarget::TextureCubemap; | ||
| 130 | case Tegra::Texture::TextureType::Texture1DArray: | 132 | case Tegra::Texture::TextureType::Texture1DArray: |
| 131 | return SurfaceTarget::Texture1DArray; | 133 | return SurfaceTarget::Texture1DArray; |
| 132 | case Tegra::Texture::TextureType::Texture2DArray: | 134 | case Tegra::Texture::TextureType::Texture2DArray: |