1 #include "draw/draw_context.h"
2 #include "pipe/p_defines.h"
3 #include "pipe/p_winsys.h"
4 #include "pipe/p_util.h"
6 #include "nv50_context.h"
7 #include "nv50_screen.h"
10 nv50_flush(struct pipe_context
*pipe
, unsigned flags
)
12 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
13 struct nouveau_winsys
*nvws
= nv50
->nvws
;
15 if (flags
& PIPE_FLUSH_WAIT
) {
16 nvws
->notifier_reset(nv50
->sync
, 0);
17 BEGIN_RING(tesla
, 0x104, 1);
19 BEGIN_RING(tesla
, 0x100, 1);
25 if (flags
& PIPE_FLUSH_WAIT
)
26 nvws
->notifier_wait(nv50
->sync
, 0, 0, 2000);
30 nv50_destroy(struct pipe_context
*pipe
)
32 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
34 draw_destroy(nv50
->draw
);
39 nv50_init_hwctx(struct nv50_context
*nv50
, int tesla_class
)
41 struct nouveau_winsys
*nvws
= nv50
->nvws
;
44 if ((ret
= nvws
->grobj_alloc(nvws
, tesla_class
, &nv50
->tesla
))) {
45 NOUVEAU_ERR("Error creating 3D object: %d\n", ret
);
49 BEGIN_RING(tesla
, NV50TCL_DMA_NOTIFY
, 1);
50 OUT_RING (nv50
->sync
->handle
);
56 #define GRCLASS5097_CHIPSETS 0x00000000
57 #define GRCLASS8297_CHIPSETS 0x00000010
59 nv50_create(struct pipe_screen
*pscreen
)
61 struct pipe_winsys
*pipe_winsys
= pscreen
->winsys
;
62 struct nouveau_winsys
*nvws
= nv50_screen(pscreen
)->nvws
;
63 unsigned chipset
= nv50_screen(pscreen
)->chipset
;
64 struct nv50_context
*nv50
;
67 if ((chipset
& 0xf0) != 0x50 && (chipset
& 0xf0) != 0x80) {
68 NOUVEAU_ERR("Not a G8x chipset\n");
72 if (GRCLASS5097_CHIPSETS
& (1 << (chipset
& 0x0f))) {
75 if (GRCLASS8297_CHIPSETS
& (1 << (chipset
& 0x0f))) {
78 NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset
);
82 nv50
= CALLOC_STRUCT(nv50_context
);
85 nv50
->chipset
= chipset
;
88 if ((ret
= nvws
->notifier_alloc(nvws
, 1, &nv50
->sync
))) {
89 NOUVEAU_ERR("Error creating notifier object: %d\n", ret
);
94 if (!nv50_init_hwctx(nv50
, tesla_class
)) {
99 nv50
->pipe
.winsys
= pipe_winsys
;
100 nv50
->pipe
.screen
= pscreen
;
102 nv50
->pipe
.destroy
= nv50_destroy
;
104 nv50
->pipe
.draw_arrays
= nv50_draw_arrays
;
105 nv50
->pipe
.draw_elements
= nv50_draw_elements
;
106 nv50
->pipe
.clear
= nv50_clear
;
108 nv50
->pipe
.flush
= nv50_flush
;
110 nv50_init_miptree_functions(nv50
);
111 nv50_init_surface_functions(nv50
);
112 nv50_init_state_functions(nv50
);
113 nv50_init_query_functions(nv50
);
115 nv50
->draw
= draw_create();
117 draw_set_rasterize_stage(nv50
->draw
, nv50_draw_render_stage(nv50
));