wined3d: Use the element size to create "isStateDirty" bitmap indices.

This commit is contained in:
Henri Verbeet 2009-12-29 17:10:22 +01:00 committed by Alexandre Julliard
parent 9ae92661cc
commit 2650885cc8
3 changed files with 9 additions and 9 deletions

View File

@ -898,8 +898,8 @@ static void Context_MarkStateDirty(struct wined3d_context *context, DWORD state,
if (isStateDirty(context, rep)) return; if (isStateDirty(context, rep)) return;
context->dirtyArray[context->numDirtyEntries++] = rep; context->dirtyArray[context->numDirtyEntries++] = rep;
idx = rep >> 5; idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
shift = rep & 0x1f; shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
context->isStateDirty[idx] |= (1 << shift); context->isStateDirty[idx] |= (1 << shift);
} }
@ -2194,8 +2194,8 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
for (i = 0; i < context->numDirtyEntries; ++i) for (i = 0; i < context->numDirtyEntries; ++i)
{ {
DWORD rep = context->dirtyArray[i]; DWORD rep = context->dirtyArray[i];
DWORD idx = rep >> 5; DWORD idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
BYTE shift = rep & 0x1f; BYTE shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
context->isStateDirty[idx] &= ~(1 << shift); context->isStateDirty[idx] &= ~(1 << shift);
state_table[rep].apply(rep, device->stateBlock, context); state_table[rep].apply(rep, device->stateBlock, context);
} }

View File

@ -7015,8 +7015,8 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
if(isStateDirty(context, rep)) continue; if(isStateDirty(context, rep)) continue;
context->dirtyArray[context->numDirtyEntries++] = rep; context->dirtyArray[context->numDirtyEntries++] = rep;
idx = rep >> 5; idx = rep / (sizeof(*context->isStateDirty) * CHAR_BIT);
shift = rep & 0x1f; shift = rep & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
context->isStateDirty[idx] |= (1 << shift); context->isStateDirty[idx] |= (1 << shift);
} }
} }

View File

@ -1028,7 +1028,7 @@ struct wined3d_context
*/ */
DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */ DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
DWORD numDirtyEntries; DWORD numDirtyEntries;
DWORD isStateDirty[STATE_HIGHEST/32 + 1]; /* Bitmap to find out quickly if a state is dirty */ DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
IWineD3DSurface *surface; IWineD3DSurface *surface;
IWineD3DSurface *current_rt; IWineD3DSurface *current_rt;
@ -1614,8 +1614,8 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DE
static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state) static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
{ {
DWORD idx = state >> 5; DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT);
BYTE shift = state & 0x1f; BYTE shift = state & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
return context->isStateDirty[idx] & (1 << shift); return context->isStateDirty[idx] & (1 << shift);
} }