mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 18:06:13 +00:00
lib/drmtest: extract gem_write
Astonishing how many different function signatures are possible for something that simple. Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
5dd17d3f4b
commit
319638ba6d
@ -142,3 +142,17 @@ void gem_close(int fd, uint32_t handle)
|
||||
ret = drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size)
|
||||
{
|
||||
struct drm_i915_gem_pwrite gem_pwrite;
|
||||
int ret;
|
||||
|
||||
gem_pwrite.handle = handle;
|
||||
gem_pwrite.offset = offset;
|
||||
gem_pwrite.size = size;
|
||||
gem_pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
|
@ -39,3 +39,4 @@ int drm_open_any_master(void);
|
||||
|
||||
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride);
|
||||
void gem_close(int fd, uint32_t handle);
|
||||
void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size);
|
||||
|
@ -64,22 +64,6 @@ static uint32_t gem_create(int fd, int size, int *retval)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static void gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite arg;
|
||||
int ret;
|
||||
|
||||
arg.handle = handle;
|
||||
arg.offset = offset;
|
||||
arg.size = length;
|
||||
arg.data_ptr = (uintptr_t)src;
|
||||
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &arg);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
|
||||
{
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
|
||||
|
@ -63,19 +63,6 @@ static uint32_t gem_create(int fd, int size)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static int gem_linear_blt(uint32_t *batch,
|
||||
uint32_t src,
|
||||
uint32_t dst,
|
||||
|
@ -88,19 +88,6 @@ static uint32_t gem_create(int fd, int size)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static int gem_linear_blt(uint32_t *batch,
|
||||
uint32_t src,
|
||||
uint32_t dst,
|
||||
@ -234,8 +221,7 @@ static void run(int object_size)
|
||||
exec[1].rsvd2 = 0;
|
||||
|
||||
handle_relocs = gem_create(fd, 4096);
|
||||
ret = gem_write(fd, handle_relocs, 0, reloc, sizeof(reloc));
|
||||
assert(ret == 0);
|
||||
gem_write(fd, handle_relocs, 0, reloc, sizeof(reloc));
|
||||
gtt_relocs = mmap_bo(fd, handle_relocs);
|
||||
assert(gtt_relocs);
|
||||
|
||||
|
@ -55,19 +55,6 @@ static uint32_t gem_create(int fd, int size)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static void gem_sync(int fd, uint32_t handle)
|
||||
{
|
||||
struct drm_i915_gem_set_domain set_domain;
|
||||
|
@ -72,19 +72,6 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static int gem_read(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
|
@ -76,20 +76,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
|
||||
{
|
||||
@ -130,7 +116,7 @@ copy(int fd, uint32_t dst, uint32_t src)
|
||||
batch[9] = MI_NOOP;
|
||||
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, sizeof(batch), batch);
|
||||
gem_write(fd, handle, 0, batch, sizeof(batch));
|
||||
|
||||
reloc[0].target_handle = dst;
|
||||
reloc[0].delta = 0;
|
||||
@ -203,7 +189,7 @@ create_bo(int fd, uint32_t val)
|
||||
/* Fill the BO with dwords starting at val */
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++)
|
||||
linear[i] = val++;
|
||||
gem_write(fd, handle, 0, sizeof(linear), linear);
|
||||
gem_write(fd, handle, 0, linear, sizeof(linear));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -42,20 +42,6 @@
|
||||
|
||||
#define OBJECT_SIZE 16384
|
||||
|
||||
static int
|
||||
do_write(int fd, int handle, void *buf, int offset, int size)
|
||||
{
|
||||
struct drm_i915_gem_pwrite write;
|
||||
|
||||
memset(&write, 0, sizeof(write));
|
||||
write.handle = handle;
|
||||
write.data_ptr = (uintptr_t)buf;
|
||||
write.size = size;
|
||||
write.offset = offset;
|
||||
|
||||
return ioctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &write);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
@ -100,8 +86,7 @@ int main(int argc, char **argv)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(buf + 1024, 0x01, 1024);
|
||||
memset(expected + 1024, 0x01, 1024);
|
||||
ret = do_write(fd, handle, buf, 0, OBJECT_SIZE);
|
||||
assert(ret == 0);
|
||||
gem_write(fd, handle, 0, buf, OBJECT_SIZE);
|
||||
assert(memcmp(buf, addr, sizeof(buf)) == 0);
|
||||
|
||||
printf("Testing that mapping stays after close\n");
|
||||
|
@ -55,22 +55,6 @@ static uint32_t gem_create(int fd, int size)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static void gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite arg;
|
||||
int ret;
|
||||
|
||||
arg.handle = handle;
|
||||
arg.offset = offset;
|
||||
arg.size = length;
|
||||
arg.data_ptr = (uintptr_t)src;
|
||||
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &arg);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void gem_read(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
void *dst, int length)
|
||||
|
@ -62,19 +62,6 @@ static uint32_t gem_create(int fd, int size)
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static void do_gem_write(int fd, uint32_t handle, void *buf, int len, int loops)
|
||||
{
|
||||
while (loops--)
|
||||
|
@ -72,20 +72,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, drm_intel_bo *bo, const void *buf, int size)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = bo->handle;
|
||||
pwrite.offset = 0;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gem_read(int fd, drm_intel_bo *bo, void *buf, int size)
|
||||
{
|
||||
@ -116,7 +102,7 @@ create_bo(int fd, uint32_t start_val)
|
||||
for (i = 0; i < 1024 * 1024 / 4; i++)
|
||||
linear[i] = start_val++;
|
||||
|
||||
gem_write(fd, bo, linear, sizeof(linear));
|
||||
gem_write(fd, bo->handle, 0, linear, sizeof(linear));
|
||||
|
||||
return bo;
|
||||
}
|
||||
|
@ -95,19 +95,6 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static int gem_write(int fd,
|
||||
uint32_t handle, uint32_t offset,
|
||||
const void *src, int length)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = length;
|
||||
pwrite.data_ptr = (uintptr_t)src;
|
||||
return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
}
|
||||
|
||||
static void
|
||||
gem_read(int fd, uint32_t handle, int offset, int length, void *buf)
|
||||
{
|
||||
|
@ -117,20 +117,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
|
||||
{
|
||||
@ -171,7 +157,7 @@ copy(int fd, uint32_t dst, uint32_t src)
|
||||
batch[9] = MI_NOOP;
|
||||
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, sizeof(batch), batch);
|
||||
gem_write(fd, handle, 0, batch, sizeof(batch));
|
||||
|
||||
reloc[0].target_handle = dst;
|
||||
reloc[0].delta = 0;
|
||||
@ -259,7 +245,7 @@ create_bo(int fd, uint32_t val)
|
||||
/* Fill the BO with dwords starting at val */
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++)
|
||||
linear[i] = val++;
|
||||
gem_write(fd, handle, 0, sizeof(linear), linear);
|
||||
gem_write(fd, handle, 0, linear, sizeof(linear));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -87,20 +87,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static uint32_t fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
|
||||
uint32_t offset,
|
||||
uint32_t handle,
|
||||
@ -306,7 +292,7 @@ render_copy(int fd,
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
@ -387,7 +373,7 @@ static void blt_copy(int fd, uint32_t dst, uint32_t src)
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
|
@ -87,20 +87,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gem_read(int fd, uint32_t handle, int offset, int size, void *buf)
|
||||
{
|
||||
@ -293,7 +279,7 @@ copy(int fd, uint32_t dst, uint32_t src)
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
@ -354,7 +340,7 @@ create_bo(int fd, uint32_t val)
|
||||
/* Fill the BO with dwords starting at val */
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++)
|
||||
linear[i] = val++;
|
||||
gem_write(fd, handle, 0, sizeof(linear), linear);
|
||||
gem_write(fd, handle, 0, linear, sizeof(linear));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -87,20 +87,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static uint32_t fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
|
||||
uint32_t offset,
|
||||
uint32_t handle,
|
||||
@ -293,7 +279,7 @@ copy(int fd,
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
|
@ -87,20 +87,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static uint32_t fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
|
||||
uint32_t offset,
|
||||
uint32_t handle,
|
||||
@ -280,7 +266,7 @@ copy(int fd, uint32_t dst, uint32_t src)
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
|
@ -87,20 +87,6 @@ gem_aperture_size(int fd)
|
||||
return aperture.aper_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gem_write(int fd, uint32_t handle, int offset, int size, const void *buf)
|
||||
{
|
||||
struct drm_i915_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
pwrite.handle = handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uintptr_t)buf;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
static uint32_t fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
|
||||
uint32_t offset,
|
||||
uint32_t handle,
|
||||
@ -280,7 +266,7 @@ copy(int fd, uint32_t dst, uint32_t src)
|
||||
|
||||
assert(b - batch <= 1024);
|
||||
handle = gem_create(fd, 4096);
|
||||
gem_write(fd, handle, 0, (b-batch)*sizeof(batch[0]), batch);
|
||||
gem_write(fd, handle, 0, batch, (b-batch)*sizeof(batch[0]));
|
||||
|
||||
assert(r-reloc == 2);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user