Commit 3cae8cfa authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- implemented render to surfaces (and render to new rendertargets)

using glx pbuffers (with a useful debug code to display rendered surface into window drawable) - better cubetextures - split utilities functions into utils.c and added more - more readable debug again - a better caps code (not perfect but i'll use glx code later) - use of the new caps code - begin of UpdateTexture - begin of Cursor support - cleaning most of deprecated #if 0/#endif - correct some lockable/unlockable behavior - correct some returns code
parent c312ff95
......@@ -23,6 +23,7 @@ C_SRCS = \
surface.c \
swapchain.c \
texture.c \
utils.c \
vertexbuffer.c \
volume.c \
volumetexture.c \
......
......@@ -123,6 +123,21 @@ 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
......
......@@ -140,7 +140,7 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
if (i == 0 && This->surfaces[0][i]->textureName != 0 && This->Dirty == FALSE) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
#endif
......@@ -173,10 +173,17 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
}
for (j = 0; j < 6; j++) {
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%lx, 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),
IDirect3DSurface8Impl_CreateGLTexture((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,
......@@ -188,6 +195,7 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
}
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
......
......@@ -101,6 +101,30 @@ D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface)
return This->ResourceType;
}
D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
ICOM_THIS(IDirect3DResource8Impl,iface);
switch (This->ResourceType) {
case D3DRTYPE_SURFACE:
return ((IDirect3DSurface8Impl*) This)->myDesc.Pool;
case D3DRTYPE_TEXTURE:
return ((IDirect3DTexture8Impl*) This)->surfaces[0]->myDesc.Pool;
case D3DRTYPE_VOLUME:
return ((IDirect3DVolume8Impl*) This)->myDesc.Pool;
case D3DRTYPE_VOLUMETEXTURE:
return ((IDirect3DVolumeTexture8Impl*) This)->volumes[0]->myDesc.Pool;
case D3DRTYPE_CUBETEXTURE:
return ((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0]->myDesc.Pool;
case D3DRTYPE_VERTEXBUFFER:
return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
case D3DRTYPE_INDEXBUFFER:
return ((IDirect3DIndexBuffer8Impl*) This)->currentDesc.Pool;
default:
FIXME("(%p) Unrecognized type(%d,%s)\n", This, This->ResourceType, debug_d3dressourcetype(This->ResourceType));
return D3DPOOL_DEFAULT;
}
}
ICOM_VTABLE(IDirect3DResource8) Direct3DResource8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
......
......@@ -593,6 +593,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
TRACE_VECTOR(vshader->data->C[6]);
TRACE_VECTOR(vshader->data->C[7]);
TRACE_VECTOR(vshader->data->C[8]);
TRACE_VECTOR(vshader->data->C[64]);
TRACE_VECTOR(input->V[D3DVSDE_POSITION]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDWEIGHT]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDINDICES]);
......
......@@ -154,7 +154,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_NORMALORDER, D3DORDER_LINEAR);
/* Texture Stage States - Put directly into state block, we will call function below */
for (i = 0; i < This->TextureUnits; i++) {
for (i = 0; i < GL_LIMITS(textures); i++) {
memcpy(&This->StateBlock->transforms[D3DTS_TEXTURE0 + i], &idmatrix, sizeof(idmatrix));
This->StateBlock->texture_state[i][D3DTSS_COLOROP ] = (i==0)? D3DTOP_MODULATE : D3DTOP_DISABLE;
This->StateBlock->texture_state[i][D3DTSS_COLORARG1 ] = D3DTA_TEXTURE;
......@@ -191,7 +191,7 @@ 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 */
for (i = 0; i < This->TextureUnits; i++) {
for (i = 0; i < GL_LIMITS(textures); i++) {
GLubyte white = 255;
/* Note this avoids calling settexture, so pretend it has been called */
......@@ -200,7 +200,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
This->StateBlock->textures[i] = NULL;
/* Make appropriate texture active */
if (This->isMultiTexture) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
#if defined(GL_VERSION_1_3)
glActiveTexture(GL_TEXTURE0 + i);
#else
......@@ -289,7 +289,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
for (i = 0; i < NUM_SAVEDPIXELSTATES_R; i++) {
object->Changed.renderstate[SavedPixelStates_R[i]] = TRUE;
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
object->Changed.texture_state[j][SavedPixelStates_T[i]] = TRUE;
}
......@@ -304,12 +304,12 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateStateBlock(IDirect3DDevice8Impl* This,
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
object->Changed.renderstate[SavedVertexStates_R[i]] = TRUE;
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
object->Changed.texture_state[j][SavedVertexStates_T[i]] = TRUE;
}
}
for (i = 0; i < This->maxLights; i++) {
for (i = 0; i < GL_LIMITS(lights); i++) {
object->Changed.lightEnable[i] = TRUE;
object->Changed.lights[i] = TRUE;
}
......@@ -385,7 +385,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
if (pSB->blockType == D3DSBT_RECORDED || pSB->blockType == D3DSBT_ALL || pSB->blockType == D3DSBT_VERTEXSTATE) {
for (i = 0; i < This->maxLights; i++) {
for (i = 0; i < GL_LIMITS(lights); i++) {
if (pSB->Set.lightEnable[i] && pSB->Changed.lightEnable[i])
IDirect3DDevice8Impl_LightEnable(iface, i, pSB->lightEnable[i]);
......@@ -428,7 +428,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
IDirect3DDevice8Impl_SetStreamSource(iface, i, pSB->stream_source[i], pSB->stream_stride[i]);
}
for (i = 0; i < This->clipPlanes; i++) {
for (i = 0; i < GL_LIMITS(clipplanes); i++) {
if (pSB->Set.clipplane[i] && pSB->Changed.clipplane[i]) {
float clip[4];
......@@ -447,7 +447,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
}
/* Texture */
for (j = 0; j < This->TextureUnits; j++) {
for (j = 0; j < GL_LIMITS(textures); j++) {
for (i = 0; i < HIGHEST_TEXTURE_STATE; i++) {
if (pSB->Set.texture_state[j][i] && pSB->Changed.texture_state[j][i]) {
IDirect3DDevice8Impl_SetTextureStageState(iface, j, i, pSB->texture_state[j][i]);
......@@ -467,7 +467,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) {
if (pSB->Set.texture_state[j][SavedPixelStates_T[i]] &&
pSB->Changed.texture_state[j][SavedPixelStates_T[i]])
......@@ -482,7 +482,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_ApplyStateBlock(IDirect3DDevice8Impl* This,
IDirect3DDevice8Impl_SetRenderState(iface, SavedVertexStates_R[i], pSB->renderstate[SavedVertexStates_R[i]]);
}
for (j = 0; j < This->TextureUnits; i++) {
for (j = 0; j < GL_LIMITS(textures); i++) {
for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) {
if (pSB->Set.texture_state[j][SavedVertexStates_T[i]] &&
pSB->Changed.texture_state[j][SavedVertexStates_T[i]])
......@@ -526,7 +526,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
/* TODO: Vertex Shader Constants */
for (i = 0; i < This->maxLights; i++) {
for (i = 0; i < GL_LIMITS(lights); i++) {
if (updateBlock->Set.lightEnable[i] && This->StateBlock->lightEnable[i] != updateBlock->lightEnable[i]) {
TRACE("Updating light enable for light %d to %d\n", i, This->StateBlock->lightEnable[i]);
updateBlock->lightEnable[i] = This->StateBlock->lightEnable[i];
......@@ -591,7 +591,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
}
for (i = 0; i < This->clipPlanes; i++) {
for (i = 0; i < GL_LIMITS(clipplanes); i++) {
if (updateBlock->Set.clipplane[i] && memcmp(&This->StateBlock->clipplane[i],
&updateBlock->clipplane[i],
sizeof(updateBlock->clipplane)) != 0) {
......@@ -613,7 +613,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CaptureStateBlock(IDirect3DDevice8Impl* This,
}
/* Texture */
for (j = 0; j < This->TextureUnits; j++) {
for (j = 0; j < GL_LIMITS(textures); j++) {
for (i = 0; i < HIGHEST_TEXTURE_STATE; i++) {
if (updateBlock->Set.texture_state[j][i] && (updateBlock->texture_state[j][i] !=
......
......@@ -74,7 +74,6 @@ HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface,
return D3D_OK;
}
ICOM_VTABLE(IDirect3DSwapChain8) Direct3DSwapChain8_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
......
......@@ -133,22 +133,30 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)");
}
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
GL_TEXTURE_2D, i, fmt2glintFmt(This->format),
This->surfaces[i]->myDesc.Width, This->surfaces[i]->myDesc.Height,
0, fmt2glFmt(This->format), fmt2glType(This->format),
IDirect3DSurface8Impl_CreateGLTexture((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,
fmt2glintFmt(This->format),
D3DFmt2GLIntFmt(This->format),
This->surfaces[i]->myDesc.Width,
This->surfaces[i]->myDesc.Height,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
D3DFmt2GLFmt(This->format),
D3DFmt2GLType(This->format),
This->surfaces[i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
......@@ -202,20 +210,27 @@ HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface,
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[Level], pLockedRect, pRect, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
/**
* Not dirtified while Surfaces don't notify dirtification
* This->Dirty = TRUE;
*/
hr = IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8) This->surfaces[Level], pLockedRect, pRect, Flags);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
}
return hr;
}
HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
HRESULT hr;
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) : stub\n", This);
TRACE("(%p) Level (%d)\n", This, Level);
if (Level < This->levels) {
hr = IDirect3DSurface8Impl_UnlockRect((LPDIRECT3DSURFACE8) This->surfaces[Level]);
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
}
return D3D_OK;
}
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
......
......@@ -136,12 +136,17 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
checkGLcall("glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, This->levels - 1)");
}
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%lx, Mem=%p\n",
GL_TEXTURE_3D, i, fmt2glintFmt(This->format),
This->volumes[i]->myDesc.Width, This->volumes[i]->myDesc.Height,
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D,
i,
fmt2glintFmt(This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0, fmt2glFmt(This->format), fmt2glType(This->format),
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
This->volumes[i]->allocatedMemory);
glTexImage3D(GL_TEXTURE_3D,
i,
......@@ -154,7 +159,7 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
fmt2glType(This->format),
This->volumes[i]->allocatedMemory);
checkGLcall("glTexImage3D");
/* Removed glTexParameterf now TextureStageStates are initialized at startup */
This->Dirty = FALSE;
}
......
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