[PATCH 3/5] wined3d: Move the "valid" field from struct wined3d_context to struct wined3d_context_gl.

Henri Verbeet hverbeet at codeweavers.com
Thu Jun 6 07:51:06 CDT 2019


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/context.c         | 54 ++++++++++++++++++++----------------------
 dlls/wined3d/cs.c              | 10 ++++----
 dlls/wined3d/device.c          |  2 +-
 dlls/wined3d/surface.c         |  4 ++--
 dlls/wined3d/swapchain.c       |  4 ++--
 dlls/wined3d/wined3d_private.h | 34 +++++++++++++-------------
 6 files changed, 53 insertions(+), 55 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index fb745e2d98e..0f107502f5c 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1241,7 +1241,7 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context
     {
         WARN("Failed to make GL context %p current on device context %p, last error %#x.\n",
                 context_gl->gl_ctx, context_gl->dc, GetLastError());
-        context_gl->c.valid = 0;
+        context_gl->valid = 0;
         WARN("Trying fallback to the backup window.\n");
 
         /* FIXME: If the context is destroyed it's no longer associated with
@@ -1280,7 +1280,7 @@ static BOOL wined3d_context_gl_set_gl_context(struct wined3d_context_gl *context
             return FALSE;
         }
 
-        context_gl->c.valid = 1;
+        context_gl->valid = 1;
     }
     context_gl->needs_set = 0;
 
@@ -1315,12 +1315,12 @@ static void wined3d_context_gl_update_window(struct wined3d_context_gl *context_
     context_gl->dc_is_private = FALSE;
     context_gl->dc_has_format = FALSE;
     context_gl->needs_set = 1;
-    context_gl->c.valid = 1;
+    context_gl->valid = 1;
 
     if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE)))
     {
         ERR("Failed to get a device context for window %p.\n", context_gl->window);
-        context_gl->c.valid = 0;
+        context_gl->valid = 0;
     }
 }
 
@@ -1346,10 +1346,10 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
 
     if (restore_ctx == context_gl->gl_ctx)
         restore_ctx = NULL;
-    else if (context_gl->c.valid)
+    else if (context_gl->valid)
         wined3d_context_gl_set_gl_context(context_gl);
 
-    if (context_gl->c.valid)
+    if (context_gl->valid)
     {
         if (context_gl->dummy_arbfp_prog)
             GL_EXTCALL(glDeleteProgramsARB(1, &context_gl->dummy_arbfp_prog));
@@ -1408,7 +1408,7 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
     LIST_FOR_EACH_ENTRY(pipeline_statistics_query, &context_gl->pipeline_statistics_queries,
             struct wined3d_pipeline_statistics_query, entry)
     {
-        if (context_gl->c.valid)
+        if (context_gl->valid)
             GL_EXTCALL(glDeleteQueries(ARRAY_SIZE(pipeline_statistics_query->u.id), pipeline_statistics_query->u.id));
         pipeline_statistics_query->context_gl = NULL;
     }
@@ -1416,21 +1416,21 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
     LIST_FOR_EACH_ENTRY(so_statistics_query, &context_gl->so_statistics_queries,
             struct wined3d_so_statistics_query, entry)
     {
-        if (context_gl->c.valid)
+        if (context_gl->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)
+        if (context_gl->valid)
             GL_EXTCALL(glDeleteQueries(1, &timestamp_query->id));
         timestamp_query->context_gl = NULL;
     }
 
     LIST_FOR_EACH_ENTRY(fence, &context_gl->fences, struct wined3d_fence, entry)
     {
-        if (context_gl->c.valid)
+        if (context_gl->valid)
         {
             if (gl_info->supported[ARB_SYNC])
             {
@@ -1451,21 +1451,21 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
 
     LIST_FOR_EACH_ENTRY(occlusion_query, &context_gl->occlusion_queries, struct wined3d_occlusion_query, entry)
     {
-        if (context_gl->c.valid)
+        if (context_gl->valid)
             GL_EXTCALL(glDeleteQueries(1, &occlusion_query->id));
         occlusion_query->context_gl = NULL;
     }
 
     LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_destroy_list, struct fbo_entry, entry)
     {
-        if (!context_gl->c.valid)
+        if (!context_gl->valid)
             entry->id = 0;
         wined3d_context_gl_destroy_fbo_entry(context_gl, entry);
     }
 
     LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context_gl->fbo_list, struct fbo_entry, entry)
     {
-        if (!context_gl->c.valid)
+        if (!context_gl->valid)
             entry->id = 0;
         wined3d_context_gl_destroy_fbo_entry(context_gl, entry);
     }
@@ -1539,7 +1539,7 @@ BOOL context_set_current(struct wined3d_context *ctx)
     {
         struct wined3d_context_gl *context_gl = wined3d_context_gl(ctx);
 
-        if (!ctx->valid)
+        if (!context_gl->valid)
         {
             ERR("Trying to make invalid context %p current\n", ctx);
             return FALSE;
@@ -2129,7 +2129,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
 
     context->render_offscreen = wined3d_resource_is_offscreen(target);
     context_gl->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
-    context->valid = 1;
+    context_gl->valid = 1;
 
     context_gl->gl_ctx = ctx;
     context_gl->dc_has_format = TRUE;
@@ -4183,7 +4183,7 @@ static void wined3d_context_gl_activate(struct wined3d_context_gl *context_gl,
     wined3d_context_gl_enter(context_gl);
     wined3d_context_gl_update_window(context_gl);
     context_setup_target(&context_gl->c, texture, sub_resource_idx);
-    if (!context_gl->c.valid)
+    if (!context_gl->valid)
         return;
 
     if (&context_gl->c != context_get_current())
@@ -4287,33 +4287,31 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
 {
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context_gl *context_gl;
-    struct wined3d_context *context;
 
-    context = context_acquire(device, NULL, 0);
-    if (!context->valid)
+    context_gl = wined3d_context_gl(context_acquire(device, NULL, 0));
+    if (!context_gl->valid)
     {
-        context_release(context);
+        context_release(&context_gl->c);
         WARN("Invalid context, skipping dispatch.\n");
         return;
     }
-    context_gl = wined3d_context_gl(context);
-    gl_info = context->gl_info;
+    gl_info = context_gl->c.gl_info;
 
     if (!gl_info->supported[ARB_COMPUTE_SHADER])
     {
-        context_release(context);
+        context_release(&context_gl->c);
         FIXME("OpenGL implementation does not support compute shaders.\n");
         return;
     }
 
     if (parameters->indirect)
-        wined3d_buffer_load(parameters->u.indirect.buffer, context, state);
+        wined3d_buffer_load(parameters->u.indirect.buffer, &context_gl->c, state);
 
     wined3d_context_gl_apply_compute_state(context_gl, device, state);
 
     if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE])
     {
-        context_release(context);
+        context_release(&context_gl->c);
         WARN("No compute shader bound, skipping dispatch.\n");
         return;
     }
@@ -4337,7 +4335,7 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
     GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS));
     checkGLcall("glMemoryBarrier");
 
-    context_release(context);
+    context_release(&context_gl->c);
 }
 
 /* Context activation is done by the caller. */
@@ -4815,13 +4813,13 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
         context = context_acquire(device, wined3d_texture_from_resource(rtv->resource), rtv->sub_resource_idx);
     else
         context = context_acquire(device, NULL, 0);
-    if (!context->valid)
+    context_gl = wined3d_context_gl(context);
+    if (!context_gl->valid)
     {
         context_release(context);
         WARN("Invalid context, skipping draw.\n");
         return;
     }
-    context_gl = wined3d_context_gl(context);
     gl_info = context->gl_info;
 
     if (!use_transform_feedback(state))
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 2fb361fb677..e1f94f45eed 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1008,12 +1008,12 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type,
 
 static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data)
 {
-    struct wined3d_context *context;
+    struct wined3d_context_gl *context_gl;
 
-    context = context_acquire(cs->device, NULL, 0);
-    if (context->valid)
-        context->gl_info->gl_ops.gl.p_glFlush();
-    context_release(context);
+    context_gl = wined3d_context_gl(context_acquire(cs->device, NULL, 0));
+    if (context_gl->valid)
+        context_gl->c.gl_info->gl_ops.gl.p_glFlush();
+    context_release(&context_gl->c);
 }
 
 void wined3d_cs_emit_flush(struct wined3d_cs *cs)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ed77a6e144a..4ec4022dce6 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -306,7 +306,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
     if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
         depth_stencil = texture_from_resource(dsv->resource);
 
-    if (!context->valid)
+    if (!context_gl->valid)
     {
         context_release(context);
         WARN("Invalid context, skipping clear.\n");
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7d126420d17..7ae4fb81877 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -224,14 +224,14 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
     else
         restore_texture = NULL;
 
-    if (!context->valid)
+    context_gl = wined3d_context_gl(context);
+    if (!context_gl->valid)
     {
         context_release(context);
         WARN("Invalid context, skipping blit.\n");
         return;
     }
 
-    context_gl = wined3d_context_gl(context);
     gl_info = context->gl_info;
 
     if (src_location == WINED3D_LOCATION_DRAWABLE)
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 2c816218c8e..c18f7304d94 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -434,13 +434,13 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
     BOOL render_to_fbo;
 
     context = context_acquire(swapchain->device, back_buffer, 0);
-    if (!context->valid)
+    context_gl = wined3d_context_gl(context);
+    if (!context_gl->valid)
     {
         context_release(context);
         WARN("Invalid context, skipping present.\n");
         return;
     }
-    context_gl = wined3d_context_gl(context);
 
     gl_info = context->gl_info;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5b37e96c9d0..753dc8cb663 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1903,40 +1903,39 @@ struct wined3d_context
     DWORD                   tid;    /* Thread ID which owns this context at the moment */
 
     /* Stores some information about the context state for optimization */
-    DWORD render_offscreen : 1;
-    DWORD last_was_rhw : 1;             /* true iff last draw_primitive was in xyzrhw mode */
+    DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
+    DWORD update_shader_resource_bindings : 1;
+    DWORD update_compute_shader_resource_bindings : 1;
+    DWORD update_unordered_access_view_bindings : 1;
+    DWORD update_compute_unordered_access_view_bindings : 1;
     DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
+    DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
     DWORD last_was_pshader : 1;
     DWORD last_was_vshader : 1;
     DWORD last_was_diffuse : 1;
     DWORD last_was_specular : 1;
     DWORD last_was_normal : 1;
-    DWORD namedArraysLoaded : 1;
+
     DWORD last_was_ffp_blit : 1;
     DWORD last_was_blit : 1;
     DWORD last_was_ckey : 1;
-    DWORD fog_coord : 1;
-    DWORD current : 1;
-    DWORD destroyed : 1;
-    DWORD destroy_delayed : 1;
-    DWORD valid : 1;
-
+    DWORD namedArraysLoaded : 1;
     DWORD texShaderBumpMap : 8;         /* WINED3D_MAX_TEXTURES, 8 */
     DWORD lastWasPow2Texture : 8;       /* WINED3D_MAX_TEXTURES, 8 */
     DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
     DWORD lowest_disabled_stage : 4;    /* Max WINED3D_MAX_TEXTURES, 8 */
+
     DWORD use_immediate_mode_draw : 1;
     DWORD uses_uavs : 1;
     DWORD transform_feedback_active : 1;
     DWORD transform_feedback_paused : 1;
-
-    DWORD update_shader_resource_bindings : 1;
-    DWORD update_compute_shader_resource_bindings : 1;
-    DWORD update_unordered_access_view_bindings : 1;
-    DWORD update_compute_unordered_access_view_bindings : 1;
-    DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
+    DWORD fog_coord : 1;
+    DWORD render_offscreen : 1;
+    DWORD current : 1;
+    DWORD destroyed : 1;
+    DWORD destroy_delayed : 1;
     DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
-    DWORD padding : 14;
+    DWORD padding : 15;
 
     DWORD constant_update_mask;
     DWORD numbered_array_mask;
@@ -1975,7 +1974,8 @@ struct wined3d_context_gl
     uint32_t rebind_fbo : 1;
     uint32_t untracked_material_count : 2; /* Max value 2 */
     uint32_t needs_set : 1;
-    uint32_t padding : 24;
+    uint32_t valid : 1;
+    uint32_t padding : 23;
 
     uint32_t default_attrib_value_set;
 
-- 
2.11.0




More information about the wine-devel mailing list