Commit 1df8f18e authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- some fixes in CreateDevice init

- vertex shader declaration parser (with output dump) and interpretation (generate the FVF descriptor for program input) - vertex shader program parser (with output dump) - software vertex shader program emulation
parent 9fcfd2c3
......@@ -170,8 +170,8 @@ typedef SHADER8Vector SHADER8Constants[SHADER_MAX_CONSTANTS];
typedef struct SHADER8Data {
/** Run Time Shader Function Constants */
/*D3DXBUFFER* constants; */
SHADER8Constants constants;
/*D3DXBUFFER* constants;*/
SHADER8Constants C;
/** Shader Code as char ... */
CONST DWORD* code;
UINT codeLength;
......@@ -184,6 +184,8 @@ typedef struct VERTEXSHADER8 { /* TODO: Vertex Shader */
UINT declLength;
UINT functionLength;
DWORD fvf;
/* run time datas */
SHADER8Data* data;
} VERTEXSHADER8;
......@@ -905,4 +907,11 @@ extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLU
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level);
extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox);
/*******************
* private functions
*/
DWORD vshader_decl_parse(VERTEXSHADER8* vshader);
DWORD vshader_program_parse(VERTEXSHADER8* vshader);
#endif /* __WINE_D3DX8_PRIVATE_H */
......@@ -2153,6 +2153,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
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); */
TRACE("(%p)->(%d,%ld) not handled yet\n", This, State, Value);
break;
......@@ -3128,7 +3130,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface
VERTEXSHADER8* object;
UINT i;
FIXME("(%p) : VertexShader not fully supported yet\n", This);
FIXME("(%p) : VertexShader not fully supported yet : Decl=%p, Func=%p\n", This, pDeclaration, pFunction);
if (NULL == pDeclaration || NULL == pHandle) { /* pFunction can be NULL see MSDN */
return D3DERR_INVALIDCALL;
}
......@@ -3142,21 +3144,26 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface
}
object->usage = Usage;
object->data = NULL; /* TODO */
object->data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHADER8Data));
VertexShaders[i] = object;
*pHandle = VS_HIGHESTFIXEDFXF + i;
object->decl = pDeclaration;
object->function = pFunction;
/*
for (i = 0; 0xFFFFFFFF != pDeclaration[i]; ++i) ;
object->declLength = i + 1;
object->function = pFunction;
if (NULL != pFunction) {
for (i = 0; 0xFFFFFFFF != pFunction[i]; ++i) ;
object->functionLength = i + 1;
} else {
object->functionLength = 1; /* no Function defined use fixed function vertex processing */
object->functionLength = 1; // no Function defined use fixed function vertex processing
}
*/
vshader_decl_parse(object);
vshader_program_parse(object);
return D3D_OK;
}
......@@ -3172,7 +3179,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, D
TRACE("Recording... not performing anything\n");
return D3D_OK;
}
if (Handle <= VS_HIGHESTFIXEDFXF) {
TRACE("(%p) : FVF Shader, Handle=%lx\n", This, Handle);
return D3D_OK;
......@@ -3196,10 +3202,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface
return D3DERR_INVALIDCALL;
}
object = VertexShaders[Handle - VS_HIGHESTFIXEDFXF];
if (NULL == object) {
return D3DERR_INVALIDCALL;
}
TRACE("(%p) : freing VertexShader %p\n", This, object);
/* TODO: check validity of object */
if (NULL != object->data) HeapFree(GetProcessHeap(), 0, (void *)object->data);
HeapFree(GetProcessHeap(), 0, (void *)object);
VertexShaders[Handle - VS_HIGHESTFIXEDFXF] = 0;
VertexShaders[Handle - VS_HIGHESTFIXEDFXF] = NULL;
return D3D_OK;
}
......@@ -3210,8 +3220,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8
VERTEXSHADER8* object;
DWORD Handle = This->UpdateStateBlock->VertexShader;
FIXME("(%p) : VertexShader_SetConstant not fully supported yet\n", This);
/* FIXME("(%p) : VertexShader_SetConstant not fully supported yet\n", This); */
if (Register + ConstantCount > VSHADER_MAX_CONSTANTS) {
return D3DERR_INVALIDCALL;
}
......@@ -3219,7 +3228,11 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8
if (NULL == object || NULL == pConstantData) {
return D3DERR_INVALIDCALL;
}
memcpy(object->data->constants + Register, pConstantData, ConstantCount * sizeof(SHADER8Vector));
if (NULL == object->data) { /* temporary while datas not supported */
FIXME("(%p) : VertexShader_SetConstant not fully supported yet\n", This);
return D3DERR_INVALIDCALL;
}
memcpy(object->data->C + Register, pConstantData, ConstantCount * sizeof(SHADER8Vector));
return D3D_OK;
}
......@@ -3237,7 +3250,10 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8
if (NULL == object || NULL == pConstantData) {
return D3DERR_INVALIDCALL;
}
memcpy(pConstantData, object->data->constants + Register, ConstantCount * sizeof(SHADER8Vector));
if (NULL == object->data) { /* temporary while datas not supported */
return D3DERR_INVALIDCALL;
}
memcpy(pConstantData, object->data->C + Register, ConstantCount * sizeof(SHADER8Vector));
return D3D_OK;
}
......@@ -3288,10 +3304,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8
}
HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
IDirect3DIndexBuffer8 *oldIdxs;
ICOM_THIS(IDirect3DDevice8Impl,iface);
TRACE("(%p) : Setting to %p, base %d\n", This, pIndexData, BaseVertexIndex);
oldIdxs = This->StateBlock.pIndexData;
......
......@@ -382,7 +382,10 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
IDirect3DDevice8** ppReturnedDeviceInterface) {
IDirect3DDevice8Impl *object;
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,
......@@ -390,6 +393,9 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice8Impl));
if (NULL == object) {
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DDevice8_Vtbl;
object->ref = 1;
object->direct3d8 = This;
......@@ -417,6 +423,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
HDC hDc;
int dblBuf[]={GLX_STENCIL_SIZE,8,GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
/* FIXME: Handle stencil appropriately via EnableAutoDepthStencil / AutoDepthStencilFormat */
/*int dblBuf[]={GLX_RGBA,GLX_RED_SIZE,4,GLX_GREEN_SIZE,4,GLX_BLUE_SIZE,4,GLX_DOUBLEBUFFER,None}; */
/* Which hwnd are we using? */
/* if (pPresentationParameters->Windowed) { */
......@@ -438,11 +445,31 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
ENTER_GL();
object->visInfo = glXChooseVisual(object->display, DefaultScreen(object->display), dblBuf);
object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
if (NULL == object->visInfo) {
FIXME("cannot choose needed glxVisual with Stencil Buffer\n");
/**
* second try using wine initialized visual ...
* must be fixed reworking wine-glx init
*/
template.visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
object->visInfo = XGetVisualInfo(object->display, VisualIDMask, &template, &num);
if (NULL == object->visInfo) {
ERR("cannot really get XVisual\n");
LEAVE_GL();
return D3DERR_NOTAVAILABLE;
}
}
object->glCtx = glXCreateContext(object->display, object->visInfo, NULL, GL_TRUE);
if (NULL == object->visInfo) {
ERR("cannot create glxContext\n");
LEAVE_GL();
return D3DERR_NOTAVAILABLE;
}
LEAVE_GL();
ReleaseDC(whichHWND, hDc);
ReleaseDC(whichHWND, hDc);
}
if (object->glCtx == NULL) {
......@@ -492,8 +519,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
ENTER_GL();
if (glXMakeCurrent(object->display, object->win, object->glCtx) == False) {
ERR("Error in setting current context (context %p drawable %ld)!\n",
object->glCtx, object->win);
ERR("Error in setting current context (context %p drawable %ld)!\n", object->glCtx, object->win);
}
checkGLcall("glXMakeCurrent");
......@@ -509,7 +535,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
checkGLcall("glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
/* Setup all the devices defaults */
......@@ -519,6 +545,9 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
GL_Extensions = glGetString(GL_EXTENSIONS);
TRACE("GL_Extensions reported:\n");
if (NULL == GL_Extensions) {
ERR(" GL_Extensions returns NULL\n");
} else {
while (*GL_Extensions!=0x00) {
const char *Start = GL_Extensions;
char ThisExtn[256];
......@@ -531,9 +560,36 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
TRACE (" %s\n", ThisExtn);
if (*GL_Extensions==' ') GL_Extensions++;
}
}
GLX_Extensions = glXQueryExtensionsString(object->display, DefaultScreen(object->display));
TRACE("GLX_Extensions reported:\n");
if (NULL == GLX_Extensions) {
ERR(" GLX_Extensions returns NULL\n");
} else {
while (*GLX_Extensions!=0x00) {
const char *Start = GLX_Extensions;
char ThisExtn[256];
memset(ThisExtn, 0x00, sizeof(ThisExtn));
while (*GLX_Extensions!=' ' && *GLX_Extensions!=0x00) {
GLX_Extensions++;
}
memcpy(ThisExtn, Start, (GLX_Extensions-Start));
TRACE (" %s\n", ThisExtn);
if (*GLX_Extensions==' ') GLX_Extensions++;
}
}
LEAVE_GL();
{
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);
}
{ /* Set a default viewport */
D3DVIEWPORT8 vp;
vp.X = 0;
......
......@@ -107,7 +107,7 @@ D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
return This->ResourceType;
}
/* IDirect3DTexture8 (Inherited from IDirect3DBaseTexture8) */
/* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
ICOM_THIS(IDirect3DTexture8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
......
......@@ -36,7 +36,9 @@ HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTUR
TRACE("(%p) : QueryInterface\n", This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IClassFactory)) {
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|| IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
IDirect3DVolumeTexture8Impl_AddRef(iface);
*ppobj = This;
return D3D_OK;
......@@ -55,7 +57,7 @@ ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface)
ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
ULONG ref = --This->ref;
int i;
UINT i;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
......@@ -107,7 +109,7 @@ D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTU
return This->ResourceType;
}
/* IDirect3DVolumeTexture8 (Inherited from IDirect3DBaseTexture8) */
/* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment