1 #include "pipe/p_screen.h"
2 #include "util/u_simple_screen.h"
4 #include "nv30_context.h"
5 #include "nv30_screen.h"
7 #define NV30TCL_CHIPSET_3X_MASK 0x00000003
8 #define NV34TCL_CHIPSET_3X_MASK 0x00000010
9 #define NV35TCL_CHIPSET_3X_MASK 0x000001e0
12 nv30_screen_get_name(struct pipe_screen
*pscreen
)
14 struct nv30_screen
*screen
= nv30_screen(pscreen
);
15 struct nouveau_device
*dev
= screen
->nvws
->channel
->device
;
16 static char buffer
[128];
18 snprintf(buffer
, sizeof(buffer
), "NV%02X", dev
->chipset
);
23 nv30_screen_get_vendor(struct pipe_screen
*pscreen
)
29 nv30_screen_get_param(struct pipe_screen
*pscreen
, int param
)
32 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
34 case PIPE_CAP_NPOT_TEXTURES
:
36 case PIPE_CAP_TWO_SIDED_STENCIL
:
42 case PIPE_CAP_ANISOTROPIC_FILTER
:
44 case PIPE_CAP_POINT_SPRITE
:
46 case PIPE_CAP_MAX_RENDER_TARGETS
:
48 case PIPE_CAP_OCCLUSION_QUERY
:
50 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
52 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
54 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
56 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
58 case PIPE_CAP_TEXTURE_MIRROR_CLAMP
:
60 case PIPE_CAP_TEXTURE_MIRROR_REPEAT
:
62 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
64 case NOUVEAU_CAP_HW_VTXBUF
:
65 case NOUVEAU_CAP_HW_IDXBUF
:
68 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
74 nv30_screen_get_paramf(struct pipe_screen
*pscreen
, int param
)
77 case PIPE_CAP_MAX_LINE_WIDTH
:
78 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
80 case PIPE_CAP_MAX_POINT_WIDTH
:
81 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
83 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
85 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
88 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
94 nv30_screen_surface_format_supported(struct pipe_screen
*pscreen
,
95 enum pipe_format format
,
96 enum pipe_texture_target target
,
97 unsigned tex_usage
, unsigned geom_flags
)
99 if (tex_usage
& PIPE_TEXTURE_USAGE_RENDER_TARGET
) {
101 case PIPE_FORMAT_A8R8G8B8_UNORM
:
102 case PIPE_FORMAT_R5G6B5_UNORM
:
103 case PIPE_FORMAT_Z24S8_UNORM
:
104 case PIPE_FORMAT_Z16_UNORM
:
111 case PIPE_FORMAT_A8R8G8B8_UNORM
:
112 case PIPE_FORMAT_A1R5G5B5_UNORM
:
113 case PIPE_FORMAT_A4R4G4B4_UNORM
:
114 case PIPE_FORMAT_R5G6B5_UNORM
:
115 case PIPE_FORMAT_L8_UNORM
:
116 case PIPE_FORMAT_A8_UNORM
:
117 case PIPE_FORMAT_I8_UNORM
:
118 case PIPE_FORMAT_A8L8_UNORM
:
119 case PIPE_FORMAT_Z16_UNORM
:
120 case PIPE_FORMAT_Z24S8_UNORM
:
130 static struct pipe_buffer
*
131 nv30_surface_buffer(struct pipe_surface
*surf
)
133 struct nv30_miptree
*mt
= (struct nv30_miptree
*)surf
->texture
;
139 nv30_screen_destroy(struct pipe_screen
*pscreen
)
141 struct nv30_screen
*screen
= nv30_screen(pscreen
);
142 struct nouveau_winsys
*nvws
= screen
->nvws
;
144 nvws
->res_free(&screen
->vp_exec_heap
);
145 nvws
->res_free(&screen
->vp_data_heap
);
146 nvws
->res_free(&screen
->query_heap
);
147 nvws
->notifier_free(&screen
->query
);
148 nvws
->notifier_free(&screen
->sync
);
149 nvws
->grobj_free(&screen
->rankine
);
155 nv30_screen_create(struct pipe_winsys
*ws
, struct nouveau_winsys
*nvws
)
157 struct nv30_screen
*screen
= CALLOC_STRUCT(nv30_screen
);
158 struct nouveau_stateobj
*so
;
159 unsigned rankine_class
= 0;
160 unsigned chipset
= nvws
->channel
->device
->chipset
;
167 /* 2D engine setup */
168 screen
->eng2d
= nv04_surface_2d_init(nvws
);
169 screen
->eng2d
->buf
= nv30_surface_buffer
;
172 switch (chipset
& 0xf0) {
174 if (NV30TCL_CHIPSET_3X_MASK
& (1 << (chipset
& 0x0f)))
175 rankine_class
= 0x0397;
177 if (NV34TCL_CHIPSET_3X_MASK
& (1 << (chipset
& 0x0f)))
178 rankine_class
= 0x0697;
180 if (NV35TCL_CHIPSET_3X_MASK
& (1 << (chipset
& 0x0f)))
181 rankine_class
= 0x0497;
187 if (!rankine_class
) {
188 NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", chipset
);
192 ret
= nvws
->grobj_alloc(nvws
, rankine_class
, &screen
->rankine
);
194 NOUVEAU_ERR("Error creating 3D object: %d\n", ret
);
198 /* Notifier for sync purposes */
199 ret
= nvws
->notifier_alloc(nvws
, 1, &screen
->sync
);
201 NOUVEAU_ERR("Error creating notifier object: %d\n", ret
);
202 nv30_screen_destroy(&screen
->pipe
);
207 ret
= nvws
->notifier_alloc(nvws
, 32, &screen
->query
);
209 NOUVEAU_ERR("Error initialising query objects: %d\n", ret
);
210 nv30_screen_destroy(&screen
->pipe
);
214 ret
= nvws
->res_init(&screen
->query_heap
, 0, 32);
216 NOUVEAU_ERR("Error initialising query object heap: %d\n", ret
);
217 nv30_screen_destroy(&screen
->pipe
);
221 /* Vtxprog resources */
222 if (nvws
->res_init(&screen
->vp_exec_heap
, 0, 256) ||
223 nvws
->res_init(&screen
->vp_data_heap
, 0, 256)) {
224 nv30_screen_destroy(&screen
->pipe
);
228 /* Static rankine initialisation */
230 so_method(so
, screen
->rankine
, NV34TCL_DMA_NOTIFY
, 1);
231 so_data (so
, screen
->sync
->handle
);
232 so_method(so
, screen
->rankine
, NV34TCL_DMA_TEXTURE0
, 2);
233 so_data (so
, nvws
->channel
->vram
->handle
);
234 so_data (so
, nvws
->channel
->gart
->handle
);
235 so_method(so
, screen
->rankine
, NV34TCL_DMA_COLOR1
, 1);
236 so_data (so
, nvws
->channel
->vram
->handle
);
237 so_method(so
, screen
->rankine
, NV34TCL_DMA_COLOR0
, 2);
238 so_data (so
, nvws
->channel
->vram
->handle
);
239 so_data (so
, nvws
->channel
->vram
->handle
);
240 so_method(so
, screen
->rankine
, NV34TCL_DMA_VTXBUF0
, 2);
241 so_data (so
, nvws
->channel
->vram
->handle
);
242 so_data (so
, nvws
->channel
->gart
->handle
);
243 /* so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2);
245 so_data (so, screen->query->handle);*/
246 so_method(so
, screen
->rankine
, NV34TCL_DMA_IN_MEMORY7
, 1);
247 so_data (so
, nvws
->channel
->vram
->handle
);
248 so_method(so
, screen
->rankine
, NV34TCL_DMA_IN_MEMORY8
, 1);
249 so_data (so
, nvws
->channel
->vram
->handle
);
251 for (i
=1; i
<8; i
++) {
252 so_method(so
, screen
->rankine
, NV34TCL_VIEWPORT_CLIP_HORIZ(i
), 1);
254 so_method(so
, screen
->rankine
, NV34TCL_VIEWPORT_CLIP_VERT(i
), 1);
258 so_method(so
, screen
->rankine
, 0x220, 1);
261 so_method(so
, screen
->rankine
, 0x03b0, 1);
262 so_data (so
, 0x00100000);
263 so_method(so
, screen
->rankine
, 0x1454, 1);
265 so_method(so
, screen
->rankine
, 0x1d80, 1);
267 so_method(so
, screen
->rankine
, 0x1450, 1);
268 so_data (so
, 0x00030004);
271 so_method(so
, screen
->rankine
, 0x1e98, 1);
273 so_method(so
, screen
->rankine
, 0x17e0, 3);
274 so_data (so
, fui(0.0));
275 so_data (so
, fui(0.0));
276 so_data (so
, fui(1.0));
277 so_method(so
, screen
->rankine
, 0x1f80, 16);
278 for (i
=0; i
<16; i
++) {
279 so_data (so
, (i
==8) ? 0x0000ffff : 0);
282 so_method(so
, screen
->rankine
, 0x120, 3);
287 so_method(so
, screen
->rankine
, 0x1d88, 1);
288 so_data (so
, 0x00001200);
290 so_method(so
, screen
->rankine
, NV34TCL_RC_ENABLE
, 1);
293 so_method(so
, screen
->rankine
, NV34TCL_DEPTH_RANGE_NEAR
, 2);
294 so_data (so
, fui(0.0));
295 so_data (so
, fui(1.0));
297 so_method(so
, screen
->rankine
, NV34TCL_MULTISAMPLE_CONTROL
, 1);
298 so_data (so
, 0xffff0000);
300 /* enables use of vp rather than fixed-function somehow */
301 so_method(so
, screen
->rankine
, 0x1e94, 1);
306 nouveau_pushbuf_flush(nvws
->channel
, 0);
308 screen
->pipe
.winsys
= ws
;
309 screen
->pipe
.destroy
= nv30_screen_destroy
;
311 screen
->pipe
.get_name
= nv30_screen_get_name
;
312 screen
->pipe
.get_vendor
= nv30_screen_get_vendor
;
313 screen
->pipe
.get_param
= nv30_screen_get_param
;
314 screen
->pipe
.get_paramf
= nv30_screen_get_paramf
;
316 screen
->pipe
.is_format_supported
= nv30_screen_surface_format_supported
;
318 nv30_screen_init_miptree_functions(&screen
->pipe
);
319 nv30_screen_init_transfer_functions(&screen
->pipe
);
320 u_simple_screen_init(&screen
->pipe
);
322 return &screen
->pipe
;