Module: Mesa
Branch: master
Commit: 8b5b5fe3944d75c5d3667516139e366d2207c22a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b5b5fe3944d75c5d3667516139e366d2207c22a

Author: Chia-I Wu <olva...@gmail.com>
Date:   Tue Aug 13 15:23:41 2013 +0800

Revert "ilo: initialize constant buffer SURFACE_STATE early"

This reverts commit a9b800aa81cffdcaef2490ff49986099feae2663.  With push
constant support, the constructed SURFACE_STATE is unused and wasted.  The
change only slows things down.

---

 src/gallium/drivers/ilo/ilo_gpe.h      |   15 -------------
 src/gallium/drivers/ilo/ilo_gpe_gen6.c |    4 +-
 src/gallium/drivers/ilo/ilo_gpe_gen6.h |    3 ++
 src/gallium/drivers/ilo/ilo_state.c    |   37 +++++++++++++++++++-------------
 4 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/gallium/drivers/ilo/ilo_gpe.h 
b/src/gallium/drivers/ilo/ilo_gpe.h
index 17b131b..f0768b9 100644
--- a/src/gallium/drivers/ilo/ilo_gpe.h
+++ b/src/gallium/drivers/ilo/ilo_gpe.h
@@ -53,9 +53,6 @@
 #define ILO_WM_CONST_SURFACE(i)    (ILO_MAX_DRAW_BUFFERS + i)
 #define ILO_WM_TEXTURE_SURFACE(i)  (ILO_MAX_DRAW_BUFFERS + 
ILO_MAX_CONST_BUFFERS  + i)
 
-#define ILO_GPE_VALID_GEN(dev, min_gen, max_gen) \
-   assert((dev)->gen >= ILO_GEN(min_gen) && (dev)->gen <= ILO_GEN(max_gen))
-
 struct ilo_buffer;
 struct ilo_texture;
 struct ilo_shader_state;
@@ -470,18 +467,6 @@ ilo_gpe_init_view_surface_for_texture(const struct 
ilo_dev_info *dev,
    }
 }
 
-static inline void
-ilo_gpe_set_view_surface_bo(const struct ilo_dev_info *dev,
-                            struct intel_bo *bo, unsigned offset,
-                            struct ilo_view_surface *surf)
-{
-   ILO_GPE_VALID_GEN(dev, 6, 7);
-
-   /* do not increment reference count */
-   surf->bo = bo;
-   surf->payload[1] = offset;
-}
-
 void
 ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev,
                         const struct ilo_texture *tex,
diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.c 
b/src/gallium/drivers/ilo/ilo_gpe_gen6.c
index da63f0c..cd12273 100644
--- a/src/gallium/drivers/ilo/ilo_gpe_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.c
@@ -1873,7 +1873,7 @@ ilo_gpe_init_view_surface_for_buffer_gen6(const struct 
ilo_dev_info *dev,
    if (render_cache_rw)
       dw[0] |= BRW_SURFACE_RC_READ_WRITE;
 
-   dw[1] = (buf) ? offset : 0;
+   dw[1] = offset;
 
    dw[2] = height << BRW_SURFACE_HEIGHT_SHIFT |
            width << BRW_SURFACE_WIDTH_SHIFT;
@@ -1885,7 +1885,7 @@ ilo_gpe_init_view_surface_for_buffer_gen6(const struct 
ilo_dev_info *dev,
    dw[5] = 0;
 
    /* do not increment reference count */
-   surf->bo = (buf) ? buf->bo : NULL;
+   surf->bo = buf->bo;
 }
 
 void
diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.h 
b/src/gallium/drivers/ilo/ilo_gpe_gen6.h
index 26aa721..a3dea39 100644
--- a/src/gallium/drivers/ilo/ilo_gpe_gen6.h
+++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.h
@@ -39,6 +39,9 @@
 #include "ilo_shader.h"
 #include "ilo_gpe.h"
 
+#define ILO_GPE_VALID_GEN(dev, min_gen, max_gen) \
+   assert((dev)->gen >= ILO_GEN(min_gen) && (dev)->gen <= ILO_GEN(max_gen))
+
 #define ILO_GPE_CMD(pipeline, op, subop) \
    (0x3 << 29 | (pipeline) << 27 | (op) << 24 | (subop) << 16)
 
diff --git a/src/gallium/drivers/ilo/ilo_state.c 
b/src/gallium/drivers/ilo/ilo_state.c
index b4af306..ce6930c 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -105,13 +105,18 @@ finalize_constant_buffers(struct ilo_context *ilo)
 
          /* upload user buffer */
          if (cbuf->user_buffer) {
+            const enum pipe_format elem_format =
+               PIPE_FORMAT_R32G32B32A32_FLOAT;
             unsigned offset;
 
             u_upload_data(ilo->uploader, 0, cbuf->user_buffer_size,
                   cbuf->user_buffer, &offset, &cbuf->resource);
 
-            ilo_gpe_set_view_surface_bo(ilo->dev,
-                  ilo_buffer(cbuf->resource)->bo, offset, &cbuf->surface);
+            ilo_gpe_init_view_surface_for_buffer(ilo->dev,
+                  ilo_buffer(cbuf->resource),
+                  offset, cbuf->user_buffer_size,
+                  util_format_get_blocksize(elem_format), elem_format,
+                  false, false, &cbuf->surface);
 
             cbuf->user_buffer = NULL;
             cbuf->user_buffer_size = 0;
@@ -628,18 +633,26 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
 
    if (buf) {
       for (i = 0; i < count; i++) {
-         const enum pipe_format elem_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
          struct ilo_cbuf_cso *cso = &cbuf->cso[index + i];
 
          pipe_resource_reference(&cso->resource, buf[i].buffer);
 
-         ilo_gpe_init_view_surface_for_buffer(ilo->dev,
-               ilo_buffer(buf[i].buffer),
-               buf[i].buffer_offset, buf[i].buffer_size,
-               util_format_get_blocksize(elem_format), elem_format,
-               false, false, &cso->surface);
+         if (buf[i].buffer) {
+            const enum pipe_format elem_format =
+               PIPE_FORMAT_R32G32B32A32_FLOAT;
 
-         if (buf[i].user_buffer) {
+            ilo_gpe_init_view_surface_for_buffer(ilo->dev,
+                  ilo_buffer(buf[i].buffer),
+                  buf[i].buffer_offset, buf[i].buffer_size,
+                  util_format_get_blocksize(elem_format), elem_format,
+                  false, false, &cso->surface);
+
+            cso->user_buffer = NULL;
+            cso->user_buffer_size = 0;
+
+            cbuf->enabled_mask |= 1 << (index + i);
+         }
+         else if (buf[i].user_buffer) {
             cso->surface.bo = NULL;
 
             /* buffer_offset does not apply for user buffer */
@@ -648,12 +661,6 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
 
             cbuf->enabled_mask |= 1 << (index + i);
          }
-         else if (buf[i].buffer) {
-            cso->user_buffer = NULL;
-            cso->user_buffer_size = 0;
-
-            cbuf->enabled_mask |= 1 << (index + i);
-         }
          else {
             cso->surface.bo = NULL;
             cso->user_buffer = NULL;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to