- if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
- clip.thread4.max_threads = 0;
-
- if (INTEL_DEBUG & DEBUG_STATS)
- clip.thread4.stats_enable = 1;
-
- clip.clip5.userclip_enable_flags = 0x7f;
- clip.clip5.userclip_must_clip = 1;
- clip.clip5.guard_band_enable = 0;
- clip.clip5.viewport_z_clip_enable = 1;
- clip.clip5.viewport_xy_clip_enable = 1;
- clip.clip5.vertex_position_space = BRW_CLIP_NDCSPACE;
- clip.clip5.api_mode = BRW_CLIP_API_OGL;
- clip.clip5.clip_mode = key->clip_mode;
-
- if (BRW_IS_G4X(brw))
- clip.clip5.negative_w_clip_test = 1;
-
- clip.clip6.clipper_viewport_state_ptr = 0;
- clip.viewport_xmin = -1;
- clip.viewport_xmax = 1;
- clip.viewport_ymin = -1;
- clip.viewport_ymax = 1;
-
- bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
- key, sizeof(*key),
- &brw->clip.prog_bo, 1,
- &clip, sizeof(clip),
- NULL, NULL);
-
- /* Emit clip program relocation */
- assert(brw->clip.prog_bo);
- dri_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION,
- 0,
- clip.thread0.grf_reg_count << 1,
- offsetof(struct brw_clip_unit_state, thread0),
- brw->clip.prog_bo);
-
- return bo;
-}
-
-static void upload_clip_unit( struct brw_context *brw )
-{
- struct brw_clip_unit_key key;
-
- clip_unit_populate_key(brw, &key);
-
- dri_bo_unreference(brw->clip.state_bo);
- brw->clip.state_bo = brw_search_cache(&brw->cache, BRW_CLIP_UNIT,
- &key, sizeof(key),
- &brw->clip.prog_bo, 1,
- NULL);
- if (brw->clip.state_bo == NULL) {
- brw->clip.state_bo = clip_unit_create_from_key(brw, &key);
- }
+ if (unlikely(INTEL_DEBUG & DEBUG_SINGLE_THREAD))
+ clip->thread4.max_threads = 0;
+
+ if (unlikely(INTEL_DEBUG & DEBUG_STATS))
+ clip->thread4.stats_enable = 1;
+
+ clip->clip5.userclip_enable_flags = 0x7f;
+ clip->clip5.userclip_must_clip = 1;
+ clip->clip5.guard_band_enable = 0;
+ /* _NEW_TRANSOFORM */
+ if (!ctx->Transform.DepthClamp)
+ clip->clip5.viewport_z_clip_enable = 1;
+ clip->clip5.viewport_xy_clip_enable = 1;
+ clip->clip5.vertex_position_space = BRW_CLIP_NDCSPACE;
+ clip->clip5.api_mode = BRW_CLIP_API_OGL;
+ clip->clip5.clip_mode = brw->clip.prog_data->clip_mode;
+
+ if (intel->is_g4x)
+ clip->clip5.negative_w_clip_test = 1;
+
+ clip->clip6.clipper_viewport_state_ptr = 0;
+ clip->viewport_xmin = -1;
+ clip->viewport_xmax = 1;
+ clip->viewport_ymin = -1;
+ clip->viewport_ymax = 1;
+
+ brw->state.dirty.cache |= CACHE_NEW_CLIP_UNIT;