From 75596c07e0fc1462c2a19484e168f4944c33d3d3 Mon Sep 17 00:00:00 2001 From: Feng Chen Date: Fri, 4 Nov 2022 14:39:42 +0800 Subject: video_core: Fix SNORM texture buffer emulating error (#9001) --- src/video_core/renderer_opengl/gl_buffer_cache.cpp | 15 ++++++--------- src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | 4 ++-- src/video_core/renderer_opengl/gl_rasterizer.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/video_core/renderer_opengl') diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index 08f4d69ab..6af4ae793 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp @@ -29,17 +29,17 @@ constexpr std::array PROGRAM_LUT{ [[nodiscard]] GLenum GetTextureBufferFormat(GLenum gl_format) { switch (gl_format) { case GL_RGBA8_SNORM: - return GL_RGBA8; + return GL_RGBA8I; case GL_R8_SNORM: - return GL_R8; + return GL_R8I; case GL_RGBA16_SNORM: - return GL_RGBA16; + return GL_RGBA16I; case GL_R16_SNORM: - return GL_R16; + return GL_R16I; case GL_RG16_SNORM: - return GL_RG16; + return GL_RG16I; case GL_RG8_SNORM: - return GL_RG8; + return GL_RG8I; default: return gl_format; } @@ -96,9 +96,6 @@ GLuint Buffer::View(u32 offset, u32 size, PixelFormat format) { texture.Create(GL_TEXTURE_BUFFER); const GLenum gl_format{MaxwellToGL::GetFormatTuple(format).internal_format}; const GLenum texture_format{GetTextureBufferFormat(gl_format)}; - if (texture_format != gl_format) { - LOG_WARNING(Render_OpenGL, "Emulating SNORM texture buffer with UNORM."); - } glTextureBufferRange(texture.handle, texture_format, buffer.handle, offset, size); views.push_back({ .offset = offset, diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index daceb05f4..c115dabe1 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp @@ -504,8 +504,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { } } if (info.uses_render_area) { - const auto render_area_width(static_cast(regs.render_area.width)); - const auto render_area_height(static_cast(regs.render_area.height)); + const auto render_area_width(static_cast(regs.surface_clip.width)); + const auto render_area_height(static_cast(regs.surface_clip.height)); if (use_assembly) { glProgramLocalParameter4fARB(AssemblyStage(stage), 1, render_area_width, render_area_height, 0.0f, 0.0f); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 79d7908d4..72e314d39 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -618,11 +618,11 @@ void RasterizerOpenGL::SyncViewport() { } flags[Dirty::Viewport0 + index] = false; - if (!regs.viewport_transform_enabled) { - const auto x = static_cast(regs.render_area.x); - const auto y = static_cast(regs.render_area.y); - const auto width = static_cast(regs.render_area.width); - const auto height = static_cast(regs.render_area.height); + if (!regs.viewport_scale_offset_enbled) { + const auto x = static_cast(regs.surface_clip.x); + const auto y = static_cast(regs.surface_clip.y); + const auto width = static_cast(regs.surface_clip.width); + const auto height = static_cast(regs.surface_clip.height); glViewportIndexedf(static_cast(index), x, y, width != 0.0f ? width : 1.0f, height != 0.0f ? height : 1.0f); continue; -- cgit v1.2.3