d3d9: Retrieve textures from the primary stateblock.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b33177355e
commit
aa18b69a66
|
@ -2516,6 +2516,7 @@ 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;
|
||||||
|
const struct wined3d_stateblock_state *state;
|
||||||
struct d3d9_texture *texture_impl;
|
struct d3d9_texture *texture_impl;
|
||||||
|
|
||||||
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
|
||||||
|
@ -2523,8 +2524,19 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
|
||||||
if (!texture)
|
if (!texture)
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
|
||||||
|
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS);
|
||||||
|
|
||||||
|
if (stage >= ARRAY_SIZE(state->textures))
|
||||||
|
{
|
||||||
|
WARN("Ignoring invalid stage %u.\n", stage);
|
||||||
|
*texture = NULL;
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)))
|
state = wined3d_stateblock_get_state(device->state);
|
||||||
|
if ((wined3d_texture = state->textures[stage]))
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -2815,16 +2827,15 @@ static float WINAPI d3d9_device_GetNPatchMode(IDirect3DDevice9Ex *iface)
|
||||||
/* wined3d critical section must be taken by the caller. */
|
/* wined3d critical section must be taken by the caller. */
|
||||||
static void d3d9_generate_auto_mipmaps(struct d3d9_device *device)
|
static void d3d9_generate_auto_mipmaps(struct d3d9_device *device)
|
||||||
{
|
{
|
||||||
|
const struct wined3d_stateblock_state *state = wined3d_stateblock_get_state(device->state);
|
||||||
struct wined3d_texture *texture;
|
struct wined3d_texture *texture;
|
||||||
unsigned int i, stage, map;
|
unsigned int i, map;
|
||||||
|
|
||||||
map = device->auto_mipmaps;
|
map = device->auto_mipmaps;
|
||||||
while (map)
|
while (map)
|
||||||
{
|
{
|
||||||
i = wined3d_bit_scan(&map);
|
i = wined3d_bit_scan(&map);
|
||||||
|
if ((texture = state->textures[i]))
|
||||||
stage = i >= 16 ? i - 16 + D3DVERTEXTEXTURESAMPLER0 : i;
|
|
||||||
if ((texture = wined3d_device_get_texture(device->wined3d_device, stage)))
|
|
||||||
d3d9_texture_gen_auto_mipmap(wined3d_texture_get_parent(texture));
|
d3d9_texture_gen_auto_mipmap(wined3d_texture_get_parent(texture));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,9 @@ static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
|
||||||
{
|
{
|
||||||
struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
|
struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
|
||||||
struct wined3d_texture *wined3d_texture;
|
struct wined3d_texture *wined3d_texture;
|
||||||
unsigned int i, offset, stride, stage;
|
|
||||||
struct wined3d_buffer *wined3d_buffer;
|
struct wined3d_buffer *wined3d_buffer;
|
||||||
struct d3d9_vertexbuffer *buffer;
|
struct d3d9_vertexbuffer *buffer;
|
||||||
|
unsigned int i, offset, stride;
|
||||||
enum wined3d_format_id format;
|
enum wined3d_format_id format;
|
||||||
struct d3d9_texture *texture;
|
struct d3d9_texture *texture;
|
||||||
struct d3d9_device *device;
|
struct d3d9_device *device;
|
||||||
|
@ -151,9 +151,7 @@ static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
|
||||||
device->auto_mipmaps = 0;
|
device->auto_mipmaps = 0;
|
||||||
for (i = 0; i < D3D9_MAX_TEXTURE_UNITS; ++i)
|
for (i = 0; i < D3D9_MAX_TEXTURE_UNITS; ++i)
|
||||||
{
|
{
|
||||||
stage = i >= 16 ? i - 16 + D3DVERTEXTEXTURESAMPLER0 : i;
|
if ((wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[i])
|
||||||
|
|
||||||
if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage))
|
|
||||||
&& (texture = wined3d_texture_get_parent(wined3d_texture))
|
&& (texture = wined3d_texture_get_parent(wined3d_texture))
|
||||||
&& texture->usage & D3DUSAGE_AUTOGENMIPMAP)
|
&& texture->usage & D3DUSAGE_AUTOGENMIPMAP)
|
||||||
device->auto_mipmaps |= 1u << i;
|
device->auto_mipmaps |= 1u << i;
|
||||||
|
|
Loading…
Reference in New Issue