mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-21 06:46:13 +00:00
tests/vgem_fb_test: Add DRM-only running path
This commit wraps all VGEM related code with 'USE_VGEM' macro, which gives the chance to enable a different running path using DRM fd without VGEM. This is particularly useful to test and compare the characteristics of VGEM and DRM. One can switch VGEM or DRM in compilation time by defining 'USE_VGEM' (which is by default on). Self annotation: if we opt out VGEM, just like the vgem_fb_test is now doing here, we achieve the same feature promised of map graphics buffers imported from a different process that in turn had allocated them. I.e. there's no GEM (or driver) specific optimizations such as tiling, memory coherency, whatsoever. Am I missing something here? Reference: http://crbug.com/426172 Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
This commit is contained in:
parent
01ed12bd7e
commit
4fa6cb5247
@ -24,10 +24,14 @@
|
|||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
#define BUFFERS 2
|
#define BUFFERS 2
|
||||||
|
#define USE_VGEM
|
||||||
|
|
||||||
struct context {
|
struct context {
|
||||||
int drm_card_fd;
|
int drm_card_fd;
|
||||||
|
#ifdef USE_VGEM
|
||||||
int vgem_card_fd;
|
int vgem_card_fd;
|
||||||
|
#endif
|
||||||
|
int card_fd;
|
||||||
struct gbm_device *drm_gbm;
|
struct gbm_device *drm_gbm;
|
||||||
|
|
||||||
drmModeRes *resources;
|
drmModeRes *resources;
|
||||||
@ -36,7 +40,7 @@ struct context {
|
|||||||
drmModeModeInfo *mode;
|
drmModeModeInfo *mode;
|
||||||
|
|
||||||
struct gbm_bo *gbm_buffer[BUFFERS];
|
struct gbm_bo *gbm_buffer[BUFFERS];
|
||||||
uint32_t vgem_bo_handle[BUFFERS];
|
uint32_t bo_handle[BUFFERS];
|
||||||
uint32_t drm_fb_id[BUFFERS];
|
uint32_t drm_fb_id[BUFFERS];
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -63,6 +67,7 @@ void do_fixes() {
|
|||||||
disable_psr();
|
disable_psr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_VGEM
|
||||||
const char g_sys_card_path_format[] =
|
const char g_sys_card_path_format[] =
|
||||||
"/sys/bus/platform/devices/vgem/drm/card%d";
|
"/sys/bus/platform/devices/vgem/drm/card%d";
|
||||||
const char g_dev_card_path_format[] =
|
const char g_dev_card_path_format[] =
|
||||||
@ -97,6 +102,7 @@ int drm_open_vgem()
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static double elapsed(const struct timeval *start, const struct timeval *end)
|
static double elapsed(const struct timeval *start, const struct timeval *end)
|
||||||
{
|
{
|
||||||
@ -273,7 +279,7 @@ void draw(struct context *ctx)
|
|||||||
case STEP_MMAP:
|
case STEP_MMAP:
|
||||||
if (enable_profiling)
|
if (enable_profiling)
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
bo_ptr = mmap_dumb_bo(ctx->vgem_card_fd, ctx->vgem_bo_handle[fb_idx], bo_size);
|
bo_ptr = mmap_dumb_bo(ctx->drm_card_fd, ctx->bo_handle[fb_idx], bo_size);
|
||||||
if (enable_profiling) {
|
if (enable_profiling) {
|
||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, NULL);
|
||||||
fprintf(stderr, "time to execute mmap: %7.3fms\n",
|
fprintf(stderr, "time to execute mmap: %7.3fms\n",
|
||||||
@ -357,19 +363,25 @@ int main(int argc, char **argv)
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_VGEM
|
||||||
ctx.vgem_card_fd = drm_open_vgem();
|
ctx.vgem_card_fd = drm_open_vgem();
|
||||||
if (ctx.vgem_card_fd < 0) {
|
if (ctx.vgem_card_fd < 0) {
|
||||||
fprintf(stderr, "failed to open vgem card\n");
|
fprintf(stderr, "failed to open vgem card\n");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto close_drm_card;
|
goto close_drm_card;
|
||||||
}
|
}
|
||||||
|
ctx.card_fd = ctx.vgem_card_fd;
|
||||||
|
fprintf(stderr, "Method to open video card: VGEM\n");
|
||||||
|
#else
|
||||||
|
ctx.card_fd = ctx.drm_card_fd;
|
||||||
|
fprintf(stderr, "Method to open video card: DRM\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
ctx.drm_gbm = gbm_create_device(ctx.drm_card_fd);
|
ctx.drm_gbm = gbm_create_device(ctx.drm_card_fd);
|
||||||
if (!ctx.drm_gbm) {
|
if (!ctx.drm_gbm) {
|
||||||
fprintf(stderr, "failed to create gbm device on %s\n", drm_card_path);
|
fprintf(stderr, "failed to create gbm device on %s\n", drm_card_path);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto close_vgem_card;
|
goto close_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!setup_drm(&ctx)) {
|
if (!setup_drm(&ctx)) {
|
||||||
@ -404,8 +416,8 @@ int main(int argc, char **argv)
|
|||||||
goto free_buffers;
|
goto free_buffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drmPrimeFDToHandle(ctx.vgem_card_fd, drm_prime_fd,
|
ret = drmPrimeFDToHandle(ctx.drm_card_fd, drm_prime_fd,
|
||||||
&ctx.vgem_bo_handle[i]);
|
&ctx.bo_handle[i]);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
fprintf(stderr, "failed to import handle\n");
|
fprintf(stderr, "failed to import handle\n");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -444,8 +456,10 @@ free_buffers:
|
|||||||
drmModeFreeResources(ctx.resources);
|
drmModeFreeResources(ctx.resources);
|
||||||
destroy_drm_gbm:
|
destroy_drm_gbm:
|
||||||
gbm_device_destroy(ctx.drm_gbm);
|
gbm_device_destroy(ctx.drm_gbm);
|
||||||
close_vgem_card:
|
close_card:
|
||||||
|
#ifdef USE_VGEM
|
||||||
close(ctx.vgem_card_fd);
|
close(ctx.vgem_card_fd);
|
||||||
|
#endif
|
||||||
close_drm_card:
|
close_drm_card:
|
||||||
close(ctx.drm_card_fd);
|
close(ctx.drm_card_fd);
|
||||||
fail:
|
fail:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user