driverfuncs.c revision b1502588c4755fa9d3d7b4eabed6332575033037
1/* 2 * Mesa 3-D graphics library 3 * Version: 6.5.3 4 * 5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 6 * 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" 30#include "framebuffer.h" 31#include "program.h" 32#include "prog_execute.h" 33#include "queryobj.h" 34#include "renderbuffer.h" 35#include "texcompress.h" 36#include "texformat.h" 37#include "teximage.h" 38#include "texobj.h" 39#include "texstore.h" 40#if FEATURE_ARB_vertex_buffer_object 41#include "bufferobj.h" 42#endif 43#if FEATURE_EXT_framebuffer_object 44#include "fbobject.h" 45#include "texrender.h" 46#endif 47#include "shader_api.h" 48#include "arrayobj.h" 49 50#include "driverfuncs.h" 51#include "tnl/tnl.h" 52#include "swrast/swrast.h" 53 54 55 56/** 57 * Plug in default functions for all pointers in the dd_function_table 58 * structure. 59 * Device drivers should call this function and then plug in any 60 * functions which it wants to override. 61 * Some functions (pointers) MUST be implemented by all drivers (REQUIRED). 62 * 63 * \param table the dd_function_table to initialize 64 */ 65void 66_mesa_init_driver_functions(struct dd_function_table *driver) 67{ 68 _mesa_bzero(driver, sizeof(*driver)); 69 70 driver->GetString = NULL; /* REQUIRED! */ 71 driver->UpdateState = NULL; /* REQUIRED! */ 72 driver->GetBufferSize = NULL; /* REQUIRED! */ 73 driver->ResizeBuffers = _mesa_resize_framebuffer; 74 driver->Error = NULL; 75 76 driver->Finish = NULL; 77 driver->Flush = NULL; 78 79 /* framebuffer/image functions */ 80 driver->Clear = _swrast_Clear; 81 driver->Accum = _swrast_Accum; 82 driver->DrawPixels = _swrast_DrawPixels; 83 driver->ReadPixels = _swrast_ReadPixels; 84 driver->CopyPixels = _swrast_CopyPixels; 85 driver->Bitmap = _swrast_Bitmap; 86 87 /* Texture functions */ 88 driver->ChooseTextureFormat = _mesa_choose_tex_format; 89 driver->TexImage1D = _mesa_store_teximage1d; 90 driver->TexImage2D = _mesa_store_teximage2d; 91 driver->TexImage3D = _mesa_store_teximage3d; 92 driver->TexSubImage1D = _mesa_store_texsubimage1d; 93 driver->TexSubImage2D = _mesa_store_texsubimage2d; 94 driver->TexSubImage3D = _mesa_store_texsubimage3d; 95 driver->GetTexImage = _mesa_get_teximage; 96 driver->CopyTexImage1D = _swrast_copy_teximage1d; 97 driver->CopyTexImage2D = _swrast_copy_teximage2d; 98 driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d; 99 driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d; 100 driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d; 101 driver->TestProxyTexImage = _mesa_test_proxy_teximage; 102 driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d; 103 driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d; 104 driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d; 105 driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; 106 driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; 107 driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; 108 driver->GetCompressedTexImage = _mesa_get_compressed_teximage; 109 driver->CompressedTextureSize = _mesa_compressed_texture_size; 110 driver->BindTexture = NULL; 111 driver->NewTextureObject = _mesa_new_texture_object; 112 driver->DeleteTexture = _mesa_delete_texture_object; 113 driver->NewTextureImage = _mesa_new_texture_image; 114 driver->FreeTexImageData = _mesa_free_texture_image_data; 115 driver->TextureMemCpy = _mesa_memcpy; 116 driver->IsTextureResident = NULL; 117 driver->PrioritizeTexture = NULL; 118 driver->ActiveTexture = NULL; 119 driver->UpdateTexturePalette = NULL; 120 121 /* imaging */ 122 driver->CopyColorTable = _swrast_CopyColorTable; 123 driver->CopyColorSubTable = _swrast_CopyColorSubTable; 124 driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; 125 driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; 126 127 /* Vertex/fragment programs */ 128 driver->BindProgram = NULL; 129 driver->NewProgram = _mesa_new_program; 130 driver->DeleteProgram = _mesa_delete_program; 131#if FEATURE_MESA_program_debug 132 driver->GetProgramRegister = _mesa_get_program_register; 133#endif /* FEATURE_MESA_program_debug */ 134 135 /* simple state commands */ 136 driver->AlphaFunc = NULL; 137 driver->BlendColor = NULL; 138 driver->BlendEquationSeparate = NULL; 139 driver->BlendFuncSeparate = NULL; 140 driver->ClearColor = NULL; 141 driver->ClearDepth = NULL; 142 driver->ClearIndex = NULL; 143 driver->ClearStencil = NULL; 144 driver->ClipPlane = NULL; 145 driver->ColorMask = NULL; 146 driver->ColorMaterial = NULL; 147 driver->CullFace = NULL; 148 driver->DrawBuffer = NULL; 149 driver->DrawBuffers = NULL; 150 driver->FrontFace = NULL; 151 driver->DepthFunc = NULL; 152 driver->DepthMask = NULL; 153 driver->DepthRange = NULL; 154 driver->Enable = NULL; 155 driver->Fogfv = NULL; 156 driver->Hint = NULL; 157 driver->IndexMask = NULL; 158 driver->Lightfv = NULL; 159 driver->LightModelfv = NULL; 160 driver->LineStipple = NULL; 161 driver->LineWidth = NULL; 162 driver->LogicOpcode = NULL; 163 driver->PointParameterfv = NULL; 164 driver->PointSize = NULL; 165 driver->PolygonMode = NULL; 166 driver->PolygonOffset = NULL; 167 driver->PolygonStipple = NULL; 168 driver->ReadBuffer = NULL; 169 driver->RenderMode = NULL; 170 driver->Scissor = NULL; 171 driver->ShadeModel = NULL; 172 driver->StencilFuncSeparate = NULL; 173 driver->StencilOpSeparate = NULL; 174 driver->StencilMaskSeparate = NULL; 175 driver->TexGen = NULL; 176 driver->TexEnv = NULL; 177 driver->TexParameter = NULL; 178 driver->TextureMatrix = NULL; 179 driver->Viewport = NULL; 180 181 /* vertex arrays */ 182 driver->VertexPointer = NULL; 183 driver->NormalPointer = NULL; 184 driver->ColorPointer = NULL; 185 driver->FogCoordPointer = NULL; 186 driver->IndexPointer = NULL; 187 driver->SecondaryColorPointer = NULL; 188 driver->TexCoordPointer = NULL; 189 driver->EdgeFlagPointer = NULL; 190 driver->VertexAttribPointer = NULL; 191 driver->LockArraysEXT = NULL; 192 driver->UnlockArraysEXT = NULL; 193 194 /* state queries */ 195 driver->GetBooleanv = NULL; 196 driver->GetDoublev = NULL; 197 driver->GetFloatv = NULL; 198 driver->GetIntegerv = NULL; 199 driver->GetPointerv = NULL; 200 201#if FEATURE_ARB_vertex_buffer_object 202 driver->NewBufferObject = _mesa_new_buffer_object; 203 driver->DeleteBuffer = _mesa_delete_buffer_object; 204 driver->BindBuffer = NULL; 205 driver->BufferData = _mesa_buffer_data; 206 driver->BufferSubData = _mesa_buffer_subdata; 207 driver->GetBufferSubData = _mesa_buffer_get_subdata; 208 driver->MapBuffer = _mesa_buffer_map; 209 driver->UnmapBuffer = _mesa_buffer_unmap; 210#endif 211 212#if FEATURE_EXT_framebuffer_object 213 driver->NewFramebuffer = _mesa_new_framebuffer; 214 driver->NewRenderbuffer = _mesa_new_soft_renderbuffer; 215 driver->RenderTexture = _mesa_render_texture; 216 driver->FinishRenderTexture = _mesa_finish_render_texture; 217 driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer; 218#endif 219 220#if FEATURE_EXT_framebuffer_blit 221 driver->BlitFramebuffer = _swrast_BlitFramebuffer; 222#endif 223 224 /* query objects */ 225 driver->NewQueryObject = _mesa_new_query_object; 226 driver->BeginQuery = NULL; 227 driver->EndQuery = NULL; 228 229 /* APPLE_vertex_array_object */ 230 driver->NewArrayObject = _mesa_new_array_object; 231 driver->DeleteArrayObject = _mesa_delete_array_object; 232 driver->BindArrayObject = NULL; 233 234 /* T&L stuff */ 235 driver->NeedValidate = GL_FALSE; 236 driver->ValidateTnlModule = NULL; 237 driver->CurrentExecPrimitive = 0; 238 driver->CurrentSavePrimitive = 0; 239 driver->NeedFlush = 0; 240 driver->SaveNeedFlush = 0; 241 242 driver->ProgramStringNotify = _tnl_program_string; 243 driver->FlushVertices = NULL; 244 driver->SaveFlushVertices = NULL; 245 driver->NotifySaveBegin = NULL; 246 driver->LightingSpaceChange = NULL; 247 248 /* display list */ 249 driver->NewList = NULL; 250 driver->EndList = NULL; 251 driver->BeginCallList = NULL; 252 driver->EndCallList = NULL; 253 254 255 /* XXX temporary here */ 256 _mesa_init_glsl_driver_functions(driver); 257} 258 259 260/** 261 * Plug in Mesa's GLSL functions. 262 */ 263void 264_mesa_init_glsl_driver_functions(struct dd_function_table *driver) 265{ 266 driver->AttachShader = _mesa_attach_shader; 267 driver->BindAttribLocation = _mesa_bind_attrib_location; 268 driver->CompileShader = _mesa_compile_shader; 269 driver->CreateProgram = _mesa_create_program; 270 driver->CreateShader = _mesa_create_shader; 271 driver->DeleteProgram2 = _mesa_delete_program2; 272 driver->DeleteShader = _mesa_delete_shader; 273 driver->DetachShader = _mesa_detach_shader; 274 driver->GetActiveAttrib = _mesa_get_active_attrib; 275 driver->GetActiveUniform = _mesa_get_active_uniform; 276 driver->GetAttachedShaders = _mesa_get_attached_shaders; 277 driver->GetAttribLocation = _mesa_get_attrib_location; 278 driver->GetHandle = _mesa_get_handle; 279 driver->GetProgramiv = _mesa_get_programiv; 280 driver->GetProgramInfoLog = _mesa_get_program_info_log; 281 driver->GetShaderiv = _mesa_get_shaderiv; 282 driver->GetShaderInfoLog = _mesa_get_shader_info_log; 283 driver->GetShaderSource = _mesa_get_shader_source; 284 driver->GetUniformfv = _mesa_get_uniformfv; 285 driver->GetUniformLocation = _mesa_get_uniform_location; 286 driver->IsProgram = _mesa_is_program; 287 driver->IsShader = _mesa_is_shader; 288 driver->LinkProgram = _mesa_link_program; 289 driver->ShaderSource = _mesa_shader_source; 290 driver->Uniform = _mesa_uniform; 291 driver->UniformMatrix = _mesa_uniform_matrix; 292 driver->UseProgram = _mesa_use_program; 293 driver->ValidateProgram = _mesa_validate_program; 294} 295