Signed-off-by: Chip Davis cdavis@codeweavers.com --- v2: Hoist a couple of GL_MULTISAMPLE enables into wined3d_context_gl_apply_blit_state(). --- dlls/wined3d/context_gl.c | 5 +++++ dlls/wined3d/surface.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 9dbd0346ff3..fa2f117fe9c 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2773,6 +2773,11 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, gl_info->gl_ops.gl.p_glDisable(GL_BLEND); gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); context_invalidate_state(context, STATE_BLEND); + if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); + } gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE); gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index e965203950e..6ab5bd10325 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -130,6 +130,11 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct context_invalidate_state(context, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK)); }
+ if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); + } gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER);
@@ -251,6 +256,11 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); context_invalidate_state(context, STATE_BLEND);
+ if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); + } gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER);
@@ -848,6 +858,12 @@ void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(&texture_gl->t)); checkGLcall("glReadBuffer");
+ if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); + } + level = sub_resource_idx % texture_gl->t.level_count; target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx); gl_info->gl_ops.gl.p_glCopyTexSubImage2D(target, level, 0, 0, 0, 0,
Have d3d8 and d3d9 enable it on startup and reset.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- dlls/d3d8/device.c | 2 ++ dlls/d3d9/device.c | 2 ++ dlls/wined3d/stateblock.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e123502dab6..32ba5c2c1ba 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -984,6 +984,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface, wined3d_stateblock_set_render_state(device->state, WINED3D_RS_POINTSIZE_MIN, 0); wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc.enable_auto_depth_stencil); + wined3d_stateblock_set_render_state(device->state, WINED3D_RS_MULTISAMPLEANTIALIAS, TRUE); device_reset_viewport_state(device); device->device_state = D3D8_DEVICE_STATE_OK; } @@ -3819,6 +3820,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc.enable_auto_depth_stencil); wined3d_stateblock_set_render_state(device->state, WINED3D_RS_POINTSIZE_MIN, 0); + wined3d_stateblock_set_render_state(device->state, WINED3D_RS_MULTISAMPLEANTIALIAS, TRUE); device_reset_viewport_state(device); wined3d_mutex_unlock();
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 61aee971a1d..5c5e45e6ff9 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1099,6 +1099,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, device->auto_mipmaps = 0; wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc.enable_auto_depth_stencil); + wined3d_stateblock_set_render_state(device->state, WINED3D_RS_MULTISAMPLEANTIALIAS, TRUE); device_reset_viewport_state(device); }
@@ -4791,6 +4792,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil); + wined3d_stateblock_set_render_state(device->state, WINED3D_RS_MULTISAMPLEANTIALIAS, TRUE); device_reset_viewport_state(device);
if (FAILED(hr = d3d9_device_get_swapchains(device))) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 7e97c84c19e..001a9b6debd 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1709,7 +1709,7 @@ static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], c rs[WINED3D_RS_POINTSCALE_B] = tmpfloat.d; tmpfloat.f = 0.0f; rs[WINED3D_RS_POINTSCALE_C] = tmpfloat.d; - rs[WINED3D_RS_MULTISAMPLEANTIALIAS] = TRUE; + rs[WINED3D_RS_MULTISAMPLEANTIALIAS] = FALSE; rs[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff; rs[WINED3D_RS_PATCHEDGESTYLE] = WINED3D_PATCH_EDGE_DISCRETE; tmpfloat.f = 1.0f;
Signed-off-by: Chip Davis cdavis@codeweavers.com --- v3: Rebase and update. --- dlls/d3d11/device.c | 15 +++---------- dlls/d3d11/state.c | 1 + dlls/wined3d/context_gl.c | 3 --- dlls/wined3d/device.c | 2 ++ dlls/wined3d/state.c | 46 +++++++++++++++++++-------------------- dlls/wined3d/surface.c | 8 +------ include/wine/wined3d.h | 1 + 7 files changed, 30 insertions(+), 46 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 7544bc86f4b..7c75431780c 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -896,18 +896,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
wined3d_mutex_lock(); - if (!(rasterizer_state_impl = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state))) - { - wined3d_device_set_rasterizer_state(device->wined3d_device, NULL); - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE); - wined3d_mutex_unlock(); - return; - } - - wined3d_device_set_rasterizer_state(device->wined3d_device, rasterizer_state_impl->wined3d_state); - - desc = &rasterizer_state_impl->desc; - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable); + rasterizer_state_impl = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state); + wined3d_device_set_rasterizer_state(device->wined3d_device, + rasterizer_state_impl ? rasterizer_state_impl->wined3d_state : NULL); wined3d_mutex_unlock(); }
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 32ef44091c4..6d7f70664e7 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -1118,6 +1118,7 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str wined3d_desc.scale_bias = desc->SlopeScaledDepthBias; wined3d_desc.depth_clip = desc->DepthClipEnable; wined3d_desc.scissor = desc->ScissorEnable; + wined3d_desc.multisample = desc->MultisampleEnable; wined3d_desc.line_antialias = desc->AntialiasedLineEnable;
/* We cannot fail after creating a wined3d_rasterizer_state object. It diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index fa2f117fe9c..8cd37153cb4 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2774,10 +2774,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); context_invalidate_state(context, STATE_BLEND); if (gl_info->supported[ARB_MULTISAMPLE]) - { gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); - } gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE); gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ee007568d46..8baf9b9df19 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3608,6 +3608,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_SLOPESCALEDEPTHBIAS: case WINED3D_RS_DEPTHBIAS: case WINED3D_RS_SCISSORTESTENABLE: + case WINED3D_RS_MULTISAMPLEANTIALIAS: case WINED3D_RS_ANTIALIASEDLINEENABLE: set_rasterizer_state = TRUE; break; @@ -3639,6 +3640,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, desc.scale_bias = bias.f; desc.depth_clip = TRUE; desc.scissor = state->rs[WINED3D_RS_SCISSORTESTENABLE]; + desc.multisample = state->rs[WINED3D_RS_MULTISAMPLEANTIALIAS]; desc.line_antialias = state->rs[WINED3D_RS_ANTIALIASEDLINEENABLE];
if ((entry = wine_rb_get(&device->rasterizer_states, &desc))) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 1cb9f222eab..d7792f46168 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1776,28 +1776,6 @@ static void state_wrap(struct wined3d_context *context, const struct wined3d_sta FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n"); }
-static void state_msaa_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) -{ - if (state->render_states[WINED3D_RS_MULTISAMPLEANTIALIAS]) - WARN("Multisample antialiasing not supported by GL.\n"); -} - -static void state_msaa(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) -{ - const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - - if (state->render_states[WINED3D_RS_MULTISAMPLEANTIALIAS]) - { - gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE_ARB); - checkGLcall("glEnable(GL_MULTISAMPLE_ARB)"); - } - else - { - gl_info->gl_ops.gl.p_glDisable(GL_MULTISAMPLE_ARB); - checkGLcall("glDisable(GL_MULTISAMPLE_ARB)"); - } -} - static void line_antialias(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info) { if (r && r->desc.line_antialias) @@ -4407,6 +4385,25 @@ static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wi checkGLcall("depth clip"); }
+static void multisample(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info) +{ + if (r && r->desc.multisample) + { + if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); + checkGLcall("glEnable GL_MULTISAMPLE"); + } + else + WARN("Multisample antialiasing not supported by GL.\n"); + } + else if (gl_info->supported[ARB_MULTISAMPLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_MULTISAMPLE); + checkGLcall("glDisable GL_MULTISAMPLE"); + } +} + static void rasterizer(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; @@ -4424,6 +4421,7 @@ static void rasterizer(struct wined3d_context *context, const struct wined3d_sta cullmode(r, gl_info); depth_clip(r, gl_info); scissor(r, gl_info); + multisample(r, gl_info); line_antialias(r, gl_info); }
@@ -4442,6 +4440,7 @@ static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_ cullmode(r, gl_info); depth_clip(r, gl_info); scissor(r, gl_info); + multisample(r, gl_info); line_antialias(r, gl_info); }
@@ -4736,8 +4735,6 @@ const struct wined3d_state_entry_template misc_state_template[] = { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),state_nvdb }, EXT_DEPTH_BOUNDS_TEST }, { 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 }, @@ -5505,6 +5502,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 47, 47}, { 61, 127}, {149, 150}, + {161, 161}, {168, 169}, {171, 171}, {174, 177}, diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 6ab5bd10325..8b425fe3ad1 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -131,10 +131,7 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct }
if (gl_info->supported[ARB_MULTISAMPLE]) - { gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); - } gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER);
@@ -257,10 +254,7 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co context_invalidate_state(context, STATE_BLEND);
if (gl_info->supported[ARB_MULTISAMPLE]) - { gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); - } gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST); context_invalidate_state(context, STATE_RASTERIZER);
@@ -861,7 +855,7 @@ void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, if (gl_info->supported[ARB_MULTISAMPLE]) { gl_info->gl_ops.gl.p_glEnable(GL_MULTISAMPLE); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS)); + context_invalidate_state(context, STATE_RASTERIZER); }
level = sub_resource_idx % texture_gl->t.level_count; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index d3eb8100cd8..f9a0d9e0f89 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2043,6 +2043,7 @@ struct wined3d_rasterizer_state_desc float scale_bias; BOOL depth_clip; BOOL scissor; + BOOL multisample; BOOL line_antialias; };
Signed-off-by: Chip Davis cdavis@codeweavers.com --- dlls/d3d11/device.c | 8 +++----- dlls/wined3d/cs.c | 6 +++++- dlls/wined3d/device.c | 27 +++++++++++++++++---------- dlls/wined3d/state.c | 18 +++++++++--------- dlls/wined3d/utils.c | 2 ++ dlls/wined3d/wined3d_private.h | 8 ++++++-- include/wine/wined3d.h | 4 ++-- 7 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 7c75431780c..23d05e08b49 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -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(); }
@@ -1877,7 +1876,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); @@ -1886,7 +1885,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(); }
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 899d5a712e4..943ffe9af62 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -265,6 +265,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 @@ -1565,11 +1566,13 @@ static void wined3d_cs_exec_set_blend_state(struct wined3d_cs *cs, const void *d device_invalidate_state(cs->device, STATE_BLEND); } state->blend_factor = op->factor; + state->sample_mask = op->sample_mask; device_invalidate_state(cs->device, STATE_BLEND_FACTOR); + 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;
@@ -1577,6 +1580,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); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8baf9b9df19..4c60c140784 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1678,34 +1678,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 0x%08x.\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; }
@@ -3588,6 +3592,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: @@ -3667,6 +3672,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; @@ -3710,20 +3716,21 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } }
+ wined3d_device_get_blend_state(device, &colour, &sample_mask); 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); + if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_MULTISAMPLEMASK)) + sample_mask = state->rs[WINED3D_RS_MULTISAMPLEMASK];
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, sample_mask); } 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, sample_mask); if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1) { ERR("Failed to insert blend state.\n"); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index d7792f46168..42666e9ccc2 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -552,6 +552,12 @@ static void state_blend_factor(struct wined3d_context *context, const struct win checkGLcall("glBlendColor"); }
+static void state_multisampmask(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + if (state->sample_mask != 0xffffffff) + FIXME("Sample mask %#x not yet implemented.\n", state->sample_mask); +} + static BOOL is_blend_enabled(struct wined3d_context *context, const struct wined3d_state *state, UINT index) { const struct wined3d_blend_state *b = state->blend_state; @@ -1901,13 +1907,6 @@ 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) -{ - if (state->render_states[WINED3D_RS_MULTISAMPLEMASK] != 0xffffffff) - FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n", - state->render_states[WINED3D_RS_MULTISAMPLEMASK]); -} - static void state_patchedgestyle(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { if (state->render_states[WINED3D_RS_PATCHEDGESTYLE] != WINED3D_PATCH_EDGE_DISCRETE) @@ -4603,6 +4602,7 @@ const struct wined3d_state_entry_template misc_state_template[] = { 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_multisampmask }, 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 }, @@ -4735,7 +4735,6 @@ const struct wined3d_state_entry_template misc_state_template[] = { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),state_nvdb }, EXT_DEPTH_BOUNDS_TEST }, { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION),state_tessellation }, 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 */ @@ -5502,7 +5501,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 47, 47}, { 61, 127}, {149, 150}, - {161, 161}, + {161, 162}, {168, 169}, {171, 171}, {174, 177}, @@ -5544,6 +5543,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) STATE_COLOR_KEY, STATE_BLEND, STATE_BLEND_FACTOR, + STATE_SAMPLE_MASK, }; unsigned int i, current;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index fa1763346bc..c18f2371758 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5262,6 +5262,8 @@ const char *debug_d3dstate(DWORD state) return "STATE_BLEND"; if (STATE_IS_BLEND_FACTOR(state)) return "STATE_BLEND_FACTOR"; + if (STATE_IS_SAMPLE_MASK(state)) + return "STATE_SAMPLE_MASK";
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index eb74aeb2bd4..fb0c8e78202 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1720,7 +1720,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) @@ -3284,6 +3287,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; };
@@ -4209,7 +4213,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, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index f9a0d9e0f89..3b541714f4f 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2336,7 +2336,7 @@ HRESULT __cdecl wined3d_device_end_scene(struct wined3d_device *device); void __cdecl wined3d_device_evict_managed_resources(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); @@ -2419,7 +2419,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);