wined3d: Pass IWineD3DStateBlockImpl pointers to stateblock_copy().

This commit is contained in:
Henri Verbeet 2009-09-29 11:09:06 +02:00 committed by Alexandre Julliard
parent 4ed126f5dc
commit 6d3e5a9cce
1 changed files with 48 additions and 51 deletions

View File

@ -167,80 +167,77 @@ static void stateblock_savedstates_set(IWineD3DStateBlock *iface, SAVEDSTATES *s
memset(states->vertexShaderConstantsF, value, bsize * GL_LIMITS(vshader_constantsF)); memset(states->vertexShaderConstantsF, value, bsize * GL_LIMITS(vshader_constantsF));
} }
static void stateblock_copy(IWineD3DStateBlock *destination, IWineD3DStateBlock *source) static void stateblock_copy(IWineD3DStateBlockImpl *dst, IWineD3DStateBlockImpl *src)
{ {
int l; const struct wined3d_gl_info *gl_info = &src->wineD3DDevice->adapter->gl_info;
unsigned int l;
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)source; dst->lpVtbl = src->lpVtbl;
IWineD3DStateBlockImpl *Dest = (IWineD3DStateBlockImpl *)destination; dst->ref = src->ref;
dst->parent = src->parent;
/* IUnknown fields */ dst->wineD3DDevice = src->wineD3DDevice;
Dest->lpVtbl = This->lpVtbl; dst->blockType = src->blockType;
Dest->ref = This->ref;
/* IWineD3DStateBlock information */
Dest->parent = This->parent;
Dest->wineD3DDevice = This->wineD3DDevice;
Dest->blockType = This->blockType;
/* Saved states */ /* Saved states */
stateblock_savedstates_copy(source, &Dest->changed, &This->changed); stateblock_savedstates_copy((IWineD3DStateBlock *)src, &dst->changed, &src->changed);
/* Single items */ /* Single items */
Dest->gl_primitive_type = This->gl_primitive_type; dst->gl_primitive_type = src->gl_primitive_type;
Dest->vertexDecl = This->vertexDecl; dst->vertexDecl = src->vertexDecl;
Dest->vertexShader = This->vertexShader; dst->vertexShader = src->vertexShader;
Dest->streamIsUP = This->streamIsUP; dst->streamIsUP = src->streamIsUP;
Dest->pIndexData = This->pIndexData; dst->pIndexData = src->pIndexData;
Dest->IndexFmt = This->IndexFmt; dst->IndexFmt = src->IndexFmt;
Dest->baseVertexIndex = This->baseVertexIndex; dst->baseVertexIndex = src->baseVertexIndex;
/* Dest->lights = This->lights; */ dst->clip_status = src->clip_status;
Dest->clip_status = This->clip_status; dst->viewport = src->viewport;
Dest->viewport = This->viewport; dst->material = src->material;
Dest->material = This->material; dst->pixelShader = src->pixelShader;
Dest->pixelShader = This->pixelShader; dst->scissorRect = src->scissorRect;
Dest->scissorRect = This->scissorRect;
/* Lights */ /* Lights */
memset(Dest->activeLights, 0, sizeof(Dest->activeLights)); memset(dst->activeLights, 0, sizeof(dst->activeLights));
for(l = 0; l < LIGHTMAP_SIZE; l++) { for (l = 0; l < LIGHTMAP_SIZE; ++l)
{
struct list *e1, *e2; struct list *e1, *e2;
LIST_FOR_EACH_SAFE(e1, e2, &Dest->lightMap[l]) { LIST_FOR_EACH_SAFE(e1, e2, &dst->lightMap[l])
{
PLIGHTINFOEL *light = LIST_ENTRY(e1, PLIGHTINFOEL, entry); PLIGHTINFOEL *light = LIST_ENTRY(e1, PLIGHTINFOEL, entry);
list_remove(&light->entry); list_remove(&light->entry);
HeapFree(GetProcessHeap(), 0, light); HeapFree(GetProcessHeap(), 0, light);
} }
LIST_FOR_EACH(e1, &This->lightMap[l]) { LIST_FOR_EACH(e1, &src->lightMap[l])
{
PLIGHTINFOEL *light = LIST_ENTRY(e1, PLIGHTINFOEL, entry), *light2; PLIGHTINFOEL *light = LIST_ENTRY(e1, PLIGHTINFOEL, entry), *light2;
light2 = HeapAlloc(GetProcessHeap(), 0, sizeof(*light)); light2 = HeapAlloc(GetProcessHeap(), 0, sizeof(*light));
*light2 = *light; *light2 = *light;
list_add_tail(&Dest->lightMap[l], &light2->entry); list_add_tail(&dst->lightMap[l], &light2->entry);
if(light2->glIndex != -1) Dest->activeLights[light2->glIndex] = light2; if (light2->glIndex != -1) dst->activeLights[light2->glIndex] = light2;
} }
} }
/* Fixed size arrays */ /* Fixed size arrays */
memcpy(Dest->vertexShaderConstantB, This->vertexShaderConstantB, sizeof(Dest->vertexShaderConstantB)); memcpy(dst->vertexShaderConstantB, src->vertexShaderConstantB, sizeof(dst->vertexShaderConstantB));
memcpy(Dest->vertexShaderConstantI, This->vertexShaderConstantI, sizeof(Dest->vertexShaderConstantI)); memcpy(dst->vertexShaderConstantI, src->vertexShaderConstantI, sizeof(dst->vertexShaderConstantI));
memcpy(Dest->pixelShaderConstantB, This->pixelShaderConstantB, sizeof(Dest->pixelShaderConstantB)); memcpy(dst->pixelShaderConstantB, src->pixelShaderConstantB, sizeof(dst->pixelShaderConstantB));
memcpy(Dest->pixelShaderConstantI, This->pixelShaderConstantI, sizeof(Dest->pixelShaderConstantI)); memcpy(dst->pixelShaderConstantI, src->pixelShaderConstantI, sizeof(dst->pixelShaderConstantI));
memcpy(Dest->streamStride, This->streamStride, sizeof(Dest->streamStride)); memcpy(dst->streamStride, src->streamStride, sizeof(dst->streamStride));
memcpy(Dest->streamOffset, This->streamOffset, sizeof(Dest->streamOffset)); memcpy(dst->streamOffset, src->streamOffset, sizeof(dst->streamOffset));
memcpy(Dest->streamSource, This->streamSource, sizeof(Dest->streamSource)); memcpy(dst->streamSource, src->streamSource, sizeof(dst->streamSource));
memcpy(Dest->streamFreq, This->streamFreq, sizeof(Dest->streamFreq)); memcpy(dst->streamFreq, src->streamFreq, sizeof(dst->streamFreq));
memcpy(Dest->streamFlags, This->streamFlags, sizeof(Dest->streamFlags)); memcpy(dst->streamFlags, src->streamFlags, sizeof(dst->streamFlags));
memcpy(Dest->transforms, This->transforms, sizeof(Dest->transforms)); memcpy(dst->transforms, src->transforms, sizeof(dst->transforms));
memcpy(Dest->clipplane, This->clipplane, sizeof(Dest->clipplane)); memcpy(dst->clipplane, src->clipplane, sizeof(dst->clipplane));
memcpy(Dest->renderState, This->renderState, sizeof(Dest->renderState)); memcpy(dst->renderState, src->renderState, sizeof(dst->renderState));
memcpy(Dest->textures, This->textures, sizeof(Dest->textures)); memcpy(dst->textures, src->textures, sizeof(dst->textures));
memcpy(Dest->textureState, This->textureState, sizeof(Dest->textureState)); memcpy(dst->textureState, src->textureState, sizeof(dst->textureState));
memcpy(Dest->samplerState, This->samplerState, sizeof(Dest->samplerState)); memcpy(dst->samplerState, src->samplerState, sizeof(dst->samplerState));
/* Dynamically sized arrays */ /* Dynamically sized arrays */
memcpy(Dest->vertexShaderConstantF, This->vertexShaderConstantF, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4); memcpy(dst->vertexShaderConstantF, src->vertexShaderConstantF, sizeof(float) * gl_info->max_vshader_constantsF * 4);
memcpy(Dest->pixelShaderConstantF, This->pixelShaderConstantF, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4); memcpy(dst->pixelShaderConstantF, src->pixelShaderConstantF, sizeof(float) * gl_info->max_pshader_constantsF * 4);
} }
/********************************************************** /**********************************************************
@ -1383,7 +1380,7 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *
if (type == WINED3DSBT_INIT || type == WINED3DSBT_RECORDED) return WINED3D_OK; if (type == WINED3DSBT_INIT || type == WINED3DSBT_RECORDED) return WINED3D_OK;
/* Otherwise, might as well set the whole state block to the appropriate values */ /* Otherwise, might as well set the whole state block to the appropriate values */
if (device->stateBlock) stateblock_copy((IWineD3DStateBlock *)stateblock, (IWineD3DStateBlock *)device->stateBlock); if (device->stateBlock) stateblock_copy(stateblock, device->stateBlock);
else memset(stateblock->streamFreq, 1, sizeof(stateblock->streamFreq)); else memset(stateblock->streamFreq, 1, sizeof(stateblock->streamFreq));
/* Reset the ref and type after kludging it. */ /* Reset the ref and type after kludging it. */