summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/v3d/v3d_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/drivers/v3d/v3d_resource.c')
-rw-r--r--lib/mesa/src/gallium/drivers/v3d/v3d_resource.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/lib/mesa/src/gallium/drivers/v3d/v3d_resource.c b/lib/mesa/src/gallium/drivers/v3d/v3d_resource.c
index 602ba6d84..cc56d02da 100644
--- a/lib/mesa/src/gallium/drivers/v3d/v3d_resource.c
+++ b/lib/mesa/src/gallium/drivers/v3d/v3d_resource.c
@@ -397,6 +397,21 @@ v3d_resource_destroy(struct pipe_screen *pscreen,
free(rsc);
}
+static uint64_t
+v3d_resource_modifier(struct v3d_resource *rsc)
+{
+ if (rsc->tiled) {
+ /* A shared tiled buffer should always be allocated as UIF,
+ * not UBLINEAR or LT.
+ */
+ assert(rsc->slices[0].tiling == VC5_TILING_UIF_XOR ||
+ rsc->slices[0].tiling == VC5_TILING_UIF_NO_XOR);
+ return DRM_FORMAT_MOD_BROADCOM_UIF;
+ } else {
+ return DRM_FORMAT_MOD_LINEAR;
+ }
+}
+
static bool
v3d_resource_get_handle(struct pipe_screen *pscreen,
struct pipe_context *pctx,
@@ -410,6 +425,7 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
whandle->stride = rsc->slices[0].stride;
whandle->offset = 0;
+ whandle->modifier = v3d_resource_modifier(rsc);
/* If we're passing some reference to our BO out to some other part of
* the system, then we can't do any optimizations about only us being
@@ -417,26 +433,16 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
*/
bo->private = false;
- if (rsc->tiled) {
- /* A shared tiled buffer should always be allocated as UIF,
- * not UBLINEAR or LT.
- */
- assert(rsc->slices[0].tiling == VC5_TILING_UIF_XOR ||
- rsc->slices[0].tiling == VC5_TILING_UIF_NO_XOR);
- whandle->modifier = DRM_FORMAT_MOD_BROADCOM_UIF;
- } else {
- whandle->modifier = DRM_FORMAT_MOD_LINEAR;
- }
-
switch (whandle->type) {
case WINSYS_HANDLE_TYPE_SHARED:
return v3d_bo_flink(bo, &whandle->handle);
case WINSYS_HANDLE_TYPE_KMS:
if (screen->ro) {
- assert(rsc->scanout);
- bool ok = renderonly_get_handle(rsc->scanout, whandle);
- whandle->stride = rsc->slices[0].stride;
- return ok;
+ if (renderonly_get_handle(rsc->scanout, whandle)) {
+ whandle->stride = rsc->slices[0].stride;
+ return true;
+ }
+ return false;
}
whandle->handle = bo->handle;
return true;
@@ -448,6 +454,30 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
return false;
}
+static bool
+v3d_resource_get_param(struct pipe_screen *pscreen,
+ struct pipe_context *pctx, struct pipe_resource *prsc,
+ unsigned plane, unsigned layer, unsigned level,
+ enum pipe_resource_param param,
+ unsigned usage, uint64_t *value)
+{
+ struct v3d_resource *rsc = v3d_resource(prsc);
+
+ switch (param) {
+ case PIPE_RESOURCE_PARAM_STRIDE:
+ *value = rsc->slices[level].stride;
+ return true;
+ case PIPE_RESOURCE_PARAM_OFFSET:
+ *value = 0;
+ return true;
+ case PIPE_RESOURCE_PARAM_MODIFIER:
+ *value = v3d_resource_modifier(rsc);
+ return true;
+ default:
+ return false;
+ }
+}
+
#define PAGE_UB_ROWS (VC5_UIFCFG_PAGE_SIZE / VC5_UIFBLOCK_ROW_SIZE)
#define PAGE_UB_ROWS_TIMES_1_5 ((PAGE_UB_ROWS * 3) >> 1)
#define PAGE_CACHE_UB_ROWS (VC5_PAGE_CACHE_SIZE / VC5_UIFBLOCK_ROW_SIZE)
@@ -929,10 +959,6 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
renderonly_create_gpu_import_for_resource(prsc,
screen->ro,
NULL);
- if (!rsc->scanout) {
- fprintf(stderr, "Failed to create scanout resource.\n");
- goto fail;
- }
}
if (rsc->tiled && whandle->stride != slice->stride) {
@@ -1152,6 +1178,7 @@ v3d_resource_screen_init(struct pipe_screen *pscreen)
pscreen->resource_create = u_transfer_helper_resource_create;
pscreen->resource_from_handle = v3d_resource_from_handle;
pscreen->resource_get_handle = v3d_resource_get_handle;
+ pscreen->resource_get_param = v3d_resource_get_param;
pscreen->resource_destroy = u_transfer_helper_resource_destroy;
pscreen->transfer_helper = u_transfer_helper_create(&transfer_vtbl,
true, false,