diff options
author | Liam <byteslice@airmail.cc> | 2024-01-12 06:46:17 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-31 17:27:20 +0100 |
commit | 2b1dd3bef511806aa479ec93e3d9b414db80d4a9 (patch) | |
tree | 24ef32a78ab1c4c13363fbed9d61774724753aa8 /src/video_core/renderer_opengl/gl_blit_screen.h | |
parent | video_core: consistently account for resolution scaling when rendering (diff) | |
download | yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar.gz yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar.bz2 yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar.lz yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar.xz yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.tar.zst yuzu-2b1dd3bef511806aa479ec93e3d9b414db80d4a9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_blit_screen.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_blit_screen.h b/src/video_core/renderer_opengl/gl_blit_screen.h new file mode 100644 index 000000000..13d769958 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_blit_screen.h @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <memory> +#include <vector> + +#include "core/hle/service/nvnflinger/pixel_format.h" +#include "video_core/host1x/gpu_device_memory_manager.h" +#include "video_core/renderer_opengl/gl_fsr.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" + +namespace Layout { +struct FramebufferLayout; +} + +namespace Tegra { +struct FramebufferConfig; +} + +namespace OpenGL { + +class Device; +class RasterizerOpenGL; +class StateTracker; + +/// Structure used for storing information about the textures for the Switch screen +struct TextureInfo { + OGLTexture resource; + GLsizei width; + GLsizei height; + GLenum gl_format; + GLenum gl_type; + Service::android::PixelFormat pixel_format; +}; + +/// Structure used for storing information about the display target for the Switch screen +struct FramebufferTextureInfo { + GLuint display_texture{}; + u32 width; + u32 height; + u32 scaled_width; + u32 scaled_height; +}; + +class BlitScreen { +public: + explicit BlitScreen(RasterizerOpenGL& rasterizer, + Tegra::MaxwellDeviceMemoryManager& device_memory, + StateTracker& state_tracker, ProgramManager& program_manager, + Device& device); + + void ConfigureFramebufferTexture(const Tegra::FramebufferConfig& framebuffer); + + /// Draws the emulated screens to the emulator window. + void DrawScreen(const Tegra::FramebufferConfig& framebuffer, + const Layout::FramebufferLayout& layout); + + void RenderScreenshot(const Tegra::FramebufferConfig& framebuffer); + + /// Loads framebuffer from emulated memory into the active OpenGL texture. + FramebufferTextureInfo LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer); + + FramebufferTextureInfo PrepareRenderTarget(const Tegra::FramebufferConfig& framebuffer); + +private: + RasterizerOpenGL& rasterizer; + Tegra::MaxwellDeviceMemoryManager& device_memory; + StateTracker& state_tracker; + ProgramManager& program_manager; + Device& device; + + OGLSampler present_sampler; + OGLSampler present_sampler_nn; + OGLBuffer vertex_buffer; + OGLProgram fxaa_vertex; + OGLProgram fxaa_fragment; + OGLProgram present_vertex; + OGLProgram present_bilinear_fragment; + OGLProgram present_bicubic_fragment; + OGLProgram present_gaussian_fragment; + OGLProgram present_scaleforce_fragment; + + /// Display information for Switch screen + TextureInfo framebuffer_texture; + OGLTexture aa_texture; + OGLFramebuffer aa_framebuffer; + + OGLProgram smaa_edge_detection_vert; + OGLProgram smaa_blending_weight_calculation_vert; + OGLProgram smaa_neighborhood_blending_vert; + OGLProgram smaa_edge_detection_frag; + OGLProgram smaa_blending_weight_calculation_frag; + OGLProgram smaa_neighborhood_blending_frag; + OGLTexture smaa_area_tex; + OGLTexture smaa_search_tex; + OGLTexture smaa_edges_tex; + OGLTexture smaa_blend_tex; + + std::unique_ptr<FSR> fsr; + + /// OpenGL framebuffer data + std::vector<u8> gl_framebuffer_data; + + // GPU address of the vertex buffer + GLuint64EXT vertex_buffer_address = 0; +}; + +} // namespace OpenGL |