mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 02:10:12 +01:00
zink: explicitly use zink_surface objects for sampler/image view objects
we can reuse this codepath instead of NIHing it Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543>
This commit is contained in:
parent
054f53e3d0
commit
5acbba4e41
3 changed files with 14 additions and 6 deletions
|
|
@ -629,7 +629,13 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
|
|||
ivci.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
||||
}
|
||||
|
||||
err = vkCreateImageView(screen->dev, &ivci, NULL, &sampler_view->image_view) != VK_SUCCESS;
|
||||
struct pipe_surface templ = {};
|
||||
templ.u.tex.level = state->u.tex.first_level;
|
||||
templ.format = state->format;
|
||||
templ.u.tex.first_layer = state->u.tex.first_layer;
|
||||
templ.u.tex.last_layer = state->u.tex.last_layer;
|
||||
sampler_view->image_view = (struct zink_surface*)zink_get_surface(zink_context(pctx), pres, &templ, &ivci);
|
||||
err = !sampler_view->image_view;
|
||||
} else {
|
||||
sampler_view->buffer_view = get_buffer_view(zink_context(pctx), res, state->format, state->u.buf.offset, state->u.buf.size);
|
||||
err = !sampler_view->buffer_view;
|
||||
|
|
@ -658,8 +664,10 @@ zink_sampler_view_destroy(struct pipe_context *pctx,
|
|||
zink_descriptor_set_refs_clear(&view->desc_set_refs, view);
|
||||
if (pview->texture->target == PIPE_BUFFER)
|
||||
zink_buffer_view_reference(zink_context(pctx), &view->buffer_view, NULL);
|
||||
else
|
||||
vkDestroyImageView(zink_screen(pctx->screen)->dev, view->image_view, NULL);
|
||||
else {
|
||||
struct pipe_surface *psurf = &view->image_view->base;
|
||||
pipe_surface_reference(&psurf, NULL);
|
||||
}
|
||||
pipe_resource_reference(&pview->texture, NULL);
|
||||
FREE(view);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "zink_batch.h"
|
||||
#include "zink_compiler.h"
|
||||
#include "zink_descriptors.h"
|
||||
#include "zink_surface.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
|
@ -56,7 +57,6 @@ struct zink_depth_stencil_alpha_state;
|
|||
struct zink_gfx_program;
|
||||
struct zink_rasterizer_state;
|
||||
struct zink_resource;
|
||||
struct zink_surface;
|
||||
struct zink_vertex_elements_state;
|
||||
|
||||
enum zink_blit_flags {
|
||||
|
|
@ -83,7 +83,7 @@ struct zink_sampler_view {
|
|||
struct pipe_sampler_view base;
|
||||
struct zink_descriptor_refs desc_set_refs;
|
||||
union {
|
||||
VkImageView image_view;
|
||||
struct zink_surface *image_view;
|
||||
struct zink_buffer_view *buffer_view;
|
||||
};
|
||||
uint32_t hash;
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ update_sampler_descriptors(struct zink_context *ctx, struct zink_descriptor_set
|
|||
if (res && res->base.target == PIPE_BUFFER) {
|
||||
bufferview = sampler_view->buffer_view->buffer_view;
|
||||
} else if (res) {
|
||||
imageview = sampler_view->image_view;
|
||||
imageview = sampler_view->image_view->image_view;
|
||||
layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
sampler = ctx->sampler_states[stage][index + k];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue