From 76148a52b82cae8e6cf11b6eeeeff55345b0f12e Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 28 Jan 2013 22:51:15 +0100 Subject: [PATCH] Fix a few other things --- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 30 ++++++++++++------- Source/Core/VideoCommon/Src/PixelShaderGen.h | 19 +++++++----- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index a19eb1a27e..fa38075118 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -273,16 +273,6 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u SetUidField(genMode.numtevstages, bpmem.genMode.numtevstages); SetUidField(genMode.numtexgens, bpmem.genMode.numtexgens); - int nIndirectStagesUsed = 0; - if (bpmem.genMode.numindstages > 0) - { - for (unsigned int i = 0; i < numStages; ++i) - { - if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) - nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; - } - } - // Declare samplers out.Write((ApiType != API_D3D11) ? "uniform sampler2D " : "sampler "); for (int i = 0; i < 8; ++i) @@ -317,6 +307,7 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u out.Write("uniform s_" I_PMATERIALS" " I_PMATERIALS" : register(c%d);\n", C_PMATERIALS); } + // TODO: Somehow should put ApiType in the hash.. out.Write("void main(\n"); if(ApiType != API_D3D11) { @@ -355,6 +346,7 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u } else { + // TODO: Not necessary... SetUidField(xfregs_numTexGen_numTexGens, xfregs.numTexGen.numTexGens); for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) out.Write(",\n in float%d uv%d : TEXCOORD%d", i < 4 ? 4 : 3 , i, i); @@ -423,10 +415,20 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u } // indirect texture map lookup + int nIndirectStagesUsed = 0; + if (bpmem.genMode.numindstages > 0) + { + for (unsigned int i = 0; i < numStages; ++i) + { + if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) + nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; + } + } + SetUidField(nIndirectStagesUsed, nIndirectStagesUsed); for(u32 i = 0; i < bpmem.genMode.numindstages; ++i) { - if (nIndirectStagesUsed & (1<(out, ApiType, dstAlphaMode); @@ -514,8 +517,13 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u out.Write("float zCoord = " I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * " I_ZBIAS"[1].y;\n"); // Note: depth textures are disabled if early depth test is enabled + SetUidField(Pretest, Pretest); + SetUidField(ztex.op, bpmem.ztex2.op); + SetUidField(early_z, bpmem.zcontrol.early_ztest); + SetUidField(ztestenable, bpmem.zmode.testenable); if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.early_ztest && bpmem.zmode.testenable) { + // TODO: Implement type?? // use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format... out.SetConstantsUsed(C_ZBIAS, C_ZBIAS+1); out.Write("zCoord = dot(" I_ZBIAS"[0].xyzw, textemp.xyzw) + " I_ZBIAS"[1].w %s;\n", diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index 221b04612e..c1c210dce6 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -20,6 +20,7 @@ #include "VideoCommon.h" #include "ShaderGenCommon.h" +#include "BPMemory.h" #define I_COLORS "color" #define I_KCOLORS "k" @@ -54,18 +55,11 @@ enum DSTALPHA_MODE DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending }; -enum ALPHA_PRETEST_RESULT -{ - ALPHAPT_UNDEFINED, // AlphaTest Result is not defined - ALPHAPT_ALWAYSFAIL, // Alpha test alway Fail - ALPHAPT_ALWAYSPASS // Alpha test alway Pass -}; - struct pixel_shader_uid_data { u32 components; DSTALPHA_MODE dstAlphaMode; // TODO: as u32 :2 - ALPHA_PRETEST_RESULT Pretest; // TODO: As :2 + AlphaTest::TEST_RESULT Pretest; // TODO: As :2 u32 nIndirectStagesUsed : 8; struct { u32 numtexgens : 4; @@ -168,6 +162,15 @@ struct pixel_shader_uid_data u32 hex : 4; } fog; + union { + struct { + u32 op : 2; + }; + u32 hex : 2; + } ztex; + + u32 early_z : 1; + u32 ztestenable : 1; u32 bHasIndStage : 16;