ddraw: Store primary stateblock state pointer in the device.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2020-03-18 14:01:23 +01:00 committed by Alexandre Julliard
parent 97e1c1414b
commit 140186b0c3
5 changed files with 18 additions and 14 deletions

View File

@ -5048,6 +5048,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
wined3d_decref(ddraw->wined3d);
return hr;
}
ddraw->stateblock_state = wined3d_stateblock_get_state(ddraw->state);
return DD_OK;
}

View File

@ -132,6 +132,7 @@ struct ddraw
UINT numConvertedDecls, declArraySize;
struct wined3d_stateblock *state;
const struct wined3d_stateblock_state *stateblock_state;
};
#define DDRAW_WINDOW_CLASS_NAME "DirectDrawDeviceWnd"
@ -356,6 +357,7 @@ struct d3d_device
struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES];
struct wined3d_stateblock *recording, *state, *update_state;
const struct wined3d_stateblock_state *stateblock_state;
};
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface,

View File

@ -2302,7 +2302,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock();
device_state = wined3d_stateblock_get_state(device->state);
device_state = device->stateblock_state;
switch (state)
{
case D3DRENDERSTATE_TEXTUREMAG:
@ -2451,7 +2451,7 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
*value = 0;
wined3d_mutex_lock();
if ((tex = wined3d_stateblock_get_state(device->state)->textures[0]))
if ((tex = device->stateblock_state->textures[0]))
{
/* The parent of the texture is the IDirectDrawSurface7
* interface of the ddraw surface. */
@ -2673,7 +2673,7 @@ static void fixup_texture_alpha_op(struct d3d_device *device)
if (!(device->legacyTextureBlending && device->texture_map_blend == D3DTBLEND_MODULATE))
return;
if ((tex = wined3d_stateblock_get_state(device->state)->textures[0]))
if ((tex = device->stateblock_state->textures[0]))
{
struct wined3d_resource_desc desc;
@ -3233,7 +3233,7 @@ static HRESULT d3d_device7_GetTransform(IDirect3DDevice7 *iface,
/* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
wined3d_mutex_lock();
memcpy(matrix, &wined3d_stateblock_get_state(device->state)->transforms[wined3d_state], sizeof(*matrix));
memcpy(matrix, &device->stateblock_state->transforms[wined3d_state], sizeof(*matrix));
wined3d_mutex_unlock();
return D3D_OK;
@ -3886,7 +3886,7 @@ static HRESULT WINAPI d3d_device7_GetClipStatus(IDirect3DDevice7 *iface, D3DCLIP
FIXME("iface %p, clip_status %p stub.\n", iface, clip_status);
vp = wined3d_stateblock_get_state(device->state)->viewport;
vp = device->stateblock_state->viewport;
clip_status->minx = vp.x;
clip_status->maxx = vp.x + vp.width;
clip_status->miny = vp.y;
@ -4566,7 +4566,7 @@ static void prepare_clip_space_planes(struct d3d_device *device, struct wined3d_
/* We want the wined3d matrices since those include the legacy viewport
* transformation. */
wined3d_mutex_lock();
state = wined3d_stateblock_get_state(device->state);
state = device->stateblock_state;
multiply_matrix(&m, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD]);
multiply_matrix(&m, &state->transforms[WINED3D_TS_PROJECTION], &m);
wined3d_mutex_unlock();
@ -4725,7 +4725,7 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
}
wined3d_mutex_lock();
if (!(wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[stage]))
if (!(wined3d_texture = device->stateblock_state->textures[stage]))
{
*texture = NULL;
wined3d_mutex_unlock();
@ -4936,7 +4936,7 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface,
wined3d_mutex_lock();
device_state = wined3d_stateblock_get_state(device->state);
device_state = device->stateblock_state;
if (l->sampler_state)
{
@ -5391,7 +5391,7 @@ static HRESULT d3d_device7_GetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *vi
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock();
wined3d_viewport = wined3d_stateblock_get_state(device->state)->viewport;
wined3d_viewport = device->stateblock_state->viewport;
wined3d_mutex_unlock();
viewport->dwX = wined3d_viewport.x;
@ -5493,7 +5493,7 @@ static HRESULT d3d_device7_GetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *ma
wined3d_mutex_lock();
/* Note: D3DMATERIAL7 is compatible with struct wined3d_material. */
memcpy(material, &wined3d_stateblock_get_state(device->state)->material, sizeof(*material));
memcpy(material, &device->stateblock_state->material, sizeof(*material));
wined3d_mutex_unlock();
return D3D_OK;
@ -6577,7 +6577,7 @@ static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DV
wined3d_mutex_lock();
if (idx < WINED3D_MAX_CLIP_DISTANCES)
memcpy(plane, &wined3d_stateblock_get_state(device->state)->clip_planes[idx], sizeof(struct wined3d_vec4));
memcpy(plane, &device->stateblock_state->clip_planes[idx], sizeof(struct wined3d_vec4));
else
{
WARN("Clip plane %u is not supported.\n", idx);
@ -6997,6 +6997,7 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw,
device->wined3d_device = ddraw->wined3d_device;
wined3d_device_incref(ddraw->wined3d_device);
device->update_state = device->state = ddraw->state;
device->stateblock_state = ddraw->stateblock_state;
wined3d_stateblock_incref(ddraw->state);
/* Render to the back buffer */

View File

@ -85,7 +85,7 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface)
* stream source in wined3d and they should get unset there before
* they are destroyed. */
wined3d_mutex_lock();
if (wined3d_stateblock_get_state(buffer->ddraw->state)->streams[0].buffer == buffer->wined3d_buffer)
if (buffer->ddraw->stateblock_state->streams[0].buffer == buffer->wined3d_buffer)
wined3d_stateblock_set_stream_source(buffer->ddraw->state, 0, NULL, 0, 0);
wined3d_vertex_declaration_decref(buffer->wined3d_declaration);
@ -275,7 +275,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7
wined3d_mutex_lock();
state = wined3d_stateblock_get_state(device_impl->state);
state = device_impl->stateblock_state;
/* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to

View File

@ -520,7 +520,7 @@ static HRESULT WINAPI d3d_viewport_TransformVertices(IDirect3DViewport3 *iface,
if (activate)
viewport_activate(viewport, TRUE);
state = wined3d_stateblock_get_state(device->state);
state = device->stateblock_state;
multiply_matrix(&mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(0)]);
multiply_matrix(&mat, &state->transforms[WINED3D_TS_PROJECTION], &mat);