Commit b21ec9ff authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Store the blend factor in the stateblock as a render state.

parent 276d970e
......@@ -2304,22 +2304,18 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
TRACE("iface %p, state %#x, value %#x.\n", iface, state, value);
if (state == D3DRS_BLENDFACTOR)
{
wined3d_color_from_d3dcolor(&factor, value);
wined3d_mutex_lock();
wined3d_stateblock_set_blend_factor(device->update_state, &factor);
if (!device->recording)
wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor);
wined3d_mutex_unlock();
return D3D_OK;
}
wined3d_mutex_lock();
wined3d_stateblock_set_render_state(device->update_state, state, value);
if (!device->recording)
wined3d_device_set_render_state(device->wined3d_device, state, value);
{
if (state == D3DRS_BLENDFACTOR)
{
wined3d_color_from_d3dcolor(&factor, value);
wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor);
}
else
wined3d_device_set_render_state(device->wined3d_device, state, value);
}
wined3d_mutex_unlock();
return D3D_OK;
......@@ -2330,20 +2326,9 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface,
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_stateblock_state *device_state;
struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
if (state == D3DRS_BLENDFACTOR)
{
wined3d_mutex_lock();
wined3d_device_get_blend_state(device->wined3d_device, &factor);
wined3d_mutex_unlock();
*value = D3DCOLOR_COLORVALUE(factor.r, factor.g, factor.b, factor.a);
return D3D_OK;
}
wined3d_mutex_lock();
device_state = wined3d_stateblock_get_state(device->state);
*value = device_state->rs[state];
......
......@@ -35,6 +35,7 @@ static const DWORD pixel_states_render[] =
WINED3D_RS_ALPHAREF,
WINED3D_RS_ALPHATESTENABLE,
WINED3D_RS_ANTIALIASEDLINEENABLE,
WINED3D_RS_BLENDFACTOR,
WINED3D_RS_BLENDOP,
WINED3D_RS_BLENDOPALPHA,
WINED3D_RS_BACK_STENCILFAIL,
......@@ -208,7 +209,6 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
states->pixelShader = 1;
states->vertexShader = 1;
states->scissorRect = 1;
states->blend_state = 1;
/* Fixed size arrays */
states->streamSource = 0xffff;
......@@ -236,7 +236,6 @@ static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states
unsigned int i;
states->pixelShader = 1;
states->blend_state = 1;
for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
{
......@@ -903,15 +902,6 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
stateblock->stateblock_state.scissor_rect = state->scissor_rect;
}
if (stateblock->changed.blend_state
&& memcmp(&state->blend_factor, &stateblock->stateblock_state.blend_factor,
sizeof(stateblock->stateblock_state.blend_factor)))
{
TRACE("Updating blend factor.\n");
stateblock->stateblock_state.blend_factor = state->blend_factor;
}
map = stateblock->changed.streamSource;
for (i = 0; map; map >>= 1, ++i)
{
......@@ -1129,7 +1119,14 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
enum wined3d_render_state rs = stateblock->contained_render_states[i];
state->rs[rs] = stateblock->stateblock_state.rs[rs];
wined3d_device_set_render_state(device, rs, stateblock->stateblock_state.rs[rs]);
if (rs == WINED3D_RS_BLENDFACTOR)
{
struct wined3d_color color;
wined3d_color_from_d3dcolor(&color, stateblock->stateblock_state.rs[rs]);
wined3d_device_set_blend_state(device, NULL, &color);
}
else
wined3d_device_set_render_state(device, rs, stateblock->stateblock_state.rs[rs]);
}
/* Texture states. */
......@@ -1209,12 +1206,6 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
wined3d_device_set_scissor_rects(device, 1, &stateblock->stateblock_state.scissor_rect);
}
if (stateblock->changed.blend_state)
{
state->blend_factor = stateblock->stateblock_state.blend_factor;
wined3d_device_set_blend_state(device, NULL, &stateblock->stateblock_state.blend_factor);
}
map = stateblock->changed.streamSource;
for (i = 0; map; map >>= 1, ++i)
{
......@@ -1437,15 +1428,6 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb
stateblock->changed.renderState[state >> 5] |= 1u << (state & 0x1f);
}
void CDECL wined3d_stateblock_set_blend_factor(struct wined3d_stateblock *stateblock,
const struct wined3d_color *blend_factor)
{
TRACE("stateblock %p, blend_factor %p.\n", stateblock, blend_factor);
stateblock->stateblock_state.blend_factor = *blend_factor;
stateblock->changed.blend_state = TRUE;
}
void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock,
UINT sampler_idx, enum wined3d_sampler_state state, DWORD value)
{
......@@ -1827,6 +1809,7 @@ static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], c
rs[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f;
rs[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f;
rs[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f;
rs[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
rs[WINED3D_RS_SRGBWRITEENABLE] = 0;
rs[WINED3D_RS_DEPTHBIAS] = 0;
rs[WINED3D_RS_WRAP8] = 0;
......@@ -1971,11 +1954,6 @@ static void stateblock_state_init_default(struct wined3d_stateblock_state *state
init_default_sampler_states(state->sampler_states);
state->blend_factor.r = 1.0f;
state->blend_factor.g = 1.0f;
state->blend_factor.b = 1.0f;
state->blend_factor.a = 1.0f;
for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
state->streams[i].frequency = 1;
}
......
......@@ -264,7 +264,6 @@
@ cdecl wined3d_stateblock_init_contained_states(ptr)
@ cdecl wined3d_stateblock_reset(ptr)
@ cdecl wined3d_stateblock_set_base_vertex_index(ptr long)
@ cdecl wined3d_stateblock_set_blend_factor(ptr ptr)
@ cdecl wined3d_stateblock_set_clip_plane(ptr long ptr)
@ cdecl wined3d_stateblock_set_index_buffer(ptr ptr long)
@ cdecl wined3d_stateblock_set_light(ptr long ptr)
......
......@@ -3875,9 +3875,8 @@ struct wined3d_saved_states
DWORD pixelShader : 1;
DWORD vertexShader : 1;
DWORD scissorRect : 1;
DWORD blend_state : 1;
DWORD store_stream_offset : 1;
DWORD padding : 3;
DWORD padding : 4;
};
struct StageState {
......
......@@ -384,6 +384,7 @@ enum wined3d_render_state
WINED3D_RS_COLORWRITEENABLE1 = 190,
WINED3D_RS_COLORWRITEENABLE2 = 191,
WINED3D_RS_COLORWRITEENABLE3 = 192,
WINED3D_RS_BLENDFACTOR = 193,
WINED3D_RS_SRGBWRITEENABLE = 194,
WINED3D_RS_DEPTHBIAS = 195,
WINED3D_RS_WRAP8 = 198,
......@@ -2151,7 +2152,6 @@ struct wined3d_stateblock_state
BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
DWORD rs[WINEHIGHEST_RENDER_STATE + 1];
struct wined3d_color blend_factor;
struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
......@@ -2726,8 +2726,6 @@ ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_reset(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_set_base_vertex_index(struct wined3d_stateblock *stateblock, INT base_index);
void __cdecl wined3d_stateblock_set_blend_factor(struct wined3d_stateblock *stateblock,
const struct wined3d_color *blend_factor);
HRESULT __cdecl wined3d_stateblock_set_clip_plane(struct wined3d_stateblock *stateblock,
UINT plane_idx, const struct wined3d_vec4 *plane);
void __cdecl wined3d_stateblock_set_index_buffer(struct wined3d_stateblock *stateblock,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment