diff options
Diffstat (limited to 'src')
| -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 09fa01d25..406d720a0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1012,10 +1012,9 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s | |||
| 1012 | 1012 | ||
| 1013 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); | 1013 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); |
| 1014 | 1014 | ||
| 1015 | Surface surface = res_cache.GetTextureSurface(texture, entry); | 1015 | if (Surface surface = res_cache.GetTextureSurface(texture, entry); surface) { |
| 1016 | if (surface != nullptr) { | ||
| 1017 | state.texture_units[current_bindpoint].texture = | 1016 | state.texture_units[current_bindpoint].texture = |
| 1018 | entry.IsArray() ? surface->TextureLayer().handle : surface->Texture().handle; | 1017 | surface->Texture(entry.IsArray()).handle; |
| 1019 | surface->UpdateSwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source, | 1018 | surface->UpdateSwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source, |
| 1020 | texture.tic.w_source); | 1019 | texture.tic.w_source); |
| 1021 | } else { | 1020 | } else { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 49c79811d..837523b82 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -399,6 +399,27 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType | |||
| 399 | return format; | 399 | return format; |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | /// Returns the discrepant array target | ||
| 403 | constexpr GLenum GetArrayDiscrepantTarget(SurfaceTarget target) { | ||
| 404 | switch (target) { | ||
| 405 | case SurfaceTarget::Texture1D: | ||
| 406 | return GL_TEXTURE_1D_ARRAY; | ||
| 407 | case SurfaceTarget::Texture2D: | ||
| 408 | return GL_TEXTURE_2D_ARRAY; | ||
| 409 | case SurfaceTarget::Texture3D: | ||
| 410 | return GL_NONE; | ||
| 411 | case SurfaceTarget::Texture1DArray: | ||
| 412 | return GL_TEXTURE_1D; | ||
| 413 | case SurfaceTarget::Texture2DArray: | ||
| 414 | return GL_TEXTURE_2D; | ||
| 415 | case SurfaceTarget::TextureCubemap: | ||
| 416 | return GL_TEXTURE_CUBE_MAP_ARRAY; | ||
| 417 | case SurfaceTarget::TextureCubeArray: | ||
| 418 | return GL_TEXTURE_CUBE_MAP; | ||
| 419 | } | ||
| 420 | return GL_NONE; | ||
| 421 | } | ||
| 422 | |||
| 402 | Common::Rectangle<u32> SurfaceParams::GetRect(u32 mip_level) const { | 423 | Common::Rectangle<u32> SurfaceParams::GetRect(u32 mip_level) const { |
| 403 | u32 actual_height{std::max(1U, unaligned_height >> mip_level)}; | 424 | u32 actual_height{std::max(1U, unaligned_height >> mip_level)}; |
| 404 | if (IsPixelFormatASTC(pixel_format)) { | 425 | if (IsPixelFormatASTC(pixel_format)) { |
| @@ -881,20 +902,22 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, | |||
| 881 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 902 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 882 | } | 903 | } |
| 883 | 904 | ||
| 884 | void CachedSurface::EnsureTextureView() { | 905 | void CachedSurface::EnsureTextureDiscrepantView() { |
| 885 | if (texture_view.handle != 0) | 906 | if (discrepant_view.handle != 0) |
| 886 | return; | 907 | return; |
| 887 | 908 | ||
| 888 | const GLenum target{TargetLayer()}; | 909 | const GLenum target{GetArrayDiscrepantTarget(params.target)}; |
| 910 | ASSERT(target != GL_NONE); | ||
| 911 | |||
| 889 | const GLuint num_layers{target == GL_TEXTURE_CUBE_MAP_ARRAY ? 6u : 1u}; | 912 | const GLuint num_layers{target == GL_TEXTURE_CUBE_MAP_ARRAY ? 6u : 1u}; |
| 890 | constexpr GLuint min_layer = 0; | 913 | constexpr GLuint min_layer = 0; |
| 891 | constexpr GLuint min_level = 0; | 914 | constexpr GLuint min_level = 0; |
| 892 | 915 | ||
| 893 | glGenTextures(1, &texture_view.handle); | 916 | glGenTextures(1, &discrepant_view.handle); |
| 894 | glTextureView(texture_view.handle, target, texture.handle, gl_internal_format, min_level, | 917 | glTextureView(discrepant_view.handle, target, texture.handle, gl_internal_format, min_level, |
| 895 | params.max_mip_level, min_layer, num_layers); | 918 | params.max_mip_level, min_layer, num_layers); |
| 896 | ApplyTextureDefaults(texture_view.handle, params.max_mip_level); | 919 | ApplyTextureDefaults(discrepant_view.handle, params.max_mip_level); |
| 897 | glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, | 920 | glTextureParameteriv(discrepant_view.handle, GL_TEXTURE_SWIZZLE_RGBA, |
| 898 | reinterpret_cast<const GLint*>(swizzle.data())); | 921 | reinterpret_cast<const GLint*>(swizzle.data())); |
| 899 | } | 922 | } |
| 900 | 923 | ||
| @@ -920,8 +943,8 @@ void CachedSurface::UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x, | |||
| 920 | swizzle = {new_x, new_y, new_z, new_w}; | 943 | swizzle = {new_x, new_y, new_z, new_w}; |
| 921 | const auto swizzle_data = reinterpret_cast<const GLint*>(swizzle.data()); | 944 | const auto swizzle_data = reinterpret_cast<const GLint*>(swizzle.data()); |
| 922 | glTextureParameteriv(texture.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); | 945 | glTextureParameteriv(texture.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); |
| 923 | if (texture_view.handle != 0) { | 946 | if (discrepant_view.handle != 0) { |
| 924 | glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); | 947 | glTextureParameteriv(discrepant_view.handle, GL_TEXTURE_SWIZZLE_RGBA, swizzle_data); |
| 925 | } | 948 | } |
| 926 | } | 949 | } |
| 927 | 950 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 838554c35..32fc6538a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -354,31 +354,19 @@ public: | |||
| 354 | return texture; | 354 | return texture; |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | const OGLTexture& TextureLayer() { | 357 | const OGLTexture& Texture(bool as_array) { |
| 358 | if (params.is_array) { | 358 | if (params.is_array == as_array) { |
| 359 | return Texture(); | 359 | return texture; |
| 360 | } else { | ||
| 361 | EnsureTextureDiscrepantView(); | ||
| 362 | return discrepant_view; | ||
| 360 | } | 363 | } |
| 361 | EnsureTextureView(); | ||
| 362 | return texture_view; | ||
| 363 | } | 364 | } |
| 364 | 365 | ||
| 365 | GLenum Target() const { | 366 | GLenum Target() const { |
| 366 | return gl_target; | 367 | return gl_target; |
| 367 | } | 368 | } |
| 368 | 369 | ||
| 369 | GLenum TargetLayer() const { | ||
| 370 | using VideoCore::Surface::SurfaceTarget; | ||
| 371 | switch (params.target) { | ||
| 372 | case SurfaceTarget::Texture1D: | ||
| 373 | return GL_TEXTURE_1D_ARRAY; | ||
| 374 | case SurfaceTarget::Texture2D: | ||
| 375 | return GL_TEXTURE_2D_ARRAY; | ||
| 376 | case SurfaceTarget::TextureCubemap: | ||
| 377 | return GL_TEXTURE_CUBE_MAP_ARRAY; | ||
| 378 | } | ||
| 379 | return Target(); | ||
| 380 | } | ||
| 381 | |||
| 382 | const SurfaceParams& GetSurfaceParams() const { | 370 | const SurfaceParams& GetSurfaceParams() const { |
| 383 | return params; | 371 | return params; |
| 384 | } | 372 | } |
| @@ -398,10 +386,10 @@ public: | |||
| 398 | private: | 386 | private: |
| 399 | void UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, GLuint draw_fb_handle); | 387 | void UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, GLuint draw_fb_handle); |
| 400 | 388 | ||
| 401 | void EnsureTextureView(); | 389 | void EnsureTextureDiscrepantView(); |
| 402 | 390 | ||
| 403 | OGLTexture texture; | 391 | OGLTexture texture; |
| 404 | OGLTexture texture_view; | 392 | OGLTexture discrepant_view; |
| 405 | std::vector<std::vector<u8>> gl_buffer; | 393 | std::vector<std::vector<u8>> gl_buffer; |
| 406 | SurfaceParams params{}; | 394 | SurfaceParams params{}; |
| 407 | GLenum gl_target{}; | 395 | GLenum gl_target{}; |