From be50fca2d6ee3e9c6f28eb1ac511305fb9363205 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 25 Dec 2019 13:05:42 +0100 Subject: [PATCH] gl: (oit) Far plane is 0 in final depth test. minor gl cache reset fix other misc changes --- core/rend/gl4/abuffer.cpp | 2 +- core/rend/gl4/gldraw.cpp | 2 +- core/rend/gl4/gltex.cpp | 6 ++---- core/rend/gles/glcache.h | 11 ++++++++++- core/rend/gles/gldraw.cpp | 2 -- core/rend/gles/gles.cpp | 17 +++++++++-------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/core/rend/gl4/abuffer.cpp b/core/rend/gl4/abuffer.cpp index 9ed0378b9..47e304254 100644 --- a/core/rend/gl4/abuffer.cpp +++ b/core/rend/gl4/abuffer.cpp @@ -71,7 +71,7 @@ vec4 resolveAlphaBlend(ivec2 coords) { vec4 finalColor = texture(tex, gl_FragCoord.xy / textureSize(tex, 0)); vec4 secondaryBuffer = vec4(0.0); // Secondary accumulation buffer - float depth = 1.0; + float depth = 0.0; bool do_depth_test = false; for (int i = 0; i < num_frag; i++) diff --git a/core/rend/gl4/gldraw.cpp b/core/rend/gl4/gldraw.cpp index 31b3d1225..ad6b8ad30 100644 --- a/core/rend/gl4/gldraw.cpp +++ b/core/rend/gl4/gldraw.cpp @@ -159,7 +159,7 @@ template SetTileClip(gp->tileclip, CurrentShader->pp_ClipTest); - //This bit control which pixels are affected + //This bit controls which pixels are affected //by modvols const u32 stencil=(gp->pcw.Shadow!=0)?0x80:0x0; diff --git a/core/rend/gl4/gltex.cpp b/core/rend/gl4/gltex.cpp index 52aba888e..ba607a172 100644 --- a/core/rend/gl4/gltex.cpp +++ b/core/rend/gl4/gltex.cpp @@ -9,10 +9,10 @@ GLuint gl4BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt) gl.rtt.TexAddr=addy>>3; // Find the smallest power of two texture that fits the viewport - int fbh2 = 2; + int fbh2 = 8; while (fbh2 < fbh) fbh2 *= 2; - int fbw2 = 2; + int fbw2 = 8; while (fbw2 < fbw) fbw2 *= 2; @@ -23,8 +23,6 @@ GLuint gl4BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt) fbw2 *= settings.rend.RenderToTextureUpscale; fbh2 *= settings.rend.RenderToTextureUpscale; } - // Get the currently bound frame buffer object. On most platforms this just gives 0. - //glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_i32OriginalFbo); // Create a texture for rendering to gl.rtt.tex = glcache.GenTexture(); diff --git a/core/rend/gles/glcache.h b/core/rend/gles/glcache.h index 341662acb..02630fede 100644 --- a/core/rend/gles/glcache.h +++ b/core/rend/gles/glcache.h @@ -188,9 +188,18 @@ public: _stencil_dpfail = 0xFFFFFFFFu; _stencil_dppass = 0xFFFFFFFFu; _stencil_mask = 0; + if (_texture_cache_size > 0) + { + glDeleteTextures(_texture_cache_size, _texture_ids); + _texture_cache_size = 0; + } } - void DisableCache() { _disable_cache = true; } + void DisableCache() + { + _disable_cache = true; + Reset(); + } void EnableCache() { _disable_cache = false; diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index 4fedb107d..a314efcc2 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -127,9 +127,7 @@ s32 SetTileClip(u32 val, GLint uniform) void SetCull(u32 CulliMode) { if (CullMode[CulliMode]==GL_NONE) - { glcache.Disable(GL_CULL_FACE); - } else { glcache.Enable(GL_CULL_FACE); diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 1c6c1c73e..5e21fc105 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -25,7 +25,8 @@ float fb_scale_x, fb_scale_y; // FIXME //Fragment and vertex shaders code -const char* VertexShaderSource = R"(%s + +static const char* VertexShaderSource = R"(%s #define TARGET_GL %s #define pp_Gouraud %d @@ -290,7 +291,7 @@ void main() } )"; -const char* ModifierVolumeShader = +static const char* ModifierVolumeShader = R"(%s #define TARGET_GL %s @@ -873,14 +874,14 @@ void UpdateFogTexture(u8 *fog_table, GLenum texture_slot, GLint fog_image_format if (fogTextureId == 0) { fogTextureId = glcache.GenTexture(); - glBindTexture(GL_TEXTURE_2D, fogTextureId); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glcache.BindTexture(GL_TEXTURE_2D, fogTextureId); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } else - glBindTexture(GL_TEXTURE_2D, fogTextureId); + glcache.BindTexture(GL_TEXTURE_2D, fogTextureId); u8 temp_tex_buffer[256]; MakeFogTexture(temp_tex_buffer);