remove printf in shader uid generation

This commit is contained in:
degasus 2013-07-29 20:52:24 +02:00
parent 8529addcc6
commit d029fc2f9f
1 changed files with 13 additions and 9 deletions

View File

@ -230,7 +230,7 @@ static void BuildSwapModeTable()
} }
template<class T> static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE ApiType, RegisterState RegisterStates[4]); template<class T> static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE ApiType, RegisterState RegisterStates[4]);
template<class T> static void SampleTexture(T& out, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType); template<class T> static void SampleTexture(T& out, const char *destination, const int dest_index, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType);
template<class T> static void WriteAlphaTest(T& out, pixel_shader_uid_data& uid_data, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode, bool per_pixel_depth); template<class T> static void WriteAlphaTest(T& out, pixel_shader_uid_data& uid_data, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode, bool per_pixel_depth);
template<class T> static void WriteFog(T& out, pixel_shader_uid_data& uid_data); template<class T> static void WriteFog(T& out, pixel_shader_uid_data& uid_data);
@ -558,9 +558,7 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api
else else
out.Write("\ttempcoord = float2(0.0f, 0.0f);\n"); out.Write("\ttempcoord = float2(0.0f, 0.0f);\n");
char buffer[32]; SampleTexture<T>(out, "float3 indtex", i, "tempcoord", "abg", texmap, ApiType);
sprintf(buffer, "float3 indtex%d", i);
SampleTexture<T>(out, buffer, "tempcoord", "abg", texmap, ApiType);
} }
} }
@ -888,7 +886,7 @@ static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE
char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap]; char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap];
int texmap = bpmem.tevorders[n/2].getTexMap(n&1); int texmap = bpmem.tevorders[n/2].getTexMap(n&1);
uid_data.SetTevindrefTexmap(i, texmap); uid_data.SetTevindrefTexmap(i, texmap);
SampleTexture<T>(out, "textemp", "tevcoord", texswap, texmap, ApiType); SampleTexture<T>(out, "textemp", -1, "tevcoord", texswap, texmap, ApiType);
} }
else else
{ {
@ -1110,13 +1108,19 @@ static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE
} }
template<class T> template<class T>
void SampleTexture(T& out, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType) void SampleTexture(T& out, const char *destination, const int dest_index, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType)
{ {
out.SetConstantsUsed(C_TEXDIMS+texmap,C_TEXDIMS+texmap); out.SetConstantsUsed(C_TEXDIMS+texmap,C_TEXDIMS+texmap);
if (ApiType == API_D3D11)
out.Write("%s=Tex%d.Sample(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap); if(dest_index >= 0)
out.Write("%s%d = ", destination, dest_index);
else else
out.Write("%s=%s(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, ApiType == API_OPENGL ? "texture" : "tex2D", texmap, texcoords, texmap, texswap); out.Write("%s = ", destination);
if (ApiType == API_D3D11)
out.Write("Tex%d.Sample(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", texmap,texmap, texcoords, texmap, texswap);
else
out.Write("%s(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", ApiType == API_OPENGL ? "texture" : "tex2D", texmap, texcoords, texmap, texswap);
} }
static const char *tevAlphaFuncsTable[] = static const char *tevAlphaFuncsTable[] =