summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/zink/zink_surface.h
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:17:30 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:17:30 +0000
commitca11beabae33eb59fb981b8adf50b1d47a2a98f0 (patch)
tree3e4691a396e6e54cd54224a190663d5cf976625b /lib/mesa/src/gallium/drivers/zink/zink_surface.h
parent27c8a50e8bbde7d28b1fc46d715a4c469e24f2c4 (diff)
Import Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/drivers/zink/zink_surface.h')
-rw-r--r--lib/mesa/src/gallium/drivers/zink/zink_surface.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/lib/mesa/src/gallium/drivers/zink/zink_surface.h b/lib/mesa/src/gallium/drivers/zink/zink_surface.h
index a85a4981c..c8931ca32 100644
--- a/lib/mesa/src/gallium/drivers/zink/zink_surface.h
+++ b/lib/mesa/src/gallium/drivers/zink/zink_surface.h
@@ -25,14 +25,20 @@
#define ZINK_SURFACE_H
#include "pipe/p_state.h"
-
+#include "zink_batch.h"
#include <vulkan/vulkan.h>
struct pipe_context;
struct zink_surface {
struct pipe_surface base;
+ VkImageViewCreateInfo ivci;
VkImageView image_view;
+ VkImageView simage_view;//old iview after storage replacement/rebind
+ void *obj; //backing resource object
+ uint32_t hash;
+ struct zink_batch_usage batch_uses;
+ struct util_dynarray framebuffer_refs;
};
static inline struct zink_surface *
@@ -42,6 +48,54 @@ zink_surface(struct pipe_surface *pipe)
}
void
+zink_destroy_surface(struct zink_screen *screen, struct pipe_surface *psurface);
+
+static inline void
+zink_surface_reference(struct zink_screen *screen, struct zink_surface **dst, struct zink_surface *src)
+{
+ struct zink_surface *old_dst = *dst;
+
+ if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL,
+ src ? &src->base.reference : NULL,
+ (debug_reference_descriptor)
+ debug_describe_surface))
+ zink_destroy_surface(screen, &old_dst->base);
+ *dst = src;
+}
+
+void
zink_context_surface_init(struct pipe_context *context);
+VkImageViewCreateInfo
+create_ivci(struct zink_screen *screen,
+ struct zink_resource *res,
+ const struct pipe_surface *templ);
+
+struct pipe_surface *
+zink_get_surface(struct zink_context *ctx,
+ struct pipe_resource *pres,
+ const struct pipe_surface *templ,
+ VkImageViewCreateInfo *ivci);
+
+static inline VkImageViewType
+zink_surface_clamp_viewtype(VkImageViewType viewType, unsigned first_layer, unsigned last_layer, unsigned array_size)
+{
+ unsigned layerCount = 1 + last_layer - first_layer;
+ if (viewType == VK_IMAGE_VIEW_TYPE_CUBE || viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) {
+ if (first_layer == last_layer)
+ return VK_IMAGE_VIEW_TYPE_2D;
+ if (layerCount % 6 == 0) {
+ if (viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && layerCount == 6)
+ return VK_IMAGE_VIEW_TYPE_CUBE;
+ } else if (first_layer || layerCount != array_size)
+ return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
+ } else if (viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY) {
+ if (first_layer == last_layer)
+ return VK_IMAGE_VIEW_TYPE_2D;
+ }
+ return viewType;
+}
+
+bool
+zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface);
#endif