/* Fill a rectangular sub-region. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ void intel_region_fill(struct intel_context *intel, struct intel_region *dst, GLuint dst_offset, GLuint dstx, GLuint dsty, GLuint width, GLuint height, GLuint color) { DBG("%s\n", __FUNCTION__); if (intel == NULL) return; if (dst->pbo) { if (dstx == 0 && dsty == 0 && width == dst->pitch && height == dst->height) intel_region_release_pbo(intel, dst); else intel_region_cow(intel, dst); } intelEmitFillBlit(intel, dst->cpp, dst->pitch, dst->buffer, dst_offset, dst->tiling, dstx, dsty, width, height, color); }
/* Break the COW tie to the region. Both the pbo and the region end * up with a copy of the data. */ void intel_bufferobj_cow(struct intel_context *intel, struct intel_buffer_object *intel_obj) { assert(intel_obj->region); intel_region_cow(intel, intel_obj->region); }
/* Copy rectangular sub-regions. Need better logic about when to * push buffers into AGP - will currently do so whenever possible. */ void intel_region_copy(struct intel_context *intel, struct intel_region *dst, GLuint dst_offset, GLuint dstx, GLuint dsty, struct intel_region *src, GLuint src_offset, GLuint srcx, GLuint srcy, GLuint width, GLuint height) { DBG("%s\n", __FUNCTION__); if (intel == NULL) return; if (dst->pbo) { if (dstx == 0 && dsty == 0 && width == dst->pitch && height == dst->height) intel_region_release_pbo(intel, dst); else intel_region_cow(intel, dst); } assert(src->cpp == dst->cpp); intelEmitCopyBlit(intel, dst->cpp, src->pitch, src->buffer, src_offset, src->tiling, dst->pitch, dst->buffer, dst_offset, dst->tiling, srcx, srcy, dstx, dsty, width, height, GL_COPY); }
/* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination * - upload data as new buffer and blit * * Currently always memcpy. */ void intel_region_data(struct intel_context *intel, struct intel_region *dst, GLuint dst_offset, GLuint dstx, GLuint dsty, const void *src, GLuint src_pitch, GLuint srcx, GLuint srcy, GLuint width, GLuint height) { _DBG("%s\n", __FUNCTION__); if (intel == NULL) return; if (dst->pbo) { if (dstx == 0 && dsty == 0 && width == dst->pitch && height == dst->height) intel_region_release_pbo(intel, dst); else intel_region_cow(intel, dst); } LOCK_HARDWARE(intel); _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset, dst->cpp, dst->pitch, dstx, dsty, width, height, src, src_pitch, srcx, srcy); intel_region_unmap(intel, dst); UNLOCK_HARDWARE(intel); }
dri_bo * intel_region_buffer(struct intel_context *intel, struct intel_region *region, GLuint flag) { if (region->pbo) { if (flag == INTEL_WRITE_PART) intel_region_cow(intel, region); else if (flag == INTEL_WRITE_FULL) intel_region_release_pbo(intel, region); } return region->buffer; }
/* XXX: Thread safety? */ GLubyte * intel_region_map(struct intel_context *intel, struct intel_region *region) { DBG("%s\n", __FUNCTION__); if (!region->map_refcount++) { if (region->pbo) intel_region_cow(intel, region); dri_bo_map(region->buffer, GL_TRUE); region->map = region->buffer->virtual; } return region->map; }
/* XXX: Thread safety? */ GLubyte * intel_region_map(struct intel_context *intel, struct intel_region *region) { intelFlush(&intel->ctx); _DBG("%s %p\n", __FUNCTION__, region); if (!region->map_refcount++) { if (region->pbo) intel_region_cow(intel, region); if (region->tiling != I915_TILING_NONE && intel->intelScreen->kernel_exec_fencing) drm_intel_gem_bo_map_gtt(region->buffer); else dri_bo_map(region->buffer, GL_TRUE); region->map = region->buffer->virtual; } return region->map; }