[PATCH 5/5] wined3d: Store the blend factor in the stateblock as a render state.
Zebediah Figura
z.figura12 at gmail.com
Wed Nov 27 19:52:39 CST 2019
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/d3d9/device.c | 33 +++++++-----------------
dlls/wined3d/stateblock.c | 47 ++++++++--------------------------
dlls/wined3d/wined3d.spec | 1 -
dlls/wined3d/wined3d_private.h | 3 +--
include/wine/wined3d.h | 4 +--
5 files changed, 21 insertions(+), 67 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 51b7f4d6f59..174cdc5bf49 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -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];
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 1196eb2a7f7..056fb7198b8 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -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)
{
@@ -1828,6 +1810,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;
@@ -1921,11 +1904,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
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;
}
@@ -1972,11 +1950,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;
}
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index bec84b5979c..716b902f313 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -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)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 4bc2ee19113..d79cfbc69dc 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3863,9 +3863,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 {
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index c5ada12d66f..387a65e84c2 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -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,
@@ -2162,7 +2163,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];
@@ -2737,8 +2737,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,
--
2.23.0
More information about the wine-devel
mailing list