Zebediah Figura : wined3d: Move the depth bias scale to wined3d_rasterizer_state.
Alexandre Julliard
julliard at winehq.org
Fri Mar 6 16:38:41 CST 2020
Module: wine
Branch: master
Commit: bdb2ead58d4282ecb9f65d558347730c4d45f6ff
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bdb2ead58d4282ecb9f65d558347730c4d45f6ff
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Thu Mar 5 19:28:11 2020 -0600
wined3d: Move the depth bias scale to wined3d_rasterizer_state.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3d11/device.c | 5 +----
dlls/d3d11/state.c | 3 ++-
dlls/wined3d/device.c | 8 ++++++++
dlls/wined3d/state.c | 14 +++++++-------
include/wine/wined3d.h | 1 +
5 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 63d7f1dc2b..0e46816246 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -933,7 +933,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
{
DWORD d;
float f;
- } scale_bias, const_bias;
+ } const_bias;
TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
@@ -941,7 +941,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
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_SLOPESCALEDEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
@@ -953,9 +952,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_rasterizer_state(device->wined3d_device, rasterizer_state_impl->wined3d_state);
desc = &rasterizer_state_impl->desc;
- scale_bias.f = desc->SlopeScaledDepthBias;
const_bias.f = desc->DepthBias;
- wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, scale_bias.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, const_bias.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c
index 47d42fd6c5..4d56f7dc75 100644
--- a/dlls/d3d11/state.c
+++ b/dlls/d3d11/state.c
@@ -1079,8 +1079,9 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str
wined3d_desc.fill_mode = desc->FillMode;
wined3d_desc.cull_mode = desc->CullMode;
wined3d_desc.front_ccw = desc->FrontCounterClockwise;
- wined3d_desc.depth_clip = desc->DepthClipEnable;
wined3d_desc.depth_bias_clamp = desc->DepthBiasClamp;
+ wined3d_desc.scale_bias = desc->SlopeScaledDepthBias;
+ wined3d_desc.depth_clip = desc->DepthClipEnable;
/* We cannot fail after creating a wined3d_rasterizer_state object. It
* would lead to double free. */
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 34482d8ea2..03c32ec6f2 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3600,6 +3600,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
case WINED3D_RS_FILLMODE:
case WINED3D_RS_CULLMODE:
+ case WINED3D_RS_SLOPESCALEDEPTHBIAS:
set_rasterizer_state = TRUE;
break;
@@ -3615,11 +3616,18 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
struct wined3d_rasterizer_state *rasterizer_state;
struct wined3d_rasterizer_state_desc desc;
struct wine_rb_entry *entry;
+ union
+ {
+ DWORD d;
+ float f;
+ } bias;
desc.fill_mode = state->rs[WINED3D_RS_FILLMODE];
desc.cull_mode = state->rs[WINED3D_RS_CULLMODE];
desc.front_ccw = FALSE;
desc.depth_bias_clamp = 0.0f;
+ bias.d = state->rs[WINED3D_RS_SLOPESCALEDEPTHBIAS];
+ desc.scale_bias = bias.f;
desc.depth_clip = TRUE;
if ((entry = wine_rb_get(&device->rasterizer_states, &desc)))
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 5cf425f0a5..85bd1e24a3 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1755,9 +1755,10 @@ static void state_scissor(struct wined3d_context *context, const struct wined3d_
static void state_depthbias(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;
+ const struct wined3d_rasterizer_state *r = state->rasterizer_state;
+ float scale_bias = r ? r->desc.scale_bias : 0.0f;
- if (state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS]
- || state->render_states[WINED3D_RS_DEPTHBIAS])
+ if (scale_bias || state->render_states[WINED3D_RS_DEPTHBIAS])
{
const struct wined3d_rendertarget_view *depth = state->fb->depth_stencil;
float factor, units, scale, clamp;
@@ -1766,10 +1767,9 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
{
DWORD d;
float f;
- } scale_bias, const_bias;
+ } const_bias;
- clamp = state->rasterizer_state ? state->rasterizer_state->desc.depth_bias_clamp : 0.0f;
- scale_bias.d = state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS];
+ clamp = r ? r->desc.depth_bias_clamp : 0.0f;
const_bias.d = state->render_states[WINED3D_RS_DEPTHBIAS];
if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_DEPTH_BIAS)
@@ -1792,7 +1792,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
scale = 0.0f;
}
- factor = scale_bias.f;
+ factor = scale_bias;
units = const_bias.f * scale;
}
@@ -4663,7 +4663,6 @@ const struct wined3d_state_entry_template misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_BLENDOP), { STATE_RENDER(WINED3D_RS_BLENDOP), state_blendop }, WINED3D_GL_BLEND_EQUATION },
{ STATE_RENDER(WINED3D_RS_BLENDOP), { STATE_RENDER(WINED3D_RS_BLENDOP), state_blendop_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE), state_scissor }, WINED3D_GL_EXT_NONE },
- { STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), state_colorwrite1 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), state_colorwrite2 }, EXT_DRAW_BUFFERS2 },
@@ -5436,6 +5435,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table)
{ 61, 127},
{149, 150},
{169, 169},
+ {175, 175},
{177, 177},
{193, 193},
{196, 197},
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index bfdd1b9ca3..3b7b837d3e 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2037,6 +2037,7 @@ struct wined3d_rasterizer_state_desc
enum wined3d_cull cull_mode;
BOOL front_ccw;
float depth_bias_clamp;
+ float scale_bias;
BOOL depth_clip;
};
More information about the wine-cvs
mailing list