#ifndef RADV_RADEON_WINSYS_H
#define RADV_RADEON_WINSYS_H
+#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
RADEON_FLAG_GTT_WC = (1 << 0),
RADEON_FLAG_CPU_ACCESS = (1 << 1),
RADEON_FLAG_NO_CPU_ACCESS = (1 << 2),
- RADEON_FLAG_VIRTUAL = (1 << 3)
+ RADEON_FLAG_VIRTUAL = (1 << 3),
+ RADEON_FLAG_VA_UNCACHED = (1 << 4),
+ RADEON_FLAG_IMPLICIT_SYNC = (1 << 5),
+ RADEON_FLAG_NO_INTERPROCESS_SHARING = (1 << 6),
+ RADEON_FLAG_READ_ONLY = (1 << 7),
};
enum radeon_bo_usage { /* bitfield */
RING_LAST,
};
+enum radeon_ctx_priority {
+ RADEON_CTX_PRIORITY_INVALID = -1,
+ RADEON_CTX_PRIORITY_LOW = 0,
+ RADEON_CTX_PRIORITY_MEDIUM,
+ RADEON_CTX_PRIORITY_HIGH,
+ RADEON_CTX_PRIORITY_REALTIME,
+};
+
+enum radeon_value_id {
+ RADEON_TIMESTAMP,
+ RADEON_NUM_BYTES_MOVED,
+ RADEON_NUM_EVICTIONS,
+ RADEON_NUM_VRAM_CPU_PAGE_FAULTS,
+ RADEON_VRAM_USAGE,
+ RADEON_VRAM_VIS_USAGE,
+ RADEON_GTT_USAGE,
+ RADEON_GPU_TEMPERATURE,
+ RADEON_CURRENT_SCLK,
+ RADEON_CURRENT_MCLK,
+};
+
struct radeon_winsys_cs {
unsigned cdw; /* Number of used dwords. */
unsigned max_dw; /* Maximum number of dwords. */
/* Tiling flags describing the texture layout for display code
* and DRI sharing.
*/
- enum radeon_bo_layout microtile;
- enum radeon_bo_layout macrotile;
- unsigned pipe_config;
- unsigned bankw;
- unsigned bankh;
- unsigned tile_split;
- unsigned mtilea;
- unsigned num_banks;
- unsigned stride;
- bool scanout;
+ union {
+ struct {
+ enum radeon_bo_layout microtile;
+ enum radeon_bo_layout macrotile;
+ unsigned pipe_config;
+ unsigned bankw;
+ unsigned bankh;
+ unsigned tile_split;
+ unsigned mtilea;
+ unsigned num_banks;
+ unsigned stride;
+ bool scanout;
+ } legacy;
+
+ struct {
+ /* surface flags */
+ unsigned swizzle_mode:5;
+ } gfx9;
+ } u;
/* Additional metadata associated with the buffer, in bytes.
* The maximum size is 64 * 4. This is opaque for the winsys & kernel.
uint32_t metadata[64];
};
-struct radeon_winsys_bo;
+uint32_t syncobj_handle;
struct radeon_winsys_fence;
-struct radeon_winsys_sem;
+
+struct radeon_winsys_bo {
+ uint64_t va;
+ bool is_local;
+};
+struct radv_winsys_sem_counts {
+ uint32_t syncobj_count;
+ uint32_t sem_count;
+ uint32_t *syncobj;
+ struct radeon_winsys_sem **sem;
+};
+
+struct radv_winsys_sem_info {
+ bool cs_emit_signal;
+ bool cs_emit_wait;
+ struct radv_winsys_sem_counts wait;
+ struct radv_winsys_sem_counts signal;
+};
struct radeon_winsys {
void (*destroy)(struct radeon_winsys *ws);
void (*query_info)(struct radeon_winsys *ws,
struct radeon_info *info);
+ uint64_t (*query_value)(struct radeon_winsys *ws,
+ enum radeon_value_id value);
+
+ bool (*read_registers)(struct radeon_winsys *ws, unsigned reg_offset,
+ unsigned num_registers, uint32_t *out);
+
+ const char *(*get_chip_name)(struct radeon_winsys *ws);
+
struct radeon_winsys_bo *(*buffer_create)(struct radeon_winsys *ws,
uint64_t size,
unsigned alignment,
void (*buffer_destroy)(struct radeon_winsys_bo *bo);
void *(*buffer_map)(struct radeon_winsys_bo *bo);
+ struct radeon_winsys_bo *(*buffer_from_ptr)(struct radeon_winsys *ws,
+ void *pointer,
+ uint64_t size);
+
struct radeon_winsys_bo *(*buffer_from_fd)(struct radeon_winsys *ws,
int fd,
unsigned *stride, unsigned *offset);
void (*buffer_unmap)(struct radeon_winsys_bo *bo);
- uint64_t (*buffer_get_va)(struct radeon_winsys_bo *bo);
-
void (*buffer_set_metadata)(struct radeon_winsys_bo *bo,
struct radeon_bo_metadata *md);
void (*buffer_virtual_bind)(struct radeon_winsys_bo *parent,
uint64_t offset, uint64_t size,
struct radeon_winsys_bo *bo, uint64_t bo_offset);
- struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws);
+ struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws,
+ enum radeon_ctx_priority priority);
void (*ctx_destroy)(struct radeon_winsys_ctx *ctx);
bool (*ctx_wait_idle)(struct radeon_winsys_ctx *ctx,
unsigned cs_count,
struct radeon_winsys_cs *initial_preamble_cs,
struct radeon_winsys_cs *continue_preamble_cs,
- struct radeon_winsys_sem **wait_sem,
- unsigned wait_sem_count,
- struct radeon_winsys_sem **signal_sem,
- unsigned signal_sem_count,
+ struct radv_winsys_sem_info *sem_info,
bool can_patch,
struct radeon_winsys_fence *fence);
void (*cs_execute_secondary)(struct radeon_winsys_cs *parent,
struct radeon_winsys_cs *child);
- void (*cs_dump)(struct radeon_winsys_cs *cs, FILE* file, uint32_t trace_id);
+ void (*cs_dump)(struct radeon_winsys_cs *cs, FILE* file, const int *trace_ids, int trace_id_count);
int (*surface_init)(struct radeon_winsys *ws,
const struct ac_surf_info *surf_info,
struct radeon_winsys_fence *fence,
bool absolute,
uint64_t timeout);
+ bool (*fences_wait)(struct radeon_winsys *ws,
+ struct radeon_winsys_fence *const *fences,
+ uint32_t fence_count,
+ bool wait_all,
+ uint64_t timeout);
+ /* old semaphores - non shareable */
struct radeon_winsys_sem *(*create_sem)(struct radeon_winsys *ws);
void (*destroy_sem)(struct radeon_winsys_sem *sem);
+ /* new shareable sync objects */
+ int (*create_syncobj)(struct radeon_winsys *ws, uint32_t *handle);
+ void (*destroy_syncobj)(struct radeon_winsys *ws, uint32_t handle);
+
+ void (*reset_syncobj)(struct radeon_winsys *ws, uint32_t handle);
+ void (*signal_syncobj)(struct radeon_winsys *ws, uint32_t handle);
+ bool (*wait_syncobj)(struct radeon_winsys *ws, const uint32_t *handles, uint32_t handle_count,
+ bool wait_all, uint64_t timeout);
+
+ int (*export_syncobj)(struct radeon_winsys *ws, uint32_t syncobj, int *fd);
+ int (*import_syncobj)(struct radeon_winsys *ws, int fd, uint32_t *syncobj);
+
+ int (*export_syncobj_to_sync_file)(struct radeon_winsys *ws, uint32_t syncobj, int *fd);
+
+ /* Note that this, unlike the normal import, uses an existing syncobj. */
+ int (*import_syncobj_from_sync_file)(struct radeon_winsys *ws, uint32_t syncobj, int fd);
+
};
static inline void radeon_emit(struct radeon_winsys_cs *cs, uint32_t value)
cs->cdw += count;
}
+static inline uint64_t radv_buffer_get_va(struct radeon_winsys_bo *bo)
+{
+ return bo->va;
+}
+
+static inline void radv_cs_add_buffer(struct radeon_winsys *ws,
+ struct radeon_winsys_cs *cs,
+ struct radeon_winsys_bo *bo,
+ uint8_t priority)
+{
+ if (bo->is_local)
+ return;
+
+ ws->cs_add_buffer(cs, bo, priority);
+}
+
#endif /* RADV_RADEON_WINSYS_H */