Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ShaderGen: Use u8 as uid storage base type. Fixes an off-by-one error…
… introduced in revision bdc2810 that caused some lighting issues.
  • Loading branch information
neobrain committed Jul 2, 2013
1 parent de369dc commit 1f92ccc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/Src/ShaderGenCommon.h
Expand Up @@ -120,7 +120,7 @@ class ShaderUid : public ShaderGeneratorInterface
union
{
uid_data data;
u32 values[sizeof(uid_data) / sizeof(u32)];
u8 values[sizeof(uid_data)];
};
};

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 0 additions & 2 deletions Source/Core/VideoCommon/Src/VertexShaderGen.cpp
Expand Up @@ -74,8 +74,6 @@ static void GenerateVertexShader(T& out, u32 components, API_TYPE api_type)
vertex_shader_uid_data& uid_data = (&out.template GetUidData<vertex_shader_uid_data>() != NULL)
? out.template GetUidData<vertex_shader_uid_data>() : dummy_data;

uid_data.num_values = sizeof(uid_data)/sizeof(u32);

out.SetBuffer(text);
#ifndef ANDROID
locale_t locale;
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/VideoCommon/Src/VertexShaderGen.h
Expand Up @@ -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;

Expand Down

0 comments on commit 1f92ccc

Please sign in to comment.