ShaderGen: Use u8 as uid storage base type. Fixes an off-by-one error introduced in revision bdc28106ee that caused some lighting issues.

This commit is contained in:
NeoBrainX 2013-07-02 14:32:52 +02:00
parent de369dcc60
commit 1f92ccc228
4 changed files with 4 additions and 8 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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;

View File

@ -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;