Home | History | Annotate | Download | only in nouveau
      1 #ifndef __NOUVEAU_SCREEN_H__
      2 #define __NOUVEAU_SCREEN_H__
      3 
      4 #include "pipe/p_screen.h"
      5 #include "util/u_memory.h"
      6 
      7 #ifdef DEBUG
      8 # define NOUVEAU_ENABLE_DRIVER_STATISTICS
      9 #endif
     10 
     11 typedef uint32_t u32;
     12 typedef uint16_t u16;
     13 
     14 extern int nouveau_mesa_debug;
     15 
     16 struct nouveau_bo;
     17 
     18 struct nouveau_screen {
     19    struct pipe_screen base;
     20    struct nouveau_drm *drm;
     21    struct nouveau_device *device;
     22    struct nouveau_object *channel;
     23    struct nouveau_client *client;
     24    struct nouveau_pushbuf *pushbuf;
     25 
     26    int refcount;
     27 
     28    unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
     29    unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
     30    unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
     31    /*
     32     * For bindings with (vidmem & sysmem) bits set, PIPE_USAGE_* decides
     33     * placement.
     34     */
     35 
     36    uint16_t class_3d;
     37 
     38    struct {
     39       struct nouveau_fence *head;
     40       struct nouveau_fence *tail;
     41       struct nouveau_fence *current;
     42       u32 sequence;
     43       u32 sequence_ack;
     44       void (*emit)(struct pipe_screen *, u32 *sequence);
     45       u32  (*update)(struct pipe_screen *);
     46    } fence;
     47 
     48    struct nouveau_mman *mm_VRAM;
     49    struct nouveau_mman *mm_GART;
     50 
     51    int64_t cpu_gpu_time_delta;
     52 
     53    bool hint_buf_keep_sysmem_copy;
     54 
     55    unsigned vram_domain;
     56 
     57    struct {
     58       unsigned profiles_checked;
     59       unsigned profiles_present;
     60    } firmware_info;
     61 
     62 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
     63    union {
     64       uint64_t v[29];
     65       struct {
     66          uint64_t tex_obj_current_count;
     67          uint64_t tex_obj_current_bytes;
     68          uint64_t buf_obj_current_count;
     69          uint64_t buf_obj_current_bytes_vid;
     70          uint64_t buf_obj_current_bytes_sys;
     71          uint64_t tex_transfers_rd;
     72          uint64_t tex_transfers_wr;
     73          uint64_t tex_copy_count;
     74          uint64_t tex_blit_count;
     75          uint64_t tex_cache_flush_count;
     76          uint64_t buf_transfers_rd;
     77          uint64_t buf_transfers_wr;
     78          uint64_t buf_read_bytes_staging_vid;
     79          uint64_t buf_write_bytes_direct;
     80          uint64_t buf_write_bytes_staging_vid;
     81          uint64_t buf_write_bytes_staging_sys;
     82          uint64_t buf_copy_bytes;
     83          uint64_t buf_non_kernel_fence_sync_count;
     84          uint64_t any_non_kernel_fence_sync_count;
     85          uint64_t query_sync_count;
     86          uint64_t gpu_serialize_count;
     87          uint64_t draw_calls_array;
     88          uint64_t draw_calls_indexed;
     89          uint64_t draw_calls_fallback_count;
     90          uint64_t user_buffer_upload_bytes;
     91          uint64_t constbuf_upload_count;
     92          uint64_t constbuf_upload_bytes;
     93          uint64_t pushbuf_count;
     94          uint64_t resource_validate_count;
     95       } named;
     96    } stats;
     97 #endif
     98 };
     99 
    100 #define NV_VRAM_DOMAIN(screen) ((screen)->vram_domain)
    101 
    102 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
    103 # define NOUVEAU_DRV_STAT(s, n, v) do {         \
    104       (s)->stats.named.n += (v);                \
    105    } while(0)
    106 # define NOUVEAU_DRV_STAT_RES(r, n, v) do {                     \
    107       nouveau_screen((r)->base.screen)->stats.named.n += (v);   \
    108    } while(0)
    109 # define NOUVEAU_DRV_STAT_IFD(x) x
    110 #else
    111 # define NOUVEAU_DRV_STAT(s, n, v)     do { } while(0)
    112 # define NOUVEAU_DRV_STAT_RES(r, n, v) do { } while(0)
    113 # define NOUVEAU_DRV_STAT_IFD(x)
    114 #endif
    115 
    116 static inline struct nouveau_screen *
    117 nouveau_screen(struct pipe_screen *pscreen)
    118 {
    119    return (struct nouveau_screen *)pscreen;
    120 }
    121 
    122 bool nouveau_drm_screen_unref(struct nouveau_screen *screen);
    123 
    124 bool
    125 nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
    126                              struct nouveau_bo *bo,
    127                              unsigned stride,
    128                              struct winsys_handle *whandle);
    129 struct nouveau_bo *
    130 nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
    131                               struct winsys_handle *whandle,
    132                               unsigned *out_stride);
    133 
    134 
    135 int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
    136 void nouveau_screen_fini(struct nouveau_screen *);
    137 
    138 void nouveau_screen_init_vdec(struct nouveau_screen *);
    139 
    140 #endif
    141