cca382d89266c3c395a142f81e3fc63e033731b6
[mesa.git] / src / mesa / drivers / dri / gamma / gamma_dd.c
1 /*
2 * Copyright 2001 by Alan Hourihane.
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@tungstengraphics.com>
23 *
24 */
25
26 #include "gamma_context.h"
27 #include "gamma_vb.h"
28 #include "gamma_lock.h"
29 #if defined(USE_X86_ASM)
30 #include "x86/common_x86_asm.h"
31 #endif
32
33 #include "context.h"
34 #include "swrast/swrast.h"
35
36 #define GAMMA_DATE "20021125"
37
38
39 /* Return the width and height of the current color buffer.
40 */
41 static void gammaDDGetBufferSize( GLframebuffer *buffer,
42 GLuint *width, GLuint *height )
43 {
44 GET_CURRENT_CONTEXT(ctx);
45 gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
46
47 GAMMAHW_LOCK( gmesa );
48 *width = gmesa->driDrawable->w;
49 *height = gmesa->driDrawable->h;
50 GAMMAHW_UNLOCK( gmesa );
51 }
52
53
54 /* Return various strings for glGetString().
55 */
56 static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name )
57 {
58 static char buffer[128];
59
60 switch ( name ) {
61 case GL_VENDOR:
62 return (GLubyte *)"VA Linux Systems, Inc.";
63
64 case GL_RENDERER:
65 sprintf( buffer, "Mesa DRI Gamma " GAMMA_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 gammaDDInitExtensions( GLcontext *ctx )
99 {
100 /* None... */
101 }
102
103 /* Initialize the driver's misc functions.
104 */
105 void gammaDDInitDriverFuncs( GLcontext *ctx )
106 {
107 ctx->Driver.GetBufferSize = gammaDDGetBufferSize;
108 ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
109 ctx->Driver.GetString = gammaDDGetString;
110
111 ctx->Driver.Error = NULL;
112
113 /* Pixel path fallbacks
114 */
115 ctx->Driver.Accum = _swrast_Accum;
116 ctx->Driver.Bitmap = _swrast_Bitmap;
117 ctx->Driver.CopyPixels = _swrast_CopyPixels;
118 ctx->Driver.DrawPixels = _swrast_DrawPixels;
119 ctx->Driver.ReadPixels = _swrast_ReadPixels;
120 ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
121
122 /* Swrast hooks for imaging extensions:
123 */
124 ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
125 ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
126 ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
127 ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
128 }