i965/vec4: Make with_writemask() non-static.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vs.c
index ee77b0197400f622d7a8aa81aba4eaa8a6353d84..7c7493f96325e3eb15267af1d4510d5d560c1df4 100644 (file)
@@ -64,6 +64,11 @@ brw_compute_vue_map(struct brw_context *brw, struct brw_vue_map *vue_map,
    vue_map->slots_valid = slots_valid;
    int i;
 
+   /* gl_Layer doesn't get its own varying slot--it's stored in the virst VUE
+    * slot (VARYING_SLOT_PSIZ).
+    */
+   slots_valid &= ~VARYING_BIT_LAYER;
+
    /* Make sure that the values we store in vue_map->varying_to_slot and
     * vue_map->slot_to_varying won't overflow the signed chars that are used
     * to store them.  Note that since vue_map->slot_to_varying sometimes holds
@@ -173,24 +178,6 @@ gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx)
 }
 
 
-bool
-brw_vec4_prog_data_compare(const struct brw_vec4_prog_data *a,
-                           const struct brw_vec4_prog_data *b)
-{
-   /* Compare all the struct up to the pointers. */
-   if (memcmp(a, b, offsetof(struct brw_vec4_prog_data, param)))
-      return false;
-
-   if (memcmp(a->param, b->param, a->nr_params * sizeof(void *)))
-      return false;
-
-   if (memcmp(a->pull_param, b->pull_param, a->nr_pull_params * sizeof(void *)))
-      return false;
-
-   return true;
-}
-
-
 bool
 brw_vs_prog_data_compare(const void *in_a, const void *in_b,
                          int aux_size, const void *in_key)
@@ -252,8 +239,10 @@ do_vs_prog(struct brw_context *brw,
    } else {
       param_count = vp->program.Base.Parameters->NumParameters * 4;
    }
-   /* We also upload clip plane data as uniforms */
-   param_count += MAX_CLIP_PLANES * 4;
+   /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip
+    * planes as uniforms.
+    */
+   param_count += c.key.base.nr_userclip_plane_consts * 4;
 
    prog_data.base.param = rzalloc_array(NULL, const float *, param_count);
    prog_data.base.pull_param = rzalloc_array(NULL, const float *, param_count);
@@ -315,7 +304,7 @@ do_vs_prog(struct brw_context *brw,
       prog_data.base.total_scratch
          = brw_get_scratch_size(c.base.last_scratch*REG_SIZE);
 
-      brw_get_scratch_bo(brw, &brw->vs.scratch_bo,
+      brw_get_scratch_bo(brw, &brw->vs.base.scratch_bo,
                         prog_data.base.total_scratch * brw->max_vs_threads);
    }
 
@@ -323,7 +312,7 @@ do_vs_prog(struct brw_context *brw,
                    &c.key, sizeof(c.key),
                    program, program_size,
                    &prog_data, sizeof(prog_data),
-                   &brw->vs.prog_offset, &brw->vs.prog_data);
+                   &brw->vs.base.prog_offset, &brw->vs.prog_data);
    ralloc_free(mem_ctx);
 
    return true;
@@ -399,6 +388,23 @@ brw_vs_debug_recompile(struct brw_context *brw,
    }
 }
 
+
+void
+brw_setup_vec4_key_clip_info(struct brw_context *brw,
+                             struct brw_vec4_prog_key *key,
+                             bool program_uses_clip_distance)
+{
+   struct gl_context *ctx = &brw->ctx;
+
+   key->userclip_active = (ctx->Transform.ClipPlanesEnabled != 0);
+   key->uses_clip_distance = program_uses_clip_distance;
+   if (key->userclip_active && !key->uses_clip_distance) {
+      key->nr_userclip_plane_consts
+         = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
+   }
+}
+
+
 static void brw_upload_vs_prog(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
@@ -415,12 +421,7 @@ static void brw_upload_vs_prog(struct brw_context *brw)
     * the inputs it asks for, whether they are varying or not.
     */
    key.base.program_string_id = vp->id;
-   key.base.userclip_active = (ctx->Transform.ClipPlanesEnabled != 0);
-   key.base.uses_clip_distance = vp->program.UsesClipDistance;
-   if (key.base.userclip_active && !key.base.uses_clip_distance) {
-      key.base.nr_userclip_plane_consts
-         = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
-   }
+   brw_setup_vec4_key_clip_info(brw, &key.base, vp->program.UsesClipDistance);
 
    /* _NEW_POLYGON */
    if (brw->gen < 6) {
@@ -440,7 +441,7 @@ static void brw_upload_vs_prog(struct brw_context *brw)
    }
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.sampler_count,
+   brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count,
                                       &key.base.tex);
 
    /* BRW_NEW_VERTICES */
@@ -482,16 +483,23 @@ static void brw_upload_vs_prog(struct brw_context *brw)
 
    if (!brw_search_cache(&brw->cache, BRW_VS_PROG,
                         &key, sizeof(key),
-                        &brw->vs.prog_offset, &brw->vs.prog_data)) {
+                        &brw->vs.base.prog_offset, &brw->vs.prog_data)) {
       bool success = do_vs_prog(brw, ctx->Shader.CurrentVertexProgram,
                                vp, &key);
-
+      (void) success;
       assert(success);
    }
    if (memcmp(&brw->vs.prog_data->base.vue_map, &brw->vue_map_geom_out,
               sizeof(brw->vue_map_geom_out)) != 0) {
-      brw->vue_map_geom_out = brw->vs.prog_data->base.vue_map;
-      brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT;
+      brw->vue_map_vs = brw->vs.prog_data->base.vue_map;
+      brw->state.dirty.brw |= BRW_NEW_VUE_MAP_VS;
+      if (brw->gen < 7) {
+         /* No geometry shader support, so the VS VUE map is the VUE map for
+          * the output of the "geometry" portion of the pipeline.
+          */
+         brw->vue_map_geom_out = brw->vue_map_vs;
+         brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT;
+      }
    }
 }
 
@@ -514,7 +522,7 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_vs_prog_key key;
-   uint32_t old_prog_offset = brw->vs.prog_offset;
+   uint32_t old_prog_offset = brw->vs.base.prog_offset;
    struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
    bool success;
 
@@ -544,21 +552,13 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
 
    success = do_vs_prog(brw, prog, bvp, &key);
 
-   brw->vs.prog_offset = old_prog_offset;
+   brw->vs.base.prog_offset = old_prog_offset;
    brw->vs.prog_data = old_prog_data;
 
    return success;
 }
 
 
-void
-brw_vec4_prog_data_free(const struct brw_vec4_prog_data *prog_data)
-{
-   ralloc_free((void *)prog_data->param);
-   ralloc_free((void *)prog_data->pull_param);
-}
-
-
 void
 brw_vs_prog_data_free(const void *in_prog_data)
 {