Commit f655879c authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Update core/rend/gl4

parent 0a71a9b1
DEBUG := 0
NO_REND := 0
HAVE_GL := 1
HAVE_OIT := 0
HAVE_CORE := 0
NO_THREADS := 1
NO_EXCEPTIONS := 0
......@@ -550,6 +551,12 @@ ifeq ($(HAVE_GL), 1)
endif
endif
ifeq ($(HAVE_OIT), 1)
RZDCY_CFLAGS += -DHAVE_OIT
CXXFLAGS += -DHAVE_OIT
CFLAGS += -DHAVE_OIT
endif
ifeq ($(HAVE_CORE), 1)
RZDCY_CFLAGS += -DCORE
CXXFLAGS += -DCORE
......
......@@ -87,9 +87,16 @@ SOURCES_CXX += $(CORE_DIR)/rend/norend/norend.cpp
endif
ifeq ($(HAVE_GL), 1)
ifeq ($(HAVE_OIT), 1)
SOURCES_CXX += $(CORE_DIR)/rend/gl4/gles.cpp \
$(CORE_DIR)/rend/gl4/gldraw.cpp \
$(CORE_DIR)/rend/gl4/gltex.cpp \
$(CORE_DIR)/rend/gl4/render_tr.cpp
else
SOURCES_CXX += $(CORE_DIR)/rend/gles/gles.cpp \
$(CORE_DIR)/rend/gles/gldraw.cpp \
$(CORE_DIR)/rend/gles/gltex.cpp
endif
SOURCES_C += $(LIBRETRO_COMM_DIR)/glsym/rglgen.c \
$(LIBRETRO_COMM_DIR)/glsm/glsm.c
ifeq ($(GLES), 1)
......
......@@ -18,6 +18,7 @@ const static u32 CullMode[]=
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 )
};
#define INVERT_DEPTH_FUNC
const static u32 Zfunction[]=
{
GL_NEVER, //GL_NEVER, //0 Never
......@@ -65,9 +66,6 @@ const static u32 SrcBlendGL[] =
GL_ONE_MINUS_DST_ALPHA
};
extern int gles_screen_width;
extern int gles_screen_height;
PipelineShader* CurrentShader;
extern u32 gcflip;
......@@ -139,9 +137,9 @@ static void SetTextureRepeatMode(GLuint dir, u32 clamp, u32 mirror)
}
template <u32 Type, bool SortingEnabled>
__forceinline void SetGPState(const PolyParam* gp, u32 cflip)
__forceinline void SetGPState(const PolyParam* gp, bool weighted_average = false, u32 front_peeling = 0, u32 cflip=0)
{
CurrentShader = &gl.program_table[
CurrentShader = gl.getShader(
GetProgramID(Type == ListType_Punch_Through ? 1 : 0,
SetTileClip(gp->tileclip, false) + 1,
gp->pcw.Texture,
......@@ -149,11 +147,26 @@ __forceinline void SetGPState(const PolyParam* gp, u32 cflip)
gp->tsp.IgnoreTexA,
gp->tsp.ShadInstr,
gp->pcw.Offset,
gp->tsp.FogCtrl)];
if (CurrentShader->program == -1)
gp->tsp.FogCtrl,
weighted_average,
front_peeling));
if (CurrentShader->program == -1) {
CurrentShader->cp_AlphaTest = Type == ListType_Punch_Through ? 1 : 0;
CurrentShader->pp_ClipTestMode = SetTileClip(gp->tileclip, false);
CurrentShader->pp_Texture = gp->pcw.Texture;
CurrentShader->pp_UseAlpha = gp->tsp.UseAlpha;
CurrentShader->pp_IgnoreTexA = gp->tsp.IgnoreTexA;
CurrentShader->pp_ShadInstr = gp->tsp.ShadInstr;
CurrentShader->pp_Offset = gp->pcw.Offset;
CurrentShader->pp_FogCtrl = gp->tsp.FogCtrl;
CurrentShader->pp_WeightedAverage = weighted_average;
CurrentShader->pp_FrontPeeling = front_peeling;
CompilePipelineShader(CurrentShader);
}
glcache.UseProgram(CurrentShader->program);
ShaderUniforms.Set(CurrentShader);
SetTileClip(gp->tileclip,true);
// This bit controls which pixels are affected
......@@ -162,28 +175,33 @@ __forceinline void SetGPState(const PolyParam* gp, u32 cflip)
glcache.StencilFunc(GL_ALWAYS, stencil, stencil);
glcache.BindTexture(GL_TEXTURE_2D, gp->texid == -1 ? 0 : gp->texid);
SetTextureRepeatMode(GL_TEXTURE_WRAP_S, gp->tsp.ClampU, gp->tsp.FlipU);
SetTextureRepeatMode(GL_TEXTURE_WRAP_T, gp->tsp.ClampV, gp->tsp.FlipV);
//set texture filter mode
if (gp->tsp.FilterMode == 0)
{
//disable filtering, mipmaps
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else
{
//bilinear filtering
//PowerVR supports also trilinear via two passes, but we ignore that for now
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (gp->tcw.MipMapped && settings.rend.UseMipmaps) ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR);
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (gp->texid > 0)
{
SetTextureRepeatMode(GL_TEXTURE_WRAP_S, gp->tsp.ClampU, gp->tsp.FlipU);
SetTextureRepeatMode(GL_TEXTURE_WRAP_T, gp->tsp.ClampV, gp->tsp.FlipV);
//set texture filter mode
if (gp->tsp.FilterMode == 0)
{
//disable filtering, mipmaps
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else
{
//bilinear filtering
//PowerVR supports also trilinear via two passes, but we ignore that for now
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (gp->tcw.MipMapped && settings.rend.UseMipmaps) ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR);
glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
}
if (Type== ListType_Translucent)
{
glcache.Enable(GL_BLEND);
glcache.BlendFunc(SrcBlendGL[gp->tsp.SrcInstr], DstBlendGL[gp->tsp.DstInstr]);
//glcache.Enable(GL_BLEND);
//glcache.BlendFunc(SrcBlendGL[gp->tsp.SrcInstr], DstBlendGL[gp->tsp.DstInstr]);
}
else
glcache.Disable(GL_BLEND);
......@@ -195,18 +213,34 @@ __forceinline void SetGPState(const PolyParam* gp, u32 cflip)
/* Set Z mode, only if required */
if (Type == ListType_Punch_Through || (Type == ListType_Translucent && SortingEnabled))
glcache.DepthFunc(Zfunction[6]);
{
if (gp->isp.DepthMode == 7) { // Fixes VR2 menu but not sure about this one
glcache.DepthFunc(GL_ALWAYS);
}
else
{
glcache.DepthFunc(Zfunction[6]); // Greater or equal
// glcache.DepthFunc(GL_LESS);
}
}
else
{
glcache.DepthFunc(Zfunction[gp->isp.DepthMode]);
}
if (SortingEnabled && settings.pvr.Emulation.AlphaSortMode == 0)
#if TRIG_SORT
if (SortingEnabled && !front_peeling)
glcache.DepthMask(GL_FALSE);
else
#endif
if (!weighted_average)
glcache.DepthMask(!gp->isp.ZWriteDis);
}
template <u32 Type, bool SortingEnabled>
void DrawList(const List<PolyParam>& gply, int first, int count)
void DrawList(const List<PolyParam>& gply, int first, int count, bool
weighted_average = false, u32 front_peeling = 0,
int srcBlendModeFilter = -1, int dstBlendModeFilter = -1)
{
PolyParam* params= &gply.head()[first];
......@@ -223,7 +257,16 @@ void DrawList(const List<PolyParam>& gply, int first, int count)
{
if (params->count>2) /* this actually happens for some games. No idea why .. */
{
SetGPState<Type,SortingEnabled>(params, 0);
if (Type == ListType_Translucent) {
if ((params->tsp.SrcInstr == 0 && params->tsp.DstInstr == 1) // Nothing to do
|| (srcBlendModeFilter != -1 && params->tsp.SrcInstr != srcBlendModeFilter) // src filter doesn't match
|| (dstBlendModeFilter != -1 && params->tsp.DstInstr != dstBlendModeFilter)) { // dst filter doesn't match
params++;
continue;
}
}
SetGPState<Type,SortingEnabled>(params, weighted_average, front_peeling);
glDrawElements(GL_TRIANGLE_STRIP, params->count, GL_UNSIGNED_SHORT, (GLvoid*)(2*params->first));
}
......@@ -240,6 +283,20 @@ void DrawList(const List<PolyParam>& gply, int first, int count)
GL_KEEP);
}
void DrawListTranslucentAutoSorted(const List<PolyParam>& gply, int first, int count, bool weighted_average = false, u32 front_peeling = 0,
int srcBlendModeFilter = -1, int dstBlendModeFilter = -1)
{
DrawList<ListType_Translucent, true>(gply, first, count, weighted_average, front_peeling, srcBlendModeFilter, dstBlendModeFilter);
}
void DrawListOpaque(const List<PolyParam>& gply, int first, int count, bool weighted_average = false, u32 front_peeling = 0)
{
DrawList<ListType_Opaque, false>(gply, first, count, weighted_average, front_peeling);
}
void DrawListPunchThrough(const List<PolyParam>& gply, int first, int count, bool weighted_average = false, u32 front_peeling = 0)
{
DrawList<ListType_Punch_Through, false>(gply, first, count, weighted_average, front_peeling);
}
bool operator<(const PolyParam &left, const PolyParam &right)
{
/* put any condition you want to sort on here */
......@@ -774,10 +831,20 @@ last *out* : flip, merge*out* &clear from last merge
//restore states
glcache.Enable(GL_DEPTH_TEST);
glcache.DepthMask(GL_TRUE);
}
void InitDualPeeling();
void RenderAverageColors();
void RenderWeightedBlended();
void RenderFrontToBackPeeling(int first, int count);
void DualPeelingReshape(int w, int h);
void DrawStrips(void)
{
InitDualPeeling();
DualPeelingReshape(gles_screen_width, gles_screen_height);
SetupMainVBO();
//Draw the strips !
......@@ -792,11 +859,11 @@ void DrawStrips(void)
//initial state
glcache.Enable(GL_DEPTH_TEST);
glcache.DepthMask(GL_TRUE);
#if 0
glClearDepth(0.f);
#endif
glcache.DepthMask(GL_TRUE);
glcache.StencilMask(0xFF);
glClear(GL_DEPTH_BUFFER_BIT );
......@@ -811,24 +878,27 @@ void DrawStrips(void)
// Modifier volumes
DrawModVols(previous_pass.mvo_count, current_pass.mvo_count - previous_pass.mvo_count);
if (UsingAutoSort())
GenSorted(previous_pass.tr_count,
current_pass.tr_count - previous_pass.tr_count);
//Alpha blended
if (settings.pvr.Emulation.AlphaSortMode == 0)
{
if (pvrrc.isAutoSort)
DrawSorted(render_pass < pvrrc.render_passes.used() - 1);
else
DrawList<ListType_Translucent, false>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
}
else if (settings.pvr.Emulation.AlphaSortMode == 1)
{
if (pvrrc.isAutoSort)
SortPParams(previous_pass.tr_count,
current_pass.tr_count - previous_pass.tr_count);
DrawList<ListType_Translucent, true>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count );
// if (hack_on)
// RenderAverageColors();
// else
RenderFrontToBackPeeling(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
//RenderWeightedBlended();
// if (pvrrc.isAutoSort)
// GenSorted(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
//
//#if TRIG_SORT
// if (pvrrc.isAutoSort)
// DrawSorted(render_pass < pvrrc.render_passes.used() - 1);
// else
// DrawList<ListType_Translucent,false>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
//#else
// if (pvrrc.isAutoSort)
// SortPParams(previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
// DrawList<ListType_Translucent,true>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count);
//#endif
SetupMainVBO();
}
previous_pass = current_pass;
......
......@@ -20,38 +20,6 @@ bool KillTex=false;
GLCache glcache;
gl_ctx gl;
struct ShaderUniforms_t
{
float PT_ALPHA;
float scale_coefs[4];
float depth_coefs[4];
float fog_den_float;
float ps_FOG_COL_RAM[3];
float ps_FOG_COL_VERT[3];
float fog_coefs[2];
void Set(PipelineShader* s)
{
if (s->cp_AlphaTestValue!=-1)
glUniform1f(s->cp_AlphaTestValue, PT_ALPHA);
if (s->scale!=-1)
glUniform4fv( s->scale, 1, scale_coefs);
if (s->depth_scale!=-1)
glUniform4fv( s->depth_scale, 1, depth_coefs);
if (s->sp_FOG_DENSITY!=-1)
glUniform1f( s->sp_FOG_DENSITY, fog_den_float);
if (s->sp_FOG_COL_RAM!=-1)
glUniform3fv( s->sp_FOG_COL_RAM, 1, ps_FOG_COL_RAM);
if (s->sp_FOG_COL_VERT!=-1)
glUniform3fv( s->sp_FOG_COL_VERT, 1, ps_FOG_COL_VERT);
}
} ShaderUniforms;
u32 gcflip;
float fb_scale_x = 0.0f;
......@@ -92,12 +60,14 @@ uniform " HIGHP " vec4 depth_scale; \n\
" vary " " LOWP " vec4 vtx_base; \n\
" vary " " LOWP " vec4 vtx_offs; \n\
" vary " " MEDIUMP " vec2 vtx_uv; \n\
" vary " " MEDIUMP " float vtx_z; \n\
void main() \n\
{ \n\
vtx_base=in_base; \n\
vtx_offs=in_offs; \n\
vtx_uv=in_uv; \n\
vec4 vpos=in_pos; \n\
vtx_z = vpos.z; \n\
vpos.w=1.0/vpos.z; \n"
#ifndef GLES
"\
......@@ -118,7 +88,7 @@ void main() \n\
const char* PixelPipelineShader =
#ifndef HAVE_OPENGLES
"#version 120 \n"
"#version 140 \n"
#endif
"\
\
......@@ -130,6 +100,21 @@ const char* PixelPipelineShader =
#define pp_ShadInstr %d \n\
#define pp_Offset %d \n\
#define pp_FogCtrl %d \n\
#define pp_WeightedAverage %d \n\
#define pp_FrontPeeling %d \n\
#if pp_WeightedAverage == 1 \n\
#extension GL_ARB_draw_buffers : require \n\
#endif \n\
#if pp_FrontPeeling == 2 \n\
uniform sampler2DRect DepthTex; \n\
#endif \n"
#ifndef GLES
"\
#if pp_WeightedAverage == 0 \n\
out vec4 FragColor; \n\
#endif \n"
#endif
"\
/* Shader program params*/ \n\
/* gles has no alpha test stage, so its emulated on the shader */ \n\
uniform " LOWP " float cp_AlphaTestValue; \n\
......@@ -141,6 +126,7 @@ uniform sampler2D tex,fog_table; \n\
" vary " " LOWP " vec4 vtx_base; \n\
" vary " " LOWP " vec4 vtx_offs; \n\
" vary " " MEDIUMP " vec2 vtx_uv; \n\
" vary " " MEDIUMP " float vtx_z; \n\
" LOWP " float fog_mode2(" HIGHP " float w) \n\
{ \n\
" HIGHP " float z = clamp(w * sp_FOG_DENSITY, 1.0, 255.9999); \n\
......@@ -151,7 +137,20 @@ uniform sampler2D tex,fog_table; \n\
return fog_coef.a; \n\
} \n\
void main() \n\
{ \n\
{ \n"
#ifndef GLES
"\
highp float w = 100000.0 * gl_FragCoord.w; \n\
gl_FragDepth = 1 - log2(1.0 + w) / 34; \n"
#endif
"\
#if pp_FrontPeeling == 2 \n\
// Bit-exact comparison between FP32 z-buffer and fragment depth \n\
highp float frontDepth = texture2DRect(DepthTex, gl_FragCoord.xy).r; \n\
if (gl_FragDepth <= frontDepth) { \n\
discard; \n\
} \n\
#endif \n\
// Clip outside the box \n\
#if pp_ClipTestMode==1 \n\
if (gl_FragCoord.x < pp_ClipTest.x || gl_FragCoord.x > pp_ClipTest.z \n\
......@@ -165,11 +164,11 @@ void main() \n\
discard; \n\
#endif \n\
\n\
" LOWP " vec4 color=vtx_base; \n\
" HIGHP " vec4 color=vtx_base; \n\
#if pp_UseAlpha==0 \n\
color.a=1.0; \n\
#endif\n\
#if pp_FogCtrl==3 \n\
#if pp_FogCtrl==3 // LUT Mode 2 \n\
color=vec4(sp_FOG_COL_RAM.rgb,fog_mode2(gl_FragCoord.w)); \n\
#endif\n\
#if pp_Texture==1 \n\
......@@ -183,23 +182,23 @@ void main() \n\
#if cp_AlphaTest == 1 \n\
if (cp_AlphaTestValue>texcol.a) discard;\n\
#endif \n\
#if pp_ShadInstr==0 \n\
#if pp_ShadInstr==0 // DECAL \n\
{ \n\
color=texcol; \n\
} \n\
#endif\n\
#if pp_ShadInstr==1 \n\
#if pp_ShadInstr==1 // MODULATE \n\
{ \n\
color.rgb*=texcol.rgb; \n\
color.a=texcol.a; \n\
} \n\
#endif\n\
#if pp_ShadInstr==2 \n\
#if pp_ShadInstr==2 // DECAL ALPHA \n\
{ \n\
color.rgb=mix(color.rgb,texcol.rgb,texcol.a); \n\
} \n\
#endif\n\
#if pp_ShadInstr==3 \n\
#if pp_ShadInstr==3 // MODULATE ALPHA \n\
{ \n\
color*=texcol; \n\
} \n\
......@@ -208,26 +207,39 @@ void main() \n\
#if pp_Offset==1 \n\
{ \n\
color.rgb+=vtx_offs.rgb; \n\
if (pp_FogCtrl==1) \n\
if (pp_FogCtrl==1) // Per vertex \n\
color.rgb=mix(color.rgb,sp_FOG_COL_VERT.rgb,vtx_offs.a); \n\
} \n\
#endif\n\
} \n\
#endif\n\
#if pp_FogCtrl==0 \n\
#if pp_FogCtrl==0 // LUT \n\
{ \n\
color.rgb=mix(color.rgb,sp_FOG_COL_RAM.rgb,fog_mode2(gl_FragCoord.w)); \n\
} \n\
#endif\n\
#if cp_AlphaTest == 1 \n\
color.a=1.0; \n\
#endif \n"
#ifndef GLES
"\
float w = gl_FragCoord.w * 100000.0; \n\
gl_FragDepth = log2(1.0 + w) / 34.0; \n"
#endif
FRAGCOL "=color; \n\
#endif \n\
\n\
\n\
#if pp_WeightedAverage == 1 \n\
// Average colors \n\
gl_FragData[0] = vec4(color.rgb * color.a, color.a); \n\
gl_FragData[1] = vec4(1.0); \n\
// Weighted Blended \n\
// float viewDepth = abs(1.0 / gl_FragCoord.w); \n\
// float linearDepth = viewDepth * 4.5; // uDepthScale \n\
// float weight = clamp(0.03 / (1e-5 + pow(linearDepth/10, 3.0)), 1e-2, 3e3); \n\
// gl_FragData[0] = vec4(color.rgb * color.a, color.a) * weight; \n\
// gl_FragData[1] = vec4(color.a); \n\
#elif pp_FrontPeeling == 1 \n"
FRAGCOL " = vec4(color.rgb * color.a, 1.0 - color.a); \n\
#elif pp_FrontPeeling == 2 \n"
FRAGCOL " = vec4(color.rgb * color.a, color.a); \n\
#else \n"
FRAGCOL "=color; \n\
#endif \n\
}";
const char* ModifierVolumeShader =
......@@ -238,8 +250,8 @@ void main() \n\
{ \n"
#ifndef GLES
"\
float w = gl_FragCoord.w * 100000.0; \n\
gl_FragDepth = log2(1.0 + w) / 34.0; \n"
float w = 100000.0 * gl_FragCoord.w; \n\
gl_FragDepth = 1 - log2(1.0 + w) / 34.0; \n"
#endif
FRAGCOL "=vec4(0.0, 0.0, 0.0, sp_ShaderColor); \n\
}";
......@@ -257,7 +269,9 @@ int GetProgramID(
u32 pp_IgnoreTexA,
u32 pp_ShadInstr,
u32 pp_Offset,
u32 pp_FogCtrl)
u32 pp_FogCtrl,
bool pp_WeightedAverage,
u32 pp_FrontPeeling)
{
u32 rv=0;
......@@ -269,6 +283,8 @@ int GetProgramID(
rv<<=2; rv|=pp_ShadInstr;
rv<<=1; rv|=pp_Offset;
rv<<=2; rv|=pp_FogCtrl;
rv <<= 1; rv |= pp_WeightedAverage;
rv <<= 2; rv |= pp_FrontPeeling;
return rv;
}
......@@ -355,13 +371,13 @@ static GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentSh
}
bool CompilePipelineShader(PipelineShader *s)
bool CompilePipelineShader(PipelineShader *s, const char *source /* = PixelPipelineShader */)
{
char pshader[8192];
sprintf(pshader,PixelPipelineShader,
sprintf(pshader, source,
s->cp_AlphaTest,s->pp_ClipTestMode,s->pp_UseAlpha,
s->pp_Texture,s->pp_IgnoreTexA,s->pp_ShadInstr,s->pp_Offset,s->pp_FogCtrl);
s->pp_Texture,s->pp_IgnoreTexA,s->pp_ShadInstr,s->pp_Offset,s->pp_FogCtrl, (int)s->pp_WeightedAverage, s->pp_FrontPeeling);
s->program = gl_CompileAndLink(VertexShaderSource,pshader);
......@@ -402,6 +418,18 @@ bool CompilePipelineShader(PipelineShader *s)
ShaderUniforms.Set(s);
// Depth peeling: use texture 1 for depth texture
gu = glGetUniformLocation(s->program, "DepthTex");
if (gu != -1)
glUniform1i(gu, 1);
else
{
// Shadow stencil for OP/PT rendering pass
gu = glGetUniformLocation(s->program, "shadow_stencil");
if (gu != -1)
glUniform1i(gu, 1);
}
return glIsProgram(s->program)==GL_TRUE;
}
......@@ -448,8 +476,6 @@ static bool gl_create_resources(void)
u32 pp_IgnoreTexA;
u32 pp_Offset;
u32 pp_ShadInstr;
PipelineShader* dshader = 0;
u32 compile = 0;
/* create VBOs */
glGenBuffers(1, &gl.vbo.geometry);
......@@ -457,7 +483,10 @@ static bool gl_create_resources(void)
glGenBuffers(1, &gl.vbo.idxs);
glGenBuffers(1, &gl.vbo.idxs2);
#if 0
memset(gl.program_table,0,sizeof(gl.program_table));
PipelineShader* dshader = 0;
u32 compile = 0;
for(cp_AlphaTest = 0; cp_AlphaTest <= 1; cp_AlphaTest++)
{
......@@ -502,12 +531,15 @@ static bool gl_create_resources(void)
}
}
}
#endif
gl.modvol_shader.program = gl_CompileAndLink(VertexShaderSource,ModifierVolumeShader);
gl.modvol_shader.scale = glGetUniformLocation(gl.modvol_shader.program, "scale");
gl.modvol_shader.sp_ShaderColor = glGetUniformLocation(gl.modvol_shader.program, "sp_ShaderColor");
gl.modvol_shader.depth_scale = glGetUniformLocation(gl.modvol_shader.program, "depth_scale");
//define PRECOMPILE_SHADERS
#ifdef PRECOMPILE_SHADERS
if (settings.pvr.Emulation.precompile_shaders)
{
for (i=0;i<sizeof(gl.program_table)/sizeof(gl.program_table[0]);i++)
......@@ -516,6 +548,7 @@ static bool gl_create_resources(void)
return false;
}
}
#endif
return true;
}
......@@ -572,7 +605,7 @@ static bool RenderFrame(void)
//Setup the matrix
float vtx_min_fZ = 0.f;
float vtx_max_fZ = pvrrc.fZ_max;
//printf("Zmin %g Zmax %g\n", pvrrc.fZ_min, pvrrc.fZ_max);
//sanitise the values, now with NaN detection (for omap)
//0x49800000 is 1024*1024. Using integer math to avoid issues w/ infs and nans
if ((s32&)vtx_max_fZ<0 || (u32&)vtx_max_fZ>0x49800000)
......@@ -790,6 +823,7 @@ static bool RenderFrame(void)
ShaderUniforms.PT_ALPHA=(PT_ALPHA_REF&0xFF)/255.0f;
#if 0
for (u32 i=0;i<sizeof(gl.program_table)/sizeof(gl.program_table[0]);i++)
{
PipelineShader* s=&gl.program_table[i];
......@@ -800,7 +834,7 @@ static bool RenderFrame(void)
ShaderUniforms.Set(s);
}
#endif
//setup render target first