Lines Matching refs:This

14  * This library is free software; you can redistribute it and/or
19 * This library is distributed in the hope that it will be useful,
52 #define GLINFO_LOCATION This->adapter->gl_info
192 void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
196 IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
219 if (!This->stateBlock->streamSource[element->input_slot]) continue;
221 stride = This->stateBlock->streamStride[element->input_slot];
222 if (This->stateBlock->streamIsUP)
224 TRACE("Stream %u is UP, %p\n", element->input_slot, This->stateBlock->streamSource[element->input_slot]);
226 data = (BYTE *)This->stateBlock->streamSource[element->input_slot];
230 TRACE("Stream %u isn't UP, %p\n", element->input_slot, This->stateBlock->streamSource[element->input_slot]);
231 data = buffer_get_memory(This->stateBlock->streamSource[element->input_slot], &buffer_object);
238 if (This->stateBlock->loadBaseVertexIndex < 0)
240 WARN("loadBaseVertexIndex is < 0 (%d), not using vbos\n", This->stateBlock->loadBaseVertexIndex);
242 data = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->streamSource[element->input_slot]);
243 if ((UINT_PTR)data < -This->stateBlock->loadBaseVertexIndex * stride)
259 /* This may be bad with the fixed function pipeline. */
277 stride_used = vshader_get_input(This->stateBlock->vertexShader,
314 if (!This->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
323 This->num_buffer_queries = 0;
324 if (!This->stateBlock->streamIsUP)
338 buffer = (struct wined3d_buffer *)This->stateBlock->streamSource[element->stream_idx];
351 This->buffer_queries[This->num_buffer_queries++] = query;
588 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
590 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
595 *ppobj = This;
603 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
604 ULONG refCount = InterlockedIncrement(&This->ref);
606 TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
611 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
612 ULONG refCount = InterlockedDecrement(&This->ref);
614 TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
619 for (i = 0; i < sizeof(This->multistate_funcs)/sizeof(This->multistate_funcs[0]); ++i) {
620 HeapFree(GetProcessHeap(), 0, This->multistate_funcs[i]);
621 This->multistate_funcs[i] = NULL;
628 if (!list_empty(&This->resources))
631 FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
633 LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
641 if(This->contexts) ERR("Context array not freed!\n");
642 if (This->hardwareCursor) DestroyCursor(This->hardwareCursor);
643 This->haveHardwareCursor = FALSE;
645 IWineD3D_Release(This->wined3d);
646 This->wined3d = NULL;
647 HeapFree(GetProcessHeap(), 0, This);
648 TRACE("Freed device %p\n", This);
649 This = NULL;
658 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
659 *pParent = This->parent;
660 IUnknown_AddRef(This->parent);
667 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
682 hr = buffer_init(object, This, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
703 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
728 hr = buffer_init(object, This, Size, Usage, WINED3DFMT_VERTEXDATA,
747 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
751 TRACE("(%p) Creating index buffer\n", This);
762 hr = buffer_init(object, This, Length, Usage | WINED3DUSAGE_STATICDECL,
782 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
793 hr = stateblock_init(object, This, type);
817 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
827 if (Impl == SURFACE_OPENGL && !This->adapter)
840 hr = surface_init(object, Impl, This->surface_alignment, Width, Height, Level, Lockable,
841 Discard, MultiSample, MultisampleQuality, This, Usage, Format, Pool, parent, parent_ops
854 TRACE("(%p) : Created surface %p\n", This, object);
893 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
897 TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#x\n", This, Width, Height, Levels, Usage);
909 hr = texture_init(object, Width, Height, Levels, This, Usage, Format, Pool, parent, parent_ops
925 TRACE("(%p) : Created texture %p\n", This, object);
939 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
943 TRACE("(%p) : W(%u) H(%u) D(%u), Lvl(%u) Usage(%#x), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
954 hr = volumetexture_init(object, Width, Height, Depth, Levels, This, Usage, Format, Pool, parent, parent_ops
968 TRACE("(%p) : Created volume texture %p.\n", This, object);
983 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
987 TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
998 hr = volume_init(object, This, Width, Height, Depth, Usage, Format, Pool, parent, parent_ops
1011 TRACE("(%p) : Created volume %p.\n", This, object);
1026 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1038 hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent, parent_ops
1053 TRACE("(%p) : Created Cube Texture %p\n", This, object);
1062 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1075 hr = query_init(object, This, type, parent);
1093 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1107 hr = swapchain_init(object, surface_type, This, present_parameters, parent);
1123 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1124 TRACE("(%p)\n", This);
1126 return This->NumberOfSwapChains;
1130 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1131 TRACE("(%p) : swapchain %d\n", This, iSwapChain);
1133 if(iSwapChain < This->NumberOfSwapChains) {
1134 *pSwapChain = This->swapchains[iSwapChain];
1136 TRACE("(%p) returning %p\n", This, *pSwapChain);
1149 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1163 hr = vertexdeclaration_init(object, This, elements, element_count, parent, parent_ops);
1206 static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
1209 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
1318 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
1325 size = ConvertFvfToDeclaration(This, fvf, &elements);
1338 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1349 hr = vertexshader_init(object, This, pFunction, output_signature, parent, parent_ops);
1358 object = vertexshader_check_cached(This, object);
1372 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1383 hr = geometryshader_init(object, This, byte_code, output_signature, parent, parent_ops);
1402 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
1413 hr = pixelshader_init(object, This, pFunction, output_signature, parent, parent_ops);
1422 object = pixelshader_check_cached(This, object);
1434 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
1448 hr = wined3d_palette_init(object, This, Flags, PalEnt, Parent);
1462 static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *filename) {
1488 hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
1489 FALSE, 0, &This->logo_surface, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL,
1492 hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
1493 FALSE, 0, &This->logo_surface, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL,
1502 hr = IWineD3DSurface_GetDC(This->logo_surface, &dcs);
1505 IWineD3DSurface_ReleaseDC(This->logo_surface, dcs);
1509 IWineD3DSurface_SetColorKey(This->logo_surface, WINEDDCKEY_SRCBLT, &colorkey);
1512 IWineD3DDevice_ColorFill((IWineD3DDevice *) This, This->logo_surface, NULL, 0xffffffff);
1521 static void create_dummy_textures(IWineD3DDeviceImpl *This)
1523 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
1548 glGenTextures(1, &This->dummyTextureName[i]);
1550 TRACE("Dummy Texture %d given name %d\n", i, This->dummyTextureName[i]);
1554 glBindTexture(GL_TEXTURE_2D, This->dummyTextureName[i]);
1616 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
1617 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
1624 TRACE("(%p)->(%p)\n", This, pPresentationParameters);
1626 if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
1627 if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
1635 This->pHgsmi = pPresentationParameters->pHgsmi;
1637 TRACE("(%p) : Creating stateblock\n", This);
1641 (IWineD3DStateBlock **)&This->stateBlock,
1647 TRACE("(%p) : Created stateblock (%p)\n", This, This->stateBlock);
1648 This->updateStateBlock = This->stateBlock;
1649 IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
1651 This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1653 This->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1656 This->NumberOfPalettes = 1;
1657 This->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
1658 if(!This->palettes || !This->render_targets || !This->draw_buffers) {
1663 This->palettes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
1664 if(!This->palettes[0]) {
1670 This->palettes[0][i].peRed = 0xFF;
1671 This->palettes[0][i].peGreen = 0xFF;
1672 This->palettes[0][i].peBlue = 0xFF;
1673 This->palettes[0][i].peFlags = 0xFF;
1675 This->currentPalette = 0;
1682 This->texUnitMap[state] = state;
1683 This->rev_tex_unit_map[state] = state;
1685 This->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
1686 This->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
1690 /* Setup the implicit swapchain. This also initializes a context. */
1692 hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
1700 This->NumberOfSwapChains = 1;
1701 This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
1702 if(!This->swapchains) {
1706 This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
1710 This->render_targets[0] = swapchain->backBuffer[0];
1714 This->render_targets[0] = swapchain->frontBuffer;
1716 IWineD3DSurface_AddRef(This->render_targets[0]);
1719 This->stencilBufferTarget = This->auto_depth_stencil_buffer;
1720 if (NULL != This->stencilBufferTarget) {
1721 IWineD3DSurface_AddRef(This->stencilBufferTarget);
1724 hr = This->shader_backend->shader_alloc_private(iface);
1729 hr = This->frag_pipe->alloc_private(iface);
1734 hr = This->blitter->alloc_private(iface);
1743 IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)This->stateBlock);
1745 context = context_acquire(This, swapchain->frontBuffer, CTXUSAGE_RESOURCELOAD);
1747 create_dummy_textures(This);
1752 This->view_ident = 1;
1753 This->contexts[0]->last_was_rhw = 0;
1754 glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights);
1755 checkGLcall("glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights)");
1759 This->offscreenBuffer = GL_COLOR_ATTACHMENT0;
1767 This->offscreenBuffer = GL_AUX0;
1770 This->offscreenBuffer = GL_BACK;
1775 TRACE("(%p) All defaults now set up, leaving Init3D with %p\n", This, This);
1781 IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL,
1785 This->d3d_initialized = TRUE;
1788 IWineD3DDeviceImpl_LoadLogo(This, wined3d_settings.logo);
1790 This->highest_dirty_ps_const = 0;
1791 This->highest_dirty_vs_const = 0;
1795 HeapFree(GetProcessHeap(), 0, This->render_targets);
1796 HeapFree(GetProcessHeap(), 0, This->draw_buffers);
1797 HeapFree(GetProcessHeap(), 0, This->swapchains);
1798 This->NumberOfSwapChains = 0;
1799 if(This->palettes) {
1800 HeapFree(GetProcessHeap(), 0, This->palettes[0]);
1801 HeapFree(GetProcessHeap(), 0, This->palettes);
1803 This->NumberOfPalettes = 0;
1807 if(This->stateBlock) {
1808 IWineD3DStateBlock_Release((IWineD3DStateBlock *) This->stateBlock);
1809 This->stateBlock = NULL;
1811 if (This->blit_priv) {
1812 This->blitter->free_private(iface);
1814 if (This->fragment_priv) {
1815 This->frag_pipe->free_private(iface);
1817 if (This->shader_priv) {
1818 This->shader_backend->shader_free_private(iface);
1826 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
1832 hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
1840 This->NumberOfSwapChains = 1;
1841 This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
1842 if(!This->swapchains) {
1846 This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
1864 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
1869 TRACE("(%p)\n", This);
1871 if(!This->d3d_initialized) return WINED3DERR_INVALIDCALL;
1874 VBOXWINEPROFILE_DRAWPRIM_TERM(&This->DrawPrimProfile);
1880 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
1883 if(This->logo_surface) IWineD3DSurface_Release(This->logo_surface);
1892 LIST_FOR_EACH_SAFE(e1, e2, &This->patches[i]) {
1899 if(This->cursorTexture) {
1901 glDeleteTextures(1, &This->cursorTexture);
1903 This->cursorTexture = 0;
1916 if(This->depth_blt_texture) {
1918 glDeleteTextures(1, &This->depth_blt_texture);
1920 This->depth_blt_texture = 0;
1922 if (This->depth_blt_rb) {
1924 gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
1926 This->depth_blt_rb = 0;
1927 This->depth_blt_rb_w = 0;
1928 This->depth_blt_rb_h = 0;
1932 if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
1933 if(This->updateStateBlock != This->stateBlock)
1934 FIXME("(%p) Something's still holding the Update stateblock\n",This);
1936 This->updateStateBlock = NULL;
1941 IWineD3DStateBlock *stateBlock = (IWineD3DStateBlock *)This->stateBlock;
1942 This->stateBlock = NULL;
1946 FIXME("(%p) Something's still holding the Update stateblock\n",This);
1951 shader_chaches_term(This);
1955 This->blitter->free_private(iface);
1956 This->frag_pipe->free_private(iface);
1957 This->shader_backend->shader_free_private(iface);
1960 TRACE("Releasing the depth stencil buffer at %p\n", This->stencilBufferTarget);
1961 if(This->stencilBufferTarget != NULL && (IWineD3DSurface_Release(This->stencilBufferTarget) >0)){
1962 if(This->auto_depth_stencil_buffer != This->stencilBufferTarget)
1963 FIXME("(%p) Something's still holding the stencilBufferTarget\n",This);
1965 This->stencilBufferTarget = NULL;
1967 TRACE("Releasing the render target at %p\n", This->render_targets[0]);
1968 IWineD3DSurface_Release(This->render_targets[0]);
1971 This->render_targets[0] = NULL;
1973 if (This->auto_depth_stencil_buffer) {
1974 if (IWineD3DSurface_Release(This->auto_depth_stencil_buffer) > 0)
1976 FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This);
1978 This->auto_depth_stencil_buffer = NULL;
1983 for(i=0; i < This->NumberOfSwapChains; i++) {
1985 if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
1986 FIXME("(%p) Something's still holding the implicit swapchain\n", This);
1990 if (This->swapchains)
1992 HeapFree(GetProcessHeap(), 0, This->swapchains);
1993 This->swapchains = NULL;
1994 This->NumberOfSwapChains = 0;
1998 Assert(!This->NumberOfSwapChains);
2001 for (i = 0; i < This->NumberOfPalettes; i++) HeapFree(GetProcessHeap(), 0, This->palettes[i]);
2002 HeapFree(GetProcessHeap(), 0, This->palettes);
2003 This->palettes = NULL;
2004 This->NumberOfPalettes = 0;
2006 HeapFree(GetProcessHeap(), 0, This->render_targets);
2007 HeapFree(GetProcessHeap(), 0, This->draw_buffers);
2008 This->render_targets = NULL;
2009 This->draw_buffers = NULL;
2011 This->d3d_initialized = FALSE;
2017 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
2020 for(i=0; i < This->NumberOfSwapChains; i++) {
2022 if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
2023 FIXME("(%p) Something's still holding the implicit swapchain\n", This);
2027 HeapFree(GetProcessHeap(), 0, This->swapchains);
2028 This->swapchains = NULL;
2029 This->NumberOfSwapChains = 0;
2040 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
2043 This->createParms.BehaviorFlags |= WINED3DCREATE_MULTITHREADED;
2049 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2050 const struct wined3d_format_desc *format_desc = getFormatDescEntry(pMode->Format, &This->adapter->gl_info);
2054 TRACE("(%p)->(%d,%p) Mode=%dx%dx@%d, %s\n", This, iSwapChain, pMode, pMode->Width, pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
2075 if( (This->ddraw_width == pMode->Width) &&
2076 (This->ddraw_height == pMode->Height) &&
2077 (This->ddraw_format == pMode->Format) &&
2096 This->ddraw_width = pMode->Width;
2097 This->ddraw_height = pMode->Height;
2098 This->ddraw_format = pMode->Format;
2108 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2109 *ppD3D = This->wined3d;
2117 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2119 TRACE("(%p) : simulating %dMB, returning %dMB left\n", This,
2120 (This->adapter->TextureRam/(1024*1024)),
2121 ((This->adapter->TextureRam - This->adapter->UsedTextureRam) / (1024*1024)));
2123 return (This->adapter->TextureRam - This->adapter->UsedTextureRam);
2136 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2147 oldSrc = This->updateStateBlock->streamSource[StreamNumber];
2148 TRACE("(%p) : StreamNo: %u, OldStream (%p), NewStream (%p), OffsetInBytes %u, NewStride %u\n", This, StreamNumber, oldSrc, pStreamData, OffsetInBytes, Stride);
2150 This->updateStateBlock->changed.streamSource |= 1 << StreamNumber;
2153 This->updateStateBlock->streamStride[StreamNumber] == Stride &&
2154 This->updateStateBlock->streamOffset[StreamNumber] == OffsetInBytes) {
2159 This->updateStateBlock->streamSource[StreamNumber] = pStreamData;
2161 This->updateStateBlock->streamStride[StreamNumber] = Stride;
2162 This->updateStateBlock->streamOffset[StreamNumber] = OffsetInBytes;
2166 if (This->isRecordingState) {
2182 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
2190 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2192 TRACE("(%p) : StreamNo: %u, Stream (%p), Offset %u, Stride %u\n", This, StreamNumber,
2193 This->stateBlock->streamSource[StreamNumber],
2194 This->stateBlock->streamOffset[StreamNumber],
2195 This->stateBlock->streamStride[StreamNumber]);
2201 *pStream = This->stateBlock->streamSource[StreamNumber];
2202 *pStride = This->stateBlock->streamStride[StreamNumber];
2204 *pOffset = This->stateBlock->streamOffset[StreamNumber];
2214 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2215 UINT oldFlags = This->updateStateBlock->streamFlags[StreamNumber];
2216 UINT oldFreq = This->updateStateBlock->streamFreq[StreamNumber];
2232 TRACE("(%p) StreamNumber(%d), Divider(%d)\n", This, StreamNumber, Divider);
2233 This->updateStateBlock->streamFlags[StreamNumber] = Divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA );
2235 This->updateStateBlock->changed.streamFreq |= 1 << StreamNumber;
2236 This->updateStateBlock->streamFreq[StreamNumber] = Divider & 0x7FFFFF;
2238 if(This->updateStateBlock->streamFreq[StreamNumber] != oldFreq ||
2239 This->updateStateBlock->streamFlags[StreamNumber] != oldFlags) {
2240 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
2247 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2249 TRACE("(%p) StreamNumber(%d), Divider(%p)\n", This, StreamNumber, Divider);
2250 *Divider = This->updateStateBlock->streamFreq[StreamNumber] | This->updateStateBlock->streamFlags[StreamNumber];
2252 TRACE("(%p) : returning %d\n", This, *Divider);
2261 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2264 TRACE("(%p) : Transform State=%s\n", This, debug_d3dtstype(d3dts));
2267 if (This->isRecordingState) {
2269 This->updateStateBlock->changed.transform[d3dts >> 5] |= 1 << (d3dts & 0x1f);
2270 This->updateStateBlock->transforms[d3dts] = *lpmatrix;
2282 if (!memcmp(&This->stateBlock->transforms[d3dts].u.m[0][0], lpmatrix, sizeof(WINED3DMATRIX))) {
2286 conv_mat(lpmatrix, &This->stateBlock->transforms[d3dts].u.m[0][0]);
2299 This->view_ident = !memcmp(lpmatrix, identity, 16 * sizeof(float));
2303 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TRANSFORM(d3dts));
2308 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2309 TRACE("(%p) : for Transform State %s\n", This, debug_d3dtstype(State));
2310 *pMatrix = This->stateBlock->transforms[State];
2323 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2324 TRACE("(%p) : For state %s\n", This, debug_d3dtstype(State));
2328 mat = &This->updateStateBlock->transforms[State];
2354 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2355 TRACE("(%p) : Idx(%d), pLight(%p). Hash index is %d\n", This, Index, pLight, Hi);
2389 LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
2403 list_add_head(&This->updateStateBlock->lightMap[Hi], &object->entry);
2487 if (object->glIndex != -1 && !This->isRecordingState) {
2488 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(object->glIndex));
2496 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2499 TRACE("(%p) : Idx(%d), pLight(%p)\n", This, Index, pLight);
2501 LIST_FOR_EACH(e, &This->stateBlock->lightMap[Hi])
2524 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2527 TRACE("(%p) : Idx(%d), enable? %d\n", This, Index, Enable);
2529 LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
2544 LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi])
2558 if(!This->isRecordingState) {
2559 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(lightInfo->glIndex));
2562 This->updateStateBlock->activeLights[lightInfo->glIndex] = NULL;
2576 for(i = 0; i < This->maxConcurrentLights; i++) {
2577 if(This->updateStateBlock->activeLights[i] == NULL) {
2578 This->updateStateBlock->activeLights[i] = lightInfo;
2585 * D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices. This
2596 if(!This->isRecordingState) {
2597 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(i));
2608 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2611 TRACE("(%p) : for idx(%d)\n", This, Index);
2613 LIST_FOR_EACH(e, &This->stateBlock->lightMap[Hi])
2633 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2634 TRACE("(%p) : for idx %d, %p\n", This, Index, pPlane);
2637 if (Index >= This->adapter->gl_info.limits.clipplanes)
2643 This->updateStateBlock->changed.clipplane |= 1 << Index;
2645 if(This->updateStateBlock->clipplane[Index][0] == pPlane[0] &&
2646 This->updateStateBlock->clipplane[Index][1] == pPlane[1] &&
2647 This->updateStateBlock->clipplane[Index][2] == pPlane[2] &&
2648 This->updateStateBlock->clipplane[Index][3] == pPlane[3]) {
2653 This->updateStateBlock->clipplane[Index][0] = pPlane[0];
2654 This->updateStateBlock->clipplane[Index][1] = pPlane[1];
2655 This->updateStateBlock->clipplane[Index][2] = pPlane[2];
2656 This->updateStateBlock->clipplane[Index][3] = pPlane[3];
2659 if (This->isRecordingState) {
2664 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_CLIPPLANE(Index));
2670 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2671 TRACE("(%p) : for idx %d\n", This, Index);
2674 if (Index >= This->adapter->gl_info.limits.clipplanes)
2680 pPlane[0] = This->stateBlock->clipplane[Index][0];
2681 pPlane[1] = This->stateBlock->clipplane[Index][1];
2682 pPlane[2] = This->stateBlock->clipplane[Index][2];
2683 pPlane[3] = This->stateBlock->clipplane[Index][3];
2689 * WARNING: This code relies on the fact that D3DCLIPSTATUS8 == D3DCLIPSTATUS9
2692 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2693 FIXME("(%p) : stub\n", This);
2697 This->updateStateBlock->clip_status.ClipUnion = pClipStatus->ClipUnion;
2698 This->updateStateBlock->clip_status.ClipIntersection = pClipStatus->ClipIntersection;
2703 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2704 FIXME("(%p) : stub\n", This);
2708 pClipStatus->ClipUnion = This->updateStateBlock->clip_status.ClipUnion;
2709 pClipStatus->ClipIntersection = This->updateStateBlock->clip_status.ClipIntersection;
2717 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2719 This->updateStateBlock->changed.material = TRUE;
2720 This->updateStateBlock->material = *pMaterial;
2723 if (This->isRecordingState) {
2728 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_MATERIAL);
2733 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2734 *pMaterial = This->updateStateBlock->material;
2735 TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
2737 TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
2739 TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g,
2741 TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g,
2743 TRACE("(%p) : Power (%f)\n", This, pMaterial->Power);
2754 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2757 TRACE("(%p) : Setting to %p\n", This, pIndexData);
2758 oldIdxs = This->updateStateBlock->pIndexData;
2760 This->updateStateBlock->changed.indices = TRUE;
2761 This->updateStateBlock->pIndexData = pIndexData;
2762 This->updateStateBlock->IndexFmt = fmt;
2765 if (This->isRecordingState) {
2773 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
2789 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2791 *ppIndexData = This->stateBlock->pIndexData;
2796 TRACE("(%p) index data set to %p\n", This, ppIndexData);
2798 TRACE("(%p) No index data set\n", This);
2807 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2808 TRACE("(%p)->(%d)\n", This, BaseIndex);
2810 if(This->updateStateBlock->baseVertexIndex == BaseIndex) {
2815 This->updateStateBlock->baseVertexIndex = BaseIndex;
2817 if (This->isRecordingState) {
2822 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
2827 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2828 TRACE("(%p) : base_index %p\n", This, base_index);
2830 *base_index = This->stateBlock->baseVertexIndex;
2841 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2843 TRACE("(%p)\n", This);
2844 This->updateStateBlock->changed.viewport = TRUE;
2845 This->updateStateBlock->viewport = *pViewport;
2848 if (This->isRecordingState) {
2853 TRACE("(%p) : x=%d, y=%d, wid=%d, hei=%d, minz=%f, maxz=%f\n", This,
2856 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
2862 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2863 TRACE("(%p)\n", This);
2864 *pViewport = This->stateBlock->viewport;
2874 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2875 DWORD oldValue = This->stateBlock->renderState[State];
2877 TRACE("(%p)->state = %s(%d), value = %d\n", This, debug_d3drenderstate(State), State, Value);
2879 This->updateStateBlock->changed.renderState[State >> 5] |= 1 << (State & 0x1f);
2880 This->updateStateBlock->renderState[State] = Value;
2883 if (This->isRecordingState) {
2892 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State));
2899 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2900 TRACE("(%p) for State %d = %d\n", This, State, This->stateBlock->renderState[State]);
2901 *pValue = This->stateBlock->renderState[State];
2911 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2915 This, Sampler, debug_d3dsamplerstate(Type), Type, Value);
2921 if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0])) {
2940 oldValue = This->stateBlock->samplerState[Sampler][Type];
2941 This->updateStateBlock->samplerState[Sampler][Type] = Value;
2942 This->updateStateBlock->changed.samplerState[Sampler] |= 1 << Type;
2945 if (This->isRecordingState) {
2955 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(Sampler));
2961 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2964 This, Sampler, debug_d3dsamplerstate(Type), Type);
2970 if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0])) {
2974 *Value = This->stateBlock->samplerState[Sampler][Type];
2975 TRACE("(%p) : Returning %#x\n", This, *Value);
2981 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
2983 This->updateStateBlock->changed.scissorRect = TRUE;
2984 if(EqualRect(&This->updateStateBlock->scissorRect, pRect)) {
2988 CopyRect(&This->updateStateBlock->scissorRect, pRect);
2990 if(This->isRecordingState) {
2995 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT);
3001 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3003 *pRect = This->updateStateBlock->scissorRect;
3004 TRACE("(%p)Returning a Scissor Rect of %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
3009 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
3010 IWineD3DVertexDeclaration *oldDecl = This->updateStateBlock->vertexDecl;
3012 TRACE("(%p) : pDecl=%p\n", This, pDecl);
3017 This->updateStateBlock->vertexDecl = pDecl;
3018 This->updateStateBlock->changed.vertexDecl = TRUE;
3020 if (This->isRecordingState) {
3029 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
3034 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3036 TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
3038 *ppDecl = This->stateBlock->vertexDecl;
3044 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3045 IWineD3DVertexShader* oldShader = This->updateStateBlock->vertexShader;
3047 This->updateStateBlock->vertexShader = pShader;
3048 This->updateStateBlock->changed.vertexShader = TRUE;
3050 if (This->isRecordingState) {
3061 TRACE("(%p) : setting pShader(%p)\n", This, pShader);
3065 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VSHADER);
3071 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3076 *ppShader = This->stateBlock->vertexShader;
3080 TRACE("(%p) : returning %p\n", This, *ppShader);
3090 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3102 memcpy(&This->updateStateBlock->vertexShaderConstantB[start], srcData, cnt * sizeof(BOOL));
3107 This->updateStateBlock->changed.vertexShaderConstantsB |= (1 << i);
3110 if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
3121 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3133 memcpy(dstData, &This->stateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL));
3143 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3155 memcpy(&This->updateStateBlock->vertexShaderConstantI[start * 4], srcData, cnt * sizeof(int) * 4);
3161 This->updateStateBlock->changed.vertexShaderConstantsI |= (1 << i);
3164 if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
3175 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3187 memcpy(dstData, &This->stateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4);
3197 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3204 if (srcData == NULL || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF)
3210 memcpy(&This->updateStateBlock->vertexShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
3217 if (!This->isRecordingState)
3219 This->shader_backend->shader_update_float_vertex_constants(iface, start, count);
3220 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
3223 memset(This->updateStateBlock->changed.vertexShaderConstantsF + start, 1,
3224 sizeof(*This->updateStateBlock->changed.vertexShaderConstantsF) * count);
3235 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3236 int cnt = min(count, This->d3d_vshader_constantF - start);
3247 memcpy(dstData, &This->stateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4);
3251 static inline void markTextureStagesDirty(IWineD3DDeviceImpl *This, DWORD stage) {
3255 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, i));
3259 static void device_map_stage(IWineD3DDeviceImpl *This, DWORD stage, DWORD unit)
3261 DWORD i = This->rev_tex_unit_map[unit];
3262 DWORD j = This->texUnitMap[stage];
3264 This->texUnitMap[stage] = unit;
3267 This->texUnitMap[i] = WINED3D_UNMAPPED_STAGE;
3270 This->rev_tex_unit_map[unit] = stage;
3273 This->rev_tex_unit_map[j] = WINED3D_UNMAPPED_STAGE;
3277 static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) {
3280 This->fixed_function_usage_map = 0;
3282 WINED3DTEXTUREOP color_op = This->stateBlock->textureState[i][WINED3DTSS_COLOROP];
3283 WINED3DTEXTUREOP alpha_op = This->stateBlock->textureState[i][WINED3DTSS_ALPHAOP];
3284 DWORD color_arg1 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG1] & WINED3DTA_SELECTMASK;
3285 DWORD color_arg2 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG2] & WINED3DTA_SELECTMASK;
3286 DWORD color_arg3 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG0] & WINED3DTA_SELECTMASK;
3287 DWORD alpha_arg1 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG1] & WINED3DTA_SELECTMASK;
3288 DWORD alpha_arg2 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG2] & WINED3DTA_SELECTMASK;
3289 DWORD alpha_arg3 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG0] & WINED3DTA_SELECTMASK;
3302 This->fixed_function_usage_map |= (1 << i);
3306 This->fixed_function_usage_map |= (1 << (i + 1));
3311 static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
3316 device_update_fixed_function_usage_map(This);
3317 ffu_map = This->fixed_function_usage_map;
3319 if (This->max_ffp_textures == gl_info->limits.texture_stages
3320 || This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures)
3326 if (This->texUnitMap[i] != i) {
3327 device_map_stage(This, i, i);
3328 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
3329 markTextureStagesDirty(This, i);
3341 if (This->texUnitMap[i] != tex) {
3342 device_map_stage(This, i, tex);
3343 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
3344 markTextureStagesDirty(This, i);
3351 static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
3354 ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type;
3358 if (sampler_type[i] && This->texUnitMap[i] != i)
3360 device_map_stage(This, i, i);
3361 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
3364 markTextureStagesDirty(This, i);
3370 static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshader_sampler_tokens,
3373 DWORD current_mapping = This->rev_tex_unit_map[unit];
3383 return current_mapping >= MAX_TEXTURES || !(This->fixed_function_usage_map & (1 << current_mapping));
3394 static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info)
3397 ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type;
3403 IWineD3DPixelShaderImpl *pshader = (IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader;
3414 if (This->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
3421 if (device_unit_free_for_vs(This, pshader_sampler_type, vshader_sampler_type, start))
3423 device_map_stage(This, vsampler_idx, start);
3424 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(vsampler_idx));
3436 void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
3438 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
3439 BOOL vs = use_vs(This->stateBlock);
3440 BOOL ps = use_ps(This->stateBlock);
3448 if (ps) device_map_psamplers(This, gl_info);
3449 else device_map_fixed_function_samplers(This, gl_info);
3451 if (vs) device_map_vsamplers(This, ps, gl_info);
3455 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3456 IWineD3DPixelShader *oldShader = This->updateStateBlock->pixelShader;
3457 This->updateStateBlock->pixelShader = pShader;
3458 This->updateStateBlock->changed.pixelShader = TRUE;
3461 if (This->isRecordingState) {
3465 if (This->isRecordingState) {
3480 TRACE("(%p) : setting pShader(%p)\n", This, pShader);
3481 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
3487 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3490 WARN("(%p) : PShader is NULL, returning INVALIDCALL\n", This);
3494 *ppShader = This->stateBlock->pixelShader;
3498 TRACE("(%p) : returning %p\n", This, *ppShader);
3508 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3520 memcpy(&This->updateStateBlock->pixelShaderConstantB[start], srcData, cnt * sizeof(BOOL));
3525 This->updateStateBlock->changed.pixelShaderConstantsB |= (1 << i);
3528 if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
3539 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3551 memcpy(dstData, &This->stateBlock->pixelShaderConstantB[start], cnt * sizeof(BOOL));
3561 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3573 memcpy(&This->updateStateBlock->pixelShaderConstantI[start * 4], srcData, cnt * sizeof(int) * 4);
3579 This->updateStateBlock->changed.pixelShaderConstantsI |= (1 << i);
3582 if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
3593 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3605 memcpy(dstData, &This->stateBlock->pixelShaderConstantI[start * 4], cnt * sizeof(int) * 4);
3615 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3622 if (srcData == NULL || start + count > This->d3d_pshader_constantF || start > This->d3d_pshader_constantF)
3628 memcpy(&This->updateStateBlock->pixelShaderConstantF[start * 4], srcData, count * sizeof(float) * 4);
3635 if (!This->isRecordingState)
3637 This->shader_backend->shader_update_float_pixel_constants(iface, start, count);
3638 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
3641 memset(This->updateStateBlock->changed.pixelShaderConstantsF + start, 1,
3642 sizeof(*This->updateStateBlock->changed.pixelShaderConstantsF) * count);
3653 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
3654 int cnt = min(count, This->d3d_pshader_constantF - start);
3665 memcpy(dstData, &This->stateBlock->pixelShaderConstantF[start * 4], cnt * sizeof(float) * 4);
3671 static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount,
3675 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
3730 if(This->stateBlock->renderState[WINED3DRS_CLIPPING]) {
3748 IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
3751 IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
3754 IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
3777 IWineD3DDevice_GetViewport( (IWineD3DDevice *) This, &vp);
4020 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4023 BOOL vbo = FALSE, streamWasUP = This->stateBlock->streamIsUP;
4026 TRACE("(%p)->(%d,%d,%d,%p,%p,%d\n", This, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
4033 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
4038 This->stateBlock->streamIsUP = FALSE;
4039 device_stream_info_from_declaration(This, FALSE, &stream_info, &vbo);
4040 This->stateBlock->streamIsUP = streamWasUP;
4058 struct wined3d_buffer *vb = (struct wined3d_buffer *)This->stateBlock->streamSource[e->stream_idx];
4070 hr = process_vertices_strided(This, DestIndex, VertexCount, &stream_info,
4083 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4084 DWORD oldValue = This->updateStateBlock->textureState[Stage][Type];
4085 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
4087 TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
4096 This->updateStateBlock->changed.textureState[Stage] |= 1 << Type;
4097 This->updateStateBlock->textureState[Stage][Type] = Value;
4099 if (This->isRecordingState) {
4110 if(Stage > This->stateBlock->lowest_disabled_stage &&
4111 This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative == STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) {
4127 for(i = Stage + 1; i < This->stateBlock->lowest_disabled_stage; i++) {
4129 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
4131 This->stateBlock->lowest_disabled_stage = Stage;
4141 for (i = Stage + 1; i < This->adapter->gl_info.limits.texture_stages; ++i)
4143 if(This->updateStateBlock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) {
4147 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
4149 This->stateBlock->lowest_disabled_stage = i;
4154 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(Stage, Type));
4160 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4161 TRACE("(%p) : requesting Stage %d, Type %d getting %d\n", This, Stage, Type, This->updateStateBlock->textureState[Stage][Type]);
4162 *pValue = This->updateStateBlock->textureState[Stage][Type];
4172 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4173 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
4182 if (stage >= sizeof(This->stateBlock->textures) / sizeof(*This->stateBlock->textures))
4199 This->updateStateBlock->changed.textures |= 1 << stage;
4201 prev = This->updateStateBlock->textures[stage];
4211 This->updateStateBlock->textures[stage] = texture;
4213 if (This->isRecordingState)
4233 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
4241 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
4242 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
4257 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
4258 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
4270 if (This->updateStateBlock->textures[i] == prev)
4280 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(stage));
4286 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4288 TRACE("(%p) : Stage %#x, ppTexture %p\n", This, Stage, ppTexture);
4294 if (Stage >= sizeof(This->stateBlock->textures)/sizeof(This->stateBlock->textures[0])) {
4299 *ppTexture=This->stateBlock->textures[Stage];
4303 TRACE("(%p) : Returning %p\n", This, *ppTexture);
4339 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4340 WARN("(%p) : stub, calling idirect3d for now\n", This);
4341 return IWineD3D_GetDeviceCaps(This->wined3d, This->adapter->ordinal, This->devType, pCaps);
4345 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4355 FIXME("(%p) Error getting display mode\n", This);
4365 pMode->Width = This->ddraw_width;
4366 pMode->Height = This->ddraw_height;
4367 pMode->Format = This->ddraw_format;
4380 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4384 TRACE("(%p)\n", This);
4386 if (This->isRecordingState) return WINED3DERR_INVALIDCALL;
4391 IWineD3DStateBlock_Release((IWineD3DStateBlock*)This->updateStateBlock);
4392 This->updateStateBlock = (IWineD3DStateBlockImpl *)stateblock;
4393 This->isRecordingState = TRUE;
4395 TRACE("(%p) recording stateblock %p\n", This, stateblock);
4401 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4402 IWineD3DStateBlockImpl *object = This->updateStateBlock;
4404 if (!This->isRecordingState) {
4405 WARN("(%p) not recording! returning error\n", This);
4413 This->isRecordingState = FALSE;
4414 This->updateStateBlock = This->stateBlock;
4415 IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
4417 TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, *ppStateBlock);
4427 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4428 TRACE("(%p)\n", This);
4430 if(This->inScene) {
4434 This->inScene = TRUE;
4440 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4443 TRACE("(%p)\n", This);
4445 if(!This->inScene) {
4450 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
4457 This->inScene = FALSE;
4507 HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
4510 IWineD3DStateBlockImpl *stateblock = This->stateBlock;
4519 IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget;
4537 context = context_acquire(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR);
4578 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE));
4581 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
4591 surface_load_ds_location(This->stencilBufferTarget, context, location);
4594 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZWRITEENABLE));
4603 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
4604 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1));
4605 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2));
4606 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
4617 if(This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
4618 IntersectRect(&vp_rect, &vp_rect, &This->stateBlock->scissorRect);
4636 if(This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
4637 IntersectRect((RECT *) &curRect, (RECT *) &curRect, &This->stateBlock->scissorRect);
4639 TRACE("(%p) Rect=(%d,%d)->(%d,%d) glRect=(%d,%d), len=%d, hei=%d\n", This,
4675 surface_modify_ds_location(This->stencilBufferTarget, location);
4691 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4692 IWineD3DSurfaceImpl *target = (IWineD3DSurfaceImpl *)This->render_targets[0];
4694 TRACE("(%p) Count (%d), pRects (%p), Flags (%x), Color (0x%08x), Z (%f), Stencil (%d)\n", This,
4697 if(Flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL) && This->stencilBufferTarget == NULL) {
4703 return IWineD3DDeviceImpl_ClearSurface(This, target, Count, pRects, Flags, Color, Z, Stencil);
4713 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4717 This->updateStateBlock->changed.primitive_type = TRUE;
4718 This->updateStateBlock->gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
4724 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4728 *primitive_type = d3d_primitive_type_from_gl(This->stateBlock->gl_primitive_type);
4735 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4737 TRACE("(%p) : start %u, count %u\n", This, StartVertex, vertex_count);
4739 if(!This->stateBlock->vertexDecl) {
4740 WARN("(%p) : Called without a valid vertex declaration set\n", This);
4745 if(This->stateBlock->streamIsUP) {
4746 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
4747 This->stateBlock->streamIsUP = FALSE;
4750 if(This->stateBlock->loadBaseVertexIndex != 0) {
4751 This->stateBlock->loadBaseVertexIndex = 0;
4752 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
4761 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4766 pIB = This->stateBlock->pIndexData;
4772 WARN("(%p) : Called without a valid index buffer set, returning WINED3DERR_INVALIDCALL\n", This);
4776 if(!This->stateBlock->vertexDecl) {
4777 WARN("(%p) : Called without a valid vertex declaration set\n", This);
4781 if(This->stateBlock->streamIsUP) {
4782 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
4783 This->stateBlock->streamIsUP = FALSE;
4787 TRACE("(%p) : startIndex %u, index count %u.\n", This, startIndex, index_count);
4789 if (This->stateBlock->IndexFmt == WINED3DFMT_R16_UINT) {
4795 if(This->stateBlock->loadBaseVertexIndex != This->stateBlock->baseVertexIndex) {
4796 This->stateBlock->loadBaseVertexIndex = This->stateBlock->baseVertexIndex;
4797 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
4809 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4813 This, vertex_count, pVertexStreamZeroData, VertexStreamZeroStride);
4815 if(!This->stateBlock->vertexDecl) {
4816 WARN("(%p) : Called without a valid vertex declaration set\n", This);
4821 vb = This->stateBlock->streamSource[0];
4822 This->stateBlock->streamSource[0] = (IWineD3DBuffer *)pVertexStreamZeroData;
4824 This->stateBlock->streamOffset[0] = 0;
4825 This->stateBlock->streamStride[0] = VertexStreamZeroStride;
4826 This->stateBlock->streamIsUP = TRUE;
4827 This->stateBlock->loadBaseVertexIndex = 0;
4830 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
4835 This->stateBlock->streamStride[0] = 0;
4836 This->stateBlock->streamSource[0] = NULL;
4849 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
4854 This, index_count, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
4856 if(!This->stateBlock->vertexDecl) {
4857 WARN("(%p) : Called without a valid vertex declaration set\n", This);
4868 vb = This->stateBlock->streamSource[0];
4869 This->stateBlock->streamSource[0] = (IWineD3DBuffer *)pVertexStreamZeroData;
4871 This->stateBlock->streamIsUP = TRUE;
4872 This->stateBlock->streamOffset[0] = 0;
4873 This->stateBlock->streamStride[0] = VertexStreamZeroStride;
4876 This->stateBlock->baseVertexIndex = 0;
4877 This->stateBlock->loadBaseVertexIndex = 0;
4879 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
4880 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
4885 This->stateBlock->streamSource[0] = NULL;
4886 This->stateBlock->streamStride[0] = 0;
4887 ib = This->stateBlock->pIndexData;
4890 This->stateBlock->pIndexData = NULL;
4902 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
4908 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
4909 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
4910 This->stateBlock->baseVertexIndex = 0;
4911 This->up_strided = DrawPrimStrideData;
4913 This->up_strided = NULL;
4921 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
4928 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
4929 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
4930 This->stateBlock->streamIsUP = TRUE;
4931 This->stateBlock->baseVertexIndex = 0;
4932 This->up_strided = DrawPrimStrideData;
4934 This->up_strided = NULL;
4938 /* This is a helper function for UpdateTexture, there is no UpdateVolume method in D3D. */
5260 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5264 TRACE("(%p) : %p\n", This, pNumPasses);
5267 if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE) {
5271 if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE) {
5276 texture = (IWineD3DBaseTextureImpl *) This->stateBlock->textures[i];
5279 if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT) {
5283 if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT) {
5287 if(This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE &&
5288 This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT /* sic! */) {
5317 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5322 TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
5325 ERR("(%p) : (%u) Out of range 0-%u, returning Invalid Call\n", This, PaletteNumber, MAX_PALETTES);
5329 if (PaletteNumber >= This->NumberOfPalettes) {
5330 NewSize = This->NumberOfPalettes;
5334 palettes = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->palettes, sizeof(PALETTEENTRY*) * NewSize);
5339 This->palettes = palettes;
5340 This->NumberOfPalettes = NewSize;
5343 if (!This->palettes[PaletteNumber]) {
5344 This->palettes[PaletteNumber] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
5345 if (!This->palettes[PaletteNumber]) {
5352 This->palettes[PaletteNumber][j].peRed = pEntries[j].peRed;
5353 This->palettes[PaletteNumber][j].peGreen = pEntries[j].peGreen;
5354 This->palettes[PaletteNumber][j].peBlue = pEntries[j].peBlue;
5355 This->palettes[PaletteNumber][j].peFlags = pEntries[j].peFlags;
5357 if (PaletteNumber == This->currentPalette) dirtify_p8_texture_samplers(This);
5358 TRACE("(%p) : returning\n", This);
5363 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5365 TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
5366 if (PaletteNumber >= This->NumberOfPalettes || !This->palettes[PaletteNumber]) {
5369 ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
5373 pEntries[j].peRed = This->palettes[PaletteNumber][j].peRed;
5374 pEntries[j].peGreen = This->palettes[PaletteNumber][j].peGreen;
5375 pEntries[j].peBlue = This->palettes[PaletteNumber][j].peBlue;
5376 pEntries[j].peFlags = This->palettes[PaletteNumber][j].peFlags;
5378 TRACE("(%p) : returning\n", This);
5383 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5384 TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
5387 if (PaletteNumber >= This->NumberOfPalettes || !This->palettes[PaletteNumber]) {
5388 ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
5392 if (This->currentPalette != PaletteNumber) {
5393 This->currentPalette = PaletteNumber;
5394 dirtify_p8_texture_samplers(This);
5396 TRACE("(%p) : returning\n", This);
5401 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5403 WARN("(%p) : returning Invalid Call\n", This);
5407 *PaletteNumber = This->currentPalette;
5408 TRACE("(%p) : returning %u\n", This, *PaletteNumber);
5413 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5417 FIXME("(%p) : stub\n", This);
5421 This->softwareVertexProcessing = bSoftware;
5427 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5431 FIXME("(%p) : stub\n", This);
5434 return This->softwareVertexProcessing;
5494 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5529 /* This call loads the OpenGL surface directly, instead of copying the
5537 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
5618 sampler = This->rev_tex_unit_map[0];
5621 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
5628 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5634 TRACE("(%p) Handle(%d) noSegs(%p) rectpatch(%p)\n", This, Handle, pNumSegs, pRectPatchInfo);
5645 LIST_FOR_EACH(e, &This->patches[i]) {
5657 list_add_head(&This->patches[i], &patch->entry);
5663 * attributes we have to tesselate, read back, and draw. This needs a patch
5669 FIXME("Drawing an uncached patch. This is slow\n");
5687 hr = tesselate_rectpatch(This, patch);
5699 This->currentPatch = patch;
5700 old_primitive_type = This->stateBlock->gl_primitive_type;
5701 This->stateBlock->gl_primitive_type = GL_TRIANGLES;
5703 This->stateBlock->gl_primitive_type = old_primitive_type;
5704 This->currentPatch = NULL;
5724 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5728 TRACE("(%p) Handle(%d)\n", This, Handle);
5731 LIST_FOR_EACH(e, &This->patches[i]) {
5750 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
5760 context = context_acquire(This, surface, CTXUSAGE_RESOURCELOAD);
5769 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
5785 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT);
5789 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
5792 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE));
5795 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
5796 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1));
5797 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2));
5798 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
5893 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
5895 if (RenderTargetIndex >= This->adapter->gl_info.limits.buffers)
5898 This, This->adapter->gl_info.limits.buffers);
5902 *ppRenderTarget = This->render_targets[RenderTargetIndex];
5903 TRACE("(%p) : RenderTarget %d Index returning %p\n", This, RenderTargetIndex, *ppRenderTarget);
6006 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
6007 *ppZStencilSurface = This->stencilBufferTarget;
6008 TRACE("(%p) : zStencilSurface returning %p\n", This, *ppZStencilSurface);
6022 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
6033 This, src_surface, src_rect_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter);
6059 if (!surface_is_offscreen(src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
6060 else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
6061 else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
6165 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
6182 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
6184 TRACE("(%p) : Setting rendertarget %d to %p\n", This, RenderTargetIndex, pRenderTarget);
6186 if (RenderTargetIndex >= This->adapter->gl_info.limits.buffers)
6189 This, RenderTargetIndex, This->adapter->gl_info.limits.buffers);
6202 FIXME("(%p)Trying to set the render target to a surface(%p) that wasn't created with a usage of WINED3DUSAGE_RENDERTARGET\n",This ,pRenderTarget);
6207 if (pRenderTarget == This->render_targets[RenderTargetIndex]) {
6212 if(This->render_targets[RenderTargetIndex]) IWineD3DSurface_Release(This->render_targets[RenderTargetIndex]);
6213 This->render_targets[RenderTargetIndex] = pRenderTarget;
6221 This->stateBlock->viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height;
6222 This->stateBlock->viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width;
6223 This->stateBlock->viewport.X = 0;
6224 This->stateBlock->viewport.Y = 0;
6225 This->stateBlock->viewport.MaxZ = 1.0f;
6226 This->stateBlock->viewport.MinZ = 0.0f;
6227 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
6229 This->stateBlock->scissorRect.top = 0;
6230 This->stateBlock->scissorRect.left = 0;
6231 This->stateBlock->scissorRect.right = This->stateBlock->viewport.Width;
6232 This->stateBlock->scissorRect.bottom = This->stateBlock->viewport.Height;
6233 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT);
6239 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
6243 TRACE("(%p) Swapping z-buffer. Old = %p, new = %p\n",This, This->stencilBufferTarget, pNewZStencil);
6245 if (pNewZStencil == This->stencilBufferTarget) {
6255 if (This->stencilBufferTarget) {
6256 if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
6257 || ((IWineD3DSurfaceImpl *)This->stencilBufferTarget)->Flags & SFLAG_DISCARD) {
6258 surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_DISCARDED);
6260 struct wined3d_context *context = context_acquire(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD);
6261 surface_load_ds_location(This->stencilBufferTarget, context, SFLAG_DS_OFFSCREEN);
6262 surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN);
6267 tmp = This->stencilBufferTarget;
6268 This->stencilBufferTarget = pNewZStencil;
6270 if (NULL != This->stencilBufferTarget) IWineD3DSurface_AddRef(This->stencilBufferTarget);
6276 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZENABLE));
6277 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILENABLE));
6278 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
6287 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6292 TRACE("(%p) : Spot Pos(%u,%u)\n", This, XHotSpot, YHotSpot);
6295 if(This->cursorTexture) {
6296 struct wined3d_context *context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
6298 glDeleteTextures(1, &This->cursorTexture);
6301 This->cursorTexture = 0;
6305 This->haveHardwareCursor = TRUE;
6307 This->haveHardwareCursor = FALSE;
6315 ERR("(%p) : surface(%p) has an invalid format\n", This, pCursorBitmap);
6320 if(pSur->currentDesc.Width > This->ddraw_width ||
6321 pSur->currentDesc.Height > This->ddraw_height) {
6322 ERR("(%p) : Surface(%p) is %dx%d pixels, but screen res is %dx%d\n", This, pSur, pSur->currentDesc.Width, pSur->currentDesc.Height, This->ddraw_width, This->ddraw_height);
6326 if (!This->haveHardwareCursor) {
6335 This->cursorWidth = pSur->currentDesc.Width;
6336 This->cursorHeight = pSur->currentDesc.Height;
6339 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
6346 INT height = This->cursorHeight;
6347 INT width = This->cursorWidth;
6359 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
6372 sampler = This->rev_tex_unit_map[0];
6375 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
6378 glGenTextures(1, &This->cursorTexture);
6380 glBindTexture(GL_TEXTURE_2D, This->cursorTexture);
6400 This->cursorTexture = 0;
6433 if (This->hardwareCursor) DestroyCursor(This->hardwareCursor);
6434 This->hardwareCursor = cursor;
6439 This->xHotSpot = XHotSpot;
6440 This->yHotSpot = YHotSpot;
6445 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6446 TRACE("(%p) : SetPos to (%u,%u)\n", This, XScreenSpace, YScreenSpace);
6448 This->xScreenSpace = XScreenSpace;
6449 This->yScreenSpace = YScreenSpace;
6456 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6457 BOOL oldVisible = This->bCursorVisible;
6460 TRACE("(%p) : visible(%d)\n", This, bShow);
6465 * ShowCursor in order to update the cursor's position. This behavior is undocumented.
6468 This->xScreenSpace = pt.x;
6469 This->yScreenSpace = pt.y;
6471 if (This->haveHardwareCursor) {
6472 This->bCursorVisible = bShow;
6474 SetCursor(This->hardwareCursor);
6480 if (This->cursorTexture)
6481 This->bCursorVisible = bShow;
6536 IWineD3DDeviceImpl *This = device; /* <- to make the below texture_gl_delete macro work and avoid other modifications */
6572 static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRESENT_PARAMETERS *pp)
6583 count = IWineD3D_GetAdapterModeCount(This->wined3d, This->adapter->ordinal, WINED3DFMT_UNKNOWN);
6586 hr = IWineD3D_EnumAdapterModes(This->wined3d, This->adapter->ordinal, WINED3DFMT_UNKNOWN, i, &m);
6605 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6610 context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
6614 LIST_FOR_EACH_ENTRY(shader, &This->shaders, IWineD3DBaseShaderImpl, baseShader.shader_list_entry) {
6615 This->shader_backend->shader_destroy((IWineD3DBaseShader *) shader);
6619 if(This->depth_blt_texture) {
6620 glDeleteTextures(1, &This->depth_blt_texture);
6621 This->depth_blt_texture = 0;
6623 if (This->depth_blt_rb) {
6624 gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
6625 This->depth_blt_rb = 0;
6626 This->depth_blt_rb_w = 0;
6627 This->depth_blt_rb_h = 0;
6631 This->blitter->free_private(iface);
6632 This->frag_pipe->free_private(iface);
6633 This->shader_backend->shader_free_private(iface);
6634 destroy_dummy_textures(This, gl_info);
6638 while (This->numContexts)
6640 context_destroy(This, This->contexts[0]);
6651 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6673 , This->pHgsmi
6688 create_dummy_textures(This);
6691 hr = This->shader_backend->shader_alloc_private(iface);
6698 hr = This->frag_pipe->alloc_private(iface);
6702 This->shader_backend->shader_free_private(iface);
6706 hr = This->blitter->alloc_private(iface);
6710 This->frag_pipe->free_private(iface);
6711 This->shader_backend->shader_free_private(iface);
6718 context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
6719 destroy_dummy_textures(This, context->gl_info);
6721 context_destroy(This, context);
6730 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6735 TRACE("(%p)\n", This);
6748 if(!is_display_mode_supported(This, pPresentationParameters)) {
6797 if (pPresentationParameters->EnableAutoDepthStencil && !This->auto_depth_stencil_buffer) {
6802 hrc = IWineD3DDeviceParent_CreateDepthStencilSurface(This->device_parent,
6803 This->parent,
6810 &This->auto_depth_stencil_buffer);
6821 IWineD3DDevice_SetDepthStencilSurface(iface, This->auto_depth_stencil_buffer);
6826 IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock);
6827 IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
6875 if(This->auto_depth_stencil_buffer) {
6876 hr = updateSurfaceDesc((IWineD3DSurfaceImpl *)This->auto_depth_stencil_buffer, pPresentationParameters);
6914 DWORD style = This->style, exStyle = This->exStyle;
6919 This->style = 0;
6920 This->exStyle = 0;
6923 This->style = style;
6924 This->exStyle = exStyle;
6928 hr = IWineD3DDevice_CreateStateBlock(iface, WINED3DSBT_INIT, (IWineD3DStateBlock **)&This->stateBlock, NULL);
6930 else TRACE("Created stateblock %p\n", This->stateBlock);
6931 This->updateStateBlock = This->stateBlock;
6932 IWineD3DStateBlock_AddRef((IWineD3DStateBlock *)This->updateStateBlock);
6934 hr = IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *) This->stateBlock);
6989 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
6990 TRACE("(%p) : pParameters %p\n", This, pParameters);
6992 *pParameters = This->createParms;
7022 /** This function must be called in the release of a resource when ref == 0,
7027 void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource)
7029 TRACE("(%p) : Adding resource %p\n", This, resource);
7031 list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
7034 static void device_resource_remove(IWineD3DDeviceImpl *This, IWineD3DResource *resource)
7036 TRACE("(%p) : Removing resource %p\n", This, resource);
7041 void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource)
7046 TRACE("(%p) : resource %p\n", This, resource);
7048 context_resource_released((IWineD3DDevice *)This, resource, type);
7055 if (This->d3d_initialized)
7057 for (i = 0; i < This->adapter->gl_info.limits.buffers; ++i)
7059 if (This->render_targets[i] == (IWineD3DSurface *)resource) {
7060 This->render_targets[i] = NULL;
7063 if (This->stencilBufferTarget == (IWineD3DSurface *)resource) {
7064 This->stencilBufferTarget = NULL;
7074 if (This->stateBlock != NULL && This->stateBlock->textures[counter] == (IWineD3DBaseTexture *)resource) {
7076 This->stateBlock->textures[counter] = NULL;
7078 if (This->updateStateBlock != This->stateBlock ){
7079 if (This->updateStateBlock->textures[counter] == (IWineD3DBaseTexture *)resource) {
7081 This->updateStateBlock->textures[counter] = NULL;
7098 if (This->updateStateBlock != NULL ) { /* ==NULL when device is being destroyed */
7099 if ((IWineD3DResource *)This->updateStateBlock->streamSource[streamNumber] == resource) {
7101 This->updateStateBlock->streamSource[streamNumber] = 0;
7105 if (This->stateBlock != NULL ) { /* only happens if there is an error in the application, or on reset/release (because we don't manage internal tracking properly) */
7106 if ((IWineD3DResource *)This->stateBlock->streamSource[streamNumber] == resource) {
7108 This->stateBlock->streamSource[streamNumber] = 0;
7113 if (This->updateStateBlock != NULL ) { /* ==NULL when device is being destroyed */
7114 if (This->updateStateBlock->pIndexData == (IWineD3DBuffer *)resource) {
7115 This->updateStateBlock->pIndexData = NULL;
7118 if (This->stateBlock != NULL ) { /* ==NULL when device is being destroyed */
7119 if (This->stateBlock->pIndexData == (IWineD3DBuffer *)resource) {
7120 This->stateBlock->pIndexData = NULL;
7127 FIXME("(%p) unknown resource type %p %u\n", This, resource, IWineD3DResource_GetType(resource));
7133 device_resource_remove(This, resource);
7140 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7143 TRACE("(%p)->(%p,%p)\n", This, pCallback, pData);
7145 LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
7159 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7162 LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
7181 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7182 VOID *pvNewBuf = HeapReAlloc(GetProcessHeap(), 0, This->swapchains, (This->NumberOfSwapChains + 1) * sizeof(IWineD3DSwapChain *));
7187 This->swapchains = (IWineD3DSwapChain **)pvNewBuf;
7188 This->swapchains[This->NumberOfSwapChains] = swapchain;
7189 ++This->NumberOfSwapChains;
7195 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7197 IWineD3DSwapChain **pvOldBuf = This->swapchains;
7199 for (i = 0; i < This->NumberOfSwapChains; ++i)
7201 if (This->swapchains[i] == swapchain)
7207 if (i == This->NumberOfSwapChains)
7213 --This->NumberOfSwapChains;
7214 if (This->NumberOfSwapChains)
7216 IWineD3DSwapChain **pvNewBuf = (IWineD3DSwapChain **)HeapAlloc(GetProcessHeap(), 0, (This->NumberOfSwapChains) * sizeof(IWineD3DSwapChain *));
7222 memcpy (pvNewBuf, This->swapchains, i*sizeof(IWineD3DSwapChain *));
7224 if (i < This->NumberOfSwapChains) {
7225 memcpy (pvNewBuf + i, This->swapchains +i+1, (This->NumberOfSwapChains - i)*sizeof(IWineD3DSwapChain *));
7228 This->swapchains = pvNewBuf;
7232 while (This->numContexts)
7234 context_destroy(This, This->contexts[0]);
7236 This->swapchains = NULL;
7248 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7253 for (i = 0; i < This->NumberOfSwapChains; ++i)
7255 IWineD3DSwapChain *pSwapchain = This->swapchains[i];
7259 for (i = 0; i < This->numContexts; ++i)
7261 context = This->contexts[i];
7278 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7283 for (i = 0; i < This->NumberOfSwapChains; ++i)
7285 IWineD3DSwapChain *pSwapchain = This->swapchains[i];
7289 for (i = 0; i < This->numContexts; ++i)
7291 context = This->contexts[i];
7308 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
7313 for (i = 0; i < This->numContexts; ++i)
7315 context = This->contexts[i];
7323 void device_cleanup_durtify_texture_target(IWineD3DDeviceImpl *This, GLuint texture_target)
7325 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
7340 glBindTexture(texture_target, This->dummyTextureName[i]);
7353 DWORD active_sampler = This->rev_tex_unit_map[i];
7357 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(active_sampler));
7554 device->posFixup[0] = 1.0f; /* This is needed to get the x coord unmodified through a MAD. */
7615 void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
7616 DWORD rep = This->StateTable[state].representative;
7622 for(i = 0; i < This->numContexts; i++) {
7623 context = This->contexts[i];