Implement UpdateTexture for 2D textures only.

Handle alphaop disabled but color op not-disable in a more appropriate
way (Docs say this is an illegal state and then proceed to use it).
Trace out textures as they are created.
Update the comments around the debug code and complete the debugging
set so textures which are used in the game can also be viewed.
This commit is contained in:
Jason Edmeades 2003-07-03 18:10:22 +00:00 committed by Alexandre Julliard
parent bd1173ca27
commit 021604c600
5 changed files with 59 additions and 21 deletions

View File

@ -1274,15 +1274,22 @@ const char *debug_d3dtexturestate(DWORD State);
# define FRAME_DEBUGGING
/* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
the file is deleted */
# if 1
# if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
# define SINGLE_FRAME_DEBUGGING
# endif
/* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
A check is made for the existence of C:\D3DSHOWFRAME, and if it exists will write the
contents of the back buffer into /tmp/backbuffer_* after each primitive array is drawn
for a single frame. At the end of the frame, the file is deleted. */
# if 1
It can only be enabled when FRAME_DEBUGGING is also enabled
The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
array is drawn. */
# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
# define SHOW_FRAME_MAKEUP 1
# endif
/* The following, when enabled, lets you see the makeup of the all the textures used during each
of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
The contents of the textures assigned to each stage are written into
/tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
# define SHOW_TEXTURE_MAKEUP 0
# endif
extern BOOL isOn;
extern BOOL isDumpingFrames;

View File

@ -462,6 +462,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UIN
}
*ppTexture = (LPDIRECT3DTEXTURE8) object;
TRACE("(%p) : Created texture %p\n", This, object);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface,
@ -552,6 +553,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
}
*ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8) object;
TRACE("(%p) : Created volume texture %p\n", This, object);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage,
@ -809,7 +811,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface,
IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) dst, &lrDst, NULL, 0L);
TRACE("Locked src and dst, Direct copy as surfaces are equal, w=%d, h=%d\n", dst->myDesc.Width, dst->myDesc.Height);
/*memcpy(dst->allocatedMemory, src->allocatedMemory, src->myDesc.Size);*/
memcpy(lrDst.pBits, lrSrc.pBits, src->myDesc.Size);
IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) src);
@ -917,7 +918,11 @@ HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDi
IDirect3DSurface8* dstSur = NULL;
hr = IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) src, i, &srcSur);
hr = IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) dst, i - skipLevels, &dstSur);
/*IDirect3DDevice8_CopyRects*/
/* Fixme: Work out how to just do the dirty regions (src or dst dirty region, and what
about dst with less levels than the source?) */
IDirect3DDevice8Impl_CopyRects(iface, srcSur, NULL, 0, dstSur, NULL);
IDirect3DSurface8Impl_Release(srcSur);
IDirect3DSurface8Impl_Release(dstSur);
}
@ -934,7 +939,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDi
for (j = 0; j < 5; ++j) {
hr = IDirect3DCubeTexture8Impl_GetCubeMapSurface((LPDIRECT3DCUBETEXTURE8) src, j, i, &srcSur);
hr = IDirect3DCubeTexture8Impl_GetCubeMapSurface((LPDIRECT3DCUBETEXTURE8) dst, j, i - skipLevels, &srcSur);
/*IDirect3DDevice8_CopyRects*/
FIXME("D3DRTYPE_CUBETEXTURE does not support UpdateTexture yet\n");
IDirect3DSurface8Impl_Release(srcSur);
IDirect3DSurface8Impl_Release(dstSur);
}
@ -2999,16 +3004,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
case D3DTSS_COLOROP :
{
if (Value == D3DTOP_DISABLE) {
if ((Value == D3DTOP_DISABLE) && (Type == D3DTSS_COLOROP)) {
/* TODO: Disable by making this and all later levels disabled */
if (Type == D3DTSS_COLOROP) {
glDisable(GL_TEXTURE_1D);
checkGLcall("Disable GL_TEXTURE_1D");
glDisable(GL_TEXTURE_2D);
checkGLcall("Disable GL_TEXTURE_2D");
glDisable(GL_TEXTURE_3D);
checkGLcall("Disable GL_TEXTURE_3D");
}
glDisable(GL_TEXTURE_1D);
checkGLcall("Disable GL_TEXTURE_1D");
glDisable(GL_TEXTURE_2D);
checkGLcall("Disable GL_TEXTURE_2D");
glDisable(GL_TEXTURE_3D);
checkGLcall("Disable GL_TEXTURE_3D");
break; /* Dont bother setting the texture operations */
} else {
/* Enable only the appropriate texture dimension */

View File

@ -1343,10 +1343,26 @@ void drawPrimitive(LPDIRECT3DDEVICE8 iface,
D3DLOCKED_RECT r;
char buffer[80];
IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->backBuffer, &r, NULL, D3DLOCK_READONLY);
sprintf(buffer, "/tmp/backbuffer_%ld.ppm", primCounter++);
sprintf(buffer, "/tmp/backbuffer_%ld.ppm", primCounter);
TRACE("Saving screenshot %s\n", buffer);
IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This->backBuffer, buffer);
IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->backBuffer);
#if defined(SHOW_TEXTURE_MAKEUP)
{
LPDIRECT3DSURFACE8 pSur;
int textureNo;
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
if (This->StateBlock->textures[textureNo] != NULL) {
sprintf(buffer, "/tmp/texture_%ld_%d.ppm", primCounter, textureNo);
TRACE("Saving texture %s\n", buffer);
IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) This->StateBlock->textures[textureNo], 0, &pSur);
IDirect3DSurface8Impl_SaveSnapshot(pSur, buffer);
}
}
}
#endif
primCounter = primCounter + 1;
}
}
#endif

View File

@ -120,8 +120,11 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
/* fixme: should we really lock as such? */
if (FALSE == This->lockable) {
ERR("trying to lock unlockable surf@%p\n", This);
return D3DERR_INVALIDCALL;
/* Note: UpdateTextures calls CopyRects which calls this routine to populate the
texture regions, and since the destination is an unlockable region we need
to tolerate this */
TRACE("Warning: trying to lock unlockable surf@%p\n", This);
/*return D3DERR_INVALIDCALL; */
}
if (This == This->Device->backBuffer || This == This->Device->renderTarget || This == This->Device->frontBuffer || This->Device->depthStencilBuffer) {

View File

@ -689,7 +689,6 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
ICOM_THIS(IDirect3DDevice8Impl,iface);
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();
@ -741,6 +740,16 @@ void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP o
Handled = TRUE; /* Assume will be handled */
switch (op) {
case D3DTOP_DISABLE: /* Only for alpha */
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
break;
case D3DTOP_SELECTARG1:
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");