diff options
author | Thierry Reding <treding@nvidia.com> | 2016-07-06 15:41:15 +0200 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2016-07-06 15:41:15 +0200 |
commit | 8849ad56e4d67b1d2b42864310a7e6c639b93957 (patch) | |
tree | c5b66a77a6b4ad7f71d15961e976b73e5b600db5 | |
parent | 64c86c20ed406314d4b5985dcdfff350a730c9c2 (diff) |
WIP working \o/staging/work
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 20 | ||||
-rw-r--r-- | src/gallium/auxiliary/target-helpers/drm_helper.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/tegra/tegra_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/tegra/tegra_screen.c | 63 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri2.c | 22 | ||||
-rw-r--r-- | src/gallium/targets/dri/target.c | 2 | ||||
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 20 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/dri_util.c | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 17 |
9 files changed, 117 insertions, 38 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 994a284385c7..08266b3e0136 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -166,6 +166,12 @@ static const struct drm_driver_descriptor driver_descriptors[] = { .create_screen = pipe_vc4_create_screen, .configuration = configuration_query, }, + { + .name = "tegra", + .driver_name = "tegra", + .create_screen = pipe_tegra_create_screen, + .configuration = configuration_query, + }, }; #endif @@ -175,6 +181,8 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device); int vendor_id, chip_id; + printf("> %s(dev=%p, fd=%d)\n", __func__, dev, fd); + if (!ddev) return false; @@ -193,14 +201,18 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) goto fail; #ifdef GALLIUM_STATIC_TARGETS + printf("driver descriptors:\n"); for (int i = 0; i < ARRAY_SIZE(driver_descriptors); i++) { + printf(" %d: %s\n", i, driver_descriptors[i].name); if (strcmp(driver_descriptors[i].name, ddev->base.driver_name) == 0) { ddev->dd = &driver_descriptors[i]; break; } } - if (!ddev->dd) + if (!ddev->dd) { + printf("failed to find driver descriptor\n"); goto fail; + } #else ddev->lib = pipe_loader_find_module(&ddev->base, PIPE_SEARCH_DIR); if (!ddev->lib) @@ -210,11 +222,14 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) util_dl_get_proc_address(ddev->lib, "driver_descriptor"); /* sanity check on the name */ - if (!ddev->dd || strcmp(ddev->dd->name, ddev->base.driver_name) != 0) + if (!ddev->dd || strcmp(ddev->dd->name, ddev->base.driver_name) != 0) { + printf("failed to get driver descriptor\n"); goto fail; + } #endif *dev = &ddev->base; + printf("< %s() = true\n", __func__); return true; fail: @@ -223,6 +238,7 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) util_dl_close(ddev->lib); #endif FREE(ddev); + printf("< %s() = false\n", __func__); return false; } diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h index 0d625f7b018f..328dc81ff751 100644 --- a/src/gallium/auxiliary/target-helpers/drm_helper.h +++ b/src/gallium/auxiliary/target-helpers/drm_helper.h @@ -274,8 +274,11 @@ pipe_tegra_create_screen(int fd) { struct pipe_screen *screen; + fprintf(stderr, "> %s(fd=%d)\n", __func__, fd); + screen = tegra_drm_screen_create(fd); + fprintf(stderr, "< %s() = %p\n", __func__, screen); return screen ? debug_screen_wrap(screen) : NULL; } diff --git a/src/gallium/drivers/tegra/tegra_context.c b/src/gallium/drivers/tegra/tegra_context.c index ef8933aaf126..f696bc45a563 100644 --- a/src/gallium/drivers/tegra/tegra_context.c +++ b/src/gallium/drivers/tegra/tegra_context.c @@ -21,6 +21,8 @@ * IN THE SOFTWARE. */ +#undef DEBUG + #include <inttypes.h> #include <stdlib.h> @@ -28,6 +30,7 @@ #include "util/u_inlines.h" #include "tegra/tegra_context.h" +#include "tegra/tegra_resource.h" #include "tegra/tegra_screen.h" static void diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c index 6496a2be0d1d..5a9671fabbc0 100644 --- a/src/gallium/drivers/tegra/tegra_screen.c +++ b/src/gallium/drivers/tegra/tegra_screen.c @@ -21,6 +21,8 @@ * IN THE SOFTWARE. */ +#undef DEBUG + #include <errno.h> #include <fcntl.h> #include <inttypes.h> @@ -37,10 +39,12 @@ #include "pipe/p_state.h" #include "util/u_debug.h" +#include "util/u_inlines.h" #include "state_tracker/drm_driver.h" #include "tegra/tegra_context.h" +#include "tegra/tegra_resource.h" #include "tegra/tegra_screen.h" /* TODO: obtain from include file */ @@ -85,12 +89,12 @@ tegra_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) struct tegra_screen *screen = to_tegra_screen(pscreen); int ret; - debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, - param); + //debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, + // param); ret = screen->gpu->get_param(screen->gpu, param); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -100,12 +104,12 @@ tegra_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param) struct tegra_screen *screen = to_tegra_screen(pscreen); float ret; - debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, - param); + //debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, + // param); ret = screen->gpu->get_paramf(screen->gpu, param); - debug_printf("< %s() = %f\n", __func__, ret); + //debug_printf("< %s() = %f\n", __func__, ret); return ret; } @@ -117,12 +121,12 @@ tegra_screen_get_shader_param(struct pipe_screen *pscreen, struct tegra_screen *screen = to_tegra_screen(pscreen); int ret; - debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, - param); + //debug_printf("> %s(pscreen=%p, param=%d)\n", __func__, pscreen, + // param); ret = screen->gpu->get_shader_param(screen->gpu, shader, param); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -135,13 +139,13 @@ tegra_screen_get_video_param(struct pipe_screen *pscreen, struct tegra_screen *screen = to_tegra_screen(pscreen); int ret; - debug_printf("> %s(pscreen=%p, profile=%d, entrypoint=%d, param=%d)\n", - __func__, pscreen, profile, entrypoint, param); + //debug_printf("> %s(pscreen=%p, profile=%d, entrypoint=%d, param=%d)\n", + // __func__, pscreen, profile, entrypoint, param); ret = screen->gpu->get_video_param(screen->gpu, profile, entrypoint, param); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -154,13 +158,13 @@ tegra_screen_get_compute_param(struct pipe_screen *pscreen, struct tegra_screen *screen = to_tegra_screen(pscreen); int ret; - debug_printf("> %s(pscreen=%p, ir_type=%d, param=%d, retp=%p)\n", - __func__, pscreen, ir_type, param, retp); + //debug_printf("> %s(pscreen=%p, ir_type=%d, param=%d, retp=%p)\n", + // __func__, pscreen, ir_type, param, retp); ret = screen->gpu->get_compute_param(screen->gpu, ir_type, param, retp); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -188,13 +192,13 @@ tegra_screen_is_format_supported(struct pipe_screen *pscreen, struct tegra_screen *screen = to_tegra_screen(pscreen); boolean ret; - debug_printf("> %s(pscreen=%p, format=%d, target=%d, sample_count=%u, usage=%x)\n", - __func__, pscreen, format, target, sample_count, usage); + //debug_printf("> %s(pscreen=%p, format=%d, target=%d, sample_count=%u, usage=%x)\n", + // __func__, pscreen, format, target, sample_count, usage); ret = screen->gpu->is_format_supported(screen->gpu, format, target, sample_count, usage); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -207,13 +211,13 @@ tegra_screen_is_video_format_supported(struct pipe_screen *pscreen, struct tegra_screen *screen = to_tegra_screen(pscreen); boolean ret; - debug_printf("> %s(pscreen=%p, format=%d, profile=%d, entrypoint=%d)\n", - __func__, pscreen, format, profile, entrypoint); + //debug_printf("> %s(pscreen=%p, format=%d, profile=%d, entrypoint=%d)\n", + // __func__, pscreen, format, profile, entrypoint); ret = screen->gpu->is_video_format_supported(screen->gpu, format, profile, entrypoint); - debug_printf("< %s() = %d\n", __func__, ret); + //debug_printf("< %s() = %d\n", __func__, ret); return ret; } @@ -226,6 +230,11 @@ tegra_screen_can_create_resource(struct pipe_screen *pscreen, debug_printf("> %s(pscreen=%p, template=%p)\n", __func__, pscreen, template); + debug_printf(" screen: %p\n", screen); + debug_printf(" base: %p\n", &screen->base); + debug_printf(" can_create_resource: %p\n", screen->base.can_create_resource); + debug_printf(" gpu: %p\n", screen->gpu); + debug_printf(" can_create_resource: %p\n", screen->gpu->can_create_resource); ret = screen->gpu->can_create_resource(screen->gpu, template); @@ -721,7 +730,8 @@ tegra_screen_create(int fd) { struct tegra_screen *screen; - debug_printf("> %s()\n", __func__); + debug_printf("> %s(fd=%d)\n", __func__, fd); + fprintf(stderr, "> %s(fd=%d)\n", __func__, fd); screen = calloc(1, sizeof(*screen)); if (!screen) @@ -737,7 +747,9 @@ tegra_screen_create(int fd) return NULL; } + debug_printf(" creating GPU screen...\n"); screen->gpu = nouveau_drm_screen_create(screen->gpu_fd); + debug_printf(" done: %p\n", screen->gpu); if (!screen->gpu) { fprintf(stderr, "failed to create GPU screen\n"); close(screen->gpu_fd); @@ -761,7 +773,11 @@ tegra_screen_create(int fd) screen->base.context_create = tegra_screen_context_create; screen->base.is_format_supported = tegra_screen_is_format_supported; screen->base.is_video_format_supported = tegra_screen_is_video_format_supported; - screen->base.can_create_resource = tegra_screen_can_create_resource; + + /* allow fallback implementation if GPU driver doesn't implement it */ + if (screen->gpu->can_create_resource) + screen->base.can_create_resource = tegra_screen_can_create_resource; + screen->base.resource_create = tegra_screen_resource_create; screen->base.resource_create_front = tegra_screen_resource_create_front; screen->base.resource_from_handle = tegra_screen_resource_from_handle; @@ -779,7 +795,6 @@ tegra_screen_create(int fd) screen->base.get_compiler_options = tegra_screen_get_compiler_options; -out: debug_printf("< %s() = %p\n", __func__, &screen->base); return &screen->base; } diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index c22a8cdc4306..d53327c5b624 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -1789,6 +1789,9 @@ dri2_init_screen(__DRIscreen * sPriv) const struct drm_conf_ret *dmabuf_ret; int fd; + printf("> %s(sPriv=%p)\n", __func__, sPriv); + printf(" fd: %d\n", sPriv->fd); + screen = CALLOC_STRUCT(dri_screen); if (!screen) return NULL; @@ -1799,14 +1802,20 @@ dri2_init_screen(__DRIscreen * sPriv) sPriv->driverPrivate = (void *)screen; - if (screen->fd < 0 || (fd = dup(screen->fd)) < 0) + if (screen->fd < 0 || (fd = dup(screen->fd)) < 0) { + printf("invalid file descriptor\n"); goto free_screen; + } if (pipe_loader_drm_probe_fd(&screen->dev, fd)) pscreen = pipe_loader_create_screen(screen->dev); + else + printf(" failed to probe fd\n"); - if (!pscreen) - goto release_pipe; + if (!pscreen) { + printf(" failed to create screen\n"); + goto release_pipe; + } throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE); dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD); @@ -1834,14 +1843,17 @@ dri2_init_screen(__DRIscreen * sPriv) sPriv->extensions = dri_screen_extensions; configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name); - if (!configs) + if (!configs) { + printf(" failed to initialize screen helper\n"); goto destroy_screen; + } screen->can_share_buffer = true; screen->auto_fake_front = dri_with_format(sPriv); screen->broken_invalidate = !sPriv->dri2.useInvalidate; screen->lookup_egl_image = dri2_lookup_egl_image; + printf("< %s() = %p\n", __func__, configs); return configs; destroy_screen: @@ -1855,6 +1867,8 @@ release_pipe: free_screen: FREE(screen); + printf(" failed\n"); + printf("< %s()\n", __func__); return NULL; } diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c index 4de7f06f9db4..a3fee0588e4b 100644 --- a/src/gallium/targets/dri/target.c +++ b/src/gallium/targets/dri/target.c @@ -164,7 +164,6 @@ PUBLIC const __DRIextension **__driDriverGetExtensions_i965(void) #endif #if defined(GALLIUM_TEGRA) -#if defined(DRI_TARGET) const __DRIextension **__driDriverGetExtensions_tegra(void); PUBLIC const __DRIextension **__driDriverGetExtensions_tegra(void) @@ -173,4 +172,3 @@ PUBLIC const __DRIextension **__driDriverGetExtensions_tegra(void) return galliumdrm_driver_extensions; } #endif -#endif diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index c3626e39c072..da51acf6cad2 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -267,7 +267,11 @@ dri_bind_extensions(struct gbm_dri_device *dri, int i, j, ret = 0; void *field; + fprintf(stderr, "> %s(dri=%p, matches=%p, extensions=%p)\n", __func__, + dri, matches, extensions); + for (i = 0; extensions[i]; i++) { + fprintf(stderr, " %s:\n", extensions[i]->name); for (j = 0; matches[j].name; j++) { if (strcmp(extensions[i]->name, matches[j].name) == 0 && extensions[i]->version >= matches[j].version) { @@ -284,6 +288,7 @@ dri_bind_extensions(struct gbm_dri_device *dri, } } + fprintf(stderr, "< %s() = %d\n", __func__, ret); return ret; } @@ -386,6 +391,8 @@ dri_load_driver(struct gbm_dri_device *dri) { const __DRIextension **extensions; + fprintf(stderr, "> %s(dri=%p)\n", __func__, dri); + extensions = dri_open_driver(dri); if (!extensions) return -1; @@ -398,6 +405,7 @@ dri_load_driver(struct gbm_dri_device *dri) dri->driver_extensions = extensions; + fprintf(stderr, "< %s()\n", __func__); return 0; } @@ -427,6 +435,8 @@ dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) const __DRIextension **extensions; int ret = 0; + printf("> %s(dri=%p, driver_name=%s)\n", __func__, dri, driver_name); + dri->base.driver_name = driver_name; if (dri->base.driver_name == NULL) return -1; @@ -439,8 +449,10 @@ dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) dri->extensions = gbm_dri_screen_extensions; - if (dri->dri2 == NULL) + if (dri->dri2 == NULL) { + printf("DRI2 not supported\n"); return -1; + } if (dri->dri2->base.version >= 4) { dri->screen = dri->dri2->createNewScreen2(0, dri->base.base.fd, @@ -452,8 +464,10 @@ dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) dri->extensions, &dri->driver_configs, dri); } - if (dri->screen == NULL) + if (dri->screen == NULL) { + printf("failed to create DRI2 screen\n"); return -1; + } extensions = dri->core->getExtensions(dri->screen); if (dri_bind_extensions(dri, dri_core_extensions, extensions) < 0) { @@ -464,11 +478,13 @@ dri_screen_create_dri2(struct gbm_dri_device *dri, char *driver_name) dri->lookup_image = NULL; dri->lookup_user_data = NULL; + printf("< %s()\n", __func__); return 0; free_screen: dri->core->destroyScreen(dri->screen); + printf("< %s() = %d\n", __func__, ret); return ret; } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 79cb0506dd8a..de3f448cbf22 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -115,6 +115,8 @@ driCreateNewScreen2(int scrn, int fd, static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; + printf("> %s(scrn=%d, fd=%d)\n", __func__, scrn, fd); + psp = calloc(1, sizeof(*psp)); if (!psp) return NULL; @@ -144,6 +146,7 @@ driCreateNewScreen2(int scrn, int fd, *driver_configs = psp->driver->InitScreen(psp); if (*driver_configs == NULL) { + printf("failed to init screen\n"); free(psp); return NULL; } @@ -180,7 +183,7 @@ driCreateNewScreen2(int scrn, int fd, driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions); driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2"); - + printf("< %s() = %p\n", __func__, psp); return psp; } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 1474d973861f..9a534461556b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -2692,12 +2692,18 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target, { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; + GLboolean ret; + + printf("> %s(ctx=%p, target=%d, level=%d, format=%d, width=%d, height=%d, depth=%d, border=%d)\n", + __func__, ctx, target, level, format, width, height, depth, border); if (width == 0 || height == 0 || depth == 0) { /* zero-sized images are legal, and always fit! */ return GL_TRUE; } + printf(" can_create_resource: %p\n", pipe->screen->can_create_resource); + if (pipe->screen->can_create_resource) { /* Ask the gallium driver if the texture is too large */ struct gl_texture_object *texObj = @@ -2726,13 +2732,18 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target, pt.last_level = _mesa_logbase2(MAX3(width, height, depth)); } - return pipe->screen->can_create_resource(pipe->screen, &pt); + printf(" calling into driver...\n"); + ret = pipe->screen->can_create_resource(pipe->screen, &pt); + printf(" done: %d\n", ret); } else { /* Use core Mesa fallback */ - return _mesa_test_proxy_teximage(ctx, target, level, format, - width, height, depth, border); + ret = _mesa_test_proxy_teximage(ctx, target, level, format, + width, height, depth, border); } + + printf("< %s() = %d\n", __func__, ret); + return ret; } static GLboolean |