From d029fc2f9f04396e145f27716266965e1da39793 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 29 Jul 2013 20:52:24 +0200 Subject: [PATCH] remove printf in shader uid generation --- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 9e831541bd..4dfbd62307 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -230,7 +230,7 @@ static void BuildSwapModeTable() } template static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE ApiType, RegisterState RegisterStates[4]); -template static void SampleTexture(T& out, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType); +template static void SampleTexture(T& out, const char *destination, const int dest_index, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType); template static void WriteAlphaTest(T& out, pixel_shader_uid_data& uid_data, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode, bool per_pixel_depth); template 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 out.Write("\ttempcoord = float2(0.0f, 0.0f);\n"); - char buffer[32]; - sprintf(buffer, "float3 indtex%d", i); - SampleTexture(out, buffer, "tempcoord", "abg", texmap, ApiType); + SampleTexture(out, "float3 indtex", i, "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]; int texmap = bpmem.tevorders[n/2].getTexMap(n&1); uid_data.SetTevindrefTexmap(i, texmap); - SampleTexture(out, "textemp", "tevcoord", texswap, texmap, ApiType); + SampleTexture(out, "textemp", -1, "tevcoord", texswap, texmap, ApiType); } else { @@ -1110,13 +1108,19 @@ static void WriteStage(T& out, pixel_shader_uid_data& uid_data, int n, API_TYPE } template -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); - 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 - 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[] =