1 /* -*- mode: c; c-basic-offset: 3 -*- */
3 * Copyright 2000 Gareth Hughes
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Gareth Hughes <gareth@valinux.com>
28 * Leif Delgass <ldelgass@retinalburn.net>
29 * José Fonseca <j_r_fonseca@yahoo.co.uk>
32 #include "mach64_context.h"
33 #include "mach64_ioctl.h"
34 #include "mach64_state.h"
35 #include "mach64_vb.h"
36 #include "mach64_dd.h"
40 #include "framebuffer.h"
42 #define DRIVER_DATE "20051019"
44 /* Return the current color buffer size.
46 static void mach64DDGetBufferSize( GLframebuffer
*buffer
,
47 GLuint
*width
, GLuint
*height
)
49 GET_CURRENT_CONTEXT(ctx
);
50 mach64ContextPtr mmesa
= MACH64_CONTEXT(ctx
);
52 LOCK_HARDWARE( mmesa
);
53 *width
= mmesa
->driDrawable
->w
;
54 *height
= mmesa
->driDrawable
->h
;
55 UNLOCK_HARDWARE( mmesa
);
58 /* Return various strings for glGetString().
60 static const GLubyte
*mach64DDGetString( GLcontext
*ctx
, GLenum name
)
62 mach64ContextPtr mmesa
= MACH64_CONTEXT(ctx
);
63 static char buffer
[128];
65 const char * card_name
= "Mach64 [Rage Pro]";
66 GLuint agp_mode
= mmesa
->mach64Screen
->IsPCI
? 0 :
67 mmesa
->mach64Screen
->AGPMode
;
71 return (GLubyte
*)"Gareth Hughes, Leif Delgass, José Fonseca";
75 offset
= driGetRendererString( buffer
, card_name
, DRIVER_DATE
,
77 return (GLubyte
*)buffer
;
84 /* Send all commands to the hardware. If vertex buffers or indirect
85 * buffers are in use, then we need to make sure they are sent to the
86 * hardware. All commands that are normally sent to the ring are
87 * already considered `flushed'.
89 static void mach64DDFlush( GLcontext
*ctx
)
91 mach64ContextPtr mmesa
= MACH64_CONTEXT(ctx
);
93 LOCK_HARDWARE( mmesa
);
94 FLUSH_DMA_LOCKED( mmesa
);
95 UNLOCK_HARDWARE( mmesa
);
99 LOCK_HARDWARE( mmesa
);
100 mach64PerformanceBoxesLocked( mmesa
);
101 UNLOCK_HARDWARE( mmesa
);
104 /* Log the performance counters if necessary */
105 mach64PerformanceCounters( mmesa
);
109 /* Make sure all commands have been sent to the hardware and have
110 * completed processing.
112 static void mach64DDFinish( GLcontext
*ctx
)
114 mach64ContextPtr mmesa
= MACH64_CONTEXT(ctx
);
116 #if ENABLE_PERF_BOXES
117 /* Bump the performance counter */
118 mmesa
->c_drawWaits
++;
121 mach64DDFlush( ctx
);
122 mach64WaitForIdle( mmesa
);
125 /* Initialize the driver's misc functions.
127 void mach64InitDriverFuncs( struct dd_function_table
*functions
)
129 functions
->GetBufferSize
= mach64DDGetBufferSize
;
130 functions
->GetString
= mach64DDGetString
;
131 functions
->Finish
= mach64DDFinish
;
132 functions
->Flush
= mach64DDFlush
;