Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
May 2019
- 96 participants
- 789 discussions
[PATCH 6/8] wined3d: Pass a wined3d_context_gl structure to context_load_numbered_arrays().
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
From: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 2e4869bf74b..51832652ed7 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -5334,9 +5334,10 @@ static void context_unload_numbered_arrays(struct wined3d_context *context)
}
}
-static void context_load_numbered_arrays(struct wined3d_context *context,
+static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *context_gl,
const struct wined3d_stream_info *stream_info, const struct wined3d_state *state)
{
+ struct wined3d_context *context = &context_gl->c;
const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
const struct wined3d_gl_info *gl_info = context->gl_info;
GLuint current_bo;
@@ -5540,7 +5541,7 @@ void context_update_stream_sources(struct wined3d_context *context, const struct
if (context->d3d_info->ffp_generic_attributes || use_vs(state))
{
TRACE("Loading numbered arrays.\n");
- context_load_numbered_arrays(context, &context->stream_info, state);
+ wined3d_context_gl_load_numbered_arrays(wined3d_context_gl(context), &context->stream_info, state);
return;
}
--
2.11.0
1
0
[PATCH 5/8] wined3d: Pass a wined3d_context_gl structure to context_apply_clear_state().
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 50 +++++++++++++++++++++---------------------
dlls/wined3d/device.c | 4 +++-
dlls/wined3d/wined3d_private.h | 16 +++++++-------
3 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 86c74c5c9f3..2e4869bf74b 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3004,16 +3004,16 @@ static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_re
}
/* Context activation is done by the caller. */
-BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
- UINT rt_count, const struct wined3d_fb_state *fb)
+BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl,
+ const struct wined3d_state *state, unsigned int rt_count, const struct wined3d_fb_state *fb)
{
struct wined3d_rendertarget_view * const *rts = fb->render_targets;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
- const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD rt_mask = 0, *cur_mask;
unsigned int i;
- if (isStateDirty(context, STATE_FRAMEBUFFER) || fb != state->fb
+ if (isStateDirty(&context_gl->c, STATE_FRAMEBUFFER) || fb != state->fb
|| rt_count != gl_info->limits.buffers)
{
if (!have_framebuffer_attachment(rt_count, rts, dsv))
@@ -3028,16 +3028,16 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))
{
- memset(context->blit_targets, 0, sizeof(context->blit_targets));
+ memset(context_gl->c.blit_targets, 0, sizeof(context_gl->c.blit_targets));
for (i = 0; i < rt_count; ++i)
{
if (rts[i])
{
struct wined3d_rendertarget_view_gl *rtv_gl = wined3d_rendertarget_view_gl(rts[i]);
- context->blit_targets[i].gl_view = rtv_gl->gl_view;
- context->blit_targets[i].resource = rtv_gl->v.resource;
- context->blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx;
- context->blit_targets[i].layer_count = rtv_gl->v.layer_count;
+ context_gl->c.blit_targets[i].gl_view = rtv_gl->gl_view;
+ context_gl->c.blit_targets[i].resource = rtv_gl->v.resource;
+ context_gl->c.blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx;
+ context_gl->c.blit_targets[i].layer_count = rtv_gl->v.layer_count;
}
if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
rt_mask |= (1u << i);
@@ -3052,13 +3052,13 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
ds_info.layer_count = dsv_gl->v.layer_count;
}
- context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, &ds_info,
+ context_apply_fbo_state(&context_gl->c, GL_FRAMEBUFFER, context_gl->c.blit_targets, &ds_info,
rt_count ? rts[0]->resource->draw_binding : 0,
dsv ? dsv->resource->draw_binding : 0);
}
else
{
- context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, &ds_info,
+ context_apply_fbo_state(&context_gl->c, GL_FRAMEBUFFER, NULL, &ds_info,
WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE);
rt_mask = context_generate_rt_mask_from_resource(rts[0]->resource);
}
@@ -3066,11 +3066,11 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
/* If the framebuffer is not the device's fb the device's fb has to be reapplied
* next draw. Otherwise we could mark the framebuffer state clean here, once the
* state management allows this */
- context_invalidate_state(context, STATE_FRAMEBUFFER);
+ context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER);
}
else
{
- rt_mask = context_generate_rt_mask_no_fbo(context, rt_count ? rts[0]->resource : NULL);
+ rt_mask = context_generate_rt_mask_no_fbo(&context_gl->c, rt_count ? rts[0]->resource : NULL);
}
}
else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
@@ -3084,25 +3084,25 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
}
else
{
- rt_mask = context_generate_rt_mask_no_fbo(context, rt_count ? rts[0]->resource : NULL);
+ rt_mask = context_generate_rt_mask_no_fbo(&context_gl->c, rt_count ? rts[0]->resource : NULL);
}
- cur_mask = context->current_fbo ? &context->current_fbo->rt_mask : &context->draw_buffers_mask;
+ cur_mask = context_gl->c.current_fbo ? &context_gl->c.current_fbo->rt_mask : &context_gl->c.draw_buffers_mask;
if (rt_mask != *cur_mask)
{
- context_apply_draw_buffers(context, rt_mask);
+ context_apply_draw_buffers(&context_gl->c, rt_mask);
*cur_mask = rt_mask;
- context_invalidate_state(context, STATE_FRAMEBUFFER);
+ context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER);
}
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- context_check_fbo_status(context, GL_FRAMEBUFFER);
+ context_check_fbo_status(&context_gl->c, GL_FRAMEBUFFER);
}
- context->last_was_blit = FALSE;
- context->last_was_ffp_blit = FALSE;
+ context_gl->c.last_was_blit = FALSE;
+ context_gl->c.last_was_ffp_blit = FALSE;
/* Blending and clearing should be orthogonal, but tests on the nvidia
* driver show that disabling blending when clearing improves the clearing
@@ -3111,17 +3111,17 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
gl_info->gl_ops.gl.p_glEnable(GL_SCISSOR_TEST);
if (rt_count && gl_info->supported[ARB_FRAMEBUFFER_SRGB])
{
- if (needs_srgb_write(context, state, fb))
+ if (needs_srgb_write(&context_gl->c, state, fb))
gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB);
else
gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB);
- context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE));
+ context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE));
}
checkGLcall("setting up state for clear");
- context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE));
- context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
- context_invalidate_state(context, STATE_SCISSORRECT);
+ context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE));
+ context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
+ context_invalidate_state(&context_gl->c, STATE_SCISSORRECT);
return TRUE;
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index eac6442804f..5272e2ef236 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -250,6 +250,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
const struct wined3d_state *state = &device->cs->state;
struct wined3d_texture *depth_stencil = NULL;
const struct wined3d_gl_info *gl_info;
+ struct wined3d_context_gl *context_gl;
struct wined3d_texture *target = NULL;
UINT drawable_width, drawable_height;
struct wined3d_color corrected_color;
@@ -267,6 +268,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
{
context = context_acquire(device, NULL, 0);
}
+ context_gl = wined3d_context_gl(context);
if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
depth_stencil = texture_from_resource(dsv->resource);
@@ -335,7 +337,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
}
}
- if (!context_apply_clear_state(context, state, rt_count, fb))
+ if (!wined3d_context_gl_apply_clear_state(context_gl, state, rt_count, fb))
{
context_release(context);
WARN("Failed to apply clear state, skipping clear.\n");
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 88602163f14..0aa379562d9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1867,6 +1867,12 @@ struct wined3d_rendertarget_info
unsigned int layer_count;
};
+struct wined3d_fb_state
+{
+ struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
+ struct wined3d_rendertarget_view *depth_stencil;
+};
+
#define MAX_GL_FRAGMENT_SAMPLERS 32
struct wined3d_context
@@ -2056,6 +2062,8 @@ void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context
struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
+BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
+ unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
@@ -2073,12 +2081,6 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
-struct wined3d_fb_state
-{
- struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
- struct wined3d_rendertarget_view *depth_stencil;
-};
-
HRESULT wined3d_context_vk_init(struct wined3d_context *context_vk,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
@@ -2213,8 +2215,6 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP
struct wined3d_context *context_acquire(const struct wined3d_device *device,
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
-BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
- UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
--
2.11.0
1
0
[PATCH 4/8] wined3d: Move the pipeline statitics query fields from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 73 ++++++++++++++++++------------------------
dlls/wined3d/query.c | 20 ++++++------
dlls/wined3d/wined3d_private.h | 20 ++++++------
3 files changed, 50 insertions(+), 63 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e74963bace5..86c74c5c9f3 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -996,14 +996,14 @@ void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_qu
context_gl->free_so_statistics_queries[context_gl->free_so_statistics_query_count++] = query->u;
}
-void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
+void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
struct wined3d_pipeline_statistics_query *query)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
- if (context->free_pipeline_statistics_query_count)
+ if (context_gl->free_pipeline_statistics_query_count)
{
- query->u = context->free_pipeline_statistics_queries[--context->free_pipeline_statistics_query_count];
+ query->u = context_gl->free_pipeline_statistics_queries[--context_gl->free_pipeline_statistics_query_count];
}
else
{
@@ -1011,26 +1011,26 @@ void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
checkGLcall("glGenQueries");
}
- query->context = context;
- list_add_head(&context->pipeline_statistics_queries, &query->entry);
+ query->context_gl = context_gl;
+ list_add_head(&context_gl->pipeline_statistics_queries, &query->entry);
}
-void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query)
+void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query)
{
- struct wined3d_context *context = query->context;
+ struct wined3d_context_gl *context_gl = query->context_gl;
list_remove(&query->entry);
- query->context = NULL;
+ query->context_gl = NULL;
- if (!wined3d_array_reserve((void **)&context->free_pipeline_statistics_queries,
- &context->free_pipeline_statistics_query_size, context->free_pipeline_statistics_query_count + 1,
- sizeof(*context->free_pipeline_statistics_queries)))
+ if (!wined3d_array_reserve((void **)&context_gl->free_pipeline_statistics_queries,
+ &context_gl->free_pipeline_statistics_query_size, context_gl->free_pipeline_statistics_query_count + 1,
+ sizeof(*context_gl->free_pipeline_statistics_queries)))
{
- ERR("Failed to grow free list, leaking GL queries in context %p.\n", context);
+ ERR("Failed to grow free list, leaking GL queries in context %p.\n", context_gl);
return;
}
- context->free_pipeline_statistics_queries[context->free_pipeline_statistics_query_count++] = query->u;
+ context_gl->free_pipeline_statistics_queries[context_gl->free_pipeline_statistics_query_count++] = query->u;
}
typedef void (context_fbo_entry_func_t)(struct wined3d_context *context, struct fbo_entry *entry);
@@ -1316,12 +1316,10 @@ static void context_update_window(struct wined3d_context *context)
void wined3d_context_cleanup(struct wined3d_context *context)
{
- struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct fbo_entry *entry, *entry2;
HGLRC restore_ctx;
HDC restore_dc;
- unsigned int i;
restore_ctx = wglGetCurrentContext();
restore_dc = wglGetCurrentDC();
@@ -1331,14 +1329,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
else if (context->valid)
context_set_gl_context(context);
- LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context->pipeline_statistics_queries,
- struct wined3d_pipeline_statistics_query, entry)
- {
- if (context->valid)
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
- pipeline_statistics_query->context = NULL;
- }
-
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
if (!context->valid) entry->id = 0;
@@ -1351,22 +1341,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
context_destroy_fbo_entry(context, entry);
}
- if (context->valid)
- {
- if (gl_info->supported[ARB_PIPELINE_STATISTICS_QUERY])
- {
- for (i = 0; i < context->free_pipeline_statistics_query_count; ++i)
- {
- union wined3d_gl_pipeline_statistics_query *q = &context->free_pipeline_statistics_queries[i];
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
- }
- }
-
- checkGLcall("context cleanup");
- }
-
- heap_free(context->free_pipeline_statistics_queries);
-
context_restore_pixel_format(context);
if (restore_ctx)
{
@@ -1388,6 +1362,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
{
+ struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
@@ -1413,6 +1388,12 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
+ for (i = 0; i < context_gl->free_pipeline_statistics_query_count; ++i)
+ {
+ union wined3d_gl_pipeline_statistics_query *q = &context_gl->free_pipeline_statistics_queries[i];
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
+ }
+
for (i = 0; i < context_gl->free_so_statistics_query_count; ++i)
{
union wined3d_gl_so_statistics_query *q = &context_gl->free_so_statistics_queries[i];
@@ -1449,11 +1430,20 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
checkGLcall("context cleanup");
}
+ heap_free(context_gl->free_pipeline_statistics_queries);
heap_free(context_gl->free_so_statistics_queries);
heap_free(context_gl->free_timestamp_queries);
heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
+ LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context_gl->pipeline_statistics_queries,
+ struct wined3d_pipeline_statistics_query, entry)
+ {
+ if (context_gl->c.valid)
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
+ pipeline_statistics_query->context_gl = NULL;
+ }
+
LIST_FOR_EACH_ENTRY(so_statistics_query, &context_gl->so_statistics_queries,
struct wined3d_so_statistics_query, entry)
{
@@ -1913,8 +1903,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
struct wined3d_device *device = swapchain->device;
DWORD state;
- list_init(&context->pipeline_statistics_queries);
-
list_init(&context->fbo_list);
list_init(&context->fbo_destroy_list);
@@ -1994,6 +1982,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
list_init(&context_gl->fences);
list_init(&context_gl->timestamp_queries);
list_init(&context_gl->so_statistics_queries);
+ list_init(&context_gl->pipeline_statistics_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index ff13c34059c..87c50eebe51 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -922,7 +922,7 @@ static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD f
TRACE("query %p, flags %#x.\n", query, flags);
- if (!(context = context_reacquire(device, pq->context)))
+ if (!(context = context_reacquire(device, &pq->context_gl->c)))
{
FIXME("%p Wrong thread.\n", query);
memset(&pq->statistics, 0, sizeof(pq->statistics));
@@ -990,24 +990,24 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_pipeline_statistics_query_end(pq, context);
}
else
{
FIXME("Wrong thread, can't restart query.\n");
- context_free_pipeline_statistics_query(pq);
+ wined3d_context_gl_free_pipeline_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_pipeline_statistics_query(context, pq);
+ wined3d_context_gl_alloc_pipeline_statistics_query(wined3d_context_gl(context), pq);
}
}
else
{
- if (pq->context)
- context_free_pipeline_statistics_query(pq);
+ if (pq->context_gl)
+ wined3d_context_gl_free_pipeline_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_pipeline_statistics_query(context, pq);
+ wined3d_context_gl_alloc_pipeline_statistics_query(wined3d_context_gl(context), pq);
}
gl_info = context->gl_info;
@@ -1031,7 +1031,7 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_pipeline_statistics_query_end(pq, context);
context_release(context);
@@ -1294,8 +1294,8 @@ static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device,
static void wined3d_pipeline_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
- if (pq->context)
- context_free_pipeline_statistics_query(pq);
+ if (pq->context_gl)
+ wined3d_context_gl_free_pipeline_statistics_query(pq);
heap_free(pq);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index da3aca18bd9..88602163f14 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1848,15 +1848,11 @@ struct wined3d_pipeline_statistics_query
struct list entry;
union wined3d_gl_pipeline_statistics_query u;
- struct wined3d_context *context;
+ struct wined3d_context_gl *context_gl;
struct wined3d_query_data_pipeline_statistics statistics;
BOOL started;
};
-void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
- struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
-void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
-
struct wined3d_gl_view
{
GLenum target;
@@ -1974,12 +1970,6 @@ struct wined3d_context
struct wined3d_rendertarget_info blit_targets[MAX_RENDER_TARGET_VIEWS];
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
- /* Queries */
- union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
- SIZE_T free_pipeline_statistics_query_size;
- unsigned int free_pipeline_statistics_query_count;
- struct list pipeline_statistics_queries;
-
struct wined3d_stream_info stream_info;
/* Fences for GL_APPLE_flush_buffer_range */
@@ -2009,6 +1999,7 @@ struct wined3d_context_gl
struct list fences;
struct list timestamp_queries;
struct list so_statistics_queries;
+ struct list pipeline_statistics_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
@@ -2026,6 +2017,10 @@ struct wined3d_context_gl
SIZE_T free_so_statistics_query_size;
unsigned int free_so_statistics_query_count;
+ union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
+ SIZE_T free_pipeline_statistics_query_size;
+ unsigned int free_pipeline_statistics_query_count;
+
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@@ -2053,6 +2048,8 @@ void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
+ struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
@@ -2066,6 +2063,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
--
2.11.0
1
0
[PATCH 3/8] wined3d: Move the stream-output statitics query fields from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 67 ++++++++++++++++++++----------------------
dlls/wined3d/query.c | 20 ++++++-------
dlls/wined3d/wined3d_private.h | 19 ++++++------
3 files changed, 51 insertions(+), 55 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index e7b8fcc569e..e74963bace5 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -955,14 +955,14 @@ void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *que
context_gl->free_timestamp_queries[context_gl->free_timestamp_query_count++] = query->id;
}
-void context_alloc_so_statistics_query(struct wined3d_context *context,
+void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
struct wined3d_so_statistics_query *query)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
- if (context->free_so_statistics_query_count)
+ if (context_gl->free_so_statistics_query_count)
{
- query->u = context->free_so_statistics_queries[--context->free_so_statistics_query_count];
+ query->u = context_gl->free_so_statistics_queries[--context_gl->free_so_statistics_query_count];
}
else
{
@@ -970,30 +970,30 @@ void context_alloc_so_statistics_query(struct wined3d_context *context,
checkGLcall("glGenQueries");
TRACE("Allocated SO statistics queries %u, %u in context %p.\n",
- query->u.id[0], query->u.id[1], context);
+ query->u.id[0], query->u.id[1], context_gl);
}
- query->context = context;
- list_add_head(&context->so_statistics_queries, &query->entry);
+ query->context_gl = context_gl;
+ list_add_head(&context_gl->so_statistics_queries, &query->entry);
}
-void context_free_so_statistics_query(struct wined3d_so_statistics_query *query)
+void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query)
{
- struct wined3d_context *context = query->context;
+ struct wined3d_context_gl *context_gl = query->context_gl;
list_remove(&query->entry);
- query->context = NULL;
+ query->context_gl = NULL;
- if (!wined3d_array_reserve((void **)&context->free_so_statistics_queries,
- &context->free_so_statistics_query_size, context->free_so_statistics_query_count + 1,
- sizeof(*context->free_so_statistics_queries)))
+ if (!wined3d_array_reserve((void **)&context_gl->free_so_statistics_queries,
+ &context_gl->free_so_statistics_query_size, context_gl->free_so_statistics_query_count + 1,
+ sizeof(*context_gl->free_so_statistics_queries)))
{
ERR("Failed to grow free list, leaking GL queries %u, %u in context %p.\n",
- query->u.id[0], query->u.id[1], context);
+ query->u.id[0], query->u.id[1], context_gl);
return;
}
- context->free_so_statistics_queries[context->free_so_statistics_query_count++] = query->u;
+ context_gl->free_so_statistics_queries[context_gl->free_so_statistics_query_count++] = query->u;
}
void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
@@ -1318,7 +1318,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
{
struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_so_statistics_query *so_statistics_query;
struct fbo_entry *entry, *entry2;
HGLRC restore_ctx;
HDC restore_dc;
@@ -1332,14 +1331,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
else if (context->valid)
context_set_gl_context(context);
- LIST_FOR_EACH_ENTRY(so_statistics_query, &context->so_statistics_queries,
- struct wined3d_so_statistics_query, entry)
- {
- if (context->valid)
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
- so_statistics_query->context = NULL;
- }
-
LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context->pipeline_statistics_queries,
struct wined3d_pipeline_statistics_query, entry)
{
@@ -1362,15 +1353,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
if (context->valid)
{
- if (gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY])
- {
- for (i = 0; i < context->free_so_statistics_query_count; ++i)
- {
- union wined3d_gl_so_statistics_query *q = &context->free_so_statistics_queries[i];
- GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
- }
- }
-
if (gl_info->supported[ARB_PIPELINE_STATISTICS_QUERY])
{
for (i = 0; i < context->free_pipeline_statistics_query_count; ++i)
@@ -1383,7 +1365,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
checkGLcall("context cleanup");
}
- heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
context_restore_pixel_format(context);
@@ -1408,6 +1389,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
{
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
+ struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct wined3d_occlusion_query *occlusion_query;
struct wined3d_fence *fence;
@@ -1431,6 +1413,12 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
+ for (i = 0; i < context_gl->free_so_statistics_query_count; ++i)
+ {
+ union wined3d_gl_so_statistics_query *q = &context_gl->free_so_statistics_queries[i];
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(q->id), q->id));
+ }
+
if (context_gl->free_timestamp_query_count)
GL_EXTCALL(glDeleteQueries(context_gl->free_timestamp_query_count, context_gl->free_timestamp_queries));
@@ -1461,10 +1449,19 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
checkGLcall("context cleanup");
}
+ heap_free(context_gl->free_so_statistics_queries);
heap_free(context_gl->free_timestamp_queries);
heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
+ LIST_FOR_EACH_ENTRY(so_statistics_query, &context_gl->so_statistics_queries,
+ struct wined3d_so_statistics_query, entry)
+ {
+ if (context_gl->c.valid)
+ GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(so_statistics_query->u.id), so_statistics_query->u.id));
+ so_statistics_query->context_gl = NULL;
+ }
+
LIST_FOR_EACH_ENTRY(timestamp_query, &context_gl->timestamp_queries, struct wined3d_timestamp_query, entry)
{
if (context_gl->c.valid)
@@ -1916,7 +1913,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
struct wined3d_device *device = swapchain->device;
DWORD state;
- list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
list_init(&context->fbo_list);
@@ -1997,6 +1993,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
list_init(&context_gl->occlusion_queries);
list_init(&context_gl->fences);
list_init(&context_gl->timestamp_queries);
+ list_init(&context_gl->so_statistics_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 3fe7784e0f8..ff13c34059c 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -788,7 +788,7 @@ static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DW
TRACE("query %p, flags %#x.\n", query, flags);
- if (!(context = context_reacquire(device, pq->context)))
+ if (!(context = context_reacquire(device, &pq->context_gl->c)))
{
FIXME("%p Wrong thread, returning 0 primitives.\n", query);
memset(&pq->statistics, 0, sizeof(pq->statistics));
@@ -849,24 +849,24 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_so_statistics_query_end(pq, context);
}
else
{
FIXME("Wrong thread, can't restart query.\n");
- context_free_so_statistics_query(pq);
+ wined3d_context_gl_free_so_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_so_statistics_query(context, pq);
+ wined3d_context_gl_alloc_so_statistics_query(wined3d_context_gl(context), pq);
}
}
else
{
- if (pq->context)
- context_free_so_statistics_query(pq);
+ if (pq->context_gl)
+ wined3d_context_gl_free_so_statistics_query(pq);
context = context_acquire(device, NULL, 0);
- context_alloc_so_statistics_query(context, pq);
+ wined3d_context_gl_alloc_so_statistics_query(wined3d_context_gl(context), pq);
}
gl_info = context->gl_info;
@@ -893,7 +893,7 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
{
if (pq->started)
{
- if ((context = context_reacquire(device, pq->context)))
+ if ((context = context_reacquire(device, &pq->context_gl->c)))
{
wined3d_so_statistics_query_end(pq, context);
@@ -1237,8 +1237,8 @@ static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
- if (pq->context)
- context_free_so_statistics_query(pq);
+ if (pq->context_gl)
+ wined3d_context_gl_free_so_statistics_query(pq);
heap_free(pq);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 91eefc43761..da3aca18bd9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1817,16 +1817,12 @@ struct wined3d_so_statistics_query
struct list entry;
union wined3d_gl_so_statistics_query u;
- struct wined3d_context *context;
+ struct wined3d_context_gl *context_gl;
unsigned int stream_idx;
struct wined3d_query_data_so_statistics statistics;
BOOL started;
};
-void context_alloc_so_statistics_query(struct wined3d_context *context,
- struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
-void context_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
-
union wined3d_gl_pipeline_statistics_query
{
GLuint id[11];
@@ -1979,11 +1975,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
- union wined3d_gl_so_statistics_query *free_so_statistics_queries;
- SIZE_T free_so_statistics_query_size;
- unsigned int free_so_statistics_query_count;
- struct list so_statistics_queries;
-
union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
SIZE_T free_pipeline_statistics_query_size;
unsigned int free_pipeline_statistics_query_count;
@@ -2017,6 +2008,7 @@ struct wined3d_context_gl
struct list occlusion_queries;
struct list fences;
struct list timestamp_queries;
+ struct list so_statistics_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
@@ -2030,6 +2022,10 @@ struct wined3d_context_gl
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
+ union wined3d_gl_so_statistics_query *free_so_statistics_queries;
+ SIZE_T free_so_statistics_query_size;
+ unsigned int free_so_statistics_query_count;
+
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@@ -2057,6 +2053,8 @@ void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
+ struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
@@ -2068,6 +2066,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
--
2.11.0
1
0
[PATCH 2/8] wined3d: Move the timestamp query fields from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 57 +++++++++++++++++++++---------------------
dlls/wined3d/query.c | 12 ++++-----
dlls/wined3d/wined3d_private.h | 18 ++++++-------
3 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 571bbbb2945..e7b8fcc569e 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -916,42 +916,43 @@ void wined3d_context_gl_free_fence(struct wined3d_fence *fence)
}
/* Context activation is done by the caller. */
-void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query)
+void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
+ struct wined3d_timestamp_query *query)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
- if (context->free_timestamp_query_count)
+ if (context_gl->free_timestamp_query_count)
{
- query->id = context->free_timestamp_queries[--context->free_timestamp_query_count];
+ query->id = context_gl->free_timestamp_queries[--context_gl->free_timestamp_query_count];
}
else
{
GL_EXTCALL(glGenQueries(1, &query->id));
checkGLcall("glGenQueries");
- TRACE("Allocated timestamp query %u in context %p.\n", query->id, context);
+ TRACE("Allocated timestamp query %u in context %p.\n", query->id, context_gl);
}
- query->context = context;
- list_add_head(&context->timestamp_queries, &query->entry);
+ query->context_gl = context_gl;
+ list_add_head(&context_gl->timestamp_queries, &query->entry);
}
-void context_free_timestamp_query(struct wined3d_timestamp_query *query)
+void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query)
{
- struct wined3d_context *context = query->context;
+ struct wined3d_context_gl *context_gl = query->context_gl;
list_remove(&query->entry);
- query->context = NULL;
+ query->context_gl = NULL;
- if (!wined3d_array_reserve((void **)&context->free_timestamp_queries,
- &context->free_timestamp_query_size, context->free_timestamp_query_count + 1,
- sizeof(*context->free_timestamp_queries)))
+ if (!wined3d_array_reserve((void **)&context_gl->free_timestamp_queries,
+ &context_gl->free_timestamp_query_size, context_gl->free_timestamp_query_count + 1,
+ sizeof(*context_gl->free_timestamp_queries)))
{
- ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context);
+ ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context_gl);
return;
}
- context->free_timestamp_queries[context->free_timestamp_query_count++] = query->id;
+ context_gl->free_timestamp_queries[context_gl->free_timestamp_query_count++] = query->id;
}
void context_alloc_so_statistics_query(struct wined3d_context *context,
@@ -1318,7 +1319,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
struct wined3d_pipeline_statistics_query *pipeline_statistics_query;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_so_statistics_query *so_statistics_query;
- struct wined3d_timestamp_query *timestamp_query;
struct fbo_entry *entry, *entry2;
HGLRC restore_ctx;
HDC restore_dc;
@@ -1348,13 +1348,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
pipeline_statistics_query->context = NULL;
}
- LIST_FOR_EACH_ENTRY(timestamp_query, &context->timestamp_queries, struct wined3d_timestamp_query, entry)
- {
- if (context->valid)
- GL_EXTCALL(glDeleteQueries(1, ×tamp_query->id));
- timestamp_query->context = NULL;
- }
-
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
if (!context->valid) entry->id = 0;
@@ -1387,15 +1380,11 @@ void wined3d_context_cleanup(struct wined3d_context *context)
}
}
- if (gl_info->supported[ARB_TIMER_QUERY])
- GL_EXTCALL(glDeleteQueries(context->free_timestamp_query_count, context->free_timestamp_queries));
-
checkGLcall("context cleanup");
}
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
- heap_free(context->free_timestamp_queries);
context_restore_pixel_format(context);
if (restore_ctx)
@@ -1419,6 +1408,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
{
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
+ struct wined3d_timestamp_query *timestamp_query;
struct wined3d_occlusion_query *occlusion_query;
struct wined3d_fence *fence;
HGLRC restore_ctx;
@@ -1441,6 +1431,9 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
+ if (context_gl->free_timestamp_query_count)
+ GL_EXTCALL(glDeleteQueries(context_gl->free_timestamp_query_count, context_gl->free_timestamp_queries));
+
if (gl_info->supported[ARB_SYNC])
{
for (i = 0; i < context_gl->free_fence_count; ++i)
@@ -1468,9 +1461,17 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
checkGLcall("context cleanup");
}
+ heap_free(context_gl->free_timestamp_queries);
heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
+ LIST_FOR_EACH_ENTRY(timestamp_query, &context_gl->timestamp_queries, struct wined3d_timestamp_query, entry)
+ {
+ if (context_gl->c.valid)
+ GL_EXTCALL(glDeleteQueries(1, ×tamp_query->id));
+ timestamp_query->context_gl = NULL;
+ }
+
LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
{
if (context_gl->c.valid)
@@ -1915,7 +1916,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
struct wined3d_device *device = swapchain->device;
DWORD state;
- list_init(&context->timestamp_queries);
list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
@@ -1996,6 +1996,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
list_init(&context_gl->occlusion_queries);
list_init(&context_gl->fences);
+ list_init(&context_gl->timestamp_queries);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 10d6b20d71b..3fe7784e0f8 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -710,7 +710,7 @@ static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD
TRACE("query %p, flags %#x.\n", query, flags);
- if (!(context = context_reacquire(device, tq->context)))
+ if (!(context = context_reacquire(device, &tq->context_gl->c)))
{
FIXME("%p Wrong thread, returning 1.\n", query);
tq->timestamp = 1;
@@ -749,11 +749,11 @@ static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD
}
if (flags & WINED3DISSUE_END)
{
- if (tq->context)
- context_free_timestamp_query(tq);
+ if (tq->context_gl)
+ wined3d_context_gl_free_timestamp_query(tq);
context = context_acquire(query->device, NULL, 0);
gl_info = context->gl_info;
- context_alloc_timestamp_query(context, tq);
+ wined3d_context_gl_alloc_timestamp_query(wined3d_context_gl(context), tq);
GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP));
checkGLcall("glQueryCounter()");
context_release(context);
@@ -1141,8 +1141,8 @@ static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
- if (tq->context)
- context_free_timestamp_query(tq);
+ if (tq->context_gl)
+ wined3d_context_gl_free_timestamp_query(tq);
heap_free(tq);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 035037c860e..91eefc43761 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1797,13 +1797,10 @@ struct wined3d_timestamp_query
struct list entry;
GLuint id;
- struct wined3d_context *context;
+ struct wined3d_context_gl *context_gl;
UINT64 timestamp;
};
-void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
-void context_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
-
union wined3d_gl_so_statistics_query
{
GLuint id[2];
@@ -1982,11 +1979,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
- GLuint *free_timestamp_queries;
- SIZE_T free_timestamp_query_size;
- unsigned int free_timestamp_query_count;
- struct list timestamp_queries;
-
union wined3d_gl_so_statistics_query *free_so_statistics_queries;
SIZE_T free_so_statistics_query_size;
unsigned int free_so_statistics_query_count;
@@ -2024,6 +2016,7 @@ struct wined3d_context_gl
/* Queries. */
struct list occlusion_queries;
struct list fences;
+ struct list timestamp_queries;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
@@ -2033,6 +2026,10 @@ struct wined3d_context_gl
SIZE_T free_fence_size;
unsigned int free_fence_count;
+ GLuint *free_timestamp_queries;
+ SIZE_T free_timestamp_query_size;
+ unsigned int free_timestamp_query_count;
+
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@@ -2060,6 +2057,8 @@ void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
+ struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
@@ -2069,6 +2068,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
+void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
--
2.11.0
1
0
[PATCH 1/8] wined3d: Move the fence fields from struct wined3d_context to struct wined3d_context_gl.
by Henri Verbeet 14 May '19
by Henri Verbeet 14 May '19
14 May '19
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 127 +++++++++++++++++++++--------------------
dlls/wined3d/query.c | 26 ++++-----
dlls/wined3d/wined3d_private.h | 17 +++---
3 files changed, 86 insertions(+), 84 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index d1ae2ceb513..571bbbb2945 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -856,13 +856,13 @@ void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *que
}
/* Context activation is done by the caller. */
-void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence)
+void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl, struct wined3d_fence *fence)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
- if (context->free_fence_count)
+ if (context_gl->free_fence_count)
{
- fence->object = context->free_fences[--context->free_fence_count];
+ fence->object = context_gl->free_fences[--context_gl->free_fence_count];
}
else
{
@@ -870,21 +870,21 @@ void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *
{
/* Using ARB_sync, not much to do here. */
fence->object.sync = NULL;
- TRACE("Allocated sync object in context %p.\n", context);
+ TRACE("Allocated sync object in context %p.\n", context_gl);
}
else if (gl_info->supported[APPLE_FENCE])
{
GL_EXTCALL(glGenFencesAPPLE(1, &fence->object.id));
checkGLcall("glGenFencesAPPLE");
- TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
+ TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
}
else if(gl_info->supported[NV_FENCE])
{
GL_EXTCALL(glGenFencesNV(1, &fence->object.id));
checkGLcall("glGenFencesNV");
- TRACE("Allocated fence %u in context %p.\n", fence->object.id, context);
+ TRACE("Allocated fence %u in context %p.\n", fence->object.id, context_gl);
}
else
{
@@ -893,26 +893,26 @@ void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *
}
}
- fence->context = context;
- list_add_head(&context->fences, &fence->entry);
+ fence->context_gl = context_gl;
+ list_add_head(&context_gl->fences, &fence->entry);
}
-void context_free_fence(struct wined3d_fence *fence)
+void wined3d_context_gl_free_fence(struct wined3d_fence *fence)
{
- struct wined3d_context *context = fence->context;
+ struct wined3d_context_gl *context_gl = fence->context_gl;
list_remove(&fence->entry);
- fence->context = NULL;
+ fence->context_gl = NULL;
- if (!wined3d_array_reserve((void **)&context->free_fences,
- &context->free_fence_size, context->free_fence_count + 1,
- sizeof(*context->free_fences)))
+ if (!wined3d_array_reserve((void **)&context_gl->free_fences,
+ &context_gl->free_fence_size, context_gl->free_fence_count + 1,
+ sizeof(*context_gl->free_fences)))
{
- ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context);
+ ERR("Failed to grow free list, leaking fence %u in context %p.\n", fence->object.id, context_gl);
return;
}
- context->free_fences[context->free_fence_count++] = fence->object;
+ context_gl->free_fences[context_gl->free_fence_count++] = fence->object;
}
/* Context activation is done by the caller. */
@@ -1320,7 +1320,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
struct wined3d_so_statistics_query *so_statistics_query;
struct wined3d_timestamp_query *timestamp_query;
struct fbo_entry *entry, *entry2;
- struct wined3d_fence *fence;
HGLRC restore_ctx;
HDC restore_dc;
unsigned int i;
@@ -1356,27 +1355,6 @@ void wined3d_context_cleanup(struct wined3d_context *context)
timestamp_query->context = NULL;
}
- LIST_FOR_EACH_ENTRY(fence, &context->fences, struct wined3d_fence, entry)
- {
- if (context->valid)
- {
- if (gl_info->supported[ARB_SYNC])
- {
- if (fence->object.sync)
- GL_EXTCALL(glDeleteSync(fence->object.sync));
- }
- else if (gl_info->supported[APPLE_FENCE])
- {
- GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
- }
- else if (gl_info->supported[NV_FENCE])
- {
- GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
- }
- }
- fence->context = NULL;
- }
-
LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_destroy_list, struct fbo_entry, entry)
{
if (!context->valid) entry->id = 0;
@@ -1412,35 +1390,12 @@ void wined3d_context_cleanup(struct wined3d_context *context)
if (gl_info->supported[ARB_TIMER_QUERY])
GL_EXTCALL(glDeleteQueries(context->free_timestamp_query_count, context->free_timestamp_queries));
- if (gl_info->supported[ARB_SYNC])
- {
- for (i = 0; i < context->free_fence_count; ++i)
- {
- GL_EXTCALL(glDeleteSync(context->free_fences[i].sync));
- }
- }
- else if (gl_info->supported[APPLE_FENCE])
- {
- for (i = 0; i < context->free_fence_count; ++i)
- {
- GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_fences[i].id));
- }
- }
- else if (gl_info->supported[NV_FENCE])
- {
- for (i = 0; i < context->free_fence_count; ++i)
- {
- GL_EXTCALL(glDeleteFencesNV(1, &context->free_fences[i].id));
- }
- }
-
checkGLcall("context cleanup");
}
heap_free(context->free_so_statistics_queries);
heap_free(context->free_pipeline_statistics_queries);
heap_free(context->free_timestamp_queries);
- heap_free(context->free_fences);
context_restore_pixel_format(context);
if (restore_ctx)
@@ -1465,8 +1420,10 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
{
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_occlusion_query *occlusion_query;
+ struct wined3d_fence *fence;
HGLRC restore_ctx;
HDC restore_dc;
+ unsigned int i;
restore_ctx = wglGetCurrentContext();
restore_dc = wglGetCurrentDC();
@@ -1484,13 +1441,57 @@ void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
if (context_gl->blit_vbo)
GL_EXTCALL(glDeleteBuffers(1, &context_gl->blit_vbo));
+ if (gl_info->supported[ARB_SYNC])
+ {
+ for (i = 0; i < context_gl->free_fence_count; ++i)
+ {
+ GL_EXTCALL(glDeleteSync(context_gl->free_fences[i].sync));
+ }
+ }
+ else if (gl_info->supported[APPLE_FENCE])
+ {
+ for (i = 0; i < context_gl->free_fence_count; ++i)
+ {
+ GL_EXTCALL(glDeleteFencesAPPLE(1, &context_gl->free_fences[i].id));
+ }
+ }
+ else if (gl_info->supported[NV_FENCE])
+ {
+ for (i = 0; i < context_gl->free_fence_count; ++i)
+ {
+ GL_EXTCALL(glDeleteFencesNV(1, &context_gl->free_fences[i].id));
+ }
+ }
+
if (context_gl->free_occlusion_query_count)
GL_EXTCALL(glDeleteQueries(context_gl->free_occlusion_query_count, context_gl->free_occlusion_queries));
checkGLcall("context cleanup");
}
+ heap_free(context_gl->free_fences);
heap_free(context_gl->free_occlusion_queries);
+ LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
+ {
+ if (context_gl->c.valid)
+ {
+ if (gl_info->supported[ARB_SYNC])
+ {
+ if (fence->object.sync)
+ GL_EXTCALL(glDeleteSync(fence->object.sync));
+ }
+ else if (gl_info->supported[APPLE_FENCE])
+ {
+ GL_EXTCALL(glDeleteFencesAPPLE(1, &fence->object.id));
+ }
+ else if (gl_info->supported[NV_FENCE])
+ {
+ GL_EXTCALL(glDeleteFencesNV(1, &fence->object.id));
+ }
+ }
+ fence->context_gl = NULL;
+ }
+
LIST_FOR_EACH_ENTRY(occlusion_query, &context_gl->occlusion_queries, struct wined3d_occlusion_query, entry)
{
if (context_gl->c.valid)
@@ -1915,7 +1916,6 @@ static BOOL wined3d_context_init(struct wined3d_context *context, struct wined3d
DWORD state;
list_init(&context->timestamp_queries);
- list_init(&context->fences);
list_init(&context->so_statistics_queries);
list_init(&context->pipeline_statistics_queries);
@@ -1995,6 +1995,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
d3d_info = context->d3d_info;
list_init(&context_gl->occlusion_queries);
+ list_init(&context_gl->fences);
for (i = 0; i < ARRAY_SIZE(context_gl->tex_unit_map); ++i)
context_gl->tex_unit_map[i] = WINED3D_UNMAPPED_STAGE;
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index fb119451e56..10d6b20d71b 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -189,15 +189,15 @@ static enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *
TRACE("fence %p, device %p, flags %#x.\n", fence, device, flags);
- if (!fence->context)
+ if (!fence->context_gl)
{
TRACE("Fence not issued.\n");
return WINED3D_FENCE_NOT_STARTED;
}
- if (!(context = context_reacquire(device, fence->context)))
+ if (!(context = context_reacquire(device, &fence->context_gl->c)))
{
- if (!fence->context->gl_info->supported[ARB_SYNC])
+ if (!fence->context_gl->c.gl_info->supported[ARB_SYNC])
{
WARN("Fence tested from wrong thread.\n");
return WINED3D_FENCE_WRONG_THREAD;
@@ -266,14 +266,14 @@ enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
TRACE("fence %p, device %p.\n", fence, device);
- if (!fence->context)
+ if (!fence->context_gl)
{
TRACE("Fence not issued.\n");
return WINED3D_FENCE_NOT_STARTED;
}
- gl_info = fence->context->gl_info;
+ gl_info = fence->context_gl->c.gl_info;
- if (!(context = context_reacquire(device, fence->context)))
+ if (!(context = context_reacquire(device, &fence->context_gl->c)))
{
/* A glFinish does not reliably wait for draws in other contexts. The caller has
* to find its own way to cope with the thread switch
@@ -337,14 +337,14 @@ void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_devic
struct wined3d_context *context = NULL;
const struct wined3d_gl_info *gl_info;
- if (fence->context && !(context = context_reacquire(device, fence->context))
- && !fence->context->gl_info->supported[ARB_SYNC])
- context_free_fence(fence);
+ if (fence->context_gl && !(context = context_reacquire(device, &fence->context_gl->c))
+ && !fence->context_gl->c.gl_info->supported[ARB_SYNC])
+ wined3d_context_gl_free_fence(fence);
if (!context)
context = context_acquire(device, NULL, 0);
gl_info = context->gl_info;
- if (!fence->context)
- context_alloc_fence(context, fence);
+ if (!fence->context_gl)
+ wined3d_context_gl_alloc_fence(wined3d_context_gl(context), fence);
if (gl_info->supported[ARB_SYNC])
{
@@ -370,8 +370,8 @@ void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_devic
static void wined3d_fence_free(struct wined3d_fence *fence)
{
- if (fence->context)
- context_free_fence(fence);
+ if (fence->context_gl)
+ wined3d_context_gl_free_fence(fence);
}
void wined3d_fence_destroy(struct wined3d_fence *fence)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 13f8b570cc1..035037c860e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1726,7 +1726,7 @@ struct wined3d_fence
{
struct list entry;
union wined3d_gl_fence_object object;
- struct wined3d_context *context;
+ struct wined3d_context_gl *context_gl;
};
HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
@@ -1982,11 +1982,6 @@ struct wined3d_context
DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
/* Queries */
- union wined3d_gl_fence_object *free_fences;
- SIZE_T free_fence_size;
- unsigned int free_fence_count;
- struct list fences;
-
GLuint *free_timestamp_queries;
SIZE_T free_timestamp_query_size;
unsigned int free_timestamp_query_count;
@@ -2028,11 +2023,16 @@ struct wined3d_context_gl
/* Queries. */
struct list occlusion_queries;
+ struct list fences;
GLuint *free_occlusion_queries;
SIZE_T free_occlusion_query_size;
unsigned int free_occlusion_query_count;
+ union wined3d_gl_fence_object *free_fences;
+ SIZE_T free_fence_size;
+ unsigned int free_fence_count;
+
GLuint blit_vbo;
unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
@@ -2056,6 +2056,8 @@ static inline const struct wined3d_context_gl *wined3d_context_gl_const(const st
return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
}
+void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
+ struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
@@ -2065,6 +2067,7 @@ void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
GLenum target, GLuint name) DECLSPEC_HIDDEN;
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
+void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
@@ -2213,7 +2216,6 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP
struct wined3d_context *context_acquire(const struct wined3d_device *device,
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
-void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence) DECLSPEC_HIDDEN;
BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
@@ -2238,7 +2240,6 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
void context_enable_clip_distances(struct wined3d_context *context, unsigned int mask) DECLSPEC_HIDDEN;
void context_end_transform_feedback(struct wined3d_context *context) DECLSPEC_HIDDEN;
-void context_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context) DECLSPEC_HIDDEN;
DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
--
2.11.0
1
0
[PATCH] kernelbase: Duplicate some path handling functions from shlwapi.
by Nikolay Sivov 14 May '19
by Nikolay Sivov 14 May '19
14 May '19
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/kernelbase/kernelbase.spec | 54 +--
dlls/kernelbase/path.c | 753 ++++++++++++++++++++++++++++++++
2 files changed, 780 insertions(+), 27 deletions(-)
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 7151bbae3c..d1bcea5593 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -1020,16 +1020,16 @@
# @ stub ParseApplicationUserModelId
@ stdcall ParseURLA(str ptr) shlwapi.ParseURLA
@ stdcall ParseURLW(wstr ptr) shlwapi.ParseURLW
-@ stdcall PathAddBackslashA(str) shlwapi.PathAddBackslashA
-@ stdcall PathAddBackslashW(wstr) shlwapi.PathAddBackslashW
-@ stdcall PathAddExtensionA(str str) shlwapi.PathAddExtensionA
-@ stdcall PathAddExtensionW(wstr wstr) shlwapi.PathAddExtensionW
+@ stdcall PathAddBackslashA(str)
+@ stdcall PathAddBackslashW(wstr)
+@ stdcall PathAddExtensionA(str str)
+@ stdcall PathAddExtensionW(wstr wstr)
@ stdcall PathAllocCanonicalize(wstr long ptr)
@ stdcall PathAllocCombine(wstr wstr long ptr)
-@ stdcall PathAppendA(str str) shlwapi.PathAppendA
-@ stdcall PathAppendW(wstr wstr) shlwapi.PathAppendW
-@ stdcall PathCanonicalizeA(ptr str) shlwapi.PathCanonicalizeA
-@ stdcall PathCanonicalizeW(ptr wstr) shlwapi.PathCanonicalizeW
+@ stdcall PathAppendA(str str)
+@ stdcall PathAppendW(wstr wstr)
+@ stdcall PathCanonicalizeA(ptr str)
+@ stdcall PathCanonicalizeW(ptr wstr)
@ stdcall PathCchAddBackslash(wstr long)
@ stdcall PathCchAddBackslashEx(wstr long ptr ptr)
@ stdcall PathCchAddExtension(wstr long wstr)
@@ -1049,17 +1049,17 @@
@ stdcall PathCchSkipRoot(wstr ptr)
@ stdcall PathCchStripPrefix(wstr long)
@ stdcall PathCchStripToRoot(wstr long)
-@ stdcall PathCombineA(ptr str str) shlwapi.PathCombineA
-@ stdcall PathCombineW(ptr wstr wstr) shlwapi.PathCombineW
-@ stdcall PathCommonPrefixA(str str ptr) shlwapi.PathCommonPrefixA
-@ stdcall PathCommonPrefixW(wstr wstr ptr) shlwapi.PathCommonPrefixW
+@ stdcall PathCombineA(ptr str str)
+@ stdcall PathCombineW(ptr wstr wstr)
+@ stdcall PathCommonPrefixA(str str ptr)
+@ stdcall PathCommonPrefixW(wstr wstr ptr)
@ stdcall PathCreateFromUrlA(str ptr ptr long) shlwapi.PathCreateFromUrlA
@ stdcall PathCreateFromUrlAlloc(wstr ptr long) shlwapi.PathCreateFromUrlAlloc
@ stdcall PathCreateFromUrlW(wstr ptr ptr long) shlwapi.PathCreateFromUrlW
@ stdcall PathFileExistsA(str) shlwapi.PathFileExistsA
@ stdcall PathFileExistsW(wstr) shlwapi.PathFileExistsW
-@ stdcall PathFindExtensionA(str) shlwapi.PathFindExtensionA
-@ stdcall PathFindExtensionW(wstr) shlwapi.PathFindExtensionW
+@ stdcall PathFindExtensionA(str)
+@ stdcall PathFindExtensionW(wstr)
@ stdcall PathFindFileNameA(str) shlwapi.PathFindFileNameA
@ stdcall PathFindFileNameW(wstr) shlwapi.PathFindFileNameW
@ stdcall PathFindNextComponentA(str) shlwapi.PathFindNextComponentA
@@ -1074,21 +1074,21 @@
@ stdcall PathIsFileSpecW(wstr) shlwapi.PathIsFileSpecW
@ stdcall PathIsLFNFileSpecA(str) shlwapi.PathIsLFNFileSpecA
@ stdcall PathIsLFNFileSpecW(wstr) shlwapi.PathIsLFNFileSpecW
-@ stdcall PathIsPrefixA(str str) shlwapi.PathIsPrefixA
-@ stdcall PathIsPrefixW(wstr wstr) shlwapi.PathIsPrefixW
-@ stdcall PathIsRelativeA(str) shlwapi.PathIsRelativeA
-@ stdcall PathIsRelativeW(wstr) shlwapi.PathIsRelativeW
-@ stdcall PathIsRootA(str) shlwapi.PathIsRootA
-@ stdcall PathIsRootW(wstr) shlwapi.PathIsRootW
+@ stdcall PathIsPrefixA(str str)
+@ stdcall PathIsPrefixW(wstr wstr)
+@ stdcall PathIsRelativeA(str)
+@ stdcall PathIsRelativeW(wstr)
+@ stdcall PathIsRootA(str)
+@ stdcall PathIsRootW(wstr)
@ stdcall PathIsSameRootA(str str) shlwapi.PathIsSameRootA
@ stdcall PathIsSameRootW(wstr wstr) shlwapi.PathIsSameRootW
-@ stdcall PathIsUNCA(str) shlwapi.PathIsUNCA
+@ stdcall PathIsUNCA(str)
@ stdcall PathIsUNCEx(wstr ptr)
@ stdcall PathIsUNCServerA(str) shlwapi.PathIsUNCServerA
-@ stdcall PathIsUNCServerShareA(str) shlwapi.PathIsUNCServerShareA
-@ stdcall PathIsUNCServerShareW(wstr) shlwapi.PathIsUNCServerShareW
+@ stdcall PathIsUNCServerShareA(str)
+@ stdcall PathIsUNCServerShareW(wstr)
@ stdcall PathIsUNCServerW(wstr) shlwapi.PathIsUNCServerW
-@ stdcall PathIsUNCW(wstr) shlwapi.PathIsUNCW
+@ stdcall PathIsUNCW(wstr)
@ stdcall PathIsURLA(str) shlwapi.PathIsURLA
@ stdcall PathIsURLW(wstr) shlwapi.PathIsURLW
@ stdcall PathIsValidCharA(long long) shlwapi.PathIsValidCharA
@@ -1109,8 +1109,8 @@
@ stdcall PathRemoveBlanksW(wstr) shlwapi.PathRemoveBlanksW
@ stdcall PathRemoveExtensionA(str) shlwapi.PathRemoveExtensionA
@ stdcall PathRemoveExtensionW(wstr) shlwapi.PathRemoveExtensionW
-@ stdcall PathRemoveFileSpecA(str) shlwapi.PathRemoveFileSpecA
-@ stdcall PathRemoveFileSpecW(wstr) shlwapi.PathRemoveFileSpecW
+@ stdcall PathRemoveFileSpecA(str)
+@ stdcall PathRemoveFileSpecW(wstr)
@ stdcall PathRenameExtensionA(str str) shlwapi.PathRenameExtensionA
@ stdcall PathRenameExtensionW(wstr wstr) shlwapi.PathRenameExtensionW
@ stdcall PathSearchAndQualifyA(str ptr long) shlwapi.PathSearchAndQualifyA
@@ -1120,7 +1120,7 @@
@ stdcall PathStripPathA(str) shlwapi.PathStripPathA
@ stdcall PathStripPathW(wstr) shlwapi.PathStripPathW
@ stdcall PathStripToRootA(str) shlwapi.PathStripToRootA
-@ stdcall PathStripToRootW(wstr) shlwapi.PathStripToRootW
+@ stdcall PathStripToRootW(wstr)
@ stdcall PathUnExpandEnvStringsA(str ptr long) shlwapi.PathUnExpandEnvStringsA
@ stdcall PathUnExpandEnvStringsW(wstr ptr long) shlwapi.PathUnExpandEnvStringsW
@ stdcall PathUnquoteSpacesA(str) shlwapi.PathUnquoteSpacesA
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index 5331f373c2..a72ff8e694 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -29,6 +29,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(path);
+char *char_next(const char *ptr)
+{
+ if (!*ptr) return (LPSTR)ptr;
+ if (IsDBCSLeadByte( ptr[0] ) && ptr[1]) return (LPSTR)(ptr + 2);
+ return (LPSTR)(ptr + 1);
+}
+
static SIZE_T strnlenW(const WCHAR *string, SIZE_T maxlen)
{
SIZE_T i;
@@ -865,3 +872,749 @@ BOOL WINAPI PathIsUNCEx(const WCHAR *path, const WCHAR **server)
if (server) *server = result;
return !!result;
}
+
+BOOL WINAPI PathIsUNCA(const char *path)
+{
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ return path && (path[0] == '\\') && (path[1] == '\\');
+}
+
+BOOL WINAPI PathIsUNCW(const WCHAR *path)
+{
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ return path && (path[0] == '\\') && (path[1] == '\\');
+}
+
+BOOL WINAPI PathIsRelativeA(const char *path)
+{
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (!path || !*path || IsDBCSLeadByte(*path))
+ return TRUE;
+
+ return !(*path == '\\' || (*path && path[1] == ':'));
+}
+
+BOOL WINAPI PathIsRelativeW(const WCHAR *path)
+{
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (!path || !*path)
+ return TRUE;
+
+ return !(*path == '\\' || (*path && path[1] == ':'));
+}
+
+BOOL WINAPI PathIsUNCServerShareA(const char *path)
+{
+ BOOL seen_slash = FALSE;
+
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (path && *path++ == '\\' && *path++ == '\\')
+ {
+ while (*path)
+ {
+ if (*path == '\\')
+ {
+ if (seen_slash)
+ return FALSE;
+ seen_slash = TRUE;
+ }
+
+ path = char_next(path);
+ }
+ }
+
+ return seen_slash;
+}
+
+BOOL WINAPI PathIsUNCServerShareW(const WCHAR *path)
+{
+ BOOL seen_slash = FALSE;
+
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (path && *path++ == '\\' && *path++ == '\\')
+ {
+ while (*path)
+ {
+ if (*path == '\\')
+ {
+ if (seen_slash)
+ return FALSE;
+ seen_slash = TRUE;
+ }
+
+ path++;
+ }
+ }
+
+ return seen_slash;
+}
+
+BOOL WINAPI PathIsRootA(const char *path)
+{
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (!path || !*path)
+ return FALSE;
+
+ if (*path == '\\')
+ {
+ if (!path[1])
+ return TRUE; /* \ */
+ else if (path[1] == '\\')
+ {
+ BOOL seen_slash = FALSE;
+ path += 2;
+
+ /* Check for UNC root path */
+ while (*path)
+ {
+ if (*path == '\\')
+ {
+ if (seen_slash)
+ return FALSE;
+ seen_slash = TRUE;
+ }
+
+ path = char_next(path);
+ }
+
+ return TRUE;
+ }
+ }
+ else if (path[1] == ':' && path[2] == '\\' && path[3] == '\0')
+ return TRUE; /* X:\ */
+
+ return FALSE;
+}
+
+BOOL WINAPI PathIsRootW(const WCHAR *path)
+{
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (!path || !*path)
+ return FALSE;
+
+ if (*path == '\\')
+ {
+ if (!path[1])
+ return TRUE; /* \ */
+ else if (path[1] == '\\')
+ {
+ BOOL seen_slash = FALSE;
+
+ path += 2;
+ /* Check for UNC root path */
+ while (*path)
+ {
+ if (*path == '\\')
+ {
+ if (seen_slash)
+ return FALSE;
+ seen_slash = TRUE;
+ }
+ path++;
+ }
+
+ return TRUE;
+ }
+ }
+ else if (path[1] == ':' && path[2] == '\\' && path[3] == '\0')
+ return TRUE; /* X:\ */
+
+ return FALSE;
+}
+
+BOOL WINAPI PathRemoveFileSpecA(char *path)
+{
+ char *filespec = path;
+ BOOL modified = FALSE;
+
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (!path)
+ return FALSE;
+
+ /* Skip directory or UNC path */
+ if (*path == '\\')
+ filespec = ++path;
+ if (*path == '\\')
+ filespec = ++path;
+
+ while (*path)
+ {
+ if (*path == '\\')
+ filespec = path; /* Skip dir */
+ else if (*path == ':')
+ {
+ filespec = ++path; /* Skip drive */
+ if (*path == '\\')
+ filespec++;
+ }
+ if (!(path = char_next(path)))
+ break;
+ }
+
+ if (*filespec)
+ {
+ *filespec = '\0';
+ modified = TRUE;
+ }
+
+ return modified;
+}
+
+BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
+{
+ WCHAR *filespec = path;
+ BOOL modified = FALSE;
+
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (!path)
+ return FALSE;
+
+ /* Skip directory or UNC path */
+ if (*path == '\\')
+ filespec = ++path;
+ if (*path == '\\')
+ filespec = ++path;
+
+ while (*path)
+ {
+ if (*path == '\\')
+ filespec = path; /* Skip dir */
+ else if (*path == ':')
+ {
+ filespec = ++path; /* Skip drive */
+ if (*path == '\\')
+ filespec++;
+ }
+
+ path++;
+ }
+
+ if (*filespec)
+ {
+ *filespec = '\0';
+ modified = TRUE;
+ }
+
+ return modified;
+}
+
+BOOL WINAPI PathStripToRootA(char *path)
+{
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (!path)
+ return FALSE;
+
+ while (!PathIsRootA(path))
+ if (!PathRemoveFileSpecA(path))
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL WINAPI PathStripToRootW(WCHAR *path)
+{
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (!path)
+ return FALSE;
+
+ while (!PathIsRootW(path))
+ if (!PathRemoveFileSpecW(path))
+ return FALSE;
+
+ return TRUE;
+}
+
+LPSTR WINAPI PathAddBackslashA(char *path)
+{
+ unsigned int len;
+ char *prev = path;
+
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (!path || (len = strlen(path)) >= MAX_PATH)
+ return NULL;
+
+ if (len)
+ {
+ do
+ {
+ path = char_next(prev);
+ if (*path)
+ prev = path;
+ } while (*path);
+
+ if (*prev != '\\')
+ {
+ *path++ = '\\';
+ *path = '\0';
+ }
+ }
+
+ return path;
+}
+
+LPWSTR WINAPI PathAddBackslashW(WCHAR *path)
+{
+ unsigned int len;
+
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (!path || (len = strlenW(path)) >= MAX_PATH)
+ return NULL;
+
+ if (len)
+ {
+ path += len;
+ if (path[-1] != '\\')
+ {
+ *path++ = '\\';
+ *path = '\0';
+ }
+ }
+
+ return path;
+}
+
+LPSTR WINAPI PathFindExtensionA(const char *path)
+{
+ const char *lastpoint = NULL;
+
+ TRACE("%s\n", wine_dbgstr_a(path));
+
+ if (path)
+ {
+ while (*path)
+ {
+ if (*path == '\\' || *path == ' ')
+ lastpoint = NULL;
+ else if (*path == '.')
+ lastpoint = path;
+ path = char_next(path);
+ }
+ }
+
+ return (LPSTR)(lastpoint ? lastpoint : path);
+}
+
+LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
+{
+ const WCHAR *lastpoint = NULL;
+
+ TRACE("%s\n", wine_dbgstr_w(path));
+
+ if (path)
+ {
+ while (*path)
+ {
+ if (*path == '\\' || *path == ' ')
+ lastpoint = NULL;
+ else if (*path == '.')
+ lastpoint = path;
+ path++;
+ }
+ }
+
+ return (LPWSTR)(lastpoint ? lastpoint : path);
+}
+
+BOOL WINAPI PathAddExtensionA(char *path, const char *ext)
+{
+ unsigned int len;
+
+ TRACE("%s, %s\n", wine_dbgstr_a(path), wine_dbgstr_a(ext));
+
+ if (!path || !ext || *(PathFindExtensionA(path)))
+ return FALSE;
+
+ len = strlen(path);
+ if (len + strlen(ext) >= MAX_PATH)
+ return FALSE;
+
+ strcpy(path + len, ext);
+ return TRUE;
+}
+
+BOOL WINAPI PathAddExtensionW(WCHAR *path, const WCHAR *ext)
+{
+ unsigned int len;
+
+ TRACE("%s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(ext));
+
+ if (!path || !ext || *(PathFindExtensionW(path)))
+ return FALSE;
+
+ len = strlenW(path);
+ if (len + strlenW(ext) >= MAX_PATH)
+ return FALSE;
+
+ strcpyW(path + len, ext);
+ return TRUE;
+}
+
+BOOL WINAPI PathCanonicalizeW(WCHAR *buffer, const WCHAR *path)
+{
+ const WCHAR *src = path;
+ WCHAR *dst = buffer;
+
+ TRACE("%p, %s\n", buffer, wine_dbgstr_w(path));
+
+ if (dst)
+ *dst = '\0';
+
+ if (!dst || !path)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (!*path)
+ {
+ *buffer++ = '\\';
+ *buffer = '\0';
+ return TRUE;
+ }
+
+ /* Copy path root */
+ if (*src == '\\')
+ {
+ *dst++ = *src++;
+ }
+ else if (*src && src[1] == ':')
+ {
+ /* X:\ */
+ *dst++ = *src++;
+ *dst++ = *src++;
+ if (*src == '\\')
+ *dst++ = *src++;
+ }
+
+ /* Canonicalize the rest of the path */
+ while (*src)
+ {
+ if (*src == '.')
+ {
+ if (src[1] == '\\' && (src == path || src[-1] == '\\' || src[-1] == ':'))
+ {
+ src += 2; /* Skip .\ */
+ }
+ else if (src[1] == '.' && (dst == buffer || dst[-1] == '\\'))
+ {
+ /* \.. backs up a directory, over the root if it has no \ following X:.
+ * .. is ignored if it would remove a UNC server name or initial \\
+ */
+ if (dst != buffer)
+ {
+ *dst = '\0'; /* Allow PathIsUNCServerShareA test on lpszBuf */
+ if (dst > buffer + 1 && dst[-1] == '\\' && (dst[-2] != '\\' || dst > buffer + 2))
+ {
+ if (dst[-2] == ':' && (dst > buffer + 3 || dst[-3] == ':'))
+ {
+ dst -= 2;
+ while (dst > buffer && *dst != '\\')
+ dst--;
+ if (*dst == '\\')
+ dst++; /* Reset to last '\' */
+ else
+ dst = buffer; /* Start path again from new root */
+ }
+ else if (dst[-2] != ':' && !PathIsUNCServerShareW(buffer))
+ dst -= 2;
+ }
+ while (dst > buffer && *dst != '\\')
+ dst--;
+ if (dst == buffer)
+ {
+ *dst++ = '\\';
+ src++;
+ }
+ }
+ src += 2; /* Skip .. in src path */
+ }
+ else
+ *dst++ = *src++;
+ }
+ else
+ *dst++ = *src++;
+ }
+
+ /* Append \ to naked drive specs */
+ if (dst - buffer == 2 && dst[-1] == ':')
+ *dst++ = '\\';
+ *dst++ = '\0';
+ return TRUE;
+}
+
+BOOL WINAPI PathCanonicalizeA(char *buffer, const char *path)
+{
+ WCHAR pathW[MAX_PATH], bufferW[MAX_PATH];
+ BOOL ret;
+ int len;
+
+ TRACE("%p, %s\n", buffer, wine_dbgstr_a(path));
+
+ if (buffer)
+ *buffer = '\0';
+
+ if (!buffer || !path)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ len = MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, ARRAY_SIZE(pathW));
+ if (!len)
+ return FALSE;
+
+ ret = PathCanonicalizeW(bufferW, pathW);
+ WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_PATH, 0, 0);
+
+ return ret;
+}
+
+WCHAR * WINAPI PathCombineW(WCHAR *dst, const WCHAR *dir, const WCHAR *file)
+{
+ BOOL use_both = FALSE, strip = FALSE;
+ WCHAR tmp[MAX_PATH];
+
+ TRACE("%p, %s, %s\n", dst, wine_dbgstr_w(dir), wine_dbgstr_w(file));
+
+ /* Invalid parameters */
+ if (!dst)
+ return NULL;
+
+ if (!dir && !file)
+ {
+ dst[0] = 0;
+ return NULL;
+ }
+
+ if ((!file || !*file) && dir)
+ {
+ /* Use dir only */
+ lstrcpynW(tmp, dir, ARRAY_SIZE(tmp));
+ }
+ else if (!dir || !*dir || !PathIsRelativeW(file))
+ {
+ if (!dir || !*dir || *file != '\\' || PathIsUNCW(file))
+ {
+ /* Use file only */
+ lstrcpynW(tmp, file, ARRAY_SIZE(tmp));
+ }
+ else
+ {
+ use_both = TRUE;
+ strip = TRUE;
+ }
+ }
+ else
+ use_both = TRUE;
+
+ if (use_both)
+ {
+ lstrcpynW(tmp, dir, ARRAY_SIZE(tmp));
+ if (strip)
+ {
+ PathStripToRootW(tmp);
+ file++; /* Skip '\' */
+ }
+
+ if (!PathAddBackslashW(tmp) || strlenW(tmp) + strlenW(file) >= MAX_PATH)
+ {
+ dst[0] = 0;
+ return NULL;
+ }
+
+ strcatW(tmp, file);
+ }
+
+ PathCanonicalizeW(dst, tmp);
+ return dst;
+}
+
+LPSTR WINAPI PathCombineA(char *dst, const char *dir, const char *file)
+{
+ WCHAR dstW[MAX_PATH], dirW[MAX_PATH], fileW[MAX_PATH];
+
+ TRACE("%p, %s, %s\n", dst, wine_dbgstr_a(dir), wine_dbgstr_a(file));
+
+ /* Invalid parameters */
+ if (!dst)
+ return NULL;
+
+ dst[0] = 0;
+
+ if (!dir && !file)
+ return NULL;
+
+ if (dir && !MultiByteToWideChar(CP_ACP, 0, dir, -1, dirW, ARRAY_SIZE(dirW)))
+ return NULL;
+
+ if (file && !MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, ARRAY_SIZE(fileW)))
+ return NULL;
+
+ if (PathCombineW(dstW, dir ? dirW : NULL, file ? fileW : NULL))
+ if (WideCharToMultiByte(CP_ACP, 0, dstW, -1, dst, MAX_PATH, 0, 0))
+ return dst;
+
+ return NULL;
+}
+
+BOOL WINAPI PathAppendA(char *path, const char *append)
+{
+ TRACE("%s, %s\n", wine_dbgstr_a(path), wine_dbgstr_a(append));
+
+ if (path && append)
+ {
+ if (!PathIsUNCA(append))
+ while (*append == '\\')
+ append++;
+
+ if (PathCombineA(path, path, append))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL WINAPI PathAppendW(WCHAR *path, const WCHAR *append)
+{
+ TRACE("%s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(append));
+
+ if (path && append)
+ {
+ if (!PathIsUNCW(append))
+ while (*append == '\\')
+ append++;
+
+ if (PathCombineW(path, path, append))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int WINAPI PathCommonPrefixA(const char *file1, const char *file2, char *path)
+{
+ const char *iter1 = file1;
+ const char *iter2 = file2;
+ unsigned int len = 0;
+
+ TRACE("%s, %s, %p.\n", wine_dbgstr_a(file1), wine_dbgstr_a(file2), path);
+
+ if (path)
+ *path = '\0';
+
+ if (!file1 || !file2)
+ return 0;
+
+ /* Handle roots first */
+ if (PathIsUNCA(file1))
+ {
+ if (!PathIsUNCA(file2))
+ return 0;
+ iter1 += 2;
+ iter2 += 2;
+ }
+ else if (PathIsUNCA(file2))
+ return 0;
+
+ for (;;)
+ {
+ /* Update len */
+ if ((!*iter1 || *iter1 == '\\') && (!*iter2 || *iter2 == '\\'))
+ len = iter1 - file1; /* Common to this point */
+
+ if (!*iter1 || (tolower(*iter1) != tolower(*iter2)))
+ break; /* Strings differ at this point */
+
+ iter1++;
+ iter2++;
+ }
+
+ if (len == 2)
+ len++; /* Feature/Bug compatible with Win32 */
+
+ if (len && path)
+ {
+ memcpy(path, file1, len);
+ path[len] = '\0';
+ }
+
+ return len;
+}
+
+int WINAPI PathCommonPrefixW(const WCHAR *file1, const WCHAR *file2, WCHAR *path)
+{
+ const WCHAR *iter1 = file1;
+ const WCHAR *iter2 = file2;
+ unsigned int len = 0;
+
+ TRACE("%s, %s, %p\n", wine_dbgstr_w(file1), wine_dbgstr_w(file2), path);
+
+ if (path)
+ *path = '\0';
+
+ if (!file1 || !file2)
+ return 0;
+
+ /* Handle roots first */
+ if (PathIsUNCW(file1))
+ {
+ if (!PathIsUNCW(file2))
+ return 0;
+ iter1 += 2;
+ iter2 += 2;
+ }
+ else if (PathIsUNCW(file2))
+ return 0;
+
+ for (;;)
+ {
+ /* Update len */
+ if ((!*iter1 || *iter1 == '\\') && (!*iter2 || *iter2 == '\\'))
+ len = iter1 - file1; /* Common to this point */
+
+ if (!*iter1 || (tolowerW(*iter1) != tolowerW(*iter2)))
+ break; /* Strings differ at this point */
+
+ iter1++;
+ iter2++;
+ }
+
+ if (len == 2)
+ len++; /* Feature/Bug compatible with Win32 */
+
+ if (len && path)
+ {
+ memcpy(path, file1, len * sizeof(WCHAR));
+ path[len] = '\0';
+ }
+
+ return len;
+}
+
+BOOL WINAPI PathIsPrefixA(const char *prefix, const char *path)
+{
+ TRACE("%s, %s\n", wine_dbgstr_a(prefix), wine_dbgstr_a(path));
+
+ return prefix && path && PathCommonPrefixA(path, prefix, NULL) == (int)strlen(prefix);
+}
+
+BOOL WINAPI PathIsPrefixW(const WCHAR *prefix, const WCHAR *path)
+{
+ TRACE("%s, %s\n", wine_dbgstr_w(prefix), wine_dbgstr_w(path));
+
+ return prefix && path && PathCommonPrefixW(path, prefix, NULL) == (int)strlenW(prefix);
+}
--
2.20.1
1
0
[PATCH 1/7] dwrite: Use array allocation helper to manage family entries.
by Nikolay Sivov 14 May '19
by Nikolay Sivov 14 May '19
14 May '19
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/dwrite/font.c | 166 ++++++++++++++++++++++-----------------------
1 file changed, 82 insertions(+), 84 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 5a3afefb27..7532aa090d 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -99,14 +99,16 @@ struct dwrite_font_data {
BOOL oblique_sim_tested : 1;
};
-struct dwrite_fontfamily_data {
- LONG ref;
+struct dwrite_fontfamily_data
+{
+ LONG refcount;
IDWriteLocalizedStrings *familyname;
struct dwrite_font_data **fonts;
- UINT32 font_count;
- UINT32 font_alloc;
+ size_t size;
+ size_t count;
+
BOOL has_normal_face : 1;
BOOL has_oblique_face : 1;
BOOL has_italic_face : 1;
@@ -428,12 +430,12 @@ static void release_font_data(struct dwrite_font_data *data)
static void release_fontfamily_data(struct dwrite_fontfamily_data *data)
{
- int i;
+ size_t i;
- if (InterlockedDecrement(&data->ref) > 0)
+ if (InterlockedDecrement(&data->refcount) > 0)
return;
- for (i = 0; i < data->font_count; i++)
+ for (i = 0; i < data->count; ++i)
release_font_data(data->fonts[i]);
heap_free(data->fonts);
IDWriteLocalizedStrings_Release(data->familyname);
@@ -2043,26 +2045,28 @@ static HRESULT WINAPI dwritefontfamily_GetFontCollection(IDWriteFontFamily1 *ifa
static UINT32 WINAPI dwritefontfamily_GetFontCount(IDWriteFontFamily1 *iface)
{
- struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
- TRACE("(%p)\n", This);
- return This->data->font_count;
+ struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily1(iface);
+
+ TRACE("%p.\n", iface);
+
+ return family->data->count;
}
static HRESULT WINAPI dwritefontfamily_GetFont(IDWriteFontFamily1 *iface, UINT32 index, IDWriteFont **font)
{
- struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
+ struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily1(iface);
- TRACE("(%p)->(%u %p)\n", This, index, font);
+ TRACE("%p, %u, %p.\n", iface, index, font);
*font = NULL;
- if (This->data->font_count == 0)
+ if (!family->data->count)
return S_FALSE;
- if (index >= This->data->font_count)
+ if (index >= family->data->count)
return E_INVALIDARG;
- return create_font(This, index, (IDWriteFont3 **)font);
+ return create_font(family, index, (IDWriteFont3 **)font);
}
static HRESULT WINAPI dwritefontfamily_GetFamilyNames(IDWriteFontFamily1 *iface, IDWriteLocalizedStrings **names)
@@ -2115,13 +2119,14 @@ static BOOL is_better_font_match(const struct dwrite_font_propvec *next, const s
static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily1 *iface, DWRITE_FONT_WEIGHT weight,
DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFont **font)
{
- struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
+ struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily1(iface);
struct dwrite_font_propvec req;
- UINT32 i, match;
+ size_t i, match;
- TRACE("(%p)->(%d %d %d %p)\n", This, weight, stretch, style, font);
+ TRACE("%p, %d, %d, %d, %p.\n", iface, weight, stretch, style, font);
- if (This->data->font_count == 0) {
+ if (!family->data->count)
+ {
*font = NULL;
return DWRITE_E_NOFONT;
}
@@ -2129,12 +2134,13 @@ static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily1 *
init_font_prop_vec(weight, stretch, style, &req);
match = 0;
- for (i = 1; i < This->data->font_count; i++) {
- if (is_better_font_match(&This->data->fonts[i]->propvec, &This->data->fonts[match]->propvec, &req))
+ for (i = 1; i < family->data->count; ++i)
+ {
+ if (is_better_font_match(&family->data->fonts[i]->propvec, &family->data->fonts[match]->propvec, &req))
match = i;
}
- return create_font(This, match, (IDWriteFont3 **)font);
+ return create_font(family, match, (IDWriteFont3 **)font);
}
typedef BOOL (*matching_filter_func)(const struct dwrite_font_data*);
@@ -2174,13 +2180,13 @@ static void matchingfonts_sort(struct dwrite_fontlist *fonts, const struct dwrit
static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *iface, DWRITE_FONT_WEIGHT weight,
DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFontList **ret)
{
- struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
+ struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily1(iface);
matching_filter_func func = NULL;
struct dwrite_font_propvec req;
struct dwrite_fontlist *fonts;
- UINT32 i;
+ size_t i;
- TRACE("(%p)->(%d %d %d %p)\n", This, weight, stretch, style, ret);
+ TRACE("%p, %d, %d, %d, %p.\n", iface, weight, stretch, style, ret);
*ret = NULL;
@@ -2189,7 +2195,7 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
return E_OUTOFMEMORY;
/* Allocate as many as family has, not all of them will be necessary used. */
- fonts->fonts = heap_calloc(This->data->font_count, sizeof(*fonts->fonts));
+ fonts->fonts = heap_calloc(family->data->count, sizeof(*fonts->fonts));
if (!fonts->fonts) {
heap_free(fonts);
return E_OUTOFMEMORY;
@@ -2197,24 +2203,26 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
fonts->IDWriteFontList1_iface.lpVtbl = &dwritefontlistvtbl;
fonts->ref = 1;
- fonts->family = This;
+ fonts->family = family;
IDWriteFontFamily1_AddRef(&fonts->family->IDWriteFontFamily1_iface);
fonts->font_count = 0;
/* Normal style accepts Normal or Italic, Oblique and Italic - both Oblique and Italic styles */
if (style == DWRITE_FONT_STYLE_NORMAL) {
- if (This->data->has_normal_face || This->data->has_italic_face)
+ if (family->data->has_normal_face || family->data->has_italic_face)
func = is_font_acceptable_for_normal;
}
else /* requested oblique or italic */ {
- if (This->data->has_oblique_face || This->data->has_italic_face)
+ if (family->data->has_oblique_face || family->data->has_italic_face)
func = is_font_acceptable_for_oblique_italic;
}
- for (i = 0; i < This->data->font_count; i++) {
- if (!func || func(This->data->fonts[i])) {
- fonts->fonts[fonts->font_count] = This->data->fonts[i];
- addref_font_data(This->data->fonts[i]);
+ for (i = 0; i < family->data->count; ++i)
+ {
+ if (!func || func(family->data->fonts[i]))
+ {
+ fonts->fonts[fonts->font_count] = family->data->fonts[i];
+ addref_font_data(family->data->fonts[i]);
fonts->font_count++;
}
}
@@ -2223,7 +2231,7 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
init_font_prop_vec(weight, stretch, style, &req);
matchingfonts_sort(fonts, &req);
- *ret = (IDWriteFontList*)&fonts->IDWriteFontList1_iface;
+ *ret = (IDWriteFontList *)&fonts->IDWriteFontList1_iface;
return S_OK;
}
@@ -2238,19 +2246,19 @@ static DWRITE_LOCALITY WINAPI dwritefontfamily1_GetFontLocality(IDWriteFontFamil
static HRESULT WINAPI dwritefontfamily1_GetFont(IDWriteFontFamily1 *iface, UINT32 index, IDWriteFont3 **font)
{
- struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
+ struct dwrite_fontfamily *family = impl_from_IDWriteFontFamily1(iface);
- TRACE("(%p)->(%u %p)\n", This, index, font);
+ TRACE("%p, %u, %p.\n", iface, index, font);
*font = NULL;
- if (This->data->font_count == 0)
+ if (!family->data->count)
return S_FALSE;
- if (index >= This->data->font_count)
+ if (index >= family->data->count)
return E_FAIL;
- return create_font(This, index, font);
+ return create_font(family, index, font);
}
static HRESULT WINAPI dwritefontfamily1_GetFontFaceReference(IDWriteFontFamily1 *iface, UINT32 index,
@@ -2359,22 +2367,23 @@ static const IDWriteFontList1Vtbl fontfamilylistvtbl = {
static HRESULT create_fontfamily(struct dwrite_fontcollection *collection, UINT32 index, IDWriteFontFamily1 **family)
{
- struct dwrite_fontfamily *This;
+ struct dwrite_fontfamily *object;
*family = NULL;
- This = heap_alloc(sizeof(struct dwrite_fontfamily));
- if (!This) return E_OUTOFMEMORY;
+ object = heap_alloc(sizeof(*object));
+ if (!object)
+ return E_OUTOFMEMORY;
- This->IDWriteFontFamily1_iface.lpVtbl = &fontfamilyvtbl;
- This->IDWriteFontList1_iface.lpVtbl = &fontfamilylistvtbl;
- This->ref = 1;
- This->collection = collection;
+ object->IDWriteFontFamily1_iface.lpVtbl = &fontfamilyvtbl;
+ object->IDWriteFontList1_iface.lpVtbl = &fontfamilylistvtbl;
+ object->ref = 1;
+ object->collection = collection;
IDWriteFontCollection1_AddRef(&collection->IDWriteFontCollection1_iface);
- This->data = collection->family_data[index];
- InterlockedIncrement(&This->data->ref);
+ object->data = collection->family_data[index];
+ InterlockedIncrement(&object->data->refcount);
- *family = &This->IDWriteFontFamily1_iface;
+ *family = &object->IDWriteFontFamily1_iface;
return S_OK;
}
@@ -2535,10 +2544,11 @@ static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollec
{
struct dwrite_fontcollection *This = impl_from_IDWriteFontCollection1(iface);
IDWriteFontFamily1 *family;
- UINT32 i, j, face_index;
BOOL found_font = FALSE;
IDWriteFontFile *file;
+ UINT32 i, face_index;
HRESULT hr;
+ size_t j;
TRACE("(%p)->(%p %p)\n", This, face, font);
@@ -2557,7 +2567,8 @@ static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollec
for (i = 0; i < This->family_count; i++) {
struct dwrite_fontfamily_data *family_data = This->family_data[i];
- for (j = 0; j < family_data->font_count; j++) {
+ for (j = 0; j < family_data->count; ++j)
+ {
struct dwrite_font_data *font_data = family_data->fonts[j];
if (face_index == font_data->face_index && is_same_fontfile(file, font_data->file)) {
@@ -2632,20 +2643,13 @@ static const IDWriteFontCollection1Vtbl systemfontcollectionvtbl = {
static HRESULT fontfamily_add_font(struct dwrite_fontfamily_data *family_data, struct dwrite_font_data *font_data)
{
- if (family_data->font_count + 1 >= family_data->font_alloc) {
- struct dwrite_font_data **new_list;
- UINT32 new_alloc;
-
- new_alloc = family_data->font_alloc * 2;
- new_list = heap_realloc(family_data->fonts, sizeof(*family_data->fonts) * new_alloc);
- if (!new_list)
- return E_OUTOFMEMORY;
- family_data->fonts = new_list;
- family_data->font_alloc = new_alloc;
+ if (!dwrite_array_reserve((void **)&family_data->fonts, &family_data->size, family_data->count + 1,
+ sizeof(*family_data->fonts)))
+ {
+ return E_OUTOFMEMORY;
}
- family_data->fonts[family_data->font_count] = font_data;
- family_data->font_count++;
+ family_data->fonts[family_data->count++] = font_data;
if (font_data->style == DWRITE_FONT_STYLE_NORMAL)
family_data->has_normal_face = 1;
else if (font_data->style == DWRITE_FONT_STYLE_OBLIQUE)
@@ -3518,35 +3522,25 @@ static HRESULT init_fontfamily_data(IDWriteLocalizedStrings *familyname, struct
{
struct dwrite_fontfamily_data *data;
- data = heap_alloc(sizeof(*data));
+ data = heap_alloc_zero(sizeof(*data));
if (!data)
return E_OUTOFMEMORY;
- data->ref = 1;
- data->font_count = 0;
- data->font_alloc = 2;
- data->has_normal_face = 0;
- data->has_oblique_face = 0;
- data->has_italic_face = 0;
-
- data->fonts = heap_calloc(data->font_alloc, sizeof(*data->fonts));
- if (!data->fonts) {
- heap_free(data);
- return E_OUTOFMEMORY;
- }
-
+ data->refcount = 1;
data->familyname = familyname;
IDWriteLocalizedStrings_AddRef(familyname);
*ret = data;
+
return S_OK;
}
static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *family)
{
- UINT32 i, j, heaviest;
+ size_t i, j, heaviest;
- for (i = 0; i < family->font_count; i++) {
+ for (i = 0; i < family->count; ++i)
+ {
DWRITE_FONT_WEIGHT weight = family->fonts[i]->weight;
heaviest = i;
@@ -3554,7 +3548,8 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa
continue;
family->fonts[i]->bold_sim_tested = 1;
- for (j = i; j < family->font_count; j++) {
+ for (j = i; j < family->count; ++j)
+ {
if (family->fonts[j]->bold_sim_tested)
continue;
@@ -3616,9 +3611,10 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa
static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data *family)
{
- UINT32 i, j;
+ size_t i, j;
- for (i = 0; i < family->font_count; i++) {
+ for (i = 0; i < family->count; ++i)
+ {
UINT32 regular = ~0u, oblique = ~0u;
struct dwrite_font_data *obliqueface;
WCHAR facenameW[255];
@@ -3633,7 +3629,8 @@ static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data
oblique = i;
/* find regular style with same weight/stretch values */
- for (j = i; j < family->font_count; j++) {
+ for (j = i; j < family->count; ++j)
+ {
if (family->fonts[j]->oblique_sim_tested)
continue;
@@ -3701,7 +3698,8 @@ static BOOL fontcollection_add_replacement(struct dwrite_fontcollection *collect
struct dwrite_fontfamily_data *replacement = collection->family_data[i];
WCHAR nameW[255];
- for (i = 0; i < replacement->font_count; i++) {
+ for (i = 0; i < replacement->count; ++i)
+ {
fontfamily_add_font(target, replacement->fonts[i]);
addref_font_data(replacement->fonts[i]);
}
--
2.20.1
1
6
[PATCH v2 4/8] ntdll: Use CLOCK_REALTIME_COARSE for NtQuerySystemTime() if it has sufficient resolution.
by Huw Davies 14 May '19
by Huw Davies 14 May '19
14 May '19
This will only affect users running with HZ=1000. On an i7-8700 CPU @
3.20GHz it cuts the call cost from ~30ns to ~12ns.
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/ntdll/time.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index ec0a187da4..3b28113542 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -458,19 +458,45 @@ void WINAPI RtlTimeToElapsedTimeFields( const LARGE_INTEGER *Time, PTIME_FIELDS
* Get the current system time.
*
* PARAMS
- * Time [O] Destination for the current system time.
+ * time [O] Destination for the current system time.
*
* RETURNS
* Success: STATUS_SUCCESS.
* Failure: An NTSTATUS error code indicating the problem.
*/
-NTSTATUS WINAPI NtQuerySystemTime( PLARGE_INTEGER Time )
+NTSTATUS WINAPI NtQuerySystemTime( LARGE_INTEGER *time )
{
- struct timeval now;
+#ifdef HAVE_CLOCK_GETTIME
+ struct timespec ts;
+ static clockid_t clock_id = CLOCK_MONOTONIC; /* placeholder */
- gettimeofday( &now, 0 );
- Time->QuadPart = now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
- Time->QuadPart += now.tv_usec * 10;
+ if (clock_id == CLOCK_MONOTONIC)
+ {
+#ifdef CLOCK_REALTIME_COARSE
+ struct timespec res;
+
+ /* Use CLOCK_REALTIME_COARSE if it has 1 ms or better resolution */
+ if (!clock_getres( CLOCK_REALTIME_COARSE, &res ) && res.tv_sec == 0 && res.tv_nsec <= 1000000)
+ clock_id = CLOCK_REALTIME_COARSE;
+ else
+#endif /* CLOCK_REALTIME_COARSE */
+ clock_id = CLOCK_REALTIME;
+ }
+
+ if (!clock_gettime( clock_id, &ts ))
+ {
+ time->QuadPart = ts.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ time->QuadPart += (ts.tv_nsec + 50) / 100;
+ }
+ else
+#endif /* HAVE_CLOCK_GETTIME */
+ {
+ struct timeval now;
+
+ gettimeofday( &now, 0 );
+ time->QuadPart = now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+ time->QuadPart += now.tv_usec * 10;
+ }
return STATUS_SUCCESS;
}
--
2.17.1
2
1
This makes the return value reply->state consistent with
reply->state = desktop->keystate[req->key & 0xff] & ~0x40;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30814
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
server/queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/queue.c b/server/queue.c
index 24239916af..3c1c6c168f 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -2842,8 +2842,8 @@ DECL_HANDLER(get_key_state)
if (!(desktop = get_thread_desktop( current, 0 ))) return;
if (req->key >= 0)
{
- reply->state = desktop->keystate[req->key & 0xff];
desktop->keystate[req->key & 0xff] &= ~0x40;
+ reply->state = desktop->keystate[req->key & 0xff];
}
set_reply_data( desktop->keystate, size );
release_object( desktop );
--
2.20.1
1
0