From 3a9fed0ba285b3c2bb80de408ac1a9da9ca774b6 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 21 Feb 2012 12:51:41 +0100 Subject: [PATCH] PixelShaderGen: Fix a bug introduced in revision 9adc119e3c2f. D3D11: Fix shader constant mapping. --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 5 +++- .../Plugin_VideoDX11/Src/PixelShaderCache.cpp | 28 ++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index e4cb0cbd17..f6e0d95f8c 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -24,7 +24,7 @@ // Increment this every time you change shader generation code. enum { - LINEAR_DISKCACHE_VER = 6971 + LINEAR_DISKCACHE_VER = 6972 }; // On disk format: diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index ed504f1c82..fe5827de05 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -560,7 +560,10 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType WRITE(p, "uniform float4 "I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS); WRITE(p, "uniform float4 "I_ALPHA"[1] : register(c%d);\n", C_ALPHA); WRITE(p, "uniform float4 "I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS); - WRITE(p, "uniform float4 "I_VTEXSCALE"[8] : register(c%d);\n", C_VTEXSCALE); + if (ApiType & API_D3D9) + { + WRITE(p, "uniform float4 "I_VTEXSCALE"[4] : register(c%d);\n", C_VTEXSCALE); + } WRITE(p, "uniform float4 "I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS); WRITE(p, "uniform float4 "I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE); WRITE(p, "uniform float4 "I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index 56f3719057..fe33c4db80 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -552,20 +552,22 @@ static const unsigned int ps_constant_offset_table[] = { 16, 20, 24, 28, // C_KCOLORS, 16 32, // C_ALPHA, 4 36, 40, 44, 48, 52, 56, 60, 64, // C_TEXDIMS, 32 - 68, 72, // C_ZBIAS, 8 - 76, 80, // C_INDTEXSCALE, 8 - 84, 88, 92, 96, 100, 104, // C_INDTEXMTX, 24 - 108, 112, 116, // C_FOG, 12 - 120, 124, 128, 132, 136, // C_PLIGHTS0, 20 - 140, 144, 148, 152, 156, // C_PLIGHTS1, 20 - 160, 164, 168, 172, 176, // C_PLIGHTS2, 20 - 180, 184, 188, 192, 196, // C_PLIGHTS3, 20 - 200, 204, 208, 212, 216, // C_PLIGHTS4, 20 - 220, 224, 228, 232, 236, // C_PLIGHTS5, 20 - 240, 244, 248, 252, 256, // C_PLIGHTS6, 20 - 260, 264, 268, 272, 276, // C_PLIGHTS7, 20 - 280, 284, 288, 292 // C_PMATERIALS, 16 + 68, 72, 76, 80, // C_VTEXSCALE, 16 (unused) + 84, 88, // C_ZBIAS, 8 + 92, 96, // C_INDTEXSCALE, 8 + 100, 104, 108, 112, 116, 120, // C_INDTEXMTX, 24 + 124, 128, 132, // C_FOG, 12 + 136, 140, 144, 148, 152, // C_PLIGHTS0, 20 + 156, 160, 164, 168, 172, // C_PLIGHTS1, 20 + 176, 180, 184, 188, 192, // C_PLIGHTS2, 20 + 196, 200, 204, 208, 212, // C_PLIGHTS3, 20 + 216, 220, 224, 228, 232, // C_PLIGHTS4, 20 + 236, 240, 244, 248, 252, // C_PLIGHTS5, 20 + 256, 260, 264, 268, 272, // C_PLIGHTS6, 20 + 276, 280, 284, 288, 292, // C_PLIGHTS7, 20 + 296, 300, 304, 308, // C_PMATERIALS, 16 }; + void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { psconstants[ps_constant_offset_table[const_number] ] = f1;