wined3d: Move the depth bias scale to wined3d_rasterizer_state.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6045fe027b
commit
bdb2ead58d
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue