XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Enumerations
asahi_drm.h File Reference
#include "drm.h"
Include dependency graph for asahi_drm.h:

Go to the source code of this file.

Classes

struct  drm_asahi_params_global
 
struct  drm_asahi_get_params
 
struct  drm_asahi_vm_create
 
struct  drm_asahi_vm_destroy
 
struct  drm_asahi_gem_create
 
struct  drm_asahi_gem_mmap_offset
 
struct  drm_asahi_gem_bind_op
 
struct  drm_asahi_vm_bind
 
struct  drm_asahi_gem_bind_object
 
struct  drm_asahi_queue_create
 
struct  drm_asahi_queue_destroy
 
struct  drm_asahi_sync
 
struct  drm_asahi_cmd_header
 
struct  drm_asahi_submit
 
struct  drm_asahi_attachment
 
struct  drm_asahi_zls_buffer
 
struct  drm_asahi_timestamp
 
struct  drm_asahi_timestamps
 
struct  drm_asahi_helper_program
 
struct  drm_asahi_bg_eot
 
struct  drm_asahi_cmd_render
 
struct  drm_asahi_cmd_compute
 
struct  drm_asahi_get_time
 

Macros

#define DRM_ASAHI_MAX_CLUSTERS   64
 
#define DRM_ASAHI_BARRIER_NONE   (0xFFFFu)
 
#define DRM_IOCTL_ASAHI(__access, __id, __type)
 

Enumerations

enum  drm_asahi_ioctl_id {
  DRM_ASAHI_GET_PARAMS = 0 , DRM_ASAHI_GET_TIME , DRM_ASAHI_VM_CREATE , DRM_ASAHI_VM_DESTROY ,
  DRM_ASAHI_VM_BIND , DRM_ASAHI_GEM_CREATE , DRM_ASAHI_GEM_MMAP_OFFSET , DRM_ASAHI_GEM_BIND_OBJECT ,
  DRM_ASAHI_QUEUE_CREATE , DRM_ASAHI_QUEUE_DESTROY , DRM_ASAHI_SUBMIT
}
 
enum  drm_asahi_feature { DRM_ASAHI_FEATURE_SOFT_FAULTS = (1UL) << 0 }
 
enum  drm_asahi_gem_flags { DRM_ASAHI_GEM_WRITEBACK = (1L << 0) , DRM_ASAHI_GEM_VM_PRIVATE = (1L << 1) }
 
enum  drm_asahi_bind_flags { DRM_ASAHI_BIND_UNBIND = (1L << 0) , DRM_ASAHI_BIND_READ = (1L << 1) , DRM_ASAHI_BIND_WRITE = (1L << 2) , DRM_ASAHI_BIND_SINGLE_PAGE = (1L << 3) }
 
enum  drm_asahi_bind_object_op { DRM_ASAHI_BIND_OBJECT_OP_BIND = 0 , DRM_ASAHI_BIND_OBJECT_OP_UNBIND = 1 }
 
enum  drm_asahi_bind_object_flags { DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS = (1L << 0) }
 
enum  drm_asahi_cmd_type {
  DRM_ASAHI_CMD_RENDER = 0 , DRM_ASAHI_CMD_COMPUTE = 1 , DRM_ASAHI_SET_VERTEX_ATTACHMENTS = 2 , DRM_ASAHI_SET_FRAGMENT_ATTACHMENTS = 3 ,
  DRM_ASAHI_SET_COMPUTE_ATTACHMENTS = 4
}
 
enum  drm_asahi_priority { DRM_ASAHI_PRIORITY_LOW = 0 , DRM_ASAHI_PRIORITY_MEDIUM = 1 , DRM_ASAHI_PRIORITY_HIGH = 2 , DRM_ASAHI_PRIORITY_REALTIME = 3 }
 
enum  drm_asahi_sync_type { DRM_ASAHI_SYNC_SYNCOBJ = 0 , DRM_ASAHI_SYNC_TIMELINE_SYNCOBJ = 1 }
 
enum  drm_asahi_render_flags { DRM_ASAHI_RENDER_VERTEX_SCRATCH = (1U << 0) , DRM_ASAHI_RENDER_PROCESS_EMPTY_TILES = (1U << 1) , DRM_ASAHI_RENDER_NO_VERTEX_CLUSTERING = (1U << 2) , DRM_ASAHI_RENDER_DBIAS_IS_INT = (1U << 18) }
 
enum  {
  DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOCTL_ASAHI(W, GET_PARAMS, get_params) , DRM_IOCTL_ASAHI_GET_TIME = DRM_IOCTL_ASAHI(WR, GET_TIME, get_time) , DRM_IOCTL_ASAHI_VM_CREATE = DRM_IOCTL_ASAHI(WR, VM_CREATE, vm_create) , DRM_IOCTL_ASAHI_VM_DESTROY = DRM_IOCTL_ASAHI(W, VM_DESTROY, vm_destroy) ,
  DRM_IOCTL_ASAHI_VM_BIND = DRM_IOCTL_ASAHI(W, VM_BIND, vm_bind) , DRM_IOCTL_ASAHI_GEM_CREATE = DRM_IOCTL_ASAHI(WR, GEM_CREATE, gem_create) , DRM_IOCTL_ASAHI_GEM_MMAP_OFFSET = DRM_IOCTL_ASAHI(WR, GEM_MMAP_OFFSET, gem_mmap_offset) , DRM_IOCTL_ASAHI_GEM_BIND_OBJECT = DRM_IOCTL_ASAHI(WR, GEM_BIND_OBJECT, gem_bind_object) ,
  DRM_IOCTL_ASAHI_QUEUE_CREATE = DRM_IOCTL_ASAHI(WR, QUEUE_CREATE, queue_create) , DRM_IOCTL_ASAHI_QUEUE_DESTROY = DRM_IOCTL_ASAHI(W, QUEUE_DESTROY, queue_destroy) , DRM_IOCTL_ASAHI_SUBMIT = DRM_IOCTL_ASAHI(W, SUBMIT, submit)
}
 

Macro Definition Documentation

◆ DRM_ASAHI_BARRIER_NONE

#define DRM_ASAHI_BARRIER_NONE   (0xFFFFu)

define DRM_ASAHI_BARRIER_NONE - Command index for no barrier

This special value may be passed in to drm_asahi_command::vdm_barrier or drm_asahi_command::cdm_barrier to indicate that the respective subqueue should not wait on any previous work.

◆ DRM_ASAHI_MAX_CLUSTERS

#define DRM_ASAHI_MAX_CLUSTERS   64

◆ DRM_IOCTL_ASAHI

#define DRM_IOCTL_ASAHI (   __access,
  __id,
  __type 
)
Value:
DRM_IO ## __access(DRM_COMMAND_BASE + DRM_ASAHI_ ## __id, \
struct drm_asahi_ ## __type)
#define DRM_COMMAND_BASE
Definition drm.h:1363
#define DRM_IO(nr)
Definition drm.h:1077

DRM_IOCTL_ASAHI() - Build an Asahi IOCTL number @__access: Access type. Must be R, W or RW. @__id: One of the DRM_ASAHI_xxx id. @__type: Suffix of the type being passed to the IOCTL.

Don't use this macro directly, use the DRM_IOCTL_ASAHI_xxx values instead.

Return: An IOCTL number to be passed to ioctl() from userspace.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DRM_IOCTL_ASAHI_GET_PARAMS 
DRM_IOCTL_ASAHI_GET_TIME 
DRM_IOCTL_ASAHI_VM_CREATE 
DRM_IOCTL_ASAHI_VM_DESTROY 
DRM_IOCTL_ASAHI_VM_BIND 
DRM_IOCTL_ASAHI_GEM_CREATE 
DRM_IOCTL_ASAHI_GEM_MMAP_OFFSET 
DRM_IOCTL_ASAHI_GEM_BIND_OBJECT 
DRM_IOCTL_ASAHI_QUEUE_CREATE 
DRM_IOCTL_ASAHI_QUEUE_DESTROY 
DRM_IOCTL_ASAHI_SUBMIT 

◆ drm_asahi_bind_flags

enum drm_asahi_bind_flags - Flags for GEM binding

Enumerator
DRM_ASAHI_BIND_UNBIND 

@DRM_ASAHI_BIND_UNBIND: Instead of binding a GEM object to the range, simply unbind the GPU VMA range.

DRM_ASAHI_BIND_READ 

@DRM_ASAHI_BIND_READ: Map BO with GPU read permission

DRM_ASAHI_BIND_WRITE 

@DRM_ASAHI_BIND_WRITE: Map BO with GPU write permission

DRM_ASAHI_BIND_SINGLE_PAGE 

@DRM_ASAHI_BIND_SINGLE_PAGE: Map a single page of the BO repeatedly across the VA range.

This is useful to fill a VA range with scratch pages or zero pages. It is intended as a mechanism to accelerate sparse.

◆ drm_asahi_bind_object_flags

enum drm_asahi_bind_object_flags - Special object bind flags

Enumerator
DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS 

@DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS: Map a BO as a timestamp buffer.

◆ drm_asahi_bind_object_op

enum drm_asahi_bind_object_op - Special object bind operation

Enumerator
DRM_ASAHI_BIND_OBJECT_OP_BIND 

@DRM_ASAHI_BIND_OBJECT_OP_BIND: Bind a BO as a special GPU object

DRM_ASAHI_BIND_OBJECT_OP_UNBIND 

@DRM_ASAHI_BIND_OBJECT_OP_UNBIND: Unbind a special GPU object

◆ drm_asahi_cmd_type

enum drm_asahi_cmd_type - Command type

Enumerator
DRM_ASAHI_CMD_RENDER 

@DRM_ASAHI_CMD_RENDER: Render command, executing on the render subqueue. Combined vertex and fragment operation.

Followed by a @drm_asahi_cmd_render payload.

DRM_ASAHI_CMD_COMPUTE 

@DRM_ASAHI_CMD_COMPUTE: Compute command on the compute subqueue.

Followed by a @drm_asahi_cmd_compute payload.

DRM_ASAHI_SET_VERTEX_ATTACHMENTS 

@DRM_ASAHI_SET_VERTEX_ATTACHMENTS: Software command to set attachments for subsequent vertex shaders in the same submit.

Followed by (possibly multiple) @drm_asahi_attachment payloads.

DRM_ASAHI_SET_FRAGMENT_ATTACHMENTS 

@DRM_ASAHI_SET_FRAGMENT_ATTACHMENTS: Software command to set attachments for subsequent fragment shaders in the same submit.

Followed by (possibly multiple) @drm_asahi_attachment payloads.

DRM_ASAHI_SET_COMPUTE_ATTACHMENTS 

@DRM_ASAHI_SET_COMPUTE_ATTACHMENTS: Software command to set attachments for subsequent compute shaders in the same submit.

Followed by (possibly multiple) @drm_asahi_attachment payloads.

◆ drm_asahi_feature

enum drm_asahi_feature - Feature bits

This covers only features that userspace cannot infer from the architecture version. Most features don't need to be here.

Enumerator
DRM_ASAHI_FEATURE_SOFT_FAULTS 

@DRM_ASAHI_FEATURE_SOFT_FAULTS: GPU has "soft fault" enabled. Shader loads of unmapped memory will return zero. Shader stores to unmapped memory will be silently discarded. Note that only shader load/store is affected. Other hardware units are not affected, notably including texture sampling.

Soft fault is set when initializing the GPU and cannot be runtime toggled. Therefore, it is exposed as a feature bit and not a userspace-settable flag on the VM. When soft fault is enabled, userspace can speculate memory accesses more aggressively.

◆ drm_asahi_gem_flags

enum drm_asahi_gem_flags - Flags for GEM creation

Enumerator
DRM_ASAHI_GEM_WRITEBACK 

@DRM_ASAHI_GEM_WRITEBACK: BO should be CPU-mapped as writeback.

Map as writeback instead of write-combine. This optimizes for CPU reads.

DRM_ASAHI_GEM_VM_PRIVATE 

@DRM_ASAHI_GEM_VM_PRIVATE: BO is private to this GPU VM (no exports).

◆ drm_asahi_ioctl_id

DOC: Introduction to the Asahi UAPI

This documentation describes the Asahi IOCTLs.

Just a few generic rules about the data passed to the Asahi IOCTLs (cribbed from Panthor):

  • Structures must be aligned on 64-bit/8-byte. If the object is not naturally aligned, a padding field must be added.
  • Fields must be explicitly aligned to their natural type alignment with pad[0..N] fields.
  • All padding fields will be checked by the driver to make sure they are zeroed.
  • Flags can be added, but not removed/replaced.
  • New fields can be added to the main structures (the structures directly passed to the ioctl). Those fields can be added at the end of the structure, or replace existing padding fields. Any new field being added must preserve the behavior that existed before those fields were added when a value of zero is passed.
  • New fields can be added to indirect objects (objects pointed by the main structure), iff those objects are passed a size to reflect the size known by the userspace driver (see drm_asahi_cmd_header::size).
  • If the kernel driver is too old to know some fields, those will be ignored if zero, and otherwise rejected (and so will be zero on output).
  • If userspace is too old to know some fields, those will be zeroed (input) before the structure is parsed by the kernel driver.
  • Each new flag/field addition must come with a driver version update so the userspace driver doesn't have to guess which flags are supported.
  • Structures should not contain unions, as this would defeat the extensibility of such structures.
  • IOCTLs can't be removed or replaced. New IOCTL IDs should be placed at the end of the drm_asahi_ioctl_id enum. enum drm_asahi_ioctl_id - IOCTL IDs

Place new ioctls at the end, don't re-order, don't replace or remove entries.

These IDs are not meant to be used directly. Use the DRM_IOCTL_ASAHI_xxx definitions instead.

Enumerator
DRM_ASAHI_GET_PARAMS 

@DRM_ASAHI_GET_PARAMS: Query device properties.

DRM_ASAHI_GET_TIME 

@DRM_ASAHI_GET_TIME: Query device time.

DRM_ASAHI_VM_CREATE 

@DRM_ASAHI_VM_CREATE: Create a GPU VM address space.

DRM_ASAHI_VM_DESTROY 

@DRM_ASAHI_VM_DESTROY: Destroy a VM.

DRM_ASAHI_VM_BIND 

@DRM_ASAHI_VM_BIND: Bind/unbind memory to a VM.

DRM_ASAHI_GEM_CREATE 

@DRM_ASAHI_GEM_CREATE: Create a buffer object.

DRM_ASAHI_GEM_MMAP_OFFSET 

@DRM_ASAHI_GEM_MMAP_OFFSET: Get offset to pass to mmap() to map a given GEM handle.

DRM_ASAHI_GEM_BIND_OBJECT 

@DRM_ASAHI_GEM_BIND_OBJECT: Bind memory as a special object

DRM_ASAHI_QUEUE_CREATE 

@DRM_ASAHI_QUEUE_CREATE: Create a scheduling queue.

DRM_ASAHI_QUEUE_DESTROY 

@DRM_ASAHI_QUEUE_DESTROY: Destroy a scheduling queue.

DRM_ASAHI_SUBMIT 

@DRM_ASAHI_SUBMIT: Submit commands to a queue.

◆ drm_asahi_priority

enum drm_asahi_priority - Scheduling queue priority.

These priorities are forwarded to the firmware to influence firmware scheduling. The exact policy is ultimately decided by firmware, but these enums allow userspace to communicate the intentions.

Enumerator
DRM_ASAHI_PRIORITY_LOW 

@DRM_ASAHI_PRIORITY_LOW: Low priority queue.

DRM_ASAHI_PRIORITY_MEDIUM 

@DRM_ASAHI_PRIORITY_MEDIUM: Medium priority queue.

DRM_ASAHI_PRIORITY_HIGH 

@DRM_ASAHI_PRIORITY_HIGH: High priority queue.

Reserved for future extension.

DRM_ASAHI_PRIORITY_REALTIME 

@DRM_ASAHI_PRIORITY_REALTIME: Real-time priority queue.

Reserved for future extension.

◆ drm_asahi_render_flags

Enumerator
DRM_ASAHI_RENDER_VERTEX_SCRATCH 

@DRM_ASAHI_RENDER_VERTEX_SCRATCH: A vertex stage shader uses scratch memory.

DRM_ASAHI_RENDER_PROCESS_EMPTY_TILES 

@DRM_ASAHI_RENDER_PROCESS_EMPTY_TILES: Process even empty tiles. This must be set when clearing render targets.

DRM_ASAHI_RENDER_NO_VERTEX_CLUSTERING 

@DRM_ASAHI_RENDER_NO_VERTEX_CLUSTERING: Run vertex stage on a single cluster (on multi-cluster GPUs)

This harms performance but can workaround certain sync/coherency bugs, and therefore is useful for debugging.

DRM_ASAHI_RENDER_DBIAS_IS_INT 

@DRM_ASAHI_RENDER_DBIAS_IS_INT: Use integer depth bias formula.

Graphics specifications contain two alternate formulas for depth bias, a float formula used with floating-point depth buffers and an integer formula using with unorm depth buffers. This flag specifies that the integer formula should be used. If omitted, the float formula is used instead.

This corresponds to bit 18 of the relevant hardware control register, so we match that here for efficiency.

◆ drm_asahi_sync_type

enum drm_asahi_sync_type - Sync item type

Enumerator
DRM_ASAHI_SYNC_SYNCOBJ 

@DRM_ASAHI_SYNC_SYNCOBJ: Binary sync object

DRM_ASAHI_SYNC_TIMELINE_SYNCOBJ 

@DRM_ASAHI_SYNC_TIMELINE_SYNCOBJ: Timeline sync object