summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ameerj2021-06-10 01:55:27 -0400
committerGravatar ameerj2021-07-22 21:51:35 -0400
commitcd8427367ed372e355fa76a78d41b3bc64f997ca (patch)
treed8e5db860e68cef834f8c14a6e1f3c33d252dadd /src
parentshader_environment: Fix local memory size calculations (diff)
downloadyuzu-cd8427367ed372e355fa76a78d41b3bc64f997ca.tar.gz
yuzu-cd8427367ed372e355fa76a78d41b3bc64f997ca.tar.xz
yuzu-cd8427367ed372e355fa76a78d41b3bc64f997ca.zip
gl_buffer_cache: Use unorm internal formats for snorm texture buffer views
Fixes black textures in UE4 games
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
index 334ed470f..0703614de 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
@@ -25,6 +25,25 @@ constexpr std::array PROGRAM_LUT{
25 GL_VERTEX_PROGRAM_NV, GL_TESS_CONTROL_PROGRAM_NV, GL_TESS_EVALUATION_PROGRAM_NV, 25 GL_VERTEX_PROGRAM_NV, GL_TESS_CONTROL_PROGRAM_NV, GL_TESS_EVALUATION_PROGRAM_NV,
26 GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_NV, 26 GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_NV,
27}; 27};
28
29[[nodiscard]] GLenum GetTextureBufferFormat(GLenum gl_format) {
30 switch (gl_format) {
31 case GL_RGBA8_SNORM:
32 return GL_RGBA8;
33 case GL_R8_SNORM:
34 return GL_R8;
35 case GL_RGBA16_SNORM:
36 return GL_RGBA16;
37 case GL_R16_SNORM:
38 return GL_R16;
39 case GL_RG16_SNORM:
40 return GL_RG16;
41 case GL_RG8_SNORM:
42 return GL_RG8;
43 default:
44 return gl_format;
45 }
46}
28} // Anonymous namespace 47} // Anonymous namespace
29 48
30Buffer::Buffer(BufferCacheRuntime&, VideoCommon::NullBufferParams null_params) 49Buffer::Buffer(BufferCacheRuntime&, VideoCommon::NullBufferParams null_params)
@@ -76,7 +95,11 @@ GLuint Buffer::View(u32 offset, u32 size, PixelFormat format) {
76 OGLTexture texture; 95 OGLTexture texture;
77 texture.Create(GL_TEXTURE_BUFFER); 96 texture.Create(GL_TEXTURE_BUFFER);
78 const GLenum gl_format{MaxwellToGL::GetFormatTuple(format).internal_format}; 97 const GLenum gl_format{MaxwellToGL::GetFormatTuple(format).internal_format};
79 glTextureBufferRange(texture.handle, gl_format, buffer.handle, offset, size); 98 const GLenum texture_format{GetTextureBufferFormat(gl_format)};
99 if (texture_format != gl_format) {
100 LOG_WARNING(Render_OpenGL, "Emulating SNORM texture buffer with UNORM.");
101 }
102 glTextureBufferRange(texture.handle, texture_format, buffer.handle, offset, size);
80 views.push_back({ 103 views.push_back({
81 .offset = offset, 104 .offset = offset,
82 .size = size, 105 .size = size,