intel: Rely on intel_region_reference()'s support of *dst != NULL.
[mesa.git] / src / mesa / drivers / dri / i915 / i915_vtbl.c
index baff49bb2f5a846f5ae5759633e6551b661bdff4..cd7d108222ee6a9a09841191475cd4386eae9d3e 100644 (file)
 #include "main/macros.h"
 #include "main/colormac.h"
 
+#include "tnl/tnl.h"
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
+#include "swrast_setup/swrast_setup.h"
 
 #include "intel_batchbuffer.h"
 #include "intel_regions.h"
@@ -568,11 +570,9 @@ i915_set_draw_region(struct intel_context *intel,
    uint32_t draw_x, draw_y, draw_offset;
 
    if (state->draw_region != color_regions[0]) {
-      intel_region_release(&state->draw_region);
       intel_region_reference(&state->draw_region, color_regions[0]);
    }
    if (state->depth_region != depth_region) {
-      intel_region_release(&state->depth_region);
       intel_region_reference(&state->depth_region, depth_region);
    }
 
@@ -703,6 +703,16 @@ i915_is_hiz_depth_format(struct intel_context *intel,
    return false;
 }
 
+static void
+i915_invalidate_state(struct intel_context *intel, GLuint new_state)
+{
+   struct gl_context *ctx = &intel->ctx;
+
+   _swsetup_InvalidateState(ctx, new_state);
+   _tnl_InvalidateState(ctx, new_state);
+   _tnl_invalidate_vertex_state(ctx, new_state);
+}
+
 void
 i915InitVtbl(struct i915_context *i915)
 {
@@ -717,6 +727,7 @@ i915InitVtbl(struct i915_context *i915)
    i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
    i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
    i915->intel.vtbl.finish_batch = intel_finish_vb;
+   i915->intel.vtbl.invalidate_state = i915_invalidate_state;
    i915->intel.vtbl.render_target_supported = i915_render_target_supported;
    i915->intel.vtbl.is_hiz_depth_format = i915_is_hiz_depth_format;
 }