gl: workaround nouveau bug (oit). Use float palette coords for switch
Don't switch render type before terminating current one.
This commit is contained in:
parent
ab50bc9936
commit
9e5769912b
|
@ -82,14 +82,17 @@ R"(
|
|||
#define pp_BumpMap %d
|
||||
#define FogClamping %d
|
||||
#define pp_Palette %d
|
||||
#define SWITCH %d
|
||||
#define NOUVEAU %d
|
||||
#define PASS %d
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
#define PASS_DEPTH 0
|
||||
#define PASS_COLOR 1
|
||||
#define PASS_OIT 2
|
||||
|
||||
#if PASS == PASS_DEPTH || PASS == PASS_COLOR
|
||||
#if PASS == PASS_DEPTH || PASS == PASS_COLOR || NOUVEAU == 1
|
||||
out vec4 FragColor;
|
||||
#endif
|
||||
|
||||
|
@ -164,8 +167,13 @@ vec4 fog_clamp(vec4 col)
|
|||
vec4 palettePixel(sampler2D tex, vec2 coords)
|
||||
{
|
||||
int color_idx = int(floor(texture(tex, coords).r * 255.0 + 0.5)) + palette_index;
|
||||
#if SWITCH == 1
|
||||
vec2 c = vec2((mod(float(color_idx), 32.0) * 2.0 + 1.0) / 64.0, (float(color_idx / 32) * 2.0 + 1.0) / 64.0);
|
||||
return texture(palette, c);
|
||||
#else
|
||||
ivec2 c = ivec2(color_idx % 32, color_idx / 32);
|
||||
return texelFetch(palette, c, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -380,7 +388,12 @@ void main()
|
|||
pixel.next = imageAtomicExchange(abufferPointerImg, coords, idx);
|
||||
pixels[idx] = pixel;
|
||||
|
||||
#if NOUVEAU == 0
|
||||
discard;
|
||||
#else
|
||||
// nouveau may be optimizing a bit too aggressively here
|
||||
FragColor = vec4(0.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -412,6 +425,7 @@ bool gl4CompilePipelineShader( gl4PipelineShader* s, const char *pixel_source /*
|
|||
s->cp_AlphaTest, s->pp_InsideClipping, s->pp_UseAlpha,
|
||||
s->pp_Texture, s->pp_IgnoreTexA, s->pp_ShadInstr, s->pp_Offset, s->pp_FogCtrl,
|
||||
s->pp_TwoVolumes, s->pp_Gouraud, s->pp_BumpMap, s->fog_clamping, s->palette,
|
||||
GL_SWITCH, gl.mesa_nouveau,
|
||||
(int)s->pass);
|
||||
|
||||
s->program = gl_CompileAndLink(vshader, pshader);
|
||||
|
@ -557,6 +571,8 @@ static bool gl_create_resources()
|
|||
}
|
||||
|
||||
//setup
|
||||
void gl_DebugOutput(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||
const GLchar *message, const void *userParam);
|
||||
|
||||
static bool gl4_init()
|
||||
{
|
||||
|
@ -570,14 +586,14 @@ static bool gl4_init()
|
|||
|
||||
glcache.DisableCache();
|
||||
|
||||
if (!gl_create_resources())
|
||||
return false;
|
||||
|
||||
//glEnable(GL_DEBUG_OUTPUT);
|
||||
//glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
//glDebugMessageCallback(gl_DebugOutput, NULL);
|
||||
//glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
|
||||
|
||||
if (!gl_create_resources())
|
||||
return false;
|
||||
|
||||
initABuffer();
|
||||
|
||||
if (config::TextureUpscale > 1)
|
||||
|
@ -631,8 +647,6 @@ static void resize(int w, int h)
|
|||
|
||||
static bool RenderFrame(int width, int height)
|
||||
{
|
||||
create_modvol_shader();
|
||||
|
||||
const bool is_rtt = pvrrc.isRTT;
|
||||
|
||||
TransformMatrix<COORD_OPENGL> matrices(pvrrc, width, height);
|
||||
|
|
|
@ -139,6 +139,6 @@ uint packColors(vec4 v) \n\
|
|||
\n\
|
||||
vec4 unpackColors(uint u) \n\
|
||||
{ \n\
|
||||
return vec4(float((u >> 24) & 255) / 255.0, float((u >> 16) & 255) / 255.0, float((u >> 8) & 255) / 255.0, float(u & 255) / 255.0); \n\
|
||||
return vec4(float((u >> 24) & 255u) / 255.0, float((u >> 16) & 255u) / 255.0, float((u >> 8) & 255u) / 255.0, float(u & 255u) / 255.0); \n\
|
||||
} \n\
|
||||
"
|
||||
|
|
|
@ -96,6 +96,7 @@ R"(
|
|||
#define FogClamping %d
|
||||
#define pp_TriLinear %d
|
||||
#define pp_Palette %d
|
||||
#define SWITCH %d
|
||||
|
||||
#if TARGET_GL == GL3 || TARGET_GL == GLES3
|
||||
#if pp_Gouraud == 0
|
||||
|
@ -160,7 +161,7 @@ highp vec4 fog_clamp(lowp vec4 col)
|
|||
lowp vec4 palettePixel(highp vec2 coords)
|
||||
{
|
||||
highp int color_idx = int(floor(texture(tex, coords).FOG_CHANNEL * 255.0 + 0.5)) + palette_index;
|
||||
#if TARGET_GL == GLES2 || TARGET_GL == GL2
|
||||
#if TARGET_GL == GLES2 || TARGET_GL == GL2 || SWITCH == 1
|
||||
highp vec2 c = vec2((mod(float(color_idx), 32.0) * 2.0 + 1.0) / 64.0, (float(color_idx / 32) * 2.0 + 1.0) / 64.0);
|
||||
return texture(palette, c);
|
||||
#else
|
||||
|
@ -495,7 +496,10 @@ void findGLVersion()
|
|||
}
|
||||
}
|
||||
#endif
|
||||
gl.mesa_nouveau = strstr((const char *)glGetString(GL_VERSION), "Mesa") != nullptr && !strcmp((const char *)glGetString(GL_VENDOR), "nouveau");
|
||||
NOTICE_LOG(RENDERER, "Open GL%s version %d.%d", gl.is_gles ? "ES" : "", gl.gl_major, gl.gl_minor);
|
||||
while (glGetError() != GL_NO_ERROR)
|
||||
;
|
||||
}
|
||||
|
||||
struct ShaderUniforms_t ShaderUniforms;
|
||||
|
@ -641,7 +645,7 @@ bool CompilePipelineShader( PipelineShader* s)
|
|||
rc = sprintf(pshader,PixelPipelineShader, gl.glsl_version_header, gl.gl_version,
|
||||
s->cp_AlphaTest,s->pp_InsideClipping,s->pp_UseAlpha,
|
||||
s->pp_Texture,s->pp_IgnoreTexA,s->pp_ShadInstr,s->pp_Offset,s->pp_FogCtrl, s->pp_Gouraud, s->pp_BumpMap,
|
||||
s->fog_clamping, s->trilinear, s->palette);
|
||||
s->fog_clamping, s->trilinear, s->palette, GL_SWITCH);
|
||||
verify(rc + 1 <= (int)sizeof(pshader));
|
||||
|
||||
s->program=gl_CompileAndLink(vshader, pshader);
|
||||
|
@ -833,7 +837,7 @@ bool gl_create_resources();
|
|||
//setup
|
||||
|
||||
#ifndef __APPLE__
|
||||
static void gl_DebugOutput(GLenum source,
|
||||
void gl_DebugOutput(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
|
|
|
@ -132,6 +132,7 @@ struct gl_ctx
|
|||
bool GL_OES_depth24_supported;
|
||||
bool highp_float_supported;
|
||||
float max_anisotropy;
|
||||
bool mesa_nouveau;
|
||||
|
||||
size_t get_index_size() { return index_type == GL_UNSIGNED_INT ? sizeof(u32) : sizeof(u16); }
|
||||
};
|
||||
|
@ -340,3 +341,10 @@ out highp vec4 FragColor; \n\
|
|||
extern "C" struct retro_hw_render_callback hw_render;
|
||||
void termVmuLightgun();
|
||||
#endif
|
||||
|
||||
constexpr int GL_SWITCH =
|
||||
#ifdef __SWITCH__
|
||||
1;
|
||||
#else
|
||||
0;
|
||||
#endif
|
||||
|
|
|
@ -92,12 +92,23 @@ void mainui_loop()
|
|||
if (config::RendererType.pendingChange() || forceReinit)
|
||||
{
|
||||
int api = config::RendererType.isOpenGL() ? 0 : config::RendererType.isVulkan() ? 1 : 2;
|
||||
RenderType oldRender = config::RendererType;
|
||||
mainui_term();
|
||||
config::RendererType.commit();
|
||||
int newApi = config::RendererType.isOpenGL() ? 0 : config::RendererType.isVulkan() ? 1 : 2;
|
||||
if (newApi != api || forceReinit)
|
||||
{
|
||||
// Switch between vulkan/opengl/directx (or full reinit)
|
||||
SwitchRenderApi();
|
||||
RenderType newRender = config::RendererType;
|
||||
// restore current render mode to terminate
|
||||
config::RendererType = oldRender;
|
||||
config::RendererType.commit();
|
||||
TermRenderApi();
|
||||
// set the new render mode and init
|
||||
config::RendererType = newRender;
|
||||
config::RendererType.commit();
|
||||
InitRenderApi();
|
||||
}
|
||||
mainui_init();
|
||||
forceReinit = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue