Lines Matching defs:surface
110 init_surface_info(struct zink_surface *surface, struct zink_resource *res, VkImageViewCreateInfo *ivci)
113 surface->info.flags = res->obj->vkflags;
114 surface->info.usage = usage_info ? usage_info->usage : res->obj->vkusage;
115 surface->info.width = surface->base.width;
116 surface->info.height = surface->base.height;
117 surface->info.layerCount = ivci->subresourceRange.layerCount;
118 surface->info.format[0] = ivci->format;
122 surface->info.format[1] = ivci->format == cdt->formats[0] ? cdt->formats[1] : cdt->formats[0];
124 surface->info_hash = _mesa_hash_data(&surface->info, sizeof(surface->info));
138 struct zink_surface *surface = CALLOC_STRUCT(zink_surface);
139 if (!surface)
163 pipe_resource_reference(&surface->base.texture, pres);
164 pipe_reference_init(&surface->base.reference, 1);
165 surface->base.context = pctx;
166 surface->base.format = templ->format;
167 surface->base.width = u_minify(pres->width0, level);
168 assert(surface->base.width);
169 surface->base.height = u_minify(pres->height0, level);
170 assert(surface->base.height);
171 surface->base.nr_samples = templ->nr_samples;
172 surface->base.u.tex.level = level;
173 surface->base.u.tex.first_layer = templ->u.tex.first_layer;
174 surface->base.u.tex.last_layer = templ->u.tex.last_layer;
175 surface->obj = zink_resource(pres)->obj;
176 util_dynarray_init(&surface->desc_set_refs.refs, NULL);
178 init_surface_info(surface, res, ivci);
181 return surface;
184 &surface->image_view);
187 FREE(surface);
191 return surface;
203 /* create a new surface */
204 struct zink_surface *surface = create_surface(pctx, pres, templ, ivci, actually);
205 surface->base.nr_samples = 0;
206 surface->hash = hash;
207 surface->ivci = *ivci;
208 return surface;
217 struct zink_surface *surface = NULL;
225 /* create a new surface */
226 surface = do_create_surface(&ctx->base, pres, templ, ivci, hash, true);
227 entry = _mesa_hash_table_insert_pre_hashed(&res->surface_cache, hash, &surface->ivci, surface);
233 surface = entry->data;
235 surface = entry->data;
236 p_atomic_inc(&surface->base.reference.count);
240 return &surface->base;
269 struct zink_surface *surface = do_create_surface(pctx, pres, templ, &ivci, 0, false);
270 if (surface) {
271 surface->is_swapchain = true;
272 psurf = &surface->base;
305 struct zink_surface *surface = zink_surface(psurface);
307 if (!psurface->nr_samples && !surface->is_swapchain) {
314 struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&res->surface_cache, surface->hash, &surface->ivci);
316 assert(he->data == surface);
320 zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
321 if (surface->simage_view)
322 VKSCR(DestroyImageView)(screen->dev, surface->simage_view, NULL);
323 if (surface->is_swapchain) {
324 for (unsigned i = 0; i < surface->old_swapchain_size; i++)
325 VKSCR(DestroyImageView)(screen->dev, surface->old_swapchain[i], NULL);
326 for (unsigned i = 0; i < surface->swapchain_size; i++)
327 VKSCR(DestroyImageView)(screen->dev, surface->swapchain[i], NULL);
328 free(surface->swapchain);
330 VKSCR(DestroyImageView)(screen->dev, surface->image_view, NULL);
332 FREE(surface);
348 struct zink_surface *surface = zink_surface(*psurface);
351 if (surface->simage_view)
354 VkImageViewCreateInfo ivci = surface->ivci;
360 if (zink_batch_usage_exists(surface->batch_uses))
361 zink_batch_reference_surface(&ctx->batch, surface);
362 zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
364 /* reuse existing surface; old one will be cleaned up naturally */
371 struct hash_entry *entry = _mesa_hash_table_search_pre_hashed(&res->surface_cache, surface->hash, &surface->ivci);
381 surface->hash = hash;
382 surface->ivci = ivci;
383 entry = _mesa_hash_table_insert_pre_hashed(&res->surface_cache, surface->hash, &surface->ivci, surface);
385 surface->simage_view = surface->image_view;
386 surface->image_view = image_view;
387 surface->obj = zink_resource(surface->base.texture)->obj;
389 surface->info.flags = res->obj->vkflags;
390 surface->info.usage = res->obj->vkusage;
391 surface->info_hash = _mesa_hash_data(&surface->info, sizeof(surface->info));
392 zink_batch_usage_set(&surface->batch_uses, ctx->batch.state);
433 zink_surface_swapchain_update(struct zink_context *ctx, struct zink_surface *surface)
436 struct zink_resource *res = zink_resource(surface->base.texture);
440 if (res->obj->dt != surface->dt) {
442 for (unsigned i = 0; i < surface->old_swapchain_size; i++)
443 util_dynarray_append(&ctx->batch.state->dead_swapchains, VkImageView, surface->old_swapchain[i]);
444 free(surface->old_swapchain);
445 surface->old_swapchain = surface->swapchain;
446 surface->old_swapchain_size = surface->swapchain_size;
447 surface->swapchain_size = cdt->swapchain->num_images;
448 surface->swapchain = calloc(surface->swapchain_size, sizeof(VkImageView));
449 surface->base.width = res->base.b.width0;
450 surface->base.height = res->base.b.height0;
451 init_surface_info(surface, res, &surface->ivci);
453 if (!surface->swapchain[res->obj->dt_idx]) {
455 surface->ivci.image = res->obj->image;
456 assert(surface->ivci.image);
457 VKSCR(CreateImageView)(screen->dev, &surface->ivci, NULL, &surface->swapchain[res->obj->dt_idx]);
459 surface->image_view = surface->swapchain[res->obj->dt_idx];