Move parameters relating to opengl on the surface structure on to a
glDesciption member. Removed Level and Target from LoadTexture, and reduced the dependency on surface->device. Fixed a couple of compiler warnings in d3d9.
This commit is contained in:
parent
9170cc8225
commit
13621056db
|
@ -160,7 +160,7 @@ HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 ifa
|
|||
TRACE("(%p) Relay\n", This);
|
||||
|
||||
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
|
||||
wined3ddesc.Format = &pDesc->Format;
|
||||
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
|
||||
wined3ddesc.Type = &pDesc->Type;
|
||||
wined3ddesc.Usage = &pDesc->Usage;
|
||||
wined3ddesc.Pool = &pDesc->Pool;
|
||||
|
|
|
@ -165,7 +165,7 @@ HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFAC
|
|||
TRACE("(%p) Relay\n", This);
|
||||
|
||||
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
|
||||
wined3ddesc.Format = &pDesc->Format;
|
||||
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
|
||||
wined3ddesc.Type = &pDesc->Type;
|
||||
wined3ddesc.Usage = &pDesc->Usage;
|
||||
wined3ddesc.Pool = &pDesc->Pool;
|
||||
|
|
|
@ -159,7 +159,7 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT
|
|||
TRACE("(%p) Relay\n", This);
|
||||
|
||||
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
|
||||
wined3ddesc.Format = &pDesc->Format;
|
||||
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
|
||||
wined3ddesc.Type = &pDesc->Type;
|
||||
wined3ddesc.Usage = &pDesc->Usage;
|
||||
wined3ddesc.Pool = &pDesc->Pool;
|
||||
|
|
|
@ -76,11 +76,19 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
|
|||
ref = InterlockedDecrement(&This->resource.ref);
|
||||
if (ref == 0) {
|
||||
int i,j;
|
||||
TRACE("(%p) : Cleaning up\n",This);
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
for (j = 0; j < 6; j++) {
|
||||
if (This->surfaces[j][i] != NULL) {
|
||||
TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
|
||||
IWineD3DSurface_Release((IWineD3DSurface *) This->surfaces[j][i]);
|
||||
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
|
||||
IUnknown* surfaceParent;
|
||||
/* Clean out the texture name we gave to the suface so that the surface doesn't try and release it */
|
||||
IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], 0, 0);
|
||||
TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
|
||||
IWineD3DSurface_GetParent(This->surfaces[j][i], &surfaceParent);
|
||||
IUnknown_Release(surfaceParent);
|
||||
IUnknown_Release(surfaceParent);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,18 +130,23 @@ DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
|
|||
void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
|
||||
/* Override the IWineD3DResource Preload method */
|
||||
unsigned int i,j;
|
||||
BOOL setGlTextureDesc = FALSE;
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
|
||||
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
|
||||
|
||||
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
|
||||
|
||||
IWineD3DCubeTexture_BindTexture(iface);
|
||||
|
||||
ENTER_GL();
|
||||
/* If were dirty then reload the surfaces */
|
||||
if(This->baseTexture.dirty != FALSE) {
|
||||
if (This->baseTexture.dirty != FALSE) {
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
for (j = 0; j < 6; j++)
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i], cube_targets[j], i);
|
||||
if(setGlTextureDesc)
|
||||
IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], This->baseTexture.textureName, cube_targets[j]);
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i]);
|
||||
}
|
||||
/* No longer dirty */
|
||||
This->baseTexture.dirty = FALSE;
|
||||
|
|
|
@ -558,17 +558,25 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
|
|||
return D3DERR_NOTAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** TODO: Check against the maximum texture sizes supported by the video card **/
|
||||
|
||||
|
||||
D3DCREATERESOURCEOBJECTINSTANCE(object,Surface,D3DRTYPE_SURFACE)
|
||||
object->container = (IUnknown*) This;
|
||||
|
||||
|
||||
object->currentDesc.Width = Width;
|
||||
object->currentDesc.Height = Height;
|
||||
object->currentDesc.Level = Level;
|
||||
object->currentDesc.MultiSampleType = MultiSample;
|
||||
object->currentDesc.MultiSampleQuality = MultisampleQuality;
|
||||
|
||||
/* Setup some glformat defaults */
|
||||
object->glDescription.glFormat = D3DFmt2GLFmt(This, object->resource.format);
|
||||
object->glDescription.glFormatInternal = D3DFmt2GLIntFmt(This, object->resource.format);
|
||||
object->glDescription.glType = D3DFmt2GLType(This, object->resource.format);
|
||||
object->glDescription.textureName = 0;
|
||||
object->glDescription.level = Level;
|
||||
object->glDescription.target = GL_TEXTURE_2D;
|
||||
|
||||
/* Internal data */
|
||||
object->pow2Width = pow2Width;
|
||||
object->pow2Height = pow2Height;
|
||||
|
|
|
@ -60,13 +60,16 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
|
|||
ULONG ref = InterlockedDecrement(&This->resource.ref);
|
||||
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
|
||||
if (ref == 0) {
|
||||
if (This->textureName != 0) { /* release the openGL texture.. */
|
||||
TRACE("(%p) : cleaning up\n", This);
|
||||
if (This->glDescription.textureName != 0) { /* release the openGL texture.. */
|
||||
ENTER_GL();
|
||||
TRACE("Deleting texture %d\n", This->textureName);
|
||||
glDeleteTextures(1, &This->textureName);
|
||||
TRACE("Deleting texture %d\n", This->glDescription.textureName);
|
||||
glDeleteTextures(1, &This->glDescription.textureName);
|
||||
LEAVE_GL();
|
||||
}
|
||||
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
|
||||
|
||||
TRACE("(%p) Released\n", This);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
|
||||
}
|
||||
|
@ -108,7 +111,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
|
|||
/* TODO: check for locks */
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
IWineD3DBaseTexture *baseTexture = NULL;
|
||||
TRACE("(%p)Checking to see if the container is a base textuer\n", This);
|
||||
TRACE("(%p)Checking to see if the container is a base texture\n", This);
|
||||
if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == D3D_OK) {
|
||||
TRACE("Passing to conatiner\n");
|
||||
IWineD3DBaseTexture_PreLoad(baseTexture);
|
||||
|
@ -119,21 +122,21 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
|
|||
#if 0 /* TODO: context manager support */
|
||||
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_2D, ENABLED, NOW /* make sure the state is applied now */);
|
||||
#endif
|
||||
glEnable(GL_TEXTURE_2D); /* make sure texture support is enabled in this context */
|
||||
if (This->currentDesc.Level == 0 && This->textureName == 0) {
|
||||
glGenTextures(1, &This->textureName);
|
||||
glEnable(This->glDescription.target);/* make sure texture support is enabled in this context */
|
||||
if (This->glDescription.level == 0 && This->glDescription.textureName == 0) {
|
||||
glGenTextures(1, &This->glDescription.textureName);
|
||||
checkGLcall("glGenTextures");
|
||||
TRACE("Surface %p given name %d\n", This, This->textureName);
|
||||
glBindTexture(GL_TEXTURE_2D, This->textureName);
|
||||
TRACE("Surface %p given name %d\n", This, This->glDescription.textureName);
|
||||
glBindTexture(This->glDescription.target, This->glDescription.textureName);
|
||||
checkGLcall("glBindTexture");
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This, GL_TEXTURE_2D, This->currentDesc.Level);
|
||||
IWineD3DSurface_LoadTexture(iface);
|
||||
/* This is where we should be reducing the amount of GLMemoryUsed */
|
||||
}else {
|
||||
if (This->currentDesc.Level == 0) {
|
||||
glBindTexture(GL_TEXTURE_2D, This->textureName);
|
||||
if (This->glDescription.level == 0) {
|
||||
glBindTexture(This->glDescription.target, This->glDescription.textureName);
|
||||
checkGLcall("glBindTexture");
|
||||
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This, GL_TEXTURE_2D, This->currentDesc.Level);
|
||||
} else if (This->textureName != 0) { /* NOTE: the level 0 surface of a mpmapped texture must be loaded first! */
|
||||
IWineD3DSurface_LoadTexture(iface);
|
||||
} else if (This->glDescription.textureName != 0) { /* NOTE: the level 0 surface of a mpmapped texture must be loaded first! */
|
||||
/* assume this is a coding error not a real error for now */
|
||||
FIXME("Mipmap surface has a glTexture bound to it!\n");
|
||||
}
|
||||
|
@ -142,7 +145,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
|
|||
/* Tell opengl to try and keep this texture in video ram (well mostly) */
|
||||
GLclampf tmp;
|
||||
tmp = 0.9f;
|
||||
glPrioritizeTextures(1, &This->textureName, &tmp);
|
||||
glPrioritizeTextures(1, &This->glDescription.textureName, &tmp);
|
||||
}
|
||||
/* TODO: disable texture support, if it wastn't enabled when we entered. */
|
||||
#if 0 /* TODO: context manager support */
|
||||
|
@ -199,6 +202,33 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target){
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
TRACE("(%p) : setting textureName %u, target %i\n", This, textureName, target);
|
||||
if (This->glDescription.textureName == 0 && textureName != 0) {
|
||||
This->Dirty = TRUE;
|
||||
IWineD3DSurface_AddDirtyRect(iface, NULL);
|
||||
}
|
||||
This->glDescription.textureName = textureName;
|
||||
This->glDescription.target = target;
|
||||
}
|
||||
|
||||
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription){
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
TRACE("(%p) : returning %p\n", This, &This->glDescription);
|
||||
*glDescription = &This->glDescription;
|
||||
}
|
||||
|
||||
/* TODO: think about moving this down to resource? */
|
||||
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface) {
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
/* This should only be called for sysmem textures, it may be a good idea to extend this to all pools at some point in the futture */
|
||||
if (This->resource.pool != D3DPOOL_SYSTEMMEM) {
|
||||
FIXME(" (%p)Attempting to get system memory for a non-system memory texture\n", iface);
|
||||
}
|
||||
return (CONST void*)(This->resource.allocatedMemory);
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
|
||||
|
@ -678,7 +708,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
|
|||
/* ******************************************************
|
||||
IWineD3DSurface Internal (No mapping to directx api) parts follow
|
||||
****************************************************** */
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl_target, GLenum gl_level) {
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
|
||||
if (This->inTexture) {
|
||||
|
@ -702,23 +732,32 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
if (This->inPBuffer) {
|
||||
ENTER_GL();
|
||||
|
||||
if (gl_level != 0)
|
||||
if (This->glDescription.level != 0)
|
||||
FIXME("Surface in texture is only supported for level 0\n");
|
||||
else if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8 ||
|
||||
This->resource.format == WINED3DFMT_DXT1 || This->resource.format == WINED3DFMT_DXT3 ||
|
||||
This->resource.format == WINED3DFMT_DXT5)
|
||||
FIXME("Format %d not supported\n", This->resource.format);
|
||||
else {
|
||||
glCopyTexImage2D(gl_target,
|
||||
0,
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice,
|
||||
This->resource.format),
|
||||
GLenum prevRead;
|
||||
glGetIntegerv(GL_READ_BUFFER, &prevRead);
|
||||
vcheckGLcall("glGetIntegerv");
|
||||
glReadBuffer(GL_BACK);
|
||||
vcheckGLcall("glReadBuffer");
|
||||
|
||||
glCopyTexImage2D(This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
This->glDescription.glFormatInternal,
|
||||
0,
|
||||
0,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
0);
|
||||
TRACE("Updating target %d\n", gl_target);
|
||||
|
||||
checkGLcall("glCopyTexImage2D");
|
||||
glReadBuffer(prevRead);
|
||||
vcheckGLcall("glReadBuffer");
|
||||
TRACE("Updating target %d\n", This->glDescription.target);
|
||||
This->inTexture = TRUE;
|
||||
}
|
||||
LEAVE_GL();
|
||||
|
@ -751,8 +790,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
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,
|
||||
gl_level,
|
||||
This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
GL_RGBA,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
|
@ -760,8 +799,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
surface);
|
||||
glTexImage2D(gl_target,
|
||||
gl_level,
|
||||
glTexImage2D(This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
GL_RGBA,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
|
@ -777,14 +816,16 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
/* TODO: Compressed non-power 2 support */
|
||||
/* TODO: DXT2 DXT4 support */
|
||||
if (This->resource.format == WINED3DFMT_DXT1 ||
|
||||
This->resource.format == WINED3DFMT_DXT3 ||
|
||||
This->resource.format == WINED3DFMT_DXT5) {
|
||||
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
|
||||
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
|
||||
gl_target,
|
||||
gl_level,
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
This->glDescription.glFormatInternal,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
0,
|
||||
|
@ -793,9 +834,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
|
||||
ENTER_GL();
|
||||
|
||||
GL_EXTCALL(glCompressedTexImage2DARB)(gl_target,
|
||||
gl_level,
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
GL_EXTCALL(glCompressedTexImage2DARB)(This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
This->glDescription.glFormatInternal,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
0,
|
||||
|
@ -815,20 +856,20 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
TRACE("non power of two support\n");
|
||||
ENTER_GL();
|
||||
TRACE("(%p) Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", This,
|
||||
gl_target,
|
||||
gl_level,
|
||||
This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
debug_d3dformat(This->resource.format),
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormatInternal,
|
||||
This->pow2Width,
|
||||
This->pow2Height,
|
||||
0,
|
||||
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormat,
|
||||
This->glDescription.glType,
|
||||
NULL);
|
||||
|
||||
glTexImage2D(gl_target,
|
||||
gl_level,
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
glTexImage2D(This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
This->glDescription.glFormatInternal,
|
||||
This->pow2Width,
|
||||
This->pow2Height,
|
||||
0/*border*/,
|
||||
|
@ -841,14 +882,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
TRACE("(%p) Calling glTexSubImage2D w(%d) h(%d) mem(%p)\n", This, This->currentDesc.Width, This->currentDesc.Height, This->resource.allocatedMemory);
|
||||
/* And map the non-power two data into the top left corner */
|
||||
glTexSubImage2D(
|
||||
gl_target,
|
||||
gl_level,
|
||||
This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
0 /* xoffset */,
|
||||
0 /* ysoffset */ ,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormat,
|
||||
This->glDescription.glType,
|
||||
This->resource.allocatedMemory
|
||||
);
|
||||
checkGLcall("glTexSubImage2D");
|
||||
|
@ -858,26 +899,26 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
} else {
|
||||
|
||||
TRACE("Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
|
||||
gl_target,
|
||||
gl_level,
|
||||
This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
debug_d3dformat(This->resource.format),
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormatInternal,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
0,
|
||||
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormat,
|
||||
This->glDescription.glType,
|
||||
This->resource.allocatedMemory);
|
||||
|
||||
ENTER_GL();
|
||||
glTexImage2D(gl_target,
|
||||
gl_level,
|
||||
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
glTexImage2D(This->glDescription.target,
|
||||
This->glDescription.level,
|
||||
This->glDescription.glFormatInternal,
|
||||
This->currentDesc.Width,
|
||||
This->currentDesc.Height,
|
||||
0 /* border */,
|
||||
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format),
|
||||
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format),
|
||||
This->glDescription.glFormat,
|
||||
This->glDescription.glType,
|
||||
This->resource.allocatedMemory);
|
||||
checkGLcall("glTexImage2D");
|
||||
LEAVE_GL();
|
||||
|
@ -889,7 +930,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
|
|||
char buffer[4096];
|
||||
++gen;
|
||||
if ((gen % 10) == 0) {
|
||||
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, gl_target, gl_level, gen);
|
||||
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
|
||||
IWineD3DSurfaceImpl_SaveSnapshot((IWineD3DSurface *) This, buffer);
|
||||
}
|
||||
/*
|
||||
|
@ -1073,5 +1114,8 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
|
|||
IWineD3DSurfaceImpl_LoadTexture,
|
||||
IWineD3DSurfaceImpl_SaveSnapshot,
|
||||
IWineD3DSurfaceImpl_SetContainer,
|
||||
IWineD3DSurfaceImpl_SetPBufferState
|
||||
IWineD3DSurfaceImpl_SetPBufferState,
|
||||
IWineD3DSurfaceImpl_SetGlTextureDesc,
|
||||
IWineD3DSurfaceImpl_GetGlDesc,
|
||||
IWineD3DSurfaceImpl_GetData
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* IDirect3DTexture9 implementation
|
||||
* IWineD3DTexture implementation
|
||||
*
|
||||
* Copyright 2002-2005 Jason Edmeades
|
||||
* Copyright 2002-2005 Raphael Junqueira
|
||||
|
@ -47,7 +47,6 @@ HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID
|
|||
ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
|
||||
IUnknown_AddRef(This->resource.parent);
|
||||
return InterlockedIncrement(&This->resource.ref);
|
||||
}
|
||||
|
||||
|
@ -58,10 +57,14 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
|
|||
ref = InterlockedDecrement(&This->resource.ref);
|
||||
if (ref == 0) {
|
||||
int i;
|
||||
|
||||
TRACE("(%p) : Cleaning up\n",This);
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
if (This->surfaces[i] != NULL) {
|
||||
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
|
||||
IUnknown* surfaceParent;
|
||||
/* Clean out the texture name we gave to the suface so that the surface doesn't try and release it */
|
||||
IWineD3DSurface_SetGlTextureDesc(This->surfaces[i], 0, 0);
|
||||
IWineD3DSurface_GetParent(This->surfaces[i], &surfaceParent);
|
||||
IUnknown_Release(surfaceParent);
|
||||
IUnknown_Release(surfaceParent);
|
||||
|
@ -70,8 +73,6 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
|
|||
|
||||
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
} else {
|
||||
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
@ -107,20 +108,28 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
|
|||
|
||||
/* Override the IWineD3DResource PreLoad method */
|
||||
unsigned int i;
|
||||
BOOL setGlTextureDesc = FALSE;
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
|
||||
TRACE("(%p) : About to load texture\n", This);
|
||||
|
||||
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
|
||||
|
||||
IWineD3DTexture_BindTexture(iface);
|
||||
ENTER_GL();
|
||||
/* If were dirty then reload the surfaces */
|
||||
/* If were dirty then reload the surfaces */
|
||||
if(This->baseTexture.dirty != FALSE) {
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; i++) {
|
||||
IWineD3DSurface_LoadTexture(This->surfaces[i], GL_TEXTURE_2D, i);
|
||||
if(setGlTextureDesc)
|
||||
IWineD3DSurface_SetGlTextureDesc(This->surfaces[i], This->baseTexture.textureName, IWineD3DTexture_GetTextureDimensions(iface));
|
||||
IWineD3DSurface_LoadTexture(This->surfaces[i]);
|
||||
}
|
||||
|
||||
/* No longer dirty */
|
||||
This->baseTexture.dirty = FALSE;
|
||||
} else {
|
||||
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
|
||||
}
|
||||
LEAVE_GL();
|
||||
|
||||
|
|
|
@ -600,7 +600,6 @@ extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
|
|||
|
||||
typedef struct _WINED3DSURFACET_DESC
|
||||
{
|
||||
UINT Level;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleType;
|
||||
DWORD MultiSampleQuality;
|
||||
UINT Width;
|
||||
|
@ -644,6 +643,8 @@ struct IWineD3DSurfaceImpl
|
|||
|
||||
BOOL inTexture;
|
||||
BOOL inPBuffer;
|
||||
|
||||
glDescriptor glDescription;
|
||||
};
|
||||
|
||||
extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
|
||||
|
|
|
@ -979,11 +979,14 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
|
|||
/* Internally used methods */
|
||||
STDMETHOD(CleanDirtyRect)(THIS) PURE;
|
||||
STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pRect) PURE;
|
||||
STDMETHOD(LoadTexture)(THIS_ UINT gl_target, UINT gl_level) PURE;
|
||||
STDMETHOD(LoadTexture)(THIS) PURE;
|
||||
STDMETHOD(SaveSnapshot)(THIS_ const char *filename) PURE;
|
||||
STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE;
|
||||
STDMETHOD(SetPBufferState)(THIS_ BOOL inPBuffer, BOOL inTexture) PURE;
|
||||
|
||||
STDMETHOD_(void,SetGlTextureDesc)(THIS_ UINT textureName, int target) PURE;
|
||||
STDMETHOD_(void,GetGlDesc)(THIS_ glDescriptor **glDescription) PURE;
|
||||
STDMETHOD_(CONST void *, GetData)(THIS) PURE;
|
||||
|
||||
};
|
||||
#undef INTERFACE
|
||||
|
||||
|
@ -1012,10 +1015,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
|
|||
/*** IWineD3DSurface (Internal, no d3d mapping) methods ***/
|
||||
#define IWineD3DSurface_CleanDirtyRect(p) (p)->lpVtbl->CleanDirtyRect(p)
|
||||
#define IWineD3DSurface_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a)
|
||||
#define IWineD3DSurface_LoadTexture(p,a,b) (p)->lpVtbl->LoadTexture(p,a,b)
|
||||
#define IWineD3DSurface_LoadTexture(p) (p)->lpVtbl->LoadTexture(p)
|
||||
#define IWineD3DSurface_SaveSnapshot(p,a) (p)->lpVtbl->SaveSnapshot(p,a)
|
||||
#define IWineD3DSurface_SetContainer(p,a) (p)->lpVtbl->SetContainer(p,a)
|
||||
#define IWineD3DSurface_SetPBufferState(p,a,b) (p)->lpVtbl->SetPBufferState(p,a,b)
|
||||
#define IWineD3DSurface_SetGlTextureDesc(p,a,b) (p)->lpVtbl->SetGlTextureDesc(p,a,b)
|
||||
#define IWineD3DSurface_GetGlDesc(p,a) (p)->lpVtbl->GetGlDesc(p,a)
|
||||
#define IWineD3DSurface_GetData(p) (p)->lpVtbl->GetData(p)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -414,12 +414,12 @@ typedef struct _WINED3DPRESENT_PARAMETERS {
|
|||
|
||||
typedef struct _WINED3DSURFACE_DESC
|
||||
{
|
||||
D3DFORMAT *Format;
|
||||
WINED3DFORMAT *Format;
|
||||
D3DRESOURCETYPE *Type;
|
||||
DWORD *Usage;
|
||||
D3DPOOL *Pool;
|
||||
UINT *Size;
|
||||
|
||||
|
||||
D3DMULTISAMPLE_TYPE *MultiSampleType;
|
||||
DWORD *MultiSampleQuality;
|
||||
UINT *Width;
|
||||
|
@ -433,7 +433,7 @@ typedef struct _WINED3DVOLUME_DESC
|
|||
DWORD *Usage;
|
||||
D3DPOOL *Pool;
|
||||
UINT *Size;
|
||||
|
||||
|
||||
UINT *Width;
|
||||
UINT *Height;
|
||||
UINT *Depth;
|
||||
|
@ -674,5 +674,13 @@ typedef struct _WINED3DCAPS {
|
|||
|
||||
} WINED3DCAPS;
|
||||
|
||||
typedef struct glDescriptor {
|
||||
UINT textureName;
|
||||
int level;
|
||||
int target;
|
||||
int/*GLenum*/ glFormat;
|
||||
int/*GLenum*/ glFormatInternal;
|
||||
int/*GLenum*/ glType;
|
||||
} glDescriptor;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue