blob: 9838e0b5ec0c0acbf2210e54cf381fae29ee17cd [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
Brian Paul988a8862004-01-20 02:36:44 +000046
47#include "driverfuncs.h"
Brian Paulb5ee3682005-10-28 14:32:49 +000048#include "tnl/tnl.h"
Brian Paul988a8862004-01-20 02:36:44 +000049#include "swrast/swrast.h"
50
51
52
53/**
54 * Plug in default functions for all pointers in the dd_function_table
55 * structure.
56 * Device drivers should call this function and then plug in any
57 * functions which it wants to override.
58 * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
59 *
60 * \param table the dd_function_table to initialize
61 */
62void
63_mesa_init_driver_functions(struct dd_function_table *driver)
64{
65 _mesa_bzero(driver, sizeof(*driver));
66
67 driver->GetString = NULL; /* REQUIRED! */
68 driver->UpdateState = NULL; /* REQUIRED! */
69 driver->GetBufferSize = NULL; /* REQUIRED! */
Brian Paule4b23562005-05-04 20:11:35 +000070 driver->ResizeBuffers = _mesa_resize_framebuffer;
Brian Paul988a8862004-01-20 02:36:44 +000071 driver->Error = NULL;
72
73 driver->Finish = NULL;
74 driver->Flush = NULL;
75
76 /* framebuffer/image functions */
77 driver->Clear = _swrast_Clear;
78 driver->Accum = _swrast_Accum;
79 driver->DrawPixels = _swrast_DrawPixels;
80 driver->ReadPixels = _swrast_ReadPixels;
81 driver->CopyPixels = _swrast_CopyPixels;
82 driver->Bitmap = _swrast_Bitmap;
83
84 /* Texture functions */
85 driver->ChooseTextureFormat = _mesa_choose_tex_format;
86 driver->TexImage1D = _mesa_store_teximage1d;
87 driver->TexImage2D = _mesa_store_teximage2d;
88 driver->TexImage3D = _mesa_store_teximage3d;
89 driver->TexSubImage1D = _mesa_store_texsubimage1d;
90 driver->TexSubImage2D = _mesa_store_texsubimage2d;
91 driver->TexSubImage3D = _mesa_store_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +000092 driver->GetTexImage = _mesa_get_teximage;
Brian Paul988a8862004-01-20 02:36:44 +000093 driver->CopyTexImage1D = _swrast_copy_teximage1d;
94 driver->CopyTexImage2D = _swrast_copy_teximage2d;
95 driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
96 driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
97 driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
98 driver->TestProxyTexImage = _mesa_test_proxy_teximage;
99 driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
100 driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
101 driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
102 driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
103 driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
104 driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
Brian Paul68d293b2004-12-12 19:03:16 +0000105 driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
Brian Paul8f04c122004-04-27 13:39:20 +0000106 driver->CompressedTextureSize = _mesa_compressed_texture_size;
Brian Paul988a8862004-01-20 02:36:44 +0000107 driver->BindTexture = NULL;
108 driver->NewTextureObject = _mesa_new_texture_object;
109 driver->DeleteTexture = _mesa_delete_texture_object;
110 driver->NewTextureImage = _mesa_new_texture_image;
Keith Whitwell3e62d3a2005-03-22 14:27:10 +0000111 driver->FreeTexImageData = _mesa_free_texture_image_data;
Keith Whitwell17bcf9f2005-05-23 12:17:27 +0000112 driver->TextureMemCpy = _mesa_memcpy;
Brian Paul988a8862004-01-20 02:36:44 +0000113 driver->IsTextureResident = NULL;
114 driver->PrioritizeTexture = NULL;
115 driver->ActiveTexture = NULL;
116 driver->UpdateTexturePalette = NULL;
117
118 /* imaging */
119 driver->CopyColorTable = _swrast_CopyColorTable;
120 driver->CopyColorSubTable = _swrast_CopyColorSubTable;
121 driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
122 driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
123
Brian Paul4d859f72004-01-23 18:57:05 +0000124 /* Vertex/fragment programs */
125 driver->BindProgram = NULL;
126 driver->NewProgram = _mesa_new_program;
127 driver->DeleteProgram = _mesa_delete_program;
128
Brian Paul988a8862004-01-20 02:36:44 +0000129 /* simple state commands */
130 driver->AlphaFunc = NULL;
131 driver->BlendColor = NULL;
Ian Romanickc93105e2004-01-27 18:52:40 +0000132 driver->BlendEquationSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000133 driver->BlendFuncSeparate = NULL;
134 driver->ClearColor = NULL;
135 driver->ClearDepth = NULL;
136 driver->ClearIndex = NULL;
137 driver->ClearStencil = NULL;
138 driver->ClipPlane = NULL;
139 driver->ColorMask = NULL;
140 driver->ColorMaterial = NULL;
141 driver->CullFace = NULL;
Brian Paulacafeeb2005-09-03 16:57:58 +0000142 driver->DrawBuffer = NULL;
143 driver->DrawBuffers = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000144 driver->FrontFace = NULL;
145 driver->DepthFunc = NULL;
146 driver->DepthMask = NULL;
147 driver->DepthRange = NULL;
148 driver->Enable = NULL;
149 driver->Fogfv = NULL;
150 driver->Hint = NULL;
151 driver->IndexMask = NULL;
152 driver->Lightfv = NULL;
153 driver->LightModelfv = NULL;
154 driver->LineStipple = NULL;
155 driver->LineWidth = NULL;
156 driver->LogicOpcode = NULL;
157 driver->PointParameterfv = NULL;
158 driver->PointSize = NULL;
159 driver->PolygonMode = NULL;
160 driver->PolygonOffset = NULL;
161 driver->PolygonStipple = NULL;
162 driver->ReadBuffer = NULL;
163 driver->RenderMode = NULL;
164 driver->Scissor = NULL;
165 driver->ShadeModel = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000166 driver->StencilFuncSeparate = NULL;
Brian Paul5179f672005-09-13 01:17:01 +0000167 driver->StencilOpSeparate = NULL;
Brian Paul878c3712005-09-13 04:42:09 +0000168 driver->StencilMaskSeparate = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000169 driver->TexGen = NULL;
170 driver->TexEnv = NULL;
171 driver->TexParameter = NULL;
172 driver->TextureMatrix = NULL;
173 driver->Viewport = NULL;
174
175 /* vertex arrays */
176 driver->VertexPointer = NULL;
177 driver->NormalPointer = NULL;
178 driver->ColorPointer = NULL;
179 driver->FogCoordPointer = NULL;
180 driver->IndexPointer = NULL;
181 driver->SecondaryColorPointer = NULL;
182 driver->TexCoordPointer = NULL;
183 driver->EdgeFlagPointer = NULL;
184 driver->VertexAttribPointer = NULL;
185 driver->LockArraysEXT = NULL;
186 driver->UnlockArraysEXT = NULL;
187
188 /* state queries */
189 driver->GetBooleanv = NULL;
190 driver->GetDoublev = NULL;
191 driver->GetFloatv = NULL;
192 driver->GetIntegerv = NULL;
193 driver->GetPointerv = NULL;
194
195#if FEATURE_ARB_vertex_buffer_object
196 driver->NewBufferObject = _mesa_new_buffer_object;
197 driver->DeleteBuffer = _mesa_delete_buffer_object;
198 driver->BindBuffer = NULL;
199 driver->BufferData = _mesa_buffer_data;
200 driver->BufferSubData = _mesa_buffer_subdata;
201 driver->GetBufferSubData = _mesa_buffer_get_subdata;
202 driver->MapBuffer = _mesa_buffer_map;
Brian Paul7eab3372004-10-31 15:23:42 +0000203 driver->UnmapBuffer = _mesa_buffer_unmap;
Brian Paul988a8862004-01-20 02:36:44 +0000204#endif
205
Brian Paul2c6f9112005-02-24 05:47:06 +0000206#if FEATURE_EXT_framebuffer_object
207 driver->NewFramebuffer = _mesa_new_framebuffer;
Brian Paule4b23562005-05-04 20:11:35 +0000208 driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
Brian Paulea4fe662006-03-26 05:22:17 +0000209 driver->RenderTexture = _mesa_render_texture;
210 driver->FinishRenderTexture = _mesa_finish_render_texture;
Brian Paule4b23562005-05-04 20:11:35 +0000211 driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
Brian Paul2c6f9112005-02-24 05:47:06 +0000212#endif
213
Brian Paulafa1df52006-03-02 03:45:28 +0000214#if FEATURE_EXT_framebuffer_blit
215 driver->BlitFramebuffer = _swrast_BlitFramebuffer;
216#endif
217
Brian Paul23ffc3a2005-08-27 13:56:08 +0000218 /* query objects */
Brian Paul4fb99502005-09-02 13:42:49 +0000219 driver->NewQueryObject = _mesa_new_query_object;
Brian Paul23ffc3a2005-08-27 13:56:08 +0000220 driver->BeginQuery = NULL;
221 driver->EndQuery = NULL;
222
Brian Paul988a8862004-01-20 02:36:44 +0000223 /* T&L stuff */
224 driver->NeedValidate = GL_FALSE;
225 driver->ValidateTnlModule = NULL;
226 driver->CurrentExecPrimitive = 0;
227 driver->CurrentSavePrimitive = 0;
228 driver->NeedFlush = 0;
229 driver->SaveNeedFlush = 0;
230
Brian Paulb5ee3682005-10-28 14:32:49 +0000231 driver->ProgramStringNotify = _tnl_program_string;
Brian Paul988a8862004-01-20 02:36:44 +0000232 driver->FlushVertices = NULL;
233 driver->SaveFlushVertices = NULL;
234 driver->NotifySaveBegin = NULL;
235 driver->LightingSpaceChange = NULL;
Brian Paul988a8862004-01-20 02:36:44 +0000236
237 /* display list */
238 driver->NewList = NULL;
239 driver->EndList = NULL;
240 driver->BeginCallList = NULL;
241 driver->EndCallList = NULL;
242}