diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 41 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 28 |
3 files changed, 42 insertions, 32 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index e038686ad..301562ff6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1002,10 +1002,9 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s | |||
| 1002 | 1002 | ||
| 1003 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); | 1003 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); |
| 1004 | 1004 | ||
| 1005 | Surface surface = res_cache.GetTextureSurface(texture, entry); | 1005 | if (Surface surface = res_cache.GetTextureSurface(texture, entry); surface) { |
| 1006 | if (surface != nullptr) { | ||
| 1007 | state.texture_units[current_bindpoint].texture = | 1006 | state.texture_units[current_bindpoint].texture = |
| 1008 | entry.IsArray() ? surface->TextureLayer().handle : surface->Texture().handle; | 1007 | surface->Texture(entry.IsArray()).handle; |
| 1009 | surface->UpdateSwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source, | 1008 | surface->UpdateSwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source, |
| 1010 | texture.tic.w_source); | 1009 | texture.tic.w_source); |
| 1011 | } else { | 1010 | } else { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 876698b37..e9eb6e921 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -400,6 +400,27 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType | |||
| 400 | return format; | 400 | return format; |
| 401 | } | 401 | } |
| 402 | 402 | ||
| 403 | /// Returns the discrepant array target | ||
| 404 | constexpr GLenum GetArrayDiscrepantTarget(SurfaceTarget target) { | ||
| 405 | switch (target) { | ||
| 406 | case SurfaceTarget::Texture1D: | ||
| 407 | return GL_TEXTURE_1D_ARRAY; | ||
| 408 | case SurfaceTarget::Texture2D: | ||
| 409 | return GL_TEXTURE_2D_ARRAY; | ||
| 410 | case SurfaceTarget::Texture3D: | ||
| 411 | return GL_NONE; | ||
| 412 | case SurfaceTarget::Texture1DArray: | ||
| 413 | return GL_TEXTURE_1D; | ||
| 414 | case SurfaceTarget::Texture2DArray: | ||
| 415 | return GL_TEXTURE_2D; | ||
| 416 | case SurfaceTarget::TextureCubemap: | ||
| 417 | return GL_TEXTURE_CUBE_MAP_ARRAY; | ||
| 418 | case SurfaceTarget::TextureCubeArray: | ||
| 419 | return GL_TEXTURE_CUBE_MAP; | ||
| 420 | } | ||
| 421 | return GL_NONE; | ||
| 422 | } | ||
| 423 | |||
| 403 | Common::Rectangle<u32> SurfaceParams::GetRect(u32 mip_level) const { | 424 | Common::Rectangle<u32> SurfaceParams::GetRect(u32 mip_level) const { |
| 404 | u32 actual_height{std::max(1U, unaligned_height >> mip_level)}; | 425 | u32 actual_height{std::max(1U, unaligned_height >> mip_level)}; |
| 405 | if (IsPixelFormatASTC(pixel_format)) { | 426 | if (IsPixelFormatASTC(pixel_format)) { |
| @@ -795,20 +816,22 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, | |||
| 795 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 816 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 796 | } | 817 | } |
| 797 | 818 | ||
| 798 | void CachedSurface::EnsureTextureView() { | 819 | void CachedSurface::EnsureTextureDiscrepantView() { |
| 799 | if (texture_view.handle != 0) | 820 | if (discrepant_view.handle != 0) |
| 800 | return; | 821 | return; |
| 801 | 822 | ||
| 802 | const GLenum target{TargetLayer()}; | 823 | const GLenum target{GetArrayDiscrepantTarget(params.target)}; |
| 824 | ASSERT(target != GL_NONE); | ||
| 825 | |||
| 803 | const GLuint num_layers{target == GL_TEXTURE_CUBE_MAP_ARRAY ? 6u : 1u}; | 826 | const GLuint num_layers{target == GL_TEXTURE_CUBE_MAP_ARRAY ? 6u : 1u}; |
| 804 | constexpr GLuint min_layer = 0; | 827 | constexpr GLuint min_layer = 0; |
| 805 | constexpr GLuint min_level = 0; | 828 | constexpr GLuint min_level = 0; |
| 806 | 829 | ||
| 807 | glGenTextures(1, &texture_view.handle); | 830 | glGenTextures(1, &discrepant_view.handle); |
| 808 | glTextureView(texture_view.handle, target, texture.handle, gl_internal_format, min_level, | 831 | glTextureView(discrepant_view.handle, target, texture.handle, gl_internal_format, min_level, |
| 809 | params.max_mip_level, min_layer, num_layers); | 832 | params.max_mip_level, min_layer, num_layers); |
| 810 | ApplyTextureDefaults(texture_view.handle, params.max_mip_level); | 833 | ApplyTextureDefaults(discrepant_view.handle, params.max_mip_level); |
| 811 | glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, | 834 | glTextureParameteriv(discrepant_view.handle, GL_TEXTURE_SWIZZLE_RGBA, |
| 812 | reinterpret_cast<const GLint*>(swizzle.data())); | 835 | reinterpret_cast<const GLint*>(swizzle.data())); |
| 813 | } | 836 | } |
| 814 | 837 | ||
| @@ -834,8 +857,8 @@ void CachedSurface::UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, | |||
| 834 | swizzle = {new_x, new_y, new_z, new_w}; | 857 | swizzle = {new_x, new_y, new_z, new_w}; |
| 835 | const auto swizzle_data = reinterpret_cast<const GLint*>(swizzle.data()); | 858 | const auto swizzle_data = reinterpret_cast<const GLint*>(swizzle.data()); |
| 836 | glTextureParameteriv(texture.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); | 859 | glTextureParameteriv(texture.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); |
| 837 | if (texture_view.handle != 0) { | 860 | if (discrepant_view.handle != 0) { |
| 838 | glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); | 861 | glTextureParameteriv(discrepant_view.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); |
| 839 | } | 862 | } |
| 840 | } | 863 | } |
| 841 | 864 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 797bbdc9c..9cf6f50be 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -367,31 +367,19 @@ public: | |||
| 367 | return texture; | 367 | return texture; |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | const OGLTexture& TextureLayer() { | 370 | const OGLTexture& Texture(bool as_array) { |
| 371 | if (params.is_array) { | 371 | if (params.is_array == as_array) { |
| 372 | return Texture(); | 372 | return texture; |
| 373 | } else { | ||
| 374 | EnsureTextureDiscrepantView(); | ||
| 375 | return discrepant_view; | ||
| 373 | } | 376 | } |
| 374 | EnsureTextureView(); | ||
| 375 | return texture_view; | ||
| 376 | } | 377 | } |
| 377 | 378 | ||
| 378 | GLenum Target() const { | 379 | GLenum Target() const { |
| 379 | return gl_target; | 380 | return gl_target; |
| 380 | } | 381 | } |
| 381 | 382 | ||
| 382 | GLenum TargetLayer() const { | ||
| 383 | using VideoCore::Surface::SurfaceTarget; | ||
| 384 | switch (params.target) { | ||
| 385 | case SurfaceTarget::Texture1D: | ||
| 386 | return GL_TEXTURE_1D_ARRAY; | ||
| 387 | case SurfaceTarget::Texture2D: | ||
| 388 | return GL_TEXTURE_2D_ARRAY; | ||
| 389 | case SurfaceTarget::TextureCubemap: | ||
| 390 | return GL_TEXTURE_CUBE_MAP_ARRAY; | ||
| 391 | } | ||
| 392 | return Target(); | ||
| 393 | } | ||
| 394 | |||
| 395 | const SurfaceParams& GetSurfaceParams() const { | 383 | const SurfaceParams& GetSurfaceParams() const { |
| 396 | return params; | 384 | return params; |
| 397 | } | 385 | } |
| @@ -431,10 +419,10 @@ public: | |||
| 431 | private: | 419 | private: |
| 432 | void UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, GLuint draw_fb_handle); | 420 | void UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, GLuint draw_fb_handle); |
| 433 | 421 | ||
| 434 | void EnsureTextureView(); | 422 | void EnsureTextureDiscrepantView(); |
| 435 | 423 | ||
| 436 | OGLTexture texture; | 424 | OGLTexture texture; |
| 437 | OGLTexture texture_view; | 425 | OGLTexture discrepant_view; |
| 438 | std::vector<std::vector<u8>> gl_buffer; | 426 | std::vector<std::vector<u8>> gl_buffer; |
| 439 | SurfaceParams params{}; | 427 | SurfaceParams params{}; |
| 440 | GLenum gl_target{}; | 428 | GLenum gl_target{}; |