nouveau_winsys.h revision 7ec681f3
1#ifndef NOUVEAU_WINSYS_H 2#define NOUVEAU_WINSYS_H 3 4#include <stdint.h> 5#include <inttypes.h> 6 7#include "pipe/p_defines.h" 8 9#include "drm-uapi/drm.h" 10#include <nouveau.h> 11 12#ifndef NV04_PFIFO_MAX_PACKET_LEN 13#define NV04_PFIFO_MAX_PACKET_LEN 2047 14#endif 15 16#define NOUVEAU_MIN_BUFFER_MAP_ALIGN 64 17#define NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK (NOUVEAU_MIN_BUFFER_MAP_ALIGN - 1) 18 19static inline uint32_t 20PUSH_AVAIL(struct nouveau_pushbuf *push) 21{ 22 return push->end - push->cur; 23} 24 25static inline bool 26PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size) 27{ 28 /* Provide a buffer so that fences always have room to be emitted */ 29 size += 8; 30 if (PUSH_AVAIL(push) < size) 31 return nouveau_pushbuf_space(push, size, 0, 0) == 0; 32 return true; 33} 34 35static inline void 36PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data) 37{ 38 *push->cur++ = data; 39} 40 41static inline void 42PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size) 43{ 44 memcpy(push->cur, data, size * 4); 45 push->cur += size; 46} 47 48static inline void 49PUSH_DATAb(struct nouveau_pushbuf *push, const void *data, uint32_t size) 50{ 51 memcpy(push->cur, data, size); 52 push->cur += DIV_ROUND_UP(size, 4); 53} 54 55static inline void 56PUSH_DATAf(struct nouveau_pushbuf *push, float f) 57{ 58 union { float f; uint32_t i; } u; 59 u.f = f; 60 PUSH_DATA(push, u.i); 61} 62 63static inline void 64PUSH_KICK(struct nouveau_pushbuf *push) 65{ 66 nouveau_pushbuf_kick(push, push->channel); 67} 68 69 70#define NOUVEAU_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) 71#define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) 72 73static inline uint32_t 74nouveau_screen_transfer_flags(unsigned pipe) 75{ 76 uint32_t flags = 0; 77 78 if (!(pipe & PIPE_MAP_UNSYNCHRONIZED)) { 79 if (pipe & PIPE_MAP_READ) 80 flags |= NOUVEAU_BO_RD; 81 if (pipe & PIPE_MAP_WRITE) 82 flags |= NOUVEAU_BO_WR; 83 if (pipe & PIPE_MAP_DONTBLOCK) 84 flags |= NOUVEAU_BO_NOBLOCK; 85 } 86 87 return flags; 88} 89 90extern struct nouveau_screen * 91nv30_screen_create(struct nouveau_device *); 92 93extern struct nouveau_screen * 94nv50_screen_create(struct nouveau_device *); 95 96extern struct nouveau_screen * 97nvc0_screen_create(struct nouveau_device *); 98 99#endif 100