From: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/cs.c | 3 +- dlls/wined3d/directx.c | 4 --- dlls/wined3d/state.c | 5 +-- dlls/wined3d/utils.c | 76 ++++++++++++++++++++++++++---------------- dlls/wined3d/wined3d_private.h | 3 +- 5 files changed, 50 insertions(+), 41 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index dbe9f42beb9d..78443d174a27 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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_DEPTHBIAS)); } - else if (prev && (prev->format_flags & WINED3DFMT_FLAG_FLOAT) - != (op->view->format_flags & WINED3DFMT_FLAG_FLOAT)) + else if (prev && prev->format->depth_bias_scale != op->view->format->depth_bias_scale) { device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 5058740464a2..ecb55bd11534 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -6634,10 +6634,6 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, 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_used = 0; TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes)); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index f3ec7df1863a..0b7c74747467 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1716,10 +1716,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3 { if (depth) { - if (depth->format_flags & WINED3DFMT_FLAG_FLOAT) - scale = gl_info->float_polyoffset_scale; - else - scale = gl_info->fixed_polyoffset_scale; + scale = depth->format->depth_bias_scale;
TRACE("Depth format %s, using depthbias scale of %.8e.\n", debug_d3dformat(depth->format->id), scale); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index cd0a8e15c908..1a75dd713920 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3565,33 +3565,6 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info) 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) { 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; }
-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; 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; 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; } } @@ -3733,6 +3706,51 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe 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, enum wined3d_format_id format_id, unsigned int resource_usage) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2321b41ad53f..4580983a1738 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2558,7 +2558,6 @@ struct wined3d_gl_info DWORD quirks; BOOL supported[WINED3D_GL_EXT_COUNT]; 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); struct opengl_funcs gl_ops; @@ -2614,7 +2613,6 @@ struct wined3d_caps_gl_ctx 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, struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN; UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN; @@ -4235,6 +4233,7 @@ struct wined3d_format UINT conv_byte_count; DWORD multisample_types; unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]; + float depth_bias_scale; struct wined3d_rational height_scale; struct color_fixup_desc color_fixup; void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,