From 1f92ccc228bcb97893598ca1788fb2f459a078c0 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 2 Jul 2013 14:32:52 +0200 Subject: [PATCH] ShaderGen: Use u8 as uid storage base type. Fixes an off-by-one error introduced in revision bdc28106eed0 that caused some lighting issues. --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 2 +- Source/Core/VideoCommon/Src/ShaderGenCommon.h | 4 ++-- Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 2 -- Source/Core/VideoCommon/Src/VertexShaderGen.h | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 1c10459160..cf0dc8e959 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -537,7 +537,7 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api #define MY_STRUCT_OFFSET(str,elem) ((u32)((u64)&(str).elem-(u64)&(str))) bool enable_pl = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting; - uid_data.num_values = (enable_pl) ? sizeof(uid_data)/sizeof(32) : MY_STRUCT_OFFSET(uid_data,stagehash[numStages])/sizeof(u32); + uid_data.num_values = (enable_pl) ? sizeof(uid_data) : MY_STRUCT_OFFSET(uid_data,stagehash[numStages]); if (numStages) diff --git a/Source/Core/VideoCommon/Src/ShaderGenCommon.h b/Source/Core/VideoCommon/Src/ShaderGenCommon.h index c8f8ff8345..ec4fe27416 100644 --- a/Source/Core/VideoCommon/Src/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/Src/ShaderGenCommon.h @@ -120,7 +120,7 @@ private: union { uid_data data; - u32 values[sizeof(uid_data) / sizeof(u32)]; + u8 values[sizeof(uid_data)]; }; }; @@ -212,7 +212,7 @@ struct LightingUidData u32 attnfunc : 8; // 4x2 bits u32 light_mask : 32; // 4x8 bits - u32 NumValues() const { return sizeof(LightingUidData) / sizeof(u32); } + u32 NumValues() const { return sizeof(LightingUidData); } }; #pragma pack() diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 63b752b838..a682b4ea21 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -74,8 +74,6 @@ static void GenerateVertexShader(T& out, u32 components, API_TYPE api_type) vertex_shader_uid_data& uid_data = (&out.template GetUidData() != NULL) ? out.template GetUidData() : dummy_data; - uid_data.num_values = sizeof(uid_data)/sizeof(u32); - out.SetBuffer(text); #ifndef ANDROID locale_t locale; diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index a28f4758fa..eef0646e6f 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -67,11 +67,9 @@ const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 }, struct vertex_shader_uid_data { - - u32 NumValues() const { return num_values; } + u32 NumValues() const { return sizeof(vertex_shader_uid_data); } u32 components; - u32 num_values : 16; // TODO: u8 might be enough, actually u32 numColorChans : 2; u32 numTexGens : 4;