-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi again, This patch need the [D3D - 0] patch (see extensions below) and [D3D - 0] patch need this patch to compile Changelog: - compile fixes needed by [D3D - 0] patch - Resend of last Jason texture work - mipmapping - copyrect#1 - copyrect#2 - Resend of my last vertex shader patch + improvements - move input and output data in VertexShader struct - better traces - begin of more COM compliant behavior: - AddRef/Release where needed - use IUnknown* instead void* - fix many GetDevice using AddRef - fix IDirect3DSurface8Impl_GetContainer using QueryInterface - Jason begin mipmaping so declare it in caps - specific input data filling function for vertex shaders using vertex shader declaration (and not FVF ... maybe FVF will return for fast path with simples vertex shader declarations) - beginning of vertex matrix blending using extensions (currently alpha alpha stage as i haven't understand needed extension behavior) - modify SetRenderState for matrix blending specific params - many fixes in IDirect3DDevice8::SetTransform (Vertex matrix weighting, texure matrix) - using extension for specular color code (using jason commented code and new x11drv/GLX opengl info) - huge vertex shader fixes: - add and fix many vs (1.0->2.0) used opcodes in complex shaders - improvements to programs parser: parse comments, version, .. - add a vertex shader input filler function (parsing vertex shader declaration): almost complete - by default diffuse color is white ;) - comments most of the traces (else flood ...) - add more urls in comments - indent, cleanups Todo: - cleanup DrawPrimitiveI: - split to a new source (draw.c ?) - merge with ddraw code - begin simple abstraction layer - vertex shader : - struct must become a IVertexShader COM object (as in Dx9) and separe declarations from shaders (bind only by d3d8 array) - abstraction layer (easy specific hardware programs) - merge my DX8 vs -> NV program extension translator prototype - begin a DX8 vs -> ARB program extension translator - begin a DX8 vs -> ATI vs extension translator - merge my DX8 vs optimisator/execution prototype - begin vs3.0 support (after HAL) - code a HLCL compiler (anyone want to do this compiler ?) - Vertex shader declaration - struct must become a IVertexShaderDecl COM object (as Dx9) - declaration validation and optimizer - Dx8 -> Dx9 translator - Dx9 -> Dx8 translator - HAL: need a new lib (maybe libwined3dgl.so ?) who contains a basic openGL HAL for the d3d versions (with ddraw version ?) - !!!! merge Dx9 prototype : we need a new d3d core dll for d3d version up to 8 (the d3d8.dll and d3d9.dll will be only simili-stubs to the core lib) alexandre, i suggest one subdir in d3d8 dir for each d3d[8-9].dll and another dlls/d3d8 subdir for the core lib (dlls/d3d8/core/ ?) - D3DX8/D3DX9: too big todo list but D3DX9 support have the same need of Dx9 support Thanks Raphael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+H2UAp7NA3AmQTU4RAuopAJ9pRHgTvkslzMRn94Xk1xKTe64YFACeKCHz QSx5IbrImcH4CqOcJggY3Nc= =u/Zt -----END PGP SIGNATURE-----
Index: dlls/d3d8/basetexture.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/basetexture.c,v retrieving revision 1.2 diff -u -r1.2 basetexture.c --- dlls/d3d8/basetexture.c 17 Dec 2002 01:15:16 -0000 1.2 +++ dlls/d3d8/basetexture.c 10 Jan 2003 23:42:11 -0000 @@ -65,6 +65,11 @@ ICOM_THIS(IDirect3DBaseTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); *ppDevice = (LPDIRECT3DDEVICE8) This->Device; + /** + * Note Calling this method will increase the internal reference count + * on the IDirect3DDevice8 interface. + */ + IDirect3DDevice8Impl_AddRef(*ppDevice); return D3D_OK; } HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { Index: dlls/d3d8/cubetexture.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/cubetexture.c,v retrieving revision 1.2 diff -u -r1.2 cubetexture.c --- dlls/d3d8/cubetexture.c 17 Dec 2002 01:15:16 -0000 1.2 +++ dlls/d3d8/cubetexture.c 10 Jan 2003 23:42:20 -0000 @@ -75,6 +75,11 @@ ICOM_THIS(IDirect3DCubeTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); *ppDevice = (LPDIRECT3DDEVICE8) This->Device; + /** + * Note Calling this method will increase the internal reference count + * on the IDirect3DDevice8 interface. + */ + IDirect3DDevice8Impl_AddRef(*ppDevice); return D3D_OK; } HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { Index: dlls/d3d8/d3d8_main.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/d3d8_main.c,v retrieving revision 1.6 diff -u -r1.6 d3d8_main.c --- dlls/d3d8/d3d8_main.c 17 Dec 2002 01:15:16 -0000 1.6 +++ dlls/d3d8/d3d8_main.c 10 Jan 2003 23:43:19 -0000 @@ -22,6 +22,9 @@ #include "winuser.h" #include "wine/debug.h" +#include "config.h" +#include "x11drv.h" + #include "d3d8.h" #include "d3d8_private.h" @@ -39,16 +42,31 @@ HRESULT WINAPI DebugSetMute(void) { FIXME("(void): stub\n"); - return 0; + return S_OK; +} + +inline static X11DRV_OPENGL_INFO* get_opengl_info( HDC hdc, X11DRV_OPENGL_INFO* info ) +{ + enum x11drv_escape_codes escape = X11DRV_GET_OPENGL_INFO; + + if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, sizeof(X11DRV_OPENGL_INFO), (LPSTR)info )) { + ERR("ExtEscape pb!\n"); + } + return info; } IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) { + HDC hDC; IDirect3D8Impl *object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl)); object->lpVtbl = &Direct3D8_Vtbl; object->ref = 1; + + hDC = CreateDCA("DISPLAY", NULL, NULL, NULL); + get_opengl_info(hDC, &object->glInfo); + DeleteDC(hDC); TRACE("SDKVersion = %x, Created Direct3D object at %p\n", SDKVersion, object); Index: dlls/d3d8/d3d8_private.h =================================================================== RCS file: /home/wine/wine/dlls/d3d8/d3d8_private.h,v retrieving revision 1.10 diff -u -r1.10 d3d8_private.h --- dlls/d3d8/d3d8_private.h 2 Jan 2003 17:59:02 -0000 1.10 +++ dlls/d3d8/d3d8_private.h 10 Jan 2003 23:43:28 -0000 @@ -42,6 +42,8 @@ /* X11 locking */ +#include "x11drv.h" + extern void (*wine_tsx11_lock_ptr)(void); extern void (*wine_tsx11_unlock_ptr)(void); @@ -147,9 +149,12 @@ /* Vertex Shader */ DWORD VertexShader; - /* TODO: Vertex Shader Constant */ + /* Indexed Vertex Blending */ + D3DVERTEXBLENDFLAGS vertex_blend; + FLOAT tween_factor; + } STATEBLOCK; typedef struct D3DSHADERVECTOR { @@ -176,6 +181,20 @@ UINT codeLength; } SHADERDATA8; +/** temporary here waiting for buffer code */ +typedef struct VSHADERINPUTDATA8 { + D3DSHADERVECTOR V[16]; +} VSHADERINPUTDATA8; + +/** temporary here waiting for buffer code */ +typedef struct VSHADEROUTPUTDATA8 { + D3DSHADERVECTOR oPos; + D3DSHADERVECTOR oD[2]; + D3DSHADERVECTOR oT[4]; + D3DSHADERVECTOR oFog; + D3DSHADERVECTOR oPts; +} VSHADEROUTPUTDATA8; + typedef struct VERTEXSHADER8 { /* TODO: Vertex Shader */ DWORD* decl; DWORD* function; @@ -186,6 +205,8 @@ DWORD version; /* run time datas */ SHADERDATA8* data; + VSHADERINPUTDATA8 input; + VSHADEROUTPUTDATA8 output; } VERTEXSHADER8; typedef struct PIXELSHADER8 { /* TODO: Pixel Shader */ @@ -196,20 +217,6 @@ SHADERDATA8* data; } PIXELSHADER8; -/** temporary here waiting for buffer code */ -typedef struct VSHADERINPUTDATA8 { - D3DSHADERVECTOR V[16]; -} VSHADERINPUTDATA8; - -/** temporary here waiting for buffer code */ -typedef struct VSHADEROUTPUTDATA8 { - D3DSHADERVECTOR oPos; - D3DSHADERVECTOR oD[2]; - D3DSHADERVECTOR oT[4]; - D3DSHADERVECTOR oFog; - D3DSHADERVECTOR oPts; -} VSHADEROUTPUTDATA8; - /* * External prototypes */ @@ -229,6 +236,28 @@ } \ } +#define checkGLSupport(ExtName) (TRUE == This->direct3d8->glInfo.supported[ExtName]) +#define GLExtCall(FuncName) (This->direct3d8->glInfo.FuncName) + + +#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f) +#define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f) +#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f) +#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f) + +#define D3DCOLORTOCOLORVALUE(dw, col) \ + (col).r = D3DCOLOR_R(dw); \ + (col).g = D3DCOLOR_G(dw); \ + (col).b = D3DCOLOR_B(dw); \ + (col).a = D3DCOLOR_A(dw); + +#define D3DCOLORTOVECTOR4(dw, vec) \ + (vec).x = D3DCOLOR_R(dw); \ + (vec).y = D3DCOLOR_G(dw); \ + (vec).z = D3DCOLOR_B(dw); \ + (vec).w = D3DCOLOR_A(dw); + + /* =========================================================================== The interfactes themselves =========================================================================== */ @@ -252,7 +281,11 @@ ICOM_VFIELD(IDirect3D8); DWORD ref; - /* IDirect3D8 fields */ + /* IDirect3D8 fields */ + + /* OpenGL related */ + /* http://developer.nvidia.com/view.asp?IO=nvidia_opengl_specs */ + X11DRV_OPENGL_INFO glInfo; }; /* IUnknown: */ @@ -270,11 +303,11 @@ extern HRESULT WINAPI IDirect3D8Impl_CheckDeviceType(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed); extern HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, - DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); + DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); extern HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, - BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType); + BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType); extern HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, - D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); + D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); extern HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps); extern HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter); extern HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, @@ -530,7 +563,7 @@ IDirect3DDevice8Impl *Device; D3DRESOURCETYPE ResourceType; - void *Container; + IUnknown *Container; D3DSURFACE_DESC myDesc; BYTE *allocatedMemory; @@ -929,5 +962,6 @@ DWORD vshader_decl_parse(VERTEXSHADER8* vshader); DWORD vshader_program_parse(VERTEXSHADER8* vshader); BOOL vshader_program_execute_SW(VERTEXSHADER8* vshader, VSHADERINPUTDATA8* input, VSHADEROUTPUTDATA8* output); +VOID vshader_fill_input(VERTEXSHADER8* vshader, IDirect3DDevice8Impl* device, const void* vertexFirstStream, DWORD StartVertexIndex, DWORD idxDecal); #endif /* __WINE_D3DX8_PRIVATE_H */ Index: dlls/d3d8/d3d8.spec =================================================================== RCS file: /home/wine/wine/dlls/d3d8/d3d8.spec,v retrieving revision 1.4 diff -u -r1.4 d3d8.spec --- dlls/d3d8/d3d8.spec 2 Jan 2003 17:59:02 -0000 1.4 +++ dlls/d3d8/d3d8.spec 10 Jan 2003 23:43:28 -0000 @@ -1,5 +1,5 @@ @ stdcall D3D8GetSWInfo() D3D8GetSWInfo @ stdcall DebugSetMute(long) DebugSetMute @ stdcall Direct3DCreate8(long) Direct3DCreate8 -@ stdcall ValidatePixelShader(ptr ptr) ValidatePixelShader +@ stdcall ValidatePixelShader(ptr) ValidatePixelShader @ stdcall ValidateVertexShader(ptr ptr) ValidateVertexShader Index: dlls/d3d8/device.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/device.c,v retrieving revision 1.23 diff -u -r1.23 device.c --- dlls/d3d8/device.c 9 Jan 2003 06:02:39 -0000 1.23 +++ dlls/d3d8/device.c 10 Jan 2003 23:43:33 -0000 @@ -28,6 +28,7 @@ #include "wingdi.h" #include "wine/debug.h" +#include "config.h" #include "d3d8_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); @@ -36,9 +37,9 @@ /* Per-vertex trace: */ #if 0 - #define VTRACE(A) TRACE A +# define VTRACE(A) TRACE A #else - #define VTRACE(A) +# define VTRACE(A) #endif @@ -106,7 +107,6 @@ int NumVertexes = NumPrimitives; VERTEXSHADER8* vertex_shader = NULL; - VSHADERINPUTDATA8 vertex_shader_input; BOOL useVertexShaderFunction = FALSE; ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -127,7 +127,7 @@ } fvf = (D3DFORMAT) vertex_shader->fvf; TRACE("vertex shader declared FVF: %lx\n", vertex_shader->fvf); - memset(&vertex_shader_input, 0, sizeof(VSHADERINPUTDATA8)); + memset(&vertex_shader->input, 0, sizeof(VSHADERINPUTDATA8)); } { @@ -150,12 +150,16 @@ BOOL enableTexture = FALSE; int vx_index; - float x=0.0, y=0.0, z=0.0; /* x,y,z coordinates */ - float nx=0.0, ny=0.0, nz=0.0; /* normal x,y,z coordinates */ - float rhw=0.0; /* rhw */ - float ptSize=0.0; /* Point size */ - DWORD diffuseColor=0; /* Diffusre Color */ - DWORD specularColor=0; /* Specular Color */ + float x = 0.0f, + y = 0.0f, + z = 0.0f; /* x,y,z coordinates */ + float nx = 0.0f, + ny =0.0, + nz = 0.0f; /* normal x,y,z coordinates */ + float rhw = 0.0f; /* rhw */ + float ptSize = 0.0f; /* Point size */ + DWORD diffuseColor = 0xFFFFFFFF; /* Diffusre Color */ + DWORD specularColor = 0; /* Specular Color */ ENTER_GL(); @@ -165,10 +169,14 @@ } /* Check vertex formats expected ? */ + /* * + * FVF parser as seen it + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/Graphics/Reference/CPP/D3D/FlexibleVertexFormatFlags.asp + */ normal = fvf & D3DFVF_NORMAL; isRHW = fvf & D3DFVF_XYZRHW; - numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2; /* WARNING can be < 0 because -2 */ isLastUByte4 = fvf & D3DFVF_LASTBETA_UBYTE4; + numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2 + ((FALSE == isLastUByte4) ? 0 : -1); /* WARNING can be < 0 because -2 */ isPtSize = fvf & D3DFVF_PSIZE; isDiffuse = fvf & D3DFVF_DIFFUSE; isSpecular = fvf & D3DFVF_SPECULAR; @@ -268,7 +276,7 @@ vertex arrays, we need to drop down to the slow mechanism for certain functions */ - if (isPtSize || isDiffuse || useVertexShaderFunction==TRUE || (numBlends > 0)) { + if (isPtSize || isDiffuse || useVertexShaderFunction || isLastUByte4 /* || (numBlends > 0)*/) { TRACE("Using slow per-vertex code\n"); /* Enable this one to be able to debug what is going on, but it is slower @@ -285,13 +293,14 @@ curPos = curVtx; } else { if (idxBytes == 2) { - VTRACE(("Idx for vertex %d = %d = %d\n", vx_index, pIdxBufS[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index]))); + TRACE("Idx for vertex %d = %d = %d\n", vx_index, pIdxBufS[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index])); curPos = curVtx + ((pIdxBufS[StartIdx+vx_index]) * skip); } else { - VTRACE(("Idx for vertex %d = %ld = %d\n", vx_index, pIdxBufL[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index]))); + TRACE("Idx for vertex %d = %ld = %d\n", vx_index, pIdxBufL[StartIdx+vx_index], (pIdxBufS[StartIdx+vx_index])); curPos = curVtx + ((pIdxBufL[StartIdx+vx_index]) * skip); } } + /*TRACE(" using curPos %p\n", curPos);*/ /* Work through the vertex buffer */ x = *(float *)curPos; @@ -302,54 +311,84 @@ curPos = curPos + sizeof(float); VTRACE(("x,y,z=%f,%f,%f\n", x,y,z)); - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_POSITION].x = x; - vertex_shader_input.V[D3DVSDE_POSITION].y = y; - vertex_shader_input.V[D3DVSDE_POSITION].z = z; - vertex_shader_input.V[D3DVSDE_POSITION].w = 1.0f; - } - /* RHW follows, only if transformed */ if (isRHW) { rhw = *(float *)curPos; curPos = curPos + sizeof(float); VTRACE(("rhw=%f\n", rhw)); + /* if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_POSITION].w = rhw; + vertex_shader->input.V[D3DVSDE_POSITION].w = rhw; } + */ } - /* Blending data */ - if (numBlends > 0) { + /** + * Indexed Vertex Blending data + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/Graphics/programmersguide/advancedtopics/indverblend/UsingIndexedVertexBlending.asp + */ + if (numBlends > 0 && numBlends > This->UpdateStateBlock->vertex_blend) { + ERR("declaring Blending in FVF, but desactived in render state\n"); + } else if (numBlends > 0) { + D3DSHADERVECTOR blend = {0.0f, 0.0f, 0.0f, 0.0f}; + DWORD blendIndices = 0; UINT i; - D3DSHADERVECTOR skippedBlend = { 0.0f, 0.0f, 0.0f, 0.0f}; - DWORD skippedBlendLastUByte4 = 0; - for (i = 0; i < ((FALSE == isLastUByte4) ? numBlends : numBlends - 1); ++i) { - ((float*)&skippedBlend)[i] = *(float *)curPos; + for (i = 0; i < numBlends; ++i) { + ((float*)&blend)[i] = *(float *)curPos; curPos = curPos + sizeof(float); } + blend.w = 1.0f - (blend.x + blend.y + blend.z); if (isLastUByte4) { - skippedBlendLastUByte4 = *(DWORD*)curPos; + blendIndices = *(DWORD*)curPos; curPos = curPos + sizeof(DWORD); } - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].x = skippedBlend.x; - vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].y = skippedBlend.y; - vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].z = skippedBlend.z; - vertex_shader_input.V[D3DVSDE_BLENDWEIGHT].w = skippedBlend.w; - - if (isLastUByte4) { - vertex_shader_input.V[D3DVSDE_BLENDINDICES].x = (float) skippedBlendLastUByte4; - vertex_shader_input.V[D3DVSDE_BLENDINDICES].y = (float) skippedBlendLastUByte4; - vertex_shader_input.V[D3DVSDE_BLENDINDICES].z = (float) skippedBlendLastUByte4; - vertex_shader_input.V[D3DVSDE_BLENDINDICES].w = (float) skippedBlendLastUByte4; - } - } - } + if (TRUE == This->UpdateStateBlock->renderstate[D3DRS_INDEXEDVERTEXBLENDENABLE]) { + if (checkGLSupport(ARB_VERTEX_BLEND)) { + FIXME("TODO\n"); + } else if (checkGLSupport(EXT_VERTEX_WEIGHTING)) { + FIXME("TODO\n"); + /* + GLExtCall(glVertexWeightfvEXT)((float*) &blend.x); + checkGLcall("glVertexWeightfvEXT(blend)"); + */ + } else { + FIXME("unsupported blending in openGl\n"); + } + } + + /** + * Arghh using blending matrix + * + * TODO: how to do this with GL Vertex Arrays ??? + */ + if (0 != blendIndices) { + /** + * Context Work: if not first, pop to the last world(0) matrix + * maybe the last multMatrixf with world(0) don't have to be done in blendIndices mode + * the documentation is confuse ... to see + */ + /** + * in doc seems to say: + * oPos = iPos * D3DTS_WORLDMATRIX(i0) * blend.x + iPos * D3DTS_WORLDMATRIX(i1) * blend.y + iPos * D3DTS_WORLDMATRIX(i2) * blend.z + * but how to do in OpenGL (understand ARB_vertex_blend extension ?) + * and the doc is really confuse ;( + */ + /* + if (0 < vx_index) glPopMatrix(); + glPushMatrix(); + + for (i = 0; i < min(3, This->UpdateStateBlock->vertex_blend); ++i) { + glMultMatrixf((float *) &This->StateBlock.transforms[D3DTS_WORLDMATRIX(((blendIndices >> (8 * i)) & 0x0F))].u.m[0][0]); + checkGLcall("glMultMatrixf"); + } + */ + } + + } /* Vertex Normal Data (untransformed only) */ if (normal) { @@ -360,52 +399,24 @@ nz = *(float *)curPos; curPos = curPos + sizeof(float); VTRACE(("nx,ny,nz=%f,%f,%f\n", nx,ny,nz)); - - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_NORMAL].x = nx; - vertex_shader_input.V[D3DVSDE_NORMAL].y = ny; - vertex_shader_input.V[D3DVSDE_NORMAL].z = nz; - vertex_shader_input.V[D3DVSDE_NORMAL].w = 1.0f; - } - } + } if (isPtSize) { ptSize = *(float *)curPos; VTRACE(("ptSize=%f\n", ptSize)); curPos = curPos + sizeof(float); - - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_PSIZE].x = ptSize; - vertex_shader_input.V[D3DVSDE_PSIZE].y = 0.0f; - vertex_shader_input.V[D3DVSDE_PSIZE].z = 0.0f; - vertex_shader_input.V[D3DVSDE_PSIZE].w = 1.0f; - } } if (isDiffuse) { diffuseColor = *(DWORD *)curPos; VTRACE(("diffuseColor=%lx\n", diffuseColor)); curPos = curPos + sizeof(DWORD); - - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_DIFFUSE].x = (float) (((diffuseColor >> 16) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_DIFFUSE].y = (float) (((diffuseColor >> 8) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_DIFFUSE].z = (float) (((diffuseColor >> 0) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_DIFFUSE].w = (float) (((diffuseColor >> 24) & 0xFF) / 255.0f); - } } if (isSpecular) { specularColor = *(DWORD *)curPos; VTRACE(("specularColor=%lx\n", specularColor)); curPos = curPos + sizeof(DWORD); - - if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_SPECULAR].x = (float) (((specularColor >> 16) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_SPECULAR].y = (float) (((specularColor >> 8) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_SPECULAR].z = (float) (((specularColor >> 0) & 0xFF) / 255.0f); - vertex_shader_input.V[D3DVSDE_SPECULAR].w = (float) (((specularColor >> 24) & 0xFF) / 255.0f); - } } /* ToDo: Texture coords */ @@ -432,10 +443,7 @@ VTRACE(("tex:%d, s,t=%f,%f\n", textureNo, s,t)); if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].x = s; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].y = t; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].z = 0.0f; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].w = 1.0f; + /* Nothing to do */ } else { if (This->isMultiTexture) { glMultiTexCoord2fARB(GL_TEXTURE0_ARB + textureNo, s, t); @@ -455,10 +463,7 @@ VTRACE(("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r)); if (TRUE == useVertexShaderFunction) { - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].x = s; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].y = t; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].z = r; - vertex_shader_input.V[D3DVSDE_TEXCOORD0 + textureNo].w = 1.0f; + /* Nothing to do */ } else { if (This->isMultiTexture) { glMultiTexCoord3fARB(GL_TEXTURE0_ARB + textureNo, s, t, r); @@ -481,38 +486,53 @@ /** if vertex shader program specified ... using it */ if (TRUE == useVertexShaderFunction) { - VSHADEROUTPUTDATA8 vs_o; - memset(&vs_o, 0, sizeof(VSHADEROUTPUTDATA8)); - vshader_program_execute_SW(vertex_shader, &vertex_shader_input, &vs_o); + + /** + * this code must become the really + * vs input params init + * + * because its possible to use input registers for anything + * and some samples use registers for other things than they are + * declared + */ + + /** + * no really valid declaration, user defined input register use + * so fill input registers as described in vertex shader declaration + */ + vshader_fill_input(vertex_shader, This, vertexBufData, StartVertexIndex, + (!isIndexed) ? (vx_index * skip) : + (idxBytes == 2) ? ((pIdxBufS[StartIdx + vx_index]) * skip) : + ((pIdxBufL[StartIdx + vx_index]) * skip)); + + memset(&vertex_shader->output, 0, sizeof(VSHADEROUTPUTDATA8)); + vshader_program_execute_SW(vertex_shader, &vertex_shader->input, &vertex_shader->output); /* - TRACE_VECTOR(vs_o.oPos); - TRACE_VECTOR(vs_o.oD[0]); - TRACE_VECTOR(vs_o.oT[0]); - TRACE_VECTOR(vs_o.oT[1]); + TRACE_VECTOR(vertex_shader->output.oPos); + TRACE_VECTOR(vertex_shader->output.oD[0]); + TRACE_VECTOR(vertex_shader->output.oD[1]); + TRACE_VECTOR(vertex_shader->output.oT[0]); + TRACE_VECTOR(vertex_shader->output.oT[1]); */ - x = vs_o.oPos.x; - y = vs_o.oPos.y; - z = vs_o.oPos.z; + x = vertex_shader->output.oPos.x; + y = vertex_shader->output.oPos.y; + z = vertex_shader->output.oPos.z; - if (1.0f != vs_o.oPos.w || isRHW) { - rhw = vs_o.oPos.w; + if (1.0f != vertex_shader->output.oPos.w || isRHW) { + rhw = vertex_shader->output.oPos.w; } - /*TRACE_VECTOR(vs_o.oPos);*/ - if (isDiffuse) { - /*diffuseColor = D3DCOLOR_COLORVALUE(vs_o.oD[0].x, vs_o.oD[0].y, vs_o.oD[0].z, vs_o.oD[0].w);*/ - /*TRACE_VECTOR(vs_o.oD[0]);*/ - /*glColor4f(vs_o.oD[0].x, vs_o.oD[0].y, vs_o.oD[0].z, vs_o.oD[0].w); */ - glMaterialfv(GL_FRONT, GL_DIFFUSE, (float*) &vs_o.oD[0]); - checkGLcall("glMaterialfv"); - } - if (isSpecular) { - /*specularColor = D3DCOLOR_COLORVALUE(vs_o.oD[1].x, vs_o.oD[1].y, vs_o.oD[1].z, vs_o.oD[1].w);*/ - /*TRACE_VECTOR(vs_o.oD[1]);*/ - glMaterialfv(GL_FRONT, GL_SPECULAR, (float*) &vs_o.oD[1]); - checkGLcall("glMaterialfv"); - } - /** reupdate textures coords binding using vs_o.oT[0->3] */ - for (textureNo = 0; textureNo < 4/*min(numTextures, 4)*/; ++textureNo) { + /*diffuseColor = D3DCOLOR_COLORVALUE(vertex_shader->output.oD[0]);*/ + glColor4fv((float*) &vertex_shader->output.oD[0]); + + /* Requires secondary color extensions to compile... */ + if (checkGLSupport(EXT_SECONDARY_COLOR)) { + /*specularColor = D3DCOLOR_COLORVALUE(vertex_shader->output.oD[1]);*/ + GLExtCall(glSecondaryColor3fvEXT)((float*) &vertex_shader->output.oD[1]); + /*checkGLcall("glSecondaryColor3fvEXT");*/ + } + + /** reupdate textures coords binding using vertex_shader->output.oT[0->3] */ + for (textureNo = 0; textureNo < 4; ++textureNo) { float s, t, r, q; if (!(This->isMultiTexture) && textureNo > 0) { @@ -523,31 +543,31 @@ if (This->StateBlock.textures[textureNo] != NULL) { switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->StateBlock.textures[textureNo])) { case D3DRTYPE_TEXTURE: - /*TRACE_VECTOR(vs_o.oT[textureNo]);*/ - s = vs_o.oT[textureNo].x; - t = vs_o.oT[textureNo].y; - VTRACE(("tex:%d, s,t=%f,%f\n", textureNo, s,t)); + /*TRACE_VECTOR(vertex_shader->output.oT[textureNo]);*/ + s = vertex_shader->output.oT[textureNo].x; + t = vertex_shader->output.oT[textureNo].y; + VTRACE(("tex:%d, s,t=%f,%f\n", textureNo, s, t)); if (This->isMultiTexture) { glMultiTexCoord2fARB(GL_TEXTURE0_ARB + textureNo, s, t); - checkGLcall("glMultiTexCoord2fARB"); + /*checkGLcall("glMultiTexCoord2fARB");*/ } else { glTexCoord2f(s, t); - checkGLcall("gTexCoord2f"); + /*checkGLcall("gTexCoord2f");*/ } break; case D3DRTYPE_VOLUMETEXTURE: - /*TRACE_VECTOR(vs_o.oT[textureNo]);*/ - s = vs_o.oT[textureNo].x; - t = vs_o.oT[textureNo].y; - r = vs_o.oT[textureNo].z; - VTRACE(("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s,t,r)); + /*TRACE_VECTOR(vertex_shader->output.oT[textureNo]);*/ + s = vertex_shader->output.oT[textureNo].x; + t = vertex_shader->output.oT[textureNo].y; + r = vertex_shader->output.oT[textureNo].z; + VTRACE(("tex:%d, s,t,r=%f,%f,%f\n", textureNo, s, t, r)); if (This->isMultiTexture) { glMultiTexCoord3fARB(GL_TEXTURE0_ARB + textureNo, s, t, r); - checkGLcall("glMultiTexCoord2fARB"); + /*checkGLcall("glMultiTexCoord2fARB");*/ } else { glTexCoord3f(s, t, r); - checkGLcall("gTexCoord3f"); + /*checkGLcall("gTexCoord3f");*/ } break; @@ -560,14 +580,15 @@ } if (1.0f == rhw || rhw < 0.01f) { - VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z)); + VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z)); glVertex3f(x, y, z); - checkGLcall("glVertex3f"); + /*checkGLcall("glVertex3f");*/ } else { VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw)); glVertex4f(x / rhw, y / rhw, z / rhw, 1.0f / rhw); - checkGLcall("glVertex4f"); + /*checkGLcall("glVertex4f");*/ } + } else { /** * FALSE == useVertexShaderFunction @@ -575,7 +596,7 @@ */ /* Handle these vertexes */ - if (isDiffuse) { + if (isDiffuse) { glColor4ub((diffuseColor >> 16) & 0xFF, (diffuseColor >> 8) & 0xFF, (diffuseColor >> 0) & 0xFF, @@ -622,20 +643,44 @@ if (isRHW) { glVertexPointer(4, GL_FLOAT, skip, curPos); checkGLcall("glVertexPointer(4, ...)"); - curPos += 4*sizeof(float); + curPos += 4 * sizeof(float); } else { glVertexPointer(3, GL_FLOAT, skip, curPos); checkGLcall("glVertexPointer(3, ...)"); - curPos += 3*sizeof(float); + curPos += 3 * sizeof(float); } glEnableClientState(GL_VERTEX_ARRAY); checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)"); - if (numBlends>0) { + if (numBlends > 0) { /* no such functionality in the fixed function GL pipeline */ /* FIXME: Wont get here as will drop to slow method */ - FIXME("Cannot handle blending data here in openGl\n"); - } + /* FIXME("Cannot handle blending data here in openGl\n");*/ + if (checkGLSupport(ARB_VERTEX_BLEND)) { + FIXME("TODO\n"); + } else if (checkGLSupport(EXT_VERTEX_WEIGHTING)) { + FIXME("TODO\n"); + /* + GLExtCall(glVertexWeightPointerEXT)(numBlends, GL_FLOAT, skip, curPos); + checkGLcall("glVertexWeightPointerEXT(numBlends, ...)"); + glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT); + checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)"); + */ + curPos += numBlends * sizeof(float); + } else { + FIXME("unsupported blending in openGl\n"); + } + } else { + if (checkGLSupport(ARB_VERTEX_BLEND)) { + FIXME("TODO\n"); + } else if (checkGLSupport(EXT_VERTEX_WEIGHTING)) { + FIXME("TODO\n"); + /* + glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT); + checkGLcall("glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)"); + */ + } + } if (normal) { @@ -643,11 +688,11 @@ checkGLcall("glNormalPointer"); glEnableClientState(GL_NORMAL_ARRAY); checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)"); - curPos += 3*sizeof(float); + curPos += 3 * sizeof(float); } else { glDisableClientState(GL_NORMAL_ARRAY); checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)"); - glNormal3f(0, 0, 1); + glNormal3f(0.0f, 0.0f, 1.0f); checkGLcall("glNormal3f(0, 0, 1)"); } @@ -668,26 +713,26 @@ else { glDisableClientState(GL_COLOR_ARRAY); checkGLcall("glDisableClientState(GL_COLOR_ARRAY)"); - glColor4f(1, 1, 1, 1); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); checkGLcall("glColor4f(1, 1, 1, 1)"); } -/* Requires secondary color extensions to compile... */ -#if 0 - if (isSpecular) { + /* Requires secondary color extensions to compile... */ + if (checkGLSupport(EXT_SECONDARY_COLOR)) { + if (isSpecular) { /* FIXME: check for GL_EXT_secondary_color */ - glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, skip, curPos); + GLExtCall(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, skip, (GLvoid*) curPos); checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, skip, curPos)"); glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)"); curPos += sizeof(DWORD); - } else { + } else { glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)"); - glSecondaryColor3fEXT(0, 0, 0); + GLExtCall(glSecondaryColor3fEXT)(0.0f, 0.0f, 0.0f); checkGLcall("glSecondaryColor3fEXT(0, 0, 0)"); + } } -#endif /* ToDo: Texture coords */ for (textureNo = 0;textureNo<numTextures; textureNo++) { @@ -700,7 +745,7 @@ case D3DRTYPE_TEXTURE: glTexCoordPointer(2, GL_FLOAT, skip, curPos); checkGLcall("glTexCoordPointer(2, ...)"); - curPos += 2*sizeof(float); + curPos += 2 * sizeof(float); glEnableClientState(GL_TEXTURE_COORD_ARRAY); checkGLcall("glEnableClientState(GL_TEXTURE_COORD_ARRAY);"); break; @@ -708,7 +753,7 @@ case D3DRTYPE_VOLUMETEXTURE: glTexCoordPointer(3, GL_FLOAT, skip, curPos); checkGLcall("glTexCoordPointer(3, ...)"); - curPos += 3*sizeof(float); + curPos += 3 * sizeof(float); glEnableClientState(GL_TEXTURE_COORD_ARRAY); checkGLcall("glEnableClientState(GL_TEXTURE_COORD_ARRAY);"); break; @@ -723,7 +768,7 @@ /* Note I have seen a program actually do this, so just hide it and continue */ TRACE("Very odd - texture requested in FVF but not bound!\n"); - glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1); + glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0.0f, 0.0f, 0.0f, 1.0f); checkGLcall("glMultiTexCoord4f(... , 0, 0, 0, 1)"); glDisableClientState(GL_TEXTURE_COORD_ARRAY); checkGLcall("glDisableClientState(GL_TEXTURE_COORD_ARRAY);"); @@ -731,7 +776,6 @@ } } - /* Finally do the drawing */ if (isIndexed) { @@ -945,10 +989,10 @@ /* Note the D3DRS value applies to all textures, but GL has one per texture, so apply it now ready to be used! */ - col[0] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR]>> 16) & 0xFF) / 255.0; - col[1] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 8 ) & 0xFF) / 255.0; - col[2] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 0 ) & 0xFF) / 255.0; - col[3] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 24 ) & 0xFF) / 255.0; + col[0] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 16) & 0xFF) / 255.0; + col[1] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 8) & 0xFF) / 255.0; + col[2] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 0) & 0xFF) / 255.0; + col[3] = ((This->StateBlock.renderstate[D3DRS_TEXTUREFACTOR] >> 24) & 0xFF) / 255.0; glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]); checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);"); @@ -1060,7 +1104,7 @@ ICOM_THIS(IDirect3DDevice8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } -void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace,DWORD Flags) { +void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) { ICOM_THIS(IDirect3DDevice8Impl,iface); FIXME("(%p) : stub\n", This); return; } @@ -1076,7 +1120,7 @@ ICOM_THIS(IDirect3DDevice8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) { +HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : complete stub!\n", This); @@ -1089,7 +1133,7 @@ return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) { +HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) { ICOM_THIS(IDirect3DDevice8Impl,iface); *ppBackBuffer = (LPDIRECT3DSURFACE8) This->backBuffer; TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, BackBuffer, Type, *ppBackBuffer); @@ -1124,7 +1168,7 @@ TRACE("(%p) : W(%d) H(%d), Lvl(%d) Usage(%ld), Fmt(%d), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl)); object->lpVtbl = &Direct3DTexture8_Vtbl; - object->Device = This; + object->Device = This; /* FIXME: AddRef(This) */ object->ResourceType = D3DRTYPE_TEXTURE; object->ref = 1; object->width = Width; @@ -1140,7 +1184,7 @@ tmpW = Width; tmpH = Height; while (tmpW > 1 && tmpH > 1) { - tmpW = max(1,tmpW / 2); + tmpW = max(1, tmpW / 2); tmpH = max(1, tmpH / 2); object->levels++; } @@ -1153,12 +1197,12 @@ for (i=0; i<object->levels; i++) { IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpH, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[i]); - object->surfaces[i]->Container = object; + object->surfaces[i]->Container = (IUnknown*) object; /* FIXME: AddRef(object) */ object->surfaces[i]->myDesc.Usage = Usage; object->surfaces[i]->myDesc.Pool = Pool ; TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[i], object->surfaces[i]->allocatedMemory); - tmpW = max(1,tmpW / 2); + tmpW = max(1, tmpW / 2); tmpH = max(1, tmpH / 2); } @@ -1220,7 +1264,7 @@ object->volumes[i] = (IDirect3DVolume8Impl *) volume; volume->lpVtbl = &Direct3DVolume8_Vtbl; - volume->Device = This; + volume->Device = This; /* FIXME: AddRef(This) */ volume->ResourceType = D3DRTYPE_VOLUME; volume->Container = object; volume->ref = 1; @@ -1259,7 +1303,7 @@ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl)); object->lpVtbl = &Direct3DCubeTexture8_Vtbl; object->ref = 1; - object->Device = This; + object->Device = This; /* FIXME: AddRef(This) */ object->ResourceType = D3DRTYPE_CUBETEXTURE; object->edgeLength = EdgeLength; @@ -1286,7 +1330,7 @@ /* Create the 6 faces */ for (j=0;j<6;j++) { IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpW, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[j][i]); - object->surfaces[j][i]->Container = object; + object->surfaces[j][i]->Container = (IUnknown*) object; object->surfaces[j][i]->myDesc.Usage = Usage; object->surfaces[j][i]->myDesc.Pool = Pool ; @@ -1371,7 +1415,7 @@ object->lpVtbl = &Direct3DSurface8_Vtbl; object->Device = This; object->ResourceType = D3DRTYPE_SURFACE; - object->Container = This; + object->Container = (IUnknown*) This; object->ref = 1; object->myDesc.Width = Width; @@ -1390,7 +1434,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects, IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) { - HRESULT rc = D3D_OK; + HRESULT rc = D3D_OK; + IDirect3DBaseTexture8* texture = NULL; + IDirect3DSurface8Impl *src = (IDirect3DSurface8Impl*) pSourceSurface; IDirect3DSurface8Impl *dst = (IDirect3DSurface8Impl*) pDestinationSurface; @@ -1404,14 +1450,13 @@ if (src->myDesc.Format != dst->myDesc.Format && (dst->myDesc.Format != D3DFMT_UNKNOWN)) { TRACE("Formats do not match %x / %x\n", src->myDesc.Format, dst->myDesc.Format); rc = D3DERR_INVALIDCALL; - } else if (dst->myDesc.Format == D3DFMT_UNKNOWN) { - void *texture = NULL; + } else if (dst->myDesc.Format == D3DFMT_UNKNOWN) { TRACE("Converting dest to same format as source, since dest was unknown\n"); dst->myDesc.Format = src->myDesc.Format; /* Convert container as well */ - IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, NULL, &texture); /* FIXME: Which refid? */ + IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, &IID_IDirect3DBaseTexture8, (void**) &texture); /* FIXME: Which refid? */ if (texture != NULL) { switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) texture)) { @@ -1428,6 +1473,8 @@ FIXME("Unhandled texture type\n"); } + /** Releasing texture after GetContainer */ + IDirect3DBaseTexture8_Release(texture); } } @@ -1454,7 +1501,7 @@ void *from; void *to; int copyperline = (r->right - r->left) * bytesPerPixel; - int j; + int j; TRACE("Copying rect %d (%ld,%ld),(%ld,%ld) -> (%ld,%ld)\n", i, r->left, r->top, r->right, r->bottom, p->x, p->y); @@ -1469,6 +1516,40 @@ } } } + + /* Set dirty */ + if (rc == D3D_OK) { + IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, &IID_IDirect3DBaseTexture8, (void**) &texture); /* FIXME: Which refid? */ + if (texture != NULL) { + + switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) texture)) { + case D3DRTYPE_TEXTURE: + { + IDirect3DTexture8Impl *pTexture = (IDirect3DTexture8Impl *)texture; + pTexture->Dirty = TRUE; + } + break; + case D3DRTYPE_VOLUMETEXTURE: + { + IDirect3DVolumeTexture8Impl *pTexture = (IDirect3DVolumeTexture8Impl *)texture; + pTexture->Dirty = TRUE; + } + break; + case D3DRTYPE_CUBETEXTURE: + { + IDirect3DCubeTexture8Impl *pTexture = (IDirect3DCubeTexture8Impl *)texture; + pTexture->Dirty = TRUE; + } + break; + default: + FIXME("Unhandled texture type\n"); + } + + /** Releasing texture after GetContainer */ + IDirect3DBaseTexture8_Release(texture); + } + } + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) { @@ -1599,7 +1680,9 @@ } HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE d3dts,CONST D3DMATRIX* lpmatrix) { ICOM_THIS(IDirect3DDevice8Impl,iface); + D3DMATRIX m; int k; + float f; /* Most of this routine, comments included copied from ddraw tree initially: */ TRACE("(%p) : State=%d\n", This, d3dts); @@ -1638,22 +1721,49 @@ to the other so that if I ever find out that I need to transpose them, I will able to do it quickly, only by changing the macro conv_mat. */ - switch (d3dts) { - case D3DTS_WORLDMATRIX(0): + if (d3dts < 256) { + switch (d3dts) { + case D3DTS_WORLDMATRIX(0): conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_WORLDMATRIX(0)]); break; - - case D3DTS_VIEW: + + case D3DTS_VIEW: conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_VIEW]); break; - - case D3DTS_PROJECTION: + + case D3DTS_PROJECTION: conv_mat(lpmatrix, &This->StateBlock.transforms[D3DTS_PROJECTION]); break; - default: - FIXME("Unhandled transform state!!\n"); + case D3DTS_TEXTURE0: + case D3DTS_TEXTURE1: + case D3DTS_TEXTURE2: + case D3DTS_TEXTURE3: + case D3DTS_TEXTURE4: + case D3DTS_TEXTURE5: + case D3DTS_TEXTURE6: + case D3DTS_TEXTURE7: + conv_mat(lpmatrix, &This->StateBlock.transforms[d3dts]); + FIXME("Unhandled transform state for TEXTURE%d!!!\n", d3dts - D3DTS_TEXTURE0); + FIXME("must use glMatrixMode(GL_TEXTURE) before texturing\n"); break; + + default: + FIXME("Unhandled transform state for %d!!\n", d3dts); + break; + } + + } else { + /** + * Indexed Vertex Blending Matrices 256 -> 511 + */ + /** store it */ + conv_mat(lpmatrix, &This->StateBlock.transforms[d3dts]); + if (checkGLSupport(ARB_VERTEX_BLEND)) { + FIXME("todo\n"); + } else if (checkGLSupport(EXT_VERTEX_WEIGHTING)) { + FIXME("todo\n"); + } } /* @@ -1665,29 +1775,79 @@ checkGLcall("glMatrixMode"); glLoadMatrixf((float *) &This->StateBlock.transforms[D3DTS_PROJECTION].u.m[0][0]); checkGLcall("glLoadMatrixf"); - + glMatrixMode(GL_MODELVIEW); checkGLcall("glMatrixMode"); glLoadMatrixf((float *) &This->StateBlock.transforms[D3DTS_VIEW].u.m[0][0]); checkGLcall("glLoadMatrixf"); - + /* If we are changing the View matrix, reset the light information to the new view */ if (d3dts == D3DTS_VIEW) { - for (k = 0; k < MAX_ACTIVE_LIGHTS; k++) { - glLightfv(GL_LIGHT0 + k, GL_POSITION, &This->lightPosn[k][0]); - checkGLcall("glLightfv posn"); - glLightfv(GL_LIGHT0 + k, GL_SPOT_DIRECTION, &This->lightDirn[k][0]); - checkGLcall("glLightfv dirn"); - } + for (k = 0; k < MAX_ACTIVE_LIGHTS; k++) { + glLightfv(GL_LIGHT0 + k, GL_POSITION, &This->lightPosn[k][0]); + checkGLcall("glLightfv posn"); + glLightfv(GL_LIGHT0 + k, GL_SPOT_DIRECTION, &This->lightDirn[k][0]); + checkGLcall("glLightfv dirn"); + } } - glMultMatrixf((float *) &This->StateBlock.transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]); - checkGLcall("glMultMatrixf"); + /** + * Vertex Blending as described + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/enums/d3dvertexblendflags.asp + */ + switch (This->UpdateStateBlock->vertex_blend) { + case D3DVBF_DISABLE: + { + glMultMatrixf((float *) &This->StateBlock.transforms[D3DTS_WORLDMATRIX(0)].u.m[0][0]); + checkGLcall("glMultMatrixf"); + } + break; + case D3DVBF_1WEIGHTS: + case D3DVBF_2WEIGHTS: + case D3DVBF_3WEIGHTS: + { + FIXME("valid/correct D3DVBF_[1..3]WEIGHTS\n"); + /* + * doc seems to say that the weight values must be in vertex data (specified in FVF by D3DFVF_XYZB*) + * so waiting for the values before matrix work + for (k = 0; k < This->UpdateStateBlock->vertex_blend; ++k) { + glMultMatrixf((float *) &This->StateBlock.transforms[D3DTS_WORLDMATRIX(k)].u.m[0][0]); + checkGLcall("glMultMatrixf"); + } + */ + } + break; + case D3DVBF_TWEENING: + { + FIXME("valid/correct D3DVBF_TWEENING\n"); + f = This->UpdateStateBlock->tween_factor; + m.u.s._11 = f; m.u.s._12 = f; m.u.s._13 = f; m.u.s._14 = f; + m.u.s._21 = f; m.u.s._22 = f; m.u.s._23 = f; m.u.s._24 = f; + m.u.s._31 = f; m.u.s._32 = f; m.u.s._33 = f; m.u.s._34 = f; + m.u.s._41 = f; m.u.s._42 = f; m.u.s._43 = f; m.u.s._44 = f; + glMultMatrixf((float *) &m.u.m[0][0]); + checkGLcall("glMultMatrixf"); + } + break; + case D3DVBF_0WEIGHTS: + { + FIXME("valid/correct D3DVBF_0WEIGHTS\n"); + /* single matrix of weight 1.0f */ + m.u.s._11 = 1.0f; m.u.s._12 = 1.0f; m.u.s._13 = 1.0f; m.u.s._14 = 1.0f; + m.u.s._21 = 1.0f; m.u.s._22 = 1.0f; m.u.s._23 = 1.0f; m.u.s._24 = 1.0f; + m.u.s._31 = 1.0f; m.u.s._32 = 1.0f; m.u.s._33 = 1.0f; m.u.s._34 = 1.0f; + m.u.s._41 = 1.0f; m.u.s._42 = 1.0f; m.u.s._43 = 1.0f; m.u.s._44 = 1.0f; + glMultMatrixf((float *) &m.u.m[0][0]); + checkGLcall("glMultMatrixf"); + } + break; + default: + break; /* stupid compilator */ + } LEAVE_GL(); return D3D_OK; - } HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) { ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -1920,13 +2080,13 @@ return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) { +HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, D3DLIGHT8* pLight) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : Idx(%ld), pLight(%p)\n", This, Index, pLight); memcpy(pLight, &This->StateBlock.lights[Index], sizeof(D3DLIGHT8)); return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) { +HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL Enable) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : Idx(%ld), enable? %d\n", This, Index, Enable); @@ -1949,13 +2109,13 @@ } return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) { +HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index, BOOL* pEnable) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : for idx(%ld)\n", This, Index); *pEnable = This->StateBlock.lightEnable[Index]; return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) { +HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST float* pPlane) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : for idx %ld, %p\n", This, Index, pPlane); @@ -1988,7 +2148,7 @@ return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) { +HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index, float* pPlane) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) : for idx %ld\n", This, Index); pPlane[0] = This->StateBlock.clipplane[Index][0]; @@ -1997,7 +2157,7 @@ pPlane[3] = This->StateBlock.clipplane[Index][0]; return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) { +HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD Value) { ICOM_THIS(IDirect3DDevice8Impl,iface); DWORD OldValue = This->StateBlock.renderstate[State]; @@ -2541,6 +2701,26 @@ } break; + case D3DRS_VERTEXBLEND : + { + This->UpdateStateBlock->vertex_blend = (D3DVERTEXBLENDFLAGS) Value; + TRACE("vertex_blend to %ul\n", (BOOL) Value); + } + break; + + case D3DRS_TWEENFACTOR : + { + This->UpdateStateBlock->tween_factor = *((float*) &Value); + TRACE("tween_factor to %ul\n", (BOOL) Value); + } + break; + + case D3DRS_INDEXEDVERTEXBLENDENABLE : + { + TRACE("D3DRS_INDEXEDVERTEXBLENDENABLE to %ul\n", (BOOL) Value); + } + break; + /* Unhandled yet...! */ case D3DRS_LINEPATTERN : case D3DRS_LASTPIXEL : @@ -2565,7 +2745,6 @@ case D3DRS_SPECULARMATERIALSOURCE : case D3DRS_AMBIENTMATERIALSOURCE : case D3DRS_EMISSIVEMATERIALSOURCE : - case D3DRS_VERTEXBLEND : case D3DRS_SOFTWAREVERTEXPROCESSING : case D3DRS_POINTSIZE : case D3DRS_POINTSIZE_MIN : @@ -2580,9 +2759,7 @@ case D3DRS_PATCHSEGMENTS : case D3DRS_DEBUGMONITORTOKEN : case D3DRS_POINTSIZE_MAX : - case D3DRS_INDEXEDVERTEXBLENDENABLE : case D3DRS_COLORWRITEENABLE : - case D3DRS_TWEENFACTOR : case D3DRS_POSITIONORDER : case D3DRS_NORMALORDER : /*Put back later: FIXME("(%p)->(%d,%ld) not handled yet\n", This, State, Value); */ @@ -2594,7 +2771,7 @@ return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) { +HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State, DWORD* pValue) { ICOM_THIS(IDirect3DDevice8Impl,iface); TRACE("(%p) for State %d = %ld\n", This, State, This->UpdateStateBlock->renderstate[State]); *pValue = This->StateBlock.renderstate[State]; @@ -2759,7 +2936,6 @@ } } - } else { FIXME("Unrecognized state block type %d\n", pSB->blockType); } @@ -3192,7 +3368,7 @@ TRACE("Activating appropriate texture state %ld\n", Stage); if (This->isMultiTexture) { glActiveTextureARB(GL_TEXTURE0_ARB + Stage); - checkGLcall("glActiveTextureARB"); + /*checkGLcall("glActiveTextureARB");*/ } else if (Stage>0) { FIXME("Program using multiple concurrent textures which this opengl implementation doesnt support\n"); } @@ -3243,7 +3419,7 @@ TRACE("ValueMIN=%ld, ValueMIP=%ld, setting MINFILTER to %x\n", ValueMIN, ValueMIP, realVal); glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_MIN_FILTER, realVal); - checkGLcall("glTexParameter GL_TEXTURE_MINFILTER, ..."); + /*checkGLcall("glTexParameter GL_TEXTURE_MINFILTER, ...");*/ } break; @@ -3251,10 +3427,10 @@ case D3DTSS_MAGFILTER : if (Value == D3DTEXF_POINT) { glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_MAG_FILTER, GL_NEAREST); - checkGLcall("glTexParameter GL_TEXTURE_MAGFILTER, GL_NEAREST"); + /*checkGLcall("glTexParameter GL_TEXTURE_MAGFILTER, GL_NEAREST");*/ } else if (Value == D3DTEXF_LINEAR) { glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_MAG_FILTER, GL_LINEAR); - checkGLcall("glTexParameter GL_TEXTURE_MAGFILTER, GL_LINEAR"); + /*checkGLcall("glTexParameter GL_TEXTURE_MAGFILTER, GL_LINEAR");*/ } else { FIXME("Unhandled D3DTSS_MAGFILTER value of %ld\n", Value); } @@ -3455,22 +3631,71 @@ break; } + case D3DTSS_ADDRESSU : + case D3DTSS_ADDRESSV : + case D3DTSS_ADDRESSW : + { + GLint wrapParm = GL_REPEAT; + switch (Value) { + case D3DTADDRESS_WRAP: wrapParm = GL_REPEAT; break; + case D3DTADDRESS_CLAMP: wrapParm = GL_CLAMP; break; + case D3DTADDRESS_BORDER: wrapParm = GL_CLAMP_TO_EDGE; break; + + case D3DTADDRESS_MIRROR: /* Unsupported in OpenGL? */ + case D3DTADDRESS_MIRRORONCE: /* Unsupported in OpenGL? */ + default: + FIXME("Unrecognized or unsupported D3DTADDRESS_* value %ld, state %d\n", Value, Type); + wrapParm = GL_REPEAT; + } + + switch (Type) { + case D3DTSS_ADDRESSU: + TRACE("Setting WRAP_S to %d for %x\n", wrapParm, This->StateBlock.textureDimensions[Stage]); + glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_WRAP_S, wrapParm); + checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_S, wrapParm)"); + break; + case D3DTSS_ADDRESSV: + TRACE("Setting WRAP_T to %d for %x\n", wrapParm, This->StateBlock.textureDimensions[Stage]); + glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_WRAP_T, wrapParm); + checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_T, wrapParm)"); + break; + case D3DTSS_ADDRESSW: + TRACE("Setting WRAP_R to %d for %x\n", wrapParm, This->StateBlock.textureDimensions[Stage]); + glTexParameteri(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_WRAP_R, wrapParm); + checkGLcall("glTexParameteri(..., GL_TEXTURE_WRAP_R, wrapParm)"); + break; + default: /* nop */ + break; /** stupic compilator */ + } + } + break; + + case D3DTSS_BORDERCOLOR : + { + float col[4]; + col[0] = ((Value >> 16) & 0xFF) / 255.0; + col[1] = ((Value >> 8) & 0xFF) / 255.0; + col[2] = ((Value >> 0) & 0xFF) / 255.0; + col[3] = ((Value >> 24) & 0xFF) / 255.0; + + TRACE("Setting border color for %x to %lx\n", This->StateBlock.textureDimensions[Stage], Value); + glTexParameterfv(This->StateBlock.textureDimensions[Stage], GL_TEXTURE_BORDER_COLOR, &col[0]); + checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)"); + } + break; + /* Unhandled */ case D3DTSS_BUMPENVMAT00 : case D3DTSS_BUMPENVMAT01 : case D3DTSS_BUMPENVMAT10 : case D3DTSS_BUMPENVMAT11 : case D3DTSS_TEXCOORDINDEX : - case D3DTSS_ADDRESSU : - case D3DTSS_ADDRESSV : - case D3DTSS_BORDERCOLOR : case D3DTSS_MIPMAPLODBIAS : case D3DTSS_MAXMIPLEVEL : case D3DTSS_MAXANISOTROPY : case D3DTSS_BUMPENVLSCALE : case D3DTSS_BUMPENVLOFFSET : case D3DTSS_TEXTURETRANSFORMFLAGS : - case D3DTSS_ADDRESSW : case D3DTSS_RESULTARG : default: /* Put back later: FIXME("(%p) : stub, Stage=%ld, Type=%d, Value =%ld\n", This, Stage, Type, Value); */ @@ -4063,9 +4288,11 @@ This->StateBlock.blockType = D3DSBT_ALL; /* FIXME: Set some of the defaults for lights, transforms etc */ - memcpy(&This->StateBlock.transforms[D3DTS_WORLDMATRIX(0)], &idmatrix, sizeof(idmatrix)); memcpy(&This->StateBlock.transforms[D3DTS_PROJECTION], &idmatrix, sizeof(idmatrix)); memcpy(&This->StateBlock.transforms[D3DTS_VIEW], &idmatrix, sizeof(idmatrix)); + for (i = 0; i < 256; ++i) { + memcpy(&This->StateBlock.transforms[D3DTS_WORLDMATRIX(i)], &idmatrix, sizeof(idmatrix)); + } /* Render states: */ if (This->PresentParms.EnableAutoDepthStencil) { Index: dlls/d3d8/directx.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/directx.c,v retrieving revision 1.11 diff -u -r1.11 directx.c --- dlls/d3d8/directx.c 7 Jan 2003 20:36:30 -0000 1.11 +++ dlls/d3d8/directx.c 10 Jan 2003 23:43:50 -0000 @@ -58,6 +58,16 @@ return display; } +inline static X11DRV_OPENGL_INFO* get_opengl_info( HDC hdc, X11DRV_OPENGL_INFO* info ) +{ + enum x11drv_escape_codes escape = X11DRV_GET_OPENGL_INFO; + + if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, sizeof(X11DRV_OPENGL_INFO), (LPSTR)info )) { + ERR("ExtEscape pb!\n"); + } + return info; +} + /* IDirect3D IUnknown parts follow: */ HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID riid,LPVOID *ppobj) @@ -316,7 +326,7 @@ pCaps->DestBlendCaps = 0; pCaps->AlphaCmpCaps = 0; pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB | D3DPSHADECAPS_COLORGOURAUDRGB ; - pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_VOLUMEMAP; + pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA | D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_VOLUMEMAP | D3DPTEXTURECAPS_MIPMAP; pCaps->TextureFilterCaps = 0; pCaps->CubeTextureFilterCaps = 0; pCaps->VolumeTextureFilterCaps = 0; @@ -348,12 +358,12 @@ pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x80000; pCaps->TextureOpCaps = 0xFFFFFFFF; + /** + * OpenGL things + */ { - GLint gl_max_texture_units_arb; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max_texture_units_arb); - TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max_texture_units_arb); - pCaps->MaxTextureBlendStages = min(8, gl_max_texture_units_arb); - pCaps->MaxSimultaneousTextures = min(8, gl_max_texture_units_arb); + pCaps->MaxTextureBlendStages = min(8, This->glInfo.max_textures); + pCaps->MaxSimultaneousTextures = min(8, This->glInfo.max_textures); } pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_TEXGEN; @@ -370,10 +380,10 @@ pCaps->MaxStreams = 1; pCaps->MaxStreamStride = 1024; - pCaps->VertexShaderVersion = 01; + pCaps->VertexShaderVersion = D3DVS_VERSION(1,1); pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS; - pCaps->PixelShaderVersion = 01; + pCaps->PixelShaderVersion = D3DPS_VERSION(1,1); pCaps->MaxPixelShaderValue = 1.0; return D3D_OK; @@ -394,8 +404,10 @@ HWND whichHWND; int num; XVisualInfo template; + /* const char *GL_Extensions = NULL; const char *GLX_Extensions = NULL; + */ ICOM_THIS(IDirect3D8Impl,iface); TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType, @@ -409,6 +421,8 @@ object->lpVtbl = &Direct3DDevice8_Vtbl; object->ref = 1; object->direct3d8 = This; + /** The device AddRef the direct3d8 Interface else crash in propers clients codes */ + IDirect3D8_AddRef((LPDIRECT3D8) object->direct3d8); object->UpdateStateBlock = &object->StateBlock; /* Save the creation parameters */ @@ -453,6 +467,15 @@ hDc = GetDC(whichHWND); object->display = get_display(hDc); + /* Initialize some OpenGL extensions related variables */ + if (object->direct3d8->glInfo.max_textures > 1) { + object->isMultiTexture = TRUE; + object->TextureUnits = min(8, object->direct3d8->glInfo.max_textures); + } else { + object->isMultiTexture = FALSE; + object->TextureUnits = 1; + } + ENTER_GL(); object->visInfo = glXChooseVisual(object->display, DefaultScreen(object->display), dblBuf); if (NULL == object->visInfo) { @@ -550,10 +573,13 @@ checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);"); /* Initialize openGL extension related variables */ + /* object->isMultiTexture = FALSE; object->TextureUnits = 1; + */ /* Parse the gl supported features, in theory enabling parts of our code appropriately */ + /* GL_Extensions = glGetString(GL_EXTENSIONS); TRACE("GL_Extensions reported:\n"); @@ -602,7 +628,8 @@ if (*GLX_Extensions == ' ') GLX_Extensions++; } } - + */ + /* Setup all the devices defaults */ CreateStateBlock((LPDIRECT3DDEVICE8) object); Index: dlls/d3d8/resource.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/resource.c,v retrieving revision 1.1 diff -u -r1.1 resource.c --- dlls/d3d8/resource.c 27 Sep 2002 22:46:17 -0000 1.1 +++ dlls/d3d8/resource.c 10 Jan 2003 23:44:07 -0000 @@ -34,7 +34,7 @@ ICOM_THIS(IDirect3DResource8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8)) { IDirect3DResource8Impl_AddRef(iface); *ppobj = This; return D3D_OK; Index: dlls/d3d8/shader.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/shader.c,v retrieving revision 1.4 diff -u -r1.4 shader.c --- dlls/d3d8/shader.c 2 Jan 2003 19:28:09 -0000 1.4 +++ dlls/d3d8/shader.c 10 Jan 2003 23:44:14 -0000 @@ -26,6 +26,9 @@ #include <math.h> +#include "config.h" +#include "x11drv.h" + #include "d3d8_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); @@ -54,6 +57,12 @@ * * FVF * http://msdn.microsoft.com/library/en-us/directx9_c/directx/graphics/programmingguide/GettingStarted/VertexFormats/vformats.asp + * + * NVIDIA: DX8 Vertex Shader to NV Vertex Program + * http://developer.nvidia.com/view.asp?IO=vstovp + * + * NVIDIA: Memory Management with VAR + * http://developer.nvidia.com/view.asp?IO=var_memory_management */ typedef void (*shader_fct_t)(); @@ -137,10 +146,14 @@ void vshader_expp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { float tmp_f = floorf(s0->w); - d->x = powf(2.0f, tmp_f); - d->y = s0->w - tmp_f; - d->z = powf(2.0f, s0->w); - d->w = 1.0f; + DWORD tmp_d = 0; + tmp_f = powf(2.0f, s0->w); + tmp_d = *((DWORD*) &tmp_f) & 0xFFFFFF00; + + d->x = powf(2.0f, tmp_f); + d->y = s0->w - tmp_f; + d->z = *((float*) &tmp_d); + d->w = 1.0f; /* DPRINTF("executing exp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", @@ -245,27 +258,123 @@ } /** + * Version 1.1 specific + */ + +void vshader_exp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { + d->x = d->y = d->z = d->w = powf(2.0f, s0->w); +} + +void vshader_log(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { + float tmp_f = fabsf(s0->w); + d->x = d->y = d->z = d->w = (0.0f != tmp_f) ? logf(tmp_f) / logf(2.0f) : -HUGE; +} + +void vshader_frc(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { + d->x = s0->x - floorf(s0->x); + d->y = s0->y - floorf(s0->y); + d->z = 0.0f; + d->w = 1.0f; +} + +typedef FLOAT D3DMATRIX44[4][4]; +typedef FLOAT D3DMATRIX43[4][3]; +typedef FLOAT D3DMATRIX34[4][4]; +typedef FLOAT D3DMATRIX33[4][3]; +typedef FLOAT D3DMATRIX32[4][2]; + +void vshader_m4x4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, /*D3DSHADERVECTOR* mat1*/ D3DMATRIX44 mat) { + /* + * BuGGY CODE: here only if cast not work for copy/paste + D3DSHADERVECTOR* mat2 = mat1 + 1; + D3DSHADERVECTOR* mat3 = mat1 + 2; + D3DSHADERVECTOR* mat4 = mat1 + 3; + d->x = mat1->x * s0->x + mat2->x * s0->y + mat3->x * s0->z + mat4->x * s0->w; + d->y = mat1->y * s0->x + mat2->y * s0->y + mat3->y * s0->z + mat4->y * s0->w; + d->z = mat1->z * s0->x + mat2->z * s0->y + mat3->z * s0->z + mat4->z * s0->w; + d->w = mat1->w * s0->x + mat2->w * s0->y + mat3->w * s0->z + mat4->w * s0->w; + */ + d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z + mat[0][3] * s0->w; + d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z + mat[1][3] * s0->w; + d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z + mat[2][3] * s0->w; + d->w = mat[3][0] * s0->x + mat[3][1] * s0->y + mat[3][2] * s0->z + mat[3][3] * s0->w; +} + +void vshader_m4x3(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX43 mat) { + FIXME("check\n"); + d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z + mat[0][3] * s0->w; + d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z + mat[1][3] * s0->w; + d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z + mat[2][3] * s0->w; + d->w = 1.0f; +} + +void vshader_m3x4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX34 mat) { + FIXME("check\n"); + d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z; + d->y = mat[2][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z; + d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z; + d->w = mat[3][0] * s0->x + mat[3][1] * s0->y + mat[3][2] * s0->z; +} + +void vshader_m3x3(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX33 mat) { + FIXME("check\n"); + d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[2][2] * s0->z; + d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[2][2] * s0->z; + d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z; + d->w = 1.0f; +} + +void vshader_m3x2(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX32 mat) { + FIXME("check\n"); + d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z; + d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z; + d->z = 0.0f; + d->w = 1.0f; +} + +/** + * Version 2.0 specific + */ +void vshader_lrp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1, D3DSHADERVECTOR* s2, D3DSHADERVECTOR* s3) { + d->x = s0->x * (s1->x - s2->x) + s2->x; + d->y = s0->y * (s1->y - s2->y) + s2->y; + d->z = s0->z * (s1->z - s2->z) + s2->z; + d->w = s0->w * (s1->w - s2->w) + s2->x; +} + +/** * log, exp, frc, m*x* seems to be macros ins ... to see */ static CONST SHADER_OPCODE vshader_ins [] = { + {D3DSIO_NOP, "nop", 0, vshader_nop}, {D3DSIO_MOV, "mov", 2, vshader_mov}, - {D3DSIO_MAX, "max", 3, vshader_max}, - {D3DSIO_MIN, "min", 3, vshader_min}, - {D3DSIO_SGE, "sge", 3, vshader_sge}, - {D3DSIO_SLT, "slt", 3, vshader_slt}, {D3DSIO_ADD, "add", 3, vshader_add}, {D3DSIO_SUB, "sub", 3, vshader_sub}, + {D3DSIO_MAD, "mad", 4, vshader_mad}, {D3DSIO_MUL, "mul", 3, vshader_mul}, {D3DSIO_RCP, "rcp", 2, vshader_rcp}, - {D3DSIO_MAD, "mad", 4, vshader_mad}, + {D3DSIO_RSQ, "rsq", 2, vshader_rsq}, {D3DSIO_DP3, "dp3", 3, vshader_dp3}, {D3DSIO_DP4, "dp4", 3, vshader_dp4}, - {D3DSIO_RSQ, "rsq", 2, vshader_rsq}, - {D3DSIO_DST, "dst", 3, vshader_dst}, + {D3DSIO_MIN, "min", 3, vshader_min}, + {D3DSIO_MAX, "max", 3, vshader_max}, + {D3DSIO_SLT, "slt", 3, vshader_slt}, + {D3DSIO_SGE, "sge", 3, vshader_sge}, + {D3DSIO_EXP, "exp", 2, vshader_exp}, + {D3DSIO_LOG, "log", 2, vshader_log}, {D3DSIO_LIT, "lit", 2, vshader_lit}, + {D3DSIO_DST, "dst", 3, vshader_dst}, + {D3DSIO_LRP, "lrp", 5, vshader_lrp}, + {D3DSIO_FRC, "frc", 2, vshader_frc}, + {D3DSIO_M4x4, "m4x4", 3, vshader_m4x4}, + {D3DSIO_M4x3, "m4x3", 3, vshader_m4x3}, + {D3DSIO_M3x4, "m3x4", 3, vshader_m3x4}, + {D3DSIO_M3x3, "m3x3", 3, vshader_m3x3}, + {D3DSIO_M3x2, "m3x2", 3, vshader_m3x2}, + /** FIXME: use direct acces so add the others opcodes as stubs */ {D3DSIO_EXPP, "expp", 2, vshader_expp}, {D3DSIO_LOGP, "logp", 2, vshader_logp}, - {D3DSIO_NOP, "nop", 0, vshader_nop}, + {0, NULL, 0, NULL} }; @@ -352,6 +461,14 @@ } } +inline static BOOL vshader_is_version_token(DWORD token) { + return 0xFFFE0000 == (token & 0xFFFE0000); +} + +inline static BOOL vshader_is_comment_token(DWORD token) { + return D3DSIO_COMMENT == (token & D3DSI_OPCODE_MASK); +} + /** * Function parser ... */ @@ -363,13 +480,27 @@ if (NULL != pToken) { while (D3DVS_END() != *pToken) { + if (vshader_is_version_token(*pToken)) { /** version */ + DPRINTF("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F)); + ++pToken; + ++len; + continue; + } + if (vshader_is_comment_token(*pToken)) { /** comment */ + DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + ++pToken; + /*DPRINTF("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/ + pToken += comment_len; + len += comment_len + 1; + continue; + } curOpcode = vshader_program_get_opcode(*pToken); ++pToken; ++len; if (NULL == curOpcode) { /* unkown current opcode ... */ while (*pToken & 0x80000000) { - DPRINTF("unrecognized opcode: %08lX\n", *pToken); + DPRINTF("unrecognized opcode: %08lx\n", *pToken); ++pToken; ++len; } @@ -426,7 +557,9 @@ D3DSHADERVECTOR* p_send[4]; DWORD i; + /** init temporary register */ memset(R, 0, 12 * sizeof(D3DSHADERVECTOR)); + /* vshader_program_parse(vshader); */ /* TRACE_VECTOR(vshader->data->C[0]); @@ -449,13 +582,29 @@ /* the first dword is the version tag */ /* TODO: parse it */ + if (vshader_is_version_token(*pToken)) { /** version */ + ++pToken; + } while (D3DVS_END() != *pToken) { + if (vshader_is_comment_token(*pToken)) { /** comment */ + DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + ++pToken; + pToken += comment_len; + continue ; + } curOpcode = vshader_program_get_opcode(*pToken); ++pToken; if (NULL == curOpcode) { + i = 0; /* unkown current opcode ... */ while (*pToken & 0x80000000) { - DPRINTF("unrecognized opcode: pos=%d token=%08lX\n", pToken - vshader->function, *pToken); + if (i == 0) { + DPRINTF("unrecognized opcode: pos=%d token=%08lX\n", (pToken - 1) - vshader->function, *(pToken - 1)); + } + DPRINTF("unrecognized opcode param: pos=%d token=%08lX what=", pToken - vshader->function, *pToken); + vshader_program_dump_param(*pToken, i); + DPRINTF("\n"); + ++i; ++pToken; } /*return FALSE;*/ @@ -561,6 +710,9 @@ case 4: curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3]); break; + case 5: + curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3], p_send[4]); + break; default: ERR("%s too many params: %u\n", curOpcode->name, curOpcode->num_params); } @@ -678,6 +830,7 @@ const DWORD* pToken = vshader->decl; DWORD fvf = 0; DWORD len = 0; + DWORD stream = 0; DWORD token; DWORD tokenlen; DWORD tokentype; @@ -686,12 +839,19 @@ while (D3DVSD_END() != *pToken) { token = *pToken; tokenlen = vshader_decl_parse_token(pToken); - tokentype = ((*pToken & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); + tokentype = ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); /** FVF generation block */ - if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 == (0x10000000 & tokentype)) { + if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { + /** + * how really works streams, + * in DolphinVS dx8 dsk sample they seems to decal reg numbers !!! + */ + stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT); + + } else if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 == (0x10000000 & tokentype)) { DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); - DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT); + DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT) - stream; switch (reg) { case D3DVSDE_POSITION: @@ -699,7 +859,7 @@ case D3DVSDT_FLOAT3: fvf |= D3DFVF_XYZ; break; case D3DVSDT_FLOAT4: fvf |= D3DFVF_XYZRHW; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_POSITION register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_POSITION register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -710,7 +870,7 @@ case D3DVSDT_FLOAT3: fvf |= D3DFVF_XYZB3; break; case D3DVSDT_FLOAT4: fvf |= D3DFVF_XYZB4; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_BLENDWEIGHT register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_BLENDWEIGHT register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -718,7 +878,7 @@ switch (type) { case D3DVSDT_UBYTE4: fvf |= D3DFVF_LASTBETA_UBYTE4; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_BLENDINDINCES register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_BLENDINDINCES register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -726,7 +886,7 @@ switch (type) { case D3DVSDT_FLOAT3: fvf |= D3DFVF_NORMAL; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_NORMAL register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_NORMAL register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -734,7 +894,7 @@ switch (type) { case D3DVSDT_FLOAT1: fvf |= D3DFVF_PSIZE; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_PSIZE register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_PSIZE register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -742,7 +902,7 @@ switch (type) { case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_DIFFUSE; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_DIFFUSE register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_DIFFUSE register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -750,7 +910,7 @@ switch (type) { case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_SPECULAR; break; default: /** errooooorr what to do ? */ - ERR("Error in VertexShader declaration of D3DVSDE_SPECULAR register: unsupported type %lu\n", type); + ERR("Error in VertexShader declaration of D3DVSDE_SPECULAR register: unsupported type %s\n", VertexShaderDeclDataTypes[type]); } break; @@ -787,18 +947,211 @@ return len * sizeof(DWORD); } + +void vshader_fill_input(VERTEXSHADER8* vshader, + IDirect3DDevice8Impl* device, + const void* vertexFirstStream, + DWORD StartVertexIndex, + DWORD idxDecal) { + /** parser data */ + const DWORD* pToken = vshader->decl; + DWORD stream = 0; + DWORD token; + /*DWORD tokenlen;*/ + DWORD tokentype; + /** for input readers */ + const void* curPos = NULL; + FLOAT x, y, z, w; + SHORT u, v, r, t; + DWORD dw; + + /*TRACE("(%p) - device:%p - stream:%p, startIdx=%lu, idxDecal=%lu\n", vshader, device, vertexFirstStream, StartVertexIndex, idxDecal);*/ + while (D3DVSD_END() != *pToken) { + token = *pToken; + tokentype = ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); + + /** FVF generation block */ + if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { + IDirect3DVertexBuffer8* pVB; + const void* startVtx = NULL; + int skip = 0; + + ++pToken; + /** + * how really works streams, + * in DolphinVS dx8 dsk sample use it !!! + */ + stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT); + + if (0 == stream) { + skip = device->StateBlock.stream_stride[0]; + startVtx = vertexFirstStream + (StartVertexIndex * skip); + curPos = startVtx + idxDecal; + /*TRACE(" using stream[%lu] with %lu decal => curPos %p\n", stream, idxDecal, curPos);*/ + } else { + skip = device->StateBlock.stream_stride[stream]; + pVB = device->StateBlock.stream_source[stream]; + + if (NULL == pVB) { + ERR("using unitialised stream[%lu]\n", stream); + return ; + } else { + startVtx = ((IDirect3DVertexBuffer8Impl*) pVB)->allocatedMemory + (StartVertexIndex * skip); + /** do we need to decal if we use idxBuffer */ + curPos = startVtx + idxDecal; + /*TRACE(" using stream[%lu] with %lu decal\n", stream, idxDecal);*/ + } + } + } else if (D3DVSD_TOKEN_CONSTMEM == tokentype) { + /** Const decl */ + DWORD i; + DWORD count = ((token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT); + DWORD constaddress = ((token & D3DVSD_CONSTADDRESSMASK) >> D3DVSD_CONSTADDRESSSHIFT); + ++pToken; + for (i = 0; i < count; ++i) { + vshader->data->C[constaddress + i].x = *(float*)pToken; + vshader->data->C[constaddress + i].y = *(float*)(pToken + 1); + vshader->data->C[constaddress + i].z = *(float*)(pToken + 2); + vshader->data->C[constaddress + i].w = *(float*)(pToken + 3); + pToken += 4; + } + + } else if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 != (0x10000000 & tokentype)) { + /** skip datas */ + DWORD skipCount = ((token & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT); + curPos = curPos + skipCount * sizeof(DWORD); + ++pToken; + + } else if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 == (0x10000000 & tokentype)) { + DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); + DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT); + ++pToken; + + switch (type) { + case D3DVSDT_FLOAT1: + x = *(float*) curPos; + curPos = curPos + sizeof(float); + /**/ + vshader->input.V[reg].x = x; + vshader->input.V[reg].y = 0.0f; + vshader->input.V[reg].z = 0.0f; + vshader->input.V[reg].w = 1.0f; + break; + + case D3DVSDT_FLOAT2: + x = *(float*) curPos; + curPos = curPos + sizeof(float); + y = *(float*) curPos; + curPos = curPos + sizeof(float); + /**/ + vshader->input.V[reg].x = x; + vshader->input.V[reg].y = y; + vshader->input.V[reg].z = 0.0f; + vshader->input.V[reg].w = 1.0f; + break; + + case D3DVSDT_FLOAT3: + x = *(float*) curPos; + curPos = curPos + sizeof(float); + y = *(float*) curPos; + curPos = curPos + sizeof(float); + z = *(float*) curPos; + curPos = curPos + sizeof(float); + /**/ + vshader->input.V[reg].x = x; + vshader->input.V[reg].y = y; + vshader->input.V[reg].z = z; + vshader->input.V[reg].w = 1.0f; + break; + + case D3DVSDT_FLOAT4: + x = *(float*) curPos; + curPos = curPos + sizeof(float); + y = *(float*) curPos; + curPos = curPos + sizeof(float); + z = *(float*) curPos; + curPos = curPos + sizeof(float); + w = *(float*) curPos; + curPos = curPos + sizeof(float); + /**/ + vshader->input.V[reg].x = x; + vshader->input.V[reg].y = y; + vshader->input.V[reg].z = z; + vshader->input.V[reg].w = w; + break; + + case D3DVSDT_D3DCOLOR: + dw = *(DWORD*) curPos; + curPos = curPos + sizeof(DWORD); + /**/ + vshader->input.V[reg].x = (float) (((dw >> 16) & 0xFF) / 255.0f); + vshader->input.V[reg].y = (float) (((dw >> 8) & 0xFF) / 255.0f); + vshader->input.V[reg].z = (float) (((dw >> 0) & 0xFF) / 255.0f); + vshader->input.V[reg].w = (float) (((dw >> 24) & 0xFF) / 255.0f); + break; + + case D3DVSDT_SHORT2: + u = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + v = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + /**/ + vshader->input.V[reg].x = (float) u; + vshader->input.V[reg].y = (float) v; + vshader->input.V[reg].z = 0.0f; + vshader->input.V[reg].w = 1.0f; + break; + + case D3DVSDT_SHORT4: + u = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + v = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + t = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + t = *(SHORT*) curPos; + curPos = curPos + sizeof(SHORT); + /**/ + vshader->input.V[reg].x = (float) u; + vshader->input.V[reg].y = (float) v; + vshader->input.V[reg].z = (float) r; + vshader->input.V[reg].w = (float) t; + break; + + case D3DVSDT_UBYTE4: + dw = *(DWORD*) curPos; + curPos = curPos + sizeof(DWORD); + /**/ + vshader->input.V[reg].x = (float) ((dw & 0x000F) >> 0); + vshader->input.V[reg].y = (float) ((dw & 0x00F0) >> 8); + vshader->input.V[reg].z = (float) ((dw & 0x0F00) >> 16); + vshader->input.V[reg].w = (float) ((dw & 0xF000) >> 24); + + break; + + default: /** errooooorr what to do ? */ + ERR("Error in VertexShader declaration of %s register: unsupported type %s\n", VertexShaderDeclRegister[reg], VertexShaderDeclDataTypes[type]); + } + } + + } + /* here D3DVSD_END() */ +} + + /*********************************************************************** * ValidateVertexShader (D3D8.@) */ BOOL WINAPI ValidateVertexShader(LPVOID what, LPVOID toto) { - FIXME("(void): stub: %p\n", what); + FIXME("(void): stub: %p %p\n", what, toto); return TRUE; } /*********************************************************************** * ValidatePixelShader (D3D8.@) */ -BOOL WINAPI ValidatePixelShader(LPVOID what, LPVOID toto) { +BOOL WINAPI ValidatePixelShader(LPVOID what) { FIXME("(void): stub: %p\n", what); return TRUE; } + Index: dlls/d3d8/surface.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/surface.c,v retrieving revision 1.4 diff -u -r1.4 surface.c --- dlls/d3d8/surface.c 8 Jan 2003 21:09:27 -0000 1.4 +++ dlls/d3d8/surface.c 10 Jan 2003 23:44:21 -0000 @@ -66,18 +66,18 @@ ICOM_THIS(IDirect3DSurface8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); *ppDevice = (LPDIRECT3DDEVICE8) This->Device; - - /* Note Calling this method will increase the internal reference count - on the IDirect3DDevice8 interface. */ + /** + * Note Calling this method will increase the internal reference count + * on the IDirect3DDevice8 interface. + */ IDirect3DDevice8Impl_AddRef(*ppDevice); - return D3D_OK; } -HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) { +HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { ICOM_THIS(IDirect3DSurface8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } -HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,void* pData,DWORD* pSizeOfData) { +HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { ICOM_THIS(IDirect3DSurface8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } @@ -85,15 +85,25 @@ ICOM_THIS(IDirect3DSurface8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } -HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid,void** ppContainer) { +HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void** ppContainer) { ICOM_THIS(IDirect3DSurface8Impl,iface); - - /* If the surface is created using CreateImageSurface, CreateRenderTarget, - or CreateDepthStencilSurface, the surface is considered stand alone. In this case, - GetContainer will return the Direct3D device used to create the surface. */ + HRESULT res; + /* TRACE("(%p) : returning %p\n", This, This->Container); *ppContainer = This->Container; return D3D_OK; + */ + res = IUnknown_QueryInterface(This->Container, riid, ppContainer); + if (E_NOINTERFACE == res) { + /** + * If the surface is created using CreateImageSurface, CreateRenderTarget, + * or CreateDepthStencilSurface, the surface is considered stand alone. In this case, + * GetContainer will return the Direct3D device used to create the surface. + */ + res = IUnknown_QueryInterface(This->Container, &IID_IDirect3DDevice8, ppContainer); + } + TRACE("(%p) : returning %p\n", This, *ppContainer); + return res; } HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) { ICOM_THIS(IDirect3DSurface8Impl,iface); @@ -121,7 +131,7 @@ ICOM_THIS(IDirect3DSurface8Impl,iface); TRACE("(%p) : stub\n", This); if (This->Container) { - IDirect3DBaseTexture8 *cont = This->Container; + IDirect3DBaseTexture8 *cont = (IDirect3DBaseTexture8*) This->Container; /* Now setup the texture appropraitly */ int containerType = IDirect3DBaseTexture8Impl_GetType(cont); Index: dlls/d3d8/texture.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/texture.c,v retrieving revision 1.3 diff -u -r1.3 texture.c --- dlls/d3d8/texture.c 18 Dec 2002 05:05:41 -0000 1.3 +++ dlls/d3d8/texture.c 10 Jan 2003 23:44:35 -0000 @@ -74,7 +74,12 @@ HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice) { ICOM_THIS(IDirect3DTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); - *ppDevice = (LPDIRECT3DDEVICE8) This->Device; + *ppDevice = (LPDIRECT3DDEVICE8) This->Device; + /** + * Note Calling this method will increase the internal reference count + * on the IDirect3DDevice8 interface. + */ + IDirect3DDevice8Impl_AddRef(*ppDevice); return D3D_OK; } HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { Index: dlls/d3d8/volumetexture.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/volumetexture.c,v retrieving revision 1.3 diff -u -r1.3 volumetexture.c --- dlls/d3d8/volumetexture.c 18 Dec 2002 05:05:41 -0000 1.3 +++ dlls/d3d8/volumetexture.c 10 Jan 2003 23:44:54 -0000 @@ -77,6 +77,11 @@ ICOM_THIS(IDirect3DVolumeTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); *ppDevice = (LPDIRECT3DDEVICE8) This->Device; + /** + * Note Calling this method will increase the internal reference count + * on the IDirect3DDevice8 interface. + */ + IDirect3DDevice8Impl_AddRef(*ppDevice); return D3D_OK; } HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {