summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/zink/zink_surface.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/zink/zink_surface.h')
-rw-r--r--src/gallium/drivers/zink/zink_surface.h65
1 files changed, 7 insertions, 58 deletions
diff --git a/src/gallium/drivers/zink/zink_surface.h b/src/gallium/drivers/zink/zink_surface.h
index 617084d39e8..9207b2e8b89 100644
--- a/src/gallium/drivers/zink/zink_surface.h
+++ b/src/gallium/drivers/zink/zink_surface.h
@@ -24,56 +24,7 @@
#ifndef ZINK_SURFACE_H
#define ZINK_SURFACE_H
-#include "pipe/p_state.h"
-#include "zink_batch.h"
-#include <vulkan/vulkan.h>
-
-struct pipe_context;
-
-struct zink_surface_info {
- VkImageCreateFlags flags;
- VkImageUsageFlags usage;
- uint32_t width;
- uint32_t height;
- uint32_t layerCount;
- VkFormat format;
-};
-
-struct zink_surface {
- struct pipe_surface base;
- VkImageViewCreateInfo ivci;
- struct zink_surface_info info; //TODO: union with fb refs
- uint32_t info_hash;
- 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;
- struct zink_descriptor_refs desc_set_refs;
-};
-
-/* wrapper object that preserves the gallium expectation of having
- * pipe_surface::context match the context used to create the surface
- */
-struct zink_ctx_surface {
- struct pipe_surface base;
- struct zink_surface *surf;
-};
-
-/* use this cast for framebuffer surfaces */
-static inline struct zink_surface *
-zink_csurface(struct pipe_surface *psurface)
-{
- return psurface ? ((struct zink_ctx_surface *)psurface)->surf : NULL;
-}
-
-/* use this cast for internal surfaces */
-static inline struct zink_surface *
-zink_surface(struct pipe_surface *psurface)
-{
- return (struct zink_surface *)psurface;
-}
+#include "zink_types.h"
void
zink_destroy_surface(struct zink_screen *screen, struct pipe_surface *psurface);
@@ -100,12 +51,13 @@ create_ivci(struct zink_screen *screen,
const struct pipe_surface *templ,
enum pipe_texture_target target);
-struct pipe_surface *
+struct zink_surface *
zink_get_surface(struct zink_context *ctx,
struct pipe_resource *pres,
const struct pipe_surface *templ,
VkImageViewCreateInfo *ivci);
+/* cube image types are clamped by gallium rules to 2D or 2D_ARRAY viewtypes if not using all layers */
static inline VkImageViewType
zink_surface_clamp_viewtype(VkImageViewType viewType, unsigned first_layer, unsigned last_layer, unsigned array_size)
{
@@ -113,14 +65,8 @@ zink_surface_clamp_viewtype(VkImageViewType viewType, unsigned first_layer, unsi
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)
+ if (layerCount % 6 != 0 && (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;
}
@@ -137,4 +83,7 @@ zink_rebind_ctx_surface(struct zink_context *ctx, struct pipe_surface **psurface
struct pipe_surface *
zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target target, unsigned width, unsigned height, unsigned samples);
+
+void
+zink_surface_swapchain_update(struct zink_context *ctx, struct zink_surface *surface);
#endif