1 /**************************************************************************
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Gareth Hughes <gareth@valinux.com>
31 * Kevin E. Martin <martin@valinux.com>
35 #include "r128_context.h"
36 #include "r128_ioctl.h"
39 #include "main/context.h"
43 /* Return the width and height of the current color buffer.
45 static void r128GetBufferSize( struct gl_framebuffer *buffer,
46 GLuint *width, GLuint *height )
48 GET_CURRENT_CONTEXT(ctx);
49 r128ContextPtr rmesa = R128_CONTEXT(ctx);
51 LOCK_HARDWARE( rmesa );
52 *width = rmesa->driDrawable->w;
53 *height = rmesa->driDrawable->h;
54 UNLOCK_HARDWARE( rmesa );
57 /* Return various strings for glGetString().
59 static const GLubyte *r128GetString( struct gl_context *ctx, GLenum name )
61 r128ContextPtr rmesa = R128_CONTEXT(ctx);
62 static char buffer[128];
64 const char * card_name = "Rage 128";
65 GLuint agp_mode = rmesa->r128Screen->IsPCI ? 0 :
66 rmesa->r128Screen->AGPMode;
70 return (GLubyte *)"VA Linux Systems, Inc.";
73 /* Select the spefic chipset.
75 if ( R128_IS_PRO( rmesa ) ) {
76 card_name = "Rage 128 Pro";
78 else if ( R128_IS_MOBILITY( rmesa ) ) {
79 card_name = "Rage 128 Mobility";
82 offset = driGetRendererString( buffer, card_name, agp_mode );
84 return (GLubyte *)buffer;
91 /* Send all commands to the hardware. If vertex buffers or indirect
92 * buffers are in use, then we need to make sure they are sent to the
93 * hardware. All commands that are normally sent to the ring are
94 * already considered `flushed'.
96 static void r128Flush( struct gl_context *ctx )
98 r128ContextPtr rmesa = R128_CONTEXT(ctx);
100 FLUSH_BATCH( rmesa );
102 #if ENABLE_PERF_BOXES
103 if ( rmesa->boxes ) {
104 LOCK_HARDWARE( rmesa );
105 r128PerformanceBoxesLocked( rmesa );
106 UNLOCK_HARDWARE( rmesa );
109 /* Log the performance counters if necessary */
110 r128PerformanceCounters( rmesa );
114 /* Make sure all commands have been sent to the hardware and have
115 * completed processing.
117 static void r128Finish( struct gl_context *ctx )
119 r128ContextPtr rmesa = R128_CONTEXT(ctx);
121 #if ENABLE_PERF_BOXES
122 /* Bump the performance counter */
123 rmesa->c_drawWaits++;
127 r128WaitForIdle( rmesa );
131 /* Initialize the driver's misc functions.
133 void r128InitDriverFuncs( struct dd_function_table *functions )
135 functions->GetBufferSize = r128GetBufferSize;
136 functions->GetString = r128GetString;
137 functions->Finish = r128Finish;
138 functions->Flush = r128Flush;