i965: Fix a "discards 'const' qualifier" warning.
[mesa.git] / src / mesa / drivers / dri / i965 / gen7_sampler_state.c
index 94091d8cecf4958b17eaa9390652532e8288b88c..74d5e9e0a7e3856f41f8735021a0b45ad10fa39c 100644 (file)
@@ -182,12 +182,16 @@ gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
 static void
 gen7_upload_sampler_state_table(struct brw_context *brw,
                                 struct gl_program *prog,
-                                uint32_t sampler_count,
-                                uint32_t *sst_offset,
-                                uint32_t *sdc_offset)
+                                struct brw_stage_state *stage_state)
 {
    struct gl_context *ctx = &brw->ctx;
    struct gen7_sampler_state *samplers;
+   uint32_t sampler_count = stage_state->sampler_count;
+   static const uint16_t packet_headers[] = {
+      [MESA_SHADER_VERTEX] = _3DSTATE_SAMPLER_STATE_POINTERS_VS,
+      [MESA_SHADER_GEOMETRY] = _3DSTATE_SAMPLER_STATE_POINTERS_GS,
+      [MESA_SHADER_FRAGMENT] = _3DSTATE_SAMPLER_STATE_POINTERS_PS,
+   };
 
    GLbitfield SamplersUsed = prog->SamplersUsed;
 
@@ -196,7 +200,7 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
 
    samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
                              sampler_count * sizeof(*samplers),
-                             32, sst_offset);
+                             32, &stage_state->sampler_offset);
    memset(samplers, 0, sampler_count * sizeof(*samplers));
 
    for (unsigned s = 0; s < sampler_count; s++) {
@@ -204,11 +208,19 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
          const unsigned unit = prog->SamplerUnits[s];
          if (ctx->Texture.Unit[unit]._Current)
             gen7_update_sampler_state(brw, unit, s, &samplers[s],
-                                      &sdc_offset[s]);
+                                      &stage_state->sdc_offset[s]);
       }
    }
 
-   brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
+  if (brw->gen == 7 && !brw->is_haswell &&
+      stage_state->stage == MESA_SHADER_VERTEX) {
+      gen7_emit_vs_workaround_flush(brw);
+  }
+
+   BEGIN_BATCH(2);
+   OUT_BATCH(packet_headers[stage_state->stage] << 16 | (2 - 2));
+   OUT_BATCH(stage_state->sampler_offset);
+   ADVANCE_BATCH();
 }
 
 void