Lines Matching refs:res
172 struct crocus_resource *res,
188 res->mod_info = isl_drm_modifier_get_info(modifier);
190 tiling_flags = 1 << res->mod_info->tiling;
194 res->mod_info = isl_drm_modifier_get_info(modifier);
195 tiling_flags = 1 << res->mod_info->tiling;
254 if (!isl_surf_init_s(&screen->isl_dev, &res->surf, &init_info))
263 if (res->surf.size_B > screen->aperture_threshold / 2)
266 res->internal_format = templ->format;
324 crocus_resource_disable_aux(struct crocus_resource *res)
326 crocus_bo_unreference(res->aux.bo);
327 free(res->aux.state);
329 res->aux.usage = ISL_AUX_USAGE_NONE;
330 res->aux.has_hiz = 0;
331 res->aux.surf.size_B = 0;
332 res->aux.surf.levels = 0;
333 res->aux.bo = NULL;
334 res->aux.state = NULL;
341 struct crocus_resource *res = (struct crocus_resource *)resource;
344 util_range_destroy(&res->valid_buffer_range);
346 if (res->shadow)
347 pipe_resource_reference((struct pipe_resource **)&res->shadow, NULL);
348 crocus_resource_disable_aux(res);
351 crocus_bo_unreference(res->bo);
352 crocus_pscreen_unref(res->orig_screen);
353 free(res);
360 struct crocus_resource *res = calloc(1, sizeof(struct crocus_resource));
361 if (!res)
364 res->base.b = *templ;
365 res->base.b.screen = pscreen;
366 res->orig_screen = crocus_pscreen_ref(pscreen);
367 pipe_reference_init(&res->base.b.reference, 1);
368 threaded_resource_init(&res->base.b, false);
371 util_range_init(&res->valid_buffer_range);
373 return res;
377 crocus_get_num_logical_layers(const struct crocus_resource *res, unsigned level)
379 if (res->surf.dim == ISL_SURF_DIM_3D)
380 return u_minify(res->surf.logical_level0_px.depth, level);
382 return res->surf.logical_level0_px.array_len;
386 create_aux_state_map(struct crocus_resource *res, enum isl_aux_state initial)
388 assert(res->aux.state == NULL);
391 for (uint32_t level = 0; level < res->surf.levels; level++)
392 total_slices += crocus_get_num_logical_layers(res, level);
395 res->surf.levels * sizeof(enum isl_aux_state *);
410 for (uint32_t level = 0; level < res->surf.levels; level++) {
412 const unsigned level_layers = crocus_get_num_logical_layers(res, level);
431 struct crocus_resource *res, bool imported,
440 assert(!res->mod_info || res->mod_info->aux_usage == ISL_AUX_USAGE_NONE);
442 const bool has_mcs = devinfo->ver >= 7 && !res->mod_info &&
443 isl_surf_get_mcs_surf(&screen->isl_dev, &res->surf, &res->aux.surf);
445 const bool has_hiz = devinfo->ver >= 6 && !res->mod_info &&
447 isl_surf_get_hiz_surf(&screen->isl_dev, &res->surf, &res->aux.surf);
450 ((devinfo->ver >= 7 && !res->mod_info && !INTEL_DEBUG(DEBUG_NO_CCS)) ||
451 (res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE)) &&
452 isl_surf_get_ccs_surf(&screen->isl_dev, &res->surf, NULL,
453 &res->aux.surf, 0);
458 if (res->mod_info && has_ccs) {
459 res->aux.usage = res->mod_info->aux_usage;
461 res->aux.usage = ISL_AUX_USAGE_MCS;
463 res->aux.usage = ISL_AUX_USAGE_HIZ;
465 if (isl_format_supports_ccs_d(devinfo, res->surf.format))
466 res->aux.usage = ISL_AUX_USAGE_CCS_D;
472 assert(!res->aux.bo);
474 switch (res->aux.usage) {
477 res->aux.surf.levels = 0;
478 return !res->mod_info || res->mod_info->aux_usage == ISL_AUX_USAGE_NONE;
510 isl_drm_modifier_get_default_aux_state(res->mod_info->modifier);
520 res->aux.state = create_aux_state_map(res, initial_state);
521 if (!res->aux.state)
525 res->aux.offset =
526 !res->mod_info || res->mod_info->aux_usage == res->aux.usage ?
527 ALIGN(res->surf.size_B, res->aux.surf.alignment_B) : 0;
528 uint64_t size = res->aux.surf.size_B;
543 if (isl_aux_usage_has_hiz(res->aux.usage)) {
544 for (unsigned level = 0; level < res->surf.levels; ++level) {
545 uint32_t width = u_minify(res->surf.phys_level0_sa.width, level);
546 uint32_t height = u_minify(res->surf.phys_level0_sa.height, level);
553 res->aux.has_hiz |= 1 << level;
566 crocus_resource_init_aux_buf(struct crocus_resource *res, uint32_t alloc_flags)
569 void *map = crocus_bo_map(NULL, res->aux.bo, MAP_WRITE | MAP_RAW);
574 if (crocus_resource_get_aux_state(res, 0, 0) != ISL_AUX_STATE_AUX_INVALID) {
575 uint8_t memset_value = isl_aux_usage_has_mcs(res->aux.usage) ? 0xFF : 0;
576 memset((char*)map + res->aux.offset, memset_value,
577 res->aux.surf.size_B);
580 crocus_bo_unmap(res->aux.bo);
594 struct crocus_resource *res)
598 if (!crocus_resource_configure_aux(screen, res, false, &size, &alloc_flags))
609 res->aux.bo = crocus_bo_alloc_tiled(screen->bufmgr, "aux buffer", size, 4096,
610 isl_tiling_to_i915_tiling(res->aux.surf.tiling),
611 res->aux.surf.row_pitch_B, alloc_flags);
612 if (!res->aux.bo) {
616 if (!crocus_resource_init_aux_buf(res, alloc_flags))
624 struct crocus_resource *res)
627 assert(crocus_resource_unfinished_aux_import(res));
628 assert(!res->mod_info->supports_clear_color);
630 struct crocus_resource *aux_res = (void *) res->base.b.next;
634 assert(res->bo == aux_res->aux.bo);
636 res->aux.bo = aux_res->aux.bo;
638 res->aux.offset = aux_res->aux.offset;
640 assert(res->bo->size >= (res->aux.offset + res->aux.surf.size_B));
641 assert(aux_res->aux.surf.row_pitch_B == res->aux.surf.row_pitch_B);
643 crocus_resource_destroy(&screen->base, res->base.b.next);
644 res->base.b.next = NULL;
652 struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
660 res->internal_format = templ->format;
661 res->surf.tiling = ISL_TILING_LINEAR;
665 res->bo = crocus_bo_alloc(screen->bufmgr, name, templ->width0);
666 if (!res->bo) {
667 crocus_resource_destroy(pscreen, &res->base.b);
671 return &res->base.b;
682 struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
684 if (!res)
701 crocus_resource_configure_main(screen, res, templ, modifier, 0);
718 if (!crocus_resource_configure_aux(screen, res, false, &aux_size,
727 MAX2(res->surf.size_B, res->aux.offset + aux_size);
728 uint32_t alignment = MAX2(4096, res->surf.alignment_B);
729 res->bo = crocus_bo_alloc_tiled(screen->bufmgr, name, bo_size, alignment,
730 isl_tiling_to_i915_tiling(res->surf.tiling),
731 res->surf.row_pitch_B, flags);
733 if (!res->bo)
737 res->aux.bo = res->bo;
738 crocus_bo_reference(res->aux.bo);
739 if (!crocus_resource_init_aux_buf(res, flags))
748 .width0 = res->base.b.width0,
749 .height0 = res->base.b.height0,
750 .depth0 = res->base.b.depth0,
751 .last_level = res->base.b.last_level,
752 .nr_samples = res->base.b.nr_samples,
753 .nr_storage_samples = res->base.b.nr_storage_samples,
754 .array_size = res->base.b.array_size,
756 .target = res->base.b.target,
758 res->shadow = (struct crocus_resource *)screen->base.resource_create(&screen->base, &templ_shadow);
759 assert(res->shadow);
762 return &res->base.b;
766 crocus_resource_destroy(pscreen, &res->base.b);
802 struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
803 if (!res)
808 res->internal_format = templ->format;
809 res->bo = crocus_bo_create_userptr(bufmgr, "user",
811 if (!res->bo) {
812 free(res);
816 util_range_add(&res->base.b, &res->valid_buffer_range, 0, templ->width0);
818 return &res->base.b;
831 struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
833 if (!res)
838 res->bo = crocus_bo_import_dmabuf(bufmgr, whandle->handle,
842 res->bo = crocus_bo_gem_create_from_name(bufmgr, "winsys image",
848 if (!res->bo)
851 res->offset = whandle->offset;
852 res->external_format = whandle->format;
857 whandle->modifier : tiling_to_modifier(res->bo->tiling_mode);
860 crocus_resource_configure_main(screen, res, templ, modifier,
863 assert(res->bo->tiling_mode ==
864 isl_tiling_to_i915_tiling(res->surf.tiling));
868 if (!crocus_resource_alloc_separate_aux(screen, res))
871 if (res->mod_info->aux_usage != ISL_AUX_USAGE_NONE) {
874 UNUSED bool ok = crocus_resource_configure_aux(screen, res, true, &size,
887 * from the main image with res->base.next. See
890 res->aux.surf.row_pitch_B = whandle->stride;
891 res->aux.offset = whandle->offset;
892 res->aux.bo = res->bo;
893 res->bo = NULL;
896 return &res->base.b;
899 crocus_resource_destroy(pscreen, &res->base.b);
911 struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
913 if (!res)
922 crocus_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0);
926 res->bo = memobj->bo;
927 res->offset = offset;
928 res->external_format = memobj->format;
932 return &res->base.b;
939 struct crocus_resource *res = (void *) resource;
940 const struct isl_drm_modifier_info *mod = res->mod_info;
942 crocus_resource_prepare_access(ice, res,
953 struct crocus_resource *res = (struct crocus_resource *)resource;
955 res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
962 (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) && res->aux.usage != 0) &&
964 crocus_resource_disable_aux(res);
980 struct crocus_resource *res = (struct crocus_resource *)resource;
982 res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
987 if (crocus_resource_unfinished_aux_import(res))
988 crocus_resource_finish_aux_import(pscreen, res);
990 struct crocus_bo *bo = wants_aux ? res->aux.bo : res->bo;
997 *value = util_format_get_num_planes(res->external_format);
1006 *value = wants_aux ? res->aux.surf.row_pitch_B : res->surf.row_pitch_B;
1009 *value = wants_aux ? res->aux.offset : 0;
1012 *value = res->mod_info ? res->mod_info->modifier :
1013 tiling_to_modifier(isl_tiling_to_i915_tiling(res->surf.tiling));
1050 struct crocus_resource *res = (struct crocus_resource *)resource;
1052 res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE;
1058 assert(res->aux.bo);
1059 bo = res->aux.bo;
1060 whandle->stride = res->aux.surf.row_pitch_B;
1061 whandle->offset = res->aux.offset;
1064 whandle->stride = res->surf.row_pitch_B;
1065 bo = res->bo;
1067 whandle->format = res->external_format;
1069 res->mod_info ? res->mod_info->modifier
1070 : tiling_to_modifier(res->bo->tiling_mode);
1074 res->mod_info ? res->mod_info->aux_usage : ISL_AUX_USAGE_NONE;
1076 if (res->aux.usage != allowed_usage) {
1077 enum isl_aux_state aux_state = crocus_resource_get_aux_state(res, 0, 0);
1107 struct crocus_resource *res)
1109 bool busy = crocus_bo_busy(res->bo);
1112 busy |= crocus_batch_references(&ice->batches[i], res->bo);
1152 struct crocus_resource *res = (void *) resource;
1158 if (res->valid_buffer_range.start > res->valid_buffer_range.end)
1161 if (!resource_is_busy(ice, res)) {
1165 util_range_set_empty(&res->valid_buffer_range);
1172 if (res->bo->userptr)
1175 struct crocus_bo *old_bo = res->bo;
1177 crocus_bo_alloc(screen->bufmgr, res->bo->name, resource->width0);
1183 res->bo = new_bo;
1188 screen->vtbl.rebind_buffer(ice, res);
1190 util_range_set_empty(&res->valid_buffer_range);
1238 struct crocus_resource *res = (void *) xfer->resource;
1251 .format = res->internal_format,
1307 crocus_resource_get_image_offset(struct crocus_resource *res,
1311 get_image_offset_el(&res->surf, level, z, x, y);
1375 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1376 struct isl_surf *surf = &res->surf;
1381 crocus_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
1408 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1409 struct isl_surf *surf = &res->surf;
1429 crocus_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
1481 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1482 struct isl_surf *surf = &res->surf;
1486 crocus_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
1509 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1510 struct isl_surf *surf = &res->surf;
1529 crocus_bo_map(map->dbg, res->bo, (xfer->usage | MAP_RAW) & MAP_FLAGS);
1557 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1559 void *ptr = crocus_bo_map(map->dbg, res->bo, xfer->usage & MAP_FLAGS);
1561 if (res->base.b.target == PIPE_BUFFER) {
1567 struct isl_surf *surf = &res->surf;
1588 can_promote_to_async(const struct crocus_resource *res,
1596 return res->base.b.target == PIPE_BUFFER && (usage & PIPE_MAP_WRITE) &&
1598 !util_ranges_intersect(&res->valid_buffer_range, box->x,
1611 struct crocus_resource *res = (struct crocus_resource *)resource;
1612 struct isl_surf *surf = &res->surf;
1626 can_promote_to_async(res, box, usage)) {
1633 map_would_stall = resource_is_busy(ice, res) ||
1634 crocus_has_invalid_primary(res, level, 1, box->z, box->depth);
1667 util_ranges_intersect(&res->valid_buffer_range, box->x,
1671 util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width);
1693 !crocus_has_invalid_primary(res, level, 1, box->z, box->depth))
1711 crocus_resource_access_raw(ice, res,
1718 if (crocus_batch_references(&ice->batches[i], res->bo))
1742 struct crocus_resource *res = (struct crocus_resource *) xfer->resource;
1750 if (res->base.b.target == PIPE_BUFFER) {
1755 history_flush |= crocus_flush_bits_for_history(res);
1757 util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width);
1778 crocus_dirty_for_history(ice, res);
1814 struct crocus_resource *res)
1818 if (res->bind_history & PIPE_BIND_CONSTANT_BUFFER) {
1819 stage_dirty |= ((uint64_t)res->bind_stages) << CROCUS_SHIFT_FOR_STAGE_DIRTY_CONSTANTS;
1830 crocus_flush_bits_for_history(struct crocus_resource *res)
1834 if (res->bind_history & PIPE_BIND_CONSTANT_BUFFER) {
1839 if (res->bind_history & PIPE_BIND_SAMPLER_VIEW)
1842 if (res->bind_history & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
1845 if (res->bind_history & (PIPE_BIND_SHADER_BUFFER | PIPE_BIND_SHADER_IMAGE))
1854 struct crocus_resource *res,
1858 if (res->base.b.target != PIPE_BUFFER)
1861 uint32_t flush = crocus_flush_bits_for_history(res) | extra_flags;
1865 crocus_dirty_for_history(ice, res);
1870 struct crocus_resource *res,
1873 if (memcmp(&res->aux.clear_color, &color, sizeof(color)) != 0) {
1874 res->aux.clear_color = color;
1882 crocus_resource_get_clear_color(const struct crocus_resource *res)
1884 assert(res->aux.bo);
1886 return res->aux.clear_color;
1892 struct crocus_resource *res = (void *) p_res;
1893 return res->internal_format;