Commit 44edc0c0 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- dsound and d3d works better when x11drv locks/unlocks are correct

- more traces
parent cf4e5d4e
......@@ -136,6 +136,9 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
int j;
ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->Dirty);
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->surfaces[0][0]->textureName != 0 && This->Dirty == FALSE) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
......@@ -185,6 +188,9 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
This->Dirty = FALSE;
}
}
LEAVE_GL();
return ;
}
......
......@@ -1289,7 +1289,7 @@ const char *debug_d3dtexturestate(DWORD State);
/* Some #defines for additional diagnostics */
#if 0 /* NOTE: Must be 0 in cvs */
/* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
of each frame, a check is made for the existance of C:\D3DTRACE, and if if exists d3d trace
of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
is enabled, and if it doesnt exists it is disabled. */
# define FRAME_DEBUGGING
/* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
......
......@@ -449,7 +449,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UIN
object->surfaces[i]->myDesc.Usage = Usage;
object->surfaces[i]->myDesc.Pool = Pool;
/**
* As writen in msdn in IDirect3DTexture8::LockRect
* As written in msdn in IDirect3DTexture8::LockRect
* Textures created in D3DPOOL_DEFAULT are not lockable.
*/
if (D3DPOOL_DEFAULT == Pool) {
......@@ -596,7 +596,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
object->surfaces[j][i]->myDesc.Usage = Usage;
object->surfaces[j][i]->myDesc.Pool = Pool;
/**
* As writen in msdn in IDirect3DCubeTexture8::LockRect
* As written in msdn in IDirect3DCubeTexture8::LockRect
* Textures created in D3DPOOL_DEFAULT are not lockable.
*/
if (D3DPOOL_DEFAULT == Pool) {
......@@ -1567,6 +1567,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST
return D3D_OK;
}
ENTER_GL();
TRACE("(%p) : x=%ld, y=%ld, wid=%ld, hei=%ld, minz=%f, maxz=%f\n", This,
pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height, pViewport->MinZ, pViewport->MaxZ);
......@@ -1577,6 +1579,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST
pViewport->Width, pViewport->Height);
checkGLcall("glViewport");
LEAVE_GL();
return D3D_OK;
......@@ -1668,6 +1671,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD In
return D3D_OK;
}
ENTER_GL();
/* Diffuse: */
colRGBA[0] = pLight->Diffuse.r;
colRGBA[1] = pLight->Diffuse.g;
......@@ -1780,6 +1785,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD In
/* Restore the modelview matrix */
glPopMatrix();
LEAVE_GL();
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
......@@ -1812,7 +1819,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD
TRACE("Recording... not performing anything\n");
return D3D_OK;
}
ENTER_GL();
if (Enable) {
glEnable(GL_LIGHT0 + Index);
checkGLcall("glEnable GL_LIGHT0+Index");
......@@ -1820,6 +1828,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD
glDisable(GL_LIGHT0 + Index);
checkGLcall("glDisable GL_LIGHT0+Index");
}
LEAVE_GL();
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
......@@ -1859,6 +1869,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWOR
/* Apply it */
ENTER_GL();
/* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
......@@ -1874,6 +1886,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWOR
glPopMatrix();
checkGLcall("glClipPlane");
LEAVE_GL();
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
......@@ -1907,6 +1921,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
return D3D_OK;
}
ENTER_GL();
switch (State) {
case D3DRS_FILLMODE :
switch ((D3DFILLMODE) Value) {
......@@ -1987,6 +2003,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
break;
case D3DSHADE_PHONG:
FIXME("D3DSHADE_PHONG isnt supported?\n");
LEAVE_GL();
return D3DERR_INVALIDCALL;
default:
FIXME("Unrecognized/Unhandled D3DSHADEMODE value %ld\n", Value);
......@@ -2235,7 +2253,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
/* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
specular color. This is wrong:
Seperate specular color means the specular colour is maintained seperately, whereas
Separate specular color means the specular colour is maintained separately, whereas
single color means it is merged in. However in both cases they are being used to
some extent.
To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
......@@ -2668,6 +2686,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
FIXME("(%p)->(%d,%ld) unrecognized\n", This, State, Value);
}
LEAVE_GL();
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
......@@ -2775,6 +2795,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD
return D3D_OK;
}
ENTER_GL();
/* Make appropriate texture active */
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
#if defined(GL_VERSION_1_3)
......@@ -2850,7 +2872,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD
if (reapplyStates) {
setupTextureStates(iface, Stage);
}
LEAVE_GL();
return D3D_OK;
}
......@@ -2884,6 +2908,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
return D3D_OK;
}
ENTER_GL();
/* Make appropriate texture active */
VTRACE(("Activating appropriate texture state %ld\n", Stage));
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
......@@ -3284,6 +3310,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
/* Put back later: FIXME("(%p) : stub, Stage=%ld, Type=%d, Value =%ld\n", This, Stage, Type, Value); */
TRACE("Still a stub, Stage=%ld, Type=%d, Value =%ld\n", Stage, Type, Value);
}
LEAVE_GL();
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
......@@ -3314,8 +3343,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : Setting to (%u)\n", This, PaletteNumber);
This->currentPalette = PaletteNumber;
#if defined(GL_EXT_paletted_texture)
if (GL_SUPPORT(EXT_PALETTED_TEXTURE)) {
ENTER_GL();
GL_EXTCALL(glColorTableEXT)(GL_TEXTURE_2D, /* target */
GL_RGBA, /* internal format */
256, /* table size */
......@@ -3323,6 +3356,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8
GL_UNSIGNED_BYTE, /* table type */
This->palettes[PaletteNumber]);
checkGLcall("glColorTableEXT");
LEAVE_GL();
} else {
/* Delayed palette handling ... waiting for software emulation into preload code */
}
......@@ -3430,7 +3466,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface
HRESULT res;
UINT i;
TRACE_(d3d_shader)("(%p) : VertexShader not fully supported yet : Decl=%p, Func=%p\n", This, pDeclaration, pFunction);
TRACE_(d3d_shader)("(%p) : VertexShader not fully supported yet : Decl=%p, Func=%p, Usage=%lu\n", This, pDeclaration, pFunction, Usage);
if (NULL == pDeclaration || NULL == pHandle) { /* pFunction can be NULL see MSDN */
return D3DERR_INVALIDCALL;
}
......@@ -3891,6 +3927,9 @@ ICOM_VTABLE(IDirect3DDevice8) Direct3DDevice8_Vtbl =
HRESULT WINAPI IDirect3DDevice8Impl_CleanRender(LPDIRECT3DDEVICE8 iface) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
#if defined(GL_VERSION_1_3) /* @see comments on ActiveRender */
ENTER_GL();
#if 0
if (This->glCtx != This->render_ctx) {
glXDestroyContext(This->display, This->render_ctx);
......@@ -3901,6 +3940,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_CleanRender(LPDIRECT3DDEVICE8 iface) {
glXDestroyPbuffer(This->display, This->drawable);
This->drawable = This->win;
}
LEAVE_GL();
#endif
return D3D_OK;
}
......@@ -3909,6 +3951,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
IDirect3DSurface8* RenderSurface,
IDirect3DSurface8* StencilSurface) {
HRESULT ret = D3DERR_INVALIDCALL;
/**
* Currently only active for GLX >= 1.3
* for others versions we'll have to use GLXPixmaps
......@@ -3918,7 +3961,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
* so only check OpenGL version
*/
#if defined(GL_VERSION_1_3)
GLXFBConfig* cfgs = NULL;
int nCfgs = 0;
int attribs[256];
......@@ -4022,6 +4064,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
PUSH1(None);
ENTER_GL();
cfgs = glXChooseFBConfig(This->display, DefaultScreen(This->display), attribs, &nCfgs);
if (NULL != cfgs) {
#if 0
......@@ -4096,7 +4140,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
return D3D_OK;
ret = D3D_OK;
} else {
ERR("cannot get valides GLXFBConfig for (%u,%s)/(%u,%s)\n", BackBufferFormat, debug_d3dformat(BackBufferFormat), StencilBufferFormat, debug_d3dformat(StencilBufferFormat));
......@@ -4105,7 +4149,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
#undef PUSH1
#undef PUSH2
LEAVE_GL();
#endif
return D3DERR_INVALIDCALL;
return ret;
}
......@@ -1295,7 +1295,8 @@ void drawPrimitive(LPDIRECT3DDEVICE8 iface,
drawStridedSoftwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives,
idxData, idxSize, minIndex, StartIdx);
} else if ((dataLocations.u.s.pSize.lpData != NULL) ||
} else if (/*TRUE ||*/
(dataLocations.u.s.pSize.lpData != NULL) ||
(dataLocations.u.s.diffuse.lpData != NULL) ||
(dataLocations.u.s.blendWeights.lpData != NULL)) {
......
......@@ -198,6 +198,8 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
texture stage, but disable all stages by default. Hence if a stage is enabled
then the default texture will kick in until replaced by a SetTexture call */
ENTER_GL();
for (i = 0; i < GL_LIMITS(textures); i++) {
GLubyte white = 255;
......@@ -235,6 +237,8 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
setupTextureStates(iface, i);
}
LEAVE_GL();
/* defaulting palettes */
for (i = 0; i < MAX_PALETTES; ++i) {
for (j = 0; j < 256; ++j) {
......
......@@ -209,7 +209,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
glReadBuffer(prev_read);
vcheckGLcall("glReadBuffer");
LEAVE_GL();
} else {
FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
}
......@@ -341,6 +343,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
vcheckGLcall("glDrawBuffer");
glRasterPos3iv(&prev_rasterpos[0]);
vcheckGLcall("glRasterPos3iv");
LEAVE_GL();
/** restore clean dirty state */
......@@ -412,6 +415,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
else
*dst++ = 0xFF;
}
ENTER_GL();
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
......@@ -435,6 +440,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
checkGLcall("glTexImage2D");
HeapFree(GetProcessHeap(), 0, surface);
LEAVE_GL();
return D3D_OK;
}
......@@ -452,6 +459,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
0,
This->myDesc.Size,
This->allocatedMemory);
ENTER_GL();
glCompressedTexImage2DARB(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
......@@ -461,6 +471,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
This->myDesc.Size,
This->allocatedMemory);
checkGLcall("glCommpressedTexTexImage2D");
LEAVE_GL();
}
#endif
} else {
......@@ -474,6 +486,9 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
D3DFmt2GLFmt(This->Device, This->myDesc.Format),
D3DFmt2GLType(This->Device, This->myDesc.Format),
This->allocatedMemory);
ENTER_GL();
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
......@@ -485,6 +500,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenu
This->allocatedMemory);
checkGLcall("glTexImage2D");
LEAVE_GL();
#if 0
{
static unsigned int gen = 0;
......
......@@ -110,6 +110,9 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
int i;
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) : About to load texture\n", This);
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName);
......@@ -139,6 +142,9 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
This->Dirty = FALSE;
}
}
LEAVE_GL();
return ;
}
D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
......
......@@ -691,6 +691,8 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
TRACE("Alpha?(%d), Stage:%d Op(%d), a1(%ld), a2(%ld), a3(%ld)\n", isAlpha, Stage, op, arg1, arg2, arg3);
if (op == D3DTOP_DISABLE) return;
ENTER_GL();
/* Note: Operations usually involve two ars, src0 and src1 and are operations of
the form (a1 <operation> a2). However, some of the more complex operations
take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
......@@ -1005,6 +1007,8 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
default:
FIXME("Cant have COMBINE4 and COMBINE in efferct together, thisop=%d, otherop=%ld, isAlpha(%d)\n",
op, op2, isAlpha);
LEAVE_GL();
return;
}
}
......@@ -1013,6 +1017,8 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
if (combineOK == TRUE) {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE));
checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
LEAVE_GL();
return;
}
}
......@@ -1253,10 +1259,14 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
if (Handled) {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
return;
LEAVE_GL();
return;
}
#endif /* GL_NV_texture_env_combine4 */
LEAVE_GL();
/* After all the extensions, if still unhandled, report fixme */
FIXME("Unhandled texture operation %d\n", op);
}
......
......@@ -114,6 +114,9 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
int i;
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
TRACE("(%p) : About to load texture\n", This);
ENTER_GL();
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->volumes[i]->textureName != 0 && This->Dirty == FALSE) {
glBindTexture(GL_TEXTURE_3D, This->volumes[i]->textureName);
......@@ -164,6 +167,9 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
This->Dirty = FALSE;
}
}
LEAVE_GL();
return ;
}
D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
......
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