blob: 3ccbe54817a4e3c8bc7f802624958398c5aba652 [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;
129
Brian Paul988a8862004-01-20 02:36:44 +0000130 /* simple state commands */
131 driver->AlphaFunc = NULL;
132 driver->BlendColor = NULL;
Ian Romanickc93105e2004-01-27 18:52:40 +0000133 driver->BlendEquationSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000134 driver->BlendFuncSeparate = NULL;
135 driver->ClearColor = NULL;
136 driver->ClearDepth = NULL;
137 driver->ClearIndex = NULL;
138 driver->ClearStencil = NULL;
139 driver->ClipPlane = NULL;
140 driver->ColorMask = NULL;
141 driver->ColorMaterial = NULL;
142 driver->CullFace = NULL;
Brian Paulacafeeb2005-09-03 16:57:58 +0000143 driver->DrawBuffer = NULL;
144 driver->DrawBuffers = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000145 driver->FrontFace = NULL;
146 driver->DepthFunc = NULL;
147 driver->DepthMask = NULL;
148 driver->DepthRange = NULL;
149 driver->Enable = NULL;
150 driver->Fogfv = NULL;
151 driver->Hint = NULL;
152 driver->IndexMask = NULL;
153 driver->Lightfv = NULL;
154 driver->LightModelfv = NULL;
155 driver->LineStipple = NULL;
156 driver->LineWidth = NULL;
157 driver->LogicOpcode = NULL;
158 driver->PointParameterfv = NULL;
159 driver->PointSize = NULL;
160 driver->PolygonMode = NULL;
161 driver->PolygonOffset = NULL;
162 driver->PolygonStipple = NULL;
163 driver->ReadBuffer = NULL;
164 driver->RenderMode = NULL;
165 driver->Scissor = NULL;
166 driver->ShadeModel = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000167 driver->StencilFuncSeparate = NULL;
Brian Paul5179f672005-09-13 01:17:01 +0000168 driver->StencilOpSeparate = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000169 driver->StencilMaskSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000170 driver->TexGen = NULL;
171 driver->TexEnv = NULL;
172 driver->TexParameter = NULL;
173 driver->TextureMatrix = NULL;
174 driver->Viewport = NULL;
175
176 /* vertex arrays */
177 driver->VertexPointer = NULL;
178 driver->NormalPointer = NULL;
179 driver->ColorPointer = NULL;
180 driver->FogCoordPointer = NULL;
181 driver->IndexPointer = NULL;
182 driver->SecondaryColorPointer = NULL;
183 driver->TexCoordPointer = NULL;
184 driver->EdgeFlagPointer = NULL;
185 driver->VertexAttribPointer = NULL;
186 driver->LockArraysEXT = NULL;
187 driver->UnlockArraysEXT = NULL;
188
189 /* state queries */
190 driver->GetBooleanv = NULL;
191 driver->GetDoublev = NULL;
192 driver->GetFloatv = NULL;
193 driver->GetIntegerv = NULL;
194 driver->GetPointerv = NULL;
195
196#if FEATURE_ARB_vertex_buffer_object
197 driver->NewBufferObject = _mesa_new_buffer_object;
198 driver->DeleteBuffer = _mesa_delete_buffer_object;
199 driver->BindBuffer = NULL;
200 driver->BufferData = _mesa_buffer_data;
201 driver->BufferSubData = _mesa_buffer_subdata;
202 driver->GetBufferSubData = _mesa_buffer_get_subdata;
203 driver->MapBuffer = _mesa_buffer_map;
Brian Paul7eab3372004-10-31 15:23:42 +0000204 driver->UnmapBuffer = _mesa_buffer_unmap;
Brian Paul988a8862004-01-20 02:36:44 +0000205#endif
206
Brian Paul2c6f9112005-02-24 05:47:06 +0000207#if FEATURE_EXT_framebuffer_object
208 driver->NewFramebuffer = _mesa_new_framebuffer;
Brian Paule4b23562005-05-04 20:11:35 +0000209 driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
Brian Paulea4fe662006-03-26 05:22:17 +0000210 driver->RenderTexture = _mesa_render_texture;
211 driver->FinishRenderTexture = _mesa_finish_render_texture;
Brian Paule4b23562005-05-04 20:11:35 +0000212 driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
Brian Paul2c6f9112005-02-24 05:47:06 +0000213#endif
214
Brian Paulafa1df52006-03-02 03:45:28 +0000215#if FEATURE_EXT_framebuffer_blit
216 driver->BlitFramebuffer = _swrast_BlitFramebuffer;
217#endif
218
Brian Paul23ffc3a2005-08-27 13:56:08 +0000219 /* query objects */
Brian Paul4fb99502005-09-02 13:42:49 +0000220 driver->NewQueryObject = _mesa_new_query_object;
Brian Paul23ffc3a2005-08-27 13:56:08 +0000221 driver->BeginQuery = NULL;
222 driver->EndQuery = NULL;
223
Ian Romanickee34e6e2006-06-12 16:26:29 +0000224 /* APPLE_vertex_array_object */
225 driver->NewArrayObject = _mesa_new_array_object;
226 driver->DeleteArrayObject = _mesa_delete_array_object;
227 driver->BindArrayObject = NULL;
228
Brian Paul988a8862004-01-20 02:36:44 +0000229 /* T&L stuff */
230 driver->NeedValidate = GL_FALSE;
231 driver->ValidateTnlModule = NULL;
232 driver->CurrentExecPrimitive = 0;
233 driver->CurrentSavePrimitive = 0;
234 driver->NeedFlush = 0;
235 driver->SaveNeedFlush = 0;
236
Brian Paulb5ee3682005-10-28 14:32:49 +0000237 driver->ProgramStringNotify = _tnl_program_string;
Brian Paul988a8862004-01-20 02:36:44 +0000238 driver->FlushVertices = NULL;
239 driver->SaveFlushVertices = NULL;
240 driver->NotifySaveBegin = NULL;
241 driver->LightingSpaceChange = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000242
243 /* display list */
244 driver->NewList = NULL;
245 driver->EndList = NULL;
246 driver->BeginCallList = NULL;
247 driver->EndCallList = NULL;
248}