8c3af2001665de27fd86fec231b14c22d5f0c227
[mesa.git] / src / mesa / drivers / dri / trident / trident_dd.c
1 /*
2 * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Alan Hourihane not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Alan Hourihane makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
13 *
14 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 *
22 * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
23 *
24 * Trident CyberBladeXP driver.
25 *
26 */
27 #include "trident_context.h"
28 #include "trident_lock.h"
29 #if defined(USE_X86_ASM)
30 #include "x86/common_x86_asm.h"
31 #endif
32
33 #include "swrast/swrast.h"
34 #include "context.h"
35 #include "framebuffer.h"
36
37 #define TRIDENT_DATE "20041223"
38
39 /* Return the width and height of the current color buffer.
40 */
41 static void tridentDDGetBufferSize( GLframebuffer *framebuffer,
42 GLuint *width, GLuint *height )
43 {
44 GET_CURRENT_CONTEXT(ctx);
45 tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
46
47 LOCK_HARDWARE(tmesa);
48 *width = tmesa->driDrawable->w;
49 *height = tmesa->driDrawable->h;
50 UNLOCK_HARDWARE(tmesa);
51 }
52
53
54 /* Return various strings for glGetString().
55 */
56 static const GLubyte *tridentDDGetString( GLcontext *ctx, GLenum name )
57 {
58 static char buffer[128];
59
60 switch ( name ) {
61 case GL_VENDOR:
62 return (GLubyte *)"Alan Hourihane";
63
64 case GL_RENDERER:
65 sprintf( buffer, "Mesa DRI Trident " TRIDENT_DATE );
66
67 /* Append any CPU-specific information.
68 */
69 #ifdef USE_X86_ASM
70 if ( _mesa_x86_cpu_features ) {
71 strncat( buffer, " x86", 4 );
72 }
73 #ifdef USE_MMX_ASM
74 if ( cpu_has_mmx ) {
75 strncat( buffer, "/MMX", 4 );
76 }
77 #endif
78 #ifdef USE_3DNOW_ASM
79 if ( cpu_has_3dnow ) {
80 strncat( buffer, "/3DNow!", 7 );
81 }
82 #endif
83 #ifdef USE_SSE_ASM
84 if ( cpu_has_xmm ) {
85 strncat( buffer, "/SSE", 4 );
86 }
87 #endif
88 #endif
89 return (GLubyte *)buffer;
90
91 default:
92 return NULL;
93 }
94 }
95
96 /* Enable the extensions supported by this driver.
97 */
98 void tridentDDInitExtensions( GLcontext *ctx )
99 {
100 /* None... */
101 }
102
103 /* Initialize the driver's misc functions.
104 */
105 void tridentDDInitDriverFuncs( GLcontext *ctx )
106 {
107 ctx->Driver.GetBufferSize = tridentDDGetBufferSize;
108 ctx->Driver.GetString = tridentDDGetString;
109
110 ctx->Driver.Error = NULL;
111
112 /* Pixel path fallbacks
113 */
114 ctx->Driver.Accum = _swrast_Accum;
115 ctx->Driver.Bitmap = _swrast_Bitmap;
116 ctx->Driver.CopyPixels = _swrast_CopyPixels;
117 ctx->Driver.DrawPixels = _swrast_DrawPixels;
118 ctx->Driver.ReadPixels = _swrast_ReadPixels;
119 ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
120
121 /* Swrast hooks for imaging extensions:
122 */
123 ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
124 ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
125 ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
126 ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
127 }