blob: bc637a879e37e9192bc6e2596a2ccc73456d357a [file] [log] [blame]
Brian Paul988a8862004-01-20 02:36:44 +00001/*
2 * Mesa 3-D graphics library
Brian0bf5dbe2006-12-19 18:02:41 -07003 * Version: 6.5.3
Brian Paul988a8862004-01-20 02:36:44 +00004 *
Brian0bf5dbe2006-12-19 18:02:41 -07005 * Copyright (C) 1999-2007 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
Brian0bf5dbe2006-12-19 18:02:41 -070046#include "shader_api.h"
Ian Romanickee34e6e2006-06-12 16:26:29 +000047#include "arrayobj.h"
Brian Paul988a8862004-01-20 02:36:44 +000048
49#include "driverfuncs.h"
Brian Paulb5ee3682005-10-28 14:32:49 +000050#include "tnl/tnl.h"
Brian Paul988a8862004-01-20 02:36:44 +000051#include "swrast/swrast.h"
52
53
54
55/**
56 * Plug in default functions for all pointers in the dd_function_table
57 * structure.
58 * Device drivers should call this function and then plug in any
59 * functions which it wants to override.
60 * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
61 *
62 * \param table the dd_function_table to initialize
63 */
64void
65_mesa_init_driver_functions(struct dd_function_table *driver)
66{
67 _mesa_bzero(driver, sizeof(*driver));
68
69 driver->GetString = NULL; /* REQUIRED! */
70 driver->UpdateState = NULL; /* REQUIRED! */
71 driver->GetBufferSize = NULL; /* REQUIRED! */
Brian Paule4b23562005-05-04 20:11:35 +000072 driver->ResizeBuffers = _mesa_resize_framebuffer;
Brian Paul988a8862004-01-20 02:36:44 +000073 driver->Error = NULL;
74
75 driver->Finish = NULL;
76 driver->Flush = NULL;
77
78 /* framebuffer/image functions */
79 driver->Clear = _swrast_Clear;
80 driver->Accum = _swrast_Accum;
81 driver->DrawPixels = _swrast_DrawPixels;
82 driver->ReadPixels = _swrast_ReadPixels;
83 driver->CopyPixels = _swrast_CopyPixels;
84 driver->Bitmap = _swrast_Bitmap;
85
86 /* Texture functions */
87 driver->ChooseTextureFormat = _mesa_choose_tex_format;
88 driver->TexImage1D = _mesa_store_teximage1d;
89 driver->TexImage2D = _mesa_store_teximage2d;
90 driver->TexImage3D = _mesa_store_teximage3d;
91 driver->TexSubImage1D = _mesa_store_texsubimage1d;
92 driver->TexSubImage2D = _mesa_store_texsubimage2d;
93 driver->TexSubImage3D = _mesa_store_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +000094 driver->GetTexImage = _mesa_get_teximage;
Brian Paul988a8862004-01-20 02:36:44 +000095 driver->CopyTexImage1D = _swrast_copy_teximage1d;
96 driver->CopyTexImage2D = _swrast_copy_teximage2d;
97 driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
98 driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
99 driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
100 driver->TestProxyTexImage = _mesa_test_proxy_teximage;
101 driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
102 driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
103 driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
104 driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
105 driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
106 driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +0000107 driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
Brian Paul8f04c122004-04-27 13:39:20 +0000108 driver->CompressedTextureSize = _mesa_compressed_texture_size;
Brian Paul988a8862004-01-20 02:36:44 +0000109 driver->BindTexture = NULL;
110 driver->NewTextureObject = _mesa_new_texture_object;
111 driver->DeleteTexture = _mesa_delete_texture_object;
112 driver->NewTextureImage = _mesa_new_texture_image;
Keith Whitwell3e62d3a2005-03-22 14:27:10 +0000113 driver->FreeTexImageData = _mesa_free_texture_image_data;
Keith Whitwell17bcf9f2005-05-23 12:17:27 +0000114 driver->TextureMemCpy = _mesa_memcpy;
Brian Paul988a8862004-01-20 02:36:44 +0000115 driver->IsTextureResident = NULL;
116 driver->PrioritizeTexture = NULL;
117 driver->ActiveTexture = NULL;
118 driver->UpdateTexturePalette = NULL;
119
120 /* imaging */
121 driver->CopyColorTable = _swrast_CopyColorTable;
122 driver->CopyColorSubTable = _swrast_CopyColorSubTable;
123 driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
124 driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
125
Brian Paul4d859f72004-01-23 18:57:05 +0000126 /* Vertex/fragment programs */
127 driver->BindProgram = NULL;
128 driver->NewProgram = _mesa_new_program;
129 driver->DeleteProgram = _mesa_delete_program;
Brian Paul39c4daa2006-10-10 21:43:31 +0000130#if FEATURE_MESA_program_debug
131 driver->GetFragmentProgramRegister = _swrast_get_program_register;
132#endif /* FEATURE_MESA_program_debug */
Brian Paul4d859f72004-01-23 18:57:05 +0000133
Brian Paul988a8862004-01-20 02:36:44 +0000134 /* simple state commands */
135 driver->AlphaFunc = NULL;
136 driver->BlendColor = NULL;
Ian Romanickc93105e2004-01-27 18:52:40 +0000137 driver->BlendEquationSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000138 driver->BlendFuncSeparate = NULL;
139 driver->ClearColor = NULL;
140 driver->ClearDepth = NULL;
141 driver->ClearIndex = NULL;
142 driver->ClearStencil = NULL;
143 driver->ClipPlane = NULL;
144 driver->ColorMask = NULL;
145 driver->ColorMaterial = NULL;
146 driver->CullFace = NULL;
Brian Paulacafeeb2005-09-03 16:57:58 +0000147 driver->DrawBuffer = NULL;
148 driver->DrawBuffers = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000149 driver->FrontFace = NULL;
150 driver->DepthFunc = NULL;
151 driver->DepthMask = NULL;
152 driver->DepthRange = NULL;
153 driver->Enable = NULL;
154 driver->Fogfv = NULL;
155 driver->Hint = NULL;
156 driver->IndexMask = NULL;
157 driver->Lightfv = NULL;
158 driver->LightModelfv = NULL;
159 driver->LineStipple = NULL;
160 driver->LineWidth = NULL;
161 driver->LogicOpcode = NULL;
162 driver->PointParameterfv = NULL;
163 driver->PointSize = NULL;
164 driver->PolygonMode = NULL;
165 driver->PolygonOffset = NULL;
166 driver->PolygonStipple = NULL;
167 driver->ReadBuffer = NULL;
168 driver->RenderMode = NULL;
169 driver->Scissor = NULL;
170 driver->ShadeModel = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000171 driver->StencilFuncSeparate = NULL;
Brian Paul5179f672005-09-13 01:17:01 +0000172 driver->StencilOpSeparate = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000173 driver->StencilMaskSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000174 driver->TexGen = NULL;
175 driver->TexEnv = NULL;
176 driver->TexParameter = NULL;
177 driver->TextureMatrix = NULL;
178 driver->Viewport = NULL;
179
180 /* vertex arrays */
181 driver->VertexPointer = NULL;
182 driver->NormalPointer = NULL;
183 driver->ColorPointer = NULL;
184 driver->FogCoordPointer = NULL;
185 driver->IndexPointer = NULL;
186 driver->SecondaryColorPointer = NULL;
187 driver->TexCoordPointer = NULL;
188 driver->EdgeFlagPointer = NULL;
189 driver->VertexAttribPointer = NULL;
190 driver->LockArraysEXT = NULL;
191 driver->UnlockArraysEXT = NULL;
192
193 /* state queries */
194 driver->GetBooleanv = NULL;
195 driver->GetDoublev = NULL;
196 driver->GetFloatv = NULL;
197 driver->GetIntegerv = NULL;
198 driver->GetPointerv = NULL;
199
200#if FEATURE_ARB_vertex_buffer_object
201 driver->NewBufferObject = _mesa_new_buffer_object;
202 driver->DeleteBuffer = _mesa_delete_buffer_object;
203 driver->BindBuffer = NULL;
204 driver->BufferData = _mesa_buffer_data;
205 driver->BufferSubData = _mesa_buffer_subdata;
206 driver->GetBufferSubData = _mesa_buffer_get_subdata;
207 driver->MapBuffer = _mesa_buffer_map;
Brian Paul7eab3372004-10-31 15:23:42 +0000208 driver->UnmapBuffer = _mesa_buffer_unmap;
Brian Paul988a8862004-01-20 02:36:44 +0000209#endif
210
Brian Paul2c6f9112005-02-24 05:47:06 +0000211#if FEATURE_EXT_framebuffer_object
212 driver->NewFramebuffer = _mesa_new_framebuffer;
Brian Paule4b23562005-05-04 20:11:35 +0000213 driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
Brian Paulea4fe662006-03-26 05:22:17 +0000214 driver->RenderTexture = _mesa_render_texture;
215 driver->FinishRenderTexture = _mesa_finish_render_texture;
Brian Paule4b23562005-05-04 20:11:35 +0000216 driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
Brian Paul2c6f9112005-02-24 05:47:06 +0000217#endif
218
Brian Paulafa1df52006-03-02 03:45:28 +0000219#if FEATURE_EXT_framebuffer_blit
220 driver->BlitFramebuffer = _swrast_BlitFramebuffer;
221#endif
222
Brian Paul23ffc3a2005-08-27 13:56:08 +0000223 /* query objects */
Brian Paul4fb99502005-09-02 13:42:49 +0000224 driver->NewQueryObject = _mesa_new_query_object;
Brian Paul23ffc3a2005-08-27 13:56:08 +0000225 driver->BeginQuery = NULL;
226 driver->EndQuery = NULL;
227
Ian Romanickee34e6e2006-06-12 16:26:29 +0000228 /* APPLE_vertex_array_object */
229 driver->NewArrayObject = _mesa_new_array_object;
230 driver->DeleteArrayObject = _mesa_delete_array_object;
231 driver->BindArrayObject = NULL;
232
Brian Paul988a8862004-01-20 02:36:44 +0000233 /* T&L stuff */
234 driver->NeedValidate = GL_FALSE;
235 driver->ValidateTnlModule = NULL;
236 driver->CurrentExecPrimitive = 0;
237 driver->CurrentSavePrimitive = 0;
238 driver->NeedFlush = 0;
239 driver->SaveNeedFlush = 0;
240
Brian Paulb5ee3682005-10-28 14:32:49 +0000241 driver->ProgramStringNotify = _tnl_program_string;
Brian Paul988a8862004-01-20 02:36:44 +0000242 driver->FlushVertices = NULL;
243 driver->SaveFlushVertices = NULL;
244 driver->NotifySaveBegin = NULL;
245 driver->LightingSpaceChange = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000246
247 /* display list */
248 driver->NewList = NULL;
249 driver->EndList = NULL;
250 driver->BeginCallList = NULL;
251 driver->EndCallList = NULL;
Brian0bf5dbe2006-12-19 18:02:41 -0700252
253
254 /* XXX temporary here */
255 _mesa_init_glsl_driver_functions(driver);
256}
257
258
259/**
260 * Plug in Mesa's GLSL functions.
261 */
262void
263_mesa_init_glsl_driver_functions(struct dd_function_table *driver)
264{
265 driver->AttachShader = _mesa_attach_shader;
266 driver->BindAttribLocation = _mesa_bind_attrib_location;
267 driver->CompileShader = _mesa_compile_shader;
268 driver->CreateProgram = _mesa_create_program;
269 driver->CreateShader = _mesa_create_shader;
270 driver->DeleteProgram2 = _mesa_delete_program2;
271 driver->DeleteShader = _mesa_delete_shader;
272 driver->DetachShader = _mesa_detach_shader;
273 driver->GetActiveAttrib = _mesa_get_active_attrib;
274 driver->GetActiveUniform = _mesa_get_active_uniform;
275 driver->GetAttachedShaders = _mesa_get_attached_shaders;
276 driver->GetAttribLocation = _mesa_get_attrib_location;
277 driver->GetHandle = _mesa_get_handle;
278 driver->GetProgramiv = _mesa_get_programiv;
279 driver->GetProgramInfoLog = _mesa_get_program_info_log;
280 driver->GetShaderiv = _mesa_get_shaderiv;
281 driver->GetShaderInfoLog = _mesa_get_shader_info_log;
282 driver->GetShaderSource = _mesa_get_shader_source;
283 driver->GetUniformfv = _mesa_get_uniformfv;
284 driver->GetUniformLocation = _mesa_get_uniform_location;
285 driver->IsProgram = _mesa_is_program;
286 driver->IsShader = _mesa_is_shader;
287 driver->LinkProgram = _mesa_link_program;
288 driver->ShaderSource = _mesa_shader_source;
289 driver->Uniform = _mesa_uniform;
290 driver->UniformMatrix = _mesa_uniform_matrix;
291 driver->UseProgram = _mesa_use_program;
292 driver->ValidateProgram = _mesa_validate_program;
Brian Paul988a8862004-01-20 02:36:44 +0000293}