wined3d: Set the texture name at surface creation.
Henri Verbeet
hverbeet at codeweavers.com
Wed Sep 24 08:56:47 CDT 2008
This prevents the target from changing during the first PreLoad() call on a
surface, which would be inconvenient when attaching a surface to a FBO for
example.
---
dlls/wined3d/cubetexture.c | 14 +-------------
dlls/wined3d/device.c | 10 ++++++++++
dlls/wined3d/texture.c | 5 +----
3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c
index d670106..786a40c 100644
--- a/dlls/wined3d/cubetexture.c
+++ b/dlls/wined3d/cubetexture.c
@@ -27,15 +27,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
-static const GLenum cube_targets[6] = {
- GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
-};
-
/* *******************************************
IWineD3DCubeTexture IUnknown parts follow
******************************************* */
@@ -156,8 +147,7 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
IWineD3DSurface_AddDirtyRect(This->surfaces[j][i], NULL);
- surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName);
- surface_set_texture_target(This->surfaces[j][i], cube_targets[j]);
+ surface_force_reload(This->surfaces[j][i]);
IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
}
}
@@ -183,7 +173,6 @@ static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
IWineD3DSurface_UnLoad(This->surfaces[j][i]);
surface_set_texture_name(This->surfaces[j][i], 0);
- surface_set_texture_target(This->surfaces[j][i], IWineD3DTexture_GetTextureDimensions(iface));
}
}
@@ -248,7 +237,6 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
for (i = 0; i < This->baseTexture.levels; ++i) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName);
- surface_set_texture_target(This->surfaces[j][i], cube_targets[j]);
}
}
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 08ef2e1..1a99b31 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -887,6 +887,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
IWineD3DSurface_SetContainer(object->surfaces[i], (IWineD3DBase *)object);
TRACE("Created surface level %d @ %p\n", i, object->surfaces[i]);
+ surface_set_texture_target(object->surfaces[i], object->target);
/* calculate the next mipmap level */
tmpW = max(1, tmpW >> 1);
tmpH = max(1, tmpH >> 1);
@@ -1132,6 +1133,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
/* Create the 6 faces */
for (j = 0; j < 6; j++) {
+ static const GLenum cube_targets[6] = {
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
+ };
hr=D3DCB_CreateSurface(This->parent, parent, tmpW, tmpW, Format, Usage, Pool,
i /* Level */, j, &object->surfaces[j][i],pSharedHandle);
@@ -1156,6 +1165,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
}
IWineD3DSurface_SetContainer(object->surfaces[j][i], (IWineD3DBase *)object);
TRACE("Created surface level %d @ %p,\n", i, object->surfaces[j][i]);
+ surface_set_texture_target(object->surfaces[j][i], cube_targets[j]);
}
tmpW = max(1, tmpW >> 1);
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 8390060..2c3f5d5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -138,8 +138,7 @@ static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DSurface_AddDirtyRect(This->surfaces[i], NULL);
- surface_set_texture_name(This->surfaces[i], This->baseTexture.textureName);
- surface_set_texture_target(This->surfaces[i], IWineD3DTexture_GetTextureDimensions(iface));
+ surface_force_reload(This->surfaces[i]);
IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode);
}
} else {
@@ -164,7 +163,6 @@ static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DSurface_UnLoad(This->surfaces[i]);
surface_set_texture_name(This->surfaces[i], 0);
- surface_set_texture_target(This->surfaces[i], IWineD3DTexture_GetTextureDimensions(iface));
}
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
@@ -226,7 +224,6 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
UINT i;
for (i = 0; i < This->baseTexture.levels; ++i) {
surface_set_texture_name(This->surfaces[i], This->baseTexture.textureName);
- surface_set_texture_target(This->surfaces[i], IWineD3DTexture_GetTextureDimensions(iface));
}
/* Conditinal non power of two textures use a different clamping default. If we're using the GL_WINE_normalized_texrect
* partial driver emulation, we're dealing with a GL_TEXTURE_2D texture which has the address mode set to repeat - something
--
1.5.6.4
--------------040005040706020900000205--
More information about the wine-patches
mailing list