Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vs_surface_state.c
index c697756bee3b3eed0df98855e10c5114019c3b97..f9ee4d112a5b991c538c33ab364f8965731ceb11 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "main/mtypes.h"
 #include "main/texstore.h"
-#include "shader/prog_parameter.h"
+#include "program/prog_parameter.h"
 
 #include "brw_context.h"
 #include "brw_state.h"
@@ -45,7 +45,7 @@
 static void
 prepare_vs_constants(struct brw_context *brw)
 {
-   GLcontext *ctx = &brw->intel.ctx;
+   struct gl_context *ctx = &brw->intel.ctx;
    struct intel_context *intel = &brw->intel;
    struct brw_vertex_program *vp =
       (struct brw_vertex_program *) brw->vertex_program;
@@ -82,6 +82,15 @@ prepare_vs_constants(struct brw_context *brw)
             params->ParameterValues[i],
             4 * sizeof(float));
    }
+
+   if (0) {
+      for (i = 0; i < params->NumParameters; i++) {
+        float *row = (float *)brw->vs.const_bo->virtual + i * 4;
+        printf("vs const surface %3d: %4.3f %4.3f %4.3f %4.3f\n",
+               i, row[0], row[1], row[2], row[3]);
+      }
+   }
+
    drm_intel_gem_bo_unmap_gtt(brw->vs.const_bo);
    brw->state.dirty.brw |= BRW_NEW_VS_CONSTBUF;
 }
@@ -101,11 +110,11 @@ const struct brw_tracked_state brw_vs_constants = {
  * Sets brw->vs.surf_bo[surf] and brw->vp->const_buffer.
  */
 static void
-brw_update_vs_constant_surface( GLcontext *ctx,
+brw_update_vs_constant_surface( struct gl_context *ctx,
                                 GLuint surf)
 {
    struct brw_context *brw = brw_context(ctx);
-   struct brw_surface_key key;
+   struct intel_context *intel = &brw->intel;
    struct brw_vertex_program *vp =
       (struct brw_vertex_program *) brw->vertex_program;
    const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
@@ -116,31 +125,17 @@ brw_update_vs_constant_surface( GLcontext *ctx,
     * it.
     */
    if (brw->vs.const_bo == NULL) {
-      drm_intel_bo_unreference(brw->vs.surf_bo[surf]);
-      brw->vs.surf_bo[surf] = NULL;
+      brw->vs.surf_offset[surf] = 0;
       return;
    }
 
-   memset(&key, 0, sizeof(key));
-
-   key.format = MESA_FORMAT_RGBA_FLOAT32;
-   key.internal_format = GL_RGBA;
-   key.bo = brw->vs.const_bo;
-   key.depthmode = GL_NONE;
-   key.pitch = params->NumParameters;
-   key.width = params->NumParameters;
-   key.height = 1;
-   key.depth = 1;
-   key.cpp = 16;
-
-   /*
-   printf("%s:\n", __FUNCTION__);
-   printf("  width %d  height %d  depth %d  cpp %d  pitch %d\n",
-          key.width, key.height, key.depth, key.cpp, key.pitch);
-   */
-
-   brw_create_constant_surface(brw, &key, &brw->vs.surf_bo[surf],
-                              &brw->vs.surf_offset[surf]);
+   if (intel->gen >= 7) {
+      gen7_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
+                                 &brw->vs.surf_offset[surf]);
+   } else {
+      brw_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
+                                 &brw->vs.surf_offset[surf]);
+   }
 }
 
 
@@ -169,17 +164,16 @@ prepare_vs_surfaces(struct brw_context *brw)
  */
 static void upload_vs_surfaces(struct brw_context *brw)
 {
-   GLcontext *ctx = &brw->intel.ctx;
+   struct gl_context *ctx = &brw->intel.ctx;
    uint32_t *bind;
    int i;
 
    /* BRW_NEW_NR_VS_SURFACES */
    if (brw->vs.nr_surfaces == 0) {
-      if (brw->vs.bind_bo) {
-        drm_intel_bo_unreference(brw->vs.bind_bo);
-        brw->vs.bind_bo = NULL;
-        brw->state.dirty.brw |= BRW_NEW_BINDING_TABLE;
+      if (brw->vs.bind_bo_offset) {
+        brw->state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE;
       }
+      brw->vs.bind_bo_offset = 0;
       return;
    }
 
@@ -188,19 +182,16 @@ static void upload_vs_surfaces(struct brw_context *brw)
    /* Might want to calculate nr_surfaces first, to avoid taking up so much
     * space for the binding table. (once we have vs samplers)
     */
-   bind = brw_state_batch(brw, sizeof(uint32_t) * BRW_VS_MAX_SURF,
-                         32, &brw->vs.bind_bo, &brw->vs.bind_bo_offset);
+   bind = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
+                         sizeof(uint32_t) * BRW_VS_MAX_SURF,
+                         32, &brw->vs.bind_bo_offset);
 
    for (i = 0; i < BRW_VS_MAX_SURF; i++) {
       /* BRW_NEW_VS_CONSTBUF */
-      if (brw->vs.surf_bo[i]) {
-        bind[i] = brw->vs.surf_offset[i];
-      } else {
-        bind[i] = 0;
-      }
+      bind[i] = brw->vs.surf_offset[i];
    }
 
-   brw->state.dirty.brw |= BRW_NEW_BINDING_TABLE;
+   brw->state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE;
 }
 
 const struct brw_tracked_state brw_vs_surfaces = {