mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
wined3d: Just return the texture from wined3d_device_get_texture().
This commit is contained in:
parent
fb2dac9621
commit
f9d494294a
@ -1691,7 +1691,6 @@ static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stag
|
|||||||
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
|
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
|
||||||
struct wined3d_texture *wined3d_texture;
|
struct wined3d_texture *wined3d_texture;
|
||||||
struct d3d8_texture *texture_impl;
|
struct d3d8_texture *texture_impl;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||||
|
|
||||||
@ -1699,21 +1698,11 @@ static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stag
|
|||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
|
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
WARN("Failed to get texture for stage %u, hr %#x.\n", stage, hr);
|
|
||||||
wined3d_mutex_unlock();
|
|
||||||
*texture = NULL;
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wined3d_texture)
|
|
||||||
{
|
{
|
||||||
texture_impl = wined3d_texture_get_parent(wined3d_texture);
|
texture_impl = wined3d_texture_get_parent(wined3d_texture);
|
||||||
*texture = &texture_impl->IDirect3DBaseTexture8_iface;
|
*texture = &texture_impl->IDirect3DBaseTexture8_iface;
|
||||||
IDirect3DBaseTexture8_AddRef(*texture);
|
IDirect3DBaseTexture8_AddRef(*texture);
|
||||||
wined3d_texture_decref(wined3d_texture);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1666,7 +1666,6 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
|
|||||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||||
struct wined3d_texture *wined3d_texture = NULL;
|
struct wined3d_texture *wined3d_texture = NULL;
|
||||||
struct d3d9_texture *texture_impl;
|
struct d3d9_texture *texture_impl;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||||
|
|
||||||
@ -1674,23 +1673,19 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
|
|||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
|
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
|
||||||
if (SUCCEEDED(hr) && wined3d_texture)
|
|
||||||
{
|
{
|
||||||
texture_impl = wined3d_texture_get_parent(wined3d_texture);
|
texture_impl = wined3d_texture_get_parent(wined3d_texture);
|
||||||
*texture = &texture_impl->IDirect3DBaseTexture9_iface;
|
*texture = &texture_impl->IDirect3DBaseTexture9_iface;
|
||||||
IDirect3DBaseTexture9_AddRef(*texture);
|
IDirect3DBaseTexture9_AddRef(*texture);
|
||||||
wined3d_texture_decref(wined3d_texture);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (FAILED(hr))
|
|
||||||
WARN("Call to get texture (%u) failed (%p).\n", stage, wined3d_texture);
|
|
||||||
*texture = NULL;
|
*texture = NULL;
|
||||||
}
|
}
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 *texture)
|
static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 *texture)
|
||||||
|
@ -2361,7 +2361,6 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
|
|||||||
D3DRENDERSTATETYPE state, DWORD *value)
|
D3DRENDERSTATETYPE state, DWORD *value)
|
||||||
{
|
{
|
||||||
struct d3d_device *device = impl_from_IDirect3DDevice3(iface);
|
struct d3d_device *device = impl_from_IDirect3DDevice3(iface);
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
|
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
|
||||||
|
|
||||||
@ -2375,19 +2374,17 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
|
|||||||
*value = 0;
|
*value = 0;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
|
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
|
||||||
if (SUCCEEDED(hr) && tex)
|
|
||||||
{
|
{
|
||||||
/* The parent of the texture is the IDirectDrawSurface7
|
/* The parent of the texture is the IDirectDrawSurface7
|
||||||
* interface of the ddraw surface. */
|
* interface of the ddraw surface. */
|
||||||
struct ddraw_surface *parent = wined3d_texture_get_parent(tex);
|
struct ddraw_surface *parent = wined3d_texture_get_parent(tex);
|
||||||
if (parent)
|
if (parent)
|
||||||
*value = parent->Handle;
|
*value = parent->Handle;
|
||||||
wined3d_texture_decref(tex);
|
|
||||||
}
|
}
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
case D3DRENDERSTATE_TEXTUREMAPBLEND:
|
||||||
@ -2423,13 +2420,10 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct wined3d_texture *tex = NULL;
|
struct wined3d_texture *tex = NULL;
|
||||||
HRESULT hr;
|
|
||||||
BOOL tex_alpha = FALSE;
|
BOOL tex_alpha = FALSE;
|
||||||
DDPIXELFORMAT ddfmt;
|
DDPIXELFORMAT ddfmt;
|
||||||
|
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
|
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
|
||||||
|
|
||||||
if(hr == WINED3D_OK && tex)
|
|
||||||
{
|
{
|
||||||
struct wined3d_resource *sub_resource;
|
struct wined3d_resource *sub_resource;
|
||||||
|
|
||||||
@ -2442,8 +2436,6 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
|
|||||||
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
||||||
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wined3d_texture_decref(tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(colorop == WINED3D_TOP_MODULATE
|
if (!(colorop == WINED3D_TOP_MODULATE
|
||||||
@ -2720,9 +2712,7 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
|
|||||||
BOOL tex_alpha = FALSE;
|
BOOL tex_alpha = FALSE;
|
||||||
DDPIXELFORMAT ddfmt;
|
DDPIXELFORMAT ddfmt;
|
||||||
|
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
|
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
|
||||||
|
|
||||||
if(hr == WINED3D_OK && tex)
|
|
||||||
{
|
{
|
||||||
struct wined3d_resource *sub_resource;
|
struct wined3d_resource *sub_resource;
|
||||||
|
|
||||||
@ -2735,8 +2725,6 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
|
|||||||
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
||||||
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wined3d_texture_decref(tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex_alpha)
|
if (tex_alpha)
|
||||||
@ -4312,7 +4300,6 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
|
|||||||
struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
|
struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
|
||||||
struct wined3d_texture *wined3d_texture;
|
struct wined3d_texture *wined3d_texture;
|
||||||
struct ddraw_surface *surface;
|
struct ddraw_surface *surface;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||||
|
|
||||||
@ -4320,21 +4307,19 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
|
|||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
hr = wined3d_device_get_texture(device->wined3d_device, stage, &wined3d_texture);
|
if (!(wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
|
||||||
if (FAILED(hr) || !wined3d_texture)
|
|
||||||
{
|
{
|
||||||
*texture = NULL;
|
*texture = NULL;
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = wined3d_texture_get_parent(wined3d_texture);
|
surface = wined3d_texture_get_parent(wined3d_texture);
|
||||||
*texture = &surface->IDirectDrawSurface7_iface;
|
*texture = &surface->IDirectDrawSurface7_iface;
|
||||||
IDirectDrawSurface7_AddRef(*texture);
|
IDirectDrawSurface7_AddRef(*texture);
|
||||||
wined3d_texture_decref(wined3d_texture);
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
return hr;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI d3d_device7_GetTexture_FPUSetup(IDirect3DDevice7 *iface,
|
static HRESULT WINAPI d3d_device7_GetTexture_FPUSetup(IDirect3DDevice7 *iface,
|
||||||
@ -4452,10 +4437,8 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
|
|||||||
struct wined3d_texture *tex = NULL;
|
struct wined3d_texture *tex = NULL;
|
||||||
BOOL tex_alpha = FALSE;
|
BOOL tex_alpha = FALSE;
|
||||||
DDPIXELFORMAT ddfmt;
|
DDPIXELFORMAT ddfmt;
|
||||||
HRESULT result;
|
|
||||||
|
|
||||||
result = wined3d_device_get_texture(device->wined3d_device, 0, &tex);
|
if ((tex = wined3d_device_get_texture(device->wined3d_device, 0)))
|
||||||
if (result == WINED3D_OK && tex)
|
|
||||||
{
|
{
|
||||||
struct wined3d_resource *sub_resource;
|
struct wined3d_resource *sub_resource;
|
||||||
|
|
||||||
@ -4468,8 +4451,6 @@ static HRESULT WINAPI d3d_device3_SetTexture(IDirect3DDevice3 *iface,
|
|||||||
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
|
||||||
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wined3d_texture_decref(tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
|
/* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
|
||||||
|
@ -3556,10 +3556,9 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
|
|||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CDECL wined3d_device_get_texture(const struct wined3d_device *device,
|
struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_device *device, UINT stage)
|
||||||
UINT stage, struct wined3d_texture **texture)
|
|
||||||
{
|
{
|
||||||
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
|
TRACE("device %p, stage %u.\n", device, stage);
|
||||||
|
|
||||||
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
|
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
|
||||||
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
|
||||||
@ -3567,16 +3566,10 @@ HRESULT CDECL wined3d_device_get_texture(const struct wined3d_device *device,
|
|||||||
if (stage >= sizeof(device->stateBlock->state.textures) / sizeof(*device->stateBlock->state.textures))
|
if (stage >= sizeof(device->stateBlock->state.textures) / sizeof(*device->stateBlock->state.textures))
|
||||||
{
|
{
|
||||||
WARN("Ignoring invalid stage %u.\n", stage);
|
WARN("Ignoring invalid stage %u.\n", stage);
|
||||||
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
|
return NULL; /* Windows accepts overflowing this array ... we do not. */
|
||||||
}
|
}
|
||||||
|
|
||||||
*texture = device->stateBlock->state.textures[stage];
|
return device->stateBlock->state.textures[stage];
|
||||||
if (*texture)
|
|
||||||
wined3d_texture_incref(*texture);
|
|
||||||
|
|
||||||
TRACE("Returning %p.\n", *texture);
|
|
||||||
|
|
||||||
return WINED3D_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CDECL wined3d_device_get_back_buffer(const struct wined3d_device *device, UINT swapchain_idx,
|
HRESULT CDECL wined3d_device_get_back_buffer(const struct wined3d_device *device, UINT swapchain_idx,
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
|
@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
|
||||||
@ cdecl wined3d_device_get_swapchain(ptr long)
|
@ cdecl wined3d_device_get_swapchain(ptr long)
|
||||||
@ cdecl wined3d_device_get_swapchain_count(ptr)
|
@ cdecl wined3d_device_get_swapchain_count(ptr)
|
||||||
@ cdecl wined3d_device_get_texture(ptr long ptr)
|
@ cdecl wined3d_device_get_texture(ptr long)
|
||||||
@ cdecl wined3d_device_get_texture_stage_state(ptr long long)
|
@ cdecl wined3d_device_get_texture_stage_state(ptr long long)
|
||||||
@ cdecl wined3d_device_get_transform(ptr long ptr)
|
@ cdecl wined3d_device_get_transform(ptr long ptr)
|
||||||
@ cdecl wined3d_device_get_vertex_declaration(ptr)
|
@ cdecl wined3d_device_get_vertex_declaration(ptr)
|
||||||
|
@ -2158,8 +2158,7 @@ HRESULT __cdecl wined3d_device_get_surface_from_dc(const struct wined3d_device *
|
|||||||
struct wined3d_swapchain * __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
|
struct wined3d_swapchain * __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
|
||||||
UINT swapchain_idx);
|
UINT swapchain_idx);
|
||||||
UINT __cdecl wined3d_device_get_swapchain_count(const struct wined3d_device *device);
|
UINT __cdecl wined3d_device_get_swapchain_count(const struct wined3d_device *device);
|
||||||
HRESULT __cdecl wined3d_device_get_texture(const struct wined3d_device *device,
|
struct wined3d_texture * __cdecl wined3d_device_get_texture(const struct wined3d_device *device, UINT stage);
|
||||||
UINT stage, struct wined3d_texture **texture);
|
|
||||||
DWORD __cdecl wined3d_device_get_texture_stage_state(const struct wined3d_device *device,
|
DWORD __cdecl wined3d_device_get_texture_stage_state(const struct wined3d_device *device,
|
||||||
UINT stage, enum wined3d_texture_stage_state state);
|
UINT stage, enum wined3d_texture_stage_state state);
|
||||||
void __cdecl wined3d_device_get_transform(const struct wined3d_device *device,
|
void __cdecl wined3d_device_get_transform(const struct wined3d_device *device,
|
||||||
|
Loading…
Reference in New Issue
Block a user