st/nine: Use nine_context_clear_render_target
authorAxel Davy <axel.davy@ens.fr>
Sun, 13 Nov 2016 11:47:58 +0000 (12:47 +0100)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:47:08 +0000 (23:47 +0100)
Enables to not wait for the worker thread for ColorFill.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/surface9.c

index 66bfc8d0181cd178f20baf821fe2552f3bd293ea..45fe5b5fcd8ab11edf242a09a997339f55187c9d 100644 (file)
@@ -1752,11 +1752,8 @@ NineDevice9_ColorFill( struct NineDevice9 *This,
                        const RECT *pRect,
                        D3DCOLOR color )
 {
-    struct pipe_context *pipe = NineDevice9_GetPipe(This);
     struct NineSurface9 *surf = NineSurface9(pSurface);
-    struct pipe_surface *psurf;
     unsigned x, y, w, h;
-    union pipe_color_union rgba;
 
     DBG("This=%p pSurface=%p pRect=%p color=%08x\n", This,
         pSurface, pRect, color);
@@ -1790,11 +1787,9 @@ NineDevice9_ColorFill( struct NineDevice9 *This,
         w = surf->desc.Width;
         h = surf->desc.Height;
     }
-    d3dcolor_to_pipe_color_union(&rgba, color);
 
     if (surf->base.info.bind & PIPE_BIND_RENDER_TARGET) {
-        psurf = NineSurface9_GetSurface(surf, 0);
-        pipe->clear_render_target(pipe, psurf, &rgba, x, y, w, h, false);
+        nine_context_clear_render_target(This, surf, color, x, y, w, h);
     } else {
         D3DLOCKED_RECT lock;
         union util_color uc;
index 5b6ca12fd7ea5c231d275ffd105c55055fd9fb01..56a31520110ceb866c56c1d81d0f275a8d138db1 100644 (file)
@@ -2675,6 +2675,23 @@ CSMT_ITEM_NO_WAIT(nine_context_blit,
     context->pipe->blit(context->pipe, blit);
 }
 
+CSMT_ITEM_NO_WAIT(nine_context_clear_render_target,
+                  ARG_BIND_REF(struct NineSurface9, surface),
+                  ARG_VAL(D3DCOLOR, color),
+                  ARG_VAL(UINT, x),
+                  ARG_VAL(UINT, y),
+                  ARG_VAL(UINT, width),
+                  ARG_VAL(UINT, height))
+{
+    struct nine_context *context = &device->context;
+    struct pipe_surface *surf;
+    union pipe_color_union rgba;
+
+    d3dcolor_to_pipe_color_union(&rgba, color);
+    surf = NineSurface9_GetSurface(surface, 0);
+    context->pipe->clear_render_target(context->pipe, surf, &rgba, x, y, width, height, false);
+}
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
 {
index 912395de81f6c73003e70e53b96dadb76ab3e4c7..421f8f974040e374635ed5710f6bbeda9b60b42e 100644 (file)
@@ -530,6 +530,15 @@ void
 nine_context_blit(struct NineDevice9 *device,
                   struct pipe_blit_info *blit);
 
+void
+nine_context_clear_render_target(struct NineDevice9 *device,
+                                 struct NineSurface9 *surface,
+                                 D3DCOLOR color,
+                                 UINT x,
+                                 UINT y,
+                                 UINT width,
+                                 UINT height);
+
 struct pipe_query *
 nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
 
index ca9fd55828e761f9bd8d2166526f5301cf9cbca6..6373f6908d5f2fa1ac75dfe0ad8b7cb59274fb83 100644 (file)
@@ -55,9 +55,6 @@ NineSurface9_ctor( struct NineSurface9 *This,
                    D3DSURFACE_DESC *pDesc )
 {
     HRESULT hr;
-    union pipe_color_union rgba = {0};
-    struct pipe_surface *surf;
-    struct pipe_context *pipe;
     bool allocate = !pContainer && pDesc->Format != D3DFMT_NULL;
     D3DMULTISAMPLE_TYPE multisample_type;
 
@@ -192,12 +189,8 @@ 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 = 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);
-    }
+    if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET))
+        nine_context_clear_render_target(pParams->device, This, 0, 0, 0, pDesc->Width, pDesc->Height);
 
     NineSurface9_Dump(This);