diff options
Diffstat (limited to 'lib/intel_batchbuffer.c')
-rw-r--r-- | lib/intel_batchbuffer.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 3747019a..d9cc4d89 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -706,12 +706,13 @@ fill_object(struct drm_i915_gem_exec_object2 *obj, static void exec_blit(int fd, struct drm_i915_gem_exec_object2 *objs, uint32_t count, - unsigned int gen) + unsigned int gen, uint32_t ctx) { struct drm_i915_gem_execbuffer2 exec = { .buffers_ptr = to_user_pointer(objs), .buffer_count = count, .flags = gen >= 6 ? I915_EXEC_BLT : 0, + .rsvd1 = ctx, }; gem_execbuf(fd, &exec); @@ -896,7 +897,7 @@ void igt_blitter_src_copy(int fd, objs[0].flags |= EXEC_OBJECT_NEEDS_FENCE; objs[1].flags |= EXEC_OBJECT_NEEDS_FENCE; - exec_blit(fd, objs, 3, gen); + exec_blit(fd, objs, 3, gen, 0); gem_close(fd, batch_handle); } @@ -904,12 +905,15 @@ void igt_blitter_src_copy(int fd, /** * igt_blitter_fast_copy__raw: * @fd: file descriptor of the i915 driver + * @ahnd: handle to an allocator + * @ctx: context within which execute copy blit * @src_handle: GEM handle of the source buffer * @src_delta: offset into the source GEM bo, in bytes * @src_stride: Stride (in bytes) of the source buffer * @src_tiling: Tiling mode of the source buffer * @src_x: X coordinate of the source region to copy * @src_y: Y coordinate of the source region to copy + * @src_size: size of the src bo required for allocator and softpin * @width: Width of the region to copy * @height: Height of the region to copy * @bpp: source and destination bits per pixel @@ -919,16 +923,20 @@ void igt_blitter_src_copy(int fd, * @dst_tiling: Tiling mode of the destination buffer * @dst_x: X coordinate of destination * @dst_y: Y coordinate of destination + * @dst_size: size of the dst bo required for allocator and softpin * * Like igt_blitter_fast_copy(), but talking to the kernel directly. */ void igt_blitter_fast_copy__raw(int fd, + uint64_t ahnd, + uint32_t ctx, /* src */ uint32_t src_handle, unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y, + uint64_t src_size, /* size */ unsigned int width, unsigned int height, @@ -941,7 +949,8 @@ void igt_blitter_fast_copy__raw(int fd, unsigned dst_delta, unsigned int dst_stride, unsigned int dst_tiling, - unsigned int dst_x, unsigned dst_y) + unsigned int dst_x, unsigned dst_y, + uint64_t dst_size) { uint32_t batch[12]; struct drm_i915_gem_exec_object2 objs[3]; @@ -949,8 +958,20 @@ void igt_blitter_fast_copy__raw(int fd, uint32_t batch_handle; uint32_t dword0, dword1; uint32_t src_pitch, dst_pitch; + uint64_t batch_offset, src_offset, dst_offset; int i = 0; + batch_handle = gem_create(fd, 4096); + if (ahnd) { + src_offset = get_offset(ahnd, src_handle, src_size, 0); + dst_offset = get_offset(ahnd, dst_handle, dst_size, 0); + batch_offset = get_offset(ahnd, batch_handle, 4096, 0); + } else { + src_offset = 16 << 20; + dst_offset = ALIGN(src_offset + src_size, 1 << 20); + batch_offset = ALIGN(dst_offset + dst_size, 1 << 20); + } + src_pitch = fast_copy_pitch(src_stride, src_tiling); dst_pitch = fast_copy_pitch(dst_stride, dst_tiling); dword0 = fast_copy_dword0(src_tiling, dst_tiling); @@ -967,30 +988,36 @@ void igt_blitter_fast_copy__raw(int fd, batch[i++] = dword1 | dst_pitch; batch[i++] = (dst_y << 16) | dst_x; /* dst x1,y1 */ batch[i++] = ((dst_y + height) << 16) | (dst_x + width); /* dst x2,y2 */ - batch[i++] = dst_delta; /* dst address lower bits */ - batch[i++] = 0; /* dst address upper bits */ + batch[i++] = dst_offset + dst_delta; /* dst address lower bits */ + batch[i++] = (dst_offset + dst_delta) >> 32; /* dst address upper bits */ batch[i++] = (src_y << 16) | src_x; /* src x1,y1 */ batch[i++] = src_pitch; - batch[i++] = src_delta; /* src address lower bits */ - batch[i++] = 0; /* src address upper bits */ + batch[i++] = src_offset + src_delta; /* src address lower bits */ + batch[i++] = (src_offset + src_delta) >> 32; /* src address upper bits */ batch[i++] = MI_BATCH_BUFFER_END; batch[i++] = MI_NOOP; igt_assert(i == ARRAY_SIZE(batch)); - batch_handle = gem_create(fd, 4096); gem_write(fd, batch_handle, 0, batch, sizeof(batch)); - fill_relocation(&relocs[0], dst_handle, -1, dst_delta, 4, + fill_relocation(&relocs[0], dst_handle, dst_offset, dst_delta, 4, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); - fill_relocation(&relocs[1], src_handle, -1, src_delta, 8, + fill_relocation(&relocs[1], src_handle, src_offset, src_delta, 8, I915_GEM_DOMAIN_RENDER, 0); - fill_object(&objs[0], dst_handle, 0, NULL, 0); - fill_object(&objs[1], src_handle, 0, NULL, 0); - fill_object(&objs[2], batch_handle, 0, relocs, 2); + fill_object(&objs[0], dst_handle, dst_offset, NULL, 0); + objs[0].flags |= EXEC_OBJECT_WRITE; + fill_object(&objs[1], src_handle, src_offset, NULL, 0); + fill_object(&objs[2], batch_handle, batch_offset, relocs, !ahnd ? 2 : 0); + + if (ahnd) { + objs[0].flags |= EXEC_OBJECT_PINNED; + objs[1].flags |= EXEC_OBJECT_PINNED; + objs[2].flags |= EXEC_OBJECT_PINNED; + } - exec_blit(fd, objs, 3, intel_gen(intel_get_drm_devid(fd))); + exec_blit(fd, objs, 3, intel_gen(intel_get_drm_devid(fd)), ctx); gem_close(fd, batch_handle); } |