Lines Matching refs:This

10  * This library is free software; you can redistribute it and/or
15 * This library is distributed in the hope that it will be useful,
474 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
475 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
480 *ppobj = This;
488 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
489 ULONG refCount = InterlockedIncrement(&This->ref);
491 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
496 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
497 ULONG refCount = InterlockedDecrement(&This->ref);
499 TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
504 if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
508 if (This->textures[counter]) IWineD3DBaseTexture_Release(This->textures[counter]);
512 if(This->streamSource[counter]) {
513 if (IWineD3DBuffer_Release(This->streamSource[counter]))
515 TRACE("Vertex buffer still referenced by stateblock, applications has leaked Stream %u, buffer %p\n", counter, This->streamSource[counter]);
519 if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
520 if(This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
521 if(This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
525 LIST_FOR_EACH_SAFE(e1, e2, &This->lightMap[counter])
533 HeapFree(GetProcessHeap(), 0, This->vertexShaderConstantF);
534 HeapFree(GetProcessHeap(), 0, This->changed.vertexShaderConstantsF);
535 HeapFree(GetProcessHeap(), 0, This->pixelShaderConstantF);
536 HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
537 HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f);
538 HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f);
539 HeapFree(GetProcessHeap(), 0, This);
547 static void record_lights(IWineD3DStateBlockImpl *This, const IWineD3DStateBlockImpl *targetStateBlock)
556 LIST_FOR_EACH(e, &This->lightMap[i]) {
570 This->activeLights[src->glIndex] = NULL;
575 This->activeLights[realLight->glIndex] = src;
585 /* This can happen if the light was originally created as a
588 src->OriginalIndex, This, targetStateBlock);
593 This->activeLights[src->glIndex] = NULL;
603 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
604 IWineD3DStateBlockImpl *targetStateBlock = This->device->stateBlock;
608 TRACE("(%p) : Updating state block %p ------------------v\n", targetStateBlock, This);
610 if (This->changed.vertexShader && This->vertexShader != targetStateBlock->vertexShader)
612 TRACE("Updating vertex shader from %p to %p\n", This->vertexShader, targetStateBlock->vertexShader);
615 if (This->vertexShader) IWineD3DVertexShader_Release(This->vertexShader);
616 This->vertexShader = targetStateBlock->vertexShader;
620 for (i = 0; i < This->num_contained_vs_consts_f; ++i)
622 unsigned int idx = This->contained_vs_consts_f[i];
625 This, targetStateBlock, idx,
631 This->vertexShaderConstantF[idx * 4 + 0] = targetStateBlock->vertexShaderConstantF[idx * 4 + 0];
632 This->vertexShaderConstantF[idx * 4 + 1] = targetStateBlock->vertexShaderConstantF[idx * 4 + 1];
633 This->vertexShaderConstantF[idx * 4 + 2] = targetStateBlock->vertexShaderConstantF[idx * 4 + 2];
634 This->vertexShaderConstantF[idx * 4 + 3] = targetStateBlock->vertexShaderConstantF[idx * 4 + 3];
638 for (i = 0; i < This->num_contained_vs_consts_i; ++i)
640 unsigned int idx = This->contained_vs_consts_i[i];
643 This, targetStateBlock, idx,
649 This->vertexShaderConstantI[idx * 4 + 0] = targetStateBlock->vertexShaderConstantI[idx * 4 + 0];
650 This->vertexShaderConstantI[idx * 4 + 1] = targetStateBlock->vertexShaderConstantI[idx * 4 + 1];
651 This->vertexShaderConstantI[idx * 4 + 2] = targetStateBlock->vertexShaderConstantI[idx * 4 + 2];
652 This->vertexShaderConstantI[idx * 4 + 3] = targetStateBlock->vertexShaderConstantI[idx * 4 + 3];
656 for (i = 0; i < This->num_contained_vs_consts_b; ++i)
658 unsigned int idx = This->contained_vs_consts_b[i];
661 This, targetStateBlock, idx,
664 This->vertexShaderConstantB[idx] = targetStateBlock->vertexShaderConstantB[idx];
668 for (i = 0; i < This->num_contained_ps_consts_f; ++i)
670 unsigned int idx = This->contained_ps_consts_f[i];
673 This, targetStateBlock, idx,
679 This->pixelShaderConstantF[idx * 4 + 0] = targetStateBlock->pixelShaderConstantF[idx * 4 + 0];
680 This->pixelShaderConstantF[idx * 4 + 1] = targetStateBlock->pixelShaderConstantF[idx * 4 + 1];
681 This->pixelShaderConstantF[idx * 4 + 2] = targetStateBlock->pixelShaderConstantF[idx * 4 + 2];
682 This->pixelShaderConstantF[idx * 4 + 3] = targetStateBlock->pixelShaderConstantF[idx * 4 + 3];
686 for (i = 0; i < This->num_contained_ps_consts_i; ++i)
688 unsigned int idx = This->contained_ps_consts_i[i];
690 This, targetStateBlock, idx,
696 This->pixelShaderConstantI[idx * 4 + 0] = targetStateBlock->pixelShaderConstantI[idx * 4 + 0];
697 This->pixelShaderConstantI[idx * 4 + 1] = targetStateBlock->pixelShaderConstantI[idx * 4 + 1];
698 This->pixelShaderConstantI[idx * 4 + 2] = targetStateBlock->pixelShaderConstantI[idx * 4 + 2];
699 This->pixelShaderConstantI[idx * 4 + 3] = targetStateBlock->pixelShaderConstantI[idx * 4 + 3];
703 for (i = 0; i < This->num_contained_ps_consts_b; ++i)
705 unsigned int idx = This->contained_ps_consts_b[i];
706 TRACE("Setting %p from %p %u to %s.\n", This, targetStateBlock, idx,
709 This->pixelShaderConstantB[idx] = targetStateBlock->pixelShaderConstantB[idx];
713 for (i = 0; i < This->num_contained_transform_states; ++i)
715 WINED3DTRANSFORMSTATETYPE transform = This->contained_transform_states[i];
719 This->transforms[transform] = targetStateBlock->transforms[transform];
722 if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
724 if (This->changed.indices
725 && ((This->pIndexData != targetStateBlock->pIndexData)
726 || (This->baseVertexIndex != targetStateBlock->baseVertexIndex)
727 || (This->IndexFmt != targetStateBlock->IndexFmt)))
733 if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
734 This->pIndexData = targetStateBlock->pIndexData;
735 This->baseVertexIndex = targetStateBlock->baseVertexIndex;
736 This->IndexFmt = targetStateBlock->IndexFmt;
739 if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl)
741 TRACE("Updating vertex declaration from %p to %p.\n", This->vertexDecl, targetStateBlock->vertexDecl);
744 if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
745 This->vertexDecl = targetStateBlock->vertexDecl;
748 if (This->changed.material
749 && memcmp(&targetStateBlock->material, &This->material, sizeof(This->material)))
753 This->material = targetStateBlock->material;
756 if (This->changed.viewport
757 && memcmp(&targetStateBlock->viewport, &This->viewport, sizeof(This->viewport)))
761 This->viewport = targetStateBlock->viewport;
764 if(This->changed.scissorRect
765 && memcmp(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(This->scissorRect)))
769 This->scissorRect = targetStateBlock->scissorRect;
772 map = This->changed.streamSource;
777 if (This->streamStride[i] != targetStateBlock->streamStride[i]
778 || This->streamSource[i] != targetStateBlock->streamSource[i])
783 This->streamStride[i] = targetStateBlock->streamStride[i];
785 if (This->streamSource[i]) IWineD3DBuffer_Release(This->streamSource[i]);
786 This->streamSource[i] = targetStateBlock->streamSource[i];
790 map = This->changed.streamFreq;
795 if (This->streamFreq[i] != targetStateBlock->streamFreq[i]
796 || This->streamFlags[i] != targetStateBlock->streamFlags[i])
801 This->streamFreq[i] = targetStateBlock->streamFreq[i];
802 This->streamFlags[i] = targetStateBlock->streamFlags[i];
806 map = This->changed.clipplane;
811 if (memcmp(targetStateBlock->clipplane[i], This->clipplane[i], sizeof(*This->clipplane)))
814 memcpy(This->clipplane[i], targetStateBlock->clipplane[i], sizeof(*This->clipplane));
819 for (i = 0; i < This->num_contained_render_states; ++i)
821 WINED3DRENDERSTATETYPE rs = This->contained_render_states[i];
825 This->renderState[rs] = targetStateBlock->renderState[rs];
829 for (i = 0; i < This->num_contained_tss_states; ++i)
831 DWORD stage = This->contained_tss_states[i].stage;
832 DWORD state = This->contained_tss_states[i].state;
835 targetStateBlock->textureState[stage][state], This->textureState[stage][state]);
837 This->textureState[stage][state] = targetStateBlock->textureState[stage][state];
841 map = This->changed.textures;
846 TRACE("Updating texture %u to %p (was %p).\n", i, targetStateBlock->textures[i], This->textures[i]);
849 if (This->textures[i]) IWineD3DBaseTexture_Release(This->textures[i]);
850 This->textures[i] = targetStateBlock->textures[i];
853 for (i = 0; i < This->num_contained_sampler_states; ++i)
855 DWORD stage = This->contained_sampler_states[i].stage;
856 DWORD state = This->contained_sampler_states[i].state;
859 targetStateBlock->samplerState[stage][state], This->samplerState[stage][state]);
861 This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state];
864 if (This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader)
867 if (This->pixelShader) IWineD3DPixelShader_Release(This->pixelShader);
868 This->pixelShader = targetStateBlock->pixelShader;
871 record_lights(This, targetStateBlock);
873 TRACE("(%p) : Updated state block %p ------------------^\n", targetStateBlock, This);
878 static void apply_lights(IWineD3DDevice *pDevice, const IWineD3DStateBlockImpl *This)
884 LIST_FOR_EACH(e, &This->lightMap[i])
896 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
897 IWineD3DDevice *pDevice = (IWineD3DDevice *)This->device;
901 TRACE("(%p) : Applying state block %p ------------------v\n", This, pDevice);
903 TRACE("Blocktype: %d\n", This->blockType);
905 if (This->changed.vertexShader) IWineD3DDevice_SetVertexShader(pDevice, This->vertexShader);
908 for (i = 0; i < This->num_contained_vs_consts_f; ++i)
910 IWineD3DDevice_SetVertexShaderConstantF(pDevice, This->contained_vs_consts_f[i],
911 This->vertexShaderConstantF + This->contained_vs_consts_f[i] * 4, 1);
913 for (i = 0; i < This->num_contained_vs_consts_i; ++i)
915 IWineD3DDevice_SetVertexShaderConstantI(pDevice, This->contained_vs_consts_i[i],
916 This->vertexShaderConstantI + This->contained_vs_consts_i[i] * 4, 1);
918 for (i = 0; i < This->num_contained_vs_consts_b; ++i)
920 IWineD3DDevice_SetVertexShaderConstantB(pDevice, This->contained_vs_consts_b[i],
921 This->vertexShaderConstantB + This->contained_vs_consts_b[i], 1);
924 apply_lights(pDevice, This);
926 if (This->changed.pixelShader) IWineD3DDevice_SetPixelShader(pDevice, This->pixelShader);
929 for (i = 0; i < This->num_contained_ps_consts_f; ++i)
931 IWineD3DDevice_SetPixelShaderConstantF(pDevice, This->contained_ps_consts_f[i],
932 This->pixelShaderConstantF + This->contained_ps_consts_f[i] * 4, 1);
934 for (i = 0; i < This->num_contained_ps_consts_i; ++i)
936 IWineD3DDevice_SetPixelShaderConstantI(pDevice, This->contained_ps_consts_i[i],
937 This->pixelShaderConstantI + This->contained_ps_consts_i[i] * 4, 1);
939 for (i = 0; i < This->num_contained_ps_consts_b; ++i)
941 IWineD3DDevice_SetPixelShaderConstantB(pDevice, This->contained_ps_consts_b[i],
942 This->pixelShaderConstantB + This->contained_ps_consts_b[i], 1);
946 for (i = 0; i < This->num_contained_render_states; ++i)
948 IWineD3DDevice_SetRenderState(pDevice, This->contained_render_states[i],
949 This->renderState[This->contained_render_states[i]]);
953 for (i = 0; i < This->num_contained_tss_states; ++i)
955 DWORD stage = This->contained_tss_states[i].stage;
956 DWORD state = This->contained_tss_states[i].state;
958 IWineD3DDevice_SetTextureStageState(pDevice, stage, state, This->textureState[stage][state]);
962 for (i = 0; i < This->num_contained_sampler_states; ++i)
964 DWORD stage = This->contained_sampler_states[i].stage;
965 DWORD state = This->contained_sampler_states[i].state;
966 DWORD value = This->samplerState[stage][state];
972 for (i = 0; i < This->num_contained_transform_states; ++i)
974 IWineD3DDevice_SetTransform(pDevice, This->contained_transform_states[i],
975 &This->transforms[This->contained_transform_states[i]]);
978 if (This->changed.primitive_type)
980 This->device->updateStateBlock->changed.primitive_type = TRUE;
981 This->device->updateStateBlock->gl_primitive_type = This->gl_primitive_type;
984 if (This->changed.indices)
986 IWineD3DDevice_SetIndexBuffer(pDevice, This->pIndexData, This->IndexFmt);
987 IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
990 if (This->changed.vertexDecl && This->vertexDecl)
992 IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
995 if (This->changed.material)
997 IWineD3DDevice_SetMaterial(pDevice, &This->material);
1000 if (This->changed.viewport)
1002 IWineD3DDevice_SetViewport(pDevice, &This->viewport);
1005 if (This->changed.scissorRect)
1007 IWineD3DDevice_SetScissorRect(pDevice, &This->scissorRect);
1010 map = This->changed.streamSource;
1013 if (map & 1) IWineD3DDevice_SetStreamSource(pDevice, i, This->streamSource[i], 0, This->streamStride[i]);
1016 map = This->changed.streamFreq;
1019 if (map & 1) IWineD3DDevice_SetStreamSourceFreq(pDevice, i, This->streamFreq[i] | This->streamFlags[i]);
1022 map = This->changed.textures;
1030 IWineD3DDevice_SetTexture(pDevice, stage, This->textures[i]);
1033 map = This->changed.clipplane;
1040 clip[0] = This->clipplane[i][0];
1041 clip[1] = This->clipplane[i][1];
1042 clip[2] = This->clipplane[i][2];
1043 clip[3] = This->clipplane[i][3];
1047 This->device->stateBlock->lowest_disabled_stage = MAX_TEXTURES - 1;
1050 if (This->device->stateBlock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
1052 This->device->stateBlock->lowest_disabled_stage = i;
1056 TRACE("(%p) : Applied state block %p ------------------^\n", This, pDevice);
1062 IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
1063 IWineD3DDevice *device = (IWineD3DDevice *)This->device;
1082 TRACE("(%p) -----------------------> Setting up device defaults... %p\n", This, ThisDevice);
1084 This->blockType = WINED3DSBT_INIT;
1087 memcpy(&This->transforms[WINED3DTS_PROJECTION], identity, sizeof(identity));
1088 memcpy(&This->transforms[WINED3DTS_VIEW], identity, sizeof(identity));
1090 memcpy(&This->transforms[WINED3DTS_WORLDMATRIX(i)], identity, sizeof(identity));
1228 This->clip_status.ClipUnion = 0;
1229 This->clip_status.ClipIntersection = 0xFFFFFFFF;
1234 memcpy(&This->transforms[WINED3DTS_TEXTURE0 + i], identity, sizeof(identity));
1235 This->textureState[i][WINED3DTSS_COLOROP ] = (i==0)? WINED3DTOP_MODULATE : WINED3DTOP_DISABLE;
1236 This->textureState[i][WINED3DTSS_COLORARG1 ] = WINED3DTA_TEXTURE;
1237 This->textureState[i][WINED3DTSS_COLORARG2 ] = WINED3DTA_CURRENT;
1238 This->textureState[i][WINED3DTSS_ALPHAOP ] = (i==0)? WINED3DTOP_SELECTARG1 : WINED3DTOP_DISABLE;
1239 This->textureState[i][WINED3DTSS_ALPHAARG1 ] = WINED3DTA_TEXTURE;
1240 This->textureState[i][WINED3DTSS_ALPHAARG2 ] = WINED3DTA_CURRENT;
1241 This->textureState[i][WINED3DTSS_BUMPENVMAT00 ] = 0;
1242 This->textureState[i][WINED3DTSS_BUMPENVMAT01 ] = 0;
1243 This->textureState[i][WINED3DTSS_BUMPENVMAT10 ] = 0;
1244 This->textureState[i][WINED3DTSS_BUMPENVMAT11 ] = 0;
1245 This->textureState[i][WINED3DTSS_TEXCOORDINDEX ] = i;
1246 This->textureState[i][WINED3DTSS_BUMPENVLSCALE ] = 0;
1247 This->textureState[i][WINED3DTSS_BUMPENVLOFFSET ] = 0;
1248 This->textureState[i][WINED3DTSS_TEXTURETRANSFORMFLAGS ] = WINED3DTTFF_DISABLE;
1249 This->textureState[i][WINED3DTSS_COLORARG0 ] = WINED3DTA_CURRENT;
1250 This->textureState[i][WINED3DTSS_ALPHAARG0 ] = WINED3DTA_CURRENT;
1251 This->textureState[i][WINED3DTSS_RESULTARG ] = WINED3DTA_CURRENT;
1253 This->lowest_disabled_stage = 1;
1258 This->samplerState[i][WINED3DSAMP_ADDRESSU ] = WINED3DTADDRESS_WRAP;
1259 This->samplerState[i][WINED3DSAMP_ADDRESSV ] = WINED3DTADDRESS_WRAP;
1260 This->samplerState[i][WINED3DSAMP_ADDRESSW ] = WINED3DTADDRESS_WRAP;
1261 This->samplerState[i][WINED3DSAMP_BORDERCOLOR ] = 0x00;
1262 This->samplerState[i][WINED3DSAMP_MAGFILTER ] = WINED3DTEXF_POINT;
1263 This->samplerState[i][WINED3DSAMP_MINFILTER ] = WINED3DTEXF_POINT;
1264 This->samplerState[i][WINED3DSAMP_MIPFILTER ] = WINED3DTEXF_NONE;
1265 This->samplerState[i][WINED3DSAMP_MIPMAPLODBIAS ] = 0;
1266 This->samplerState[i][WINED3DSAMP_MAXMIPLEVEL ] = 0;
1267 This->samplerState[i][WINED3DSAMP_MAXANISOTROPY ] = 1;
1268 This->samplerState[i][WINED3DSAMP_SRGBTEXTURE ] = 0;
1269 This->samplerState[i][WINED3DSAMP_ELEMENTINDEX ] = 0; /* TODO: Indicates which element of a multielement texture to use */
1270 This->samplerState[i][WINED3DSAMP_DMAPOFFSET ] = 0; /* TODO: Vertex offset in the presampled displacement map */
1275 /* Note: This avoids calling SetTexture, so pretend it has been called */
1276 This->changed.textures |= 1 << i;
1277 This->textures[i] = NULL;
1300 if (FAILED(hr)) ERR("This should never happen, expect rendering issues!\n");