mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
fix formatting uglies introduced in glsl-master branch
This commit is contained in:
committed by
Sonicadvance1
parent
4a4833e617
commit
31a8424bcc
@@ -573,7 +573,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
||||
|
||||
// GLSL Option
|
||||
{
|
||||
if(strstr(choice_backend->GetString(choice_backend->GetSelection()).ToAscii(), "OpenGL") != NULL)
|
||||
if (strstr(choice_backend->GetString(choice_backend->GetSelection()).ToAscii(), "OpenGL") != NULL)
|
||||
{
|
||||
wxCheckBox* const cb_GLSL = CreateCheckBox(page_advanced, _("Use GLSL Shaders"), wxGetTranslation(GLSL_desc), vconfig.bUseGLSL);
|
||||
szr_misc->Add(cb_GLSL);
|
||||
|
||||
@@ -112,7 +112,7 @@ protected:
|
||||
void Event_ProgressiveScan(wxCommandEvent &ev)
|
||||
{
|
||||
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", ev.GetInt());
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive = ev.GetInt();
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive = !!ev.GetInt();
|
||||
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
@@ -511,23 +511,25 @@ static void BuildSwapModeTable()
|
||||
|
||||
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
|
||||
{
|
||||
if(ApiType == API_GLSL)
|
||||
if (ApiType == API_GLSL)
|
||||
return ""; // Nothing to do here
|
||||
static char result[64];
|
||||
sprintf(result, " : register(%s%d)", prefix, num);
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* WriteBinding(API_TYPE ApiType, const u32 num)
|
||||
{
|
||||
if(ApiType != API_GLSL || !g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
if (ApiType != API_GLSL || !g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
return "";
|
||||
static char result[64];
|
||||
sprintf(result, "layout(binding = %d) ", num);
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *WriteLocation(API_TYPE ApiType)
|
||||
{
|
||||
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
return "";
|
||||
static char result[64];
|
||||
sprintf(result, "uniform ");
|
||||
@@ -559,7 +561,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
DepthTextureEnable = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable) || g_ActiveConfig.bEnablePerPixelDepth ;
|
||||
|
||||
if(ApiType == API_GLSL)
|
||||
if (ApiType == API_GLSL)
|
||||
{
|
||||
// A few required defines and ones that will make our lives a lot easier
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding || g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
@@ -573,7 +575,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
else
|
||||
WRITE(p, "#version 120\n");
|
||||
|
||||
if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
|
||||
// Silly differences
|
||||
WRITE(p, "#define float2 vec2\n");
|
||||
@@ -602,7 +604,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
{
|
||||
// Declare samplers
|
||||
|
||||
if(ApiType != API_D3D11)
|
||||
if (ApiType != API_D3D11)
|
||||
{
|
||||
WRITE(p, "uniform sampler2D ");
|
||||
}
|
||||
@@ -618,7 +620,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
bfirst = false;
|
||||
}
|
||||
WRITE(p, ";\n");
|
||||
if(ApiType == API_D3D11)
|
||||
if (ApiType == API_D3D11)
|
||||
{
|
||||
WRITE(p, "Texture2D ");
|
||||
bfirst = true;
|
||||
@@ -632,7 +634,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
|
||||
WRITE(p, "\n");
|
||||
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "layout(std140) uniform PSBlock {\n");
|
||||
|
||||
WRITE(p, "%sfloat4 "I_COLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_COLORS));
|
||||
@@ -648,13 +650,13 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
WRITE(p, "%sfloat4 "I_PLIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PLIGHTS));
|
||||
WRITE(p, "%sfloat4 "I_PMATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PMATERIALS));
|
||||
|
||||
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "};\n");
|
||||
|
||||
if(ApiType != API_GLSL)
|
||||
if (ApiType != API_GLSL)
|
||||
{
|
||||
WRITE(p, "void main(\n");
|
||||
if(ApiType != API_D3D11)
|
||||
if (ApiType != API_D3D11)
|
||||
{
|
||||
WRITE(p, " out float4 ocol0 : COLOR0,%s%s\n in float4 rawpos : %s,\n",
|
||||
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : COLOR1," : "",
|
||||
@@ -702,7 +704,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
// Once we switch to GLSL 1.3 we will bind a lot of these.
|
||||
|
||||
|
||||
if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
{
|
||||
// This won't get hit unless we support GL 3.3
|
||||
WRITE(p, " layout(location = 0) out float4 ocol0;\n");
|
||||
@@ -712,7 +714,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
{
|
||||
WRITE(p, " float4 ocol0;\n");
|
||||
}
|
||||
if(DepthTextureEnable)
|
||||
if (DepthTextureEnable)
|
||||
WRITE(p, " float depth;\n"); // TODO: Passed to Vertex Shader right?
|
||||
WRITE(p, " float4 rawpos = gl_FragCoord;\n");
|
||||
|
||||
@@ -725,13 +727,13 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
for (int i = 0; i < numTexgen; ++i)
|
||||
WRITE(p, " float3 uv%d = gl_TexCoord[%d].xyz;\n", i, i);
|
||||
WRITE(p, " float4 clipPos = gl_TexCoord[%d];\n", numTexgen);
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
WRITE(p, " float4 Normal = gl_TexCoord[%d];\n", numTexgen + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// wpos is in w of first 4 texcoords
|
||||
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)
|
||||
WRITE(p, " float4 uv%d = gl_TexCoord[%d];\n", i, i);
|
||||
@@ -783,7 +785,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
" float4 cc2=float4(0.0f,0.0f,0.0f,0.0f), cprev=float4(0.0f,0.0f,0.0f,0.0f);\n"
|
||||
" float4 crastemp=float4(0.0f,0.0f,0.0f,0.0f),ckonsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n\n");
|
||||
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
{
|
||||
if (xfregs.numTexGen.numTexGens < 7)
|
||||
{
|
||||
@@ -830,7 +832,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
|
||||
// indirect texture map lookup
|
||||
for(u32 i = 0; i < bpmem.genMode.numindstages; ++i)
|
||||
for (u32 i = 0; i < bpmem.genMode.numindstages; ++i)
|
||||
{
|
||||
if (nIndirectStagesUsed & (1<<i))
|
||||
{
|
||||
@@ -860,7 +862,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
for (int i = 0; i < numStages; i++)
|
||||
WriteStage(p, i, ApiType); //build the equation for this stage
|
||||
|
||||
if(numStages)
|
||||
if (numStages)
|
||||
{
|
||||
// The results of the last texenv stage are put onto the screen,
|
||||
// regardless of the used destination register
|
||||
@@ -889,15 +891,15 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
WRITE(p, "ocol0 = 0;\n");
|
||||
if(DepthTextureEnable)
|
||||
WRITE(p, "depth = 1.f;\n");
|
||||
if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
WRITE(p, "ocol1 = vec4(0.0f);\n");
|
||||
if(ApiType == API_GLSL)
|
||||
if (ApiType == API_GLSL)
|
||||
{
|
||||
// Once we switch to GLSL 1.3 and bind variables, we won't need to do this
|
||||
if (dstAlphaMode != DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
WRITE(p, "gl_FragData[0] = ocol0;\n");
|
||||
if(DepthTextureEnable)
|
||||
WRITE(p, "gl_FragDepth = depth;\n");
|
||||
if (DepthTextureEnable)
|
||||
WRITE(p, "gl_FragDepth = depth;\n");
|
||||
}
|
||||
WRITE(p, "discard;\n");
|
||||
if(ApiType != API_D3D11)
|
||||
@@ -945,9 +947,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
// ...and the alpha from ocol0 will be written to the framebuffer.
|
||||
WRITE(p, " ocol0.a = " I_ALPHA"[0].a;\n");
|
||||
|
||||
if(ApiType == API_GLSL)
|
||||
if (ApiType == API_GLSL)
|
||||
{
|
||||
if(DepthTextureEnable)
|
||||
if (DepthTextureEnable)
|
||||
WRITE(p, "gl_FragDepth = depth;\n");
|
||||
if (dstAlphaMode != DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
WRITE(p, "gl_FragData[0] = ocol0;\n");
|
||||
@@ -1109,10 +1111,10 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
|
||||
if (bpmem.tevorders[n/2].getEnable(n&1))
|
||||
{
|
||||
if(!bHasIndStage)
|
||||
if (!bHasIndStage)
|
||||
{
|
||||
// calc tevcord
|
||||
if(bHasTexCoord)
|
||||
if (bHasTexCoord)
|
||||
WRITE(p, "tevcoord.xy = uv%d.xy;\n", texcoord);
|
||||
else
|
||||
WRITE(p, "tevcoord.xy = float2(0.0f, 0.0f);\n");
|
||||
@@ -1132,7 +1134,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
int kc = bpmem.tevksel[n / 2].getKC(n & 1);
|
||||
int ka = bpmem.tevksel[n / 2].getKA(n & 1);
|
||||
WRITE(p, "konsttemp = float4(%s, %s);\n", tevKSelTableC[kc], tevKSelTableA[ka]);
|
||||
if(kc > 7 || ka > 7)
|
||||
if (kc > 7 || ka > 7)
|
||||
{
|
||||
WRITE(p, "ckonsttemp = frac(konsttemp * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
}
|
||||
@@ -1231,7 +1233,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
if (cc.shift > TEVSCALE_1)
|
||||
WRITE(p, "%s*(", tevScaleTable[cc.shift]);
|
||||
|
||||
if(!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD))
|
||||
if (!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD))
|
||||
WRITE(p, "%s%s", tevCInputTable[cc.d], tevOpTable[cc.op]);
|
||||
|
||||
if (cc.a == cc.b)
|
||||
@@ -1281,7 +1283,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
if (ac.shift > TEVSCALE_1)
|
||||
WRITE(p, "%s*(", tevScaleTable[ac.shift]);
|
||||
|
||||
if(!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD))
|
||||
if (!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD))
|
||||
WRITE(p, "%s.a%s", tevAInputTable[ac.d], tevOpTable[ac.op]);
|
||||
|
||||
if (ac.a == ac.b)
|
||||
@@ -1297,7 +1299,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
|
||||
WRITE(p, "%s",tevBiasTable[ac.bias]);
|
||||
|
||||
if (ac.shift>0)
|
||||
if (ac.shift > 0)
|
||||
WRITE(p, ")");
|
||||
|
||||
}
|
||||
@@ -1386,6 +1388,7 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
||||
I_ALPHA"[0].g"
|
||||
};
|
||||
|
||||
|
||||
// using discard then return works the same in cg and dx9 but not in dx11
|
||||
WRITE(p, "if(!( ");
|
||||
|
||||
@@ -1399,9 +1402,9 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
||||
<<<<<<< HEAD
|
||||
WRITE(p, ")) {\n");
|
||||
|
||||
WRITE(p, "ocol0 = float4(0);\n");
|
||||
WRITE(p, "ocol0 = float4(0.0f);\n");
|
||||
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
WRITE(p, "ocol1 = 0;\n");
|
||||
WRITE(p, "ocol1 = float4(0.0f);\n");
|
||||
if (DepthTextureEnable)
|
||||
WRITE(p, "depth = 1.f;\n");
|
||||
|
||||
@@ -1426,13 +1429,6 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
|
||||
|
||||
WRITE(p, "}\n");
|
||||
|
||||
=======
|
||||
WRITE(p, ")){ocol0 = float4(0.0f);%s%s discard;%s}\n",
|
||||
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "ocol1 = vec4(0.0f);" : "",
|
||||
DepthTextureEnable ? "depth = 1.f;" : "",
|
||||
(ApiType != API_D3D11) ? "return;" : "");
|
||||
return true;
|
||||
>>>>>>> Few compiler errors that got exposed once I got Dual Source Blending working. Seems it isn't working quite 100% either. Good chance I missed something anyway.
|
||||
}
|
||||
|
||||
static const char *tevFogFuncsTable[] =
|
||||
@@ -1449,7 +1445,8 @@ static const char *tevFogFuncsTable[] =
|
||||
|
||||
static void WriteFog(char *&p)
|
||||
{
|
||||
if(bpmem.fog.c_proj_fsel.fsel == 0)return;//no Fog
|
||||
if (bpmem.fog.c_proj_fsel.fsel == 0)
|
||||
return; // no Fog
|
||||
|
||||
if (bpmem.fog.c_proj_fsel.proj == 0)
|
||||
{
|
||||
@@ -1467,7 +1464,7 @@ static void WriteFog(char *&p)
|
||||
// x_adjust = sqrt((x-center)^2 + k^2)/k
|
||||
// ze *= x_adjust
|
||||
//this is complitly teorical as the real hard seems to use a table intead of calculate the values.
|
||||
if(bpmem.fogRange.Base.Enabled)
|
||||
if (bpmem.fogRange.Base.Enabled)
|
||||
{
|
||||
WRITE (p, " float x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n");
|
||||
WRITE (p, " x_adjust = sqrt(x_adjust * x_adjust + " I_FOG"[2].z * " I_FOG"[2].z) / " I_FOG"[2].z;\n");
|
||||
@@ -1476,17 +1473,15 @@ static void WriteFog(char *&p)
|
||||
|
||||
WRITE (p, " float fog = saturate(ze - " I_FOG"[1].z);\n");
|
||||
|
||||
if(bpmem.fog.c_proj_fsel.fsel > 3)
|
||||
if (bpmem.fog.c_proj_fsel.fsel > 3)
|
||||
{
|
||||
WRITE(p, "%s", tevFogFuncsTable[bpmem.fog.c_proj_fsel.fsel]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bpmem.fog.c_proj_fsel.fsel != 2)
|
||||
if (bpmem.fog.c_proj_fsel.fsel != 2)
|
||||
WARN_LOG(VIDEO, "Unknown Fog Type! %08x", bpmem.fog.c_proj_fsel.fsel);
|
||||
}
|
||||
|
||||
WRITE(p, " prev.rgb = lerp(prev.rgb," I_FOG"[0].rgb,fog);\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -185,65 +185,64 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
char *p = text;
|
||||
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
|
||||
|
||||
if(ApiType == API_GLSL)
|
||||
if (ApiType == API_GLSL)
|
||||
{
|
||||
// A few required defines and ones that will make our lives a lot easier
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding || g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
WRITE(p, "#version 330 compatibility\n");
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
|
||||
WRITE(p, "#define ATTRIN in\n");
|
||||
WRITE(p, "#define ATTROUT out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "#version 120\n");
|
||||
WRITE(p, "#define ATTRIN attribute\n");
|
||||
WRITE(p, "#define ATTROUT attribute\n");
|
||||
}
|
||||
if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
|
||||
// Silly differences
|
||||
WRITE(p, "#define float2 vec2\n");
|
||||
WRITE(p, "#define float3 vec3\n");
|
||||
WRITE(p, "#define float4 vec4\n");
|
||||
// A few required defines and ones that will make our lives a lot easier
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding || g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
WRITE(p, "#version 330 compatibility\n");
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
|
||||
WRITE(p, "#define ATTRIN in\n");
|
||||
WRITE(p, "#define ATTROUT out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "#version 120\n");
|
||||
WRITE(p, "#define ATTRIN attribute\n");
|
||||
WRITE(p, "#define ATTROUT attribute\n");
|
||||
}
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
|
||||
// Silly differences
|
||||
WRITE(p, "#define float2 vec2\n");
|
||||
WRITE(p, "#define float3 vec3\n");
|
||||
WRITE(p, "#define float4 vec4\n");
|
||||
|
||||
// cg to glsl function translation
|
||||
WRITE(p, "#define frac(x) fract(x)\n");
|
||||
WRITE(p, "#define saturate(x) clamp(x, 0.0f, 1.0f)\n");
|
||||
WRITE(p, "#define lerp(x, y, z) mix(x, y, z)\n");
|
||||
// cg to glsl function translation
|
||||
WRITE(p, "#define frac(x) fract(x)\n");
|
||||
WRITE(p, "#define saturate(x) clamp(x, 0.0f, 1.0f)\n");
|
||||
WRITE(p, "#define lerp(x, y, z) mix(x, y, z)\n");
|
||||
}
|
||||
|
||||
// uniforms
|
||||
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "layout(std140) uniform VSBlock {\n");
|
||||
|
||||
WRITE(p, "%sfloat4 "I_POSNORMALMATRIX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
|
||||
WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
|
||||
WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS));
|
||||
WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_LIGHTS));
|
||||
WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices
|
||||
WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType),WriteRegister(ApiType, "c", C_TRANSFORMMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS));
|
||||
WRITE(p, "%sfloat4 "I_POSNORMALMATRIX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
|
||||
WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
|
||||
WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS));
|
||||
WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_LIGHTS));
|
||||
WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices
|
||||
WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType),WriteRegister(ApiType, "c", C_TRANSFORMMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES));
|
||||
WRITE(p, "%sfloat4 "I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS));
|
||||
|
||||
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
WRITE(p, "};\n");
|
||||
|
||||
|
||||
|
||||
p = GenerateVSOutputStruct(p, components, ApiType);
|
||||
|
||||
if(ApiType == API_GLSL)
|
||||
if(ApiType == API_GLSL)
|
||||
{
|
||||
if (components & VB_HAS_NRM0)
|
||||
WRITE(p, " float3 rawnorm0 = gl_Normal; // NORMAL0,\n");
|
||||
WRITE(p, " float3 rawnorm0 = gl_Normal; // NORMAL0,\n");
|
||||
|
||||
if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
{
|
||||
if (components & VB_HAS_POSMTXIDX)
|
||||
WRITE(p, "layout(location = %d) ATTRIN float fposmtx;\n", SHADER_POSMTX_ATTRIB);
|
||||
@@ -277,7 +276,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
WRITE(p, "VS_OUTPUT main(\n");
|
||||
|
||||
// inputs
|
||||
@@ -306,9 +304,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
}
|
||||
if (components & VB_HAS_POSMTXIDX) {
|
||||
if (is_d3d)
|
||||
{
|
||||
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
|
||||
}
|
||||
else
|
||||
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
|
||||
}
|
||||
@@ -369,7 +365,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
"float3 ldir, h;\n"
|
||||
"float dist, dist2, attn;\n");
|
||||
|
||||
if(xfregs.numChan.numColorChans == 0)
|
||||
if (xfregs.numChan.numColorChans == 0)
|
||||
{
|
||||
if (components & VB_HAS_COL0)
|
||||
WRITE(p, "o.colors_0 = color0;\n");
|
||||
@@ -380,7 +376,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
// TODO: This probably isn't necessary if pixel lighting is enabled.
|
||||
p = GenerateLightingShader(p, components, I_MATERIALS, I_LIGHTS, "color", "o.colors_");
|
||||
|
||||
if(xfregs.numChan.numColorChans < 2)
|
||||
if (xfregs.numChan.numColorChans < 2)
|
||||
{
|
||||
if (components & VB_HAS_COL1)
|
||||
WRITE(p, "o.colors_1 = color1;\n");
|
||||
@@ -584,23 +580,23 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
// clipPos/w needs to be done in pixel shader, not here
|
||||
|
||||
if (xfregs.numTexGen.numTexGens < 7) {
|
||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d].xyz = o.tex%d;\n", i, i);
|
||||
WRITE(p, " gl_TexCoord[%d] = o.clipPos;\n", xfregs.numTexGen.numTexGens);
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
WRITE(p, " gl_TexCoord[%d] = o.Normal;\n", xfregs.numTexGen.numTexGens + 1);
|
||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d].xyz = o.tex%d;\n", i, i);
|
||||
WRITE(p, " gl_TexCoord[%d] = o.clipPos;\n", xfregs.numTexGen.numTexGens);
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
WRITE(p, " gl_TexCoord[%d] = o.Normal;\n", xfregs.numTexGen.numTexGens + 1);
|
||||
} else {
|
||||
// clip position is in w of first 4 texcoords
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d] = o.tex%d;\n", i, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d]%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
|
||||
}
|
||||
// clip position is in w of first 4 texcoords
|
||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d] = o.tex%d;\n", i, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||
WRITE(p, " gl_TexCoord[%d]%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
|
||||
}
|
||||
}
|
||||
WRITE(p, "gl_FrontColor = o.colors_0;\n");
|
||||
WRITE(p, "gl_FrontSecondaryColor = o.colors_1;\n");
|
||||
@@ -608,7 +604,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
|
||||
WRITE(p, "}\n");
|
||||
}
|
||||
else
|
||||
WRITE(p, "return o;\n}\n");
|
||||
WRITE(p, "return o;\n}\n");
|
||||
|
||||
if (text[sizeof(text) - 1] != 0x7C)
|
||||
PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ struct FRAGMENTSHADER
|
||||
{
|
||||
if (glprogid)
|
||||
{
|
||||
if(bGLSL)
|
||||
if (bGLSL)
|
||||
glDeleteShader(glprogid);
|
||||
else
|
||||
glDeleteProgramsARB(1, &glprogid);
|
||||
|
||||
@@ -18,234 +18,247 @@
|
||||
#include "ProgramShaderCache.h"
|
||||
#include "MathUtil.h"
|
||||
|
||||
#include <assert.h>
|
||||
namespace OGL
|
||||
{
|
||||
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
||||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
||||
GLintptr ProgramShaderCache::s_vs_data_offset;
|
||||
|
||||
LinearDiskCache<PROGRAMUID, u8> g_program_disk_cache;
|
||||
GLenum ProgramFormat;
|
||||
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
||||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
||||
GLintptr ProgramShaderCache::s_vs_data_offset;
|
||||
|
||||
std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
|
||||
const char *UniformNames[NUM_UNIFORMS] = {
|
||||
// SAMPLERS
|
||||
"samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7",
|
||||
// PIXEL SHADER UNIFORMS
|
||||
I_COLORS,
|
||||
I_KCOLORS,
|
||||
I_ALPHA,
|
||||
I_TEXDIMS,
|
||||
I_ZBIAS ,
|
||||
I_INDTEXSCALE ,
|
||||
I_INDTEXMTX,
|
||||
I_FOG,
|
||||
I_PLIGHTS,
|
||||
I_PMATERIALS,
|
||||
// VERTEX SHADER UNIFORMS
|
||||
I_POSNORMALMATRIX,
|
||||
I_PROJECTION ,
|
||||
I_MATERIALS,
|
||||
I_LIGHTS,
|
||||
I_TEXMATRICES,
|
||||
I_TRANSFORMMATRICES ,
|
||||
I_NORMALMATRICES ,
|
||||
I_POSTTRANSFORMMATRICES,
|
||||
I_DEPTHPARAMS,
|
||||
};
|
||||
LinearDiskCache<PROGRAMUID, u8> g_program_disk_cache;
|
||||
GLenum ProgramFormat;
|
||||
|
||||
void ProgramShaderCache::SetProgramVariables(PCacheEntry &entry, const PROGRAMUID &uid)
|
||||
std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
|
||||
const char *UniformNames[NUM_UNIFORMS] =
|
||||
{
|
||||
// SAMPLERS
|
||||
"samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7",
|
||||
// PIXEL SHADER UNIFORMS
|
||||
I_COLORS,
|
||||
I_KCOLORS,
|
||||
I_ALPHA,
|
||||
I_TEXDIMS,
|
||||
I_ZBIAS ,
|
||||
I_INDTEXSCALE ,
|
||||
I_INDTEXMTX,
|
||||
I_FOG,
|
||||
I_PLIGHTS,
|
||||
I_PMATERIALS,
|
||||
// VERTEX SHADER UNIFORMS
|
||||
I_POSNORMALMATRIX,
|
||||
I_PROJECTION ,
|
||||
I_MATERIALS,
|
||||
I_LIGHTS,
|
||||
I_TEXMATRICES,
|
||||
I_TRANSFORMMATRICES ,
|
||||
I_NORMALMATRICES ,
|
||||
I_POSTTRANSFORMMATRICES,
|
||||
I_DEPTHPARAMS,
|
||||
};
|
||||
|
||||
void ProgramShaderCache::SetProgramVariables(PCacheEntry &entry, const PROGRAMUID &uid)
|
||||
{
|
||||
// Dunno why this is needed when I have the binding
|
||||
// points statically set in the shader source
|
||||
// We should only need these two functions when we don't support binding but do support UBO
|
||||
// Driver Bug? Nvidia GTX 570, 290.xx Driver, Linux x64
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
// Dunno why this is needed when I have the binding
|
||||
// points statically set in the shader source
|
||||
// We should only need these two functions when we don't support binding but do support UBO
|
||||
// Driver Bug? Nvidia GTX 570, 290.xx Driver, Linux x64
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
glUniformBlockBinding( entry.program.glprogid, 0, 1 );
|
||||
if(uid.uid.vsid != 0) // Some things have no vertex shader
|
||||
glUniformBlockBinding( entry.program.glprogid, 1, 2 );
|
||||
}
|
||||
|
||||
// We cache our uniform locations for now
|
||||
// Once we move up to a newer version of GLSL, ~1.30
|
||||
// We can remove this
|
||||
|
||||
//For some reason this fails on my hardware
|
||||
//glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations);
|
||||
//Got to do it this crappy way.
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
for(int a = 8; a < NUM_UNIFORMS; ++a)
|
||||
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
for(int a = 0; a < 8; ++a)
|
||||
{
|
||||
// Still need to get sampler locations since we aren't binding them statically in the shaders
|
||||
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
||||
if(entry.program.UniformLocations[a] != -1)
|
||||
glUniform1i(entry.program.UniformLocations[a], a);
|
||||
}
|
||||
glUniformBlockBinding(entry.program.glprogid, 0, 1);
|
||||
// Some things have no vertex shader
|
||||
if (uid.uid.vsid != 0)
|
||||
glUniformBlockBinding(entry.program.glprogid, 1, 2);
|
||||
}
|
||||
|
||||
// Need to get some attribute locations
|
||||
if(uid.uid.vsid != 0 && !g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) // We have no vertex Shader
|
||||
// We cache our uniform locations for now
|
||||
// Once we move up to a newer version of GLSL, ~1.30
|
||||
// We can remove this
|
||||
|
||||
// (Sonicadvance): For some reason this fails on my hardware
|
||||
//glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations);
|
||||
// Got to do it this crappy way.
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
for (int a = 8; a < NUM_UNIFORMS; ++a)
|
||||
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
||||
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
{
|
||||
for (int a = 0; a < 8; ++a)
|
||||
{
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_POSMTX_ATTRIB, "fposmtx");
|
||||
// Still need to get sampler locations since we aren't binding them statically in the shaders
|
||||
entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]);
|
||||
if (entry.program.UniformLocations[a] != -1)
|
||||
glUniform1i(entry.program.UniformLocations[a], a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
||||
// Need to get some attribute locations
|
||||
if (uid.uid.vsid != 0 && !g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
{
|
||||
PROGRAMUID uid;
|
||||
CurrentFShader = PS;
|
||||
CurrentVShader = VS;
|
||||
|
||||
|
||||
GetProgramShaderId(&uid, CurrentVShader, CurrentFShader);
|
||||
|
||||
if(uid.uid.id == 0)
|
||||
{
|
||||
CurrentProgram = 0;
|
||||
glUseProgram(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fragment shaders can survive without Vertex Shaders
|
||||
// We have a valid fragment shader, let's create our program
|
||||
std::pair<u32, u32> ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid);
|
||||
PCache::iterator iter = pshaders.find(ShaderPair);
|
||||
if (iter != pshaders.end())
|
||||
{
|
||||
PCacheEntry &entry = iter->second;
|
||||
glUseProgram(entry.program.glprogid);
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
CurrentProgram = entry.program.glprogid;
|
||||
return;
|
||||
}
|
||||
PCacheEntry entry;
|
||||
entry.program.vsid = CurrentVShader;
|
||||
entry.program.psid = CurrentFShader;
|
||||
entry.program.uid = uid;
|
||||
entry.program.glprogid = glCreateProgram();
|
||||
|
||||
// Right, the program is created now
|
||||
// Let's attach everything
|
||||
if(entry.program.vsid != 0) // attaching zero vertex shader makes it freak out
|
||||
glAttachShader(entry.program.glprogid, entry.program.vsid);
|
||||
|
||||
glAttachShader(entry.program.glprogid, entry.program.psid);
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
glProgramParameteri(entry.program.glprogid, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
||||
#endif
|
||||
|
||||
glLinkProgram(entry.program.glprogid);
|
||||
|
||||
glUseProgram(entry.program.glprogid);
|
||||
|
||||
SetProgramVariables(entry, uid);
|
||||
|
||||
pshaders[ShaderPair] = entry;
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
CurrentProgram = entry.program.glprogid;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||
{
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, offset * sizeof(float) * 4,
|
||||
count * sizeof(float) * 4, f);
|
||||
}
|
||||
|
||||
void ProgramShaderCache::SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||
{
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, s_vs_data_offset + offset * sizeof(float) * 4,
|
||||
count * sizeof(float) * 4, f);
|
||||
}
|
||||
|
||||
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
|
||||
|
||||
PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void)
|
||||
{
|
||||
return pshaders[CurrentShaderProgram].program;
|
||||
}
|
||||
void ProgramShaderCache::Init(void)
|
||||
{
|
||||
// We have to get the UBO alignment here because
|
||||
// if we generate a buffer that isn't aligned
|
||||
// then the UBO will fail.
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
GLint Align;
|
||||
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &Align);
|
||||
|
||||
GLintptr const ps_data_size = ROUND_UP(C_PENVCONST_END * sizeof(float) * 4, Align);
|
||||
GLintptr const vs_data_size = ROUND_UP(C_VENVCONST_END * sizeof(float) * 4, Align);
|
||||
s_vs_data_offset = ps_data_size;
|
||||
|
||||
// We multiply by *4*4 because we need to get down to basic machine units.
|
||||
// So multiply by four to get how many floats we have from vec4s
|
||||
// Then once more to get bytes
|
||||
glGenBuffers(1, &s_ps_vs_ubo);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, s_ps_vs_ubo);
|
||||
glBufferData(GL_UNIFORM_BUFFER, ps_data_size + vs_data_size, NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
// Now bind the buffer to the index point
|
||||
// We know PS is 0 since we have it statically set in the shader
|
||||
// Repeat for VS shader
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_ps_vs_ubo, 0, ps_data_size);
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_ps_vs_ubo, s_vs_data_offset, vs_data_size);
|
||||
}
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
// Read our shader cache, only if supported
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
{
|
||||
char cache_filename[MAX_PATH];
|
||||
sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
|
||||
ProgramShaderCacheInserter inserter;
|
||||
g_program_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||
|
||||
GLint Supported;
|
||||
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported);
|
||||
|
||||
GLint *Formats = new GLint[Supported];
|
||||
glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, Formats);
|
||||
ProgramFormat = (GLenum)Formats[0]; // We don't really care about format
|
||||
delete[] Formats;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProgramShaderCache::Shutdown(void)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
{
|
||||
PCache::iterator iter = pshaders.begin();
|
||||
for (; iter != pshaders.end(); ++iter)
|
||||
g_program_disk_cache.Append(iter->second.program.uid, iter->second.program.Data(), iter->second.program.Size());
|
||||
|
||||
g_program_disk_cache.Sync();
|
||||
g_program_disk_cache.Close();
|
||||
}
|
||||
|
||||
PCache::iterator iter = pshaders.begin();
|
||||
for (; iter != pshaders.end(); ++iter)
|
||||
iter->second.Destroy();
|
||||
pshaders.clear();
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
glDeleteBuffers(1, &s_ps_vs_ubo);
|
||||
s_ps_vs_ubo = 0;
|
||||
}
|
||||
// We have no vertex Shader
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
|
||||
glBindAttribLocation(entry.program.glprogid, SHADER_POSMTX_ATTRIB, "fposmtx");
|
||||
}
|
||||
}
|
||||
|
||||
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
||||
{
|
||||
PROGRAMUID uid;
|
||||
CurrentFShader = PS;
|
||||
CurrentVShader = VS;
|
||||
|
||||
GetProgramShaderId(&uid, CurrentVShader, CurrentFShader);
|
||||
|
||||
if (uid.uid.id == 0)
|
||||
{
|
||||
CurrentProgram = 0;
|
||||
glUseProgram(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fragment shaders can survive without Vertex Shaders
|
||||
// We have a valid fragment shader, let's create our program
|
||||
std::pair<u32, u32> ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid);
|
||||
PCache::iterator iter = pshaders.find(ShaderPair);
|
||||
if (iter != pshaders.end())
|
||||
{
|
||||
PCacheEntry &entry = iter->second;
|
||||
glUseProgram(entry.program.glprogid);
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
CurrentProgram = entry.program.glprogid;
|
||||
return;
|
||||
}
|
||||
|
||||
PCacheEntry entry;
|
||||
entry.program.vsid = CurrentVShader;
|
||||
entry.program.psid = CurrentFShader;
|
||||
entry.program.uid = uid;
|
||||
entry.program.glprogid = glCreateProgram();
|
||||
|
||||
// Right, the program is created now
|
||||
// Let's attach everything
|
||||
if (entry.program.vsid != 0) // attaching zero vertex shader makes it freak out
|
||||
glAttachShader(entry.program.glprogid, entry.program.vsid);
|
||||
|
||||
glAttachShader(entry.program.glprogid, entry.program.psid);
|
||||
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
glProgramParameteri(entry.program.glprogid, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
|
||||
#endif
|
||||
|
||||
glLinkProgram(entry.program.glprogid);
|
||||
|
||||
glUseProgram(entry.program.glprogid);
|
||||
|
||||
SetProgramVariables(entry, uid);
|
||||
|
||||
pshaders[ShaderPair] = entry;
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
CurrentProgram = entry.program.glprogid;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||
{
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, offset * sizeof(float) * 4,
|
||||
count * sizeof(float) * 4, f);
|
||||
}
|
||||
|
||||
void ProgramShaderCache::SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||
{
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, s_vs_data_offset + offset * sizeof(float) * 4,
|
||||
count * sizeof(float) * 4, f);
|
||||
}
|
||||
|
||||
GLuint ProgramShaderCache::GetCurrentProgram(void)
|
||||
{
|
||||
return CurrentProgram;
|
||||
}
|
||||
|
||||
PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void)
|
||||
{
|
||||
return pshaders[CurrentShaderProgram].program;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::Init(void)
|
||||
{
|
||||
// We have to get the UBO alignment here because
|
||||
// if we generate a buffer that isn't aligned
|
||||
// then the UBO will fail.
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
GLint Align;
|
||||
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &Align);
|
||||
|
||||
GLintptr const ps_data_size = ROUND_UP(C_PENVCONST_END * sizeof(float) * 4, Align);
|
||||
GLintptr const vs_data_size = ROUND_UP(C_VENVCONST_END * sizeof(float) * 4, Align);
|
||||
s_vs_data_offset = ps_data_size;
|
||||
|
||||
// We multiply by *4*4 because we need to get down to basic machine units.
|
||||
// So multiply by four to get how many floats we have from vec4s
|
||||
// Then once more to get bytes
|
||||
glGenBuffers(1, &s_ps_vs_ubo);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, s_ps_vs_ubo);
|
||||
glBufferData(GL_UNIFORM_BUFFER, ps_data_size + vs_data_size, NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
// Now bind the buffer to the index point
|
||||
// We know PS is 0 since we have it statically set in the shader
|
||||
// Repeat for VS shader
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_ps_vs_ubo, 0, ps_data_size);
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_ps_vs_ubo, s_vs_data_offset, vs_data_size);
|
||||
}
|
||||
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
// Read our shader cache, only if supported
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
{
|
||||
char cache_filename[MAX_PATH];
|
||||
sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
|
||||
ProgramShaderCacheInserter inserter;
|
||||
g_program_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||
|
||||
GLint Supported;
|
||||
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &Supported);
|
||||
|
||||
GLint *Formats = new GLint[Supported];
|
||||
glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, Formats);
|
||||
// We don't really care about format
|
||||
ProgramFormat = (GLenum)Formats[0];
|
||||
delete[] Formats;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProgramShaderCache::Shutdown(void)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
{
|
||||
PCache::iterator iter = pshaders.begin();
|
||||
for (; iter != pshaders.end(); ++iter)
|
||||
g_program_disk_cache.Append(iter->second.program.uid, iter->second.program.Data(), iter->second.program.Size());
|
||||
|
||||
g_program_disk_cache.Sync();
|
||||
g_program_disk_cache.Close();
|
||||
}
|
||||
|
||||
PCache::iterator iter = pshaders.begin();
|
||||
for (; iter != pshaders.end(); ++iter)
|
||||
iter->second.Destroy();
|
||||
pshaders.clear();
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
{
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
glDeleteBuffers(1, &s_ps_vs_ubo);
|
||||
s_ps_vs_ubo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OGL
|
||||
|
||||
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p)
|
||||
{
|
||||
uid->uid.vsid = _v;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _ProgramShaderCache_H_
|
||||
#define _ProgramShaderCache_H_
|
||||
#pragma once
|
||||
|
||||
#include "GLUtil.h"
|
||||
|
||||
@@ -28,18 +27,18 @@
|
||||
#include "LinearDiskCache.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
union PID
|
||||
union PID
|
||||
{
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
GLuint vsid, psid;
|
||||
};
|
||||
u64 id;
|
||||
};
|
||||
u64 id;
|
||||
};
|
||||
|
||||
class PROGRAMUID
|
||||
{
|
||||
public:
|
||||
|
||||
PID uid;
|
||||
|
||||
PROGRAMUID()
|
||||
@@ -51,57 +50,63 @@ public:
|
||||
{
|
||||
uid.id = r.uid.id;
|
||||
}
|
||||
|
||||
PROGRAMUID(GLuint _v, GLuint _p)
|
||||
{
|
||||
uid.vsid = _v;
|
||||
uid.psid = _p;
|
||||
}
|
||||
|
||||
int GetNumValues() const
|
||||
u64 GetNumValues() const
|
||||
{
|
||||
return uid.id;
|
||||
}
|
||||
};
|
||||
|
||||
void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p);
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
#define NUM_UNIFORMS 27
|
||||
|
||||
const int NUM_UNIFORMS = 27;
|
||||
extern const char *UniformNames[NUM_UNIFORMS];
|
||||
extern GLenum ProgramFormat;
|
||||
|
||||
struct PROGRAMSHADER
|
||||
{
|
||||
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0){}
|
||||
GLuint glprogid; // opengl program id
|
||||
PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0) {}
|
||||
// opengl program id
|
||||
GLuint glprogid;
|
||||
GLuint vsid, psid;
|
||||
PROGRAMUID uid;
|
||||
GLint UniformLocations[NUM_UNIFORMS];
|
||||
GLint binaryLength;
|
||||
|
||||
// TODO at first glance looks bad - malloc/no free/pointer not saved in instance...
|
||||
u8 *Data()
|
||||
{
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
glGetProgramiv(glprogid, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
|
||||
u8* binary = (u8*)malloc(binaryLength);
|
||||
glGetProgramBinary(glprogid, binaryLength, NULL, &ProgramFormat, binary);
|
||||
return binary;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
u8* binary = (u8*)malloc(binaryLength);
|
||||
glGetProgramBinary(glprogid, binaryLength, NULL, &ProgramFormat, binary);
|
||||
return binary;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
GLint Size()
|
||||
{
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
if(!binaryLength)
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
if (!binaryLength)
|
||||
glGetProgramiv(glprogid, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
|
||||
return binaryLength;
|
||||
#else
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ProgramShaderCache
|
||||
{
|
||||
struct PCacheEntry
|
||||
@@ -109,50 +114,54 @@ class ProgramShaderCache
|
||||
PROGRAMSHADER program;
|
||||
int frameCount;
|
||||
PCacheEntry() : frameCount(0) {}
|
||||
void Destroy() {
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
glDeleteProgram(program.glprogid);
|
||||
program.glprogid = 0;
|
||||
}
|
||||
|
||||
u8* Data()
|
||||
{
|
||||
return program.Data();
|
||||
}
|
||||
|
||||
GLint Size()
|
||||
{
|
||||
return program.Size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ProgramShaderCacheInserter : public LinearDiskCacheReader<PROGRAMUID, u8>
|
||||
{
|
||||
public:
|
||||
void Read(const PROGRAMUID &key, const u8 *value, u32 value_size)
|
||||
public:
|
||||
void Read(const PROGRAMUID &key, const u8 *value, u32 value_size)
|
||||
{
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
PCacheEntry entry;
|
||||
|
||||
// The two shaders might not even exist anymore
|
||||
// But it is fine, no need to worry about that
|
||||
entry.program.vsid = key.uid.vsid;
|
||||
entry.program.psid = key.uid.psid;
|
||||
|
||||
entry.program.glprogid = glCreateProgram();
|
||||
|
||||
glProgramBinary(entry.program.glprogid, ProgramFormat, value, value_size);
|
||||
|
||||
GLint success;
|
||||
glGetProgramiv(entry.program.glprogid, GL_LINK_STATUS, &success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
#ifdef GLEW_VERSION_4_0
|
||||
PCacheEntry entry;
|
||||
|
||||
// The two shaders might not even exist anymore
|
||||
// But it is fine, no need to worry about that
|
||||
entry.program.vsid = key.uid.vsid;
|
||||
entry.program.psid = key.uid.psid;
|
||||
|
||||
entry.program.glprogid = glCreateProgram();
|
||||
|
||||
glProgramBinary(entry.program.glprogid, ProgramFormat, value, value_size);
|
||||
|
||||
GLint success;
|
||||
glGetProgramiv(entry.program.glprogid, GL_LINK_STATUS, &success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
pshaders[std::make_pair(key.uid.psid, key.uid.vsid)] = entry;
|
||||
glUseProgram(entry.program.glprogid);
|
||||
SetProgramVariables(entry, key);
|
||||
}
|
||||
#endif
|
||||
pshaders[std::make_pair(key.uid.psid, key.uid.vsid)] = entry;
|
||||
glUseProgram(entry.program.glprogid);
|
||||
SetProgramVariables(entry, key);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef std::map<std::pair<u32, u32>, PCacheEntry> PCache;
|
||||
|
||||
static PCache pshaders;
|
||||
@@ -162,7 +171,7 @@ class ProgramShaderCache
|
||||
static GLuint s_ps_vs_ubo;
|
||||
static GLintptr s_vs_data_offset;
|
||||
static void SetProgramVariables(PCacheEntry &entry, const PROGRAMUID &uid);
|
||||
|
||||
|
||||
public:
|
||||
static PROGRAMSHADER GetShaderProgram(void);
|
||||
static void SetBothShaders(GLuint PS, GLuint VS);
|
||||
@@ -170,12 +179,9 @@ public:
|
||||
|
||||
static void SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count);
|
||||
static void SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count);
|
||||
|
||||
|
||||
static void Init(void);
|
||||
static void Shutdown(void);
|
||||
|
||||
};
|
||||
|
||||
} // namespace OGL
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1419,7 +1419,7 @@ void Renderer::ResetAPIState()
|
||||
{
|
||||
// Gets us to a reasonably sane state where it's possible to do things like
|
||||
// image copies with textured quads, etc.
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders(0, 0);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -211,7 +211,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||
if (pcfmt != PC_TEX_FMT_DXT1)
|
||||
{
|
||||
if (expanded_width != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
||||
|
||||
if (bHaveMipMaps && autogen_mips)
|
||||
{
|
||||
@@ -225,7 +225,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||
}
|
||||
|
||||
if (expanded_width != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -300,7 +300,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
||||
|
||||
glViewport(0, 0, virtual_width, virtual_height);
|
||||
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders((srcFormat == PIXELFMT_Z24) ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram(), 0);
|
||||
else
|
||||
PixelShaderCache::SetCurrentShader((srcFormat == PIXELFMT_Z24) ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram());
|
||||
@@ -396,8 +396,8 @@ TextureCache::~TextureCache()
|
||||
{
|
||||
if (s_TempFramebuffer)
|
||||
{
|
||||
glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
|
||||
s_TempFramebuffer = 0;
|
||||
glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
|
||||
s_TempFramebuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ static FRAGMENTSHADER s_encodingPrograms[NUM_ENCODING_PROGRAMS];
|
||||
void CreateRgbToYuyvProgram()
|
||||
{
|
||||
// Output is BGRA because that is slightly faster than RGBA.
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
{
|
||||
if(g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
{
|
||||
const char *FProgram =
|
||||
"#version 330 compatibility\n"
|
||||
@@ -132,9 +132,9 @@ void CreateRgbToYuyvProgram()
|
||||
|
||||
void CreateYuyvToRgbProgram()
|
||||
{
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
{
|
||||
if(g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
{
|
||||
const char *FProgram =
|
||||
"#version 330 compatibility\n"
|
||||
@@ -390,7 +390,7 @@ int EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer,
|
||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
||||
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders(texconv_shader.glprogid, 0);
|
||||
else
|
||||
PixelShaderCache::SetCurrentShader(texconv_shader.glprogid);
|
||||
@@ -425,7 +425,7 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* des
|
||||
{
|
||||
g_renderer->ResetAPIState();
|
||||
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders(s_rgbToYuyvProgram.glprogid, 0);
|
||||
else
|
||||
PixelShaderCache::SetCurrentShader(s_rgbToYuyvProgram.glprogid);
|
||||
@@ -472,7 +472,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
|
||||
|
||||
// TODO: make this less slow. (How?)
|
||||
if((GLsizei)s_srcTextureWidth == (GLsizei)srcFmtWidth && (GLsizei)s_srcTextureHeight == (GLsizei)srcHeight)
|
||||
if ((GLsizei)s_srcTextureWidth == (GLsizei)srcFmtWidth && (GLsizei)s_srcTextureHeight == (GLsizei)srcHeight)
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0,0,0,s_srcTextureWidth, s_srcTextureHeight,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, srcAddr);
|
||||
@@ -486,7 +486,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
|
||||
}
|
||||
|
||||
glViewport(0, 0, srcWidth, srcHeight);
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders(s_yuyvToRgbProgram.glprogid, 0);
|
||||
else
|
||||
PixelShaderCache::SetCurrentShader(s_yuyvToRgbProgram.glprogid);
|
||||
|
||||
@@ -195,7 +195,7 @@ void VertexManager::vFlush()
|
||||
}
|
||||
VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components);
|
||||
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
ProgramShaderCache::SetBothShaders(ps->glprogid, vs->glprogid);
|
||||
else
|
||||
{
|
||||
@@ -218,10 +218,10 @@ void VertexManager::vFlush()
|
||||
if (useDstAlpha && !dualSourcePossible)
|
||||
{
|
||||
ps = PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS,g_nativeVertexFmt->m_components);
|
||||
if(g_ActiveConfig.bUseGLSL)
|
||||
if (g_ActiveConfig.bUseGLSL)
|
||||
{
|
||||
ProgramShaderCache::SetBothShaders(ps->glprogid, 0);
|
||||
if(!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
PixelShaderManager::SetConstants(); // Need to set these again, if we don't support UBO
|
||||
if (g_nativeVertexFmt)
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ struct VERTEXSHADER
|
||||
VERTEXSHADER() : glprogid(0), bGLSL(0) {}
|
||||
void Destroy()
|
||||
{
|
||||
if(bGLSL)
|
||||
if (bGLSL)
|
||||
glDeleteShader(glprogid);
|
||||
else
|
||||
glDeleteProgramsARB(1, &glprogid);
|
||||
|
||||
Reference in New Issue
Block a user