diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c index b1a7e52e8c0..515be630132 100644 --- a/dlls/d3d8/cubetexture.c +++ b/dlls/d3d8/cubetexture.c @@ -253,18 +253,20 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(IDirect3DCubeTexture static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(IDirect3DCubeTexture8 *iface, UINT level, D3DSURFACE_DESC *desc) { - IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface); - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface); + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - hr = IWineD3DCubeTexture_GetSubResourceDesc(This->wineD3DCubeTexture, level, &wined3d_desc); - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DCubeTexture_GetSubResource(texture->wineD3DCubeTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -274,6 +276,7 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(IDirect3DCubeTextur desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index 949457d4e2a..31196acb35f 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -250,18 +250,20 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(IDirect3DTexture8 *iface static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(IDirect3DTexture8 *iface, UINT level, D3DSURFACE_DESC *desc) { - IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface); - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface); + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - hr = IWineD3DTexture_GetSubResourceDesc(This->wineD3DTexture, level, &wined3d_desc); - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DTexture_GetSubResource(texture->wineD3DTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -271,6 +273,7 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(IDirect3DTexture8 *ifac desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/d3d8/volumetexture.c b/dlls/d3d8/volumetexture.c index de91216e08e..429f1128013 100644 --- a/dlls/d3d8/volumetexture.c +++ b/dlls/d3d8/volumetexture.c @@ -227,18 +227,20 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETE static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(IDirect3DVolumeTexture8 *iface, UINT level, D3DVOLUME_DESC *desc) { - IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface; - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DVolumeTexture8Impl *texture = (IDirect3DVolumeTexture8Impl *)iface; + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - hr = IWineD3DVolumeTexture_GetSubResourceDesc(This->wineD3DVolumeTexture, level, &wined3d_desc); - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -248,6 +250,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(IDirect3DVolumeTe desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c index a628bb8c6c3..f6cacd9155f 100644 --- a/dlls/d3d9/cubetexture.c +++ b/dlls/d3d9/cubetexture.c @@ -269,18 +269,20 @@ static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBE static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(IDirect3DCubeTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) { - IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface; - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DCubeTexture9Impl *texture = (IDirect3DCubeTexture9Impl *)iface; + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - hr = IWineD3DCubeTexture_GetSubResourceDesc(This->wineD3DCubeTexture, level, &wined3d_desc); - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DCubeTexture_GetSubResource(texture->wineD3DCubeTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -290,6 +292,7 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(IDirect3DCubeTextur desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 2b874172f21..611ef670957 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -265,18 +265,20 @@ static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(IDirect3DTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) { - IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DTexture9Impl *texture = (IDirect3DTexture9Impl *)iface; + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - hr = IWineD3DTexture_GetSubResourceDesc(This->wineD3DTexture, level, &wined3d_desc); - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DTexture_GetSubResource(texture->wineD3DTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -286,6 +288,7 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(IDirect3DTexture9 *ifac desc->Width = wined3d_desc.width; desc->Height = wined3d_desc.height; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c index 83b92d836a9..e97d1a43868 100644 --- a/dlls/d3d9/volumetexture.c +++ b/dlls/d3d9/volumetexture.c @@ -290,20 +290,20 @@ static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVO static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(IDirect3DVolumeTexture9 *iface, UINT level, D3DVOLUME_DESC *desc) { - IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface; - struct wined3d_resource_desc wined3d_desc; - HRESULT hr; + IDirect3DVolumeTexture9Impl *texture = (IDirect3DVolumeTexture9Impl *)iface; + struct wined3d_resource *sub_resource; + HRESULT hr = D3D_OK; TRACE("iface %p, level %u, desc %p.\n", iface, level, desc); wined3d_mutex_lock(); - - hr = IWineD3DVolumeTexture_GetSubResourceDesc(This->wineD3DVolumeTexture, level, &wined3d_desc); - - wined3d_mutex_unlock(); - - if (SUCCEEDED(hr)) + if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level))) + hr = D3DERR_INVALIDCALL; + else { + struct wined3d_resource_desc wined3d_desc; + + wined3d_resource_get_desc(sub_resource, &wined3d_desc); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); desc->Type = wined3d_desc.resource_type; desc->Usage = wined3d_desc.usage; @@ -312,6 +312,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(IDirect3DVolumeTe desc->Height = wined3d_desc.height; desc->Depth = wined3d_desc.depth; } + wined3d_mutex_unlock(); return hr; } diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index b55994d3498..710c8f3e5b2 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2497,18 +2497,19 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface, HRESULT hr; BOOL tex_alpha = FALSE; IWineD3DBaseTexture *tex = NULL; - struct wined3d_resource_desc desc; DDPIXELFORMAT ddfmt; - hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, - 0, - &tex); + hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex); if(hr == WINED3D_OK && tex) { - hr = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc); - if (SUCCEEDED(hr)) + struct wined3d_resource *sub_resource; + + if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0))) { + struct wined3d_resource_desc desc; + + wined3d_resource_get_desc(sub_resource, &desc); ddfmt.dwSize = sizeof(ddfmt); PixelFormat_WineD3DtoDD(&ddfmt, desc.format); if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE; @@ -2805,19 +2806,19 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface, { BOOL tex_alpha = FALSE; IWineD3DBaseTexture *tex = NULL; - struct wined3d_resource_desc desc; DDPIXELFORMAT ddfmt; - hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, - 0, - &tex); + hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex); if(hr == WINED3D_OK && tex) { - memset(&desc, 0, sizeof(desc)); - hr = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc); - if (SUCCEEDED(hr)) + struct wined3d_resource *sub_resource; + + if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0))) { + struct wined3d_resource_desc desc; + + wined3d_resource_get_desc(sub_resource, &desc); ddfmt.dwSize = sizeof(ddfmt); PixelFormat_WineD3DtoDD(&ddfmt, desc.format); if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE; @@ -4575,22 +4576,22 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, { /* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states. See IDirect3DDeviceImpl_3_SetRenderState for details. */ - struct wined3d_resource_desc desc; BOOL tex_alpha = FALSE; IWineD3DBaseTexture *tex = NULL; DDPIXELFORMAT ddfmt; HRESULT result; - result = IWineD3DDevice_GetTexture(This->wineD3DDevice, - 0, - &tex); + result = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex); if(result == WINED3D_OK && tex) { - memset(&desc, 0, sizeof(desc)); - result = IWineD3DBaseTexture_GetSubResourceDesc(tex, 0, &desc); - if (SUCCEEDED(result)) + struct wined3d_resource *sub_resource; + + if ((sub_resource = IWineD3DBaseTexture_GetSubResource(tex, 0))) { + struct wined3d_resource_desc desc; + + wined3d_resource_get_desc(sub_resource, &desc); ddfmt.dwSize = sizeof(ddfmt); PixelFormat_WineD3DtoDD(&ddfmt, desc.format); if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE; diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c index 66e6c94190f..40311627460 100644 --- a/dlls/wined3d/cubetexture.c +++ b/dlls/wined3d/cubetexture.c @@ -326,25 +326,6 @@ static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface) return FALSE; } -static HRESULT WINAPI IWineD3DCubeTextureImpl_GetSubResourceDesc(IWineD3DCubeTexture *iface, - UINT sub_resource_idx, struct wined3d_resource_desc *desc) -{ - IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; - struct wined3d_resource *sub_resource; - - TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc); - - if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx))) - { - WARN("Failed to get sub-resource.\n"); - return WINED3DERR_INVALIDCALL; - } - - wined3d_resource_get_desc(sub_resource, desc); - - return WINED3D_OK; -} - static struct wined3d_resource * WINAPI IWineD3DCubeTextureImpl_GetSubResource(IWineD3DCubeTexture *iface, UINT sub_resource_idx) { @@ -437,7 +418,6 @@ static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl = IWineD3DCubeTextureImpl_GetAutoGenFilterType, IWineD3DCubeTextureImpl_GenerateMipSubLevels, IWineD3DCubeTextureImpl_IsCondNP2, - IWineD3DCubeTextureImpl_GetSubResourceDesc, IWineD3DCubeTextureImpl_GetSubResource, /* IWineD3DCubeTexture */ IWineD3DCubeTextureImpl_Map, diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 5a73df2f4b4..cdc483d8fa2 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -283,7 +283,7 @@ void * CDECL wined3d_resource_get_parent(const struct wined3d_resource *resource return resource->parent; } -void wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc) +void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc) { desc->resource_type = resource->resourceType; desc->format = resource->format->id; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index de7488bb145..752ea8f8307 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -351,25 +351,6 @@ static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) { return This->cond_np2; } -static HRESULT WINAPI IWineD3DTextureImpl_GetSubResourceDesc(IWineD3DTexture *iface, - UINT sub_resource_idx, struct wined3d_resource_desc *desc) -{ - IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; - struct wined3d_resource *sub_resource; - - TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc); - - if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx))) - { - WARN("Failed to get sub-resource.\n"); - return WINED3DERR_INVALIDCALL; - } - - wined3d_resource_get_desc(sub_resource, desc); - - return WINED3D_OK; -} - static struct wined3d_resource * WINAPI IWineD3DTextureImpl_GetSubResource(IWineD3DTexture *iface, UINT sub_resource_idx) { @@ -456,7 +437,6 @@ static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl = IWineD3DTextureImpl_GetAutoGenFilterType, IWineD3DTextureImpl_GenerateMipSubLevels, IWineD3DTextureImpl_IsCondNP2, - IWineD3DTextureImpl_GetSubResourceDesc, IWineD3DTextureImpl_GetSubResource, /* IWineD3DTexture */ IWineD3DTextureImpl_Map, diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c index f2ca9391acd..e53d4f5879d 100644 --- a/dlls/wined3d/volumetexture.c +++ b/dlls/wined3d/volumetexture.c @@ -263,25 +263,6 @@ static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *if return FALSE; } -static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetSubResourceDesc(IWineD3DVolumeTexture *iface, - UINT sub_resource_idx, struct wined3d_resource_desc *desc) -{ - IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; - struct wined3d_resource *sub_resource; - - TRACE("iface %p, sub_resource_idx %u, desc %p.\n", iface, sub_resource_idx, desc); - - if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx))) - { - WARN("Failed to get sub-resource.\n"); - return WINED3DERR_INVALIDCALL; - } - - wined3d_resource_get_desc(sub_resource, desc); - - return WINED3D_OK; -} - static struct wined3d_resource * WINAPI IWineD3DVolumeTextureImpl_GetSubResource(IWineD3DVolumeTexture *iface, UINT sub_resource_idx) { @@ -369,7 +350,6 @@ static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl = IWineD3DVolumeTextureImpl_GetAutoGenFilterType, IWineD3DVolumeTextureImpl_GenerateMipSubLevels, IWineD3DVolumeTextureImpl_IsCondNP2, - IWineD3DVolumeTextureImpl_GetSubResourceDesc, IWineD3DVolumeTextureImpl_GetSubResource, /* volume texture */ IWineD3DVolumeTextureImpl_Map, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 4e1786488e5..aa971695bc8 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -59,6 +59,7 @@ @ cdecl wined3d_query_incref(ptr) @ cdecl wined3d_query_issue(ptr long) +@ cdecl wined3d_resource_get_desc(ptr ptr) @ cdecl wined3d_resource_get_parent(ptr) @ cdecl wined3d_stateblock_apply(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f395a950b5e..201e19b774a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1824,8 +1824,6 @@ struct wined3d_resource void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN; HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid) DECLSPEC_HIDDEN; -void wined3d_resource_get_desc(const struct wined3d_resource *resource, - struct wined3d_resource_desc *desc) DECLSPEC_HIDDEN; DWORD resource_get_priority(const struct wined3d_resource *resource) DECLSPEC_HIDDEN; HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid, void *data, DWORD *data_size) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index 0ce41f8f311..d70ae2c165f 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2362,10 +2362,6 @@ interface IWineD3DBaseTexture : IWineD3DResource ); BOOL IsCondNP2( ); - HRESULT GetSubResourceDesc( - [in] UINT sub_resource_idx, - [out] struct wined3d_resource_desc *desc - ); struct wined3d_resource *GetSubResource( [in] UINT sub_resource_idx ); @@ -3215,6 +3211,8 @@ WINED3DQUERYTYPE __cdecl wined3d_query_get_type(const struct wined3d_query *quer ULONG __cdecl wined3d_query_incref(struct wined3d_query *query); HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags); +void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource, + struct wined3d_resource_desc *desc); void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource); HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);