blob: 1e44904b930a450ab5e6834320c9014543f0b7e7 [file] [log] [blame]
Brian Paul988a8862004-01-20 02:36:44 +00001/*
2 * Mesa 3-D graphics library
Brian Paul4fb99502005-09-02 13:42:49 +00003 * Version: 6.5
Brian Paul988a8862004-01-20 02:36:44 +00004 *
Brian Paul2c6f9112005-02-24 05:47:06 +00005 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
Brian Paul988a8862004-01-20 02:36:44 +00006 *
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * 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.
23 */
24
25
26#include "glheader.h"
27#include "imports.h"
28#include "buffers.h"
29#include "context.h"
Brian Paule4b23562005-05-04 20:11:35 +000030#include "framebuffer.h"
Brian Paul4fb99502005-09-02 13:42:49 +000031#include "occlude.h"
Brian Paul4d859f72004-01-23 18:57:05 +000032#include "program.h"
Brian Paule4b23562005-05-04 20:11:35 +000033#include "renderbuffer.h"
Brian Paul8f04c122004-04-27 13:39:20 +000034#include "texcompress.h"
Brian Paul988a8862004-01-20 02:36:44 +000035#include "texformat.h"
36#include "teximage.h"
37#include "texobj.h"
38#include "texstore.h"
Brian Paul2c6f9112005-02-24 05:47:06 +000039#if FEATURE_ARB_vertex_buffer_object
Brian Paul988a8862004-01-20 02:36:44 +000040#include "bufferobj.h"
Brian Paul2c6f9112005-02-24 05:47:06 +000041#endif
42#if FEATURE_EXT_framebuffer_object
43#include "fbobject.h"
Brian Paule4b23562005-05-04 20:11:35 +000044#include "texrender.h"
Brian Paul2c6f9112005-02-24 05:47:06 +000045#endif
Ian Romanickee34e6e2006-06-12 16:26:29 +000046#include "arrayobj.h"
Brian Paul988a8862004-01-20 02:36:44 +000047
48#include "driverfuncs.h"
Brian Paulb5ee3682005-10-28 14:32:49 +000049#include "tnl/tnl.h"
Brian Paul988a8862004-01-20 02:36:44 +000050#include "swrast/swrast.h"
51
52
53
54/**
55 * Plug in default functions for all pointers in the dd_function_table
56 * structure.
57 * Device drivers should call this function and then plug in any
58 * functions which it wants to override.
59 * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
60 *
61 * \param table the dd_function_table to initialize
62 */
63void
64_mesa_init_driver_functions(struct dd_function_table *driver)
65{
66 _mesa_bzero(driver, sizeof(*driver));
67
68 driver->GetString = NULL; /* REQUIRED! */
69 driver->UpdateState = NULL; /* REQUIRED! */
70 driver->GetBufferSize = NULL; /* REQUIRED! */
Brian Paule4b23562005-05-04 20:11:35 +000071 driver->ResizeBuffers = _mesa_resize_framebuffer;
Brian Paul988a8862004-01-20 02:36:44 +000072 driver->Error = NULL;
73
74 driver->Finish = NULL;
75 driver->Flush = NULL;
76
77 /* framebuffer/image functions */
78 driver->Clear = _swrast_Clear;
79 driver->Accum = _swrast_Accum;
80 driver->DrawPixels = _swrast_DrawPixels;
81 driver->ReadPixels = _swrast_ReadPixels;
82 driver->CopyPixels = _swrast_CopyPixels;
83 driver->Bitmap = _swrast_Bitmap;
84
85 /* Texture functions */
86 driver->ChooseTextureFormat = _mesa_choose_tex_format;
87 driver->TexImage1D = _mesa_store_teximage1d;
88 driver->TexImage2D = _mesa_store_teximage2d;
89 driver->TexImage3D = _mesa_store_teximage3d;
90 driver->TexSubImage1D = _mesa_store_texsubimage1d;
91 driver->TexSubImage2D = _mesa_store_texsubimage2d;
92 driver->TexSubImage3D = _mesa_store_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +000093 driver->GetTexImage = _mesa_get_teximage;
Brian Paul988a8862004-01-20 02:36:44 +000094 driver->CopyTexImage1D = _swrast_copy_teximage1d;
95 driver->CopyTexImage2D = _swrast_copy_teximage2d;
96 driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
97 driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
98 driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
99 driver->TestProxyTexImage = _mesa_test_proxy_teximage;
100 driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
101 driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
102 driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
103 driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
104 driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
105 driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +0000106 driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
Brian Paul8f04c122004-04-27 13:39:20 +0000107 driver->CompressedTextureSize = _mesa_compressed_texture_size;
Brian Paul988a8862004-01-20 02:36:44 +0000108 driver->BindTexture = NULL;
109 driver->NewTextureObject = _mesa_new_texture_object;
110 driver->DeleteTexture = _mesa_delete_texture_object;
111 driver->NewTextureImage = _mesa_new_texture_image;
Keith Whitwell3e62d3a2005-03-22 14:27:10 +0000112 driver->FreeTexImageData = _mesa_free_texture_image_data;
Keith Whitwell17bcf9f2005-05-23 12:17:27 +0000113 driver->TextureMemCpy = _mesa_memcpy;
Brian Paul988a8862004-01-20 02:36:44 +0000114 driver->IsTextureResident = NULL;
115 driver->PrioritizeTexture = NULL;
116 driver->ActiveTexture = NULL;
117 driver->UpdateTexturePalette = NULL;
118
119 /* imaging */
120 driver->CopyColorTable = _swrast_CopyColorTable;
121 driver->CopyColorSubTable = _swrast_CopyColorSubTable;
122 driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
123 driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
124
Brian Paul4d859f72004-01-23 18:57:05 +0000125 /* Vertex/fragment programs */
126 driver->BindProgram = NULL;
127 driver->NewProgram = _mesa_new_program;
128 driver->DeleteProgram = _mesa_delete_program;
Brian Paul39c4daa2006-10-10 21:43:31 +0000129#if FEATURE_MESA_program_debug
130 driver->GetFragmentProgramRegister = _swrast_get_program_register;
131#endif /* FEATURE_MESA_program_debug */
Brian Paul4d859f72004-01-23 18:57:05 +0000132
Brian Paul988a8862004-01-20 02:36:44 +0000133 /* simple state commands */
134 driver->AlphaFunc = NULL;
135 driver->BlendColor = NULL;
Ian Romanickc93105e2004-01-27 18:52:40 +0000136 driver->BlendEquationSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000137 driver->BlendFuncSeparate = NULL;
138 driver->ClearColor = NULL;
139 driver->ClearDepth = NULL;
140 driver->ClearIndex = NULL;
141 driver->ClearStencil = NULL;
142 driver->ClipPlane = NULL;
143 driver->ColorMask = NULL;
144 driver->ColorMaterial = NULL;
145 driver->CullFace = NULL;
Brian Paulacafeeb2005-09-03 16:57:58 +0000146 driver->DrawBuffer = NULL;
147 driver->DrawBuffers = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000148 driver->FrontFace = NULL;
149 driver->DepthFunc = NULL;
150 driver->DepthMask = NULL;
151 driver->DepthRange = NULL;
152 driver->Enable = NULL;
153 driver->Fogfv = NULL;
154 driver->Hint = NULL;
155 driver->IndexMask = NULL;
156 driver->Lightfv = NULL;
157 driver->LightModelfv = NULL;
158 driver->LineStipple = NULL;
159 driver->LineWidth = NULL;
160 driver->LogicOpcode = NULL;
161 driver->PointParameterfv = NULL;
162 driver->PointSize = NULL;
163 driver->PolygonMode = NULL;
164 driver->PolygonOffset = NULL;
165 driver->PolygonStipple = NULL;
166 driver->ReadBuffer = NULL;
167 driver->RenderMode = NULL;
168 driver->Scissor = NULL;
169 driver->ShadeModel = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000170 driver->StencilFuncSeparate = NULL;
Brian Paul5179f672005-09-13 01:17:01 +0000171 driver->StencilOpSeparate = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000172 driver->StencilMaskSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000173 driver->TexGen = NULL;
174 driver->TexEnv = NULL;
175 driver->TexParameter = NULL;
176 driver->TextureMatrix = NULL;
177 driver->Viewport = NULL;
178
179 /* vertex arrays */
180 driver->VertexPointer = NULL;
181 driver->NormalPointer = NULL;
182 driver->ColorPointer = NULL;
183 driver->FogCoordPointer = NULL;
184 driver->IndexPointer = NULL;
185 driver->SecondaryColorPointer = NULL;
186 driver->TexCoordPointer = NULL;
187 driver->EdgeFlagPointer = NULL;
188 driver->VertexAttribPointer = NULL;
189 driver->LockArraysEXT = NULL;
190 driver->UnlockArraysEXT = NULL;
191
192 /* state queries */
193 driver->GetBooleanv = NULL;
194 driver->GetDoublev = NULL;
195 driver->GetFloatv = NULL;
196 driver->GetIntegerv = NULL;
197 driver->GetPointerv = NULL;
198
199#if FEATURE_ARB_vertex_buffer_object
200 driver->NewBufferObject = _mesa_new_buffer_object;
201 driver->DeleteBuffer = _mesa_delete_buffer_object;
202 driver->BindBuffer = NULL;
203 driver->BufferData = _mesa_buffer_data;
204 driver->BufferSubData = _mesa_buffer_subdata;
205 driver->GetBufferSubData = _mesa_buffer_get_subdata;
206 driver->MapBuffer = _mesa_buffer_map;
Brian Paul7eab3372004-10-31 15:23:42 +0000207 driver->UnmapBuffer = _mesa_buffer_unmap;
Brian Paul988a8862004-01-20 02:36:44 +0000208#endif
209
Brian Paul2c6f9112005-02-24 05:47:06 +0000210#if FEATURE_EXT_framebuffer_object
211 driver->NewFramebuffer = _mesa_new_framebuffer;
Brian Paule4b23562005-05-04 20:11:35 +0000212 driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
Brian Paulea4fe662006-03-26 05:22:17 +0000213 driver->RenderTexture = _mesa_render_texture;
214 driver->FinishRenderTexture = _mesa_finish_render_texture;
Brian Paule4b23562005-05-04 20:11:35 +0000215 driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
Brian Paul2c6f9112005-02-24 05:47:06 +0000216#endif
217
Brian Paulafa1df52006-03-02 03:45:28 +0000218#if FEATURE_EXT_framebuffer_blit
219 driver->BlitFramebuffer = _swrast_BlitFramebuffer;
220#endif
221
Brian Paul23ffc3a2005-08-27 13:56:08 +0000222 /* query objects */
Brian Paul4fb99502005-09-02 13:42:49 +0000223 driver->NewQueryObject = _mesa_new_query_object;
Brian Paul23ffc3a2005-08-27 13:56:08 +0000224 driver->BeginQuery = NULL;
225 driver->EndQuery = NULL;
226
Ian Romanickee34e6e2006-06-12 16:26:29 +0000227 /* APPLE_vertex_array_object */
228 driver->NewArrayObject = _mesa_new_array_object;
229 driver->DeleteArrayObject = _mesa_delete_array_object;
230 driver->BindArrayObject = NULL;
231
Brian Paul988a8862004-01-20 02:36:44 +0000232 /* T&L stuff */
233 driver->NeedValidate = GL_FALSE;
234 driver->ValidateTnlModule = NULL;
235 driver->CurrentExecPrimitive = 0;
236 driver->CurrentSavePrimitive = 0;
237 driver->NeedFlush = 0;
238 driver->SaveNeedFlush = 0;
239
Brian Paulb5ee3682005-10-28 14:32:49 +0000240 driver->ProgramStringNotify = _tnl_program_string;
Brian Paul988a8862004-01-20 02:36:44 +0000241 driver->FlushVertices = NULL;
242 driver->SaveFlushVertices = NULL;
243 driver->NotifySaveBegin = NULL;
244 driver->LightingSpaceChange = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000245
246 /* display list */
247 driver->NewList = NULL;
248 driver->EndList = NULL;
249 driver->BeginCallList = NULL;
250 driver->EndCallList = NULL;
251}