1 /**************************************************************************
3 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
4 VA Linux Systems Inc., Fremont, California.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
31 * \file radeon_screen.c
32 * Screen initialization functions for the Radeon driver.
34 * \author Kevin E. Martin <martin@valinux.com>
35 * \author Gareth Hughes <gareth@valinux.com>
38 #include "main/glheader.h"
39 #include "main/imports.h"
40 #include "main/mtypes.h"
41 #include "main/framebuffer.h"
42 #include "main/renderbuffer.h"
44 #define STANDALONE_MMIO
45 #include "radeon_chipset.h"
46 #include "radeon_macros.h"
47 #include "radeon_screen.h"
49 #include "radeon_context.h"
50 #include "radeon_span.h"
51 #include "radeon_tex.h"
52 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
53 #include "r200_context.h"
54 #include "r200_ioctl.h"
55 #include "r200_span.h"
57 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
58 #include "r300_context.h"
59 #include "r300_fragprog.h"
61 #include "radeon_span.h"
66 #include "drirenderbuffer.h"
68 #include "GL/internal/dri_interface.h"
70 /* Radeon configuration
74 #if !RADEON_COMMON /* R100 */
75 PUBLIC
const char __driConfigOptions
[] =
77 DRI_CONF_SECTION_PERFORMANCE
78 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN
)
79 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
80 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0
)
81 DRI_CONF_MAX_TEXTURE_UNITS(3,2,3)
82 DRI_CONF_HYPERZ(false)
84 DRI_CONF_SECTION_QUALITY
85 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB
)
86 DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
87 DRI_CONF_NO_NEG_LOD_BIAS(false)
88 DRI_CONF_FORCE_S3TC_ENABLE(false)
89 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER
)
90 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC
)
91 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF
)
92 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
94 DRI_CONF_SECTION_DEBUG
95 DRI_CONF_NO_RAST(false)
98 static const GLuint __driNConfigOptions
= 14;
100 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
102 PUBLIC
const char __driConfigOptions
[] =
104 DRI_CONF_SECTION_PERFORMANCE
105 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN
)
106 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
107 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0
)
108 DRI_CONF_MAX_TEXTURE_UNITS(6,2,6)
109 DRI_CONF_HYPERZ(false)
111 DRI_CONF_SECTION_QUALITY
112 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB
)
113 DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
114 DRI_CONF_NO_NEG_LOD_BIAS(false)
115 DRI_CONF_FORCE_S3TC_ENABLE(false)
116 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER
)
117 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC
)
118 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF
)
119 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
120 DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
122 DRI_CONF_SECTION_DEBUG
123 DRI_CONF_NO_RAST(false)
125 DRI_CONF_SECTION_SOFTWARE
126 DRI_CONF_NV_VERTEX_PROGRAM(false)
129 static const GLuint __driNConfigOptions
= 16;
131 extern const struct dri_extension blend_extensions
[];
132 extern const struct dri_extension ARB_vp_extension
[];
133 extern const struct dri_extension NV_vp_extension
[];
134 extern const struct dri_extension ATI_fs_extension
[];
135 extern const struct dri_extension point_extensions
[];
137 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
139 /* TODO: integrate these into xmlpool.h! */
140 #define DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(def,min,max) \
141 DRI_CONF_OPT_BEGIN_V(texture_image_units,int,def, # min ":" # max ) \
142 DRI_CONF_DESC(en,"Number of texture image units") \
143 DRI_CONF_DESC(de,"Anzahl der Textureinheiten") \
146 #define DRI_CONF_MAX_TEXTURE_COORD_UNITS(def,min,max) \
147 DRI_CONF_OPT_BEGIN_V(texture_coord_units,int,def, # min ":" # max ) \
148 DRI_CONF_DESC(en,"Number of texture coordinate units") \
149 DRI_CONF_DESC(de,"Anzahl der Texturkoordinateneinheiten") \
152 #define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
153 DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
154 DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
155 DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
158 #define DRI_CONF_DISABLE_S3TC(def) \
159 DRI_CONF_OPT_BEGIN(disable_s3tc,bool,def) \
160 DRI_CONF_DESC(en,"Disable S3TC compression") \
163 #define DRI_CONF_DISABLE_FALLBACK(def) \
164 DRI_CONF_OPT_BEGIN(disable_lowimpact_fallback,bool,def) \
165 DRI_CONF_DESC(en,"Disable Low-impact fallback") \
168 #define DRI_CONF_DISABLE_DOUBLE_SIDE_STENCIL(def) \
169 DRI_CONF_OPT_BEGIN(disable_stencil_two_side,bool,def) \
170 DRI_CONF_DESC(en,"Disable GL_EXT_stencil_two_side") \
173 #define DRI_CONF_FP_OPTIMIZATION(def) \
174 DRI_CONF_OPT_BEGIN_V(fp_optimization,enum,def,"0:1") \
175 DRI_CONF_DESC_BEGIN(en,"Fragment Program optimization") \
176 DRI_CONF_ENUM(0,"Optimize for Speed") \
177 DRI_CONF_ENUM(1,"Optimize for Quality") \
181 PUBLIC
const char __driConfigOptions
[] =
183 DRI_CONF_SECTION_PERFORMANCE
184 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN
)
185 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS
)
186 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0
)
187 DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(8, 2, 8)
188 DRI_CONF_MAX_TEXTURE_COORD_UNITS(8, 2, 8)
189 DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
190 DRI_CONF_DISABLE_FALLBACK(true)
191 DRI_CONF_DISABLE_DOUBLE_SIDE_STENCIL(false)
193 DRI_CONF_SECTION_QUALITY
194 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB
)
195 DRI_CONF_DEF_MAX_ANISOTROPY(1.0, "1.0,2.0,4.0,8.0,16.0")
196 DRI_CONF_FORCE_S3TC_ENABLE(false)
197 DRI_CONF_DISABLE_S3TC(false)
198 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER
)
199 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC
)
200 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF
)
201 DRI_CONF_FP_OPTIMIZATION(DRI_CONF_FP_OPTIMIZATION_SPEED
)
203 DRI_CONF_SECTION_DEBUG
204 DRI_CONF_NO_RAST(false)
207 static const GLuint __driNConfigOptions
= 17;
209 extern const struct dri_extension gl_20_extension
[];
212 int RADEON_DEBUG
= 0;
214 static const struct dri_debug_control debug_control
[] = {
215 {"fall", DEBUG_FALLBACKS
},
216 {"tex", DEBUG_TEXTURE
},
217 {"ioctl", DEBUG_IOCTL
},
218 {"prim", DEBUG_PRIMS
},
219 {"vert", DEBUG_VERTS
},
220 {"state", DEBUG_STATE
},
221 {"code", DEBUG_CODEGEN
},
222 {"vfmt", DEBUG_VFMT
},
223 {"vtxf", DEBUG_VFMT
},
224 {"verb", DEBUG_VERBOSE
},
227 {"san", DEBUG_SANITY
},
228 {"sync", DEBUG_SYNC
},
229 {"pix", DEBUG_PIXEL
},
230 {"mem", DEBUG_MEMORY
},
231 {"allmsg", ~DEBUG_SYNC
}, /* avoid the term "sync" because the parser uses strstr */
234 #endif /* RADEON_DEBUG */
236 #endif /* RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) */
238 extern const struct dri_extension card_extensions
[];
240 static int getSwapInfo( __DRIdrawablePrivate
*dPriv
, __DRIswapInfo
* sInfo
);
243 radeonGetParam(int fd
, int param
, void *value
)
246 drm_radeon_getparam_t gp
;
251 ret
= drmCommandWriteRead( fd
, DRM_RADEON_GETPARAM
, &gp
, sizeof(gp
));
255 static const __DRIconfig
**
256 radeonFillInModes( __DRIscreenPrivate
*psp
,
257 unsigned pixel_bits
, unsigned depth_bits
,
258 unsigned stencil_bits
, GLboolean have_back_buffer
)
260 __DRIconfig
**configs
;
262 unsigned depth_buffer_factor
;
263 unsigned back_buffer_factor
;
268 /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
269 * enough to add support. Basically, if a context is created with an
270 * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
271 * will never be used.
273 static const GLenum back_buffer_modes
[] = {
274 GLX_NONE
, GLX_SWAP_UNDEFINED_OML
/*, GLX_SWAP_COPY_OML */
277 uint8_t depth_bits_array
[2];
278 uint8_t stencil_bits_array
[2];
279 uint8_t msaa_samples_array
[1];
281 depth_bits_array
[0] = depth_bits
;
282 depth_bits_array
[1] = depth_bits
;
284 /* Just like with the accumulation buffer, always provide some modes
285 * with a stencil buffer. It will be a sw fallback, but some apps won't
288 stencil_bits_array
[0] = 0;
289 stencil_bits_array
[1] = (stencil_bits
== 0) ? 8 : stencil_bits
;
291 msaa_samples_array
[0] = 0;
293 depth_buffer_factor
= ((depth_bits
!= 0) || (stencil_bits
!= 0)) ? 2 : 1;
294 back_buffer_factor
= (have_back_buffer
) ? 2 : 1;
296 if ( pixel_bits
== 16 ) {
298 fb_type
= GL_UNSIGNED_SHORT_5_6_5
;
302 fb_type
= GL_UNSIGNED_INT_8_8_8_8_REV
;
305 configs
= driCreateConfigs(fb_format
, fb_type
,
306 depth_bits_array
, stencil_bits_array
,
308 back_buffer_modes
, back_buffer_factor
,
309 msaa_samples_array
, 1);
310 if (configs
== NULL
) {
311 fprintf( stderr
, "[%s:%u] Error creating FBConfig!\n",
312 __func__
, __LINE__
);
316 /* Mark the visual as slow if there are "fake" stencil bits.
318 for (i
= 0; configs
[i
]; i
++) {
319 m
= &configs
[i
]->modes
;
320 if ((m
->stencilBits
!= 0) && (m
->stencilBits
!= stencil_bits
)) {
321 m
->visualRating
= GLX_SLOW_CONFIG
;
325 return (const __DRIconfig
**) configs
;
329 static const __DRItexOffsetExtension radeonTexOffsetExtension
= {
330 { __DRI_TEX_OFFSET
, __DRI_TEX_OFFSET_VERSION
},
335 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
336 static const __DRIallocateExtension r200AllocateExtension
= {
337 { __DRI_ALLOCATE
, __DRI_ALLOCATE_VERSION
},
338 r200AllocateMemoryMESA
,
340 r200GetMemoryOffsetMESA
343 static const __DRItexOffsetExtension r200texOffsetExtension
= {
344 { __DRI_TEX_OFFSET
, __DRI_TEX_OFFSET_VERSION
},
349 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
350 static const __DRItexOffsetExtension r300texOffsetExtension
= {
351 { __DRI_TEX_OFFSET
, __DRI_TEX_OFFSET_VERSION
},
356 /* Create the device specific screen private data struct.
358 static radeonScreenPtr
359 radeonCreateScreen( __DRIscreenPrivate
*sPriv
)
361 radeonScreenPtr screen
;
362 RADEONDRIPtr dri_priv
= (RADEONDRIPtr
)sPriv
->pDevPriv
;
363 unsigned char *RADEONMMIO
;
368 if (sPriv
->devPrivSize
!= sizeof(RADEONDRIRec
)) {
369 fprintf(stderr
,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
373 /* Allocate the private area */
374 screen
= (radeonScreenPtr
) CALLOC( sizeof(*screen
) );
376 __driUtilMessage("%s: Could not allocate memory for screen structure",
381 #if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
382 RADEON_DEBUG
= driParseDebugString(getenv("RADEON_DEBUG"), debug_control
);
385 /* parse information in __driConfigOptions */
386 driParseOptionInfo (&screen
->optionCache
,
387 __driConfigOptions
, __driNConfigOptions
);
389 /* This is first since which regions we map depends on whether or
390 * not we are using a PCI card.
392 screen
->card_type
= (dri_priv
->IsPCI
? RADEON_CARD_PCI
: RADEON_CARD_AGP
);
395 ret
= radeonGetParam( sPriv
->fd
, RADEON_PARAM_GART_BUFFER_OFFSET
,
396 &screen
->gart_buffer_offset
);
400 fprintf(stderr
, "drm_radeon_getparam_t (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret
);
404 ret
= radeonGetParam( sPriv
->fd
, RADEON_PARAM_GART_BASE
,
408 fprintf(stderr
, "drm_radeon_getparam_t (RADEON_PARAM_GART_BASE): %d\n", ret
);
412 ret
= radeonGetParam( sPriv
->fd
, RADEON_PARAM_IRQ_NR
,
416 fprintf(stderr
, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret
);
419 screen
->drmSupportsCubeMapsR200
= (sPriv
->drm_version
.minor
>= 7);
420 screen
->drmSupportsBlendColor
= (sPriv
->drm_version
.minor
>= 11);
421 screen
->drmSupportsTriPerf
= (sPriv
->drm_version
.minor
>= 16);
422 screen
->drmSupportsFragShader
= (sPriv
->drm_version
.minor
>= 18);
423 screen
->drmSupportsPointSprites
= (sPriv
->drm_version
.minor
>= 13);
424 screen
->drmSupportsCubeMapsR100
= (sPriv
->drm_version
.minor
>= 15);
425 screen
->drmSupportsVertexProgram
= (sPriv
->drm_version
.minor
>= 25);
428 screen
->mmio
.handle
= dri_priv
->registerHandle
;
429 screen
->mmio
.size
= dri_priv
->registerSize
;
430 if ( drmMap( sPriv
->fd
,
433 &screen
->mmio
.map
) ) {
435 __driUtilMessage("%s: drmMap failed\n", __FUNCTION__
);
439 RADEONMMIO
= screen
->mmio
.map
;
441 screen
->status
.handle
= dri_priv
->statusHandle
;
442 screen
->status
.size
= dri_priv
->statusSize
;
443 if ( drmMap( sPriv
->fd
,
444 screen
->status
.handle
,
446 &screen
->status
.map
) ) {
447 drmUnmap( screen
->mmio
.map
, screen
->mmio
.size
);
449 __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__
);
452 screen
->scratch
= (__volatile__
uint32_t *)
453 ((GLubyte
*)screen
->status
.map
+ RADEON_SCRATCH_REG_OFFSET
);
455 screen
->buffers
= drmMapBufs( sPriv
->fd
);
456 if ( !screen
->buffers
) {
457 drmUnmap( screen
->status
.map
, screen
->status
.size
);
458 drmUnmap( screen
->mmio
.map
, screen
->mmio
.size
);
460 __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__
);
464 if ( dri_priv
->gartTexHandle
&& dri_priv
->gartTexMapSize
) {
465 screen
->gartTextures
.handle
= dri_priv
->gartTexHandle
;
466 screen
->gartTextures
.size
= dri_priv
->gartTexMapSize
;
467 if ( drmMap( sPriv
->fd
,
468 screen
->gartTextures
.handle
,
469 screen
->gartTextures
.size
,
470 (drmAddressPtr
)&screen
->gartTextures
.map
) ) {
471 drmUnmapBufs( screen
->buffers
);
472 drmUnmap( screen
->status
.map
, screen
->status
.size
);
473 drmUnmap( screen
->mmio
.map
, screen
->mmio
.size
);
475 __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__
);
479 screen
->gart_texture_offset
= dri_priv
->gartTexOffset
+ screen
->gart_base
;
482 screen
->chip_flags
= 0;
483 /* XXX: add more chipsets */
484 switch ( dri_priv
->deviceID
) {
485 case PCI_CHIP_RADEON_LY
:
486 case PCI_CHIP_RADEON_LZ
:
487 case PCI_CHIP_RADEON_QY
:
488 case PCI_CHIP_RADEON_QZ
:
489 case PCI_CHIP_RN50_515E
:
490 case PCI_CHIP_RN50_5969
:
491 screen
->chip_family
= CHIP_FAMILY_RV100
;
494 case PCI_CHIP_RS100_4136
:
495 case PCI_CHIP_RS100_4336
:
496 screen
->chip_family
= CHIP_FAMILY_RS100
;
499 case PCI_CHIP_RS200_4137
:
500 case PCI_CHIP_RS200_4337
:
501 case PCI_CHIP_RS250_4237
:
502 case PCI_CHIP_RS250_4437
:
503 screen
->chip_family
= CHIP_FAMILY_RS200
;
506 case PCI_CHIP_RADEON_QD
:
507 case PCI_CHIP_RADEON_QE
:
508 case PCI_CHIP_RADEON_QF
:
509 case PCI_CHIP_RADEON_QG
:
510 /* all original radeons (7200) presumably have a stencil op bug */
511 screen
->chip_family
= CHIP_FAMILY_R100
;
512 screen
->chip_flags
= RADEON_CHIPSET_TCL
| RADEON_CHIPSET_BROKEN_STENCIL
;
515 case PCI_CHIP_RV200_QW
:
516 case PCI_CHIP_RV200_QX
:
517 case PCI_CHIP_RADEON_LW
:
518 case PCI_CHIP_RADEON_LX
:
519 screen
->chip_family
= CHIP_FAMILY_RV200
;
520 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
523 case PCI_CHIP_R200_BB
:
524 case PCI_CHIP_R200_BC
:
525 case PCI_CHIP_R200_QH
:
526 case PCI_CHIP_R200_QL
:
527 case PCI_CHIP_R200_QM
:
528 screen
->chip_family
= CHIP_FAMILY_R200
;
529 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
532 case PCI_CHIP_RV250_If
:
533 case PCI_CHIP_RV250_Ig
:
534 case PCI_CHIP_RV250_Ld
:
535 case PCI_CHIP_RV250_Lf
:
536 case PCI_CHIP_RV250_Lg
:
537 screen
->chip_family
= CHIP_FAMILY_RV250
;
538 screen
->chip_flags
= R200_CHIPSET_YCBCR_BROKEN
| RADEON_CHIPSET_TCL
;
541 case PCI_CHIP_RV280_5960
:
542 case PCI_CHIP_RV280_5961
:
543 case PCI_CHIP_RV280_5962
:
544 case PCI_CHIP_RV280_5964
:
545 case PCI_CHIP_RV280_5965
:
546 case PCI_CHIP_RV280_5C61
:
547 case PCI_CHIP_RV280_5C63
:
548 screen
->chip_family
= CHIP_FAMILY_RV280
;
549 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
552 case PCI_CHIP_RS300_5834
:
553 case PCI_CHIP_RS300_5835
:
554 case PCI_CHIP_RS350_7834
:
555 case PCI_CHIP_RS350_7835
:
556 screen
->chip_family
= CHIP_FAMILY_RS300
;
559 /* 9500 with 1 pipe verified by: Reid Linnemann <lreid@cs.okstate.edu> */
560 case PCI_CHIP_R300_AD
:
561 screen
->chip_family
= CHIP_FAMILY_RV350
;
562 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
564 case PCI_CHIP_R300_AE
:
565 case PCI_CHIP_R300_AF
:
566 case PCI_CHIP_R300_AG
:
567 case PCI_CHIP_R300_ND
:
568 case PCI_CHIP_R300_NE
:
569 case PCI_CHIP_R300_NF
:
570 case PCI_CHIP_R300_NG
:
571 screen
->chip_family
= CHIP_FAMILY_R300
;
572 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
575 case PCI_CHIP_RV350_AP
:
576 case PCI_CHIP_RV350_AQ
:
577 case PCI_CHIP_RV350_AR
:
578 case PCI_CHIP_RV350_AS
:
579 case PCI_CHIP_RV350_AT
:
580 case PCI_CHIP_RV350_AV
:
581 case PCI_CHIP_RV350_AU
:
582 case PCI_CHIP_RV350_NP
:
583 case PCI_CHIP_RV350_NQ
:
584 case PCI_CHIP_RV350_NR
:
585 case PCI_CHIP_RV350_NS
:
586 case PCI_CHIP_RV350_NT
:
587 case PCI_CHIP_RV350_NV
:
588 screen
->chip_family
= CHIP_FAMILY_RV350
;
589 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
592 case PCI_CHIP_R350_AH
:
593 case PCI_CHIP_R350_AI
:
594 case PCI_CHIP_R350_AJ
:
595 case PCI_CHIP_R350_AK
:
596 case PCI_CHIP_R350_NH
:
597 case PCI_CHIP_R350_NI
:
598 case PCI_CHIP_R360_NJ
:
599 case PCI_CHIP_R350_NK
:
600 screen
->chip_family
= CHIP_FAMILY_R350
;
601 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
604 case PCI_CHIP_RV370_5460
:
605 case PCI_CHIP_RV370_5462
:
606 case PCI_CHIP_RV370_5464
:
607 case PCI_CHIP_RV370_5B60
:
608 case PCI_CHIP_RV370_5B62
:
609 case PCI_CHIP_RV370_5B63
:
610 case PCI_CHIP_RV370_5B64
:
611 case PCI_CHIP_RV370_5B65
:
612 case PCI_CHIP_RV380_3150
:
613 case PCI_CHIP_RV380_3152
:
614 case PCI_CHIP_RV380_3154
:
615 case PCI_CHIP_RV380_3E50
:
616 case PCI_CHIP_RV380_3E54
:
617 screen
->chip_family
= CHIP_FAMILY_RV380
;
618 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
621 case PCI_CHIP_R420_JN
:
622 case PCI_CHIP_R420_JH
:
623 case PCI_CHIP_R420_JI
:
624 case PCI_CHIP_R420_JJ
:
625 case PCI_CHIP_R420_JK
:
626 case PCI_CHIP_R420_JL
:
627 case PCI_CHIP_R420_JM
:
628 case PCI_CHIP_R420_JO
:
629 case PCI_CHIP_R420_JP
:
630 case PCI_CHIP_R420_JT
:
631 case PCI_CHIP_R481_4B49
:
632 case PCI_CHIP_R481_4B4A
:
633 case PCI_CHIP_R481_4B4B
:
634 case PCI_CHIP_R481_4B4C
:
635 case PCI_CHIP_R423_UH
:
636 case PCI_CHIP_R423_UI
:
637 case PCI_CHIP_R423_UJ
:
638 case PCI_CHIP_R423_UK
:
639 case PCI_CHIP_R430_554C
:
640 case PCI_CHIP_R430_554D
:
641 case PCI_CHIP_R430_554E
:
642 case PCI_CHIP_R430_554F
:
643 case PCI_CHIP_R423_5550
:
644 case PCI_CHIP_R423_UQ
:
645 case PCI_CHIP_R423_UR
:
646 case PCI_CHIP_R423_UT
:
647 case PCI_CHIP_R430_5D48
:
648 case PCI_CHIP_R430_5D49
:
649 case PCI_CHIP_R430_5D4A
:
650 case PCI_CHIP_R480_5D4C
:
651 case PCI_CHIP_R480_5D4D
:
652 case PCI_CHIP_R480_5D4E
:
653 case PCI_CHIP_R480_5D4F
:
654 case PCI_CHIP_R480_5D50
:
655 case PCI_CHIP_R480_5D52
:
656 case PCI_CHIP_R423_5D57
:
657 screen
->chip_family
= CHIP_FAMILY_R420
;
658 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
661 case PCI_CHIP_RV410_5E4C
:
662 case PCI_CHIP_RV410_5E4F
:
663 case PCI_CHIP_RV410_564A
:
664 case PCI_CHIP_RV410_564B
:
665 case PCI_CHIP_RV410_564F
:
666 case PCI_CHIP_RV410_5652
:
667 case PCI_CHIP_RV410_5653
:
668 case PCI_CHIP_RV410_5657
:
669 case PCI_CHIP_RV410_5E48
:
670 case PCI_CHIP_RV410_5E4A
:
671 case PCI_CHIP_RV410_5E4B
:
672 case PCI_CHIP_RV410_5E4D
:
673 screen
->chip_family
= CHIP_FAMILY_RV410
;
674 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
677 case PCI_CHIP_RS480_5954
:
678 case PCI_CHIP_RS480_5955
:
679 case PCI_CHIP_RS482_5974
:
680 case PCI_CHIP_RS482_5975
:
681 case PCI_CHIP_RS400_5A41
:
682 case PCI_CHIP_RS400_5A42
:
683 case PCI_CHIP_RC410_5A61
:
684 case PCI_CHIP_RC410_5A62
:
685 screen
->chip_family
= CHIP_FAMILY_RS400
;
688 case PCI_CHIP_RS690_791E
:
689 case PCI_CHIP_RS690_791F
:
690 screen
->chip_family
= CHIP_FAMILY_RS690
;
692 case PCI_CHIP_RS740_796C
:
693 case PCI_CHIP_RS740_796D
:
694 case PCI_CHIP_RS740_796E
:
695 case PCI_CHIP_RS740_796F
:
696 screen
->chip_family
= CHIP_FAMILY_RS740
;
699 case PCI_CHIP_R520_7100
:
700 case PCI_CHIP_R520_7101
:
701 case PCI_CHIP_R520_7102
:
702 case PCI_CHIP_R520_7103
:
703 case PCI_CHIP_R520_7104
:
704 case PCI_CHIP_R520_7105
:
705 case PCI_CHIP_R520_7106
:
706 case PCI_CHIP_R520_7108
:
707 case PCI_CHIP_R520_7109
:
708 case PCI_CHIP_R520_710A
:
709 case PCI_CHIP_R520_710B
:
710 case PCI_CHIP_R520_710C
:
711 case PCI_CHIP_R520_710E
:
712 case PCI_CHIP_R520_710F
:
713 screen
->chip_family
= CHIP_FAMILY_R520
;
714 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
717 case PCI_CHIP_RV515_7140
:
718 case PCI_CHIP_RV515_7141
:
719 case PCI_CHIP_RV515_7142
:
720 case PCI_CHIP_RV515_7143
:
721 case PCI_CHIP_RV515_7144
:
722 case PCI_CHIP_RV515_7145
:
723 case PCI_CHIP_RV515_7146
:
724 case PCI_CHIP_RV515_7147
:
725 case PCI_CHIP_RV515_7149
:
726 case PCI_CHIP_RV515_714A
:
727 case PCI_CHIP_RV515_714B
:
728 case PCI_CHIP_RV515_714C
:
729 case PCI_CHIP_RV515_714D
:
730 case PCI_CHIP_RV515_714E
:
731 case PCI_CHIP_RV515_714F
:
732 case PCI_CHIP_RV515_7151
:
733 case PCI_CHIP_RV515_7152
:
734 case PCI_CHIP_RV515_7153
:
735 case PCI_CHIP_RV515_715E
:
736 case PCI_CHIP_RV515_715F
:
737 case PCI_CHIP_RV515_7180
:
738 case PCI_CHIP_RV515_7181
:
739 case PCI_CHIP_RV515_7183
:
740 case PCI_CHIP_RV515_7186
:
741 case PCI_CHIP_RV515_7187
:
742 case PCI_CHIP_RV515_7188
:
743 case PCI_CHIP_RV515_718A
:
744 case PCI_CHIP_RV515_718B
:
745 case PCI_CHIP_RV515_718C
:
746 case PCI_CHIP_RV515_718D
:
747 case PCI_CHIP_RV515_718F
:
748 case PCI_CHIP_RV515_7193
:
749 case PCI_CHIP_RV515_7196
:
750 case PCI_CHIP_RV515_719B
:
751 case PCI_CHIP_RV515_719F
:
752 case PCI_CHIP_RV515_7200
:
753 case PCI_CHIP_RV515_7210
:
754 case PCI_CHIP_RV515_7211
:
755 screen
->chip_family
= CHIP_FAMILY_RV515
;
756 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
759 case PCI_CHIP_RV530_71C0
:
760 case PCI_CHIP_RV530_71C1
:
761 case PCI_CHIP_RV530_71C2
:
762 case PCI_CHIP_RV530_71C3
:
763 case PCI_CHIP_RV530_71C4
:
764 case PCI_CHIP_RV530_71C5
:
765 case PCI_CHIP_RV530_71C6
:
766 case PCI_CHIP_RV530_71C7
:
767 case PCI_CHIP_RV530_71CD
:
768 case PCI_CHIP_RV530_71CE
:
769 case PCI_CHIP_RV530_71D2
:
770 case PCI_CHIP_RV530_71D4
:
771 case PCI_CHIP_RV530_71D5
:
772 case PCI_CHIP_RV530_71D6
:
773 case PCI_CHIP_RV530_71DA
:
774 case PCI_CHIP_RV530_71DE
:
775 screen
->chip_family
= CHIP_FAMILY_RV530
;
776 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
779 case PCI_CHIP_R580_7240
:
780 case PCI_CHIP_R580_7243
:
781 case PCI_CHIP_R580_7244
:
782 case PCI_CHIP_R580_7245
:
783 case PCI_CHIP_R580_7246
:
784 case PCI_CHIP_R580_7247
:
785 case PCI_CHIP_R580_7248
:
786 case PCI_CHIP_R580_7249
:
787 case PCI_CHIP_R580_724A
:
788 case PCI_CHIP_R580_724B
:
789 case PCI_CHIP_R580_724C
:
790 case PCI_CHIP_R580_724D
:
791 case PCI_CHIP_R580_724E
:
792 case PCI_CHIP_R580_724F
:
793 case PCI_CHIP_R580_7284
:
794 screen
->chip_family
= CHIP_FAMILY_R580
;
795 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
798 case PCI_CHIP_RV570_7280
:
799 case PCI_CHIP_RV560_7281
:
800 case PCI_CHIP_RV560_7283
:
801 case PCI_CHIP_RV560_7287
:
802 case PCI_CHIP_RV570_7288
:
803 case PCI_CHIP_RV570_7289
:
804 case PCI_CHIP_RV570_728B
:
805 case PCI_CHIP_RV570_728C
:
806 case PCI_CHIP_RV560_7290
:
807 case PCI_CHIP_RV560_7291
:
808 case PCI_CHIP_RV560_7293
:
809 case PCI_CHIP_RV560_7297
:
810 screen
->chip_family
= CHIP_FAMILY_RV560
;
811 screen
->chip_flags
= RADEON_CHIPSET_TCL
;
815 fprintf(stderr
, "unknown chip id 0x%x, can't guess.\n",
819 if ((screen
->chip_family
== CHIP_FAMILY_R350
|| screen
->chip_family
== CHIP_FAMILY_R300
) &&
820 sPriv
->ddx_version
.minor
< 2) {
821 fprintf(stderr
, "xf86-video-ati-6.6.2 or newer needed for Radeon 9500/9700/9800 cards.\n");
825 if ((sPriv
->drm_version
.minor
< 29) && (screen
->chip_family
>= CHIP_FAMILY_RV515
)) {
826 fprintf(stderr
, "R500 support requires a newer drm.\n");
830 if (getenv("R300_NO_TCL"))
831 screen
->chip_flags
&= ~RADEON_CHIPSET_TCL
;
833 if (screen
->chip_family
<= CHIP_FAMILY_RS200
)
834 screen
->chip_flags
|= RADEON_CLASS_R100
;
835 else if (screen
->chip_family
<= CHIP_FAMILY_RV280
)
836 screen
->chip_flags
|= RADEON_CLASS_R200
;
838 screen
->chip_flags
|= RADEON_CLASS_R300
;
840 screen
->cpp
= dri_priv
->bpp
/ 8;
841 screen
->AGPMode
= dri_priv
->AGPMode
;
843 ret
= radeonGetParam( sPriv
->fd
, RADEON_PARAM_FB_LOCATION
,
846 if (screen
->chip_family
< CHIP_FAMILY_RS690
)
847 screen
->fbLocation
= ( INREG( RADEON_MC_FB_LOCATION
) & 0xffff) << 16;
850 fprintf(stderr
, "Unable to get fb location need newer drm\n");
854 screen
->fbLocation
= (temp
& 0xffff) << 16;
857 if (screen
->chip_family
>= CHIP_FAMILY_RV515
) {
858 ret
= radeonGetParam( sPriv
->fd
, RADEON_PARAM_NUM_GB_PIPES
,
861 fprintf(stderr
, "Unable to get num_pipes, need newer drm\n");
862 switch (screen
->chip_family
) {
863 case CHIP_FAMILY_R300
:
864 case CHIP_FAMILY_R350
:
865 screen
->num_gb_pipes
= 2;
867 case CHIP_FAMILY_R420
:
868 case CHIP_FAMILY_R520
:
869 case CHIP_FAMILY_R580
:
870 case CHIP_FAMILY_RV560
:
871 case CHIP_FAMILY_RV570
:
872 screen
->num_gb_pipes
= 4;
874 case CHIP_FAMILY_RV350
:
875 case CHIP_FAMILY_RV515
:
876 case CHIP_FAMILY_RV530
:
877 case CHIP_FAMILY_RV410
:
879 screen
->num_gb_pipes
= 1;
883 screen
->num_gb_pipes
= temp
;
887 if ( sPriv
->drm_version
.minor
>= 10 ) {
888 drm_radeon_setparam_t sp
;
890 sp
.param
= RADEON_SETPARAM_FB_LOCATION
;
891 sp
.value
= screen
->fbLocation
;
893 drmCommandWrite( sPriv
->fd
, DRM_RADEON_SETPARAM
,
897 screen
->frontOffset
= dri_priv
->frontOffset
;
898 screen
->frontPitch
= dri_priv
->frontPitch
;
899 screen
->backOffset
= dri_priv
->backOffset
;
900 screen
->backPitch
= dri_priv
->backPitch
;
901 screen
->depthOffset
= dri_priv
->depthOffset
;
902 screen
->depthPitch
= dri_priv
->depthPitch
;
904 /* Check if ddx has set up a surface reg to cover depth buffer */
905 screen
->depthHasSurface
= (sPriv
->ddx_version
.major
> 4) ||
906 /* these chips don't use tiled z without hyperz. So always pretend
907 we have set up a surface which will cause linear reads/writes */
908 (IS_R100_CLASS(screen
) &&
909 !(screen
->chip_flags
& RADEON_CHIPSET_TCL
));
911 if ( dri_priv
->textureSize
== 0 ) {
912 screen
->texOffset
[RADEON_LOCAL_TEX_HEAP
] = screen
->gart_texture_offset
;
913 screen
->texSize
[RADEON_LOCAL_TEX_HEAP
] = dri_priv
->gartTexMapSize
;
914 screen
->logTexGranularity
[RADEON_LOCAL_TEX_HEAP
] =
915 dri_priv
->log2GARTTexGran
;
917 screen
->texOffset
[RADEON_LOCAL_TEX_HEAP
] = dri_priv
->textureOffset
918 + screen
->fbLocation
;
919 screen
->texSize
[RADEON_LOCAL_TEX_HEAP
] = dri_priv
->textureSize
;
920 screen
->logTexGranularity
[RADEON_LOCAL_TEX_HEAP
] =
921 dri_priv
->log2TexGran
;
924 if ( !screen
->gartTextures
.map
|| dri_priv
->textureSize
== 0
925 || getenv( "RADEON_GARTTEXTURING_FORCE_DISABLE" ) ) {
926 screen
->numTexHeaps
= RADEON_NR_TEX_HEAPS
- 1;
927 screen
->texOffset
[RADEON_GART_TEX_HEAP
] = 0;
928 screen
->texSize
[RADEON_GART_TEX_HEAP
] = 0;
929 screen
->logTexGranularity
[RADEON_GART_TEX_HEAP
] = 0;
931 screen
->numTexHeaps
= RADEON_NR_TEX_HEAPS
;
932 screen
->texOffset
[RADEON_GART_TEX_HEAP
] = screen
->gart_texture_offset
;
933 screen
->texSize
[RADEON_GART_TEX_HEAP
] = dri_priv
->gartTexMapSize
;
934 screen
->logTexGranularity
[RADEON_GART_TEX_HEAP
] =
935 dri_priv
->log2GARTTexGran
;
939 screen
->extensions
[i
++] = &driCopySubBufferExtension
.base
;
940 screen
->extensions
[i
++] = &driFrameTrackingExtension
.base
;
941 screen
->extensions
[i
++] = &driReadDrawableExtension
;
943 if ( screen
->irq
!= 0 ) {
944 screen
->extensions
[i
++] = &driSwapControlExtension
.base
;
945 screen
->extensions
[i
++] = &driMediaStreamCounterExtension
.base
;
949 screen
->extensions
[i
++] = &radeonTexOffsetExtension
.base
;
952 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
953 if (IS_R200_CLASS(screen
))
954 screen
->extensions
[i
++] = &r200AllocateExtension
.base
;
956 screen
->extensions
[i
++] = &r200texOffsetExtension
.base
;
959 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
960 screen
->extensions
[i
++] = &r300texOffsetExtension
.base
;
963 screen
->extensions
[i
++] = NULL
;
964 sPriv
->extensions
= screen
->extensions
;
966 screen
->driScreen
= sPriv
;
967 screen
->sarea_priv_offset
= dri_priv
->sarea_priv_offset
;
971 /* Destroy the device specific screen private data struct.
974 radeonDestroyScreen( __DRIscreenPrivate
*sPriv
)
976 radeonScreenPtr screen
= (radeonScreenPtr
)sPriv
->private;
981 if ( screen
->gartTextures
.map
) {
982 drmUnmap( screen
->gartTextures
.map
, screen
->gartTextures
.size
);
984 drmUnmapBufs( screen
->buffers
);
985 drmUnmap( screen
->status
.map
, screen
->status
.size
);
986 drmUnmap( screen
->mmio
.map
, screen
->mmio
.size
);
988 /* free all option information */
989 driDestroyOptionInfo (&screen
->optionCache
);
992 sPriv
->private = NULL
;
996 /* Initialize the driver specific screen private data.
999 radeonInitDriver( __DRIscreenPrivate
*sPriv
)
1001 sPriv
->private = (void *) radeonCreateScreen( sPriv
);
1002 if ( !sPriv
->private ) {
1003 radeonDestroyScreen( sPriv
);
1012 * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
1014 * \todo This function (and its interface) will need to be updated to support
1018 radeonCreateBuffer( __DRIscreenPrivate
*driScrnPriv
,
1019 __DRIdrawablePrivate
*driDrawPriv
,
1020 const __GLcontextModes
*mesaVis
,
1021 GLboolean isPixmap
)
1023 radeonScreenPtr screen
= (radeonScreenPtr
) driScrnPriv
->private;
1026 return GL_FALSE
; /* not implemented */
1029 const GLboolean swDepth
= GL_FALSE
;
1030 const GLboolean swAlpha
= GL_FALSE
;
1031 const GLboolean swAccum
= mesaVis
->accumRedBits
> 0;
1032 const GLboolean swStencil
= mesaVis
->stencilBits
> 0 &&
1033 mesaVis
->depthBits
!= 24;
1034 struct gl_framebuffer
*fb
= _mesa_create_framebuffer(mesaVis
);
1036 /* front color renderbuffer */
1038 driRenderbuffer
*frontRb
1039 = driNewRenderbuffer(GL_RGBA
,
1040 driScrnPriv
->pFB
+ screen
->frontOffset
,
1042 screen
->frontOffset
, screen
->frontPitch
,
1044 radeonSetSpanFunctions(frontRb
, mesaVis
);
1045 _mesa_add_renderbuffer(fb
, BUFFER_FRONT_LEFT
, &frontRb
->Base
);
1048 /* back color renderbuffer */
1049 if (mesaVis
->doubleBufferMode
) {
1050 driRenderbuffer
*backRb
1051 = driNewRenderbuffer(GL_RGBA
,
1052 driScrnPriv
->pFB
+ screen
->backOffset
,
1054 screen
->backOffset
, screen
->backPitch
,
1056 radeonSetSpanFunctions(backRb
, mesaVis
);
1057 _mesa_add_renderbuffer(fb
, BUFFER_BACK_LEFT
, &backRb
->Base
);
1060 /* depth renderbuffer */
1061 if (mesaVis
->depthBits
== 16) {
1062 driRenderbuffer
*depthRb
1063 = driNewRenderbuffer(GL_DEPTH_COMPONENT16
,
1064 driScrnPriv
->pFB
+ screen
->depthOffset
,
1066 screen
->depthOffset
, screen
->depthPitch
,
1068 radeonSetSpanFunctions(depthRb
, mesaVis
);
1069 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
1070 depthRb
->depthHasSurface
= screen
->depthHasSurface
;
1072 else if (mesaVis
->depthBits
== 24) {
1073 driRenderbuffer
*depthRb
1074 = driNewRenderbuffer(GL_DEPTH_COMPONENT24
,
1075 driScrnPriv
->pFB
+ screen
->depthOffset
,
1077 screen
->depthOffset
, screen
->depthPitch
,
1079 radeonSetSpanFunctions(depthRb
, mesaVis
);
1080 _mesa_add_renderbuffer(fb
, BUFFER_DEPTH
, &depthRb
->Base
);
1081 depthRb
->depthHasSurface
= screen
->depthHasSurface
;
1084 /* stencil renderbuffer */
1085 if (mesaVis
->stencilBits
> 0 && !swStencil
) {
1086 driRenderbuffer
*stencilRb
1087 = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT
,
1088 driScrnPriv
->pFB
+ screen
->depthOffset
,
1090 screen
->depthOffset
, screen
->depthPitch
,
1092 radeonSetSpanFunctions(stencilRb
, mesaVis
);
1093 _mesa_add_renderbuffer(fb
, BUFFER_STENCIL
, &stencilRb
->Base
);
1094 stencilRb
->depthHasSurface
= screen
->depthHasSurface
;
1097 _mesa_add_soft_renderbuffers(fb
,
1098 GL_FALSE
, /* color */
1103 GL_FALSE
/* aux */);
1104 driDrawPriv
->driverPrivate
= (void *) fb
;
1106 return (driDrawPriv
->driverPrivate
!= NULL
);
1112 radeonDestroyBuffer(__DRIdrawablePrivate
*driDrawPriv
)
1114 _mesa_unreference_framebuffer((GLframebuffer
**)(&(driDrawPriv
->driverPrivate
)));
1117 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
1119 * Choose the appropriate CreateContext function based on the chipset.
1120 * Eventually, all drivers will go through this process.
1122 static GLboolean
radeonCreateContext(const __GLcontextModes
* glVisual
,
1123 __DRIcontextPrivate
* driContextPriv
,
1124 void *sharedContextPriv
)
1126 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
1127 radeonScreenPtr screen
= (radeonScreenPtr
) (sPriv
->private);
1129 if (IS_R300_CLASS(screen
))
1130 return r300CreateContext(glVisual
, driContextPriv
, sharedContextPriv
);
1135 * Choose the appropriate DestroyContext function based on the chipset.
1137 static void radeonDestroyContext(__DRIcontextPrivate
* driContextPriv
)
1139 radeonContextPtr radeon
= (radeonContextPtr
) driContextPriv
->driverPrivate
;
1141 if (IS_R300_CLASS(radeon
->radeonScreen
))
1142 return r300DestroyContext(driContextPriv
);
1150 * This is the driver specific part of the createNewScreen entry point.
1152 * \todo maybe fold this into intelInitDriver
1154 * \return the __GLcontextModes supported by this driver
1156 static const __DRIconfig
**
1157 radeonInitScreen(__DRIscreenPrivate
*psp
)
1160 static const char *driver_name
= "Radeon";
1161 static const __DRIutilversion2 ddx_expected
= { 4, 5, 0, 0 };
1162 static const __DRIversion dri_expected
= { 4, 0, 0 };
1163 static const __DRIversion drm_expected
= { 1, 6, 0 };
1164 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1165 static const char *driver_name
= "R200";
1166 static const __DRIutilversion2 ddx_expected
= { 4, 5, 0, 0 };
1167 static const __DRIversion dri_expected
= { 4, 0, 0 };
1168 static const __DRIversion drm_expected
= { 1, 6, 0 };
1169 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
1170 static const char *driver_name
= "R300";
1171 static const __DRIutilversion2 ddx_expected
= { 4, 5, 0, 0 };
1172 static const __DRIversion dri_expected
= { 4, 0, 0 };
1173 static const __DRIversion drm_expected
= { 1, 24, 0 };
1175 RADEONDRIPtr dri_priv
= (RADEONDRIPtr
) psp
->pDevPriv
;
1177 if ( ! driCheckDriDdxDrmVersions3( driver_name
,
1178 &psp
->dri_version
, & dri_expected
,
1179 &psp
->ddx_version
, & ddx_expected
,
1180 &psp
->drm_version
, & drm_expected
) ) {
1184 /* Calling driInitExtensions here, with a NULL context pointer,
1185 * does not actually enable the extensions. It just makes sure
1186 * that all the dispatch offsets for all the extensions that
1187 * *might* be enables are known. This is needed because the
1188 * dispatch offsets need to be known when _mesa_context_create
1189 * is called, but we can't enable the extensions until we have a
1192 * Hello chicken. Hello egg. How are you two today?
1194 driInitExtensions( NULL
, card_extensions
, GL_FALSE
);
1195 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1196 driInitExtensions( NULL
, blend_extensions
, GL_FALSE
);
1197 driInitSingleExtension( NULL
, ARB_vp_extension
);
1198 driInitSingleExtension( NULL
, NV_vp_extension
);
1199 driInitSingleExtension( NULL
, ATI_fs_extension
);
1200 driInitExtensions( NULL
, point_extensions
, GL_FALSE
);
1201 #elif defined(RADEON_COMMON_FOR_R300)
1202 driInitSingleExtension( NULL
, gl_20_extension
);
1205 if (!radeonInitDriver(psp
))
1208 return radeonFillInModes( psp
,
1210 (dri_priv
->bpp
== 16) ? 16 : 24,
1211 (dri_priv
->bpp
== 16) ? 0 : 8,
1212 (dri_priv
->backOffset
!= dri_priv
->depthOffset
) );
1217 * Get information about previous buffer swaps.
1220 getSwapInfo( __DRIdrawablePrivate
*dPriv
, __DRIswapInfo
* sInfo
)
1222 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
1223 radeonContextPtr rmesa
;
1224 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1225 r200ContextPtr rmesa
;
1228 if ( (dPriv
== NULL
) || (dPriv
->driContextPriv
== NULL
)
1229 || (dPriv
->driContextPriv
->driverPrivate
== NULL
)
1230 || (sInfo
== NULL
) ) {
1234 rmesa
= dPriv
->driContextPriv
->driverPrivate
;
1235 sInfo
->swap_count
= rmesa
->swap_count
;
1236 sInfo
->swap_ust
= rmesa
->swap_ust
;
1237 sInfo
->swap_missed_count
= rmesa
->swap_missed_count
;
1239 sInfo
->swap_missed_usage
= (sInfo
->swap_missed_count
!= 0)
1240 ? driCalculateSwapUsage( dPriv
, 0, rmesa
->swap_missed_ust
)
1246 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
1247 const struct __DriverAPIRec driDriverAPI
= {
1248 .InitScreen
= radeonInitScreen
,
1249 .DestroyScreen
= radeonDestroyScreen
,
1250 .CreateContext
= radeonCreateContext
,
1251 .DestroyContext
= radeonDestroyContext
,
1252 .CreateBuffer
= radeonCreateBuffer
,
1253 .DestroyBuffer
= radeonDestroyBuffer
,
1254 .SwapBuffers
= radeonSwapBuffers
,
1255 .MakeCurrent
= radeonMakeCurrent
,
1256 .UnbindContext
= radeonUnbindContext
,
1257 .GetSwapInfo
= getSwapInfo
,
1258 .GetDrawableMSC
= driDrawableGetMSC32
,
1259 .WaitForMSC
= driWaitForMSC32
,
1261 .SwapBuffersMSC
= NULL
,
1262 .CopySubBuffer
= radeonCopySubBuffer
,
1265 const struct __DriverAPIRec driDriverAPI
= {
1266 .InitScreen
= radeonInitScreen
,
1267 .DestroyScreen
= radeonDestroyScreen
,
1268 .CreateContext
= r200CreateContext
,
1269 .DestroyContext
= r200DestroyContext
,
1270 .CreateBuffer
= radeonCreateBuffer
,
1271 .DestroyBuffer
= radeonDestroyBuffer
,
1272 .SwapBuffers
= r200SwapBuffers
,
1273 .MakeCurrent
= r200MakeCurrent
,
1274 .UnbindContext
= r200UnbindContext
,
1275 .GetSwapInfo
= getSwapInfo
,
1276 .GetDrawableMSC
= driDrawableGetMSC32
,
1277 .WaitForMSC
= driWaitForMSC32
,
1279 .SwapBuffersMSC
= NULL
,
1280 .CopySubBuffer
= r200CopySubBuffer
,