├── .gitignore ├── .travis-deps.sh ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── include └── GL │ └── gl3ds.h └── src ├── arrayobj.c ├── arrayobj.h ├── attrib.c ├── attrib.h ├── blend.c ├── blend.h ├── bufferobj.c ├── bufferobj.h ├── buffers.c ├── buffers.h ├── c11 └── threads.h ├── clear.c ├── colormac.h ├── compiler.h ├── config.h ├── context.c ├── context.h ├── dd.h ├── debug.c ├── debug.h ├── depth.c ├── depth.h ├── drivers ├── driverfuncs.c ├── driverfuncs.h ├── meta.c ├── meta.h ├── meta_copy_image.c ├── meta_generate_mipmap.c ├── meta_tex_subimage.c ├── s_chan.h ├── s_context.c ├── s_context.h ├── s_texture.c └── swrast.h ├── enable.c ├── enable.h ├── enums.c ├── enums.h ├── errors.c ├── errors.h ├── extensions.c ├── extensions.h ├── fbobject.c ├── fbobject.h ├── format_info.h ├── format_pack.c ├── format_pack.h ├── formats.c ├── formats.h ├── framebuffer.c ├── framebuffer.h ├── get.c ├── get.h ├── get_hash.h ├── getstring.c ├── gl3ds.c ├── glformats.c ├── glformats.h ├── glheader.h ├── hash.c ├── hash.h ├── image.c ├── image.h ├── imports.c ├── imports.h ├── light.c ├── light.h ├── macros.h ├── math ├── m_matrix.c └── m_matrix.h ├── matrix.c ├── matrix.h ├── mipmap.c ├── mipmap.h ├── mtypes.h ├── multisample.c ├── multisample.h ├── pack.c ├── pack.h ├── pbo.c ├── pbo.h ├── pixel.c ├── pixel.h ├── pixelstore.c ├── pixelstore.h ├── pixeltransfer.c ├── pixeltransfer.h ├── polygon.c ├── polygon.h ├── readpix.c ├── readpix.h ├── renderbuffer.c ├── renderbuffer.h ├── samplerobj.c ├── samplerobj.h ├── scissor.c ├── scissor.h ├── shader.c ├── shader.h ├── shared.c ├── shared.h ├── state.c ├── state.h ├── stencil.c ├── stencil.h ├── texcompress.c ├── texcompress.h ├── texcompress_etc.c ├── texcompress_etc.h ├── texcompress_etc_tmp.h ├── texenv.c ├── texenv.h ├── texformat.c ├── texformat.h ├── texgetimage.c ├── texgetimage.h ├── teximage.c ├── teximage.h ├── texobj.c ├── texobj.h ├── texparam.c ├── texparam.h ├── texstate.c ├── texstate.h ├── texstorage.c ├── texstorage.h ├── texstore.c ├── texstore.h ├── textureview.c ├── textureview.h ├── uniform.c ├── util ├── bitset.h ├── format_srgb.c ├── format_srgb.h ├── format_srgb.py ├── hash_table.c ├── hash_table.h ├── macros.h ├── ralloc.c ├── ralloc.h ├── simple_list.h └── u_math.h ├── varray.c ├── varray.h ├── viewport.c └── viewport.h /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | lib/ 3 | bin/ 4 | 5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion 6 | *.iml 7 | ## Directory-based project format: 8 | .idea/ 9 | -------------------------------------------------------------------------------- /.travis-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -x 4 | 5 | # Build and install devkitARM + ctrulib 6 | wget http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitARMupdate.pl 7 | perl devkitARMupdate.pl 8 | 9 | # Get latest ctrulib and overwrite bundled one 10 | git clone https://github.com/smealum/ctrulib.git 11 | cd ctrulib/libctru && make -j4 install && cd - 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | sudo: false 4 | 5 | before_install: 6 | - export DEVKITPRO=${HOME}/devkitPro 7 | - export DEVKITARM=${DEVKITPRO}/devkitARM 8 | - export CTRULIB=${DEVKITPRO}/libctru 9 | - sh .travis-deps.sh 10 | 11 | script: 12 | - make -j4 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Thomas Edvalson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | ifeq ($(strip $(CTRULIB)),) 3 | $(error "Please set CTRULIB in your environment: $ export CTRULIB=") 4 | endif 5 | 6 | VERSION := 1.0.0 7 | 8 | BUGREPORT := https://github.com/cpp3ds/gl3ds 9 | 10 | include $(DEVKITARM)/base_rules 11 | 12 | LIBDIRS := $(CTRULIB) 13 | 14 | export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 15 | -I$(CURDIR)/include 16 | 17 | 18 | ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard 19 | 20 | CFLAGS := -g -Wall -O2 \ 21 | -fno-strict-aliasing -ffunction-sections -fdata-sections \ 22 | $(ARCH) $(INCLUDE) 23 | 24 | ASFLAGS := -g $(ARCH) 25 | 26 | DEFINITIONS := -DPACKAGE_VERSION=\"$(VERSION)\" -DPACKAGE_BUGREPORT=\"$(BUGREPORT)\" 27 | 28 | CFILES := $(wildcard src/**/*.c) $(wildcard src/**.c) 29 | 30 | export LD := $(CC) 31 | export OFILES := $(CFILES:src/%.c=build/%.o) 32 | 33 | .PHONY: all clean 34 | 35 | all: dir lib/libgl3ds.a 36 | 37 | dir: 38 | @mkdir -p build/c11 39 | @mkdir -p build/math 40 | @mkdir -p build/util 41 | @mkdir -p build/drivers 42 | @mkdir -p lib 43 | 44 | clean: 45 | @rm -rf build lib 46 | @echo "Successfully cleaned." 47 | 48 | build/%.o: src/%.c 49 | $(CC) -MMD -MP -MF build/$*.d $(CFLAGS) $(DEFINITIONS) -c $< -o $@ 50 | 51 | lib/libgl3ds.a: $(OFILES) 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gl3ds [![Build Status](https://travis-ci.org/cpp3ds/gl3ds.png?branch=master)](https://travis-ci.org/cpp3ds/gl3ds) 2 | ===== 3 | 4 | OpenGL implementation for the Nintendo 3DS using [ctrulib](https://github.com/smealum/ctrulib/). 5 | 6 | This is mostly a port of Mesa 3D with unsupported features stripped. 7 | A lot of portions are currently commented out temporarily until it 8 | can either be implemented properly or deemed incompatible with 9 | hardware or not simply worth implementing. 10 | 11 | Mesa can be referenced here: [http://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/main](http://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/main) 12 | 13 | Requirements 14 | ------------ 15 | 16 | - [DevkitARM](http://devkitpro.org/wiki/Getting_Started/devkitARM) 17 | - [ctrulib](https://github.com/smealum/ctrulib/) 18 | 19 | Supported OpenGL API 20 | -------------------- 21 | 22 | List not yet compiled. 23 | 24 | Credit and Thanks 25 | ----------------- 26 | - [fincs](https://github.com/fincs) - GPU help 27 | - [smealum](https://github.com/smealum) - ctrulib 28 | 29 | Donate BTC: 12XCVwHSX38dvUSWhbUFPJWKWTjHDRG96k -------------------------------------------------------------------------------- /src/arrayobj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. 5 | * (C) Copyright IBM Corporation 2006 6 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, including without limitation 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | * and/or sell copies of the Software, and to permit persons to whom the 13 | * Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included 16 | * in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef ARRAYOBJ_H 28 | #define ARRAYOBJ_H 29 | 30 | #include "glheader.h" 31 | #include "mtypes.h" 32 | 33 | struct gl_context; 34 | 35 | /** 36 | * \file arrayobj.h 37 | * Functions for the GL_APPLE_vertex_array_object extension. 38 | * 39 | * \author Ian Romanick 40 | * \author Brian Paul 41 | */ 42 | 43 | /* 44 | * Internal functions 45 | */ 46 | 47 | extern struct gl_vertex_array_object * 48 | _mesa_lookup_vao(struct gl_context *ctx, GLuint id); 49 | 50 | extern struct gl_vertex_array_object * 51 | _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller); 52 | 53 | extern struct gl_vertex_array_object * 54 | _mesa_new_vao(struct gl_context *ctx, GLuint name); 55 | 56 | extern void 57 | _mesa_delete_vao(struct gl_context *ctx, struct gl_vertex_array_object *obj); 58 | 59 | extern void 60 | _mesa_reference_vao_(struct gl_context *ctx, 61 | struct gl_vertex_array_object **ptr, 62 | struct gl_vertex_array_object *vao); 63 | 64 | static inline void 65 | _mesa_reference_vao(struct gl_context *ctx, 66 | struct gl_vertex_array_object **ptr, 67 | struct gl_vertex_array_object *vao) 68 | { 69 | if (*ptr != vao) 70 | _mesa_reference_vao_(ctx, ptr, vao); 71 | } 72 | 73 | 74 | extern void 75 | _mesa_initialize_vao(struct gl_context *ctx, 76 | struct gl_vertex_array_object *obj, GLuint name); 77 | 78 | 79 | extern void 80 | _mesa_update_vao_client_arrays(struct gl_context *ctx, 81 | struct gl_vertex_array_object *vao); 82 | 83 | 84 | #endif /* ARRAYOBJ_H */ 85 | -------------------------------------------------------------------------------- /src/attrib.h: -------------------------------------------------------------------------------- 1 | #ifndef GL3DS_ATTRIB_H 2 | #define GL3DS_ATTRIB_H 3 | 4 | struct gl_context; 5 | 6 | void _mesa_init_attrib( struct gl_context *ctx ); 7 | 8 | void _mesa_free_attrib_data( struct gl_context *ctx ); 9 | 10 | #endif //GL3DS_ATTRIB_H 11 | -------------------------------------------------------------------------------- /src/blend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file blend.h 3 | * Blending functions operations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | 32 | #ifndef BLEND_H 33 | #define BLEND_H 34 | 35 | 36 | #include "glheader.h" 37 | #include "formats.h" 38 | 39 | struct gl_context; 40 | struct gl_framebuffer; 41 | 42 | 43 | 44 | extern GLboolean 45 | _mesa_get_clamp_fragment_color(const struct gl_context *ctx, 46 | const struct gl_framebuffer *drawFb); 47 | 48 | extern GLboolean 49 | _mesa_get_clamp_vertex_color(const struct gl_context *ctx, 50 | const struct gl_framebuffer *drawFb); 51 | 52 | extern GLboolean 53 | _mesa_get_clamp_read_color(const struct gl_context *ctx, 54 | const struct gl_framebuffer *readFb); 55 | 56 | extern void 57 | _mesa_update_clamp_fragment_color(struct gl_context *ctx, 58 | const struct gl_framebuffer *drawFb); 59 | 60 | extern void 61 | _mesa_update_clamp_vertex_color(struct gl_context *ctx, 62 | const struct gl_framebuffer *drawFb); 63 | 64 | extern mesa_format 65 | _mesa_get_render_format(const struct gl_context *ctx, mesa_format format); 66 | 67 | extern void 68 | _mesa_init_color( struct gl_context * ctx ); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/bufferobj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | 28 | #ifndef BUFFEROBJ_H 29 | #define BUFFEROBJ_H 30 | 31 | #include 32 | #include "mtypes.h" 33 | 34 | 35 | /* 36 | * Internal functions 37 | */ 38 | 39 | 40 | /** Is the given buffer object currently mapped by the GL user? */ 41 | static inline GLboolean 42 | _mesa_bufferobj_mapped(const struct gl_buffer_object *obj, gl_map_buffer_index index) 43 | { 44 | return obj->Mappings[index].Pointer != NULL; 45 | } 46 | 47 | /** Can we not use this buffer while mapped? */ 48 | static inline GLboolean 49 | _mesa_check_disallowed_mapping(const struct gl_buffer_object *obj) 50 | { 51 | // return _mesa_bufferobj_mapped(obj, MAP_USER) && 52 | // !(obj->Mappings[MAP_USER].AccessFlags & 53 | // GL_MAP_PERSISTENT_BIT); 54 | return GL_FALSE; 55 | } 56 | 57 | /** 58 | * Is the given buffer object a user-created buffer object? 59 | * Mesa uses default buffer objects in several places. Default buffers 60 | * always have Name==0. User created buffers have Name!=0. 61 | */ 62 | static inline GLboolean 63 | _mesa_is_bufferobj(const struct gl_buffer_object *obj) 64 | { 65 | return obj != NULL && obj->Name != 0; 66 | } 67 | 68 | 69 | extern void 70 | _mesa_init_buffer_objects(struct gl_context *ctx); 71 | 72 | extern void 73 | _mesa_free_buffer_objects(struct gl_context *ctx); 74 | 75 | extern bool 76 | _mesa_handle_bind_buffer_gen(struct gl_context *ctx, 77 | GLenum target, 78 | GLuint buffer, 79 | struct gl_buffer_object **buf_handle, 80 | const char *caller); 81 | 82 | extern void 83 | _mesa_update_default_objects_buffer_objects(struct gl_context *ctx); 84 | 85 | 86 | extern struct gl_buffer_object * 87 | _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); 88 | 89 | extern struct gl_buffer_object * 90 | _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer); 91 | 92 | extern struct gl_buffer_object * 93 | _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer, 94 | const char *caller); 95 | 96 | extern void 97 | _mesa_begin_bufferobj_lookups(struct gl_context *ctx); 98 | 99 | extern void 100 | _mesa_end_bufferobj_lookups(struct gl_context *ctx); 101 | 102 | extern struct gl_buffer_object * 103 | _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx, 104 | const GLuint *buffers, 105 | GLuint index, const char *caller); 106 | 107 | extern void 108 | _mesa_initialize_buffer_object(struct gl_context *ctx, 109 | struct gl_buffer_object *obj, 110 | GLuint name); 111 | 112 | extern void 113 | _mesa_reference_buffer_object_(struct gl_context *ctx, 114 | struct gl_buffer_object **ptr, 115 | struct gl_buffer_object *bufObj); 116 | 117 | static inline void 118 | _mesa_reference_buffer_object(struct gl_context *ctx, 119 | struct gl_buffer_object **ptr, 120 | struct gl_buffer_object *bufObj) 121 | { 122 | if (*ptr != bufObj) 123 | _mesa_reference_buffer_object_(ctx, ptr, bufObj); 124 | } 125 | 126 | extern GLuint 127 | _mesa_total_buffer_object_memory(struct gl_context *ctx); 128 | 129 | extern void 130 | _mesa_init_buffer_object_functions(struct dd_function_table *driver); 131 | 132 | extern void 133 | _mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj, 134 | GLenum target, GLsizeiptr size, const GLvoid *data, 135 | GLbitfield flags, const char *func); 136 | 137 | extern void 138 | _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, 139 | GLenum target, GLsizeiptr size, const GLvoid *data, 140 | GLenum usage, const char *func); 141 | 142 | extern void 143 | _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, 144 | GLintptr offset, GLsizeiptr size, const GLvoid *data, 145 | const char *func); 146 | 147 | extern void 148 | _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, 149 | struct gl_buffer_object *bufObj); 150 | 151 | extern void 152 | _mesa_copy_buffer_sub_data(struct gl_context *ctx, 153 | struct gl_buffer_object *src, 154 | struct gl_buffer_object *dst, 155 | GLintptr readOffset, GLintptr writeOffset, 156 | GLsizeiptr size, const char *func); 157 | 158 | extern void * 159 | _mesa_map_buffer_range(struct gl_context *ctx, 160 | struct gl_buffer_object *bufObj, 161 | GLintptr offset, GLsizeiptr length, 162 | GLbitfield access, const char *func); 163 | 164 | extern void 165 | _mesa_flush_mapped_buffer_range(struct gl_context *ctx, 166 | struct gl_buffer_object *bufObj, 167 | GLintptr offset, GLsizeiptr length, 168 | const char *func); 169 | 170 | extern void 171 | _mesa_ClearBufferSubData_sw(struct gl_context *ctx, 172 | GLintptr offset, GLsizeiptr size, 173 | const GLvoid *clearValue, 174 | GLsizeiptr clearValueSize, 175 | struct gl_buffer_object *bufObj); 176 | 177 | extern void 178 | _mesa_clear_buffer_sub_data(struct gl_context *ctx, 179 | struct gl_buffer_object *bufObj, 180 | GLenum internalformat, 181 | GLintptr offset, GLsizeiptr size, 182 | GLenum format, GLenum type, 183 | const GLvoid *data, 184 | const char *func, bool subdata); 185 | 186 | extern GLboolean 187 | _mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj, 188 | const char *func); 189 | 190 | /* 191 | * API functions 192 | */ 193 | 194 | 195 | 196 | #endif 197 | -------------------------------------------------------------------------------- /src/buffers.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file buffers.h 3 | * Frame buffer management functions declarations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | 32 | #ifndef BUFFERS_H 33 | #define BUFFERS_H 34 | 35 | 36 | #include "glheader.h" 37 | 38 | struct gl_context; 39 | struct gl_framebuffer; 40 | 41 | extern void 42 | _mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, 43 | GLenum buffer, const char *caller); 44 | 45 | extern void 46 | _mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb, 47 | GLsizei n, const GLenum *buffers, const char *caller); 48 | 49 | extern void 50 | _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, 51 | GLuint n, const GLenum *buffers, 52 | const GLbitfield *destMask); 53 | 54 | extern void 55 | _mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, 56 | GLenum buffer, GLint bufferIndex); 57 | 58 | extern void 59 | _mesa_update_draw_buffers(struct gl_context *ctx); 60 | 61 | 62 | extern void 63 | _mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, 64 | GLenum buffer, const char *caller); 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/c11/threads.h: -------------------------------------------------------------------------------- 1 | #ifndef GL3DS_THREADS 2 | #define GL3DS_THREADS 3 | 4 | #include <3ds.h> 5 | 6 | typedef Handle mtx_t; 7 | 8 | // TODO: real mutexes lol 9 | #define mtx_lock(X) 10 | #define mtx_unlock(X) 11 | #define mtx_init(X, Y) 12 | #define mtx_destroy(X) 13 | #define mtx_plain 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/colormac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /** 27 | * \file colormac.h 28 | * Color-related macros 29 | */ 30 | 31 | 32 | #ifndef COLORMAC_H 33 | #define COLORMAC_H 34 | 35 | 36 | #include "config.h" 37 | #include "macros.h" 38 | #include "mtypes.h" 39 | 40 | 41 | /** 42 | * Convert four float values in [0,1] to ubytes in [0,255] with clamping. 43 | */ 44 | static inline void 45 | _mesa_unclamped_float_rgba_to_ubyte(GLubyte dst[4], const GLfloat src[4]) 46 | { 47 | int i; 48 | for (i = 0; i < 4; i++) 49 | UNCLAMPED_FLOAT_TO_UBYTE(dst[i], src[i]); 50 | } 51 | 52 | 53 | /** 54 | * \name Generic color packing macros. All inputs should be GLubytes. 55 | */ 56 | /*@{*/ 57 | 58 | #define PACK_COLOR_8888( X, Y, Z, W ) \ 59 | (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) 60 | 61 | #define PACK_COLOR_565( X, Y, Z ) \ 62 | ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) 63 | 64 | #define PACK_COLOR_1555( A, B, G, R ) \ 65 | ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ 66 | (((A) & 0x80) << 8)) 67 | 68 | #define PACK_COLOR_4444( R, G, B, A ) \ 69 | ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) 70 | 71 | #define PACK_COLOR_88( L, A ) \ 72 | (((L) << 8) | (A)) 73 | 74 | /*@}*/ 75 | 76 | 77 | #endif /* COLORMAC_H */ 78 | -------------------------------------------------------------------------------- /src/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | /** 28 | * \file compiler.h 29 | * Compiler-related stuff. 30 | */ 31 | 32 | 33 | #ifndef COMPILER_H 34 | #define COMPILER_H 35 | 36 | 37 | #include 38 | 39 | #include 40 | #include 41 | 42 | #include "util/macros.h" 43 | 44 | //#include "c99_compat.h" /* inline, __func__, etc. */ 45 | 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** 52 | * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. 53 | * Do not use these unless absolutely necessary! 54 | * Try to use a runtime test instead. 55 | * For now, only used by some DRI hardware drivers for color/texel packing. 56 | */ 57 | #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN 58 | #if defined(__linux__) 59 | #include 60 | #define CPU_TO_LE32( x ) bswap_32( x ) 61 | #elif defined(__APPLE__) 62 | #include 63 | #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) 64 | #elif defined(__OpenBSD__) 65 | #include 66 | #define CPU_TO_LE32( x ) htole32( x ) 67 | #else /*__linux__ */ 68 | #include 69 | #define CPU_TO_LE32( x ) bswap32( x ) 70 | #endif /*__linux__*/ 71 | #define MESA_BIG_ENDIAN 1 72 | #else 73 | #define CPU_TO_LE32( x ) ( x ) 74 | #define MESA_LITTLE_ENDIAN 1 75 | #endif 76 | #define LE32_TO_CPU( x ) CPU_TO_LE32( x ) 77 | 78 | 79 | 80 | #define IEEE_ONE 0x3f800000 81 | 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | 88 | #endif /* COMPILER_H */ 89 | -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * \file debug.h 27 | * Debugging functions. 28 | * 29 | * \if subset 30 | * (No-op) 31 | * 32 | * \endif 33 | */ 34 | 35 | 36 | #ifndef _DEBUG_H 37 | #define _DEBUG_H 38 | 39 | #include "glheader.h" 40 | 41 | struct gl_context; 42 | struct gl_texture_image; 43 | 44 | extern void _mesa_print_enable_flags( const char *msg, GLuint flags ); 45 | extern void _mesa_print_state( const char *msg, GLuint state ); 46 | extern void _mesa_print_info( struct gl_context *ctx ); 47 | extern void _mesa_init_debug( struct gl_context *ctx ); 48 | 49 | extern void 50 | _mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb); 51 | 52 | extern void 53 | _mesa_dump_texture(GLuint texture, GLuint writeImages); 54 | 55 | extern void 56 | _mesa_dump_textures(GLuint writeImages); 57 | 58 | extern void 59 | _mesa_dump_renderbuffers(GLboolean writeImages); 60 | 61 | extern void 62 | _mesa_dump_color_buffer(const char *filename); 63 | 64 | extern void 65 | _mesa_dump_depth_buffer(const char *filename); 66 | 67 | extern void 68 | _mesa_dump_stencil_buffer(const char *filename); 69 | 70 | extern void 71 | _mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h, 72 | GLenum format, GLenum type); 73 | 74 | extern void 75 | _mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/depth.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #include "glheader.h" 27 | #include "imports.h" 28 | #include "context.h" 29 | #include "depth.h" 30 | #include "enums.h" 31 | #include "macros.h" 32 | #include "mtypes.h" 33 | 34 | /**********************************************************************/ 35 | /***** API Functions *****/ 36 | /**********************************************************************/ 37 | 38 | void glClearDepth( GLclampd depth ) 39 | { 40 | GET_CURRENT_CONTEXT(ctx); 41 | 42 | if (MESA_VERBOSE & VERBOSE_API) 43 | _mesa_debug(ctx, "glClearDepth(%f)\n", depth); 44 | 45 | ctx->Depth.Clear = CLAMP( depth, 0.0, 1.0 ); 46 | } 47 | 48 | 49 | void glClearDepthf( GLclampf depth ) 50 | { 51 | glClearDepth(depth); 52 | } 53 | 54 | 55 | void glDepthFunc( GLenum func ) 56 | { 57 | GET_CURRENT_CONTEXT(ctx); 58 | 59 | if (MESA_VERBOSE & VERBOSE_API) 60 | _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); 61 | 62 | switch (func) { 63 | case GL_LESS: /* (default) pass if incoming z < stored z */ 64 | case GL_GEQUAL: 65 | case GL_LEQUAL: 66 | case GL_GREATER: 67 | case GL_NOTEQUAL: 68 | case GL_EQUAL: 69 | case GL_ALWAYS: 70 | case GL_NEVER: 71 | break; 72 | default: 73 | _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); 74 | return; 75 | } 76 | 77 | if (ctx->Depth.Func == func) 78 | return; 79 | 80 | FLUSH_VERTICES(ctx, _NEW_DEPTH); 81 | ctx->Depth.Func = func; 82 | 83 | if (ctx->Driver.DepthFunc) 84 | ctx->Driver.DepthFunc( ctx, func ); 85 | } 86 | 87 | 88 | void glDepthMask( GLboolean flag ) 89 | { 90 | GET_CURRENT_CONTEXT(ctx); 91 | 92 | if (MESA_VERBOSE & VERBOSE_API) 93 | _mesa_debug(ctx, "glDepthMask %d\n", flag); 94 | 95 | /* 96 | * GL_TRUE indicates depth buffer writing is enabled (default) 97 | * GL_FALSE indicates depth buffer writing is disabled 98 | */ 99 | if (ctx->Depth.Mask == flag) 100 | return; 101 | 102 | FLUSH_VERTICES(ctx, _NEW_DEPTH); 103 | ctx->Depth.Mask = flag; 104 | 105 | if (ctx->Driver.DepthMask) 106 | ctx->Driver.DepthMask( ctx, flag ); 107 | } 108 | 109 | 110 | /** 111 | * Specified by the GL_EXT_depth_bounds_test extension. 112 | */ 113 | void glDepthBoundsEXT( GLclampd zmin, GLclampd zmax ) 114 | { 115 | GET_CURRENT_CONTEXT(ctx); 116 | 117 | if (MESA_VERBOSE & VERBOSE_API) 118 | _mesa_debug(ctx, "glDepthBounds(%f, %f)\n", zmin, zmax); 119 | 120 | if (zmin > zmax) { 121 | _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); 122 | return; 123 | } 124 | 125 | zmin = CLAMP(zmin, 0.0, 1.0); 126 | zmax = CLAMP(zmax, 0.0, 1.0); 127 | 128 | if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) 129 | return; 130 | 131 | FLUSH_VERTICES(ctx, _NEW_DEPTH); 132 | ctx->Depth.BoundsMin = (GLfloat) zmin; 133 | ctx->Depth.BoundsMax = (GLfloat) zmax; 134 | } 135 | 136 | 137 | /**********************************************************************/ 138 | /***** Initialization *****/ 139 | /**********************************************************************/ 140 | 141 | 142 | /** 143 | * Initialize the depth buffer attribute group in the given context. 144 | */ 145 | void _mesa_init_depth(struct gl_context *ctx) 146 | { 147 | ctx->Depth.Test = GL_FALSE; 148 | ctx->Depth.Clear = 1.0; 149 | ctx->Depth.Func = GL_LESS; 150 | ctx->Depth.Mask = GL_TRUE; 151 | } 152 | 153 | void _gl3ds_update_depth(struct gl_context * ctx) 154 | { 155 | const GLubyte mask = 0x0f; 156 | // TODO: use ctx->Color.ColorMask instead of mask? 157 | 158 | if (ctx->Depth.Test) 159 | GPUCMD_AddSingleParam(0x000F0107, 1 | (ctx->Depth.Func << 4) | (mask << 8) | (ctx->Depth.Mask << 12)); 160 | else 161 | GPUCMD_AddSingleParam(0x000F0107, 0 | (mask << 8) | (ctx->Depth.Mask << 12)); 162 | 163 | // This is unknown 164 | GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0); 165 | GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0); 166 | } -------------------------------------------------------------------------------- /src/depth.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file depth.h 3 | * Depth buffer operations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef DEPTH_H 32 | #define DEPTH_H 33 | 34 | 35 | #include "glheader.h" 36 | 37 | struct gl_context; 38 | 39 | extern void 40 | _mesa_init_depth( struct gl_context * ctx ); 41 | 42 | void 43 | _gl3ds_update_depth(struct gl_context * ctx); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/drivers/driverfuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef DRIVERFUNCS_H 27 | #define DRIVERFUNCS_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | extern void 34 | _mesa_init_driver_functions(struct dd_function_table *driver); 35 | 36 | 37 | extern void 38 | _mesa_init_driver_state(struct gl_context *ctx); 39 | 40 | 41 | 42 | #ifdef __cplusplus 43 | } // extern "C" 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/drivers/s_chan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2011 VMware, Inc. All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * Types, macros, etc for the GLchan datatype. 27 | * The swrast module is kind of hard-coded for 8bpp color channels but 28 | * may be recompiled to use 16- or 32-bit color channels. But that 29 | * feature is seldom used and is likely broken in various ways. 30 | */ 31 | 32 | #ifndef U_CHAN_H 33 | #define U_CHAN_H 34 | 35 | 36 | #include "../config.h" 37 | 38 | 39 | /** 40 | * Default bits per color channel: 8, 16 or 32 41 | */ 42 | #ifndef CHAN_BITS 43 | #define CHAN_BITS 8 44 | #endif 45 | 46 | 47 | /** 48 | * Color channel data type. 49 | */ 50 | #if CHAN_BITS == 8 51 | typedef GLubyte GLchan; 52 | #define CHAN_MAX 255 53 | #define CHAN_MAXF 255.0F 54 | #define CHAN_TYPE GL_UNSIGNED_BYTE 55 | #elif CHAN_BITS == 16 56 | typedef GLushort GLchan; 57 | #define CHAN_MAX 65535 58 | #define CHAN_MAXF 65535.0F 59 | #define CHAN_TYPE GL_UNSIGNED_SHORT 60 | #elif CHAN_BITS == 32 61 | typedef GLfloat GLchan; 62 | #define CHAN_MAX 1.0 63 | #define CHAN_MAXF 1.0F 64 | #define CHAN_TYPE GL_FLOAT 65 | #else 66 | #error "illegal number of color channel bits" 67 | #endif 68 | 69 | 70 | #if CHAN_BITS == 8 71 | 72 | #define CHAN_TO_UBYTE(c) (c) 73 | #define CHAN_TO_USHORT(c) (((c) << 8) | (c)) 74 | #define CHAN_TO_SHORT(c) (((c) << 7) | ((c) >> 1)) 75 | #define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) 76 | 77 | #define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) 78 | #define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) 79 | 80 | #define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) 81 | 82 | #elif CHAN_BITS == 16 83 | 84 | #define CHAN_TO_UBYTE(c) ((c) >> 8) 85 | #define CHAN_TO_USHORT(c) (c) 86 | #define CHAN_TO_SHORT(c) ((c) >> 1) 87 | #define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) 88 | 89 | #define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f) 90 | #define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f) 91 | 92 | #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) 93 | 94 | #elif CHAN_BITS == 32 95 | 96 | #define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c) 97 | #define CHAN_TO_USHORT(c) ((GLushort) (CLAMP((c), 0.0f, 1.0f) * 65535.0)) 98 | #define CHAN_TO_SHORT(c) ((GLshort) (CLAMP((c), 0.0f, 1.0f) * 32767.0)) 99 | #define CHAN_TO_FLOAT(c) (c) 100 | 101 | #define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) 102 | #define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) 103 | 104 | #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) 105 | 106 | #else 107 | 108 | #error unexpected CHAN_BITS size 109 | 110 | #endif 111 | 112 | 113 | /** 114 | * Convert 4 floats to GLchan values. 115 | * \param dst pointer to destination GLchan[4] array. 116 | * \param f pointer to source GLfloat[4] array. 117 | */ 118 | #define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \ 119 | do { \ 120 | UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ 121 | UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ 122 | UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ 123 | UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \ 124 | } while (0) 125 | 126 | 127 | 128 | #endif /* U_CHAN_H */ 129 | -------------------------------------------------------------------------------- /src/enable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file enable.h 3 | * Enable/disable/query GL capabilities. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef ENABLE_H 32 | #define ENABLE_H 33 | 34 | 35 | #include "glheader.h" 36 | 37 | struct gl_context; 38 | 39 | 40 | extern void 41 | _mesa_set_enable( struct gl_context* ctx, GLenum cap, GLboolean state ); 42 | 43 | extern void 44 | _mesa_set_enablei(struct gl_context *ctx, GLenum cap, GLuint index, GLboolean state); 45 | 46 | extern void 47 | _mesa_set_multisample(struct gl_context *ctx, GLboolean state); 48 | 49 | extern void 50 | _mesa_set_framebuffer_srgb(struct gl_context *ctx, GLboolean state); 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/enums.c: -------------------------------------------------------------------------------- 1 | 2 | extern const char *_mesa_lookup_enum_by_nr( int nr ) 3 | { 4 | return ""; 5 | } 6 | 7 | const char *_mesa_lookup_prim_by_nr( unsigned nr ) 8 | { 9 | return ""; 10 | } 11 | -------------------------------------------------------------------------------- /src/enums.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file enums.h 3 | * Enumeration name/number lookup functions. 4 | * 5 | * \if subset 6 | * (No-op) 7 | * 8 | * \endif 9 | */ 10 | 11 | /* 12 | * Mesa 3-D graphics library 13 | * 14 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 15 | * 16 | * Permission is hereby granted, free of charge, to any person obtaining a 17 | * copy of this software and associated documentation files (the "Software"), 18 | * to deal in the Software without restriction, including without limitation 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 20 | * and/or sell copies of the Software, and to permit persons to whom the 21 | * Software is furnished to do so, subject to the following conditions: 22 | * 23 | * The above copyright notice and this permission notice shall be included 24 | * in all copies or substantial portions of the Software. 25 | * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 27 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 29 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 32 | * OTHER DEALINGS IN THE SOFTWARE. 33 | */ 34 | 35 | 36 | #ifndef _ENUMS_H_ 37 | #define _ENUMS_H_ 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | 45 | extern const char *_mesa_lookup_enum_by_nr( int nr ); 46 | 47 | /* Get the name of an enum given that it is a primitive type. Avoids 48 | * GL_FALSE/GL_POINTS ambiguity and others. 49 | */ 50 | const char *_mesa_lookup_prim_by_nr( unsigned nr ); 51 | 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /** 27 | * \file errors.h 28 | * Mesa debugging and error handling functions. 29 | * 30 | * This file provides functions to record errors, warnings, and miscellaneous 31 | * debug information. 32 | */ 33 | 34 | 35 | #ifndef ERRORS_H 36 | #define ERRORS_H 37 | 38 | 39 | #include 40 | #include "compiler.h" 41 | #include "glheader.h" 42 | #include "mtypes.h" 43 | 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | struct _glapi_table; 50 | 51 | extern void 52 | _mesa_init_errors( struct gl_context *ctx ); 53 | 54 | extern void 55 | _mesa_free_errors_data( struct gl_context *ctx ); 56 | 57 | extern void 58 | _mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); 59 | 60 | extern void 61 | _mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); 62 | 63 | extern void 64 | _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); 65 | 66 | extern void 67 | _mesa_error_no_memory(const char *caller); 68 | 69 | extern void 70 | _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); 71 | 72 | extern void 73 | _mesa_log(const char *fmtString, ...) PRINTFLIKE(1, 2); 74 | 75 | extern FILE * 76 | _mesa_get_log_file(void); 77 | 78 | extern void 79 | _mesa_gl_debug(struct gl_context *ctx, 80 | GLuint *id, 81 | enum mesa_debug_source source, 82 | enum mesa_debug_type type, 83 | enum mesa_debug_severity severity, 84 | const char *fmtString, ...) PRINTFLIKE(6, 7); 85 | 86 | #define _mesa_perf_debug(ctx, sev, ...) do { \ 87 | static GLuint msg_id = 0; \ 88 | if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) { \ 89 | _mesa_gl_debug(ctx, &msg_id, \ 90 | MESA_DEBUG_SOURCE_API, \ 91 | MESA_DEBUG_TYPE_PERFORMANCE, \ 92 | sev, \ 93 | __VA_ARGS__); \ 94 | } \ 95 | } while (0) 96 | 97 | bool 98 | _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val); 99 | 100 | GLint 101 | _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname); 102 | 103 | void * 104 | _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname); 105 | 106 | extern void 107 | _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id, 108 | const char *msg, int len); 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | 115 | #endif /* ERRORS_H */ 116 | -------------------------------------------------------------------------------- /src/extensions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file extensions.h 3 | * Extension handling. 4 | * 5 | * \if subset 6 | * (No-op) 7 | * 8 | * \endif 9 | */ 10 | 11 | /* 12 | * Mesa 3-D graphics library 13 | * 14 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 15 | * 16 | * Permission is hereby granted, free of charge, to any person obtaining a 17 | * copy of this software and associated documentation files (the "Software"), 18 | * to deal in the Software without restriction, including without limitation 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 20 | * and/or sell copies of the Software, and to permit persons to whom the 21 | * Software is furnished to do so, subject to the following conditions: 22 | * 23 | * The above copyright notice and this permission notice shall be included 24 | * in all copies or substantial portions of the Software. 25 | * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 27 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 29 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 30 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 32 | * OTHER DEALINGS IN THE SOFTWARE. 33 | */ 34 | 35 | 36 | #ifndef _EXTENSIONS_H_ 37 | #define _EXTENSIONS_H_ 38 | 39 | #include "glheader.h" 40 | 41 | struct gl_context; 42 | struct gl_extensions; 43 | 44 | extern void _mesa_enable_sw_extensions(struct gl_context *ctx); 45 | 46 | extern void _mesa_one_time_init_extension_overrides(void); 47 | 48 | extern void _mesa_init_extensions(struct gl_extensions *extentions); 49 | 50 | extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); 51 | 52 | extern GLuint 53 | _mesa_get_extension_count(struct gl_context *ctx); 54 | 55 | extern const GLubyte * 56 | _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); 57 | 58 | extern struct gl_extensions _mesa_extension_override_enables; 59 | extern struct gl_extensions _mesa_extension_override_disables; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/fbobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef FBOBJECT_H 27 | #define FBOBJECT_H 28 | 29 | #include "compiler.h" 30 | #include "glheader.h" 31 | #include 32 | 33 | struct gl_context; 34 | struct gl_texture_object; 35 | 36 | 37 | /** 38 | * Is the given FBO a user-created FBO? 39 | */ 40 | static inline GLboolean 41 | _mesa_is_user_fbo(const struct gl_framebuffer *fb) 42 | { 43 | return fb->Name != 0; 44 | } 45 | 46 | 47 | /** 48 | * Is the given FBO a window system FBO (like an X window)? 49 | */ 50 | static inline GLboolean 51 | _mesa_is_winsys_fbo(const struct gl_framebuffer *fb) 52 | { 53 | return fb->Name == 0; 54 | } 55 | 56 | 57 | 58 | extern void 59 | _mesa_init_fbobjects(struct gl_context *ctx); 60 | 61 | extern struct gl_framebuffer * 62 | _mesa_get_incomplete_framebuffer(void); 63 | 64 | extern struct gl_renderbuffer * 65 | _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id); 66 | 67 | extern struct gl_renderbuffer * 68 | _mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id, 69 | const char *func); 70 | 71 | extern struct gl_framebuffer * 72 | _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id); 73 | 74 | extern struct gl_framebuffer * 75 | _mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id, 76 | const char *func); 77 | 78 | 79 | void 80 | _mesa_update_texture_renderbuffer(struct gl_context *ctx, 81 | struct gl_framebuffer *fb, 82 | struct gl_renderbuffer_attachment *att); 83 | 84 | extern void 85 | _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx, 86 | struct gl_framebuffer *fb, 87 | GLenum attachment, 88 | struct gl_renderbuffer *rb); 89 | 90 | extern void 91 | _mesa_framebuffer_renderbuffer(struct gl_context *ctx, 92 | struct gl_framebuffer *fb, 93 | GLenum attachment, 94 | struct gl_renderbuffer *rb, 95 | const char *func); 96 | 97 | extern void 98 | _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb); 99 | 100 | extern GLboolean 101 | _mesa_has_depthstencil_combined(const struct gl_framebuffer *fb); 102 | 103 | extern void 104 | _mesa_test_framebuffer_completeness(struct gl_context *ctx, 105 | struct gl_framebuffer *fb); 106 | 107 | extern GLboolean 108 | _mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat); 109 | 110 | extern GLenum 111 | _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat); 112 | 113 | extern bool 114 | _mesa_detach_renderbuffer(struct gl_context *ctx, 115 | struct gl_framebuffer *fb, 116 | const void *att); 117 | 118 | extern void 119 | _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb, 120 | GLenum attachment, 121 | struct gl_texture_object *texObj, GLenum textarget, 122 | GLint level, GLuint layer, GLboolean layered, 123 | const char *caller); 124 | 125 | extern GLenum 126 | _mesa_check_framebuffer_status(struct gl_context *ctx, 127 | struct gl_framebuffer *fb); 128 | 129 | extern void 130 | _mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx, 131 | struct gl_framebuffer *buffer, 132 | GLenum attachment, GLenum pname, 133 | GLint *params, const char *caller); 134 | 135 | 136 | #endif /* FBOBJECT_H */ 137 | -------------------------------------------------------------------------------- /src/format_pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (c) 2011 VMware, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef FORMAT_PACK_H 27 | #define FORMAT_PACK_H 28 | 29 | 30 | #include "formats.h" 31 | 32 | 33 | /** Pack a GLubyte rgba[4] color to dest address */ 34 | typedef void (*gl_pack_ubyte_rgba_func)(const GLubyte src[4], void *dst); 35 | 36 | /** Pack a GLfloat rgba[4] color to dest address */ 37 | typedef void (*gl_pack_float_rgba_func)(const GLfloat src[4], void *dst); 38 | 39 | /** Pack a GLfloat Z value to dest address */ 40 | typedef void (*gl_pack_float_z_func)(const GLfloat *src, void *dst); 41 | 42 | /** Pack a GLuint Z value to dest address */ 43 | typedef void (*gl_pack_uint_z_func)(const GLuint *src, void *dst); 44 | 45 | /** Pack a GLubyte stencil value to dest address */ 46 | typedef void (*gl_pack_ubyte_stencil_func)(const GLubyte *src, void *dst); 47 | 48 | 49 | 50 | 51 | extern gl_pack_ubyte_rgba_func 52 | _mesa_get_pack_ubyte_rgba_function(mesa_format format); 53 | 54 | 55 | extern gl_pack_float_rgba_func 56 | _mesa_get_pack_float_rgba_function(mesa_format format); 57 | 58 | 59 | extern gl_pack_float_z_func 60 | _mesa_get_pack_float_z_func(mesa_format format); 61 | 62 | 63 | extern gl_pack_uint_z_func 64 | _mesa_get_pack_uint_z_func(mesa_format format); 65 | 66 | 67 | extern gl_pack_ubyte_stencil_func 68 | _mesa_get_pack_ubyte_stencil_func(mesa_format format); 69 | 70 | 71 | extern void 72 | _mesa_pack_float_rgba_row(mesa_format format, GLuint n, 73 | const GLfloat src[][4], void *dst); 74 | 75 | extern void 76 | _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n, 77 | const GLubyte src[][4], void *dst); 78 | 79 | extern void 80 | _mesa_pack_uint_rgba_row(mesa_format format, GLuint n, 81 | const GLuint src[][4], void *dst); 82 | 83 | extern void 84 | _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height, 85 | const GLubyte *src, GLint srcRowStride, 86 | void *dst, GLint dstRowStride); 87 | 88 | extern void 89 | _mesa_pack_float_z_row(mesa_format format, GLuint n, 90 | const GLfloat *src, void *dst); 91 | 92 | extern void 93 | _mesa_pack_uint_z_row(mesa_format format, GLuint n, 94 | const GLuint *src, void *dst); 95 | 96 | extern void 97 | _mesa_pack_ubyte_stencil_row(mesa_format format, GLuint n, 98 | const GLubyte *src, void *dst); 99 | 100 | extern void 101 | _mesa_pack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n, 102 | const GLuint *src, void *dst); 103 | 104 | 105 | extern void 106 | _mesa_pack_colormask(mesa_format format, const GLubyte colorMask[4], void *dst); 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/framebuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef FRAMEBUFFER_H 27 | #define FRAMEBUFFER_H 28 | 29 | #include "glheader.h" 30 | 31 | struct gl_config; 32 | struct gl_context; 33 | struct gl_renderbuffer; 34 | 35 | extern struct gl_framebuffer * 36 | _mesa_create_framebuffer(const struct gl_config *visual); 37 | 38 | extern struct gl_framebuffer * 39 | _mesa_new_framebuffer(struct gl_context *ctx, GLuint name); 40 | 41 | extern void 42 | _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, 43 | const struct gl_config *visual); 44 | 45 | extern void 46 | _mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name); 47 | 48 | extern void 49 | _mesa_destroy_framebuffer(struct gl_framebuffer *buffer); 50 | 51 | extern void 52 | _mesa_free_framebuffer_data(struct gl_framebuffer *buffer); 53 | 54 | extern void 55 | _mesa_reference_framebuffer_(struct gl_framebuffer **ptr, 56 | struct gl_framebuffer *fb); 57 | 58 | static inline void 59 | _mesa_reference_framebuffer(struct gl_framebuffer **ptr, 60 | struct gl_framebuffer *fb) 61 | { 62 | if (*ptr != fb) 63 | _mesa_reference_framebuffer_(ptr, fb); 64 | } 65 | 66 | extern void 67 | _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, 68 | GLuint width, GLuint height); 69 | 70 | 71 | extern void 72 | _mesa_resizebuffers( struct gl_context *ctx ); 73 | 74 | extern void 75 | _mesa_scissor_bounding_box(const struct gl_context *ctx, 76 | const struct gl_framebuffer *buffer, 77 | unsigned idx, int *bbox); 78 | 79 | extern void 80 | _mesa_update_draw_buffer_bounds(struct gl_context *ctx, 81 | struct gl_framebuffer *drawFb); 82 | 83 | extern void 84 | _mesa_update_framebuffer_visual(struct gl_context *ctx, 85 | struct gl_framebuffer *fb); 86 | 87 | extern void 88 | _mesa_update_framebuffer(struct gl_context *ctx, 89 | struct gl_framebuffer *readFb, 90 | struct gl_framebuffer *drawFb); 91 | 92 | extern GLboolean 93 | _mesa_source_buffer_exists(struct gl_context *ctx, GLenum format); 94 | 95 | extern GLboolean 96 | _mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format); 97 | 98 | extern GLenum 99 | _mesa_get_color_read_type(struct gl_context *ctx); 100 | 101 | extern GLenum 102 | _mesa_get_color_read_format(struct gl_context *ctx); 103 | 104 | extern struct gl_renderbuffer * 105 | _mesa_get_read_renderbuffer_for_format(const struct gl_context *ctx, 106 | GLenum format); 107 | 108 | extern void 109 | _mesa_print_framebuffer(const struct gl_framebuffer *fb); 110 | 111 | #endif /* FRAMEBUFFER_H */ 112 | -------------------------------------------------------------------------------- /src/get.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file get.h 3 | * State query functions. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef GET_H 32 | #define GET_H 33 | 34 | 35 | #include "glheader.h" 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/glformats.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (c) 2008-2009 VMware, Inc. 6 | * Copyright (c) 2012 Intel Corporation 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, including without limitation 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | * and/or sell copies of the Software, and to permit persons to whom the 13 | * Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included 16 | * in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef GLFORMATS_H 28 | #define GLFORMATS_H 29 | 30 | 31 | #include 32 | 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | extern void 39 | _mesa_compute_component_mapping(GLenum inFormat, GLenum outFormat, GLubyte *map); 40 | 41 | extern GLboolean 42 | _mesa_type_is_packed(GLenum type); 43 | 44 | extern GLint 45 | _mesa_sizeof_type( GLenum type ); 46 | 47 | extern GLint 48 | _mesa_sizeof_packed_type( GLenum type ); 49 | 50 | extern GLint 51 | _mesa_components_in_format( GLenum format ); 52 | 53 | extern GLint 54 | _mesa_bytes_per_pixel( GLenum format, GLenum type ); 55 | 56 | extern GLint 57 | _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type); 58 | 59 | extern GLboolean 60 | _mesa_is_type_unsigned(GLenum type); 61 | 62 | extern GLboolean 63 | _mesa_is_enum_format_unsized(GLenum format); 64 | 65 | extern GLboolean 66 | _mesa_is_enum_format_unorm(GLenum format); 67 | 68 | extern GLboolean 69 | _mesa_is_enum_format_snorm(GLenum format); 70 | 71 | extern GLboolean 72 | _mesa_is_enum_format_integer(GLenum format); 73 | 74 | extern GLboolean 75 | _mesa_is_enum_format_unsigned_int(GLenum format); 76 | 77 | extern GLboolean 78 | _mesa_is_enum_format_signed_int(GLenum format); 79 | 80 | extern GLboolean 81 | _mesa_is_color_format(GLenum format); 82 | 83 | extern GLboolean 84 | _mesa_is_depth_format(GLenum format); 85 | 86 | extern GLboolean 87 | _mesa_is_stencil_format(GLenum format); 88 | 89 | extern GLboolean 90 | _mesa_is_ycbcr_format(GLenum format); 91 | 92 | extern GLboolean 93 | _mesa_is_depthstencil_format(GLenum format); 94 | 95 | extern GLboolean 96 | _mesa_is_depth_or_stencil_format(GLenum format); 97 | 98 | extern GLboolean 99 | _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format); 100 | 101 | extern GLenum 102 | _mesa_base_format_to_integer_format(GLenum format); 103 | 104 | extern GLboolean 105 | _mesa_base_format_has_channel(GLenum base_format, GLenum pname); 106 | 107 | extern GLint 108 | _mesa_base_format_component_count(GLenum base_format); 109 | 110 | extern GLenum 111 | _mesa_generic_compressed_format_to_uncompressed_format(GLenum format); 112 | 113 | extern GLenum 114 | _mesa_get_nongeneric_internalformat(GLenum format); 115 | 116 | extern GLenum 117 | _mesa_get_linear_internalformat(GLenum format); 118 | 119 | extern GLenum 120 | _mesa_error_check_format_and_type(const struct gl_context *ctx, 121 | GLenum format, GLenum type); 122 | 123 | extern GLenum 124 | _mesa_es_error_check_format_and_type(GLenum format, GLenum type, 125 | unsigned dimensions); 126 | 127 | extern GLenum 128 | _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, 129 | GLenum format, GLenum type, 130 | GLenum internalFormat); 131 | 132 | extern uint32_t 133 | _mesa_format_from_format_and_type(GLenum format, GLenum type); 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /* GLFORMATS_H */ 140 | -------------------------------------------------------------------------------- /src/glheader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /** 27 | * \file glheader.h 28 | * Wrapper for GL/gl.h and GL/glext.h 29 | */ 30 | 31 | 32 | #ifndef GLHEADER_H 33 | #define GLHEADER_H 34 | 35 | 36 | #define GL_GLEXT_PROTOTYPES 37 | //#include "GL/gl.h" 38 | //#include "GL/glext.h" 39 | #include 40 | 41 | #endif /* GLHEADER_H */ 42 | -------------------------------------------------------------------------------- /src/hash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file hash.h 3 | * Generic hash table. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef HASH_H 32 | #define HASH_H 33 | 34 | 35 | #include "glheader.h" 36 | 37 | 38 | extern struct _mesa_HashTable *_mesa_NewHashTable(void); 39 | 40 | extern void _mesa_DeleteHashTable(struct _mesa_HashTable *table); 41 | 42 | extern void *_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key); 43 | 44 | extern void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data); 45 | 46 | extern void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key); 47 | 48 | extern void _mesa_HashLockMutex(struct _mesa_HashTable *table); 49 | 50 | extern void _mesa_HashUnlockMutex(struct _mesa_HashTable *table); 51 | 52 | extern void *_mesa_HashLookupLocked(struct _mesa_HashTable *table, GLuint key); 53 | 54 | extern void _mesa_HashInsertLocked(struct _mesa_HashTable *table, 55 | GLuint key, void *data); 56 | 57 | extern void 58 | _mesa_HashDeleteAll(struct _mesa_HashTable *table, 59 | void (*callback)(GLuint key, void *data, void *userData), 60 | void *userData); 61 | 62 | extern struct _mesa_HashTable * 63 | _mesa_HashClone(const struct _mesa_HashTable *table); 64 | 65 | extern void 66 | _mesa_HashWalk(const struct _mesa_HashTable *table, 67 | void (*callback)(GLuint key, void *data, void *userData), 68 | void *userData); 69 | 70 | extern void _mesa_HashPrint(const struct _mesa_HashTable *table); 71 | 72 | extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys); 73 | 74 | extern GLuint 75 | _mesa_HashNumEntries(const struct _mesa_HashTable *table); 76 | 77 | extern void _mesa_test_hash_functions(void); 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef IMAGE_H 27 | #define IMAGE_H 28 | 29 | 30 | #include "glheader.h" 31 | #include "compiler.h" 32 | 33 | struct gl_context; 34 | struct gl_pixelstore_attrib; 35 | struct gl_framebuffer; 36 | 37 | extern void 38 | _mesa_swap2_copy(GLushort *dst, GLushort *src, GLuint n); 39 | 40 | extern void 41 | _mesa_swap4_copy(GLuint *dst, GLuint *src, GLuint n); 42 | 43 | static inline void 44 | _mesa_swap2(GLushort *p, GLuint n) 45 | { 46 | _mesa_swap2_copy(p, p, n); 47 | } 48 | 49 | static inline void 50 | _mesa_swap4(GLuint *p, GLuint n) 51 | { 52 | _mesa_swap4_copy(p, p, n); 53 | } 54 | 55 | extern GLintptr 56 | _mesa_image_offset( GLuint dimensions, 57 | const struct gl_pixelstore_attrib *packing, 58 | GLsizei width, GLsizei height, 59 | GLenum format, GLenum type, 60 | GLint img, GLint row, GLint column ); 61 | 62 | extern GLvoid * 63 | _mesa_image_address( GLuint dimensions, 64 | const struct gl_pixelstore_attrib *packing, 65 | const GLvoid *image, 66 | GLsizei width, GLsizei height, 67 | GLenum format, GLenum type, 68 | GLint img, GLint row, GLint column ); 69 | 70 | extern GLvoid * 71 | _mesa_image_address1d( const struct gl_pixelstore_attrib *packing, 72 | const GLvoid *image, 73 | GLsizei width, 74 | GLenum format, GLenum type, 75 | GLint column ); 76 | 77 | extern GLvoid * 78 | _mesa_image_address2d( const struct gl_pixelstore_attrib *packing, 79 | const GLvoid *image, 80 | GLsizei width, GLsizei height, 81 | GLenum format, GLenum type, 82 | GLint row, GLint column ); 83 | 84 | extern GLvoid * 85 | _mesa_image_address3d( const struct gl_pixelstore_attrib *packing, 86 | const GLvoid *image, 87 | GLsizei width, GLsizei height, 88 | GLenum format, GLenum type, 89 | GLint img, GLint row, GLint column ); 90 | 91 | 92 | extern GLint 93 | _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, 94 | GLint width, GLenum format, GLenum type ); 95 | 96 | 97 | extern GLint 98 | _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, 99 | GLint width, GLint height, 100 | GLenum format, GLenum type ); 101 | 102 | 103 | extern void 104 | _mesa_expand_bitmap(GLsizei width, GLsizei height, 105 | const struct gl_pixelstore_attrib *unpack, 106 | const GLubyte *bitmap, 107 | GLubyte *destBuffer, GLint destStride, 108 | GLubyte onValue); 109 | 110 | 111 | extern void 112 | _mesa_convert_colors(GLenum srcType, const GLvoid *src, 113 | GLenum dstType, GLvoid *dst, 114 | GLuint count, const GLubyte mask[]); 115 | 116 | 117 | extern GLboolean 118 | _mesa_clip_drawpixels(const struct gl_context *ctx, 119 | GLint *destX, GLint *destY, 120 | GLsizei *width, GLsizei *height, 121 | struct gl_pixelstore_attrib *unpack); 122 | 123 | 124 | extern GLboolean 125 | _mesa_clip_readpixels(const struct gl_context *ctx, 126 | GLint *srcX, GLint *srcY, 127 | GLsizei *width, GLsizei *height, 128 | struct gl_pixelstore_attrib *pack); 129 | 130 | extern GLboolean 131 | _mesa_clip_copytexsubimage(const struct gl_context *ctx, 132 | GLint *destX, GLint *destY, 133 | GLint *srcX, GLint *srcY, 134 | GLsizei *width, GLsizei *height); 135 | 136 | extern GLboolean 137 | _mesa_clip_to_region(GLint xmin, GLint ymin, 138 | GLint xmax, GLint ymax, 139 | GLint *x, GLint *y, 140 | GLsizei *width, GLsizei *height ); 141 | 142 | extern GLboolean 143 | _mesa_clip_blit(struct gl_context *ctx, 144 | const struct gl_framebuffer *readFb, 145 | const struct gl_framebuffer *drawFb, 146 | GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, 147 | GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1); 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /src/light.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef LIGHT_H 28 | #define LIGHT_H 29 | 30 | 31 | #include "glheader.h" 32 | 33 | struct gl_context; 34 | struct gl_light; 35 | struct gl_material; 36 | 37 | 38 | extern void 39 | _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params); 40 | 41 | 42 | extern GLuint _mesa_material_bitmask( struct gl_context *ctx, 43 | GLenum face, GLenum pname, 44 | GLuint legal, 45 | const char * ); 46 | 47 | extern void _mesa_update_lighting( struct gl_context *ctx ); 48 | 49 | extern void _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ); 50 | 51 | extern void _mesa_update_material( struct gl_context *ctx, 52 | GLuint bitmask ); 53 | 54 | extern void _mesa_update_color_material( struct gl_context *ctx, 55 | const GLfloat rgba[4] ); 56 | 57 | extern void _mesa_init_lighting( struct gl_context *ctx ); 58 | 59 | extern void _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef GL3DS_MATRICES_H 2 | #define GL3DS_MATRICES_H 3 | 4 | #include "glheader.h" 5 | #include "math/m_matrix.h" 6 | 7 | struct gl_context; 8 | 9 | void _mesa_init_matrix( struct gl_context * ctx ); 10 | void _mesa_init_transform( struct gl_context *ctx ); 11 | void _mesa_free_matrix_data( struct gl_context *ctx ); 12 | void _mesa_update_modelview_project( struct gl_context *ctx, GLuint newstate ); 13 | void _gl3ds_upload_matrix(GLmatrix *mat, GLint uniform, bool rotate); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/mipmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef MIPMAP_H 27 | #define MIPMAP_H 28 | 29 | #include "mtypes.h" 30 | 31 | 32 | extern void 33 | _mesa_generate_mipmap_level(GLenum target, 34 | GLenum datatype, GLuint comps, 35 | GLint border, 36 | GLint srcWidth, GLint srcHeight, GLint srcDepth, 37 | const GLubyte **srcData, 38 | GLint srcRowStride, 39 | GLint dstWidth, GLint dstHeight, GLint dstDepth, 40 | GLubyte **dstData, 41 | GLint dstRowStride); 42 | 43 | 44 | extern GLboolean 45 | _mesa_prepare_mipmap_level(struct gl_context *ctx, 46 | struct gl_texture_object *texObj, GLuint level, 47 | GLsizei width, GLsizei height, GLsizei depth, 48 | GLsizei border, GLenum intFormat, mesa_format format); 49 | 50 | extern void 51 | _mesa_generate_mipmap(struct gl_context *ctx, GLenum target, 52 | struct gl_texture_object *texObj); 53 | 54 | extern GLboolean 55 | _mesa_next_mipmap_level_size(GLenum target, GLint border, 56 | GLint srcWidth, GLint srcHeight, GLint srcDepth, 57 | GLint *dstWidth, GLint *dstHeight, GLint *dstDepth); 58 | 59 | #endif /* MIPMAP_H */ 60 | -------------------------------------------------------------------------------- /src/multisample.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef MULTISAMPLE_H 27 | #define MULTISAMPLE_H 28 | 29 | #include "glheader.h" 30 | 31 | struct gl_context; 32 | 33 | extern void 34 | _mesa_init_multisample(struct gl_context *ctx); 35 | 36 | extern GLenum 37 | _mesa_check_sample_count(struct gl_context *ctx, GLenum target, 38 | GLenum internalFormat, GLsizei samples); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 1999-2010 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef PACK_H 28 | #define PACK_H 29 | 30 | 31 | #include "mtypes.h" 32 | 33 | 34 | extern void 35 | _mesa_unpack_polygon_stipple(const GLubyte *pattern, GLuint dest[32], 36 | const struct gl_pixelstore_attrib *unpacking); 37 | 38 | 39 | extern void 40 | _mesa_pack_polygon_stipple(const GLuint pattern[32], GLubyte *dest, 41 | const struct gl_pixelstore_attrib *packing); 42 | 43 | 44 | extern void 45 | _mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source, 46 | GLubyte *dest, const struct gl_pixelstore_attrib *packing); 47 | 48 | 49 | extern void 50 | _mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n, 51 | GLenum dstType, GLvoid *dest, 52 | GLenum srcType, const GLvoid *source, 53 | const struct gl_pixelstore_attrib *srcPacking, 54 | GLbitfield transferOps); 55 | 56 | extern void 57 | _mesa_pack_stencil_span(struct gl_context *ctx, GLuint n, 58 | GLenum dstType, GLvoid *dest, const GLubyte *source, 59 | const struct gl_pixelstore_attrib *dstPacking); 60 | 61 | 62 | extern void 63 | _mesa_unpack_depth_span(struct gl_context *ctx, GLuint n, 64 | GLenum dstType, GLvoid *dest, GLuint depthMax, 65 | GLenum srcType, const GLvoid *source, 66 | const struct gl_pixelstore_attrib *srcPacking); 67 | 68 | extern void 69 | _mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest, 70 | GLenum dstType, const GLfloat *depthSpan, 71 | const struct gl_pixelstore_attrib *dstPacking); 72 | 73 | 74 | extern void 75 | _mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n, 76 | GLenum dstType, GLuint *dest, 77 | const GLfloat *depthVals, 78 | const GLubyte *stencilVals, 79 | const struct gl_pixelstore_attrib *dstPacking); 80 | 81 | 82 | extern void * 83 | _mesa_unpack_image(GLuint dimensions, 84 | GLsizei width, GLsizei height, GLsizei depth, 85 | GLenum format, GLenum type, const GLvoid *pixels, 86 | const struct gl_pixelstore_attrib *unpack); 87 | 88 | extern void 89 | _mesa_pack_luminance_from_rgba_float(GLuint n, GLfloat rgba[][4], 90 | GLvoid *dstAddr, GLenum dst_format, 91 | GLbitfield transferOps); 92 | 93 | extern void 94 | _mesa_pack_luminance_from_rgba_integer(GLuint n, GLuint rgba[][4], bool rgba_is_signed, 95 | GLvoid *dstAddr, GLenum dst_format, 96 | GLenum dst_type); 97 | 98 | extern GLfloat * 99 | _mesa_unpack_color_index_to_rgba_float(struct gl_context *ctx, GLuint dims, 100 | const void *src, GLenum srcFormat, GLenum srcType, 101 | int srcWidth, int srcHeight, int srcDepth, 102 | const struct gl_pixelstore_attrib *srcPacking, 103 | GLbitfield transferOps); 104 | 105 | extern GLubyte * 106 | _mesa_unpack_color_index_to_rgba_ubyte(struct gl_context *ctx, GLuint dims, 107 | const void *src, GLenum srcFormat, GLenum srcType, 108 | int srcWidth, int srcHeight, int srcDepth, 109 | const struct gl_pixelstore_attrib *srcPacking, 110 | GLbitfield transferOps); 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /src/pbo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009-2011 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef PBO_H 28 | #define PBO_H 29 | 30 | 31 | #include "mtypes.h" 32 | 33 | 34 | extern GLboolean 35 | _mesa_validate_pbo_access(GLuint dimensions, 36 | const struct gl_pixelstore_attrib *pack, 37 | GLsizei width, GLsizei height, GLsizei depth, 38 | GLenum format, GLenum type, GLsizei clientMemSize, 39 | const GLvoid *ptr); 40 | 41 | extern const GLvoid * 42 | _mesa_map_pbo_source(struct gl_context *ctx, 43 | const struct gl_pixelstore_attrib *unpack, 44 | const GLvoid *src); 45 | 46 | extern const GLvoid * 47 | _mesa_map_validate_pbo_source(struct gl_context *ctx, 48 | GLuint dimensions, 49 | const struct gl_pixelstore_attrib *unpack, 50 | GLsizei width, GLsizei height, GLsizei depth, 51 | GLenum format, GLenum type, GLsizei clientMemSize, 52 | const GLvoid *ptr, const char *where); 53 | 54 | extern void 55 | _mesa_unmap_pbo_source(struct gl_context *ctx, 56 | const struct gl_pixelstore_attrib *unpack); 57 | 58 | extern void * 59 | _mesa_map_pbo_dest(struct gl_context *ctx, 60 | const struct gl_pixelstore_attrib *pack, 61 | GLvoid *dest); 62 | 63 | extern GLvoid * 64 | _mesa_map_validate_pbo_dest(struct gl_context *ctx, 65 | GLuint dimensions, 66 | const struct gl_pixelstore_attrib *unpack, 67 | GLsizei width, GLsizei height, GLsizei depth, 68 | GLenum format, GLenum type, GLsizei clientMemSize, 69 | GLvoid *ptr, const char *where); 70 | 71 | extern void 72 | _mesa_unmap_pbo_dest(struct gl_context *ctx, 73 | const struct gl_pixelstore_attrib *pack); 74 | 75 | 76 | extern const GLvoid * 77 | _mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, 78 | GLsizei width, GLsizei height, GLsizei depth, 79 | GLenum format, GLenum type, const GLvoid *pixels, 80 | const struct gl_pixelstore_attrib *unpack, 81 | const char *funcName); 82 | 83 | extern const GLvoid * 84 | _mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, 85 | GLuint dimensions, GLsizei imageSize, 86 | const GLvoid *pixels, 87 | const struct gl_pixelstore_attrib *packing, 88 | const char *funcName); 89 | 90 | extern void 91 | _mesa_unmap_teximage_pbo(struct gl_context *ctx, 92 | const struct gl_pixelstore_attrib *unpack); 93 | 94 | 95 | extern bool 96 | _mesa_validate_pbo_source(struct gl_context *ctx, GLuint dimensions, 97 | const struct gl_pixelstore_attrib *unpack, 98 | GLsizei width, GLsizei height, GLsizei depth, 99 | GLenum format, GLenum type, 100 | GLsizei clientMemSize, 101 | const GLvoid *ptr, const char *where); 102 | 103 | extern bool 104 | _mesa_validate_pbo_source_compressed(struct gl_context *ctx, GLuint dimensions, 105 | const struct gl_pixelstore_attrib *unpack, 106 | GLsizei imageSize, const GLvoid *ptr, 107 | const char *where); 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /src/pixel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | /** 27 | * \file pixel.h 28 | * Pixel operations. 29 | */ 30 | 31 | 32 | #ifndef PIXEL_H 33 | #define PIXEL_H 34 | 35 | 36 | #include "glheader.h" 37 | 38 | struct gl_context; 39 | 40 | extern void 41 | _mesa_update_pixel( struct gl_context *ctx, GLuint newstate ); 42 | 43 | extern void 44 | _mesa_init_pixel( struct gl_context * ctx ); 45 | 46 | /*@}*/ 47 | 48 | #endif /* PIXEL_H */ 49 | -------------------------------------------------------------------------------- /src/pixelstore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * \file pixelstore.h 27 | * glPixelStore functions. 28 | */ 29 | 30 | 31 | #ifndef PIXELSTORE_H 32 | #define PIXELSTORE_H 33 | 34 | 35 | #include "glheader.h" 36 | 37 | struct gl_context; 38 | 39 | 40 | extern void 41 | _mesa_init_pixelstore( struct gl_context *ctx ); 42 | 43 | 44 | extern bool 45 | _mesa_compressed_pixel_storage_error_check( 46 | struct gl_context *ctx, 47 | GLint dimensions, 48 | const struct gl_pixelstore_attrib *packing, 49 | const char *caller); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/pixeltransfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009-2010 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef PIXELTRANSFER_H 28 | #define PIXELTRANSFER_H 29 | 30 | 31 | #include "mtypes.h" 32 | 33 | 34 | extern void 35 | _mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], 36 | GLfloat rScale, GLfloat gScale, 37 | GLfloat bScale, GLfloat aScale, 38 | GLfloat rBias, GLfloat gBias, 39 | GLfloat bBias, GLfloat aBias); 40 | 41 | extern void 42 | _mesa_map_rgba(const struct gl_context *ctx, GLuint n, GLfloat rgba[][4]); 43 | 44 | extern void 45 | _mesa_map_ci_to_rgba(const struct gl_context *ctx, 46 | GLuint n, const GLuint index[], GLfloat rgba[][4]); 47 | 48 | 49 | extern void 50 | _mesa_scale_and_bias_depth(const struct gl_context *ctx, GLuint n, 51 | GLfloat depthValues[]); 52 | 53 | extern void 54 | _mesa_scale_and_bias_depth_uint(const struct gl_context *ctx, GLuint n, 55 | GLuint depthValues[]); 56 | 57 | extern void 58 | _mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, 59 | GLuint n, GLfloat rgba[][4]); 60 | 61 | extern void 62 | _mesa_shift_and_offset_ci(const struct gl_context *ctx, 63 | GLuint n, GLuint indexes[]); 64 | 65 | extern void 66 | _mesa_apply_ci_transfer_ops(const struct gl_context *ctx, 67 | GLbitfield transferOps, 68 | GLuint n, GLuint indexes[]); 69 | 70 | 71 | extern void 72 | _mesa_apply_stencil_transfer_ops(const struct gl_context *ctx, GLuint n, 73 | GLubyte stencil[]); 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/polygon.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file polygon.c 3 | * Polygon operations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #include "glheader.h" 32 | #include "imports.h" 33 | #include "context.h" 34 | #include "image.h" 35 | #include "enums.h" 36 | #include "pack.h" 37 | #include "pbo.h" 38 | #include "polygon.h" 39 | #include "mtypes.h" 40 | 41 | /** 42 | * Specify whether to cull front- or back-facing facets. 43 | * 44 | * \param mode culling mode. 45 | * 46 | * \sa glCullFace(). 47 | * 48 | * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On 49 | * change, flushes the vertices and notifies the driver via 50 | * the dd_function_table::CullFace callback. 51 | */ 52 | void glCullFace( GLenum mode ) 53 | { 54 | GET_CURRENT_CONTEXT(ctx); 55 | 56 | if (MESA_VERBOSE&VERBOSE_API) 57 | _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); 58 | 59 | if (mode!=GL_FRONT && mode!=GL_BACK) { 60 | _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); 61 | return; 62 | } 63 | 64 | if (ctx->Polygon.CullFaceMode == mode) 65 | return; 66 | 67 | FLUSH_VERTICES(ctx, _NEW_POLYGON); 68 | ctx->Polygon.CullFaceMode = mode; 69 | 70 | if (ctx->Driver.CullFace) 71 | ctx->Driver.CullFace( ctx, mode ); 72 | } 73 | 74 | 75 | /** 76 | * Define front- and back-facing 77 | * 78 | * \param mode orientation of front-facing polygons. 79 | * 80 | * \sa glFrontFace(). 81 | * 82 | * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change 83 | * flushes the vertices and notifies the driver via 84 | * the dd_function_table::FrontFace callback. 85 | */ 86 | void glFrontFace( GLenum mode ) 87 | { 88 | GET_CURRENT_CONTEXT(ctx); 89 | 90 | if (MESA_VERBOSE&VERBOSE_API) 91 | _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); 92 | 93 | if (mode!=GL_CW && mode!=GL_CCW) { 94 | _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); 95 | return; 96 | } 97 | 98 | if (ctx->Polygon.FrontFace == mode) 99 | return; 100 | 101 | FLUSH_VERTICES(ctx, _NEW_POLYGON); 102 | ctx->Polygon.FrontFace = mode; 103 | 104 | if (ctx->Driver.FrontFace) 105 | ctx->Driver.FrontFace( ctx, mode ); 106 | } 107 | 108 | 109 | /** 110 | * Set the polygon rasterization mode. 111 | * 112 | * \param face the polygons which \p mode applies to. 113 | * \param mode how polygons should be rasterized. 114 | * 115 | * \sa glPolygonMode(). 116 | * 117 | * Verifies the parameters and updates gl_polygon_attrib::FrontMode and 118 | * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the 119 | * driver via the dd_function_table::PolygonMode callback. 120 | */ 121 | void glPolygonMode( GLenum face, GLenum mode ) 122 | { 123 | GET_CURRENT_CONTEXT(ctx); 124 | 125 | if (MESA_VERBOSE&VERBOSE_API) 126 | _mesa_debug(ctx, "glPolygonMode %s %s\n", 127 | _mesa_lookup_enum_by_nr(face), 128 | _mesa_lookup_enum_by_nr(mode)); 129 | 130 | // if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { 131 | // _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); 132 | // return; 133 | // } 134 | 135 | switch (face) { 136 | case GL_FRONT: 137 | if (ctx->Polygon.FrontMode == mode) 138 | return; 139 | FLUSH_VERTICES(ctx, _NEW_POLYGON); 140 | ctx->Polygon.FrontMode = mode; 141 | break; 142 | // case GL_FRONT_AND_BACK: 143 | // if (ctx->Polygon.FrontMode == mode && 144 | // ctx->Polygon.BackMode == mode) 145 | // return; 146 | // FLUSH_VERTICES(ctx, _NEW_POLYGON); 147 | // ctx->Polygon.FrontMode = mode; 148 | // ctx->Polygon.BackMode = mode; 149 | // break; 150 | case GL_BACK: 151 | if (ctx->Polygon.BackMode == mode) 152 | return; 153 | FLUSH_VERTICES(ctx, _NEW_POLYGON); 154 | ctx->Polygon.BackMode = mode; 155 | break; 156 | default: 157 | _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); 158 | return; 159 | } 160 | 161 | if (ctx->Driver.PolygonMode) 162 | ctx->Driver.PolygonMode(ctx, face, mode); 163 | } 164 | 165 | 166 | 167 | void 168 | _mesa_polygon_offset_clamp(struct gl_context *ctx, 169 | GLfloat factor, GLfloat units, GLfloat clamp) 170 | { 171 | if (ctx->Polygon.OffsetFactor == factor && 172 | ctx->Polygon.OffsetUnits == units && 173 | ctx->Polygon.OffsetClamp == clamp) 174 | return; 175 | 176 | FLUSH_VERTICES(ctx, _NEW_POLYGON); 177 | ctx->Polygon.OffsetFactor = factor; 178 | ctx->Polygon.OffsetUnits = units; 179 | ctx->Polygon.OffsetClamp = clamp; 180 | 181 | if (ctx->Driver.PolygonOffset) 182 | ctx->Driver.PolygonOffset( ctx, factor, units, clamp ); 183 | } 184 | 185 | void glPolygonOffset( GLfloat factor, GLfloat units ) 186 | { 187 | GET_CURRENT_CONTEXT(ctx); 188 | 189 | if (MESA_VERBOSE&VERBOSE_API) 190 | _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); 191 | 192 | _mesa_polygon_offset_clamp(ctx, factor, units, 0.0); 193 | } 194 | 195 | 196 | 197 | /**********************************************************************/ 198 | /** \name Initialization */ 199 | /*@{*/ 200 | 201 | /** 202 | * Initialize the context polygon state. 203 | * 204 | * \param ctx GL context. 205 | * 206 | * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple 207 | * attribute groups. 208 | */ 209 | void _mesa_init_polygon( struct gl_context * ctx ) 210 | { 211 | /* Polygon group */ 212 | ctx->Polygon.CullFlag = GL_FALSE; 213 | ctx->Polygon.CullFaceMode = GL_BACK; 214 | ctx->Polygon.FrontFace = GL_CCW; 215 | ctx->Polygon._FrontBit = 0; 216 | // ctx->Polygon.FrontMode = GL_FILL; 217 | // ctx->Polygon.BackMode = GL_FILL; 218 | ctx->Polygon.SmoothFlag = GL_FALSE; 219 | ctx->Polygon.StippleFlag = GL_FALSE; 220 | ctx->Polygon.OffsetFactor = 0.0F; 221 | ctx->Polygon.OffsetUnits = 0.0F; 222 | ctx->Polygon.OffsetClamp = 0.0F; 223 | ctx->Polygon.OffsetPoint = GL_FALSE; 224 | ctx->Polygon.OffsetLine = GL_FALSE; 225 | ctx->Polygon.OffsetFill = GL_FALSE; 226 | 227 | 228 | /* Polygon Stipple group */ 229 | // memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); 230 | } 231 | 232 | 233 | void _gl3ds_update_polygon(struct gl_context *ctx) { 234 | if (ctx->Polygon.CullFlag) 235 | GPUCMD_AddSingleParam(0x000F0040, 2 - (ctx->Polygon.CullFaceMode ^ ctx->Polygon.FrontFace)); 236 | else 237 | GPUCMD_AddSingleParam(0x000F0040, 0); 238 | } 239 | 240 | /*@}*/ 241 | -------------------------------------------------------------------------------- /src/polygon.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file polygon.h 3 | * Polygon operations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef GL3DS_POLYGON_H 32 | #define GL3DS_POLYGON_H 33 | 34 | #include "glheader.h" 35 | 36 | struct gl_context; 37 | 38 | extern void 39 | _mesa_polygon_offset_clamp(struct gl_context *ctx, 40 | GLfloat factor, GLfloat units, GLfloat clamp); 41 | 42 | extern void 43 | _mesa_init_polygon( struct gl_context * ctx ); 44 | 45 | void _gl3ds_update_polygon(struct gl_context *ctx); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/readpix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef READPIXELS_H 27 | #define READPIXELS_H 28 | 29 | 30 | #include "glheader.h" 31 | 32 | struct gl_context; 33 | struct gl_pixelstore_attrib; 34 | 35 | 36 | extern GLboolean 37 | _mesa_readpixels_needs_slow_path(const struct gl_context *ctx, GLenum format, 38 | GLenum type, GLboolean uses_blit); 39 | 40 | extern void 41 | _mesa_readpixels(struct gl_context *ctx, 42 | GLint x, GLint y, GLsizei width, GLsizei height, 43 | GLenum format, GLenum type, 44 | const struct gl_pixelstore_attrib *packing, 45 | GLvoid *pixels); 46 | 47 | void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, 48 | GLenum format, GLenum type, GLvoid *pixels ); 49 | 50 | void glReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, 51 | GLenum format, GLenum type, GLsizei bufSize, 52 | GLvoid *pixels ); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/renderbuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #include "glheader.h" 27 | #include "imports.h" 28 | #include "context.h" 29 | #include "fbobject.h" 30 | #include "formats.h" 31 | #include "mtypes.h" 32 | #include "renderbuffer.h" 33 | 34 | 35 | /** 36 | * Initialize the fields of a gl_renderbuffer to default values. 37 | */ 38 | void 39 | _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) 40 | { 41 | GET_CURRENT_CONTEXT(ctx); 42 | 43 | mtx_init(&rb->Mutex, mtx_plain); 44 | 45 | rb->ClassID = 0; 46 | rb->Name = name; 47 | rb->RefCount = 0; 48 | rb->Delete = _mesa_delete_renderbuffer; 49 | 50 | /* The rest of these should be set later by the caller of this function or 51 | * the AllocStorage method: 52 | */ 53 | rb->AllocStorage = NULL; 54 | 55 | rb->Width = 0; 56 | rb->Height = 0; 57 | rb->Depth = 0; 58 | 59 | /* In GL 3, the initial format is GL_RGBA according to Table 6.26 60 | * on page 302 of the GL 3.3 spec. 61 | * 62 | * In GLES 3, the initial format is GL_RGBA4 according to Table 6.15 63 | * on page 258 of the GLES 3.0.4 spec. 64 | * 65 | * If the context is current, set the initial format based on the 66 | * specs. If the context is not current, we cannot determine the 67 | * API, so default to GL_RGBA. 68 | */ 69 | // if (ctx && _mesa_is_gles3(ctx)) { 70 | // rb->InternalFormat = GL_RGBA4; 71 | // } else { 72 | rb->InternalFormat = GL_RGBA; 73 | // } 74 | 75 | rb->Format = MESA_FORMAT_NONE; 76 | } 77 | 78 | 79 | /** 80 | * Allocate a new gl_renderbuffer object. This can be used for user-created 81 | * renderbuffers or window-system renderbuffers. 82 | */ 83 | struct gl_renderbuffer * 84 | _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) 85 | { 86 | struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); 87 | if (rb) { 88 | _mesa_init_renderbuffer(rb, name); 89 | } 90 | return rb; 91 | } 92 | 93 | 94 | /** 95 | * Delete a gl_framebuffer. 96 | * This is the default function for renderbuffer->Delete(). 97 | * Drivers which subclass gl_renderbuffer should probably implement their 98 | * own delete function. But the driver might also call this function to 99 | * free the object in the end. 100 | */ 101 | void 102 | _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) 103 | { 104 | mtx_destroy(&rb->Mutex); 105 | free(rb->Label); 106 | free(rb); 107 | } 108 | 109 | 110 | /** 111 | * Attach a renderbuffer to a framebuffer. 112 | * \param bufferName one of the BUFFER_x tokens 113 | */ 114 | void 115 | _mesa_add_renderbuffer(struct gl_framebuffer *fb, 116 | gl_buffer_index bufferName, struct gl_renderbuffer *rb) 117 | { 118 | assert(fb); 119 | assert(rb); 120 | assert(bufferName < BUFFER_COUNT); 121 | 122 | /* There should be no previous renderbuffer on this attachment point, 123 | * with the exception of depth/stencil since the same renderbuffer may 124 | * be used for both. 125 | */ 126 | assert(bufferName == BUFFER_DEPTH || 127 | bufferName == BUFFER_STENCIL || 128 | fb->Attachment[bufferName].Renderbuffer == NULL); 129 | 130 | /* winsys vs. user-created buffer cross check */ 131 | if (_mesa_is_user_fbo(fb)) { 132 | assert(rb->Name); 133 | } 134 | else { 135 | assert(!rb->Name); 136 | } 137 | 138 | fb->Attachment[bufferName].Type = GL_RENDERBUFFER; 139 | fb->Attachment[bufferName].Complete = GL_TRUE; 140 | _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); 141 | } 142 | 143 | 144 | /** 145 | * Remove the named renderbuffer from the given framebuffer. 146 | * \param bufferName one of the BUFFER_x tokens 147 | */ 148 | void 149 | _mesa_remove_renderbuffer(struct gl_framebuffer *fb, 150 | gl_buffer_index bufferName) 151 | { 152 | assert(bufferName < BUFFER_COUNT); 153 | _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, 154 | NULL); 155 | } 156 | 157 | 158 | /** 159 | * Set *ptr to point to rb. If *ptr points to another renderbuffer, 160 | * dereference that buffer first. The new renderbuffer's refcount will 161 | * be incremented. The old renderbuffer's refcount will be decremented. 162 | * This is normally only called from the _mesa_reference_renderbuffer() macro 163 | * when there's a real pointer change. 164 | */ 165 | void 166 | _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, 167 | struct gl_renderbuffer *rb) 168 | { 169 | if (*ptr) { 170 | /* Unreference the old renderbuffer */ 171 | GLboolean deleteFlag = GL_FALSE; 172 | struct gl_renderbuffer *oldRb = *ptr; 173 | 174 | mtx_lock(&oldRb->Mutex); 175 | assert(oldRb->RefCount > 0); 176 | oldRb->RefCount--; 177 | /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ 178 | deleteFlag = (oldRb->RefCount == 0); 179 | mtx_unlock(&oldRb->Mutex); 180 | 181 | if (deleteFlag) { 182 | GET_CURRENT_CONTEXT(ctx); 183 | oldRb->Delete(ctx, oldRb); 184 | } 185 | 186 | *ptr = NULL; 187 | } 188 | assert(!*ptr); 189 | 190 | if (rb) { 191 | /* reference new renderbuffer */ 192 | mtx_lock(&rb->Mutex); 193 | rb->RefCount++; 194 | /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ 195 | mtx_unlock(&rb->Mutex); 196 | *ptr = rb; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /src/renderbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef RENDERBUFFER_H 27 | #define RENDERBUFFER_H 28 | 29 | #include "glheader.h" 30 | #include "mtypes.h" 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | struct gl_context; 37 | struct gl_framebuffer; 38 | struct gl_renderbuffer; 39 | 40 | extern void 41 | _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); 42 | 43 | extern struct gl_renderbuffer * 44 | _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name); 45 | 46 | extern void 47 | _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb); 48 | 49 | extern void 50 | _mesa_add_renderbuffer(struct gl_framebuffer *fb, 51 | gl_buffer_index bufferName, struct gl_renderbuffer *rb); 52 | 53 | extern void 54 | _mesa_remove_renderbuffer(struct gl_framebuffer *fb, 55 | gl_buffer_index bufferName); 56 | 57 | extern void 58 | _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, 59 | struct gl_renderbuffer *rb); 60 | 61 | static inline void 62 | _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, 63 | struct gl_renderbuffer *rb) 64 | { 65 | if (*ptr != rb) 66 | _mesa_reference_renderbuffer_(ptr, rb); 67 | } 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* RENDERBUFFER_H */ 74 | -------------------------------------------------------------------------------- /src/samplerobj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2011 VMware, Inc. All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | 27 | #ifndef SAMPLEROBJ_H 28 | #define SAMPLEROBJ_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | 35 | #include "mtypes.h" 36 | 37 | 38 | struct dd_function_table; 39 | 40 | static inline struct gl_sampler_object * 41 | _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit) 42 | { 43 | if (ctx->Texture.Unit[unit].Sampler) 44 | return ctx->Texture.Unit[unit].Sampler; 45 | else if (ctx->Texture.Unit[unit]._Current) 46 | return &ctx->Texture.Unit[unit]._Current->Sampler; 47 | else 48 | return NULL; 49 | } 50 | 51 | 52 | /** Does the given filter state do mipmap filtering? */ 53 | static inline GLboolean 54 | _mesa_is_mipmap_filter(const struct gl_sampler_object *samp) 55 | { 56 | return samp->MinFilter != GL_NEAREST && samp->MinFilter != GL_LINEAR; 57 | } 58 | 59 | 60 | extern void 61 | _mesa_reference_sampler_object_(struct gl_context *ctx, 62 | struct gl_sampler_object **ptr, 63 | struct gl_sampler_object *samp); 64 | 65 | static inline void 66 | _mesa_reference_sampler_object(struct gl_context *ctx, 67 | struct gl_sampler_object **ptr, 68 | struct gl_sampler_object *samp) 69 | { 70 | if (*ptr != samp) 71 | _mesa_reference_sampler_object_(ctx, ptr, samp); 72 | } 73 | 74 | extern struct gl_sampler_object * 75 | _mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name); 76 | 77 | extern struct gl_sampler_object * 78 | _mesa_new_sampler_object(struct gl_context *ctx, GLuint name); 79 | 80 | extern void 81 | _mesa_init_sampler_object_functions(struct dd_function_table *driver); 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* SAMPLEROBJ_H */ 88 | -------------------------------------------------------------------------------- /src/scissor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef GL3DS_SCISSOR_H 27 | #define GL3DS_SCISSOR_H 28 | 29 | #include "glheader.h" 30 | 31 | extern void 32 | _mesa_set_scissor(struct gl_context *ctx, unsigned idx, 33 | GLint x, GLint y, GLsizei width, GLsizei height); 34 | 35 | extern void 36 | _mesa_init_scissor(struct gl_context *ctx); 37 | 38 | void _gl3ds_update_scissor(struct gl_context *ctx); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/shader.c: -------------------------------------------------------------------------------- 1 | #include "glheader.h" 2 | #include "context.h" 3 | 4 | 5 | GLuint glCreateShader(GLenum shaderType) 6 | { 7 | return (GLuint) malloc(sizeof(shaderInstance_s)); 8 | } 9 | 10 | void glAttachShader(GLuint program, GLuint shader) 11 | { 12 | // Not implemented 13 | } 14 | 15 | 16 | GLuint glCreateProgram(void) 17 | { 18 | // TODO: store in shared context hash, return hash value 19 | shaderProgram_s* prog = (shaderProgram_s*) malloc(sizeof(shaderProgram_s)); 20 | shaderProgramInit(prog); 21 | return (GLuint) prog; 22 | } 23 | 24 | 25 | void glDeleteProgram(GLuint program) 26 | { 27 | shaderProgram_s* prog = (shaderProgram_s*) program; 28 | 29 | if (prog == NULL) 30 | return; 31 | 32 | GET_CURRENT_CONTEXT(ctx); 33 | if (ctx->Shared->Shader->Program == prog) 34 | ctx->Shared->Shader->Program = NULL; 35 | 36 | free(prog); 37 | } 38 | 39 | void glUseProgram(GLuint program) { 40 | // TODO: unset program when 0? 41 | if (program == 0) 42 | return; 43 | 44 | GET_CURRENT_CONTEXT(ctx); 45 | 46 | shaderProgram_s* prog = (shaderProgram_s*) program; 47 | 48 | if (ctx->Shared->Shader->Program == prog) 49 | return; 50 | 51 | ctx->Shared->Shader->Program = prog; 52 | 53 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); 54 | } 55 | 56 | 57 | void glProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) 58 | { 59 | GET_CURRENT_CONTEXT(ctx); 60 | 61 | // set GL_PROGRAM_BINARY_FORMATS enum 62 | shaderProgram_s* prog = (shaderProgram_s*) program; 63 | DVLB_s* dvlb; 64 | 65 | if (binaryFormat & GL_VERTEX_SHADER_BINARY) 66 | { 67 | dvlb = DVLB_ParseFile((u32*)binary, length); 68 | shaderProgramSetVsh(prog, &dvlb->DVLE[0]); 69 | } 70 | else if (binaryFormat & GL_GEOMETRY_SHADER_BINARY) 71 | { 72 | dvlb = DVLB_ParseFile((u32*)binary, length); 73 | shaderProgramSetGsh(prog, &dvlb->DVLE[0], 1); // TODO: figure out geometry stride 74 | } 75 | } 76 | 77 | void _mesa_init_program(struct gl_context *ctx) 78 | { 79 | ctx->Shared->Shader = CALLOC_STRUCT(gl_shader_program); 80 | } 81 | 82 | void _mesa_free_program_data(struct gl_context *ctx) 83 | { 84 | if (ctx->Shared->Shader->Program) 85 | shaderProgramFree(ctx->Shared->Shader->Program); 86 | 87 | int i; 88 | for (i = 0; i < ctx->Shared->Shader->UniformCount; i++) { 89 | free(ctx->Shared->Shader->UniformVals[i].value); 90 | } 91 | 92 | free(ctx->Shared->Shader); 93 | } 94 | 95 | static void upload_program(struct gl_context *ctx) 96 | { 97 | 98 | } 99 | 100 | #define GET_VSH_UNIFORM(name) (GLint) shaderInstanceGetUniformLocation(ctx->Shared->Shader->Program->vertexShader, name) 101 | 102 | void _gl3ds_update_program(struct gl_context *ctx) 103 | { 104 | if (ctx->Shared->Shader->Program) 105 | { 106 | shaderProgramUse(ctx->Shared->Shader->Program); 107 | 108 | // TODO: something better than forcing usage of these uniforms? 109 | ctx->Shared->Shader->ProjectionUniform = GET_VSH_UNIFORM("projection"); 110 | ctx->Shared->Shader->ModelviewUniform = GET_VSH_UNIFORM("modelview"); 111 | ctx->Shared->Shader->TextureUniform = GET_VSH_UNIFORM("texture"); 112 | 113 | int i; 114 | for (i = 0; i < ctx->Shared->Shader->UniformCount; i++) { 115 | struct gl_shader_uniform* uniform = &ctx->Shared->Shader->UniformVals[i]; 116 | if (uniform->changed) { 117 | GPU_SetFloatUniform(GPU_VERTEX_SHADER, uniform->location, (u32*) uniform->value, uniform->count); 118 | uniform->changed = false; 119 | } 120 | } 121 | if (!ctx->Shared->Shader->Uploaded) { 122 | ctx->Shared->Shader->Uploaded = GL_TRUE; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/shader.h: -------------------------------------------------------------------------------- 1 | #ifndef GL3DS_SHADER 2 | #define GL3DS_SHADER 3 | 4 | struct gl_context; 5 | 6 | void _gl3ds_update_program(struct gl_context *ctx); 7 | void _mesa_init_program(struct gl_context *ctx); 8 | void _mesa_free_program_data(struct gl_context *ctx); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef SHARED_H 26 | #define SHARED_H 27 | 28 | struct gl_context; 29 | 30 | void 31 | _mesa_reference_shared_state(struct gl_context *ctx, 32 | struct gl_shared_state **ptr, 33 | struct gl_shared_state *state); 34 | 35 | 36 | struct gl_shared_state * 37 | _mesa_alloc_shared_state(struct gl_context *ctx); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef STATE_H 27 | #define STATE_H 28 | 29 | #include "mtypes.h" 30 | 31 | extern void 32 | _mesa_update_state(struct gl_context *ctx); 33 | 34 | /* As above but can only be called between _mesa_lock_context_textures() and 35 | * _mesa_unlock_context_textures(). 36 | */ 37 | extern void 38 | _mesa_update_state_locked(struct gl_context *ctx); 39 | 40 | 41 | extern void 42 | _mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield64 varying_inputs); 43 | 44 | 45 | extern void 46 | _mesa_set_vp_override(struct gl_context *ctx, GLboolean flag); 47 | 48 | 49 | /** 50 | * Is the secondary color needed? 51 | */ 52 | static inline GLboolean 53 | _mesa_need_secondary_color(const struct gl_context *ctx) 54 | { 55 | // if (ctx->Light.Enabled && 56 | // ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) 57 | // return GL_TRUE; 58 | // 59 | // if (ctx->Fog.ColorSumEnabled) 60 | // return GL_TRUE; 61 | // 62 | // if (ctx->VertexProgram._Current && 63 | // (ctx->VertexProgram._Current != ctx->VertexProgram._TnlProgram) && 64 | // (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) 65 | // return GL_TRUE; 66 | // 67 | // if (ctx->FragmentProgram._Current && 68 | // (ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram) && 69 | // (ctx->FragmentProgram._Current->Base.InputsRead & VARYING_BIT_COL1)) 70 | // return GL_TRUE; 71 | 72 | return GL_FALSE; 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/stencil.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file stencil.h 3 | * Stencil operations. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | #ifndef GL3DS_STENCIL_H 31 | #define GL3DS_STENCIL_H 32 | 33 | #include "glheader.h" 34 | #include "macros.h" 35 | 36 | struct gl_context; 37 | 38 | void _mesa_update_stencil(struct gl_context *ctx); 39 | void _mesa_init_stencil( struct gl_context * ctx ); 40 | 41 | /* From the GL 4.3 spec, 17.3.5: 42 | * "Stencil comparison operations and queries of clamp its value 43 | * to the range [0, 2^s-1], where is the number of bits in the 44 | * stencil buffer attached to the draw framebuffer." 45 | */ 46 | 47 | static inline GLint 48 | _mesa_get_stencil_ref(struct gl_context const *ctx, int face) 49 | { 50 | GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; 51 | GLint ref = ctx->Stencil.Ref[face]; 52 | return CLAMP(ref, 0, stencilMax); 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /src/texcompress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef TEXCOMPRESS_H 26 | #define TEXCOMPRESS_H 27 | 28 | #include "formats.h" 29 | #include "glheader.h" 30 | 31 | struct gl_context; 32 | 33 | extern GLenum 34 | _mesa_gl_compressed_format_base_format(GLenum format); 35 | 36 | extern GLuint 37 | _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats); 38 | 39 | extern mesa_format 40 | _mesa_glenum_to_compressed_format(GLenum format); 41 | 42 | extern GLenum 43 | _mesa_compressed_format_to_glenum(struct gl_context *ctx, mesa_format mesaFormat); 44 | 45 | extern GLubyte * 46 | _mesa_compressed_image_address(GLint col, GLint row, GLint img, 47 | mesa_format mesaFormat, 48 | GLsizei width, const GLubyte *image); 49 | 50 | 51 | /** A function to fetch one texel from a compressed texture */ 52 | typedef void (*compressed_fetch_func)(const GLubyte *map, 53 | GLint rowStride, 54 | GLint i, GLint j, 55 | GLfloat *texel); 56 | 57 | extern compressed_fetch_func 58 | _mesa_get_compressed_fetch_func(mesa_format format); 59 | 60 | 61 | extern void 62 | _mesa_decompress_image(mesa_format format, GLuint width, GLuint height, 63 | const GLubyte *src, GLint srcRowStride, 64 | GLfloat *dest); 65 | 66 | #endif /* TEXCOMPRESS_H */ 67 | -------------------------------------------------------------------------------- /src/texcompress_etc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 LunarG, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice (including the next 12 | * paragraph) shall be included in all copies or substantial portions of the 13 | * Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef TEXCOMPRESS_ETC1_H 25 | #define TEXCOMPRESS_ETC1_H 26 | 27 | #include 28 | #include "glheader.h" 29 | #include "texcompress.h" 30 | #include "texstore.h" 31 | 32 | 33 | GLboolean 34 | _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS); 35 | 36 | GLboolean 37 | _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS); 38 | 39 | GLboolean 40 | _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS); 41 | 42 | GLboolean 43 | _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS); 44 | 45 | GLboolean 46 | _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS); 47 | 48 | GLboolean 49 | _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS); 50 | 51 | GLboolean 52 | _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS); 53 | 54 | GLboolean 55 | _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS); 56 | 57 | GLboolean 58 | _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS); 59 | 60 | GLboolean 61 | _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS); 62 | 63 | GLboolean 64 | _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS); 65 | 66 | void 67 | _mesa_etc1_unpack_rgba8888(uint8_t *dst_row, 68 | unsigned dst_stride, 69 | const uint8_t *src_row, 70 | unsigned src_stride, 71 | unsigned src_width, 72 | unsigned src_height); 73 | void 74 | _mesa_unpack_etc2_format(uint8_t *dst_row, 75 | unsigned dst_stride, 76 | const uint8_t *src_row, 77 | unsigned src_stride, 78 | unsigned src_width, 79 | unsigned src_height, 80 | mesa_format format); 81 | 82 | compressed_fetch_func 83 | _mesa_get_etc_fetch_func(mesa_format format); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/texcompress_etc_tmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 LunarG, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice (including the next 12 | * paragraph) shall be included in all copies or substantial portions of the 13 | * Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | /* 25 | * Included by texcompress_etc1 and gallium to define ETC1 decoding routines. 26 | */ 27 | 28 | struct TAG(etc1_block) { 29 | uint32_t pixel_indices; 30 | int flipped; 31 | const int *modifier_tables[2]; 32 | UINT8_TYPE base_colors[2][3]; 33 | }; 34 | 35 | static UINT8_TYPE 36 | TAG(etc1_base_color_diff_hi)(UINT8_TYPE in) 37 | { 38 | return (in & 0xf8) | (in >> 5); 39 | } 40 | 41 | static UINT8_TYPE 42 | TAG(etc1_base_color_diff_lo)(UINT8_TYPE in) 43 | { 44 | static const int lookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 }; 45 | 46 | in = (in >> 3) + lookup[in & 0x7]; 47 | 48 | return (in << 3) | (in >> 2); 49 | } 50 | 51 | static UINT8_TYPE 52 | TAG(etc1_base_color_ind_hi)(UINT8_TYPE in) 53 | { 54 | return (in & 0xf0) | ((in & 0xf0) >> 4); 55 | } 56 | 57 | static UINT8_TYPE 58 | TAG(etc1_base_color_ind_lo)(UINT8_TYPE in) 59 | { 60 | return ((in & 0xf) << 4) | (in & 0xf); 61 | } 62 | 63 | static UINT8_TYPE 64 | TAG(etc1_clamp)(UINT8_TYPE base, int modifier) 65 | { 66 | int tmp = (int) base + modifier; 67 | 68 | /* CLAMP(tmp, 0, 255) */ 69 | return (UINT8_TYPE) ((tmp < 0) ? 0 : ((tmp > 255) ? 255 : tmp)); 70 | } 71 | 72 | static const int TAG(etc1_modifier_tables)[8][4] = { 73 | { 2, 8, -2, -8}, 74 | { 5, 17, -5, -17}, 75 | { 9, 29, -9, -29}, 76 | { 13, 42, -13, -42}, 77 | { 18, 60, -18, -60}, 78 | { 24, 80, -24, -80}, 79 | { 33, 106, -33, -106}, 80 | { 47, 183, -47, -183} 81 | }; 82 | 83 | static void 84 | TAG(etc1_parse_block)(struct TAG(etc1_block) *block, const UINT8_TYPE *src) 85 | { 86 | if (src[3] & 0x2) { 87 | /* differential mode */ 88 | block->base_colors[0][0] = (int) TAG(etc1_base_color_diff_hi)(src[0]); 89 | block->base_colors[1][0] = (int) TAG(etc1_base_color_diff_lo)(src[0]); 90 | block->base_colors[0][1] = (int) TAG(etc1_base_color_diff_hi)(src[1]); 91 | block->base_colors[1][1] = (int) TAG(etc1_base_color_diff_lo)(src[1]); 92 | block->base_colors[0][2] = (int) TAG(etc1_base_color_diff_hi)(src[2]); 93 | block->base_colors[1][2] = (int) TAG(etc1_base_color_diff_lo)(src[2]); 94 | } 95 | else { 96 | /* individual mode */ 97 | block->base_colors[0][0] = (int) TAG(etc1_base_color_ind_hi)(src[0]); 98 | block->base_colors[1][0] = (int) TAG(etc1_base_color_ind_lo)(src[0]); 99 | block->base_colors[0][1] = (int) TAG(etc1_base_color_ind_hi)(src[1]); 100 | block->base_colors[1][1] = (int) TAG(etc1_base_color_ind_lo)(src[1]); 101 | block->base_colors[0][2] = (int) TAG(etc1_base_color_ind_hi)(src[2]); 102 | block->base_colors[1][2] = (int) TAG(etc1_base_color_ind_lo)(src[2]); 103 | } 104 | 105 | /* pick modifier tables */ 106 | block->modifier_tables[0] = TAG(etc1_modifier_tables)[(src[3] >> 5) & 0x7]; 107 | block->modifier_tables[1] = TAG(etc1_modifier_tables)[(src[3] >> 2) & 0x7]; 108 | 109 | block->flipped = (src[3] & 0x1); 110 | 111 | block->pixel_indices = 112 | (src[4] << 24) | (src[5] << 16) | (src[6] << 8) | src[7]; 113 | } 114 | 115 | static void 116 | TAG(etc1_fetch_texel)(const struct TAG(etc1_block) *block, 117 | int x, int y, UINT8_TYPE *dst) 118 | { 119 | const UINT8_TYPE *base_color; 120 | int modifier, bit, idx, blk; 121 | 122 | /* get pixel index */ 123 | bit = y + x * 4; 124 | idx = ((block->pixel_indices >> (15 + bit)) & 0x2) | 125 | ((block->pixel_indices >> (bit)) & 0x1); 126 | 127 | /* get subblock */ 128 | blk = (block->flipped) ? (y >= 2) : (x >= 2); 129 | 130 | base_color = block->base_colors[blk]; 131 | modifier = block->modifier_tables[blk][idx]; 132 | 133 | dst[0] = TAG(etc1_clamp)(base_color[0], modifier); 134 | dst[1] = TAG(etc1_clamp)(base_color[1], modifier); 135 | dst[2] = TAG(etc1_clamp)(base_color[2], modifier); 136 | } 137 | 138 | static void 139 | etc1_unpack_rgba8888(uint8_t *dst_row, 140 | unsigned dst_stride, 141 | const uint8_t *src_row, 142 | unsigned src_stride, 143 | unsigned width, 144 | unsigned height) 145 | { 146 | const unsigned bw = 4, bh = 4, bs = 8, comps = 4; 147 | struct etc1_block block; 148 | unsigned x, y, i, j; 149 | 150 | for (y = 0; y < height; y += bh) { 151 | const uint8_t *src = src_row; 152 | 153 | for (x = 0; x < width; x+= bw) { 154 | etc1_parse_block(&block, src); 155 | 156 | for (j = 0; j < MIN2(bh, height - y); j++) { 157 | uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; 158 | for (i = 0; i < MIN2(bw, width - x); i++) { 159 | etc1_fetch_texel(&block, i, j, dst); 160 | dst[3] = 255; 161 | dst += comps; 162 | } 163 | } 164 | 165 | src += bs; 166 | } 167 | 168 | src_row += src_stride; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/texenv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef TEXENV_H 27 | #define TEXENV_H 28 | 29 | 30 | #include "glheader.h" 31 | 32 | 33 | #endif /* TEXENV_H */ 34 | -------------------------------------------------------------------------------- /src/texformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (c) 2008-2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef TEXFORMAT_H 27 | #define TEXFORMAT_H 28 | 29 | 30 | #include "formats.h" 31 | 32 | struct gl_context; 33 | 34 | extern mesa_format 35 | _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, 36 | GLint internalFormat, GLenum format, GLenum type); 37 | 38 | extern GLboolean 39 | _mesa_tex_target_is_array(GLenum target); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/texgetimage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (c) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef TEXGETIMAGE_H 28 | #define TEXGETIMAGE_H 29 | 30 | #include "glheader.h" 31 | 32 | struct gl_context; 33 | struct gl_texture_image; 34 | struct gl_texture_object; 35 | 36 | extern GLenum 37 | _mesa_base_pack_format(GLenum format); 38 | 39 | extern void 40 | _mesa_GetTexImage_sw(struct gl_context *ctx, 41 | GLenum format, GLenum type, GLvoid *pixels, 42 | struct gl_texture_image *texImage); 43 | 44 | 45 | extern void 46 | _mesa_GetCompressedTexImage_sw(struct gl_context *ctx, 47 | struct gl_texture_image *texImage, 48 | GLvoid *data); 49 | 50 | extern void 51 | _mesa_get_texture_image(struct gl_context *ctx, 52 | struct gl_texture_object *texObj, 53 | struct gl_texture_image *texImage, GLenum target, 54 | GLint level, GLenum format, GLenum type, 55 | GLsizei bufSize, GLvoid *pixels, bool dsa); 56 | 57 | extern void 58 | _mesa_get_compressed_texture_image( struct gl_context *ctx, 59 | struct gl_texture_object *texObj, 60 | struct gl_texture_image *texImage, 61 | GLenum target, GLint level, 62 | GLsizei bufSize, GLvoid *pixels, 63 | bool dsa ); 64 | 65 | 66 | #endif /* TEXGETIMAGE_H */ 67 | -------------------------------------------------------------------------------- /src/texobj.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file texobj.h 3 | * Texture object management. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef TEXTOBJ_H 32 | #define TEXTOBJ_H 33 | 34 | 35 | #include "compiler.h" 36 | #include "glheader.h" 37 | #include "mtypes.h" 38 | #include "samplerobj.h" 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /** 47 | * \name Internal functions 48 | */ 49 | /*@{*/ 50 | 51 | extern struct gl_texture_object * 52 | _mesa_lookup_texture(struct gl_context *ctx, GLuint id); 53 | 54 | extern struct gl_texture_object * 55 | _mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* func); 56 | 57 | extern void 58 | _mesa_begin_texture_lookups(struct gl_context *ctx); 59 | 60 | extern void 61 | _mesa_end_texture_lookups(struct gl_context *ctx); 62 | 63 | extern struct gl_texture_object * 64 | _mesa_lookup_texture_locked(struct gl_context *ctx, GLuint id); 65 | 66 | extern struct gl_texture_object * 67 | _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target); 68 | 69 | extern struct gl_texture_object * 70 | _mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ); 71 | 72 | extern void 73 | _mesa_initialize_texture_object( struct gl_context *ctx, 74 | struct gl_texture_object *obj, 75 | GLuint name, GLenum target ); 76 | 77 | extern int 78 | _mesa_tex_target_to_index(const struct gl_context *ctx, GLenum target); 79 | 80 | extern void 81 | _mesa_delete_texture_object( struct gl_context *ctx, 82 | struct gl_texture_object *obj ); 83 | 84 | extern void 85 | _mesa_copy_texture_object( struct gl_texture_object *dest, 86 | const struct gl_texture_object *src ); 87 | 88 | extern void 89 | _mesa_clear_texture_object(struct gl_context *ctx, 90 | struct gl_texture_object *obj); 91 | 92 | extern void 93 | _mesa_reference_texobj_(struct gl_texture_object **ptr, 94 | struct gl_texture_object *tex); 95 | 96 | static inline void 97 | _mesa_reference_texobj(struct gl_texture_object **ptr, 98 | struct gl_texture_object *tex) 99 | { 100 | if (*ptr != tex) 101 | _mesa_reference_texobj_(ptr, tex); 102 | } 103 | 104 | /** 105 | * Lock a texture for updating. See also _mesa_lock_context_textures(). 106 | */ 107 | static inline void 108 | _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) 109 | { 110 | // mtx_lock(&ctx->Shared->TexMutex); 111 | // ctx->Shared->TextureStateStamp++; 112 | (void) texObj; 113 | } 114 | 115 | static inline void 116 | _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) 117 | { 118 | (void) texObj; 119 | // mtx_unlock(&ctx->Shared->TexMutex); 120 | } 121 | 122 | 123 | /** 124 | * Return number of faces for a texture target. This will be 6 for 125 | * cube maps (and cube map arrays) and 1 otherwise. 126 | * NOTE: this function is not used for cube map arrays which operate 127 | * more like 2D arrays than cube maps. 128 | */ 129 | static inline GLuint 130 | _mesa_num_tex_faces(GLenum target) 131 | { 132 | switch (target) { 133 | // case GL_TEXTURE_CUBE_MAP: 134 | // case GL_PROXY_TEXTURE_CUBE_MAP: 135 | // return 6; 136 | default: 137 | return 1; 138 | } 139 | } 140 | 141 | 142 | /** Is the texture "complete" with respect to the given sampler state? */ 143 | static inline GLboolean 144 | _mesa_is_texture_complete(const struct gl_texture_object *texObj, 145 | const struct gl_sampler_object *sampler) 146 | { 147 | if (texObj->_IsIntegerFormat && 148 | (sampler->MagFilter != GL_NEAREST || 149 | (sampler->MinFilter != GL_NEAREST && 150 | sampler->MinFilter != GL_NEAREST_MIPMAP_NEAREST))) { 151 | /* If the format is integer, only nearest filtering is allowed */ 152 | return GL_FALSE; 153 | } 154 | 155 | /* From the ARB_stencil_texturing specification: 156 | * "Add a new bullet point for the conditions that cause the texture 157 | * to not be complete: 158 | * 159 | * * The internal format of the texture is DEPTH_STENCIL, the 160 | * DEPTH_STENCIL_TEXTURE_MODE for the texture is STENCIL_INDEX and either 161 | * the magnification filter or the minification filter is not NEAREST." 162 | */ 163 | if (texObj->StencilSampling && 164 | texObj->Image[0][texObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL && 165 | (sampler->MagFilter != GL_NEAREST || sampler->MinFilter != GL_NEAREST)) { 166 | return GL_FALSE; 167 | } 168 | 169 | if (_mesa_is_mipmap_filter(sampler)) 170 | return texObj->_MipmapComplete; 171 | else 172 | return texObj->_BaseComplete; 173 | } 174 | 175 | 176 | extern void 177 | _mesa_test_texobj_completeness( const struct gl_context *ctx, 178 | struct gl_texture_object *obj ); 179 | 180 | extern GLboolean 181 | _mesa_cube_level_complete(const struct gl_texture_object *texObj, 182 | const GLint level); 183 | 184 | extern GLboolean 185 | _mesa_cube_complete(const struct gl_texture_object *texObj); 186 | 187 | extern void 188 | _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj); 189 | 190 | extern struct gl_texture_object * 191 | _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex); 192 | 193 | extern GLuint 194 | _mesa_total_texture_memory(struct gl_context *ctx); 195 | 196 | extern GLenum 197 | _mesa_texture_base_format(const struct gl_texture_object *texObj); 198 | 199 | extern void 200 | _mesa_unlock_context_textures( struct gl_context *ctx ); 201 | 202 | extern void 203 | _mesa_lock_context_textures( struct gl_context *ctx ); 204 | 205 | extern struct gl_texture_object * 206 | _mesa_create_nameless_texture(struct gl_context *ctx, GLenum target); 207 | 208 | extern void 209 | _mesa_delete_nameless_texture(struct gl_context *ctx, 210 | struct gl_texture_object *texObj); 211 | 212 | extern void 213 | _mesa_bind_texture_unit(struct gl_context *ctx, 214 | GLuint unit, 215 | struct gl_texture_object *texObj); 216 | 217 | /*@}*/ 218 | 219 | #ifdef __cplusplus 220 | } 221 | #endif 222 | 223 | 224 | #endif 225 | -------------------------------------------------------------------------------- /src/texparam.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef TEXPARAM_H 27 | #define TEXPARAM_H 28 | 29 | 30 | #include "glheader.h" 31 | 32 | /** 33 | * \name Internal functions 34 | */ 35 | /*@{*/ 36 | 37 | extern void 38 | _mesa_texture_parameterf(struct gl_context *ctx, 39 | struct gl_texture_object *texObj, 40 | GLenum pname, GLfloat param, bool dsa); 41 | 42 | extern void 43 | _mesa_texture_parameterfv(struct gl_context *ctx, 44 | struct gl_texture_object *texObj, 45 | GLenum pname, const GLfloat *params, bool dsa); 46 | 47 | 48 | extern void 49 | _mesa_texture_parameteri(struct gl_context *ctx, 50 | struct gl_texture_object *texObj, 51 | GLenum pname, GLint param, bool dsa); 52 | 53 | extern void 54 | _mesa_texture_parameteriv(struct gl_context *ctx, 55 | struct gl_texture_object *texObj, 56 | GLenum pname, const GLint *params, bool dsa); 57 | 58 | extern void 59 | _mesa_texture_parameterIiv(struct gl_context *ctx, 60 | struct gl_texture_object *texObj, 61 | GLenum pname, const GLint *params, bool dsa); 62 | 63 | extern void 64 | _mesa_texture_parameterIuiv(struct gl_context *ctx, 65 | struct gl_texture_object *texObj, 66 | GLenum pname, const GLuint *params, bool dsa); 67 | 68 | #endif /* TEXPARAM_H */ 69 | -------------------------------------------------------------------------------- /src/texstate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file texstate.h 3 | * Texture state management. 4 | */ 5 | 6 | /* 7 | * Mesa 3-D graphics library 8 | * 9 | * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a 12 | * copy of this software and associated documentation files (the "Software"), 13 | * to deal in the Software without restriction, including without limitation 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | * and/or sell copies of the Software, and to permit persons to whom the 16 | * Software is furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included 19 | * in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | * OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | 31 | #ifndef TEXSTATE_H 32 | #define TEXSTATE_H 33 | 34 | 35 | #include "compiler.h" 36 | #include "enums.h" 37 | #include "macros.h" 38 | #include "mtypes.h" 39 | 40 | 41 | static inline struct gl_texture_unit * 42 | _mesa_get_tex_unit(struct gl_context *ctx, GLuint unit) 43 | { 44 | assert(unit < ARRAY_SIZE(ctx->Texture.Unit)); 45 | return &(ctx->Texture.Unit[unit]); 46 | } 47 | 48 | /** 49 | * Return pointer to current texture unit. 50 | * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). 51 | */ 52 | static inline struct gl_texture_unit * 53 | _mesa_get_current_tex_unit(struct gl_context *ctx) 54 | { 55 | return _mesa_get_tex_unit(ctx, ctx->Texture.CurrentUnit); 56 | } 57 | 58 | static inline GLuint 59 | _mesa_max_tex_unit(struct gl_context *ctx) 60 | { 61 | /* See OpenGL spec for glActiveTexture: */ 62 | return MAX2(ctx->Const.MaxCombinedTextureImageUnits, 63 | ctx->Const.MaxTextureCoordUnits); 64 | } 65 | 66 | static inline struct gl_texture_unit * 67 | _mesa_get_tex_unit_err(struct gl_context *ctx, GLuint unit, const char *func) 68 | { 69 | if (unit < _mesa_max_tex_unit(ctx)) 70 | return _mesa_get_tex_unit(ctx, unit); 71 | 72 | /* Note: This error is a precedent set by glBindTextures. From the GL 4.5 73 | * specification (30.10.2014) Section 8.1 ("Texture Objects"): 74 | * 75 | * "An INVALID_OPERATION error is generated if first + count is greater 76 | * than the number of texture image units supported by the 77 | * implementation." 78 | */ 79 | _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unit=%d)", func, 80 | unit); //_mesa_lookup_enum_by_nr(GL_TEXTURE0+unit)); 81 | return NULL; 82 | } 83 | 84 | 85 | extern void 86 | _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ); 87 | 88 | extern void 89 | _mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ); 90 | 91 | 92 | 93 | /** 94 | * \name Initialization, state maintenance 95 | */ 96 | /*@{*/ 97 | 98 | extern void 99 | _mesa_update_texture( struct gl_context *ctx, GLuint new_state ); 100 | 101 | extern GLboolean 102 | _mesa_init_texture( struct gl_context *ctx ); 103 | 104 | extern void 105 | _mesa_free_texture_data( struct gl_context *ctx ); 106 | 107 | extern void 108 | _mesa_update_default_objects_texture(struct gl_context *ctx); 109 | 110 | /*@}*/ 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /src/texstorage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2011 VMware, Inc. All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | 26 | #ifndef TEXSTORAGE_H 27 | #define TEXSTORAGE_H 28 | 29 | /** 30 | * \name Internal functions 31 | */ 32 | /*@{*/ 33 | 34 | extern void 35 | _mesa_texture_storage(struct gl_context *ctx, GLuint dims, 36 | struct gl_texture_object *texObj, 37 | GLenum target, GLsizei levels, 38 | GLenum internalformat, GLsizei width, 39 | GLsizei height, GLsizei depth, bool dsa); 40 | 41 | /*@}*/ 42 | 43 | extern GLboolean 44 | _mesa_is_legal_tex_storage_format(struct gl_context *ctx, GLenum internalformat); 45 | 46 | GLboolean 47 | _mesa_AllocTextureStorage_sw(struct gl_context *ctx, 48 | struct gl_texture_object *texObj, 49 | GLsizei levels, GLsizei width, 50 | GLsizei height, GLsizei depth); 51 | 52 | #endif /* TEXSTORAGE_H */ 53 | -------------------------------------------------------------------------------- /src/texstore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5 | * Copyright (c) 2008 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | /** 28 | * \file texstore.h 29 | * Texture image storage routines. 30 | * 31 | * \author Brian Paul 32 | */ 33 | 34 | 35 | #ifndef TEXSTORE_H 36 | #define TEXSTORE_H 37 | 38 | 39 | #include "mtypes.h" 40 | #include "formats.h" 41 | 42 | 43 | void imageTile32(u8* dest, const u8* source, unsigned int width, unsigned int height); 44 | 45 | /** 46 | * This macro defines the (many) parameters to the texstore functions. 47 | * \param dims either 1 or 2 or 3 48 | * \param baseInternalFormat user-specified base internal format 49 | * \param dstFormat destination Mesa texture format 50 | * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels 51 | * \param dstRowStride destination image row stride, in bytes 52 | * \param dstSlices array of addresses of image slices (for 3D, array texture) 53 | * \param srcWidth/Height/Depth source image size, in pixels 54 | * \param srcFormat incoming image format 55 | * \param srcType incoming image data type 56 | * \param srcAddr source image address 57 | * \param srcPacking source image packing parameters 58 | */ 59 | #define TEXSTORE_PARAMS \ 60 | struct gl_context *ctx, GLuint dims, \ 61 | GLenum baseInternalFormat, \ 62 | mesa_format dstFormat, \ 63 | GLint dstRowStride, \ 64 | GLubyte **dstSlices, \ 65 | GLint srcWidth, GLint srcHeight, GLint srcDepth, \ 66 | GLenum srcFormat, GLenum srcType, \ 67 | const GLvoid *srcAddr, \ 68 | const struct gl_pixelstore_attrib *srcPacking 69 | 70 | 71 | extern GLboolean 72 | _mesa_texstore(TEXSTORE_PARAMS); 73 | 74 | extern GLboolean 75 | _mesa_texstore_needs_transfer_ops(struct gl_context *ctx, 76 | GLenum baseInternalFormat, 77 | mesa_format dstFormat); 78 | 79 | extern GLboolean 80 | _mesa_texstore_can_use_memcpy(struct gl_context *ctx, 81 | GLenum baseInternalFormat, mesa_format dstFormat, 82 | GLenum srcFormat, GLenum srcType, 83 | const struct gl_pixelstore_attrib *srcPacking); 84 | 85 | 86 | extern void 87 | _mesa_store_teximage(struct gl_context *ctx, 88 | GLuint dims, 89 | struct gl_texture_image *texImage, 90 | GLenum format, GLenum type, const GLvoid *pixels, 91 | const struct gl_pixelstore_attrib *packing); 92 | 93 | 94 | extern void 95 | _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims, 96 | struct gl_texture_image *texImage, 97 | GLint xoffset, GLint yoffset, GLint zoffset, 98 | GLint width, GLint height, GLint depth, 99 | GLenum format, GLenum type, const GLvoid *pixels, 100 | const struct gl_pixelstore_attrib *packing); 101 | 102 | 103 | extern void 104 | _mesa_store_cleartexsubimage(struct gl_context *ctx, 105 | struct gl_texture_image *texImage, 106 | GLint xoffset, GLint yoffset, GLint zoffset, 107 | GLsizei width, GLsizei height, GLsizei depth, 108 | const GLvoid *clearValue); 109 | 110 | extern void 111 | _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims, 112 | struct gl_texture_image *texImage, 113 | GLsizei imageSize, const GLvoid *data); 114 | 115 | 116 | extern void 117 | _mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims, 118 | struct gl_texture_image *texImage, 119 | GLint xoffset, GLint yoffset, GLint zoffset, 120 | GLsizei width, GLsizei height, GLsizei depth, 121 | GLenum format, 122 | GLsizei imageSize, const GLvoid *data); 123 | 124 | 125 | struct compressed_pixelstore { 126 | int SkipBytes; 127 | int CopyBytesPerRow; 128 | int CopyRowsPerSlice; 129 | int TotalBytesPerRow; 130 | int TotalRowsPerSlice; 131 | int CopySlices; 132 | }; 133 | 134 | 135 | extern void 136 | _mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat, 137 | GLsizei width, GLsizei height, 138 | GLsizei depth, 139 | const struct gl_pixelstore_attrib *packing, 140 | struct compressed_pixelstore *store); 141 | 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /src/textureview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2012-2013 LunarG, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Authors: 25 | * Courtney Goeltzenleuchter 26 | */ 27 | 28 | 29 | #ifndef TEXTUREVIEW_H 30 | #define TEXTUREVIEW_H 31 | 32 | bool 33 | _mesa_texture_view_compatible_format(const struct gl_context *ctx, 34 | GLenum origInternalFormat, 35 | GLenum newInternalFormat); 36 | 37 | extern void 38 | _mesa_set_texture_view_state(struct gl_context *ctx, 39 | struct gl_texture_object *texObj, 40 | GLenum target, GLuint levels); 41 | 42 | #endif /* TEXTUREVIEW_H */ 43 | -------------------------------------------------------------------------------- /src/uniform.c: -------------------------------------------------------------------------------- 1 | #include "glheader.h" 2 | #include "mtypes.h" 3 | #include "errors.h" 4 | #include "context.h" 5 | 6 | static void set_uniform(GLint location, GLsizei count, const GLfloat* value, bool need_swap) 7 | { 8 | GET_CURRENT_CONTEXT(ctx); 9 | if (ctx->Shared->Shader->Program) 10 | { 11 | int i; 12 | struct gl_shader_uniform* uniform; 13 | for (i = 0; i < ctx->Shared->Shader->UniformCount; i++) { 14 | if (ctx->Shared->Shader->UniformVals[i].location == location) { 15 | break; 16 | } 17 | } 18 | uniform = &ctx->Shared->Shader->UniformVals[i]; 19 | if (i == ctx->Shared->Shader->UniformCount) { 20 | uniform->count = (u8) count; 21 | uniform->location = (u32) location; 22 | uniform->value = malloc(sizeof(float) * count * 4); 23 | if (!uniform->value) 24 | return; 25 | ctx->Shared->Shader->UniformCount++; 26 | } 27 | 28 | if (need_swap) { 29 | for (i = 0; i < count*4; i+=4) { 30 | uniform->value[i] = value[i+3]; 31 | uniform->value[i+1] = value[i+2]; 32 | uniform->value[i+2] = value[i+1]; 33 | uniform->value[i+3] = value[i]; 34 | } 35 | } else { 36 | memcpy(uniform->value, value, sizeof(float) * count * 4); 37 | } 38 | 39 | uniform->changed = true; 40 | } 41 | } 42 | 43 | void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) 44 | { 45 | GET_CURRENT_CONTEXT(ctx); 46 | 47 | // TODO: make use of transpose according to OGL standards 48 | if (location < 0) { 49 | _mesa_error(ctx, GL_INVALID_VALUE, 50 | "glUniformMatrix4fv(location=%d)", 51 | location); 52 | return; 53 | } 54 | 55 | if (!transpose) { 56 | GLfloat copy[16]; 57 | _math_transposef(copy, value); 58 | memcpy(value, copy, sizeof(GLfloat)*16); 59 | } 60 | 61 | // printf("\nv:%f,%f,%f,%f\nv:%f,%f,%f,%f\nv:%f,%f,%f,%f\nv:%f,%f,%f,%f\n", 62 | // value[0],value[1],value[2],value[3], 63 | // value[4],value[5],value[6],value[7], 64 | // value[8],value[9],value[10],value[11], 65 | // value[12],value[13],value[14],value[15]); 66 | set_uniform(location, count * 4, value, true); 67 | } 68 | 69 | GLint glGetUniformLocation(GLuint program, const GLchar* name) 70 | { 71 | shaderProgram_s* prog = (shaderProgram_s*) program; 72 | // TODO: need to check geometry shader too? 73 | return (GLint) shaderInstanceGetUniformLocation(prog->vertexShader, name); 74 | } 75 | 76 | /* UNIFORM FUNCTIONS */ 77 | void glUniform1f(GLint location, GLfloat v0){ 78 | float params[4] = {0, 0, 0, v0}; 79 | set_uniform(location, 1, params, false); 80 | } 81 | 82 | void glUniform2f(GLint location, GLfloat v0, GLfloat v1){ 83 | float params[4] = {0, 0, v1, v0}; 84 | set_uniform(location, 1, params, false); 85 | } 86 | 87 | void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2){ 88 | float params[4] = {0, v2, v1, v0}; 89 | set_uniform(location, 1, params, false); 90 | } 91 | 92 | void glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3){ 93 | float params[4] = {v3, v2, v1, v0}; 94 | set_uniform(location, 1, params, false); 95 | } 96 | 97 | void glUniform1i(GLint location, GLint v0){} 98 | void glUniform2i(GLint location, GLint v0, GLint v1){} 99 | void glUniform3i(GLint location, GLint v0, GLint v1, GLint v2){} 100 | void glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3){} 101 | 102 | void glUniform4iv(GLint location, GLsizei count, const GLint *value) 103 | { 104 | GPUCMD_AddSingleParam(0x000F02C0, 0x80000000 | location); 105 | GPUCMD_Add(0x000F02C1, (u32*) value, count * 4); 106 | } 107 | 108 | 109 | void glUniform4fv(GLint location, GLsizei count, const GLfloat* value) 110 | { 111 | // TODO: update shader state 112 | GPUCMD_AddSingleParam(0x000F02C0, 0x80000000 | location); 113 | GPUCMD_Add(0x000F02C1, (u32*) value, count * 4); 114 | } 115 | -------------------------------------------------------------------------------- /src/util/bitset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 2006 Brian Paul All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * \file bitset.h 27 | * \brief Bitset of arbitrary size definitions. 28 | * \author Michal Krol 29 | */ 30 | 31 | #ifndef BITSET_H 32 | #define BITSET_H 33 | 34 | #include "u_math.h" 35 | 36 | /**************************************************************************** 37 | * generic bitset implementation 38 | */ 39 | 40 | #define BITSET_WORD unsigned int 41 | #define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8) 42 | 43 | /* bitset declarations 44 | */ 45 | #define BITSET_WORDS(bits) (((bits) + BITSET_WORDBITS - 1) / BITSET_WORDBITS) 46 | #define BITSET_DECLARE(name, bits) BITSET_WORD name[BITSET_WORDS(bits)] 47 | 48 | /* bitset operations 49 | */ 50 | #define BITSET_COPY(x, y) memcpy( (x), (y), sizeof (x) ) 51 | #define BITSET_EQUAL(x, y) (memcmp( (x), (y), sizeof (x) ) == 0) 52 | #define BITSET_ZERO(x) memset( (x), 0, sizeof (x) ) 53 | #define BITSET_ONES(x) memset( (x), 0xff, sizeof (x) ) 54 | 55 | #define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS) 56 | #define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS)) 57 | 58 | /* single bit operations 59 | */ 60 | #define BITSET_TEST(x, b) ((x)[BITSET_BITWORD(b)] & BITSET_BIT(b)) 61 | #define BITSET_SET(x, b) ((x)[BITSET_BITWORD(b)] |= BITSET_BIT(b)) 62 | #define BITSET_CLEAR(x, b) ((x)[BITSET_BITWORD(b)] &= ~BITSET_BIT(b)) 63 | 64 | #define BITSET_MASK(b) ((b) == BITSET_WORDBITS ? ~0 : BITSET_BIT(b) - 1) 65 | #define BITSET_RANGE(b, e) (BITSET_MASK((e) + 1) & ~BITSET_MASK(b)) 66 | 67 | /* bit range operations 68 | */ 69 | #define BITSET_TEST_RANGE(x, b, e) \ 70 | (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 71 | ((x)[BITSET_BITWORD(b)] & BITSET_RANGE(b, e)) : \ 72 | (assert (!"BITSET_TEST_RANGE: bit range crosses word boundary"), 0)) 73 | #define BITSET_SET_RANGE(x, b, e) \ 74 | (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 75 | ((x)[BITSET_BITWORD(b)] |= BITSET_RANGE(b, e)) : \ 76 | (assert (!"BITSET_SET_RANGE: bit range crosses word boundary"), 0)) 77 | #define BITSET_CLEAR_RANGE(x, b, e) \ 78 | (BITSET_BITWORD(b) == BITSET_BITWORD(e) ? \ 79 | ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ 80 | (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) 81 | 82 | /* Get first bit set in a bitset. 83 | */ 84 | static inline int 85 | __bitset_ffs(const BITSET_WORD *x, int n) 86 | { 87 | int i; 88 | 89 | for (i = 0; i < n; i++) { 90 | if (x[i]) 91 | return ffs(x[i]) + BITSET_WORDBITS * i; 92 | } 93 | 94 | return 0; 95 | } 96 | 97 | #define BITSET_FFS(x) __bitset_ffs(x, ARRAY_SIZE(x)) 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/util/format_srgb.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * 3 | * Copyright 2010 VMware, Inc. 4 | * All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sub license, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * The above copyright notice and this permission notice (including the 23 | * next paragraph) shall be included in all copies or substantial portions 24 | * of the Software. 25 | * 26 | **************************************************************************/ 27 | 28 | /** 29 | * @file 30 | * SRGB translation. 31 | * 32 | * @author Brian Paul 33 | * @author Michal Krol 34 | * @author Jose Fonseca 35 | */ 36 | 37 | #ifndef U_FORMAT_SRGB_H_ 38 | #define U_FORMAT_SRGB_H_ 39 | 40 | #include 41 | #include 42 | //#include "c99_compat.h" 43 | 44 | extern const float 45 | util_format_srgb_8unorm_to_linear_float_table[256]; 46 | 47 | extern const uint8_t 48 | util_format_srgb_to_linear_8unorm_table[256]; 49 | 50 | extern const uint8_t 51 | util_format_linear_to_srgb_8unorm_table[256]; 52 | 53 | extern const unsigned 54 | util_format_linear_to_srgb_helper_table[104]; 55 | 56 | 57 | static inline float 58 | util_format_linear_to_srgb_float(float cl) 59 | { 60 | if (cl < 0.0f) 61 | return 0.0f; 62 | else if (cl < 0.0031308f) 63 | return 12.92f * cl; 64 | else if (cl < 1.0f) 65 | return 1.055f * powf(cl, 0.41666f) - 0.055f; 66 | else 67 | return 1.0f; 68 | } 69 | 70 | 71 | /** 72 | * Convert a unclamped linear float to srgb value in the [0,255]. 73 | */ 74 | static inline uint8_t 75 | util_format_linear_float_to_srgb_8unorm(float x) 76 | { 77 | /* 78 | * This is taken from https://gist.github.com/rygorous/2203834 79 | * Use LUT and do linear interpolation. 80 | */ 81 | union { 82 | uint32_t ui; 83 | float f; 84 | } almostone, minval, f; 85 | unsigned tab, bias, scale, t; 86 | 87 | almostone.ui = 0x3f7fffff; 88 | minval.ui = (127-13) << 23; 89 | 90 | /* 91 | * Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. 92 | * The tests are carefully written so that NaNs map to 0, same as in the 93 | * reference implementation. 94 | */ 95 | if (!(x > minval.f)) 96 | x = minval.f; 97 | if (x > almostone.f) 98 | x = almostone.f; 99 | 100 | /* Do the table lookup and unpack bias, scale */ 101 | f.f = x; 102 | tab = util_format_linear_to_srgb_helper_table[(f.ui - minval.ui) >> 20]; 103 | bias = (tab >> 16) << 9; 104 | scale = tab & 0xffff; 105 | 106 | /* Grab next-highest mantissa bits and perform linear interpolation */ 107 | t = (f.ui >> 12) & 0xff; 108 | return (uint8_t) ((bias + scale*t) >> 16); 109 | } 110 | 111 | 112 | /** 113 | * Convert an 8-bit sRGB value from non-linear space to a 114 | * linear RGB value in [0, 1]. 115 | * Implemented with a 256-entry lookup table. 116 | */ 117 | static inline float 118 | util_format_srgb_8unorm_to_linear_float(uint8_t x) 119 | { 120 | return util_format_srgb_8unorm_to_linear_float_table[x]; 121 | } 122 | 123 | 124 | /* 125 | * XXX These 2 functions probably don't make a lot of sense (but lots 126 | * of potential callers which most likely all don't make sense neither) 127 | */ 128 | 129 | /** 130 | * Convert a 8bit normalized value from linear to srgb. 131 | */ 132 | static inline uint8_t 133 | util_format_linear_to_srgb_8unorm(uint8_t x) 134 | { 135 | return util_format_linear_to_srgb_8unorm_table[x]; 136 | } 137 | 138 | 139 | /** 140 | * Convert a 8bit normalized value from srgb to linear. 141 | */ 142 | static inline uint8_t 143 | util_format_srgb_to_linear_8unorm(uint8_t x) 144 | { 145 | return util_format_srgb_to_linear_8unorm_table[x]; 146 | } 147 | 148 | 149 | #endif /* U_FORMAT_SRGB_H_ */ 150 | -------------------------------------------------------------------------------- /src/util/format_srgb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | CopyRight = ''' 4 | /************************************************************************** 5 | * 6 | * Copyright 2010 VMware, Inc. 7 | * All Rights Reserved. 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a 10 | * copy of this software and associated documentation files (the 11 | * "Software"), to deal in the Software without restriction, including 12 | * without limitation the rights to use, copy, modify, merge, publish, 13 | * distribute, sub license, and/or sell copies of the Software, and to 14 | * permit persons to whom the Software is furnished to do so, subject to 15 | * the following conditions: 16 | * 17 | * The above copyright notice and this permission notice (including the 18 | * next paragraph) shall be included in all copies or substantial portions 19 | * of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 24 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 25 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | * 29 | **************************************************************************/ 30 | 31 | /** 32 | * @file 33 | * SRGB translation. 34 | * 35 | * @author Brian Paul 36 | * @author Michal Krol 37 | * @author Jose Fonseca 38 | */ 39 | ''' 40 | 41 | 42 | import math 43 | import struct 44 | 45 | 46 | def srgb_to_linear(x): 47 | if x <= 0.04045: 48 | return x / 12.92 49 | else: 50 | return math.pow((x + 0.055) / 1.055, 2.4) 51 | 52 | 53 | def linear_to_srgb(x): 54 | if x >= 0.0031308: 55 | return 1.055 * math.pow(x, 0.41666666) - 0.055 56 | else: 57 | return 12.92 * x 58 | 59 | 60 | def generate_srgb_tables(): 61 | print 'const float' 62 | print 'util_format_srgb_8unorm_to_linear_float_table[256] = {' 63 | for j in range(0, 256, 4): 64 | print ' ', 65 | for i in range(j, j + 4): 66 | print '%.7e,' % (srgb_to_linear(i / 255.0),), 67 | print 68 | print '};' 69 | print 70 | print 'const uint8_t' 71 | print 'util_format_srgb_to_linear_8unorm_table[256] = {' 72 | for j in range(0, 256, 16): 73 | print ' ', 74 | for i in range(j, j + 16): 75 | print '%3u,' % (int(srgb_to_linear(i / 255.0) * 255.0 + 0.5),), 76 | print 77 | print '};' 78 | print 79 | print 'const uint8_t' 80 | print 'util_format_linear_to_srgb_8unorm_table[256] = {' 81 | for j in range(0, 256, 16): 82 | print ' ', 83 | for i in range(j, j + 16): 84 | print '%3u,' % (int(linear_to_srgb(i / 255.0) * 255.0 + 0.5),), 85 | print 86 | print '};' 87 | print 88 | 89 | # calculate the table interpolation values used in float linear to unorm8 srgb 90 | numexp = 13 91 | mantissa_msb = 3 92 | # stepshift is just used to only use every x-th float to make things faster, 93 | # 5 is largest value which still gives exact same table as 0 94 | stepshift = 5 95 | nbuckets = numexp << mantissa_msb 96 | bucketsize = (1 << (23 - mantissa_msb)) >> stepshift 97 | mantshift = 12 98 | valtable = [] 99 | sum_aa = float(bucketsize) 100 | sum_ab = 0.0 101 | sum_bb = 0.0 102 | for i in range(0, bucketsize): 103 | j = (i << stepshift) >> mantshift 104 | sum_ab += j 105 | sum_bb += j*j 106 | inv_det = 1.0 / (sum_aa * sum_bb - sum_ab * sum_ab) 107 | 108 | for bucket in range(0, nbuckets): 109 | start = ((127 - numexp) << 23) + bucket*(bucketsize << stepshift) 110 | sum_a = 0.0 111 | sum_b = 0.0 112 | 113 | for i in range(0, bucketsize): 114 | j = (i << stepshift) >> mantshift 115 | fint = start + (i << stepshift) 116 | ffloat = struct.unpack('f', struct.pack('I', fint))[0] 117 | val = linear_to_srgb(ffloat) * 255.0 + 0.5 118 | sum_a += val 119 | sum_b += j*val 120 | 121 | solved_a = inv_det * (sum_bb*sum_a - sum_ab*sum_b) 122 | solved_b = inv_det * (sum_aa*sum_b - sum_ab*sum_a) 123 | 124 | scaled_a = solved_a * 65536.0 / 512.0 125 | scaled_b = solved_b * 65536.0 126 | 127 | int_a = int(scaled_a + 0.5) 128 | int_b = int(scaled_b + 0.5) 129 | 130 | valtable.append((int_a << 16) + int_b) 131 | 132 | print 'const unsigned' 133 | print 'util_format_linear_to_srgb_helper_table[104] = {' 134 | 135 | for j in range(0, nbuckets, 4): 136 | print ' ', 137 | for i in range(j, j + 4): 138 | print '0x%08x,' % (valtable[i],), 139 | print 140 | print '};' 141 | print 142 | 143 | def main(): 144 | print '/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */' 145 | print 146 | # This will print the copyright message on the top of this file 147 | print CopyRight.strip() 148 | print 149 | print '#include "format_srgb.h"' 150 | print 151 | generate_srgb_tables() 152 | 153 | 154 | if __name__ == '__main__': 155 | main() 156 | -------------------------------------------------------------------------------- /src/util/hash_table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2009,2012 Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice (including the next 12 | * paragraph) shall be included in all copies or substantial portions of the 13 | * Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | * IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Eric Anholt 25 | * 26 | */ 27 | 28 | #ifndef _HASH_TABLE_H 29 | #define _HASH_TABLE_H 30 | 31 | #include 32 | #include 33 | #include 34 | //#include "c99_compat.h" 35 | #include "macros.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | struct hash_entry { 42 | uint32_t hash; 43 | const void *key; 44 | void *data; 45 | }; 46 | 47 | struct hash_table { 48 | struct hash_entry *table; 49 | uint32_t (*key_hash_function)(const void *key); 50 | bool (*key_equals_function)(const void *a, const void *b); 51 | const void *deleted_key; 52 | uint32_t size; 53 | uint32_t rehash; 54 | uint32_t max_entries; 55 | uint32_t size_index; 56 | uint32_t entries; 57 | uint32_t deleted_entries; 58 | }; 59 | 60 | struct hash_table * 61 | _mesa_hash_table_create(void *mem_ctx, 62 | uint32_t (*key_hash_function)(const void *key), 63 | bool (*key_equals_function)(const void *a, 64 | const void *b)); 65 | void _mesa_hash_table_destroy(struct hash_table *ht, 66 | void (*delete_function)(struct hash_entry *entry)); 67 | void _mesa_hash_table_set_deleted_key(struct hash_table *ht, 68 | const void *deleted_key); 69 | 70 | struct hash_entry * 71 | _mesa_hash_table_insert(struct hash_table *ht, const void *key, void *data); 72 | struct hash_entry * 73 | _mesa_hash_table_insert_pre_hashed(struct hash_table *ht, uint32_t hash, 74 | const void *key, void *data); 75 | struct hash_entry * 76 | _mesa_hash_table_search(struct hash_table *ht, const void *key); 77 | struct hash_entry * 78 | _mesa_hash_table_search_pre_hashed(struct hash_table *ht, uint32_t hash, 79 | const void *key); 80 | void _mesa_hash_table_remove(struct hash_table *ht, 81 | struct hash_entry *entry); 82 | 83 | struct hash_entry *_mesa_hash_table_next_entry(struct hash_table *ht, 84 | struct hash_entry *entry); 85 | struct hash_entry * 86 | _mesa_hash_table_random_entry(struct hash_table *ht, 87 | bool (*predicate)(struct hash_entry *entry)); 88 | 89 | uint32_t _mesa_hash_data(const void *data, size_t size); 90 | uint32_t _mesa_hash_string(const char *key); 91 | bool _mesa_key_string_equal(const void *a, const void *b); 92 | bool _mesa_key_pointer_equal(const void *a, const void *b); 93 | 94 | static inline uint32_t _mesa_key_hash_string(const void *key) 95 | { 96 | return _mesa_hash_string((const char *)key); 97 | } 98 | 99 | static inline uint32_t _mesa_hash_pointer(const void *pointer) 100 | { 101 | return _mesa_hash_data(&pointer, sizeof(pointer)); 102 | } 103 | 104 | static const uint32_t _mesa_fnv32_1a_offset_bias = 2166136261u; 105 | 106 | static inline uint32_t 107 | _mesa_fnv32_1a_accumulate_block(uint32_t hash, const void *data, size_t size) 108 | { 109 | const uint8_t *bytes = (const uint8_t *)data; 110 | 111 | while (size-- != 0) { 112 | hash ^= *bytes; 113 | hash = hash * 0x01000193; 114 | bytes++; 115 | } 116 | 117 | return hash; 118 | } 119 | 120 | #define _mesa_fnv32_1a_accumulate(hash, expr) \ 121 | _mesa_fnv32_1a_accumulate_block(hash, &(expr), sizeof(expr)) 122 | 123 | /** 124 | * This foreach function is safe against deletion (which just replaces 125 | * an entry's data with the deleted marker), but not against insertion 126 | * (which may rehash the table, making entry a dangling pointer). 127 | */ 128 | #define hash_table_foreach(ht, entry) \ 129 | for (entry = _mesa_hash_table_next_entry(ht, NULL); \ 130 | entry != NULL; \ 131 | entry = _mesa_hash_table_next_entry(ht, entry)) 132 | 133 | #ifdef __cplusplus 134 | } /* extern C */ 135 | #endif 136 | 137 | #endif /* _HASH_TABLE_H */ 138 | -------------------------------------------------------------------------------- /src/util/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2014 Intel Corporation 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice (including the next 12 | * paragraph) shall be included in all copies or substantial portions of the 13 | * Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | * IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef UTIL_MACROS_H 25 | #define UTIL_MACROS_H 26 | 27 | /* Compute the size of an array */ 28 | #ifndef ARRAY_SIZE 29 | # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) 30 | #endif 31 | 32 | /* For compatibility with Clang's __has_builtin() */ 33 | #ifndef __has_builtin 34 | # define __has_builtin(x) 0 35 | #endif 36 | 37 | /** 38 | * __builtin_expect macros 39 | */ 40 | #if !defined(HAVE___BUILTIN_EXPECT) 41 | # define __builtin_expect(x, y) (x) 42 | #endif 43 | 44 | #ifndef likely 45 | # ifdef HAVE___BUILTIN_EXPECT 46 | # define likely(x) __builtin_expect(!!(x), 1) 47 | # define unlikely(x) __builtin_expect(!!(x), 0) 48 | # else 49 | # define likely(x) (x) 50 | # define unlikely(x) (x) 51 | # endif 52 | #endif 53 | 54 | 55 | /** 56 | * Static (compile-time) assertion. 57 | * Basically, use COND to dimension an array. If COND is false/zero the 58 | * array size will be -1 and we'll get a compilation error. 59 | */ 60 | #define STATIC_ASSERT(COND) \ 61 | do { \ 62 | (void) sizeof(char [1 - 2*!(COND)]); \ 63 | } while (0) 64 | 65 | 66 | /** 67 | * Unreachable macro. Useful for suppressing "control reaches end of non-void 68 | * function" warnings. 69 | */ 70 | #ifdef HAVE___BUILTIN_UNREACHABLE 71 | #define unreachable(str) \ 72 | do { \ 73 | assert(!str); \ 74 | __builtin_unreachable(); \ 75 | } while (0) 76 | #elif defined (_MSC_VER) 77 | #define unreachable(str) \ 78 | do { \ 79 | assert(!str); \ 80 | __assume(0); \ 81 | } while (0) 82 | #else 83 | #define unreachable(str) assert(!str) 84 | #endif 85 | 86 | /** 87 | * Assume macro. Useful for expressing our assumptions to the compiler, 88 | * typically for purposes of silencing warnings. 89 | */ 90 | #if __has_builtin(__builtin_assume) 91 | #define assume(expr) \ 92 | do { \ 93 | assert(expr); \ 94 | __builtin_assume(expr); \ 95 | } while (0) 96 | #elif defined HAVE___BUILTIN_UNREACHABLE 97 | #define assume(expr) ((expr) ? ((void) 0) \ 98 | : (assert(!"assumption failed"), \ 99 | __builtin_unreachable())) 100 | #elif defined (_MSC_VER) 101 | #define assume(expr) __assume(expr) 102 | #else 103 | #define assume(expr) assert(expr) 104 | #endif 105 | 106 | #ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN 107 | #define FLATTEN __attribute__((__flatten__)) 108 | #else 109 | #define FLATTEN 110 | #endif 111 | 112 | #ifdef HAVE_FUNC_ATTRIBUTE_FORMAT 113 | #define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) 114 | #else 115 | #define PRINTFLIKE(f, a) 116 | #endif 117 | 118 | #ifdef HAVE_FUNC_ATTRIBUTE_MALLOC 119 | #define MALLOCLIKE __attribute__((__malloc__)) 120 | #else 121 | #define MALLOCLIKE 122 | #endif 123 | 124 | /* Used to optionally mark structures with misaligned elements or size as 125 | * packed, to trade off performance for space. 126 | */ 127 | #ifdef PACKED 128 | #undef PACKED 129 | #endif 130 | #ifdef HAVE_FUNC_ATTRIBUTE_PACKED 131 | #define PACKED __attribute__((__packed__)) 132 | #else 133 | #define PACKED 134 | #endif 135 | 136 | #ifdef __cplusplus 137 | /** 138 | * Macro function that evaluates to true if T is a trivially 139 | * destructible type -- that is, if its (non-virtual) destructor 140 | * performs no action and all member variables and base classes are 141 | * trivially destructible themselves. 142 | */ 143 | # if defined(__GNUC__) 144 | # if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) 145 | # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) 146 | # endif 147 | # elif (defined(__clang__) && defined(__has_feature)) 148 | # if __has_feature(has_trivial_destructor) 149 | # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) 150 | # endif 151 | # endif 152 | # ifndef HAS_TRIVIAL_DESTRUCTOR 153 | /* It's always safe (if inefficient) to assume that a 154 | * destructor is non-trivial. 155 | */ 156 | # define HAS_TRIVIAL_DESTRUCTOR(T) (false) 157 | # endif 158 | #endif 159 | 160 | /** 161 | * PUBLIC/USED macros 162 | * 163 | * If we build the library with gcc's -fvisibility=hidden flag, we'll 164 | * use the PUBLIC macro to mark functions that are to be exported. 165 | * 166 | * We also need to define a USED attribute, so the optimizer doesn't 167 | * inline a static function that we later use in an alias. - ajax 168 | */ 169 | #ifndef PUBLIC 170 | # if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) 171 | # define PUBLIC __attribute__((visibility("default"))) 172 | # define USED __attribute__((used)) 173 | # elif defined(_MSC_VER) 174 | # define PUBLIC __declspec(dllexport) 175 | # define USED 176 | # else 177 | # define PUBLIC 178 | # define USED 179 | # endif 180 | #endif 181 | 182 | #ifdef HAVE_FUNC_ATTRIBUTE_UNUSED 183 | #define UNUSED __attribute__((unused)) 184 | #else 185 | #define UNUSED 186 | #endif 187 | 188 | /** Compute ceiling of integer quotient of A divided by B. */ 189 | #define DIV_ROUND_UP( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) 190 | 191 | #endif /* UTIL_MACROS_H */ 192 | -------------------------------------------------------------------------------- /src/util/simple_list.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file simple_list.h 3 | * Simple macros for type-safe, intrusive lists. 4 | * 5 | * Intended to work with a list sentinal which is created as an empty 6 | * list. Insert & delete are O(1). 7 | * 8 | * \author 9 | * (C) 1997, Keith Whitwell 10 | */ 11 | 12 | /* 13 | * Mesa 3-D graphics library 14 | * 15 | * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 16 | * 17 | * Permission is hereby granted, free of charge, to any person obtaining a 18 | * copy of this software and associated documentation files (the "Software"), 19 | * to deal in the Software without restriction, including without limitation 20 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 21 | * and/or sell copies of the Software, and to permit persons to whom the 22 | * Software is furnished to do so, subject to the following conditions: 23 | * 24 | * The above copyright notice and this permission notice shall be included 25 | * in all copies or substantial portions of the Software. 26 | * 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 28 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 30 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 33 | * OTHER DEALINGS IN THE SOFTWARE. 34 | */ 35 | 36 | 37 | #ifndef _SIMPLE_LIST_H 38 | #define _SIMPLE_LIST_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | struct simple_node { 45 | struct simple_node *next; 46 | struct simple_node *prev; 47 | }; 48 | 49 | /** 50 | * Remove an element from list. 51 | * 52 | * \param elem element to remove. 53 | */ 54 | #define remove_from_list(elem) \ 55 | do { \ 56 | (elem)->next->prev = (elem)->prev; \ 57 | (elem)->prev->next = (elem)->next; \ 58 | make_empty_list(elem); \ 59 | } while (0) 60 | 61 | /** 62 | * Insert an element to the list head. 63 | * 64 | * \param list list. 65 | * \param elem element to insert. 66 | */ 67 | #define insert_at_head(list, elem) \ 68 | do { \ 69 | (elem)->prev = list; \ 70 | (elem)->next = (list)->next; \ 71 | (list)->next->prev = elem; \ 72 | (list)->next = elem; \ 73 | } while(0) 74 | 75 | /** 76 | * Insert an element to the list tail. 77 | * 78 | * \param list list. 79 | * \param elem element to insert. 80 | */ 81 | #define insert_at_tail(list, elem) \ 82 | do { \ 83 | (elem)->next = list; \ 84 | (elem)->prev = (list)->prev; \ 85 | (list)->prev->next = elem; \ 86 | (list)->prev = elem; \ 87 | } while(0) 88 | 89 | /** 90 | * Move an element to the list head. 91 | * 92 | * \param list list. 93 | * \param elem element to move. 94 | */ 95 | #define move_to_head(list, elem) \ 96 | do { \ 97 | remove_from_list(elem); \ 98 | insert_at_head(list, elem); \ 99 | } while (0) 100 | 101 | /** 102 | * Move an element to the list tail. 103 | * 104 | * \param list list. 105 | * \param elem element to move. 106 | */ 107 | #define move_to_tail(list, elem) \ 108 | do { \ 109 | remove_from_list(elem); \ 110 | insert_at_tail(list, elem); \ 111 | } while (0) 112 | 113 | /** 114 | * Make a empty list empty. 115 | * 116 | * \param sentinal list (sentinal element). 117 | */ 118 | #define make_empty_list(sentinal) \ 119 | do { \ 120 | (sentinal)->next = sentinal; \ 121 | (sentinal)->prev = sentinal; \ 122 | } while (0) 123 | 124 | /** 125 | * Get list first element. 126 | * 127 | * \param list list. 128 | * 129 | * \return pointer to first element. 130 | */ 131 | #define first_elem(list) ((list)->next) 132 | 133 | /** 134 | * Get list last element. 135 | * 136 | * \param list list. 137 | * 138 | * \return pointer to last element. 139 | */ 140 | #define last_elem(list) ((list)->prev) 141 | 142 | /** 143 | * Get next element. 144 | * 145 | * \param elem element. 146 | * 147 | * \return pointer to next element. 148 | */ 149 | #define next_elem(elem) ((elem)->next) 150 | 151 | /** 152 | * Get previous element. 153 | * 154 | * \param elem element. 155 | * 156 | * \return pointer to previous element. 157 | */ 158 | #define prev_elem(elem) ((elem)->prev) 159 | 160 | /** 161 | * Test whether element is at end of the list. 162 | * 163 | * \param list list. 164 | * \param elem element. 165 | * 166 | * \return non-zero if element is at end of list, or zero otherwise. 167 | */ 168 | #define at_end(list, elem) ((elem) == (list)) 169 | 170 | /** 171 | * Test if a list is empty. 172 | * 173 | * \param list list. 174 | * 175 | * \return non-zero if list empty, or zero otherwise. 176 | */ 177 | #define is_empty_list(list) ((list)->next == (list)) 178 | 179 | /** 180 | * Walk through the elements of a list. 181 | * 182 | * \param ptr pointer to the current element. 183 | * \param list list. 184 | * 185 | * \note It should be followed by a { } block or a single statement, as in a \c 186 | * for loop. 187 | */ 188 | #define foreach(ptr, list) \ 189 | for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) 190 | 191 | /** 192 | * Walk through the elements of a list. 193 | * 194 | * Same as #foreach but lets you unlink the current value during a list 195 | * traversal. Useful for freeing a list, element by element. 196 | * 197 | * \param ptr pointer to the current element. 198 | * \param t temporary pointer. 199 | * \param list list. 200 | * 201 | * \note It should be followed by a { } block or a single statement, as in a \c 202 | * for loop. 203 | */ 204 | #define foreach_s(ptr, t, list) \ 205 | for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) 206 | 207 | #ifdef __cplusplus 208 | } 209 | #endif 210 | 211 | #endif 212 | -------------------------------------------------------------------------------- /src/varray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef VARRAY_H 28 | #define VARRAY_H 29 | 30 | 31 | #include "glheader.h" 32 | #include "bufferobj.h" 33 | 34 | struct gl_client_array; 35 | struct gl_context; 36 | 37 | /** 38 | * Returns a pointer to the vertex attribute data in a client array, 39 | * or the offset into the vertex buffer for an array that resides in 40 | * a vertex buffer. 41 | */ 42 | static inline const GLubyte * 43 | _mesa_vertex_attrib_address(const struct gl_vertex_attrib_array *array, 44 | const struct gl_vertex_buffer_binding *binding) 45 | { 46 | if (_mesa_is_bufferobj(binding->BufferObj)) 47 | return (const GLubyte *) (binding->Offset + array->RelativeOffset); 48 | else 49 | return array->Ptr; 50 | } 51 | 52 | /** 53 | * Sets the fields in a gl_client_array to values derived from a 54 | * gl_vertex_attrib_array and a gl_vertex_buffer_binding. 55 | */ 56 | static inline void 57 | _mesa_update_client_array(struct gl_context *ctx, 58 | struct gl_client_array *dst, 59 | const struct gl_vertex_attrib_array *src, 60 | const struct gl_vertex_buffer_binding *binding) 61 | { 62 | dst->Size = src->Size; 63 | dst->Type = src->Type; 64 | dst->Format = src->Format; 65 | dst->Stride = src->Stride; 66 | dst->StrideB = binding->Stride; 67 | dst->Ptr = _mesa_vertex_attrib_address(src, binding); 68 | dst->Enabled = src->Enabled; 69 | dst->Normalized = src->Normalized; 70 | dst->Integer = src->Integer; 71 | dst->Doubles = src->Doubles; 72 | dst->InstanceDivisor = binding->InstanceDivisor; 73 | dst->_ElementSize = src->_ElementSize; 74 | _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj); 75 | } 76 | 77 | static inline bool 78 | _mesa_attr_zero_aliases_vertex(struct gl_context *ctx) 79 | { 80 | return false; 81 | } 82 | 83 | extern unsigned 84 | _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type); 85 | 86 | 87 | extern void 88 | _mesa_copy_client_array(struct gl_context *ctx, 89 | struct gl_client_array *dst, 90 | struct gl_client_array *src); 91 | 92 | extern void 93 | _mesa_copy_vertex_attrib_array(struct gl_context *ctx, 94 | struct gl_vertex_attrib_array *dst, 95 | const struct gl_vertex_attrib_array *src); 96 | 97 | extern void 98 | _mesa_copy_vertex_buffer_binding(struct gl_context *ctx, 99 | struct gl_vertex_buffer_binding *dst, 100 | const struct gl_vertex_buffer_binding *src); 101 | 102 | extern void 103 | _mesa_print_arrays(struct gl_context *ctx); 104 | 105 | extern void 106 | _mesa_init_varray( struct gl_context * ctx ); 107 | 108 | extern void 109 | _mesa_free_varray_data(struct gl_context *ctx); 110 | 111 | 112 | //void init_varray(struct gl_context *ctx); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/viewport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mesa 3-D graphics library 3 | * 4 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 | * Copyright (C) 2009 VMware, Inc. 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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef VIEWPORT_H 28 | #define VIEWPORT_H 29 | 30 | #include "glheader.h" 31 | 32 | struct gl_context; 33 | 34 | extern void 35 | _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y, 36 | GLfloat width, GLfloat height); 37 | 38 | extern void 39 | _mesa_set_depth_range(struct gl_context *ctx, unsigned idx, 40 | GLclampd nearval, GLclampd farval); 41 | 42 | extern void 43 | _mesa_init_viewport(struct gl_context *ctx); 44 | 45 | extern void 46 | _mesa_get_viewport_xform(struct gl_context *ctx, unsigned i, 47 | double scale[3], double translate[3]); 48 | 49 | void _gl3ds_update_viewport(struct gl_context *ctx); 50 | 51 | #endif 52 | --------------------------------------------------------------------------------