1 #include "pipe/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"
10 nv50_is_format_supported(struct pipe_context
*pipe
, enum pipe_format format
,
17 nv50_get_name(struct pipe_context
*pipe
)
19 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
20 static char buffer
[128];
22 snprintf(buffer
, sizeof(buffer
), "NV%02X", nv50
->chipset
);
27 nv50_get_vendor(struct pipe_context
*pipe
)
33 nv50_get_param(struct pipe_context
*pipe
, int param
)
36 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
38 case PIPE_CAP_NPOT_TEXTURES
:
40 case PIPE_CAP_TWO_SIDED_STENCIL
:
46 case PIPE_CAP_ANISOTROPIC_FILTER
:
48 case PIPE_CAP_POINT_SPRITE
:
50 case PIPE_CAP_MAX_RENDER_TARGETS
:
52 case PIPE_CAP_OCCLUSION_QUERY
:
54 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
56 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
58 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
60 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
63 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
69 nv50_get_paramf(struct pipe_context
*pipe
, int param
)
72 case PIPE_CAP_MAX_LINE_WIDTH
:
73 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
75 case PIPE_CAP_MAX_POINT_WIDTH
:
76 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
78 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
80 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
83 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
89 nv50_flush(struct pipe_context
*pipe
, unsigned flags
)
91 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
92 struct nouveau_winsys
*nvws
= nv50
->nvws
;
94 if (flags
& PIPE_FLUSH_WAIT
) {
95 nvws
->notifier_reset(nv50
->sync
, 0);
96 BEGIN_RING(tesla
, 0x104, 1);
98 BEGIN_RING(tesla
, 0x100, 1);
104 if (flags
& PIPE_FLUSH_WAIT
)
105 nvws
->notifier_wait(nv50
->sync
, 0, 0, 2000);
109 nv50_destroy(struct pipe_context
*pipe
)
111 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
113 draw_destroy(nv50
->draw
);
118 nv50_init_hwctx(struct nv50_context
*nv50
, int tesla_class
)
120 struct nouveau_winsys
*nvws
= nv50
->nvws
;
123 if ((ret
= nvws
->grobj_alloc(nvws
, tesla_class
, &nv50
->tesla
))) {
124 NOUVEAU_ERR("Error creating 3D object: %d\n", ret
);
128 BEGIN_RING(tesla
, NV50TCL_DMA_NOTIFY
, 1);
129 OUT_RING (nv50
->sync
->handle
);
135 #define GRCLASS5097_CHIPSETS 0x00000000
136 #define GRCLASS8297_CHIPSETS 0x00000010
137 struct pipe_context
*
138 nv50_create(struct pipe_winsys
*pipe_winsys
, struct nouveau_winsys
*nvws
,
141 struct nv50_context
*nv50
;
142 int tesla_class
, ret
;
144 if ((chipset
& 0xf0) != 0x50 && (chipset
& 0xf0) != 0x80) {
145 NOUVEAU_ERR("Not a G8x chipset\n");
149 if (GRCLASS5097_CHIPSETS
& (1 << (chipset
& 0x0f))) {
150 tesla_class
= 0x5097;
152 if (GRCLASS8297_CHIPSETS
& (1 << (chipset
& 0x0f))) {
153 tesla_class
= 0x8297;
155 NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset
);
159 nv50
= CALLOC_STRUCT(nv50_context
);
162 nv50
->chipset
= chipset
;
165 if ((ret
= nvws
->notifier_alloc(nvws
, 1, &nv50
->sync
))) {
166 NOUVEAU_ERR("Error creating notifier object: %d\n", ret
);
171 if (!nv50_init_hwctx(nv50
, tesla_class
)) {
176 nv50
->pipe
.winsys
= pipe_winsys
;
178 nv50
->pipe
.destroy
= nv50_destroy
;
179 nv50
->pipe
.is_format_supported
= nv50_is_format_supported
;
180 nv50
->pipe
.get_name
= nv50_get_name
;
181 nv50
->pipe
.get_vendor
= nv50_get_vendor
;
182 nv50
->pipe
.get_param
= nv50_get_param
;
183 nv50
->pipe
.get_paramf
= nv50_get_paramf
;
185 nv50
->pipe
.draw_arrays
= nv50_draw_arrays
;
186 nv50
->pipe
.draw_elements
= nv50_draw_elements
;
187 nv50
->pipe
.clear
= nv50_clear
;
189 nv50
->pipe
.flush
= nv50_flush
;
191 nv50_init_miptree_functions(nv50
);
192 nv50_init_surface_functions(nv50
);
193 nv50_init_state_functions(nv50
);
194 nv50_init_query_functions(nv50
);
196 nv50
->draw
= draw_create();
198 draw_set_rasterize_stage(nv50
->draw
, nv50_draw_render_stage(nv50
));