Commit e4882b15 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- cleaning of volume.c/volumetexture.c as done previously for

surface.c/*texture.c (with add of lockable, locked and Dirty flags) - add of dirtyRect/dirtyBox for better dirtification management (not used yet, but huge optimisation can be possible now) - fix some debug traces (well it's better to use debug_d3dpool) - fix some stupid regression on point parameters (forgot to check extension on fillcaps)
parent 713013a9
......@@ -123,21 +123,6 @@ DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEX
return 0;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
return This->Dirty;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
BOOL old;
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
old = This->Dirty;
This->Dirty = dirty;
return old;
}
ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
......@@ -156,3 +141,17 @@ ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl =
IDirect3DBaseTexture8Impl_GetLOD,
IDirect3DBaseTexture8Impl_GetLevelCount,
};
BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
return This->Dirty;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
BOOL old;
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
old = This->Dirty;
This->Dirty = dirty;
return old;
}
......@@ -175,28 +175,6 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
for (j = 0; j < 6; j++) {
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%x, Mem=%p\n",
cube_targets[j],
i,
fmt2glintFmt(This->format),
This->surfaces[j][i]->myDesc.Width,
This->surfaces[j][i]->myDesc.Height,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
glTexImage2D(cube_targets[j],
i,
fmt2glintFmt(This->format),
This->surfaces[j][i]->myDesc.Width,
This->surfaces[j][i]->myDesc.Height,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
#if 0
static int gen = 0;
char buffer[4096];
snprintf(buffer, sizeof(buffer), "/tmp/cube%d_face%d_level%d_%d.png", This->surfaces[0][0]->textureName, j, i, ++gen);
......@@ -266,7 +244,7 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8_LockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level], pLockedRect, pRect, Flags);
TRACE("(%p) -> faceType(%d) level(%d) returning memory@%p success(%lu)\n", This, FaceType, Level, pLockedRect->pBits, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
......@@ -278,8 +256,8 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTUR
HRESULT hr;
ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
if (Level < This->levels) {
hr = IDirect3DSurface8_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level]);
FIXME("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][Level]);
TRACE("(%p) -> faceType(%d) level(%d) success(%lu)\n", This, FaceType, Level, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
......@@ -289,8 +267,8 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTUR
HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
This->Dirty = TRUE;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[FaceType][0], pDirtyRect);
}
......
......@@ -495,6 +495,12 @@ struct IDirect3DVolume8Impl
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
D3DBOX lockedBox;
D3DBOX dirtyBox;
BOOL Dirty;
};
/* IUnknown: */
......@@ -509,9 +515,12 @@ extern HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 ifac
extern HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid);
extern HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer);
extern HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc);
extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox, DWORD Flags);
extern HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags);
extern HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface);
/* internal Interfaces */
extern HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface);
extern HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox);
/* ------------------- */
/* IDirect3DSwapChain8 */
......@@ -540,7 +549,6 @@ struct IDirect3DSwapChain8Impl
/* OpenGL/GLX related */
GLXContext swap_ctx;
Drawable swap_drawable;
};
/* IUnknown: */
......@@ -584,8 +592,8 @@ struct IDirect3DSurface8Impl
BOOL lockable;
BOOL locked;
RECT lockedRect;
RECT dirtyRect;
BOOL Dirty;
};
/* IUnknown: */
......@@ -606,7 +614,8 @@ extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)
/* internal Interfaces */
extern HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
extern HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename);
extern HRESULT WINAPI IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface);
extern HRESULT WINAPI IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface, CONST RECT* pDirtyRect);
/* ------------------ */
/* IDirect3DResource8 */
......
......@@ -1340,7 +1340,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
ICOM_THIS(IDirect3DDevice8Impl,iface);
/* Allocate the storage for it */
TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), Pool);
TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, Width, Height, Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
object->ResourceType = D3DRTYPE_VOLUMETEXTURE;
......@@ -1399,6 +1399,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
volume->myDesc.Size = (Width * volume->bytesPerPixel) * Height * Depth;
volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
volume->lockable = TRUE;
volume->locked = FALSE;
memset(&volume->lockedBox, 0, sizeof(D3DBOX));
volume->Dirty = FALSE;
IDirect3DVolume8Impl_CleanDirtyBox((LPDIRECT3DVOLUME8) volume);
TRACE("(%p) : Volume at w(%d) h(%d) d(%d) fmt(%u,%s) surf@%p, surfmem@%p, %d bytes\n",
This, Width, Height, Depth, Format, debug_d3dformat(Format),
volume, volume->allocatedMemory, volume->myDesc.Size);
......@@ -1420,7 +1426,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
UINT tmpW;
/* Allocate the storage for it */
TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%d)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), Pool);
TRACE("(%p) : Len(%d), Lvl(%d) Usage(%ld), Fmt(%u,%s), Pool(%s)\n", This, EdgeLength, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
object->ref = 1;
......@@ -1466,7 +1472,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
}
TRACE("(%p) : Iface@%p\n", This, object);
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8)object;
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
......@@ -1488,7 +1494,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface
TRACE("(%p) : Size=%d, Usage=%ld, FVF=%lx, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->allocatedMemory, object);
*ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8)object;
*ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8) object;
return D3D_OK;
}
......@@ -1515,7 +1521,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface,
TRACE("(%p) : Iface@%p allocatedMem @ %p\n", This, object, object->allocatedMemory);
*ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8)object;
*ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8) object;
return D3D_OK;
}
......@@ -1547,6 +1553,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = Lockable;
object->locked = FALSE;
memset(&object->lockedRect, 0, sizeof(RECT));
IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
......@@ -1580,6 +1588,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
object->locked = FALSE;
memset(&object->lockedRect, 0, sizeof(RECT));
IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
......@@ -1608,6 +1618,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = TRUE;
object->locked = FALSE;
memset(&object->lockedRect, 0, sizeof(RECT));
IDirect3DSurface8Impl_CleanDirtyRect((LPDIRECT3DSURFACE8) object);
TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->myDesc.Size);
return D3D_OK;
......
......@@ -712,10 +712,12 @@ static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
} else if (strcmp(ThisExtn, "GL_EXT_fog_coord") == 0) {
FIXME(" FOUND: EXT Fog coord support\n");
This->gl_info.supported[EXT_FOG_COORD] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) {
/* handle paletted texture extensions */
} else if (strcmp(ThisExtn, "GL_EXT_paletted_texture") == 0) { /* handle paletted texture extensions */
FIXME(" FOUND: EXT Paletted texture support\n");
This->gl_info.supported[EXT_PALETTED_TEXTURE] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_point_parameters") == 0) {
FIXME(" FOUND: EXT Point parameters support\n");
This->gl_info.supported[EXT_POINT_PARAMETERS] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_secondary_color") == 0) {
FIXME(" FOUND: EXT Secondary coord support\n");
This->gl_info.supported[EXT_SECONDARY_COLOR] = TRUE;
......
......@@ -235,7 +235,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
* Dirtify on lock
* as seen in msdn docs
*/
This->Dirty = TRUE;
IDirect3DSurface8Impl_AddDirtyRect(iface, &This->lockedRect);
/** Dirtify Container if needed */
if (NULL != This->Container) {
IDirect3DBaseTexture8* cont = NULL;
......@@ -348,7 +349,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
vcheckGLcall("glRasterPos3iv");
LEAVE_GL();
This->Dirty = FALSE;
/** restore clean dirty state */
IDirect3DSurface8Impl_CleanDirtyRect(iface);
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This, This->myDesc.Usage);
......@@ -368,6 +370,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
unlock_end:
This->locked = FALSE;
memset(&This->lockedRect, 0, sizeof(RECT));
return D3D_OK;
}
......@@ -583,3 +586,27 @@ HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, cons
fclose(f);
return D3D_OK;
}
HRESULT WINAPI IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
This->Dirty = FALSE;
This->dirtyRect.left = This->myDesc.Width;
This->dirtyRect.top = This->myDesc.Height;
This->dirtyRect.right = 0;
This->dirtyRect.bottom = 0;
return D3D_OK;
}
/**
* Raphael:
* very stupid way to handle multiple dirty rects but it works :)
*/
extern HRESULT WINAPI IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface, CONST RECT* pDirtyRect) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
This->Dirty = TRUE;
This->dirtyRect.left = min(This->dirtyRect.left, pDirtyRect->left);
This->dirtyRect.top = min(This->dirtyRect.top, pDirtyRect->top);
This->dirtyRect.right = max(This->dirtyRect.right, pDirtyRect->right);
This->dirtyRect.bottom = max(This->dirtyRect.bottom, pDirtyRect->bottom);
return D3D_OK;
}
......@@ -135,28 +135,6 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
}
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_2D,
i,
D3DFmt2GLIntFmt(This->format),
This->surfaces[i]->myDesc.Width,
This->surfaces[i]->myDesc.Height,
0,
D3DFmt2GLFmt(This->format),
D3DFmt2GLType(This->format),
This->surfaces[i]->allocatedMemory);
glTexImage2D(GL_TEXTURE_2D,
i,
D3DFmt2GLIntFmt(This->format),
This->surfaces[i]->myDesc.Width,
This->surfaces[i]->myDesc.Height,
0,
D3DFmt2GLFmt(This->format),
D3DFmt2GLType(This->format),
This->surfaces[i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
......@@ -187,7 +165,7 @@ DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 if
}
/* IDirect3DTexture8 */
HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DSURFACE_DESC* pDesc) {
HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
ICOM_THIS(IDirect3DTexture8Impl,iface);
if (Level < This->levels) {
......@@ -199,7 +177,7 @@ HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 ifa
}
return D3D_OK;
}
HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level,IDirect3DSurface8** ppSurfaceLevel) {
HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8** ppSurfaceLevel) {
ICOM_THIS(IDirect3DTexture8Impl,iface);
*ppSurfaceLevel = (LPDIRECT3DSURFACE8)This->surfaces[Level];
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->surfaces[Level]);
......@@ -239,8 +217,8 @@ HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
ICOM_THIS(IDirect3DTexture8Impl,iface);
This->Dirty = TRUE;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
return IDirect3DSurface8Impl_AddDirtyRect((LPDIRECT3DSURFACE8) This->surfaces[0], pDirtyRect);
}
......
......@@ -116,12 +116,24 @@ HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_B
if (!pBox) {
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->allocatedMemory;
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->myDesc.Width;
This->lockedBox.Bottom = This->myDesc.Height;
This->lockedBox.Back = This->myDesc.Depth;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->allocatedMemory +
(pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
(pLockedVolume->RowPitch * pBox->Top) +
(pBox->Left * This->bytesPerPixel);
This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top;
This->lockedBox.Front = pBox->Front;
This->lockedBox.Right = pBox->Right;
This->lockedBox.Bottom = pBox->Bottom;
This->lockedBox.Back = pBox->Back;
}
if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
......@@ -131,6 +143,8 @@ HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_B
* Dirtify on lock
* as seen in msdn docs
*/
IDirect3DVolume8Impl_AddDirtyBox(iface, &This->lockedBox);
/** Dirtify Container if needed */
if (NULL != This->Container) {
IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
......@@ -144,24 +158,19 @@ HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_B
}
}
This->locked = TRUE;
TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
ICOM_THIS(IDirect3DVolume8Impl,iface);
TRACE("(%p) : stub\n", This);
#if 0
if (This->Container) {
IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
D3DRESOURCETYPE containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
if (containerType == D3DRTYPE_VOLUMETEXTURE) {
IDirect3DTexture8Impl* pTexture = (IDirect3DTexture8Impl*) cont;
pTexture->Dirty = TRUE;
} else {
FIXME("Set dirty on container type %d\n", containerType);
if (FALSE == This->locked) {
ERR("trying to lock unlocked volume@%p\n", This);
return D3DERR_INVALIDCALL;
}
}
#endif
TRACE("(%p) : unlocking volume\n", This);
This->locked = FALSE;
memset(&This->lockedBox, 0, sizeof(RECT));
return D3D_OK;
}
......@@ -181,3 +190,31 @@ ICOM_VTABLE(IDirect3DVolume8) Direct3DVolume8_Vtbl =
IDirect3DVolume8Impl_LockBox,
IDirect3DVolume8Impl_UnlockBox
};
HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface) {
ICOM_THIS(IDirect3DVolume8Impl,iface);
This->Dirty = FALSE;
This->lockedBox.Left = This->myDesc.Width;
This->lockedBox.Top = This->myDesc.Height;
This->lockedBox.Front = This->myDesc.Depth;
This->lockedBox.Right = 0;
This->lockedBox.Bottom = 0;
This->lockedBox.Back = 0;
return D3D_OK;
}
/**
* Raphael:
* very stupid way to handle multiple dirty box but it works :)
*/
HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox) {
ICOM_THIS(IDirect3DVolume8Impl,iface);
This->Dirty = TRUE;
This->lockedBox.Left = min(This->lockedBox.Left, pDirtyBox->Left);
This->lockedBox.Top = min(This->lockedBox.Top, pDirtyBox->Top);
This->lockedBox.Front = min(This->lockedBox.Front, pDirtyBox->Front);
This->lockedBox.Right = max(This->lockedBox.Right, pDirtyBox->Right);
This->lockedBox.Bottom = max(This->lockedBox.Bottom, pDirtyBox->Bottom);
This->lockedBox.Back = max(This->lockedBox.Back, pDirtyBox->Back);
return D3D_OK;
}
......@@ -230,20 +230,22 @@ HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTU
return hr;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
HRESULT hr;
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
if (Level < This->levels) {
TRACE("(%p) level(%d) stub\n", This, Level);
hr = IDirect3DVolume8Impl_UnlockBox((LPDIRECT3DVOLUME8) This->volumes[Level]);
TRACE("(%p) -> level(%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->levels);
return D3DERR_INVALIDCALL;
}
return D3D_OK;
return hr;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX* pDirtyBox) {
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
This->Dirty = TRUE;
FIXME("(%p) : stub\n", This);
return D3D_OK;
TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
return IDirect3DVolume8Impl_AddDirtyBox((LPDIRECT3DVOLUME8) This->volumes[0], pDirtyBox);
}
......
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