1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Mesa 3-D graphics library 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 12bf215546Sopenharmony_ci * 13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci/** 26bf215546Sopenharmony_ci * \file program.c 27bf215546Sopenharmony_ci * Vertex and fragment program support functions. 28bf215546Sopenharmony_ci * \author Brian Paul 29bf215546Sopenharmony_ci */ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci/** 33bf215546Sopenharmony_ci * \mainpage Mesa vertex and fragment program module 34bf215546Sopenharmony_ci * 35bf215546Sopenharmony_ci * This module or directory contains most of the code for vertex and 36bf215546Sopenharmony_ci * fragment programs and shaders, including state management, parsers, 37bf215546Sopenharmony_ci * and (some) software routines for executing programs 38bf215546Sopenharmony_ci */ 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci#ifndef PROGRAM_H 41bf215546Sopenharmony_ci#define PROGRAM_H 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci#include "prog_parameter.h" 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#ifdef __cplusplus 47bf215546Sopenharmony_ciextern "C" { 48bf215546Sopenharmony_ci#endif 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ciextern struct gl_program _mesa_DummyProgram; 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ciextern void 54bf215546Sopenharmony_ci_mesa_init_program(struct gl_context *ctx); 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ciextern void 57bf215546Sopenharmony_ci_mesa_free_program_data(struct gl_context *ctx); 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ciextern void 60bf215546Sopenharmony_ci_mesa_update_default_objects_program(struct gl_context *ctx); 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ciextern void 63bf215546Sopenharmony_ci_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string); 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ciextern struct gl_program * 66bf215546Sopenharmony_ci_mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage, 67bf215546Sopenharmony_ci GLuint id, bool is_arb_asm); 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ciextern struct gl_program * 70bf215546Sopenharmony_ci_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id, 71bf215546Sopenharmony_ci bool is_arb_asm); 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ciextern void 74bf215546Sopenharmony_ci_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog); 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ciextern struct gl_program * 77bf215546Sopenharmony_ci_mesa_lookup_program(struct gl_context *ctx, GLuint id); 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ciextern void 80bf215546Sopenharmony_ci_mesa_reference_program_(struct gl_context *ctx, 81bf215546Sopenharmony_ci struct gl_program **ptr, 82bf215546Sopenharmony_ci struct gl_program *prog); 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_cistatic inline void 85bf215546Sopenharmony_ci_mesa_reference_program(struct gl_context *ctx, 86bf215546Sopenharmony_ci struct gl_program **ptr, 87bf215546Sopenharmony_ci struct gl_program *prog) 88bf215546Sopenharmony_ci{ 89bf215546Sopenharmony_ci if (*ptr != prog) 90bf215546Sopenharmony_ci _mesa_reference_program_(ctx, ptr, prog); 91bf215546Sopenharmony_ci} 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ciextern GLint 94bf215546Sopenharmony_ci_mesa_get_min_invocations_per_fragment(struct gl_context *ctx, 95bf215546Sopenharmony_ci const struct gl_program *prog); 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_cistatic inline GLuint 98bf215546Sopenharmony_ci_mesa_program_enum_to_shader_stage(GLenum v) 99bf215546Sopenharmony_ci{ 100bf215546Sopenharmony_ci switch (v) { 101bf215546Sopenharmony_ci case GL_VERTEX_PROGRAM_ARB: 102bf215546Sopenharmony_ci return MESA_SHADER_VERTEX; 103bf215546Sopenharmony_ci case GL_FRAGMENT_PROGRAM_ARB: 104bf215546Sopenharmony_ci return MESA_SHADER_FRAGMENT; 105bf215546Sopenharmony_ci case GL_FRAGMENT_SHADER_ATI: 106bf215546Sopenharmony_ci return MESA_SHADER_FRAGMENT; 107bf215546Sopenharmony_ci case GL_GEOMETRY_PROGRAM_NV: 108bf215546Sopenharmony_ci return MESA_SHADER_GEOMETRY; 109bf215546Sopenharmony_ci case GL_TESS_CONTROL_PROGRAM_NV: 110bf215546Sopenharmony_ci return MESA_SHADER_TESS_CTRL; 111bf215546Sopenharmony_ci case GL_TESS_EVALUATION_PROGRAM_NV: 112bf215546Sopenharmony_ci return MESA_SHADER_TESS_EVAL; 113bf215546Sopenharmony_ci case GL_COMPUTE_PROGRAM_NV: 114bf215546Sopenharmony_ci return MESA_SHADER_COMPUTE; 115bf215546Sopenharmony_ci default: 116bf215546Sopenharmony_ci assert(0); 117bf215546Sopenharmony_ci return ~0; 118bf215546Sopenharmony_ci } 119bf215546Sopenharmony_ci} 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_cistatic inline GLenum 123bf215546Sopenharmony_ci_mesa_shader_stage_to_program(unsigned stage) 124bf215546Sopenharmony_ci{ 125bf215546Sopenharmony_ci switch (stage) { 126bf215546Sopenharmony_ci case MESA_SHADER_VERTEX: 127bf215546Sopenharmony_ci return GL_VERTEX_PROGRAM_ARB; 128bf215546Sopenharmony_ci case MESA_SHADER_FRAGMENT: 129bf215546Sopenharmony_ci return GL_FRAGMENT_PROGRAM_ARB; 130bf215546Sopenharmony_ci case MESA_SHADER_GEOMETRY: 131bf215546Sopenharmony_ci return GL_GEOMETRY_PROGRAM_NV; 132bf215546Sopenharmony_ci case MESA_SHADER_TESS_CTRL: 133bf215546Sopenharmony_ci return GL_TESS_CONTROL_PROGRAM_NV; 134bf215546Sopenharmony_ci case MESA_SHADER_TESS_EVAL: 135bf215546Sopenharmony_ci return GL_TESS_EVALUATION_PROGRAM_NV; 136bf215546Sopenharmony_ci case MESA_SHADER_COMPUTE: 137bf215546Sopenharmony_ci return GL_COMPUTE_PROGRAM_NV; 138bf215546Sopenharmony_ci } 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_ci assert(!"Unexpected shader stage in _mesa_shader_stage_to_program"); 141bf215546Sopenharmony_ci return GL_VERTEX_PROGRAM_ARB; 142bf215546Sopenharmony_ci} 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ciGLbitfield 146bf215546Sopenharmony_cigl_external_samplers(const struct gl_program *prog); 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_civoid 149bf215546Sopenharmony_ci_mesa_add_separate_state_parameters(struct gl_program *prog, 150bf215546Sopenharmony_ci struct gl_program_parameter_list *state_params); 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci#ifdef __cplusplus 153bf215546Sopenharmony_ci} /* extern "C" */ 154bf215546Sopenharmony_ci#endif 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_ci#endif /* PROGRAM_H */ 157