diff options
| author | 2019-04-14 18:16:27 -0300 | |
|---|---|---|
| committer | 2019-06-20 21:36:11 -0300 | |
| commit | 84139586c9e6c95a7f3faaa09d04eb11b2bcd70c (patch) | |
| tree | 94e6d2746b7d0d60d5b5316d4867c0a9fe1edaba /src | |
| parent | gl_texture_cache: Add fast copy path (diff) | |
| download | yuzu-84139586c9e6c95a7f3faaa09d04eb11b2bcd70c.tar.gz yuzu-84139586c9e6c95a7f3faaa09d04eb11b2bcd70c.tar.xz yuzu-84139586c9e6c95a7f3faaa09d04eb11b2bcd70c.zip | |
gl_texture_cache: Attach surface textures instead of views
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 22 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 3 |
3 files changed, 32 insertions, 20 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index cea268f1e..07c28357e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -83,10 +83,10 @@ struct FramebufferCacheKey { | |||
| 83 | bool stencil_enable = false; | 83 | bool stencil_enable = false; |
| 84 | 84 | ||
| 85 | std::array<GLenum, Maxwell::NumRenderTargets> color_attachments{}; | 85 | std::array<GLenum, Maxwell::NumRenderTargets> color_attachments{}; |
| 86 | std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> colors{}; | 86 | std::array<CachedSurfaceView*, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> colors{}; |
| 87 | u32 colors_count = 0; | 87 | u32 colors_count = 0; |
| 88 | 88 | ||
| 89 | GLuint zeta = 0; | 89 | CachedSurfaceView* zeta = nullptr; |
| 90 | 90 | ||
| 91 | auto Tie() const { | 91 | auto Tie() const { |
| 92 | return std::tie(is_single_buffer, stencil_enable, color_attachments, colors, colors_count, | 92 | return std::tie(is_single_buffer, stencil_enable, color_attachments, colors, colors_count, |
| @@ -367,25 +367,21 @@ void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey, | |||
| 367 | 367 | ||
| 368 | if (fbkey.is_single_buffer) { | 368 | if (fbkey.is_single_buffer) { |
| 369 | if (fbkey.color_attachments[0] != GL_NONE) { | 369 | if (fbkey.color_attachments[0] != GL_NONE) { |
| 370 | glFramebufferTexture(GL_DRAW_FRAMEBUFFER, fbkey.color_attachments[0], fbkey.colors[0], | 370 | fbkey.colors[0]->Attach(fbkey.color_attachments[0]); |
| 371 | 0); | ||
| 372 | } | 371 | } |
| 373 | glDrawBuffer(fbkey.color_attachments[0]); | 372 | glDrawBuffer(fbkey.color_attachments[0]); |
| 374 | } else { | 373 | } else { |
| 375 | for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { | 374 | for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { |
| 376 | if (fbkey.colors[index]) { | 375 | if (fbkey.colors[index]) { |
| 377 | glFramebufferTexture(GL_DRAW_FRAMEBUFFER, | 376 | fbkey.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index)); |
| 378 | GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index), | ||
| 379 | fbkey.colors[index], 0); | ||
| 380 | } | 377 | } |
| 381 | } | 378 | } |
| 382 | glDrawBuffers(fbkey.colors_count, fbkey.color_attachments.data()); | 379 | glDrawBuffers(fbkey.colors_count, fbkey.color_attachments.data()); |
| 383 | } | 380 | } |
| 384 | 381 | ||
| 385 | if (fbkey.zeta) { | 382 | if (fbkey.zeta) { |
| 386 | GLenum zeta_attachment = | 383 | fbkey.zeta->Attach(fbkey.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT |
| 387 | fbkey.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT; | 384 | : GL_DEPTH_ATTACHMENT); |
| 388 | glFramebufferTexture(GL_DRAW_FRAMEBUFFER, zeta_attachment, fbkey.zeta, 0); | ||
| 389 | } | 385 | } |
| 390 | } | 386 | } |
| 391 | 387 | ||
| @@ -509,7 +505,7 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( | |||
| 509 | fbkey.is_single_buffer = true; | 505 | fbkey.is_single_buffer = true; |
| 510 | fbkey.color_attachments[0] = | 506 | fbkey.color_attachments[0] = |
| 511 | GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(*single_color_target); | 507 | GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(*single_color_target); |
| 512 | fbkey.colors[0] = color_surface != nullptr ? color_surface->GetTexture() : 0; | 508 | fbkey.colors[0] = color_surface; |
| 513 | } else { | 509 | } else { |
| 514 | // Multiple color attachments are enabled | 510 | // Multiple color attachments are enabled |
| 515 | for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { | 511 | for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) { |
| @@ -529,7 +525,7 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( | |||
| 529 | 525 | ||
| 530 | fbkey.color_attachments[index] = | 526 | fbkey.color_attachments[index] = |
| 531 | GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index); | 527 | GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index); |
| 532 | fbkey.colors[index] = color_surface != nullptr ? color_surface->GetTexture() : 0; | 528 | fbkey.colors[index] = color_surface; |
| 533 | } | 529 | } |
| 534 | fbkey.is_single_buffer = false; | 530 | fbkey.is_single_buffer = false; |
| 535 | fbkey.colors_count = regs.rt_control.count; | 531 | fbkey.colors_count = regs.rt_control.count; |
| @@ -544,7 +540,7 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers( | |||
| 544 | // the shader doesn't actually write to it. | 540 | // the shader doesn't actually write to it. |
| 545 | depth_surface->MarkAsModified(true); | 541 | depth_surface->MarkAsModified(true); |
| 546 | 542 | ||
| 547 | fbkey.zeta = depth_surface->GetTexture(); | 543 | fbkey.zeta = depth_surface; |
| 548 | fbkey.stencil_enable = regs.stencil_enable && depth_surface->GetSurfaceParams().GetType() == | 544 | fbkey.stencil_enable = regs.stencil_enable && depth_surface->GetSurfaceParams().GetType() == |
| 549 | SurfaceType::DepthStencil; | 545 | SurfaceType::DepthStencil; |
| 550 | } | 546 | } |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 00f9ab92f..ba6d3af4b 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -428,13 +428,28 @@ CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, ViewKey key) | |||
| 428 | 428 | ||
| 429 | CachedSurfaceView::~CachedSurfaceView() = default; | 429 | CachedSurfaceView::~CachedSurfaceView() = default; |
| 430 | 430 | ||
| 431 | GLuint CachedSurfaceView::GetTexture() { | 431 | void CachedSurfaceView::Attach(GLenum attachment) const { |
| 432 | // TODO(Rodrigo): Remove this entry and attach the super texture to the framebuffer through | 432 | ASSERT(key.num_layers == 1 && key.num_levels == 1); |
| 433 | // legacy API (also dropping Intel driver issues). | 433 | |
| 434 | if (texture_view_2d.texture.handle == 0) { | 434 | switch (params.GetTarget()) { |
| 435 | texture_view_2d = CreateTextureView(GL_TEXTURE_2D); | 435 | case SurfaceTarget::Texture1D: |
| 436 | glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(), | ||
| 437 | surface.GetTexture(), key.base_level); | ||
| 438 | break; | ||
| 439 | case SurfaceTarget::Texture2D: | ||
| 440 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(), | ||
| 441 | surface.GetTexture(), key.base_level); | ||
| 442 | break; | ||
| 443 | case SurfaceTarget::Texture1DArray: | ||
| 444 | case SurfaceTarget::Texture2DArray: | ||
| 445 | case SurfaceTarget::TextureCubemap: | ||
| 446 | case SurfaceTarget::TextureCubeArray: | ||
| 447 | glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTexture(), | ||
| 448 | key.base_level, key.base_layer); | ||
| 449 | break; | ||
| 450 | default: | ||
| 451 | UNIMPLEMENTED(); | ||
| 436 | } | 452 | } |
| 437 | return texture_view_2d.texture.handle; | ||
| 438 | } | 453 | } |
| 439 | 454 | ||
| 440 | GLuint CachedSurfaceView::GetTexture(Tegra::Shader::TextureType texture_type, bool is_array, | 455 | GLuint CachedSurfaceView::GetTexture(Tegra::Shader::TextureType texture_type, bool is_array, |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index b18b32d99..80733ac36 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -73,7 +73,8 @@ public: | |||
| 73 | explicit CachedSurfaceView(CachedSurface& surface, ViewKey key); | 73 | explicit CachedSurfaceView(CachedSurface& surface, ViewKey key); |
| 74 | ~CachedSurfaceView(); | 74 | ~CachedSurfaceView(); |
| 75 | 75 | ||
| 76 | GLuint GetTexture(); | 76 | /// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER |
| 77 | void Attach(GLenum attachment) const; | ||
| 77 | 78 | ||
| 78 | GLuint GetTexture(Tegra::Shader::TextureType texture_type, bool is_array, | 79 | GLuint GetTexture(Tegra::Shader::TextureType texture_type, bool is_array, |
| 79 | Tegra::Texture::SwizzleSource x_source, | 80 | Tegra::Texture::SwizzleSource x_source, |