[Mesa-dev] [PATCH] gallium: deconstify sw_winsys::displaytarget_create()'s front_private

Emil Velikov emil.l.velikov at gmail.com
Fri Apr 21 12:11:30 UTC 2017


The variable is propagated as constant, yet we explicitly cast away the
constness as we get to use it.

Make it clearer and drop the const notation all together.

Cc: Dave Airlie <airlied at redhat.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/drivers/llvmpipe/lp_texture.c         |  4 ++--
 src/gallium/drivers/softpipe/sp_texture.c         |  4 ++--
 src/gallium/include/state_tracker/sw_winsys.h     |  2 +-
 src/gallium/state_trackers/dri/drisw.c            |  2 +-
 src/gallium/winsys/sw/dri/dri_sw_winsys.c         | 13 +++++++++----
 src/gallium/winsys/sw/gdi/gdi_sw_winsys.c         |  2 +-
 src/gallium/winsys/sw/hgl/hgl_sw_winsys.c         |  2 +-
 src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c |  2 +-
 src/gallium/winsys/sw/null/null_sw_winsys.c       |  2 +-
 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
 src/gallium/winsys/sw/xlib/xlib_sw_winsys.c       |  2 +-
 11 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 733253b0b08..0492afa8bf2 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -201,7 +201,7 @@ llvmpipe_can_create_resource(struct pipe_screen *screen,
 static boolean
 llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
                               struct llvmpipe_resource *lpr,
-                              const void *map_front_private)
+                              void *map_front_private)
 {
    struct sw_winsys *winsys = screen->winsys;
 
@@ -239,7 +239,7 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
 static struct pipe_resource *
 llvmpipe_resource_create_front(struct pipe_screen *_screen,
                                const struct pipe_resource *templat,
-                               const void *map_front_private)
+                               void *map_front_private)
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
    struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index ea5e2c64b84..f554733b565 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -129,7 +129,7 @@ softpipe_can_create_resource(struct pipe_screen *screen,
 static boolean
 softpipe_displaytarget_layout(struct pipe_screen *screen,
                               struct softpipe_resource *spr,
-                              const void *map_front_private)
+                              void *map_front_private)
 {
    struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
 
@@ -154,7 +154,7 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
 static struct pipe_resource *
 softpipe_resource_create_front(struct pipe_screen *screen,
                                const struct pipe_resource *templat,
-                               const void *map_front_private)
+                               void *map_front_private)
 {
    struct softpipe_resource *spr = CALLOC_STRUCT(softpipe_resource);
    if (!spr)
diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h
index 0b792cd0ce4..41b8f7d66c0 100644
--- a/src/gallium/include/state_tracker/sw_winsys.h
+++ b/src/gallium/include/state_tracker/sw_winsys.h
@@ -90,7 +90,7 @@ struct sw_winsys
                             enum pipe_format format,
                             unsigned width, unsigned height,
                             unsigned alignment,
-                            const void *front_private,
+                            void *front_private,
                             unsigned *stride );
 
    /**
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index b85a73c57d2..b62e231877a 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -314,7 +314,7 @@ drisw_allocate_textures(struct dri_context *stctx,
           screen->base.screen->resource_create_front &&
           loader->base.version >= 3) {
          drawable->textures[statts[i]] =
-            screen->base.screen->resource_create_front(screen->base.screen, &templ, (const void *)drawable);
+            screen->base.screen->resource_create_front(screen->base.screen, &templ, drawable);
       } else
          drawable->textures[statts[i]] =
             screen->base.screen->resource_create(screen->base.screen, &templ);
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 00849985d6b..fccc80e06ad 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -47,7 +47,7 @@ struct dri_sw_displaytarget
    unsigned map_flags;
    void *data;
    void *mapped;
-   const void *front_private;
+   void *front_private;
 };
 
 struct dri_sw_winsys
@@ -85,7 +85,7 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
                             enum pipe_format format,
                             unsigned width, unsigned height,
                             unsigned alignment,
-                            const void *front_private,
+                            void *front_private,
                             unsigned *stride)
 {
    struct dri_sw_displaytarget *dri_sw_dt;
@@ -140,7 +140,10 @@ dri_sw_displaytarget_map(struct sw_winsys *ws,
 
    if (dri_sw_dt->front_private && (flags & PIPE_TRANSFER_READ)) {
       struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws);
-      dri_sw_ws->lf->get_image((void *)dri_sw_dt->front_private, 0, 0, dri_sw_dt->width, dri_sw_dt->height, dri_sw_dt->stride, dri_sw_dt->data);
+
+      dri_sw_ws->lf->get_image(dri_sw_dt->front_private,
+                               0, 0, dri_sw_dt->width, dri_sw_dt->height,
+                               dri_sw_dt->stride, dri_sw_dt->data);
    }
    dri_sw_dt->map_flags = flags;
    return dri_sw_dt->mapped;
@@ -153,7 +156,9 @@ dri_sw_displaytarget_unmap(struct sw_winsys *ws,
    struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
    if (dri_sw_dt->front_private && (dri_sw_dt->map_flags & PIPE_TRANSFER_WRITE)) {
       struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws);
-      dri_sw_ws->lf->put_image2((void *)dri_sw_dt->front_private, dri_sw_dt->data, 0, 0, dri_sw_dt->width, dri_sw_dt->height, dri_sw_dt->stride);
+
+      dri_sw_ws->lf->put_image2(dri_sw_dt->front_private, dri_sw_dt->data,
+                                0, 0, dri_sw_dt->width, dri_sw_dt->height, dri_sw_dt->stride);
    }
    dri_sw_dt->map_flags = 0;
    dri_sw_dt->mapped = NULL;
diff --git a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
index 16f641833c6..36634d601eb 100644
--- a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
+++ b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
@@ -124,7 +124,7 @@ gdi_sw_displaytarget_create(struct sw_winsys *winsys,
                                   enum pipe_format format,
                                   unsigned width, unsigned height,
                                   unsigned alignment,
-                                  const void *front_private,
+                                  void *front_private,
                                   unsigned *stride)
 {
    struct gdi_sw_displaytarget *gdt;
diff --git a/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c b/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
index f7bc907ea5c..fc0b8151236 100644
--- a/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
+++ b/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
@@ -106,7 +106,7 @@ hgl_winsys_convert_cs(enum pipe_format format)
 static struct sw_displaytarget*
 hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
 	unsigned textureUsage, enum pipe_format format, unsigned width,
-	unsigned height, unsigned alignment, const void *front_private,
+	unsigned height, unsigned alignment, void *front_private,
 	unsigned* stride)
 {
 	struct haiku_displaytarget* haikuDisplayTarget
diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
index 22e1c936ac5..b6d09c37aae 100644
--- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
@@ -111,7 +111,7 @@ kms_sw_displaytarget_create(struct sw_winsys *ws,
                             enum pipe_format format,
                             unsigned width, unsigned height,
                             unsigned alignment,
-                            const void *front_private,
+                            void *front_private,
                             unsigned *stride)
 {
    struct kms_sw_winsys *kms_sw = kms_sw_winsys(ws);
diff --git a/src/gallium/winsys/sw/null/null_sw_winsys.c b/src/gallium/winsys/sw/null/null_sw_winsys.c
index 10ce2508507..b68346e4098 100644
--- a/src/gallium/winsys/sw/null/null_sw_winsys.c
+++ b/src/gallium/winsys/sw/null/null_sw_winsys.c
@@ -84,7 +84,7 @@ null_sw_displaytarget_create(struct sw_winsys *winsys,
                              enum pipe_format format,
                              unsigned width, unsigned height,
                              unsigned alignment,
-                             const void *front_private,
+                             void *front_private,
                              unsigned *stride)
 {
    fprintf(stderr, "null_sw_displaytarget_create() returning NULL\n");
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index 47cf7f02870..ace0957eb4e 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -148,7 +148,7 @@ wsw_dt_create(struct sw_winsys *ws,
               enum pipe_format format,
               unsigned width, unsigned height,
               unsigned alignment,
-              const void *front_private,
+              void *front_private,
               unsigned *stride)
 {
    struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index 8753139107c..5bef90b9544 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -391,7 +391,7 @@ xlib_displaytarget_create(struct sw_winsys *winsys,
                           enum pipe_format format,
                           unsigned width, unsigned height,
                           unsigned alignment,
-                          const void *front_private,
+                          void *front_private,
                           unsigned *stride)
 {
    struct xlib_displaytarget *xlib_dt;
-- 
2.12.2



More information about the mesa-dev mailing list