wined3d: Detect depth bias scale value per format.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2017-12-06 11:00:32 +01:00 committed by Alexandre Julliard
parent 9c8e781df1
commit 5fb50c9a1c
5 changed files with 50 additions and 41 deletions

View File

@ -1032,8 +1032,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
} }
else if (prev && (prev->format_flags & WINED3DFMT_FLAG_FLOAT) else if (prev && prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
!= (op->view->format_flags & WINED3DFMT_FLAG_FLOAT))
{ {
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
} }

View File

@ -6636,10 +6636,6 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
return FALSE; return FALSE;
} }
gl_info->fixed_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH_COMPONENT);
if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT])
gl_info->float_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH32F_STENCIL8);
adapter->vram_bytes = adapter->driver_info.vram_bytes; adapter->vram_bytes = adapter->driver_info.vram_bytes;
adapter->vram_bytes_used = 0; adapter->vram_bytes_used = 0;
TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes)); TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));

View File

@ -1716,10 +1716,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
{ {
if (depth) if (depth)
{ {
if (depth->format_flags & WINED3DFMT_FLAG_FLOAT) scale = depth->format->depth_bias_scale;
scale = gl_info->float_polyoffset_scale;
else
scale = gl_info->fixed_polyoffset_scale;
TRACE("Depth format %s, using depthbias scale of %.8e.\n", TRACE("Depth format %s, using depthbias scale of %.8e.\n",
debug_d3dformat(depth->format->id), scale); debug_d3dformat(depth->format->id), scale);

View File

@ -3565,33 +3565,6 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
return TRUE; return TRUE;
} }
/* Context activation is done by the caller. */
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail;
apply_format_fixups(adapter, gl_info);
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
gl_info->formats = NULL;
return FALSE;
}
BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx)
{ {
static const struct wined3d_color red = {1.0f, 0.0f, 0.0f, 1.0f}; static const struct wined3d_color red = {1.0f, 0.0f, 0.0f, 1.0f};
@ -3639,7 +3612,7 @@ BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
return TRUE; return TRUE;
} }
float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format) static float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format)
{ {
const struct wined3d_gl_info *gl_info = ctx->gl_info; const struct wined3d_gl_info *gl_info = ctx->gl_info;
static const struct wined3d_color blue = {0.0f, 0.0f, 1.0f, 1.0f}; static const struct wined3d_color blue = {0.0f, 0.0f, 1.0f, 1.0f};
@ -3717,7 +3690,7 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe
low = cur; low = cur;
else else
{ {
TRACE("Found scale factor 2^%u for format %x\n", cur, format); TRACE("Found scale factor 2^%u for format %x.\n", cur, format);
break; break;
} }
} }
@ -3733,6 +3706,51 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe
return (float)(1u << cur); return (float)(1u << cur);
} }
static void init_format_depth_bias_scale(struct wined3d_caps_gl_ctx *ctx)
{
const struct wined3d_gl_info *gl_info = ctx->gl_info;
unsigned int i;
for (i = 0; i < gl_info->format_count; ++i)
{
struct wined3d_format *format = &gl_info->formats[i];
if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
{
TRACE("Testing depth bias scale for format %s.\n", debug_d3dformat(format->id));
format->depth_bias_scale = wined3d_adapter_find_polyoffset_scale(ctx, format->glInternal);
}
}
}
/* Context activation is done by the caller. */
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail;
apply_format_fixups(adapter, gl_info);
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
init_format_depth_bias_scale(ctx);
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
gl_info->formats = NULL;
return FALSE;
}
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info, const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
enum wined3d_format_id format_id, unsigned int resource_usage) enum wined3d_format_id format_id, unsigned int resource_usage)
{ {

View File

@ -2559,7 +2559,6 @@ struct wined3d_gl_info
DWORD quirks; DWORD quirks;
BOOL supported[WINED3D_GL_EXT_COUNT]; BOOL supported[WINED3D_GL_EXT_COUNT];
GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1]; GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
float fixed_polyoffset_scale, float_polyoffset_scale;
HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs); HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
struct opengl_funcs gl_ops; struct opengl_funcs gl_ops;
@ -2615,7 +2614,6 @@ struct wined3d_caps_gl_ctx
GLuint test_program_id; GLuint test_program_id;
}; };
float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format) DECLSPEC_HIDDEN;
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter,
struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN; struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN; UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
@ -4236,6 +4234,7 @@ struct wined3d_format
UINT conv_byte_count; UINT conv_byte_count;
DWORD multisample_types; DWORD multisample_types;
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]; unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
float depth_bias_scale;
struct wined3d_rational height_scale; struct wined3d_rational height_scale;
struct color_fixup_desc color_fixup; struct color_fixup_desc color_fixup;
void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,