nv50_screen.c revision 2b8c0cf16959c07341309484da41b2e9a17e5266
121e463b2bf864671a87ebe386cb100ef9349a540Nate Begeman/*
27c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * Copyright 2008 Ben Skeggs
37c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner *
47c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * Permission is hereby granted, free of charge, to any person obtaining a
54ee451de366474b9c228b4e5fa573795a715216dChris Lattner * copy of this software and associated documentation files (the "Software"),
64ee451de366474b9c228b4e5fa573795a715216dChris Lattner * to deal in the Software without restriction, including without limitation
77c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * and/or sell copies of the Software, and to permit persons to whom the
97c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * Software is furnished to do so, subject to the following conditions:
107c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner *
117c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * The above copyright notice and this permission notice shall be included in
127c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * all copies or substantial portions of the Software.
137c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner *
147c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
157c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
177c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
187c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
190bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
202668959b8879097db368aec7d76c455260abc75bChris Lattner * SOFTWARE.
21331d1bc5dfe1be9090e29f9af9579888a63a9a79Chris Lattner */
227c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner
237c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner#include "pipe/p_screen.h"
240bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner
250bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner#include "nv50_context.h"
263c983c3dc19bb83807f978c04737b4572be90a93Nate Begeman#include "nv50_screen.h"
270ba2bcfcc3149a25d08aa8aa00fb6c34a4e25bddDan Gohman
280bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner#include "nouveau/nouveau_stateobj.h"
290bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner
300bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattnerstatic boolean
310bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattnernv50_screen_is_format_supported(struct pipe_screen *pscreen,
32f76053269ecc6c7bd3d0b1e90ebdd0cef1bb2bdcChris Lattner				enum pipe_format format,
33c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman				enum pipe_texture_target target,
34c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman				unsigned tex_usage, unsigned geom_flags)
35c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman{
36c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman	if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
37c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman		switch (format) {
38c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman		case PIPE_FORMAT_B8G8R8X8_UNORM:
39c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman		case PIPE_FORMAT_B8G8R8A8_UNORM:
40c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman		case PIPE_FORMAT_B5G6R5_UNORM:
41c09eeec0ebc378644bafd04916e5efafa7d98152Nate Begeman		case PIPE_FORMAT_R16G16B16A16_SNORM:
42860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		case PIPE_FORMAT_R16G16B16A16_UNORM:
435126984b1da4bda0e93961da07e883699f1f2d57Chris Lattner		case PIPE_FORMAT_R32G32B32A32_FLOAT:
44c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman		case PIPE_FORMAT_R16G16_SNORM:
455126984b1da4bda0e93961da07e883699f1f2d57Chris Lattner		case PIPE_FORMAT_R16G16_UNORM:
465126984b1da4bda0e93961da07e883699f1f2d57Chris Lattner			return TRUE;
47993aeb2ed93f99faf1438f1b67cd922989306828Nate Begeman		default:
48993aeb2ed93f99faf1438f1b67cd922989306828Nate Begeman			break;
49993aeb2ed93f99faf1438f1b67cd922989306828Nate Begeman		}
50993aeb2ed93f99faf1438f1b67cd922989306828Nate Begeman	} else
51f1d0b2bedaa065972a5ba17259055c1176cd1497Chris Lattner	if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
52f1d0b2bedaa065972a5ba17259055c1176cd1497Chris Lattner		switch (format) {
53f1d0b2bedaa065972a5ba17259055c1176cd1497Chris Lattner		case PIPE_FORMAT_Z32_FLOAT:
54f1d0b2bedaa065972a5ba17259055c1176cd1497Chris Lattner		case PIPE_FORMAT_S8Z24_UNORM:
55860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		case PIPE_FORMAT_Z24X8_UNORM:
56860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		case PIPE_FORMAT_Z24S8_UNORM:
57860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner			return TRUE;
58860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		default:
59860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner			break;
60860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		}
61860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner	} else {
626b16eff207f99bbde3c0f7340452a5287218772cTilmann Scheller		switch (format) {
636b16eff207f99bbde3c0f7340452a5287218772cTilmann Scheller		case PIPE_FORMAT_B8G8R8A8_UNORM:
643a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B8G8R8X8_UNORM:
653a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B8G8R8A8_SRGB:
663a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B8G8R8X8_SRGB:
673a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B5G5R5A1_UNORM:
683a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B4G4R4A4_UNORM:
693a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_B5G6R5_UNORM:
703a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_L8_UNORM:
713a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_A8_UNORM:
723a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_I8_UNORM:
733a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_L8A8_UNORM:
743a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_DXT1_RGB:
753a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_DXT1_RGBA:
763a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_DXT3_RGBA:
773a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_DXT5_RGBA:
783a84dae654630a89a91a73807201b6067c4774ecTilmann Scheller		case PIPE_FORMAT_S8Z24_UNORM:
792f616bff7ef1e2e08d6d23c2a8b42ec2bfebb173Jim Laskey		case PIPE_FORMAT_Z24S8_UNORM:
802f616bff7ef1e2e08d6d23c2a8b42ec2bfebb173Jim Laskey		case PIPE_FORMAT_Z32_FLOAT:
812f616bff7ef1e2e08d6d23c2a8b42ec2bfebb173Jim Laskey		case PIPE_FORMAT_R16G16B16A16_SNORM:
822f616bff7ef1e2e08d6d23c2a8b42ec2bfebb173Jim Laskey		case PIPE_FORMAT_R16G16B16A16_UNORM:
832f616bff7ef1e2e08d6d23c2a8b42ec2bfebb173Jim Laskey		case PIPE_FORMAT_R32G32B32A32_FLOAT:
84860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		case PIPE_FORMAT_R16G16_SNORM:
85860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner		case PIPE_FORMAT_R16G16_UNORM:
86860e8862c1fbd3b261da4a64a8c0096f9f373681Chris Lattner			return TRUE;
874172b10ca1adfc1026428e5f522aaab98bd939adChris Lattner		default:
884172b10ca1adfc1026428e5f522aaab98bd939adChris Lattner			break;
894172b10ca1adfc1026428e5f522aaab98bd939adChris Lattner		}
904172b10ca1adfc1026428e5f522aaab98bd939adChris Lattner	}
914172b10ca1adfc1026428e5f522aaab98bd939adChris Lattner
92ecfe55e65b6a72fddd543c42f2e2df4c96c647baChris Lattner	return FALSE;
93ecfe55e65b6a72fddd543c42f2e2df4c96c647baChris Lattner}
94ecfe55e65b6a72fddd543c42f2e2df4c96c647baChris Lattner
95ecfe55e65b6a72fddd543c42f2e2df4c96c647baChris Lattnerstatic int
969e4dd9dfc97f3930f58ca6e47bebbd8eb5cdd8a1Nate Begemannv50_screen_get_param(struct pipe_screen *pscreen, int param)
97c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner{
982a9ddfb903ae3baede7282348afae1f750905248Tilmann Scheller	switch (param) {
99281b55ebeccd3f0d723888c1bb9ec6e476f708f1Chris Lattner	case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
1006b16eff207f99bbde3c0f7340452a5287218772cTilmann Scheller		return 32;
1016b16eff207f99bbde3c0f7340452a5287218772cTilmann Scheller	case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
1026b16eff207f99bbde3c0f7340452a5287218772cTilmann Scheller		return 32;
103c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner	case PIPE_CAP_MAX_COMBINED_SAMPLERS:
104c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner		return 64;
105c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner	case PIPE_CAP_NPOT_TEXTURES:
106c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner		return 1;
107c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner	case PIPE_CAP_TWO_SIDED_STENCIL:
108c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner		return 1;
1092a9ddfb903ae3baede7282348afae1f750905248Tilmann Scheller	case PIPE_CAP_GLSL:
110c703a8fbf8653ac8302ae368391a4954c307ca2cChris Lattner		return 0;
1119e4dd9dfc97f3930f58ca6e47bebbd8eb5cdd8a1Nate Begeman	case PIPE_CAP_ANISOTROPIC_FILTER:
1129e4dd9dfc97f3930f58ca6e47bebbd8eb5cdd8a1Nate Begeman		return 1;
1136d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_POINT_SPRITE:
1146d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner		return 1;
1156d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_MAX_RENDER_TARGETS:
1166d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner		return 8;
1176d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_OCCLUSION_QUERY:
118a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner		return 1;
119a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner	case PIPE_CAP_TEXTURE_SHADOW_MAP:
120a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner		return 1;
121a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner	case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
122a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner		return 13;
123a17b1557ad705c56c41624e6841e19093ed31f21Chris Lattner	case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
1246d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner		return 10;
1256d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
1266d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner		return 13;
1276d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
1286d92caddc4aa5fc946b294259e00cc35536e61e8Chris Lattner	case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
12990564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner		return 1;
13090564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner	case PIPE_CAP_TGSI_CONT_SUPPORTED:
13190564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner		return 1;
13290564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner	case PIPE_CAP_BLEND_EQUATION_SEPARATE:
13390564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner		return 1;
13490564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner	case NOUVEAU_CAP_HW_VTXBUF:
13590564f26d17701e11effa2f4e0fb9a18d8a91274Chris Lattner		return 1;
136d9989384592a3bd9dd374470a723ca8303071a2dChris Lattner	case NOUVEAU_CAP_HW_IDXBUF:
137d9989384592a3bd9dd374470a723ca8303071a2dChris Lattner		return 1;
1386eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_INDEP_BLEND_ENABLE:
1396eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		return 1;
1406eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_INDEP_BLEND_FUNC:
1416eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		return 0;
1426eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
1436eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
1446eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		return 1;
1456eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
1466eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
1476eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		return 0;
1486eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	default:
1496eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
1506eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen		return 0;
1516eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen	}
1526eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen}
1536eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen
1546eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesenstatic float
1556eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesennv50_screen_get_paramf(struct pipe_screen *pscreen, int param)
1566eaeff29b8a6990107735f7e5f5e49da38f56223Dale Johannesen{
15754fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng	switch (param) {
15854fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng	case PIPE_CAP_MAX_LINE_WIDTH:
1598608f2eff2dab5345243c40d0bca9138f2dce6f1Evan Cheng	case PIPE_CAP_MAX_LINE_WIDTH_AA:
16054fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng		return 10.0;
1618608f2eff2dab5345243c40d0bca9138f2dce6f1Evan Cheng	case PIPE_CAP_MAX_POINT_WIDTH:
16254fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng	case PIPE_CAP_MAX_POINT_WIDTH_AA:
1638608f2eff2dab5345243c40d0bca9138f2dce6f1Evan Cheng		return 64.0;
1648608f2eff2dab5345243c40d0bca9138f2dce6f1Evan Cheng	case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
1658608f2eff2dab5345243c40d0bca9138f2dce6f1Evan Cheng		return 16.0;
16654fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng	case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
16730e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer		return 4.0;
16830e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer	default:
16930e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
17030e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer		return 0.0;
17130e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer	}
172c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman}
173c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman
174c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohmanstatic void
175c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohmannv50_screen_destroy(struct pipe_screen *pscreen)
176c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman{
177c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	struct nv50_screen *screen = nv50_screen(pscreen);
178c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	unsigned i;
179c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman
180c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	for (i = 0; i < 3; i++) {
181c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman		if (screen->constbuf_parm[i])
182c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman			nouveau_bo_ref(NULL, &screen->constbuf_parm[i]);
183c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	}
184c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman
185c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	if (screen->constbuf_misc[0])
186c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman		nouveau_bo_ref(NULL, &screen->constbuf_misc[0]);
187c76909abfec876c6b751d693ebd3df07df686aa0Dan Gohman	if (screen->tic)
188281b55ebeccd3f0d723888c1bb9ec6e476f708f1Chris Lattner		nouveau_bo_ref(NULL, &screen->tic);
1893c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner	if (screen->tsc)
1903c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner		nouveau_bo_ref(NULL, &screen->tsc);
1913c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner	if (screen->static_init)
1923c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner		so_ref(NULL, &screen->static_init);
193ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner
194ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner	nouveau_notifier_free(&screen->sync);
1959008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman	nouveau_grobj_free(&screen->tesla);
196ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner	nouveau_grobj_free(&screen->eng2d);
197ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner	nouveau_grobj_free(&screen->m2mf);
198ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner	nouveau_resource_destroy(&screen->immd_heap[0]);
1999008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman	nouveau_resource_destroy(&screen->parm_heap[0]);
200116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattner	nouveau_resource_destroy(&screen->parm_heap[1]);
201116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattner	nouveau_screen_fini(&screen->base);
202116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattner	FREE(screen);
2039008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman}
2049008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman
205116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattnerstruct pipe_screen *
206116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattnernv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
207116cc48e30b9c307bf3eec29c890b4ba25cd18dbChris Lattner{
2089008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman	struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen);
2099008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman	struct nouveau_channel *chan;
210ddb739e5ea6ccf6fa4f4e2a23e3da550868efaa1Chris Lattner	struct pipe_screen *pscreen;
211d0608e191ff9c00af68985f246410c219d1bec57Chris Lattner	struct nouveau_stateobj *so;
212d0608e191ff9c00af68985f246410c219d1bec57Chris Lattner	unsigned chipset = dev->chipset;
213f24380e78ecc8a2db1b2116867d878b1e7c6f6edChris Lattner	unsigned tesla_class = 0;
214d0608e191ff9c00af68985f246410c219d1bec57Chris Lattner	int ret, i;
2153c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner
2163c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner	if (!screen)
2173c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner		return NULL;
2189008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman	pscreen = &screen->base.base;
2193c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner
22066ffe6be0c7b50100a00cb0cc87a5d4983818572Evan Cheng	ret = nouveau_screen_init(&screen->base, dev);
22166ffe6be0c7b50100a00cb0cc87a5d4983818572Evan Cheng	if (ret) {
22266ffe6be0c7b50100a00cb0cc87a5d4983818572Evan Cheng		nv50_screen_destroy(pscreen);
22366ffe6be0c7b50100a00cb0cc87a5d4983818572Evan Cheng		return NULL;
2243c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner	}
2253c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner	chan = screen->base.channel;
2267ff7e674580adad7a5bccdbd74cf9c9f05e46d0fChris Lattner
22764b3a08bc696b2ef8733d72ce81e49be175cbbffChris Lattner	pscreen->winsys = ws;
228e87192a854ff0f2f1904dd9ea282eb36059bb5afChris Lattner	pscreen->destroy = nv50_screen_destroy;
229140a58f9dfda30dbb80edd3da1b5632c178f7efcChris Lattner	pscreen->get_param = nv50_screen_get_param;
230140a58f9dfda30dbb80edd3da1b5632c178f7efcChris Lattner	pscreen->get_paramf = nv50_screen_get_paramf;
231140a58f9dfda30dbb80edd3da1b5632c178f7efcChris Lattner	pscreen->is_format_supported = nv50_screen_is_format_supported;
232475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	pscreen->context_create = nv50_create;
2333c0f9cc90cdcb70caf0dc517b9f9206d731aeb70Chris Lattner
2340bbea954331b8f08afa5b094dfb0841829c70eaaChris Lattner	nv50_screen_init_miptree_functions(pscreen);
23521e463b2bf864671a87ebe386cb100ef9349a540Nate Begeman	nv50_transfer_init_screen_functions(pscreen);
2367c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner
2370111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray	/* DMA engine object */
2380111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray	ret = nouveau_grobj_alloc(chan, 0xbeef5039,
2390111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray		NV50_MEMORY_TO_MEMORY_FORMAT, &screen->m2mf);
2400111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray	if (ret) {
2410111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray		NOUVEAU_ERR("Error creating M2MF object: %d\n", ret);
2420111999a88077f237c49d03c5e7891ec874b33a9Nicolas Geoffray		nv50_screen_destroy(pscreen);
243331d1bc5dfe1be9090e29f9af9579888a63a9a79Chris Lattner		return NULL;
2447c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner	}
24561e729e2e9517ab2d8887bab86fb377900fa1081Dan Gohman
2467c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner	/* 2D object */
247da6d20f0c15205923cb2c3ef4bf9b5d77de88881Chris Lattner	ret = nouveau_grobj_alloc(chan, 0xbeef502d, NV50_2D, &screen->eng2d);
248da6d20f0c15205923cb2c3ef4bf9b5d77de88881Chris Lattner	if (ret) {
249da6d20f0c15205923cb2c3ef4bf9b5d77de88881Chris Lattner		NOUVEAU_ERR("Error creating 2D object: %d\n", ret);
250fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		nv50_screen_destroy(pscreen);
2515b8f82e35b51bf007de07a7ca9347d804084ddf8Scott Michel		return NULL;
252825b72b0571821bf2d378749f69d6c4cfb52d2f9Owen Anderson	}
2535b8f82e35b51bf007de07a7ca9347d804084ddf8Scott Michel
254fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	/* 3D object */
255fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	switch (chipset & 0xf0) {
256fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	case 0x50:
257475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		tesla_class = NV50TCL;
258475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		break;
259144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng	case 0x80:
26073e0914848662404cf2aa18eb049ff5aae543388Dan Gohman	case 0x90:
261fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		tesla_class = NV84TCL;
262fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		break;
263fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	case 0xa0:
264fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		switch (chipset) {
265475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		case 0xa0:
26673e0914848662404cf2aa18eb049ff5aae543388Dan Gohman		case 0xaa:
267fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		case 0xac:
268fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner			tesla_class = NVA0TCL;
269fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner			break;
270fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		default:
271475871a144eb604ddaf37503397ba0941442e5fbDan Gohman			tesla_class = NVA8TCL;
27273e0914848662404cf2aa18eb049ff5aae543388Dan Gohman			break;
273fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		}
274fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		break;
275fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	default:
276475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
27773e0914848662404cf2aa18eb049ff5aae543388Dan Gohman		nv50_screen_destroy(pscreen);
278fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		return NULL;
279fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	}
280fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner
281fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class,
282475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		&screen->tesla);
28373e0914848662404cf2aa18eb049ff5aae543388Dan Gohman	if (ret) {
284fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
285da6d20f0c15205923cb2c3ef4bf9b5d77de88881Chris Lattner		nv50_screen_destroy(pscreen);
286e4bc9ea0a560d8a0ba42f5a2da617e1f1f834710Chris Lattner		return NULL;
287e4bc9ea0a560d8a0ba42f5a2da617e1f1f834710Chris Lattner	}
288475871a144eb604ddaf37503397ba0941442e5fbDan Gohman
2891f873003266fbdec7c2c48a965c60f4e2e35a158Chris Lattner	/* Sync notifier */
2901607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands	ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
2911607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands	if (ret) {
2921607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands		NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
2931607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands		nv50_screen_destroy(pscreen);
2941607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands		return NULL;
2951607f05cb7d77d01ce521a30232faa389dbed4e2Duncan Sands	}
296475871a144eb604ddaf37503397ba0941442e5fbDan Gohman
297fc5b1ab94959879a91c34aee8859e652a50270d0Chris Lattner	/* Static M2MF init */
298475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so = so_new(1, 3, 0);
299977a76fbb6ea1b87dfd7fbbe2ae2afb63e982ff3Dan Gohman	so_method(so, screen->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
300fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman	so_data  (so, screen->sync->handle);
301fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman	so_data  (so, chan->vram->handle);
302ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman	so_data  (so, chan->vram->handle);
303bbe77de450ef36b4f83cc3b57705a9758adbd925Chris Lattner	so_emit(chan, so);
3044a95945fa5aa431110f50092f4a45d24772a553bNate Begeman	so_ref (NULL, &so);
305ff9b373e8f5006c629af81e2619778b4c4f5249eEvan Cheng
306fb2e752e4175920d0531f2afc93a23d0cdf4db14Evan Cheng	/* Static 2D init */
307fb2e752e4175920d0531f2afc93a23d0cdf4db14Evan Cheng	so = so_new(4, 7, 0);
308bdab93a2ef5d9574bb4e322e020849f9bc9c90d7Dale Johannesen	so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4);
309bdab93a2ef5d9574bb4e322e020849f9bc9c90d7Dale Johannesen	so_data  (so, screen->sync->handle);
3101fdbc1dd4e9cb42c79a30e8dc308c322e923cc52Dan Gohman	so_data  (so, chan->vram->handle);
31197efa365869d3b7b62836434585360a232836f0eDale Johannesen	so_data  (so, chan->vram->handle);
31297efa365869d3b7b62836434585360a232836f0eDale Johannesen	so_data  (so, chan->vram->handle);
3131fdbc1dd4e9cb42c79a30e8dc308c322e923cc52Dan Gohman	so_method(so, screen->eng2d, NV50_2D_OPERATION, 1);
314ddc787dfdc75fb2d78eb3e5793ca0f417ad74fd3Chris Lattner	so_data  (so, NV50_2D_OPERATION_SRCCOPY);
3154234f57fa02b1f04a9f52a7b3c2aa22d32ac521cChris Lattner	so_method(so, screen->eng2d, NV50_2D_CLIP_ENABLE, 1);
316331d1bc5dfe1be9090e29f9af9579888a63a9a79Chris Lattner	so_data  (so, 0);
317331d1bc5dfe1be9090e29f9af9579888a63a9a79Chris Lattner	so_method(so, screen->eng2d, 0x0888, 1);
318e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson	so_data  (so, 1);
319c4c6257c1a154279bf10e9498d46d6c1793dbaa7Evan Cheng	so_emit(chan, so);
32028d08fdb9f6572cafd5aae95c7caffa3cd136d8eDale Johannesen	so_ref(NULL, &so);
32128d08fdb9f6572cafd5aae95c7caffa3cd136d8eDale Johannesen
32228d08fdb9f6572cafd5aae95c7caffa3cd136d8eDale Johannesen	/* Static tesla init */
32328d08fdb9f6572cafd5aae95c7caffa3cd136d8eDale Johannesen	so = so_new(47, 95, 24);
32428d08fdb9f6572cafd5aae95c7caffa3cd136d8eDale Johannesen
32548884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner	so_method(so, screen->tesla, NV50TCL_COND_MODE, 1);
326da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng	so_data  (so, NV50TCL_COND_MODE_ALWAYS);
327da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng	so_method(so, screen->tesla, NV50TCL_DMA_NOTIFY, 1);
328da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng	so_data  (so, screen->sync->handle);
329475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_DMA_ZETA, 11);
33048884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner	for (i = 0; i < 11; i++)
331da43bcf624acb56a3d77bb5ae9a02728af032613Evan Cheng		so_data(so, chan->vram->handle);
332475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_DMA_COLOR(0),
3335e764233f398b6929b67701672a5e78fec20ce2eChris Lattner				     NV50TCL_DMA_COLOR__SIZE);
33448884cd80b52be1528618f2e9b3425ac24e7b5caChris Lattner	for (i = 0; i < NV50TCL_DMA_COLOR__SIZE; i++)
335c9addb74883fef318140272768422656a694341fChris Lattner		so_data(so, chan->vram->handle);
336c9addb74883fef318140272768422656a694341fChris Lattner	so_method(so, screen->tesla, NV50TCL_RT_CONTROL, 1);
337c9addb74883fef318140272768422656a694341fChris Lattner	so_data  (so, 1);
338c9addb74883fef318140272768422656a694341fChris Lattner
339c4c6257c1a154279bf10e9498d46d6c1793dbaa7Evan Cheng	/* activate all 32 lanes (threads) in a warp */
340861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	so_method(so, screen->tesla, NV50TCL_WARP_HALVES, 1);
341861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	so_data  (so, 0x2);
342861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	so_method(so, screen->tesla, 0x1400, 1);
343861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	so_data  (so, 0xf);
344861939152debbaa15a55a196a4321837c7bc379dEvan Cheng
345861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	/* max TIC (bits 4:8) & TSC (ignored) bindings, per program type */
346861939152debbaa15a55a196a4321837c7bc379dEvan Cheng	for (i = 0; i < 3; ++i) {
34743c6e7cd9b0d9a3b0006650ddfac256848f10d51Nicolas Geoffray		so_method(so, screen->tesla, NV50TCL_TEX_LIMITS(i), 1);
34854aeea39a743effe88eedb43d2f7f4805e806ab5Dan Gohman		so_data  (so, 0x54);
349ffd0200abfd63177257f949a3674b91dcf87bf23Tilmann Scheller	}
350e50ed30282bb5b4a9ed952580523f2dda16215acOwen Anderson
351ffd0200abfd63177257f949a3674b91dcf87bf23Tilmann Scheller	/* origin is top left (set to 1 for bottom left) */
352ffd0200abfd63177257f949a3674b91dcf87bf23Tilmann Scheller	so_method(so, screen->tesla, NV50TCL_Y_ORIGIN_BOTTOM, 1);
35354aeea39a743effe88eedb43d2f7f4805e806ab5Dan Gohman	so_data  (so, 0);
354b4202b84d7e54efe5e144885c7da63e6cc465f80Bill Wendling	so_method(so, screen->tesla, NV50TCL_VP_REG_ALLOC_RESULT, 1);
35520c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling	so_data  (so, 8);
35620c568f366be211323eeaf0e45ef053278ec9ddcBill Wendling
35754fc97dcdc0ab747f49bd09c5a877bfd2a00e364Evan Cheng	/* constant buffers for immediates and VP/FP parameters */
358475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4,
359475871a144eb604ddaf37503397ba0941442e5fbDan Gohman			     &screen->constbuf_misc[0]);
36030e62c098b5841259f8026df1c5c45c7c1182a38Arnold Schwaighofer	if (ret) {
3610c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng		nv50_screen_destroy(pscreen);
3620c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng		return NULL;
3630c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng	}
3640c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng
3650c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng	for (i = 0; i < 3; i++) {
3660c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng		ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (256 * 4) * 4,
3670c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng				     &screen->constbuf_parm[i]);
368475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		if (ret) {
36933c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen			nv50_screen_destroy(pscreen);
37033c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen			return NULL;
37133c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen		}
37233c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen	}
3732a9ddfb903ae3baede7282348afae1f750905248Tilmann Scheller
37433c960f523f2308482d5b2816af46a7ec90a6d3dDale Johannesen	if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) ||
375475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	    nouveau_resource_init(&screen->parm_heap[0], 0, 512) ||
376475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	    nouveau_resource_init(&screen->parm_heap[1], 0, 512))
377475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	{
378475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		NOUVEAU_ERR("Error initialising constant buffers.\n");
3793d90dbee695e723f422dafca3fc75f193268ab9eBob Wilson		nv50_screen_destroy(pscreen);
380475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		return NULL;
381475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	}
382475871a144eb604ddaf37503397ba0941442e5fbDan Gohman
383475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	/*
3847795932d41a84c921a5d348b7fa70f5d32e146d0Bill Wendling	// map constant buffers:
385475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	//  B = buffer ID (maybe more than 1 byte)
3865b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	//  N = CB index used in shader instruction
3875b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	//  P = program type (0 = VP, 2 = GP, 3 = FP)
3885b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
389475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_data  (so, 0x000BBNP1);
3905b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	*/
3915b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen
392475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
3935b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
394475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
3955b3b695c2f1e11b6f5e0c89e1644211a92edab49Dale Johannesen	so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM |
396475871a144eb604ddaf37503397ba0941442e5fbDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
3974c9369df57a52cec5e1fc735e61a979766288074Dale Johannesen	so_data  (so, (NV50_CB_PMISC << 16) | 0x00000200);
398475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
399475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_data  (so, 0x00000001 | (NV50_CB_PMISC << 12));
400475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
401475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_data  (so, 0x00000021 | (NV50_CB_PMISC << 12));
402475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
403475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_data  (so, 0x00000031 | (NV50_CB_PMISC << 12));
404475871a144eb604ddaf37503397ba0941442e5fbDan Gohman
405475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	/* bind auxiliary constbuf to immediate data bo */
406475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
407475871a144eb604ddaf37503397ba0941442e5fbDan Gohman	so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4,
40898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
40998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4,
41065c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
41198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, (NV50_CB_AUX << 16) | 0x00000200);
41298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
41398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, 0x00000201 | (NV50_CB_AUX << 12));
41465c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
41598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, 0x00000221 | (NV50_CB_AUX << 12));
41698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
41798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
41898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0,
41998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
42098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0,
42198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
42298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, (NV50_CB_PVP << 16) | 0x00000800);
42398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
42498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, 0x00000101 | (NV50_CB_PVP << 12));
42598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
42698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
42765c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0,
42898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
42998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_GEOMETRY], 0,
43098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
43198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, (NV50_CB_PGP << 16) | 0x00000800);
43298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
433022d9e1cef7586a80a96446ae8691a37def9bbf4Evan Cheng	so_data  (so, 0x00000121 | (NV50_CB_PGP << 12));
4340c439eb2c8397996cbccaf2798e598052d9982c8Evan Cheng
43598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3);
43698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0,
43798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
43898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->constbuf_parm[PIPE_SHADER_FRAGMENT], 0,
43998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
44098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, (NV50_CB_PFP << 16) | 0x00000800);
44198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1);
44265c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel	so_data  (so, 0x00000131 | (NV50_CB_PFP << 12));
44398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
44498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
44598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman			     &screen->tic);
44698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	if (ret) {
44798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		nv50_screen_destroy(pscreen);
44865c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel		return NULL;
44998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	}
45098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
45198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3);
45298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
45398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
45465c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel	so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
45598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
45698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, PIPE_SHADER_TYPES * 32 - 1);
45798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
45898ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, PIPE_SHADER_TYPES*32*32,
45998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman			     &screen->tsc);
46098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	if (ret) {
46165c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel		nv50_screen_destroy(pscreen);
46298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		return NULL;
46398ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	}
46498ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
46598ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3);
46698ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
46798ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
46865c3c8f323198b99b88b109654194540cf9b3fa5Sandeep Patel	so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
46998ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman		  NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
47098ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman	so_data  (so, 0x00000000); /* ignored if TSC_LINKED (0x1234) = 1 */
47198ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
47298ca4f2a325f72374a477f9deba7d09e8999c29bDan Gohman
4737c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner	/* Vertex array limits - max them out */
4747c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner	for (i = 0; i < 16; i++) {
4757c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner		so_method(so, screen->tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
4767c5a3d390a463fb50a6eee7ae3174817925e6d28Chris Lattner		so_data  (so, 0x000000ff);
477		so_data  (so, 0xffffffff);
478	}
479
480	so_method(so, screen->tesla, NV50TCL_DEPTH_RANGE_NEAR(0), 2);
481	so_data  (so, fui(0.0));
482	so_data  (so, fui(1.0));
483
484	/* no dynamic combination of TIC & TSC entries => only BIND_TIC used */
485	so_method(so, screen->tesla, NV50TCL_LINKED_TSC, 1);
486	so_data  (so, 1);
487
488	so_method(so, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1);
489	so_data  (so, 1); /* default edgeflag to TRUE */
490
491	so_emit(chan, so);
492	so_ref (so, &screen->static_init);
493	so_ref (NULL, &so);
494	nouveau_pushbuf_flush(chan, 0);
495
496	return pscreen;
497}
498
499