Signed-off-by: Daniel Ansorregui <mailszeros(a)gmail.com>
---
dlls/d3d11/device.c | 15 ++++++++-------
dlls/d3d9/device.c | 9 ++++++++-
dlls/wined3d/cs.c | 28 ++++++++++++++++++++++++++++
dlls/wined3d/device.c | 29 +++++++++++++++++++++++++++++
dlls/wined3d/state.c | 11 ++++++-----
dlls/wined3d/stateblock.c | 7 +++++--
dlls/wined3d/utils.c | 3 ++-
dlls/wined3d/wined3d.spec | 3 +++
dlls/wined3d/wined3d_private.h | 7 ++++++-
include/wine/wined3d.h | 4 +++-
10 files changed, 98 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 157ff0341a..9964568acb 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -700,6 +700,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
{
struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
static const float default_blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ struct wined3d_color blend_color;
struct d3d_blend_state *blend_state_impl;
const D3D11_BLEND_DESC *desc;
@@ -709,6 +710,12 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
if (!blend_factor)
blend_factor = default_blend_factor;
+ /* Assign the blend factor (given, or default) to wine color */
+ blend_color.r = blend_factor[0];
+ blend_color.g = blend_factor[1];
+ blend_color.b = blend_factor[2];
+ blend_color.a = blend_factor[3];
+
wined3d_mutex_lock();
memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor));
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
@@ -743,13 +750,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA, d->SrcBlendAlpha);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA, d->DestBlendAlpha);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA, d->BlendOpAlpha);
-
- if (memcmp(blend_factor, default_blend_factor, sizeof(default_blend_factor))
- && (d->SrcBlend == D3D11_BLEND_BLEND_FACTOR || d->SrcBlend == D3D11_BLEND_INV_BLEND_FACTOR
- || d->DestBlend == D3D11_BLEND_BLEND_FACTOR || d->DestBlend == D3D11_BLEND_INV_BLEND_FACTOR
- || d->SrcBlendAlpha == D3D11_BLEND_BLEND_FACTOR || d->SrcBlendAlpha == D3D11_BLEND_INV_BLEND_FACTOR
- || d->DestBlendAlpha == D3D11_BLEND_BLEND_FACTOR || d->DestBlendAlpha == D3D11_BLEND_INV_BLEND_FACTOR))
- FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor));
+ wined3d_device_set_blendfactor(device->wined3d_device, &blend_color);
}
wined3d_device_set_render_state(device->wined3d_device,
WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask);
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index a31360886b..c43e4971ff 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2221,7 +2221,14 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
TRACE("iface %p, state %#x, value %#x.\n", iface, state, value);
wined3d_mutex_lock();
- wined3d_device_set_render_state(device->wined3d_device, state, value);
+ switch (state)
+ {
+ case D3DRS_BLENDFACTOR:
+ wined3d_device_set_blendfactor_integer(device->wined3d_device, value);
+ break;
+ default:
+ wined3d_device_set_render_state(device->wined3d_device, state, value);
+ }
wined3d_mutex_unlock();
return D3D_OK;
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index af1dbef84c..9cfa0b107b 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -49,6 +49,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_SAMPLER,
WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_BLEND_STATE,
+ WINED3D_CS_OP_SET_BLENDFACTOR,
WINED3D_CS_OP_SET_RASTERIZER_STATE,
WINED3D_CS_OP_SET_RENDER_STATE,
WINED3D_CS_OP_SET_TEXTURE_STATE,
@@ -266,6 +267,12 @@ struct wined3d_cs_set_blend_state
struct wined3d_blend_state *state;
};
+struct wined3d_cs_set_blendfactor
+{
+ enum wined3d_cs_op opcode;
+ struct wined3d_color factor;
+};
+
struct wined3d_cs_set_rasterizer_state
{
enum wined3d_cs_op opcode;
@@ -471,6 +478,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op)
WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLER);
WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER);
WINED3D_TO_STR(WINED3D_CS_OP_SET_BLEND_STATE);
+ WINED3D_TO_STR(WINED3D_CS_OP_SET_BLENDFACTOR);
WINED3D_TO_STR(WINED3D_CS_OP_SET_RASTERIZER_STATE);
WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDER_STATE);
WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE_STATE);
@@ -1555,6 +1563,25 @@ void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
+static void wined3d_cs_exec_set_blendfactor(struct wined3d_cs *cs, const void *data)
+{
+ const struct wined3d_cs_set_blendfactor *op = data;
+
+ cs->state.blend_factor = op->factor;
+ device_invalidate_state(cs->device, STATE_BLENDFACTOR);
+}
+
+void wined3d_cs_emit_set_blendfactor(struct wined3d_cs *cs, struct wined3d_color *factor)
+{
+ struct wined3d_cs_set_blendfactor *op;
+
+ op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
+ op->opcode = WINED3D_CS_OP_SET_BLENDFACTOR;
+ op->factor = *factor;
+
+ cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
+}
+
static void wined3d_cs_exec_set_rasterizer_state(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_rasterizer_state *op = data;
@@ -2505,6 +2532,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler,
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader,
/* WINED3D_CS_OP_SET_BLEND_STATE */ wined3d_cs_exec_set_blend_state,
+ /* WINED3D_CS_OP_SET_BLENDFACTOR */ wined3d_cs_exec_set_blendfactor,
/* WINED3D_CS_OP_SET_RASTERIZER_STATE */ wined3d_cs_exec_set_rasterizer_state,
/* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state,
/* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index abb2a89363..3b966d7eed 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1993,6 +1993,35 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w
return device->state.blend_state;
}
+void CDECL wined3d_device_set_blendfactor_integer(struct wined3d_device *device, DWORD factori)
+{
+ struct wined3d_color factor;
+
+ wined3d_color_from_d3dcolor(&factor, factori);
+ wined3d_device_set_blendfactor(device, &factor);
+}
+
+void CDECL wined3d_device_set_blendfactor(struct wined3d_device *device, struct wined3d_color *factor)
+{
+ struct wined3d_color *prev;
+
+ TRACE("device %p, blendfactor %s.\n", device, debug_color(factor));
+
+ prev = &device->update_state->blend_factor;
+ if (!memcmp(prev, factor, sizeof(*factor)))
+ return;
+
+ device->update_state->blend_factor = *factor;
+ wined3d_cs_emit_set_blendfactor(device->cs, factor);
+}
+
+struct wined3d_color * CDECL wined3d_device_get_blendfactor(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
+
+ return &device->state.blend_factor;
+}
+
void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device,
struct wined3d_rasterizer_state *rasterizer_state)
{
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 375bc6562a..0c2e340ee7 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -605,11 +605,10 @@ static void state_blendfactor_w(struct wined3d_context *context, const struct wi
static void state_blendfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_color color;
+ struct wined3d_color color = state->blend_factor;
- TRACE("Setting blend factor to %#x.\n", state->render_states[WINED3D_RS_BLENDFACTOR]);
+ TRACE("Setting blend factor to %s\n", debug_color(&color));
- wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_BLENDFACTOR]);
GL_EXTCALL(glBlendColor(color.r, color.g, color.b, color.a));
checkGLcall("glBlendColor");
}
@@ -4689,8 +4688,8 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), state_colorwrite3 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
- { STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor }, EXT_BLEND_COLOR },
- { STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor_w }, WINED3D_GL_EXT_NONE },
+ { STATE_BLENDFACTOR, { STATE_BLENDFACTOR, state_blendfactor }, EXT_BLEND_COLOR },
+ { STATE_BLENDFACTOR, { STATE_BLENDFACTOR, state_blendfactor_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), state_depthbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
/* Samplers */
@@ -5453,6 +5452,7 @@ static void validate_state_table(struct StateEntry *state_table)
{149, 150},
{169, 169},
{177, 177},
+ {193, 193},
{196, 197},
{ 0, 0},
};
@@ -5488,6 +5488,7 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_POINT_ENABLE,
STATE_COLOR_KEY,
STATE_BLEND,
+ STATE_BLENDFACTOR,
};
unsigned int i, current;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 45a4008ac4..da3e59eb5a 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -35,7 +35,6 @@ 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,
@@ -1255,7 +1254,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f;
state->render_states[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f;
state->render_states[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f;
- state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
state->render_states[WINED3D_RS_WRAP8] = 0;
@@ -1271,6 +1269,11 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_DESTBLENDALPHA] = WINED3D_BLEND_ZERO;
state->render_states[WINED3D_RS_BLENDOPALPHA] = WINED3D_BLEND_OP_ADD;
+ state->blend_factor.r = 1.0f;
+ state->blend_factor.g = 1.0f;
+ state->blend_factor.b = 1.0f;
+ state->blend_factor.a = 1.0f;
+
/* Texture Stage States - Put directly into state block, we will call function below */
for (i = 0; i < MAX_TEXTURES; ++i)
{
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index e3df24ade4..41e41a2184 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4716,7 +4716,6 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE1);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE2);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE3);
- D3DSTATE_TO_STR(WINED3D_RS_BLENDFACTOR);
D3DSTATE_TO_STR(WINED3D_RS_SRGBWRITEENABLE);
D3DSTATE_TO_STR(WINED3D_RS_DEPTHBIAS);
D3DSTATE_TO_STR(WINED3D_RS_WRAP8);
@@ -4965,6 +4964,8 @@ const char *debug_d3dstate(DWORD state)
return "STATE_STREAM_OUTPUT";
if (STATE_IS_BLEND(state))
return "STATE_BLEND";
+ if (STATE_IS_BLENDFACTOR(state))
+ return "STATE_BLENDFACTOR";
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
}
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 7944387bca..ac0a52efc9 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -58,6 +58,7 @@
@ cdecl wined3d_device_get_available_texture_mem(ptr)
@ cdecl wined3d_device_get_base_vertex_index(ptr)
@ cdecl wined3d_device_get_blend_state(ptr)
+@ cdecl wined3d_device_get_blendfactor(ptr)
@ cdecl wined3d_device_get_clip_plane(ptr long ptr)
@ cdecl wined3d_device_get_clip_status(ptr ptr)
@ cdecl wined3d_device_get_compute_shader(ptr)
@@ -130,6 +131,8 @@
@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr ptr)
@ cdecl wined3d_device_set_base_vertex_index(ptr long)
@ cdecl wined3d_device_set_blend_state(ptr ptr)
+@ cdecl wined3d_device_set_blendfactor_integer(ptr long)
+@ cdecl wined3d_device_set_blendfactor(ptr ptr)
@ cdecl wined3d_device_set_clip_plane(ptr long ptr)
@ cdecl wined3d_device_set_clip_status(ptr ptr)
@ cdecl wined3d_device_set_compute_shader(ptr ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 20e626cd43..3d15fa6fcf 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1645,7 +1645,10 @@ enum wined3d_pipeline
#define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
#define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
-#define STATE_COMPUTE_OFFSET (STATE_BLEND + 1)
+#define STATE_BLENDFACTOR (STATE_BLEND + 1)
+#define STATE_IS_BLENDFACTOR(a) ((a) == STATE_BLENDFACTOR)
+
+#define STATE_COMPUTE_OFFSET (STATE_BLENDFACTOR + 1)
#define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
#define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
@@ -2934,6 +2937,7 @@ struct wined3d_state
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
struct wined3d_blend_state *blend_state;
+ struct wined3d_color blend_factor;
struct wined3d_rasterizer_state *rasterizer_state;
};
@@ -3642,6 +3646,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN;
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_set_blendfactor(struct wined3d_cs *cs, struct wined3d_color *factor) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index c62d3640e5..bcfbcbd134 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -388,7 +388,6 @@ 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,
@@ -2265,6 +2264,7 @@ void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *devic
UINT __cdecl wined3d_device_get_available_texture_mem(const struct wined3d_device *device);
INT __cdecl wined3d_device_get_base_vertex_index(const struct wined3d_device *device);
struct wined3d_blend_state * __cdecl wined3d_device_get_blend_state(const struct wined3d_device *device);
+struct wined3d_color * __cdecl wined3d_device_get_blendfactor(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_get_clip_plane(const struct wined3d_device *device,
UINT plane_idx, struct wined3d_vec4 *plane);
HRESULT __cdecl wined3d_device_get_clip_status(const struct wined3d_device *device,
@@ -2380,6 +2380,8 @@ void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *dev
const RECT *window_rect);
void __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index);
void __cdecl wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state);
+void __cdecl wined3d_device_set_blendfactor_integer(struct wined3d_device *device, DWORD factor);
+void __cdecl wined3d_device_set_blendfactor(struct wined3d_device *device, struct wined3d_color *factor);
HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device,
UINT plane_idx, const struct wined3d_vec4 *plane);
HRESULT __cdecl wined3d_device_set_clip_status(struct wined3d_device *device,
--
2.17.1