gl4: use same depth direction as gles. Round scale_y value.
This commit is contained in:
parent
732e685ea7
commit
8792c06adc
|
@ -46,7 +46,7 @@ int fillAndSortFragmentArray(ivec2 coords) \n\
|
|||
Pixel jp = pixels[pixel_list[j]]; \n\
|
||||
#if DEPTH_SORTED == 1 \n\
|
||||
while (j >= 0 \n\
|
||||
&& (jp.depth < p.depth \n\
|
||||
&& (jp.depth > p.depth \n\
|
||||
|| (jp.depth == p.depth && getPolyNumber(jp) > getPolyNumber(p)))) \n\
|
||||
#else \n\
|
||||
while (j >= 0 && getPolyNumber(jp) > getPolyNumber(p)) \n\
|
||||
|
@ -85,28 +85,28 @@ vec4 resolveAlphaBlend(ivec2 coords) { \n\
|
|||
{ \n\
|
||||
case 0: // Never \n\
|
||||
continue; \n\
|
||||
case 1: // Greater \n\
|
||||
if (frag_depth <= depth) \n\
|
||||
case 1: // Less \n\
|
||||
if (frag_depth >= depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 2: // Equal \n\
|
||||
if (frag_depth != depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 3: // Greater or equal \n\
|
||||
if (frag_depth < depth) \n\
|
||||
case 3: // Less or equal \n\
|
||||
if (frag_depth > depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 4: // Less \n\
|
||||
if (frag_depth >= depth) \n\
|
||||
case 4: // Greater \n\
|
||||
if (frag_depth <= depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 5: // Not equal \n\
|
||||
if (frag_depth == depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 6: // Less or equal \n\
|
||||
if (frag_depth > depth) \n\
|
||||
case 6: // Greater or equal \n\
|
||||
if (frag_depth < depth) \n\
|
||||
continue; \n\
|
||||
break; \n\
|
||||
case 7: // Always \n\
|
||||
|
|
|
@ -114,7 +114,7 @@ uint getNextPixelIndex() \n\
|
|||
void setFragDepth(void) \n\
|
||||
{ \n\
|
||||
highp float w = 100000.0 * gl_FragCoord.w; \n\
|
||||
gl_FragDepth = 1.0 - log2(1.0 + w) / 34.0; \n\
|
||||
gl_FragDepth = log2(1.0 + w) / 34.0; \n\
|
||||
} \n\
|
||||
struct PolyParam { \n\
|
||||
int first; \n\
|
||||
|
|
|
@ -13,28 +13,6 @@ Takes vertex, textures and renders to the currently set up target
|
|||
|
||||
*/
|
||||
|
||||
#define INVERT_DEPTH_FUNC
|
||||
const static u32 Zfunction[]=
|
||||
{
|
||||
GL_NEVER, //GL_NEVER, //0 Never
|
||||
#ifndef INVERT_DEPTH_FUNC
|
||||
GL_LESS, //GL_LESS/*EQUAL*/, //1 Less
|
||||
GL_EQUAL, //GL_EQUAL, //2 Equal
|
||||
GL_LEQUAL, //GL_LEQUAL, //3 Less Or Equal
|
||||
GL_GREATER, //GL_GREATER/*EQUAL*/, //4 Greater
|
||||
GL_NOTEQUAL, //GL_NOTEQUAL, //5 Not Equal
|
||||
GL_GEQUAL, //GL_GEQUAL, //6 Greater Or Equal
|
||||
#else
|
||||
GL_GREATER, //1 Less
|
||||
GL_EQUAL, //2 Equal
|
||||
GL_GEQUAL, //3 Less Or Equal
|
||||
GL_LESS, //4 Greater
|
||||
GL_NOTEQUAL, //5 Not Equal
|
||||
GL_LEQUAL, //6 Greater Or Equal
|
||||
#endif
|
||||
GL_ALWAYS, //GL_ALWAYS, //7 Always
|
||||
};
|
||||
|
||||
static gl4PipelineShader* CurrentShader;
|
||||
extern u32 gcflip;
|
||||
static GLuint geom_fbo;
|
||||
|
@ -236,7 +214,7 @@ template <u32 Type, bool SortingEnabled>
|
|||
//set Z mode, only if required
|
||||
if (Type == ListType_Punch_Through || (pass == 0 && SortingEnabled))
|
||||
{
|
||||
glcache.DepthFunc(Zfunction[6]); // Greater or equal
|
||||
glcache.DepthFunc(GL_GEQUAL);
|
||||
}
|
||||
else if (Type == ListType_Opaque || (pass == 0 && !SortingEnabled))
|
||||
{
|
||||
|
@ -344,51 +322,41 @@ static void DrawModVols(int first, int count)
|
|||
|
||||
glcache.UseProgram(gl4.modvol_shader.program);
|
||||
|
||||
glcache.Enable(GL_DEPTH_TEST);
|
||||
glcache.DepthMask(GL_FALSE);
|
||||
glcache.DepthFunc(Zfunction[4]);
|
||||
glcache.DepthFunc(GL_GREATER);
|
||||
|
||||
if(false)
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
|
||||
ModifierVolumeParam* params = &pvrrc.global_param_mvo.head()[first];
|
||||
|
||||
int mod_base = -1;
|
||||
|
||||
for (u32 cmv = 0; cmv < count; cmv++)
|
||||
{
|
||||
//simply draw the volumes -- for debugging
|
||||
SetCull(0);
|
||||
glDrawArrays(GL_TRIANGLES, first, count * 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Full emulation
|
||||
ModifierVolumeParam& param = params[cmv];
|
||||
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
if (param.count == 0)
|
||||
continue;
|
||||
|
||||
ModifierVolumeParam* params = &pvrrc.global_param_mvo.head()[first];
|
||||
u32 mv_mode = param.isp.DepthMode;
|
||||
|
||||
int mod_base = -1;
|
||||
if (mod_base == -1)
|
||||
mod_base = param.first;
|
||||
|
||||
for (u32 cmv = 0; cmv < count; cmv++)
|
||||
if (!param.isp.VolumeLast && mv_mode > 0)
|
||||
SetMVS_Mode(Or, param.isp); // OR'ing (open volume or quad)
|
||||
else
|
||||
SetMVS_Mode(Xor, param.isp); // XOR'ing (closed volume)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, param.first * 3, param.count * 3);
|
||||
|
||||
if (mv_mode == 1 || mv_mode == 2)
|
||||
{
|
||||
ModifierVolumeParam& param = params[cmv];
|
||||
|
||||
if (param.count == 0)
|
||||
continue;
|
||||
|
||||
u32 mv_mode = param.isp.DepthMode;
|
||||
|
||||
if (mod_base == -1)
|
||||
mod_base = param.first;
|
||||
|
||||
if (!param.isp.VolumeLast && mv_mode > 0)
|
||||
SetMVS_Mode(Or, param.isp); // OR'ing (open volume or quad)
|
||||
else
|
||||
SetMVS_Mode(Xor, param.isp); // XOR'ing (closed volume)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, param.first * 3, param.count * 3);
|
||||
|
||||
if (mv_mode == 1 || mv_mode == 2)
|
||||
{
|
||||
// Sum the area
|
||||
SetMVS_Mode(mv_mode == 1 ? Inclusion : Exclusion, param.isp);
|
||||
glDrawArrays(GL_TRIANGLES, mod_base * 3, (param.first + param.count - mod_base) * 3);
|
||||
mod_base = -1;
|
||||
}
|
||||
// Sum the area
|
||||
SetMVS_Mode(mv_mode == 1 ? Inclusion : Exclusion, param.isp);
|
||||
glDrawArrays(GL_TRIANGLES, mod_base * 3, (param.first + param.count - mod_base) * 3);
|
||||
mod_base = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,6 +425,7 @@ void gl4DrawStrips(GLuint output_fbo, int width, int height)
|
|||
glGenSamplers(2, texSamplers);
|
||||
|
||||
glcache.DepthMask(GL_TRUE);
|
||||
glClearDepthf(0.0);
|
||||
glStencilMask(0xFF);
|
||||
glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCheck();
|
||||
|
||||
|
@ -553,6 +522,7 @@ void gl4DrawStrips(GLuint output_fbo, int width, int height)
|
|||
if (render_pass == 0)
|
||||
{
|
||||
glcache.DepthMask(GL_TRUE);
|
||||
glClearDepthf(0.0);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -159,23 +159,23 @@ void main() \n\
|
|||
highp float frontDepth = texture(DepthTex, gl_FragCoord.xy / textureSize(DepthTex, 0)).r; \n\
|
||||
#if pp_DepthFunc == 0 // Never \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 1 // Greater \n\
|
||||
if (gl_FragDepth <= frontDepth) \n\
|
||||
#elif pp_DepthFunc == 1 // Less \n\
|
||||
if (gl_FragDepth >= frontDepth) \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 2 // Equal \n\
|
||||
if (gl_FragDepth != frontDepth) \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 3 // Greater or equal \n\
|
||||
if (gl_FragDepth < frontDepth) \n\
|
||||
#elif pp_DepthFunc == 3 // Less or equal \n\
|
||||
if (gl_FragDepth > frontDepth) \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 4 // Less \n\
|
||||
if (gl_FragDepth >= frontDepth) \n\
|
||||
#elif pp_DepthFunc == 4 // Greater \n\
|
||||
if (gl_FragDepth <= frontDepth) \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 5 // Not equal \n\
|
||||
if (gl_FragDepth == frontDepth) \n\
|
||||
discard; \n\
|
||||
#elif pp_DepthFunc == 6 // Less or equal \n\
|
||||
if (gl_FragDepth > frontDepth) \n\
|
||||
#elif pp_DepthFunc == 6 // Greater or equal \n\
|
||||
if (gl_FragDepth < frontDepth) \n\
|
||||
discard; \n\
|
||||
#endif \n\
|
||||
#endif \n\
|
||||
|
@ -687,8 +687,8 @@ static bool RenderFrame()
|
|||
{
|
||||
scale_x=fb_scale_x;
|
||||
scale_y=fb_scale_y;
|
||||
if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor >= 0x400)
|
||||
scale_y *= (float)SCALER_CTL.vscalefactor / 0x400;
|
||||
if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor > 0x400)
|
||||
scale_y *= roundf((float)SCALER_CTL.vscalefactor / 0x400);
|
||||
|
||||
//work out scaling parameters !
|
||||
//Pixel doubling is on VO, so it does not affect any pixel operations
|
||||
|
@ -906,7 +906,7 @@ static bool RenderFrame()
|
|||
float min_y = pvrrc.fb_Y_CLIP.min / scale_y;
|
||||
if (!is_rtt)
|
||||
{
|
||||
if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor >= 0x400)
|
||||
if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor > 0x400)
|
||||
{
|
||||
// Clipping is done after scaling/filtering so account for that if enabled
|
||||
height *= (float)SCALER_CTL.vscalefactor / 0x400;
|
||||
|
|
|
@ -7,30 +7,26 @@
|
|||
Drawing and related state management
|
||||
Takes vertex, textures and renders to the currently set up target
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
const static u32 CullMode[]=
|
||||
{
|
||||
|
||||
GL_NONE, //0 No culling No culling
|
||||
GL_NONE, //1 Cull if Small Cull if ( |det| < fpu_cull_val )
|
||||
|
||||
GL_FRONT, //2 Cull if Negative Cull if ( |det| < 0 ) or ( |det| < fpu_cull_val )
|
||||
GL_BACK, //3 Cull if Positive Cull if ( |det| > 0 ) or ( |det| < fpu_cull_val )
|
||||
};
|
||||
const static u32 Zfunction[]=
|
||||
const u32 Zfunction[] =
|
||||
{
|
||||
GL_NEVER, //GL_NEVER, //0 Never
|
||||
GL_LESS, //GL_LESS/*EQUAL*/, //1 Less
|
||||
GL_EQUAL, //GL_EQUAL, //2 Equal
|
||||
GL_LEQUAL, //GL_LEQUAL, //3 Less Or Equal
|
||||
GL_GREATER, //GL_GREATER/*EQUAL*/, //4 Greater
|
||||
GL_NOTEQUAL, //GL_NOTEQUAL, //5 Not Equal
|
||||
GL_GEQUAL, //GL_GEQUAL, //6 Greater Or Equal
|
||||
GL_ALWAYS, //GL_ALWAYS, //7 Always
|
||||
GL_NEVER, //0 Never
|
||||
GL_LESS, //1 Less
|
||||
GL_EQUAL, //2 Equal
|
||||
GL_LEQUAL, //3 Less Or Equal
|
||||
GL_GREATER, //4 Greater
|
||||
GL_NOTEQUAL, //5 Not Equal
|
||||
GL_GEQUAL, //6 Greater Or Equal
|
||||
GL_ALWAYS, //7 Always
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -73,7 +69,6 @@ extern int screen_height;
|
|||
|
||||
PipelineShader* CurrentShader;
|
||||
u32 gcflip;
|
||||
static GLuint g_previous_frame_tex;
|
||||
|
||||
s32 SetTileClip(u32 val, GLint uniform)
|
||||
{
|
||||
|
@ -1003,53 +998,43 @@ void DrawModVols(int first, int count)
|
|||
glcache.UseProgram(gl.modvol_shader.program);
|
||||
glUniform1f(gl.modvol_shader.sp_ShaderColor, 1 - FPU_SHAD_SCALE.scale_factor / 256.f);
|
||||
|
||||
glcache.Enable(GL_DEPTH_TEST);
|
||||
glcache.DepthMask(GL_FALSE);
|
||||
glcache.DepthFunc(GL_GREATER);
|
||||
|
||||
if(0)
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
|
||||
ModifierVolumeParam* params = &pvrrc.global_param_mvo.head()[first];
|
||||
|
||||
int mod_base = -1;
|
||||
|
||||
for (u32 cmv = 0; cmv < count; cmv++)
|
||||
{
|
||||
//simply draw the volumes -- for debugging
|
||||
SetCull(0);
|
||||
glDrawArrays(GL_TRIANGLES, first, count * 3);
|
||||
SetupMainVBO();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Full emulation
|
||||
ModifierVolumeParam& param = params[cmv];
|
||||
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
if (param.count == 0)
|
||||
continue;
|
||||
|
||||
ModifierVolumeParam* params = &pvrrc.global_param_mvo.head()[first];
|
||||
u32 mv_mode = param.isp.DepthMode;
|
||||
|
||||
int mod_base = -1;
|
||||
if (mod_base == -1)
|
||||
mod_base = param.first;
|
||||
|
||||
for (u32 cmv = 0; cmv < count; cmv++)
|
||||
if (!param.isp.VolumeLast && mv_mode > 0)
|
||||
SetMVS_Mode(Or, param.isp); // OR'ing (open volume or quad)
|
||||
else
|
||||
SetMVS_Mode(Xor, param.isp); // XOR'ing (closed volume)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, param.first * 3, param.count * 3);
|
||||
|
||||
if (mv_mode == 1 || mv_mode == 2)
|
||||
{
|
||||
ModifierVolumeParam& param = params[cmv];
|
||||
|
||||
if (param.count == 0)
|
||||
continue;
|
||||
|
||||
u32 mv_mode = param.isp.DepthMode;
|
||||
|
||||
if (mod_base == -1)
|
||||
mod_base = param.first;
|
||||
|
||||
if (!param.isp.VolumeLast && mv_mode > 0)
|
||||
SetMVS_Mode(Or, param.isp); // OR'ing (open volume or quad)
|
||||
else
|
||||
SetMVS_Mode(Xor, param.isp); // XOR'ing (closed volume)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, param.first * 3, param.count * 3);
|
||||
|
||||
if (mv_mode == 1 || mv_mode == 2)
|
||||
{
|
||||
// Sum the area
|
||||
SetMVS_Mode(mv_mode == 1 ? Inclusion : Exclusion, param.isp);
|
||||
glDrawArrays(GL_TRIANGLES, mod_base * 3, (param.first + param.count - mod_base) * 3);
|
||||
mod_base = -1;
|
||||
}
|
||||
// Sum the area
|
||||
SetMVS_Mode(mv_mode == 1 ? Inclusion : Exclusion, param.isp);
|
||||
glDrawArrays(GL_TRIANGLES, mod_base * 3, (param.first + param.count - mod_base) * 3);
|
||||
mod_base = -1;
|
||||
}
|
||||
|
||||
//disable culling
|
||||
SetCull(0);
|
||||
//enable color writes
|
||||
|
|
|
@ -1745,8 +1745,8 @@ bool RenderFrame()
|
|||
{
|
||||
scale_x=fb_scale_x;
|
||||
scale_y=fb_scale_y;
|
||||
if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor >= 0x400)
|
||||
scale_y *= (float)SCALER_CTL.vscalefactor / 0x400;
|
||||
if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor > 0x400)
|
||||
scale_y *= roundf((float)SCALER_CTL.vscalefactor / 0x400);
|
||||
|
||||
//work out scaling parameters !
|
||||
//Pixel doubling is on VO, so it does not affect any pixel operations
|
||||
|
@ -1996,7 +1996,7 @@ bool RenderFrame()
|
|||
float min_y = pvrrc.fb_Y_CLIP.min / scale_y;
|
||||
if (!is_rtt)
|
||||
{
|
||||
if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor >= 0x400)
|
||||
if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor > 0x400)
|
||||
{
|
||||
// Clipping is done after scaling/filtering so account for that if enabled
|
||||
height *= (float)SCALER_CTL.vscalefactor / 0x400;
|
||||
|
|
|
@ -296,3 +296,5 @@ struct TextureCacheData
|
|||
bool NeedsUpdate();
|
||||
bool Delete();
|
||||
};
|
||||
|
||||
extern const u32 Zfunction[8];
|
||||
|
|
Loading…
Reference in New Issue