More "stuff" for SS, also a small fix in the program shader cache cache setup."

This commit is contained in:
Ryan Houdek 2012-01-11 04:10:43 -06:00
parent 38f9820905
commit 0b74ead13f
3 changed files with 25 additions and 14 deletions

View File

@ -564,12 +564,16 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n"); WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
WRITE(p, "#define ATTRIN in\n"); WRITE(p, "#define ATTRIN in\n");
WRITE(p, "#define ATTROUT out\n"); WRITE(p, "#define ATTROUT out\n");
WRITE(p, "#define VARYIN in\n");
WRITE(p, "#define VARYOUT out\n");
} }
else else
{ {
WRITE(p, "#version 120\n"); WRITE(p, "#version 120\n");
WRITE(p, "#define ATTRIN attribute\n"); WRITE(p, "#define ATTRIN attribute\n");
WRITE(p, "#define ATTROUT attribute\n"); WRITE(p, "#define ATTROUT attribute\n"); // Can't really be used, but provide it anyway
WRITE(p, "#define VARYIN varying\n");
WRITE(p, "#define VARYOUT varying\n");
} }
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
@ -720,7 +724,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
} }
if (DepthTextureEnable) if (DepthTextureEnable)
WRITE(p, " float depth;\n"); // TODO: Passed to Vertex Shader right? WRITE(p, " float depth;\n"); // TODO: Passed to Vertex Shader right?
WRITE(p, " float4 rawpos = gl_FragCoord;\n"); WRITE(p, "VARYIN float4 rawpos;\n");
WRITE(p, " float4 colors_0 = gl_Color;\n"); WRITE(p, " float4 colors_0 = gl_Color;\n");
WRITE(p, " float4 colors_1 = gl_SecondaryColor;\n"); WRITE(p, " float4 colors_1 = gl_SecondaryColor;\n");
@ -731,14 +735,14 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
WRITE(p, "ATTRIN float3 uv%d_2;\n", i); WRITE(p, "VARYIN float3 uv%d_2;\n", i);
WRITE(p, " float3 uv%d = uv%d_2;\n", i, i); WRITE(p, " float3 uv%d = uv%d_2;\n", i, i);
} }
WRITE(p, "ATTRIN float4 clipPos_2;\n"); WRITE(p, "VARYIN float4 clipPos_2;\n");
WRITE(p, " float4 clipPos = clipPos_2;\n"); WRITE(p, " float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
WRITE(p, "ATTRIN float4 Normal_2;\n"); WRITE(p, "VARYIN float4 Normal_2;\n");
WRITE(p, " float4 Normal = Normal_2;\n"); WRITE(p, " float4 Normal = Normal_2;\n");
} }
} }
@ -749,7 +753,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
WRITE(p, "ATTRIN float4 uv%d_2;\n", i); WRITE(p, "VARYIN float4 uv%d_2;\n", i);
WRITE(p, " float4 uv%d = uv%d_2;\n", i, i); WRITE(p, " float4 uv%d = uv%d_2;\n", i, i);
} }
} }
@ -757,7 +761,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{ {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{ {
WRITE(p, "ATTRIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i); WRITE(p, "VARYIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
WRITE(p, " float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i); WRITE(p, " float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
} }
} }

View File

@ -197,12 +197,16 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n"); WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
WRITE(p, "#define ATTRIN in\n"); WRITE(p, "#define ATTRIN in\n");
WRITE(p, "#define ATTROUT out\n"); WRITE(p, "#define ATTROUT out\n");
WRITE(p, "#define VARYIN in\n");
WRITE(p, "#define VARYOUT out\n");
} }
else else
{ {
WRITE(p, "#version 120\n"); WRITE(p, "#version 120\n");
WRITE(p, "#define ATTRIN attribute\n"); WRITE(p, "#define ATTRIN attribute\n");
WRITE(p, "#define ATTROUT attribute\n"); WRITE(p, "#define ATTROUT attribute\n"); // Can't really be used, but provide it anyway
WRITE(p, "#define VARYIN varying\n");
WRITE(p, "#define VARYOUT varying\n");
} }
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n"); WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
@ -275,10 +279,10 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if (xfregs.numTexGen.numTexGens < 7) if (xfregs.numTexGen.numTexGens < 7)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
WRITE(p, "ATTROUT float3 uv%d_2;\n", i); WRITE(p, "VARYOUT float3 uv%d_2;\n", i);
WRITE(p, "ATTROUT float4 clipPos_2;\n"); WRITE(p, "VARYOUT float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, "ATTROUT float4 Normal_2;\n"); WRITE(p, "VARYOUT float4 Normal_2;\n");
} }
else else
{ {
@ -286,17 +290,18 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
WRITE(p, "ATTROUT float4 uv%d_2;\n", i); WRITE(p, "VARYOUT float4 uv%d_2;\n", i);
} }
else else
{ {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, "ATTROUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i); WRITE(p, "VARYOUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
} }
} }
WRITE(p, " float4 rawpos = gl_Vertex;\n") ; WRITE(p, "VARYOUT float4 rawpos;\n") ;
WRITE(p, "void main()\n{\n"); WRITE(p, "void main()\n{\n");
WRITE(p, "rawpos = gl_Vertex;\n");
} }
else else
{ {

View File

@ -78,6 +78,8 @@ public:
// No idea how necessary this is // No idea how necessary this is
static GLenum SetProgramFormat() static GLenum SetProgramFormat()
{ {
if(!g_ActiveConfig.backend_info.bSupportsGLSLCache)
return 0;
GLint Supported; GLint Supported;
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported); glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported);