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; };