#include "virgl_screen.h"
#define VR_MAX_TEXTURE_2D_LEVELS 15
-/* Indicates that the resource will be used as a staging buffer, not requiring
- * dedicated host-side storage. Can only be used with PIPE_BUFFER resources
- * that have a PIPE_BIND_CUSTOM bind type.
- */
-#define VIRGL_RESOURCE_FLAG_STAGING (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
-
struct winsys_handle;
struct virgl_screen;
struct virgl_context;
unsigned long level_offset[VR_MAX_TEXTURE_2D_LEVELS];
unsigned stride[VR_MAX_TEXTURE_2D_LEVELS];
unsigned layer_stride[VR_MAX_TEXTURE_2D_LEVELS];
- uint32_t total_size;
+ uint32_t plane, plane_offset, total_size;
+ uint64_t modifier;
};
struct virgl_resource {
/* For PIPE_BUFFER only. Data outside of this range are uninitialized. */
struct util_range valid_buffer_range;
-};
-enum virgl_transfer_map_type {
- VIRGL_TRANSFER_MAP_ERROR = -1,
- VIRGL_TRANSFER_MAP_HW_RES,
+ /* This mask indicates where the resource has been bound to, excluding
+ * pipe_surface binds.
+ *
+ * This is more accurate than pipe_resource::bind. Besides,
+ * pipe_resource::bind can be 0 with direct state access, and is not
+ * usable.
+ */
+ unsigned bind_history;
};
struct virgl_transfer {
struct util_range range;
struct list_head queue_link;
struct pipe_transfer *resolve_transfer;
+
+ struct virgl_hw_res *hw_res;
void *hw_res_map;
/* If not NULL, denotes that this is a copy transfer, i.e.,
* that the transfer source data should be taken from this
* resource instead of the original transfer resource.
*/
- struct pipe_resource *copy_src_res;
+ struct virgl_hw_res *copy_src_hw_res;
/* The offset in the copy source resource to copy data from. */
uint32_t copy_src_offset;
};
outbind |= VIRGL_BIND_STREAM_OUTPUT;
if (pbind & PIPE_BIND_CURSOR)
outbind |= VIRGL_BIND_CURSOR;
- if (pbind & PIPE_BIND_CUSTOM) {
- if (flags & VIRGL_RESOURCE_FLAG_STAGING)
- outbind |= VIRGL_BIND_STAGING;
- else
- outbind |= VIRGL_BIND_CUSTOM;
- }
+ if (pbind & PIPE_BIND_CUSTOM)
+ outbind |= VIRGL_BIND_CUSTOM;
if (pbind & PIPE_BIND_SCANOUT)
outbind |= VIRGL_BIND_SCANOUT;
+ if (pbind & PIPE_BIND_SHARED)
+ outbind |= VIRGL_BIND_SHARED;
if (pbind & PIPE_BIND_SHADER_BUFFER)
outbind |= VIRGL_BIND_SHADER_BUFFER;
if (pbind & PIPE_BIND_QUERY_BUFFER)
if (pbind & PIPE_BIND_COMMAND_ARGS_BUFFER)
if (vs->caps.caps.v2.capability_bits & VIRGL_CAP_BIND_COMMAND_ARGS)
outbind |= VIRGL_BIND_COMMAND_ARGS;
+
+ /* Staging resources should only be created directly through the winsys,
+ * not using pipe_resources.
+ */
+ assert(!(outbind & VIRGL_BIND_STAGING));
+
return outbind;
}
-enum virgl_transfer_map_type
-virgl_resource_transfer_prepare(struct virgl_context *vctx,
- struct virgl_transfer *xfer);
-
-void virgl_resource_layout(struct pipe_resource *pt,
- struct virgl_resource_metadata *metadata);
+void *
+virgl_resource_transfer_map(struct pipe_context *ctx,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer);
struct virgl_transfer *
-virgl_resource_create_transfer(struct slab_child_pool *pool,
+virgl_resource_create_transfer(struct virgl_context *vctx,
struct pipe_resource *pres,
const struct virgl_resource_metadata *metadata,
unsigned level, unsigned usage,
const struct pipe_box *box);
-void virgl_resource_destroy_transfer(struct slab_child_pool *pool,
+void virgl_resource_destroy_transfer(struct virgl_context *vctx,
struct virgl_transfer *trans);
void virgl_resource_destroy(struct pipe_screen *screen,
struct pipe_resource *resource);
-boolean virgl_resource_get_handle(struct pipe_screen *screen,
- struct pipe_resource *resource,
- struct winsys_handle *whandle);
+bool virgl_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *whandle);
void virgl_resource_dirty(struct virgl_resource *res, uint32_t level);