1 #include "pipe/p_util.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 assert(nv
->nvc
->next_subchannel
< 7);
33 BIND_RING(chan
, *grobj
, nv
->nvc
->next_subchannel
++);
38 nouveau_pipe_surface_copy(struct nouveau_winsys
*nvws
, struct pipe_surface
*dst
,
39 unsigned dx
, unsigned dy
, struct pipe_surface
*src
,
40 unsigned sx
, unsigned sy
, unsigned w
, unsigned h
)
42 struct nouveau_context
*nv
= nvws
->nv
;
44 if (nv
->surface_copy_prep(nv
, dst
, src
))
46 nv
->surface_copy(nv
, dx
, dy
, sx
, sy
, w
, h
);
47 nv
->surface_copy_done(nv
);
53 nouveau_pipe_surface_fill(struct nouveau_winsys
*nvws
, struct pipe_surface
*dst
,
54 unsigned dx
, unsigned dy
, unsigned w
, unsigned h
,
57 if (nvws
->nv
->surface_fill(nvws
->nv
, dst
, dx
, dy
, w
, h
, value
))
63 nouveau_pipe_push_reloc(struct nouveau_winsys
*nvws
, void *ptr
,
64 struct pipe_buffer
*buf
, uint32_t data
,
65 uint32_t flags
, uint32_t vor
, uint32_t tor
)
67 return nouveau_pushbuf_emit_reloc(nvws
->channel
, ptr
,
68 nouveau_buffer(buf
)->bo
,
69 data
, flags
, vor
, tor
);
73 nouveau_pipe_push_flush(struct nouveau_winsys
*nvws
, unsigned size
,
74 struct pipe_fence_handle
**fence
)
77 struct nouveau_pushbuf
*pb
= nvws
->channel
->pushbuf
;
78 struct nouveau_pushbuf_priv
*nvpb
= nouveau_pushbuf(pb
);
79 struct nouveau_fence
*ref
= NULL
;
81 nouveau_fence_ref(nvpb
->fence
, &ref
);
82 *fence
= (struct pipe_fence_handle
*)ref
;
85 return nouveau_pushbuf_flush(nvws
->channel
, size
);
89 nouveau_pipe_create(struct nouveau_context
*nv
)
91 struct nouveau_channel_context
*nvc
= nv
->nvc
;
92 struct nouveau_winsys
*nvws
= CALLOC_STRUCT(nouveau_winsys
);
93 struct pipe_screen
*(*hws_create
)(struct pipe_winsys
*,
94 struct nouveau_winsys
*);
95 struct pipe_context
*(*hw_create
)(struct pipe_screen
*, unsigned);
96 struct pipe_winsys
*ws
;
97 unsigned chipset
= nv
->nv_screen
->device
->chipset
;
102 switch (chipset
& 0xf0) {
105 hws_create
= nv10_screen_create
;
106 hw_create
= nv10_create
;
109 hws_create
= nv30_screen_create
;
110 hw_create
= nv30_create
;
114 hws_create
= nv40_screen_create
;
115 hw_create
= nv40_create
;
120 hws_create
= nv50_screen_create
;
121 hw_create
= nv50_create
;
124 NOUVEAU_ERR("Unknown chipset NV%02x\n", chipset
);
129 nvws
->channel
= nv
->nvc
->channel
;
131 nvws
->res_init
= nouveau_resource_init
;
132 nvws
->res_alloc
= nouveau_resource_alloc
;
133 nvws
->res_free
= nouveau_resource_free
;
135 nvws
->push_reloc
= nouveau_pipe_push_reloc
;
136 nvws
->push_flush
= nouveau_pipe_push_flush
;
138 nvws
->grobj_alloc
= nouveau_pipe_grobj_alloc
;
139 nvws
->grobj_free
= nouveau_grobj_free
;
141 nvws
->notifier_alloc
= nouveau_pipe_notifier_alloc
;
142 nvws
->notifier_free
= nouveau_notifier_free
;
143 nvws
->notifier_reset
= nouveau_notifier_reset
;
144 nvws
->notifier_status
= nouveau_notifier_status
;
145 nvws
->notifier_retval
= nouveau_notifier_return_val
;
146 nvws
->notifier_wait
= nouveau_notifier_wait_status
;
148 nvws
->surface_copy
= nouveau_pipe_surface_copy
;
149 nvws
->surface_fill
= nouveau_pipe_surface_fill
;
151 ws
= nouveau_create_pipe_winsys(nv
);
154 nvc
->pscreen
= hws_create(ws
, nvws
);
155 nvc
->pctx
[nv
->pctx_id
] = hw_create(nvc
->pscreen
, nv
->pctx_id
);
156 return nvc
->pctx
[nv
->pctx_id
];