summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-10-06 07:18:00 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-11-16 22:11:30 +0100
commit31478c6c1b841b9a820742830b136775fafe270f (patch)
treee8f5644dd6c570cf8ee08e5e23592983162a8ec4 /src/video_core/renderer_opengl
parenttexture_cache: Refactor scaled image size calculation (diff)
downloadyuzu-31478c6c1b841b9a820742830b136775fafe270f.tar
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.gz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.bz2
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.lz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.xz
yuzu-31478c6c1b841b9a820742830b136775fafe270f.tar.zst
yuzu-31478c6c1b841b9a820742830b136775fafe270f.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp31
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h11
3 files changed, 21 insertions, 25 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d94f1e89f..bb24a0656 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -554,7 +554,7 @@ void RasterizerOpenGL::SyncViewport() {
}
glFrontFace(mode);
}
- if (dirty_viewport || flags[Dirty::ClipControl]) {
+ if (dirty_viewport || dirty_clip_control) {
flags[Dirty::ClipControl] = false;
bool flip_y = false;
@@ -925,7 +925,7 @@ void RasterizerOpenGL::SyncScissorTest() {
const auto& regs = maxwell3d.regs;
const auto& resolution = Settings::values.resolution_info;
- const auto scale_up = [&](u32 value) -> u32 {
+ const auto scale_up = [resolution](u32 value) -> u32 {
if (value == 0) {
return 0U;
}
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index fafee62ee..c68a51ebb 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -405,7 +405,8 @@ ImageBufferMap::~ImageBufferMap() {
TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& program_manager,
StateTracker& state_tracker_)
- : device{device_}, state_tracker{state_tracker_}, util_shaders(program_manager) {
+ : device{device_}, state_tracker{state_tracker_},
+ util_shaders(program_manager), resolution{Settings::values.resolution_info} {
static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D};
for (size_t i = 0; i < TARGETS.size(); ++i) {
const GLenum target = TARGETS[i];
@@ -473,7 +474,6 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
set_view(Shader::TextureType::ColorArray2D, null_image_view_2d_array.handle);
set_view(Shader::TextureType::ColorArrayCube, null_image_cube_array.handle);
- resolution = Settings::values.resolution_info;
if (resolution.active) {
for (size_t i = 0; i < rescale_draw_fbos.size(); ++i) {
rescale_draw_fbos[i].Create();
@@ -681,7 +681,7 @@ Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_,
gl_type = tuple.type;
}
texture = MakeImage(info, gl_internal_format);
- original_backup = texture.handle;
+ current_texture = texture.handle;
if (runtime->device.HasDebuggingToolAttached()) {
const std::string name = VideoCommon::Name(*this);
glObjectLabel(ImageTarget(info) == GL_TEXTURE_BUFFER ? GL_BUFFER : GL_TEXTURE,
@@ -726,10 +726,6 @@ void Image::UploadMemory(const ImageBufferMap& map,
void Image::DownloadMemory(ImageBufferMap& map,
std::span<const VideoCommon::BufferImageCopy> copies) {
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API
- const bool is_rescaled = True(flags & ImageFlagBits::Rescaled);
- if (is_rescaled) {
- ScaleDown();
- }
glBindBuffer(GL_PIXEL_PACK_BUFFER, map.buffer);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -747,9 +743,6 @@ void Image::DownloadMemory(ImageBufferMap& map,
}
CopyImageToBuffer(copy, map.offset);
}
- if (is_rescaled) {
- texture.handle = upscaled_backup.handle;
- }
}
GLuint Image::StorageHandle() noexcept {
@@ -775,11 +768,11 @@ GLuint Image::StorageHandle() noexcept {
return store_view.handle;
}
store_view.Create();
- glTextureView(store_view.handle, ImageTarget(info), texture.handle, GL_RGBA8, 0,
+ glTextureView(store_view.handle, ImageTarget(info), current_texture, GL_RGBA8, 0,
info.resources.levels, 0, info.resources.layers);
return store_view.handle;
default:
- return texture.handle;
+ return current_texture;
}
}
@@ -940,10 +933,10 @@ bool Image::Scale() {
const u32 original_width = info.size.width;
const u32 original_height = info.size.height;
- auto dst_info = info;
- dst_info.size.width = scaled_width;
- dst_info.size.height = scaled_height;
if (!upscaled_backup.handle) {
+ auto dst_info = info;
+ dst_info.size.width = scaled_width;
+ dst_info.size.height = scaled_height;
upscaled_backup = MakeImage(dst_info, gl_internal_format);
}
const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle;
@@ -955,14 +948,14 @@ bool Image::Scale() {
const u32 dst_level_width = std::max(1u, scaled_width >> level);
const u32 dst_level_height = std::max(1u, scaled_height >> level);
- glNamedFramebufferTextureLayer(read_fbo, attachment, original_backup, level, layer);
+ glNamedFramebufferTextureLayer(read_fbo, attachment, texture.handle, level, layer);
glNamedFramebufferTextureLayer(draw_fbo, attachment, upscaled_backup.handle, level,
layer);
glBlitNamedFramebuffer(read_fbo, draw_fbo, 0, 0, src_level_width, src_level_height, 0,
0, dst_level_width, dst_level_height, mask, filter);
}
}
- texture.handle = upscaled_backup.handle;
+ current_texture = upscaled_backup.handle;
return true;
}
@@ -993,7 +986,7 @@ bool Image::ScaleDown() {
return false;
}
flags &= ~ImageFlagBits::Rescaled;
- texture.handle = original_backup;
+ current_texture = texture.handle;
return true;
}
@@ -1010,7 +1003,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
flat_range = info.range;
set_object_label = device.HasDebuggingToolAttached();
is_render_target = info.IsRenderTarget();
- original_texture = image.texture.handle;
+ original_texture = image.Handle();
num_samples = image.info.num_samples;
if (!is_render_target) {
swizzle[0] = info.x_source;
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index 61f9b0259..cf7f37a16 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -9,13 +9,16 @@
#include <glad/glad.h>
-#include "common/settings.h"
#include "shader_recompiler/shader_info.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
#include "video_core/renderer_opengl/util_shaders.h"
#include "video_core/texture_cache/image_view_base.h"
#include "video_core/texture_cache/texture_cache_base.h"
+namespace Settings {
+struct ResolutionScalingInfo;
+}
+
namespace OpenGL {
class Device;
@@ -155,7 +158,7 @@ private:
std::array<OGLFramebuffer, 3> rescale_draw_fbos;
std::array<OGLFramebuffer, 3> rescale_read_fbos;
- Settings::ResolutionScalingInfo resolution;
+ const Settings::ResolutionScalingInfo& resolution;
};
class Image : public VideoCommon::ImageBase {
@@ -182,7 +185,7 @@ public:
GLuint StorageHandle() noexcept;
GLuint Handle() const noexcept {
- return texture.handle;
+ return current_texture;
}
GLuint GlFormat() const noexcept {
@@ -211,7 +214,7 @@ private:
GLenum gl_format = GL_NONE;
GLenum gl_type = GL_NONE;
TextureCacheRuntime* runtime{};
- GLuint original_backup{};
+ GLuint current_texture{};
};
class ImageView : public VideoCommon::ImageViewBase {