1 #include "util/u_memory.h"
3 #include "nouveau_context.h"
4 #include "nouveau_screen.h"
5 #include "nouveau_winsys_pipe.h"
7 #include "nouveau/nouveau_winsys.h"
10 nouveau_pipe_notifier_alloc(struct nouveau_winsys
*nvws
, int count
,
11 struct nouveau_notifier
**notify
)
13 struct nouveau_context
*nv
= nvws
->nv
;
15 return nouveau_notifier_alloc(nv
->nvc
->channel
, nv
->nvc
->next_handle
++,
20 nouveau_pipe_grobj_alloc(struct nouveau_winsys
*nvws
, int grclass
,
21 struct nouveau_grobj
**grobj
)
23 struct nouveau_context
*nv
= nvws
->nv
;
24 struct nouveau_channel
*chan
= nv
->nvc
->channel
;
27 ret
= nouveau_grobj_alloc(chan
, nv
->nvc
->next_handle
++,
32 BEGIN_RING(chan
, *grobj
, 0x0000, 1);
33 OUT_RING (chan
, (*grobj
)->handle
);
34 (*grobj
)->bound
= NOUVEAU_GROBJ_BOUND_EXPLICIT
;
39 nouveau_pipe_push_reloc(struct nouveau_winsys
*nvws
, void *ptr
,
40 struct pipe_buffer
*buf
, uint32_t data
,
41 uint32_t flags
, uint32_t vor
, uint32_t tor
)
43 struct nouveau_bo
*bo
= nouveau_pipe_buffer(buf
)->bo
;
45 return nouveau_pushbuf_emit_reloc(nvws
->channel
, ptr
, bo
,
46 data
, flags
, vor
, tor
);
50 nouveau_pipe_push_flush(struct nouveau_winsys
*nvws
, unsigned size
,
51 struct pipe_fence_handle
**fence
)
56 return nouveau_pushbuf_flush(nvws
->channel
, size
);
59 static struct nouveau_bo
*
60 nouveau_pipe_get_bo(struct pipe_buffer
*pb
)
62 return nouveau_pipe_buffer(pb
)->bo
;
66 nouveau_pipe_create(struct nouveau_context
*nv
)
68 struct nouveau_channel_context
*nvc
= nv
->nvc
;
69 struct nouveau_winsys
*nvws
= CALLOC_STRUCT(nouveau_winsys
);
70 struct pipe_screen
*(*hws_create
)(struct pipe_winsys
*,
71 struct nouveau_winsys
*);
72 struct pipe_context
*(*hw_create
)(struct pipe_screen
*, unsigned);
73 struct pipe_winsys
*ws
;
74 unsigned chipset
= nv
->nv_screen
->device
->chipset
;
79 switch (chipset
& 0xf0) {
81 hws_create
= nv04_screen_create
;
82 hw_create
= nv04_create
;
85 hws_create
= nv10_screen_create
;
86 hw_create
= nv10_create
;
89 hws_create
= nv20_screen_create
;
90 hw_create
= nv20_create
;
93 hws_create
= nv30_screen_create
;
94 hw_create
= nv30_create
;
98 hws_create
= nv40_screen_create
;
99 hw_create
= nv40_create
;
104 hws_create
= nv50_screen_create
;
105 hw_create
= nv50_create
;
108 NOUVEAU_ERR("Unknown chipset NV%02x\n", chipset
);
113 nvws
->channel
= nv
->nvc
->channel
;
115 nvws
->res_init
= nouveau_resource_init
;
116 nvws
->res_alloc
= nouveau_resource_alloc
;
117 nvws
->res_free
= nouveau_resource_free
;
119 nvws
->push_reloc
= nouveau_pipe_push_reloc
;
120 nvws
->push_flush
= nouveau_pipe_push_flush
;
122 nvws
->grobj_alloc
= nouveau_pipe_grobj_alloc
;
123 nvws
->grobj_free
= nouveau_grobj_free
;
125 nvws
->notifier_alloc
= nouveau_pipe_notifier_alloc
;
126 nvws
->notifier_free
= nouveau_notifier_free
;
127 nvws
->notifier_reset
= nouveau_notifier_reset
;
128 nvws
->notifier_status
= nouveau_notifier_status
;
129 nvws
->notifier_retval
= nouveau_notifier_return_val
;
130 nvws
->notifier_wait
= nouveau_notifier_wait_status
;
132 nvws
->get_bo
= nouveau_pipe_get_bo
;
134 ws
= nouveau_create_pipe_winsys(nv
);
137 nvc
->pscreen
= hws_create(ws
, nvws
);
138 nvc
->pctx
[nv
->pctx_id
] = hw_create(nvc
->pscreen
, nv
->pctx_id
);
139 return nvc
->pctx
[nv
->pctx_id
];