[Mesa-dev] [PATCH 58/84] st/nine: use get_pipe_acquire/release when possible

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:55:31 UTC 2016


Use the acquire/release semantic when we don't need
to wait for any pending command.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/basetexture9.c  |  8 ++++++--
 src/gallium/state_trackers/nine/buffer9.c       |  4 +++-
 src/gallium/state_trackers/nine/nine_state.c    | 16 ++++++++++------
 src/gallium/state_trackers/nine/pixelshader9.c  |  3 ++-
 src/gallium/state_trackers/nine/surface9.c      | 10 +++++++---
 src/gallium/state_trackers/nine/swapchain9.c    |  3 ++-
 src/gallium/state_trackers/nine/vertexshader9.c |  3 ++-
 src/gallium/state_trackers/nine/volume9.c       |  3 ++-
 8 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c
index f37dbb1..ce08c25 100644
--- a/src/gallium/state_trackers/nine/basetexture9.c
+++ b/src/gallium/state_trackers/nine/basetexture9.c
@@ -455,7 +455,6 @@ NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This,
     if (!res)
         return D3DERR_OUTOFVIDEOMEMORY;
     This->base.resource = res;
-    pipe = NineDevice9_GetPipe(This->base.base.device);
 
     if (old && CopyData) { /* Don't return without releasing old ! */
         struct pipe_box box;
@@ -470,6 +469,8 @@ NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This,
         box.height = u_minify(templ.height0, l);
         box.depth = u_minify(templ.depth0, l);
 
+        pipe = nine_context_get_pipe_acquire(This->base.base.device);
+
         for (; l <= templ.last_level; ++l, ++m) {
             pipe->resource_copy_region(pipe,
                                        res, l, 0, 0, 0,
@@ -478,6 +479,8 @@ NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This,
             box.height = u_minify(box.height, 1);
             box.depth = u_minify(box.depth, 1);
         }
+
+        nine_context_get_pipe_release(This->base.base.device);
     }
     pipe_resource_reference(&old, NULL);
 
@@ -574,8 +577,9 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
     templ.swizzle_a = swizzle[3];
     templ.target = resource->target;
 
-    pipe = NineDevice9_GetPipe(This->base.base.device);
+    pipe = nine_context_get_pipe_acquire(This->base.base.device);
     This->view[sRGB] = pipe->create_sampler_view(pipe, resource, &templ);
+    nine_context_get_pipe_release(This->base.base.device);
 
     DBG("sampler view = %p(resource = %p)\n", This->view[sRGB], resource);
 
diff --git a/src/gallium/state_trackers/nine/buffer9.c b/src/gallium/state_trackers/nine/buffer9.c
index 7a2145d..ca6a1b3 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -323,8 +323,10 @@ NineBuffer9_Unlock( struct NineBuffer9 *This )
     if (This->base.pool != D3DPOOL_MANAGED) {
         pipe = This->maps[This->nmaps].is_pipe_secondary ?
             device->pipe_secondary :
-            NineDevice9_GetPipe(device);
+            nine_context_get_pipe_acquire(device);
         pipe->transfer_unmap(pipe, This->maps[This->nmaps].transfer);
+        if (!This->maps[This->nmaps].is_pipe_secondary)
+            nine_context_get_pipe_release(device);
     } else {
         BASEBUF_REGISTER_UPDATE(This);
     }
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 0cf3721..4783599 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2682,11 +2682,13 @@ CSMT_ITEM_NO_WAIT(nine_context_blit,
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
-    struct nine_context *context = &device->context;
+    struct pipe_context *pipe;
+    struct pipe_query *res;
 
-    if (device->csmt_active)
-        nine_csmt_process(device);
-    return context->pipe->create_query(context->pipe, query_type, 0);
+    pipe = nine_context_get_pipe_acquire(device);
+    res = pipe->create_query(pipe, query_type, 0);
+    nine_context_get_pipe_release(device);
+    return res;
 }
 
 CSMT_ITEM_DO_WAIT(nine_context_destroy_query,
@@ -3150,7 +3152,7 @@ update_vertex_elements_sw(struct NineDevice9 *device)
 static void
 update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_vertices)
 {
-    struct pipe_context *pipe = NineDevice9_GetPipe(device);
+    struct pipe_context *pipe = nine_context_get_pipe_acquire(device);
     struct pipe_context *pipe_sw = device->pipe_sw;
     struct nine_state *state = &device->state;
     struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
@@ -3198,6 +3200,7 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_
                 pipe_sw->set_vertex_buffers(pipe_sw, i, 1, NULL);
         }
     }
+    nine_context_get_pipe_release(device);
 }
 
 static void
@@ -3375,7 +3378,7 @@ void
 nine_state_after_draw_sw(struct NineDevice9 *device)
 {
     struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
-    struct pipe_context *pipe = NineDevice9_GetPipe(device);
+    struct pipe_context *pipe = nine_context_get_pipe_acquire(device);
     struct pipe_context *pipe_sw = device->pipe_sw;
     int i;
 
@@ -3385,6 +3388,7 @@ nine_state_after_draw_sw(struct NineDevice9 *device)
             pipe->transfer_unmap(pipe, sw_internal->transfers_so[i]);
         sw_internal->transfers_so[i] = NULL;
     }
+    nine_context_get_pipe_release(device);
 }
 
 void
diff --git a/src/gallium/state_trackers/nine/pixelshader9.c b/src/gallium/state_trackers/nine/pixelshader9.c
index cb970ea..bfc395c 100644
--- a/src/gallium/state_trackers/nine/pixelshader9.c
+++ b/src/gallium/state_trackers/nine/pixelshader9.c
@@ -51,7 +51,6 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
         return D3D_OK;
     }
     device = This->base.device;
-    pipe = NineDevice9_GetPipe(device);
 
     info.type = PIPE_SHADER_FRAGMENT;
     info.byte_code = pFunction;
@@ -63,7 +62,9 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
     info.projected = 0;
     info.process_vertices = false;
 
+    pipe = nine_context_get_pipe_acquire(device);
     hr = nine_translate_shader(device, &info, pipe);
+    nine_context_get_pipe_release(device);
     if (FAILED(hr))
         return hr;
     This->byte_code.version = info.version;
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index f348f50..ca9fd55 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -194,8 +194,9 @@ NineSurface9_ctor( struct NineSurface9 *This,
     /* TODO: investigate what else exactly needs to be cleared */
     if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) {
         surf = NineSurface9_GetSurface(This, 0);
-        pipe = NineDevice9_GetPipe(pParams->device);
+        pipe = nine_context_get_pipe_acquire(pParams->device);
         pipe->clear_render_target(pipe, surf, &rgba, 0, 0, pDesc->Width, pDesc->Height, false);
+        nine_context_get_pipe_release(pParams->device);
     }
 
     NineSurface9_Dump(This);
@@ -225,7 +226,7 @@ NineSurface9_dtor( struct NineSurface9 *This )
 struct pipe_surface *
 NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB )
 {
-    struct pipe_context *pipe = NineDevice9_GetPipe(This->base.base.device);
+    struct pipe_context *pipe;
     struct pipe_screen *screen = NineDevice9_GetScreen(This->base.base.device);
     struct pipe_resource *resource = This->base.resource;
     struct pipe_surface templ;
@@ -245,7 +246,9 @@ NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB )
     templ.u.tex.first_layer = This->layer;
     templ.u.tex.last_layer = This->layer;
 
+    pipe = nine_context_get_pipe_acquire(This->base.base.device);
     This->surface[sRGB] = pipe->create_surface(pipe, resource, &templ);
+    nine_context_get_pipe_release(This->base.base.device);
     assert(This->surface[sRGB]);
     return This->surface[sRGB];
 }
@@ -509,8 +512,9 @@ NineSurface9_UnlockRect( struct NineSurface9 *This )
     DBG("This=%p lock_count=%u\n", This, This->lock_count);
     user_assert(This->lock_count, D3DERR_INVALIDCALL);
     if (This->transfer) {
-        pipe = NineDevice9_GetPipe(This->base.base.device);
+        pipe = nine_context_get_pipe_acquire(This->base.base.device);
         pipe->transfer_unmap(pipe, This->transfer);
+        nine_context_get_pipe_release(This->base.base.device);
         This->transfer = NULL;
     }
     --This->lock_count;
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index d1d23c2..75e0345 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -90,7 +90,7 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
                        int for_frontbuffer_reading)
 {
     D3DWindowBuffer *ret;
-    struct pipe_context *pipe = NineDevice9_GetPipe(This->base.device);
+    struct pipe_context *pipe = nine_context_get_pipe_acquire(This->base.device);
     struct winsys_handle whandle;
     int stride, dmaBufFd;
     HRESULT hr;
@@ -103,6 +103,7 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This,
                                           PIPE_HANDLE_USAGE_WRITE :
                                           PIPE_HANDLE_USAGE_EXPLICIT_FLUSH |
                                           PIPE_HANDLE_USAGE_READ);
+    nine_context_get_pipe_release(This->base.device);
     stride = whandle.stride;
     dmaBufFd = whandle.handle;
     hr = ID3DPresent_NewD3DWindowBufferFromDmaBuf(This->present,
diff --git a/src/gallium/state_trackers/nine/vertexshader9.c b/src/gallium/state_trackers/nine/vertexshader9.c
index 79a49d1..a4228af 100644
--- a/src/gallium/state_trackers/nine/vertexshader9.c
+++ b/src/gallium/state_trackers/nine/vertexshader9.c
@@ -56,7 +56,6 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
     }
 
     device = This->base.device;
-    pipe = NineDevice9_GetPipe(device);
 
     info.type = PIPE_SHADER_VERTEX;
     info.byte_code = pFunction;
@@ -70,6 +69,7 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
     info.swvp_on = !!(device->params.BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING);
     info.process_vertices = false;
 
+    pipe = nine_context_get_pipe_acquire(device);
     hr = nine_translate_shader(device, &info, pipe);
     if (hr == D3DERR_INVALIDCALL &&
         (device->params.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING)) {
@@ -77,6 +77,7 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
         info.swvp_on = true;
         hr = nine_translate_shader(device, &info, pipe);
     }
+    nine_context_get_pipe_release(device);
     if (hr == D3DERR_INVALIDCALL)
         ERR("Encountered buggy shader\n");
     if (FAILED(hr))
diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c
index ac93551..b579f92 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -344,9 +344,10 @@ NineVolume9_UnlockBox( struct NineVolume9 *This )
     DBG("This=%p lock_count=%u\n", This, This->lock_count);
     user_assert(This->lock_count, D3DERR_INVALIDCALL);
     if (This->transfer) {
-        pipe = NineDevice9_GetPipe(This->base.device);
+        pipe = nine_context_get_pipe_acquire(This->base.device);
         pipe->transfer_unmap(pipe, This->transfer);
         This->transfer = NULL;
+        nine_context_get_pipe_release(This->base.device);
     }
     --This->lock_count;
 
-- 
2.10.2



More information about the mesa-dev mailing list