1 #include "pipe/p_screen.h"
3 #include "nv20_context.h"
4 #include "nv20_screen.h"
7 nv20_screen_get_name(struct pipe_screen
*screen
)
9 struct nv20_screen
*nv20screen
= nv20_screen(screen
);
10 struct nouveau_device
*dev
= nv20screen
->nvws
->channel
->device
;
11 static char buffer
[128];
13 snprintf(buffer
, sizeof(buffer
), "NV%02X", dev
->chipset
);
18 nv20_screen_get_vendor(struct pipe_screen
*screen
)
24 nv20_screen_get_param(struct pipe_screen
*screen
, int param
)
27 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
29 case PIPE_CAP_NPOT_TEXTURES
:
31 case PIPE_CAP_TWO_SIDED_STENCIL
:
37 case PIPE_CAP_ANISOTROPIC_FILTER
:
39 case PIPE_CAP_POINT_SPRITE
:
41 case PIPE_CAP_MAX_RENDER_TARGETS
:
43 case PIPE_CAP_OCCLUSION_QUERY
:
45 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
47 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
49 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
51 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
53 case NOUVEAU_CAP_HW_VTXBUF
:
54 case NOUVEAU_CAP_HW_IDXBUF
:
57 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
63 nv20_screen_get_paramf(struct pipe_screen
*screen
, int param
)
66 case PIPE_CAP_MAX_LINE_WIDTH
:
67 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
69 case PIPE_CAP_MAX_POINT_WIDTH
:
70 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
72 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
74 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
77 NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param
);
83 nv20_screen_is_format_supported(struct pipe_screen
*screen
,
84 enum pipe_format format
,
85 enum pipe_texture_target target
,
86 unsigned tex_usage
, unsigned geom_flags
)
88 if (tex_usage
& PIPE_TEXTURE_USAGE_RENDER_TARGET
) {
90 case PIPE_FORMAT_A8R8G8B8_UNORM
:
91 case PIPE_FORMAT_R5G6B5_UNORM
:
92 case PIPE_FORMAT_Z24S8_UNORM
:
93 case PIPE_FORMAT_Z16_UNORM
:
100 case PIPE_FORMAT_A8R8G8B8_UNORM
:
101 case PIPE_FORMAT_A1R5G5B5_UNORM
:
102 case PIPE_FORMAT_A4R4G4B4_UNORM
:
103 case PIPE_FORMAT_R5G6B5_UNORM
:
104 case PIPE_FORMAT_L8_UNORM
:
105 case PIPE_FORMAT_A8_UNORM
:
106 case PIPE_FORMAT_I8_UNORM
:
117 nv20_surface_map(struct pipe_screen
*screen
, struct pipe_surface
*surface
,
120 struct pipe_winsys
*ws
= screen
->winsys
;
123 map
= ws
->buffer_map(ws
, surface
->buffer
, flags
);
127 return map
+ surface
->offset
;
131 nv20_surface_unmap(struct pipe_screen
*screen
, struct pipe_surface
*surface
)
133 struct pipe_winsys
*ws
= screen
->winsys
;
135 ws
->buffer_unmap(ws
, surface
->buffer
);
139 nv20_screen_destroy(struct pipe_screen
*pscreen
)
141 struct nv20_screen
*screen
= nv20_screen(pscreen
);
142 struct nouveau_winsys
*nvws
= screen
->nvws
;
144 nvws
->notifier_free(&screen
->sync
);
145 nvws
->grobj_free(&screen
->kelvin
);
151 nv20_screen_create(struct pipe_winsys
*ws
, struct nouveau_winsys
*nvws
)
153 struct nv20_screen
*screen
= CALLOC_STRUCT(nv20_screen
);
154 unsigned kelvin_class
= 0;
155 unsigned chipset
= nvws
->channel
->device
->chipset
;
164 kelvin_class
= NV25TCL
;
165 else if (chipset
>= 0x20)
166 kelvin_class
= NV20TCL
;
168 if (!kelvin_class
|| chipset
>= 0x30) {
169 NOUVEAU_ERR("Unknown nv2x chipset: nv%02x\n", chipset
);
173 ret
= nvws
->grobj_alloc(nvws
, kelvin_class
, &screen
->kelvin
);
175 NOUVEAU_ERR("Error creating 3D object: %d\n", ret
);
179 /* Notifier for sync purposes */
180 ret
= nvws
->notifier_alloc(nvws
, 1, &screen
->sync
);
182 NOUVEAU_ERR("Error creating notifier object: %d\n", ret
);
183 nv20_screen_destroy(&screen
->pipe
);
187 screen
->pipe
.winsys
= ws
;
188 screen
->pipe
.destroy
= nv20_screen_destroy
;
190 screen
->pipe
.get_name
= nv20_screen_get_name
;
191 screen
->pipe
.get_vendor
= nv20_screen_get_vendor
;
192 screen
->pipe
.get_param
= nv20_screen_get_param
;
193 screen
->pipe
.get_paramf
= nv20_screen_get_paramf
;
195 screen
->pipe
.is_format_supported
= nv20_screen_is_format_supported
;
197 screen
->pipe
.surface_map
= nv20_surface_map
;
198 screen
->pipe
.surface_unmap
= nv20_surface_unmap
;
200 nv20_screen_init_miptree_functions(&screen
->pipe
);
202 return &screen
->pipe
;