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

wined3d: Store the sample mask in wined3d_state.

parent 8333e7f2
......@@ -715,13 +715,12 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi
blend_factor = default_blend_factor;
wined3d_mutex_lock();
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask);
if (!(blend_state_impl = unsafe_impl_from_ID3D11BlendState(blend_state)))
wined3d_device_set_blend_state(device->wined3d_device, NULL,
(const struct wined3d_color *)blend_factor);
(const struct wined3d_color *)blend_factor, sample_mask);
else
wined3d_device_set_blend_state(device->wined3d_device, blend_state_impl->wined3d_state,
(const struct wined3d_color *)blend_factor);
(const struct wined3d_color *)blend_factor, sample_mask);
wined3d_mutex_unlock();
}
......@@ -1886,7 +1885,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11Devi
wined3d_mutex_lock();
if ((wined3d_state = wined3d_device_get_blend_state(device->wined3d_device,
(struct wined3d_color *)blend_factor)))
(struct wined3d_color *)blend_factor, sample_mask)))
{
blend_state_impl = wined3d_blend_state_get_parent(wined3d_state);
ID3D11BlendState_AddRef(*blend_state = &blend_state_impl->ID3D11BlendState_iface);
......@@ -1895,7 +1894,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11Devi
{
*blend_state = NULL;
}
*sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK);
wined3d_mutex_unlock();
}
......
......@@ -39,6 +39,7 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] =
{STATE_STREAM_OUTPUT, {STATE_STREAM_OUTPUT, state_nop}},
{STATE_BLEND, {STATE_BLEND, state_nop}},
{STATE_BLEND_FACTOR, {STATE_BLEND_FACTOR, state_nop}},
{STATE_SAMPLE_MASK, {STATE_SAMPLE_MASK, state_nop}},
{STATE_STREAMSRC, {STATE_STREAMSRC, state_nop}},
{STATE_VDECL, {STATE_VDECL, state_nop}},
{STATE_RASTERIZER, {STATE_RASTERIZER, state_nop}},
......@@ -161,7 +162,6 @@ static const struct wined3d_state_entry_template misc_state_template_vk[] =
{STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W), {STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION)}},
{STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION), {STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION), state_nop}},
{STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), {STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), state_nop}},
{STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), {STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), state_nop}},
{STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), {STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), state_nop}},
{STATE_RENDER(WINED3D_RS_ZVISIBLE), {STATE_RENDER(WINED3D_RS_ZVISIBLE), state_nop}},
/* Samplers */
......
......@@ -266,6 +266,7 @@ struct wined3d_cs_set_blend_state
enum wined3d_cs_op opcode;
struct wined3d_blend_state *state;
struct wined3d_color factor;
unsigned int sample_mask;
};
struct wined3d_cs_set_rasterizer_state
......@@ -1636,10 +1637,12 @@ static void wined3d_cs_exec_set_blend_state(struct wined3d_cs *cs, const void *d
}
state->blend_factor = op->factor;
device_invalidate_state(cs->device, STATE_BLEND_FACTOR);
state->sample_mask = op->sample_mask;
device_invalidate_state(cs->device, STATE_SAMPLE_MASK);
}
void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state,
const struct wined3d_color *blend_factor)
const struct wined3d_color *blend_factor, unsigned int sample_mask)
{
struct wined3d_cs_set_blend_state *op;
......@@ -1647,6 +1650,7 @@ void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend
op->opcode = WINED3D_CS_OP_SET_BLEND_STATE;
op->state = state;
op->factor = *blend_factor;
op->sample_mask = sample_mask;
wined3d_cs_submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
......
......@@ -1705,34 +1705,38 @@ static void resolve_depth_buffer(struct wined3d_device *device)
}
void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor)
struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
{
struct wined3d_state *state = &device->state;
struct wined3d_blend_state *prev;
TRACE("device %p, blend_state %p, blend_factor %s.\n", device, blend_state, debug_color(blend_factor));
TRACE("device %p, blend_state %p, blend_factor %s, sample_mask %#x.\n",
device, blend_state, debug_color(blend_factor), sample_mask);
prev = state->blend_state;
if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)))
if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor))
&& sample_mask == state->sample_mask)
return;
if (blend_state)
wined3d_blend_state_incref(blend_state);
state->blend_state = blend_state;
state->blend_factor = *blend_factor;
wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor);
state->sample_mask = sample_mask;
wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor, sample_mask);
if (prev)
wined3d_blend_state_decref(prev);
}
struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct wined3d_device *device,
struct wined3d_color *blend_factor)
struct wined3d_color *blend_factor, unsigned int *sample_mask)
{
const struct wined3d_state *state = &device->state;
TRACE("device %p, blend_factor %p.\n", device, blend_factor);
TRACE("device %p, blend_factor %p, sample_mask %p.\n", device, blend_factor, sample_mask);
*blend_factor = state->blend_factor;
*sample_mask = state->sample_mask;
return state->blend_state;
}
......@@ -3615,6 +3619,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
switch (idx)
{
case WINED3D_RS_BLENDFACTOR:
case WINED3D_RS_MULTISAMPLEMASK:
case WINED3D_RS_ALPHABLENDENABLE:
case WINED3D_RS_SRCBLEND:
case WINED3D_RS_DESTBLEND:
......@@ -3692,6 +3697,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
struct wined3d_blend_state_desc desc;
struct wine_rb_entry *entry;
struct wined3d_color colour;
unsigned int sample_mask;
memset(&desc, 0, sizeof(desc));
desc.alpha_to_coverage = state->alpha_to_coverage;
......@@ -3738,17 +3744,17 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR))
wined3d_color_from_d3dcolor(&colour, state->rs[WINED3D_RS_BLENDFACTOR]);
else
wined3d_device_get_blend_state(device, &colour);
wined3d_device_get_blend_state(device, &colour, &sample_mask);
if ((entry = wine_rb_get(&device->blend_states, &desc)))
{
blend_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry);
wined3d_device_set_blend_state(device, blend_state, &colour);
wined3d_device_set_blend_state(device, blend_state, &colour, state->rs[WINED3D_RS_MULTISAMPLEMASK]);
}
else if (SUCCEEDED(wined3d_blend_state_create(device, &desc, NULL,
&wined3d_null_parent_ops, &blend_state)))
{
wined3d_device_set_blend_state(device, blend_state, &colour);
wined3d_device_set_blend_state(device, blend_state, &colour, state->rs[WINED3D_RS_MULTISAMPLEMASK]);
if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1)
{
ERR("Failed to insert blend state.\n");
......
......@@ -2365,6 +2365,7 @@ static const struct wined3d_state_entry_template misc_state_template_no3d[] =
{STATE_STREAM_OUTPUT, {STATE_VDECL}},
{STATE_BLEND, {STATE_VDECL}},
{STATE_BLEND_FACTOR, {STATE_VDECL}},
{STATE_SAMPLE_MASK, {STATE_VDECL}},
{STATE_STREAMSRC, {STATE_VDECL}},
{STATE_VDECL, {STATE_VDECL, state_nop}},
{STATE_RASTERIZER, {STATE_VDECL}},
......@@ -2487,7 +2488,6 @@ static const struct wined3d_state_entry_template misc_state_template_no3d[] =
{STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W), {STATE_VDECL}},
{STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION), {STATE_VDECL}},
{STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), {STATE_VDECL}},
{STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), {STATE_VDECL}},
{STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), {STATE_VDECL}},
{STATE_RENDER(WINED3D_RS_ZVISIBLE), {STATE_VDECL}},
/* Samplers */
......
......@@ -1923,11 +1923,10 @@ static void state_antialias(struct wined3d_context *context, const struct wined3
FIXME("Antialias not supported yet.\n");
}
static void state_multisampmask(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void state_sample_mask(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
if (state->render_states[WINED3D_RS_MULTISAMPLEMASK] != 0xffffffff)
FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n",
state->render_states[WINED3D_RS_MULTISAMPLEMASK]);
if (state->sample_mask != 0xffffffff)
FIXME("Sample mask %#x not yet implemented.\n", state->sample_mask);
}
static void state_patchedgestyle(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
......@@ -4604,6 +4603,7 @@ const struct wined3d_state_entry_template misc_state_template_gl[] =
{ STATE_BLEND, { STATE_BLEND, blend }, WINED3D_GL_EXT_NONE },
{ STATE_BLEND_FACTOR, { STATE_BLEND_FACTOR, state_blend_factor }, EXT_BLEND_COLOR },
{ STATE_BLEND_FACTOR, { STATE_BLEND_FACTOR, state_blend_factor_w}, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLE_MASK, { STATE_SAMPLE_MASK, state_sample_mask }, WINED3D_GL_EXT_NONE },
{ STATE_STREAMSRC, { STATE_STREAMSRC, streamsrc }, WINED3D_GL_EXT_NONE },
{ STATE_VDECL, { STATE_VDECL, vdecl_miscpart }, WINED3D_GL_EXT_NONE },
{ STATE_RASTERIZER, { STATE_RASTERIZER, rasterizer_cc }, ARB_CLIP_CONTROL },
......@@ -4738,7 +4738,6 @@ const struct wined3d_state_entry_template misc_state_template_gl[] =
{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),state_tessellation }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), state_msaa }, ARB_MULTISAMPLE },
{ STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), state_msaa_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), state_multisampmask }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), state_debug_monitor }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
/* Samplers */
......@@ -5505,6 +5504,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table)
{ 47, 47},
{ 61, 127},
{149, 150},
{162, 162},
{168, 169},
{171, 171},
{174, 177},
......
......@@ -1848,6 +1848,8 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->blend_factor.b = 1.0f;
state->blend_factor.a = 1.0f;
state->sample_mask = 0xffffffff;
for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
state->streams[i].frequency = 1;
}
......
......@@ -1770,7 +1770,10 @@ enum wined3d_pipeline
#define STATE_BLEND_FACTOR (STATE_BLEND + 1)
#define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
#define STATE_COMPUTE_OFFSET (STATE_BLEND_FACTOR + 1)
#define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
#define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
#define STATE_COMPUTE_OFFSET (STATE_SAMPLE_MASK + 1)
#define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
#define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
......@@ -3611,6 +3614,7 @@ struct wined3d_state
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
struct wined3d_blend_state *blend_state;
struct wined3d_color blend_factor;
unsigned int sample_mask;
struct wined3d_rasterizer_state *rasterizer_state;
};
......@@ -4606,7 +4610,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,
const struct wined3d_color *blend_factor) DECLSPEC_HIDDEN;
const struct wined3d_color *blend_factor, unsigned int sample_mask) 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,
......
......@@ -2339,7 +2339,7 @@ void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *devic
void __cdecl wined3d_device_flush(struct wined3d_device *device);
UINT __cdecl wined3d_device_get_available_texture_mem(const struct wined3d_device *device);
struct wined3d_blend_state * __cdecl wined3d_device_get_blend_state(const struct wined3d_device *device,
struct wined3d_color *blend_factor);
struct wined3d_color *blend_factor, unsigned int *sample_mask);
HRESULT __cdecl wined3d_device_get_clip_status(const struct wined3d_device *device,
struct wined3d_clip_status *clip_status);
struct wined3d_shader * __cdecl wined3d_device_get_compute_shader(const struct wined3d_device *device);
......@@ -2422,7 +2422,7 @@ void __cdecl wined3d_device_resolve_sub_resource(struct wined3d_device *device,
enum wined3d_format_id format_id);
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,
const struct wined3d_color *blend_factor);
const struct wined3d_color *blend_factor, unsigned int sample_mask);
HRESULT __cdecl wined3d_device_set_clip_status(struct wined3d_device *device,
const struct wined3d_clip_status *clip_status);
void __cdecl wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader);
......
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