--- ./mesa-18.2.2/src/mesa/drivers/dri/i915/intel_batchbuffer.h 2018-10-05 12:15:58.000000000 +0200 +++ /home/gert/srcmesa/./mesa-18.2.2/src/mesa/drivers/dri/i915/intel_batchbuffer.h 2019-02-16 21:02:28.238130203 +0100 @@ -90,6 +90,12 @@ } static inline void +intel_batchbuffer_emit_reset(struct intel_context *intel) +{ + intel->batch.used = intel->batch.emit; +} + +static inline void intel_batchbuffer_require_space(struct intel_context *intel, GLuint sz) { --- ./mesa-18.2.2/src/mesa/drivers/dri/i915/intel_blit.c 2018-10-05 12:15:58.000000000 +0200 +++ /home/gert/srcmesa/./mesa-18.2.2/src/mesa/drivers/dri/i915/intel_blit.c 2019-02-18 23:34:14.557563539 +0100 @@ -93,7 +93,7 @@ GLuint CMD, BR13, pass = 0; int dst_y2 = dst_y + h; int dst_x2 = dst_x + w; - drm_intel_bo *aper_array[3]; + drm_intel_bo *aper_array[1]; bool dst_y_tiled = dst_tiling == I915_TILING_Y; bool src_y_tiled = src_tiling == I915_TILING_Y; BATCH_LOCALS; @@ -109,22 +109,6 @@ if (dst_y_tiled || src_y_tiled) return false; - /* do space check before going any further */ - do { - aper_array[0] = intel->batch.bo; - aper_array[1] = dst_buffer; - aper_array[2] = src_buffer; - - if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) { - intel_batchbuffer_flush(intel); - pass++; - } else - break; - } while (pass < 2); - - if (pass >= 2) - return false; - intel_batchbuffer_require_space(intel, 8 * 4); DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", __func__, @@ -177,8 +161,8 @@ assert(dst_x < dst_x2); assert(dst_y < dst_y2); +again: BEGIN_BATCH(8); - OUT_BATCH(CMD | (8 - 2)); OUT_BATCH(BR13 | (uint16_t)dst_pitch); OUT_BATCH((dst_y << 16) | dst_x); @@ -186,6 +170,19 @@ OUT_RELOC_FENCED(dst_buffer, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, dst_offset); + /* do space check before going any further */ + aper_array[0] = intel->batch.bo; + if (dri_bufmgr_check_aperture_space(aper_array, 1) != 0) { + int reloc_count = drm_intel_gem_bo_get_reloc_count(intel->batch.bo); + drm_intel_gem_bo_clear_relocs(intel->batch.bo, reloc_count - 1); + intel_batchbuffer_emit_reset(intel); + intel_batchbuffer_flush(intel); + pass++; + if (pass >= 2) + return false; + goto again; + } + OUT_BATCH((src_y << 16) | src_x); OUT_BATCH((uint16_t)src_pitch); OUT_RELOC_FENCED(src_buffer, @@ -378,7 +375,7 @@ uint32_t BR13, CMD; struct intel_region *region; int pitch, cpp; - drm_intel_bo *aper_array[2]; + drm_intel_bo *aper_array[1]; mask &= ~(1 << buf); @@ -463,15 +460,7 @@ assert(x1 < x2); assert(y1 < y2); - /* do space check before going any further */ - aper_array[0] = intel->batch.bo; - aper_array[1] = region->bo; - - if (drm_intel_bufmgr_check_aperture_space(aper_array, - ARRAY_SIZE(aper_array)) != 0) { - intel_batchbuffer_flush(intel); - } - + again: BEGIN_BATCH(6); OUT_BATCH(CMD | (6 - 2)); OUT_BATCH(BR13); @@ -480,6 +469,16 @@ OUT_RELOC_FENCED(region->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); + /* do space check before going any further */ + aper_array[0] = intel->batch.bo; + if (dri_bufmgr_check_aperture_space(aper_array, 1) != 0) { + int reloc_count = drm_intel_gem_bo_get_reloc_count(intel->batch.bo); + drm_intel_gem_bo_clear_relocs(intel->batch.bo, reloc_count - 1); + intel_batchbuffer_emit_reset(intel); + intel_batchbuffer_flush(intel); + goto again; + } + OUT_BATCH(clear_val); ADVANCE_BATCH(); @@ -632,7 +631,7 @@ struct intel_region *region = mt->region; uint32_t BR13, CMD; int pitch, cpp; - drm_intel_bo *aper_array[2]; + drm_intel_bo *aper_array[1]; BATCH_LOCALS; pitch = region->pitch; @@ -647,15 +646,7 @@ BR13 |= pitch; - /* do space check before going any further */ - aper_array[0] = intel->batch.bo; - aper_array[1] = region->bo; - - if (drm_intel_bufmgr_check_aperture_space(aper_array, - ARRAY_SIZE(aper_array)) != 0) { - intel_batchbuffer_flush(intel); - } - +again: BEGIN_BATCH(6); OUT_BATCH(CMD | (6 - 2)); OUT_BATCH(BR13); @@ -664,6 +655,15 @@ OUT_RELOC_FENCED(region->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); + /* do space check before going any further */ + aper_array[0] = intel->batch.bo; + if (dri_bufmgr_check_aperture_space(aper_array, 1) != 0) { + int reloc_count = drm_intel_gem_bo_get_reloc_count(intel->batch.bo); + drm_intel_gem_bo_clear_relocs(intel->batch.bo, reloc_count - 1); + intel_batchbuffer_emit_reset(intel); + intel_batchbuffer_flush(intel); + goto again; + } OUT_BATCH(0xffffffff); /* white, but only alpha gets written */ ADVANCE_BATCH();