diff options
| -rw-r--r-- | src/glsl/hash_table.c | 159 | ||||
| -rw-r--r-- | src/glsl/hash_table.h | 125 | ||||
| -rw-r--r-- | src/glsl/main/imports.h | 6 | ||||
| -rw-r--r-- | src/glsl/main/mtypes.h | 270 | ||||
| -rw-r--r-- | src/glsl/main/simple_list.h | 235 | ||||
| -rw-r--r-- | src/glsl/mesa/shader/prog_instruction.c | 363 | ||||
| -rw-r--r-- | src/glsl/mesa/shader/prog_instruction.h | 437 | ||||
| -rw-r--r-- | src/glsl/mesa/shader/prog_print.c | 1089 | ||||
| -rw-r--r-- | src/glsl/mesa/shader/prog_print.h | 98 | ||||
| -rw-r--r-- | src/glsl/symbol_table.c | 413 | ||||
| -rw-r--r-- | src/glsl/symbol_table.h | 66 | 
11 files changed, 0 insertions, 3261 deletions
diff --git a/src/glsl/hash_table.c b/src/glsl/hash_table.c deleted file mode 100644 index e89a2564d7..0000000000 --- a/src/glsl/hash_table.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick <ian.d.romanick@intel.com> - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { -   struct node *next; -   struct node *prev; -}; - -struct hash_table { -    hash_func_t    hash; -    hash_compare_func_t  compare; - -    unsigned num_buckets; -    struct node buckets[1]; -}; - - -struct hash_node { -    struct node link; -    const void *key; -    void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, -                hash_compare_func_t compare) -{ -    struct hash_table *ht; -    unsigned i; - - -    if (num_buckets < 16) { -        num_buckets = 16; -    } - -    ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1)  -				     * sizeof(ht->buckets[0]))); -    if (ht != NULL) { -        ht->hash = hash; -        ht->compare = compare; -        ht->num_buckets = num_buckets; - -        for (i = 0; i < num_buckets; i++) { -            make_empty_list(& ht->buckets[i]); -        } -    } - -    return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ -   hash_table_clear(ht); -   _mesa_free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ -   struct node *node; -   struct node *temp; -   unsigned i; - - -   for (i = 0; i < ht->num_buckets; i++) { -      foreach_s(node, temp, & ht->buckets[i]) { -	 remove_from_list(node); -	 _mesa_free(node); -      } - -      assert(is_empty_list(& ht->buckets[i])); -   } -} - - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ -    const unsigned hash_value = (*ht->hash)(key); -    const unsigned bucket = hash_value % ht->num_buckets; -    struct node *node; - -    foreach(node, & ht->buckets[bucket]) { -       struct hash_node *hn = (struct hash_node *) node; - -       if ((*ht->compare)(hn->key, key) == 0) { -	  return hn->data; -       } -    } - -    return NULL; -} - - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ -    const unsigned hash_value = (*ht->hash)(key); -    const unsigned bucket = hash_value % ht->num_buckets; -    struct hash_node *node; - -    node = _mesa_calloc(sizeof(*node)); - -    node->data = data; -    node->key = key; - -    insert_at_head(& ht->buckets[bucket], & node->link); -} - - -unsigned -hash_table_string_hash(const void *key) -{ -    const char *str = (const char *) key; -    unsigned hash = 5381; - - -    while (*str != '\0') { -        hash = (hash * 33) + *str; -        str++; -    } - -    return hash; -} diff --git a/src/glsl/hash_table.h b/src/glsl/hash_table.h deleted file mode 100644 index b9dd343dee..0000000000 --- a/src/glsl/hash_table.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick <ian.d.romanick@intel.com> - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <string.h> - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets.  The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets  Number of buckets (bins) in the hash table. - * \param hash         Function used to compute hash value of input keys. - * \param compare      Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, -    hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht  Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht   Table to be searched - * \param key  Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added.  If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - */ -extern void hash_table_insert(struct hash_table *ht, void *data, -    const void *key); - - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein.  It was published on comp.lang.c once upon - * a time.  I was unable to find the original posting in the archives. - * - * \param key  Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - -#ifdef __cplusplus -}; -#endif - -#endif /* HASH_TABLE_H */ diff --git a/src/glsl/main/imports.h b/src/glsl/main/imports.h deleted file mode 100644 index d2197342c0..0000000000 --- a/src/glsl/main/imports.h +++ /dev/null @@ -1,6 +0,0 @@ -#include <assert.h> -#include <stdlib.h> - -#define _mesa_malloc(x)   malloc(x) -#define _mesa_free(x)     free(x) -#define _mesa_calloc(x)   calloc(1,x) diff --git a/src/glsl/main/mtypes.h b/src/glsl/main/mtypes.h deleted file mode 100644 index 06e2dd4b54..0000000000 --- a/src/glsl/main/mtypes.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version:  7.7 - * - * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. - * Copyright (C) 2009  VMware, Inc.  All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - -#define MAX_DRAW_BUFFERS 8 -#define MAX_VARYING 16 - -#include <GL/gl.h> - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes.  In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ -   VERT_ATTRIB_POS = 0, -   VERT_ATTRIB_WEIGHT = 1, -   VERT_ATTRIB_NORMAL = 2, -   VERT_ATTRIB_COLOR0 = 3, -   VERT_ATTRIB_COLOR1 = 4, -   VERT_ATTRIB_FOG = 5, -   VERT_ATTRIB_COLOR_INDEX = 6, -   VERT_ATTRIB_POINT_SIZE = 6,  /*alias*/ -   VERT_ATTRIB_EDGEFLAG = 7, -   VERT_ATTRIB_TEX0 = 8, -   VERT_ATTRIB_TEX1 = 9, -   VERT_ATTRIB_TEX2 = 10, -   VERT_ATTRIB_TEX3 = 11, -   VERT_ATTRIB_TEX4 = 12, -   VERT_ATTRIB_TEX5 = 13, -   VERT_ATTRIB_TEX6 = 14, -   VERT_ATTRIB_TEX7 = 15, -   VERT_ATTRIB_GENERIC0 = 16, -   VERT_ATTRIB_GENERIC1 = 17, -   VERT_ATTRIB_GENERIC2 = 18, -   VERT_ATTRIB_GENERIC3 = 19, -   VERT_ATTRIB_GENERIC4 = 20, -   VERT_ATTRIB_GENERIC5 = 21, -   VERT_ATTRIB_GENERIC6 = 22, -   VERT_ATTRIB_GENERIC7 = 23, -   VERT_ATTRIB_GENERIC8 = 24, -   VERT_ATTRIB_GENERIC9 = 25, -   VERT_ATTRIB_GENERIC10 = 26, -   VERT_ATTRIB_GENERIC11 = 27, -   VERT_ATTRIB_GENERIC12 = 28, -   VERT_ATTRIB_GENERIC13 = 29, -   VERT_ATTRIB_GENERIC14 = 30, -   VERT_ATTRIB_GENERIC15 = 31, -   VERT_ATTRIB_MAX = 32 -} gl_vert_attrib; - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS         (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT      (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL      (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0      (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1      (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG         (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG    (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0        (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1        (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2        (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3        (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4        (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5        (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6        (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7        (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0    (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1    (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2    (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3    (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4    (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5    (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6    (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7    (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8    (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9    (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10   (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11   (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12   (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13   (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14   (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15   (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u)  (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g)  (1 << (VERT_ATTRIB_GENERIC0 + (g))) -/*@}*/ - - -/** - * Indexes for vertex program result attributes - */ -typedef enum -{ -   VERT_RESULT_HPOS = 0, -   VERT_RESULT_COL0 = 1, -   VERT_RESULT_COL1 = 2, -   VERT_RESULT_FOGC = 3, -   VERT_RESULT_TEX0 = 4, -   VERT_RESULT_TEX1 = 5, -   VERT_RESULT_TEX2 = 6, -   VERT_RESULT_TEX3 = 7, -   VERT_RESULT_TEX4 = 8, -   VERT_RESULT_TEX5 = 9, -   VERT_RESULT_TEX6 = 10, -   VERT_RESULT_TEX7 = 11, -   VERT_RESULT_PSIZ = 12, -   VERT_RESULT_BFC0 = 13, -   VERT_RESULT_BFC1 = 14, -   VERT_RESULT_EDGE = 15, -   VERT_RESULT_VAR0 = 16,  /**< shader varying */ -   VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/** - * Indexes for fragment program input attributes. - */ -typedef enum -{ -   FRAG_ATTRIB_WPOS = 0, -   FRAG_ATTRIB_COL0 = 1, -   FRAG_ATTRIB_COL1 = 2, -   FRAG_ATTRIB_FOGC = 3, -   FRAG_ATTRIB_TEX0 = 4, -   FRAG_ATTRIB_TEX1 = 5, -   FRAG_ATTRIB_TEX2 = 6, -   FRAG_ATTRIB_TEX3 = 7, -   FRAG_ATTRIB_TEX4 = 8, -   FRAG_ATTRIB_TEX5 = 9, -   FRAG_ATTRIB_TEX6 = 10, -   FRAG_ATTRIB_TEX7 = 11, -   FRAG_ATTRIB_FACE = 12,  /**< front/back face */ -   FRAG_ATTRIB_PNTC = 13,  /**< sprite/point coord */ -   FRAG_ATTRIB_VAR0 = 14,  /**< shader varying */ -   FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -} gl_frag_attrib; - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS  (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0  (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1  (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC  (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE  (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC  (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0  (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1  (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2  (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3  (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4  (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5  (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6  (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7  (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0  (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U)  (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V)  (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0|	\ -			   FRAG_BIT_TEX1|	\ -			   FRAG_BIT_TEX2|	\ -			   FRAG_BIT_TEX3|	\ -			   FRAG_BIT_TEX4|	\ -			   FRAG_BIT_TEX5|	\ -			   FRAG_BIT_TEX6|	\ -			   FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ -   FRAG_RESULT_DEPTH = 0, -   FRAG_RESULT_COLOR = 1, -   FRAG_RESULT_DATA0 = 2, -   FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -} gl_frag_result; - -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ -   PROGRAM_TEMPORARY,   /**< machine->Temporary[] */ -   PROGRAM_INPUT,       /**< machine->Inputs[] */ -   PROGRAM_OUTPUT,      /**< machine->Outputs[] */ -   PROGRAM_VARYING,     /**< machine->Inputs[]/Outputs[] */ -   PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ -   PROGRAM_ENV_PARAM,   /**< gl_program->Parameters[] */ -   PROGRAM_STATE_VAR,   /**< gl_program->Parameters[] */ -   PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ -   PROGRAM_CONSTANT,    /**< gl_program->Parameters[] */ -   PROGRAM_UNIFORM,     /**< gl_program->Parameters[] */ -   PROGRAM_WRITE_ONLY,  /**< A dummy, write-only register */ -   PROGRAM_ADDRESS,     /**< machine->AddressReg */ -   PROGRAM_SAMPLER,     /**< for shader samplers, compile-time only */ -   PROGRAM_UNDEFINED,   /**< Invalid/TBD value */ -   PROGRAM_FILE_MAX -} gl_register_file; - -/** - * An index for each type of texture object.  These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ -   TEXTURE_2D_ARRAY_INDEX, -   TEXTURE_1D_ARRAY_INDEX, -   TEXTURE_CUBE_INDEX, -   TEXTURE_3D_INDEX, -   TEXTURE_RECT_INDEX, -   TEXTURE_2D_INDEX, -   TEXTURE_1D_INDEX, -   NUM_TEXTURE_TARGETS -} gl_texture_index; - -#endif /* MTYPES_H */ diff --git a/src/glsl/main/simple_list.h b/src/glsl/main/simple_list.h deleted file mode 100644 index 5ef39e14cc..0000000000 --- a/src/glsl/main/simple_list.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - *  Intended to work with a list sentinal which is created as an empty - *  list.  Insert & delete are O(1). - *   - * \author - *  (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version:  3.5 - * - * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _SIMPLE_LIST_H -#define _SIMPLE_LIST_H - -struct simple_node { -   struct simple_node *next; -   struct simple_node *prev; -}; - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem)			\ -do {						\ -   (elem)->next->prev = (elem)->prev;		\ -   (elem)->prev->next = (elem)->next;		\ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem)		\ -do {						\ -   (elem)->prev = list;				\ -   (elem)->next = (list)->next;			\ -   (list)->next->prev = elem;			\ -   (list)->next = elem;				\ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem)		\ -do {						\ -   (elem)->next = list;				\ -   (elem)->prev = (list)->prev;			\ -   (list)->prev->next = elem;			\ -   (list)->prev = elem;				\ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem)		\ -do {						\ -   remove_from_list(elem);			\ -   insert_at_head(list, elem);			\ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem)		\ -do {						\ -   remove_from_list(elem);			\ -   insert_at_tail(list, elem);			\ -} while (0) - -/** - * Consatinate a cyclic list to a list - * - * Appends the sequence of nodes starting with \c tail to the list \c head. - * A "cyclic list" is a list that does not have a sentinal node.  This means - * that the data pointed to by \c tail is an actual node, not a dataless - * sentinal.  Note that if \c tail constist of a single node, this macro - * behaves identically to \c insert_at_tail - * - * \param head Head of the list to be appended to.  This may or may not - *             be a cyclic list. - * \param tail Head of the cyclic list to be appended to \c head. - * \param temp Temporary \c simple_list used by the macro - * - * \sa insert_at_tail - */ -#define concat_list_and_cycle(head, tail, temp)	\ -do {						\ -   (head)->prev->next = (tail);			\ -   (tail)->prev->next = (head);			\ -   (temp) = (head)->prev;			\ -   (head)->prev = (tail)->prev;			\ -   (tail)->prev = (temp);			\ -} while (0) - -#define concat_list(head, next_list)		\ -do {						\ -   (next_list)->next->prev = (head)->prev;	\ -   (next_list)->prev->next = (head);		\ -   (head)->prev->next = (next_list)->next;	\ -   (head)->prev = (next_list)->prev;		\ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal)		\ -do {						\ -   (sentinal)->next = sentinal;			\ -   (sentinal)->prev = sentinal;			\ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list)       ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list)        ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem)        ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem)        ((elem)->prev) - -/** - * Test whether element is at end of the list. - *  - * \param list list. - * \param elem element. - *  - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem)     ((elem) == (list)) - -/** - * Test if a list is empty. - *  - * \param list list. - *  - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list)    ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list)     \ -        for( ptr=(list)->next ;  ptr!=list ;  ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal.  Useful for freeing a list, element by element. - *  - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list)   \ -        for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif diff --git a/src/glsl/mesa/shader/prog_instruction.c b/src/glsl/mesa/shader/prog_instruction.c deleted file mode 100644 index fbcf868f50..0000000000 --- a/src/glsl/mesa/shader/prog_instruction.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version:  7.3 - * - * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. - * Copyright (C) 1999-2009  VMware, Inc.  All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#define _GNU_SOURCE -#include <stdio.h> -#include <string.h> -#include <assert.h> - -#if 0 -#include "main/glheader.h" -#else -#define _mesa_strdup strdup -#define _mesa_snprintf snprintf -#define ASSERT assert -#endif -#include "main/imports.h" -#include "main/mtypes.h" -#include "prog_instruction.h" - - -/** - * Initialize program instruction fields to defaults. - * \param inst  first instruction to initialize - * \param count  number of instructions to initialize - */ -void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count) -{ -   GLuint i; - -   memset(inst, 0, count * sizeof(struct prog_instruction)); - -   for (i = 0; i < count; i++) { -      inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; -      inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; -      inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; -      inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; -      inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; -      inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; - -      inst[i].DstReg.File = PROGRAM_UNDEFINED; -      inst[i].DstReg.WriteMask = WRITEMASK_XYZW; -      inst[i].DstReg.CondMask = COND_TR; -      inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; - -      inst[i].SaturateMode = SATURATE_OFF; -      inst[i].Precision = FLOAT32; -   } -} - - -/** - * Allocate an array of program instructions. - * \param numInst  number of instructions - * \return pointer to instruction memory - */ -struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst) -{ -   return (struct prog_instruction *) -      calloc(1, numInst * sizeof(struct prog_instruction)); -} - - -/** - * Reallocate memory storing an array of program instructions. - * This is used when we need to append additional instructions onto an - * program. - * \param oldInst  pointer to first of old/src instructions - * \param numOldInst  number of instructions at <oldInst> - * \param numNewInst  desired size of new instruction array. - * \return  pointer to start of new instruction array. - */ -struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, -                           GLuint numOldInst, GLuint numNewInst) -{ -   struct prog_instruction *newInst; - -   (void)numOldInst; -   newInst = (struct prog_instruction *) -      realloc(oldInst, -	      numNewInst * sizeof(struct prog_instruction)); - -   return newInst; -} - - -/** - * Copy an array of program instructions. - * \param dest  pointer to destination. - * \param src  pointer to source. - * \param n  number of instructions to copy. - * \return pointer to destination. - */ -struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, -                        const struct prog_instruction *src, GLuint n) -{ -   GLuint i; -   memcpy(dest, src, n * sizeof(struct prog_instruction)); -   for (i = 0; i < n; i++) { -      if (src[i].Comment) -         dest[i].Comment = _mesa_strdup(src[i].Comment); -   } -   return dest; -} - - -/** - * Free an array of instructions - */ -void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count) -{ -   GLuint i; -   for (i = 0; i < count; i++) { -      if (inst[i].Data) -         free(inst[i].Data); -      if (inst[i].Comment) -         free((char *) inst[i].Comment); -   } -   free(inst); -} - - -/** - * Basic info about each instruction - */ -struct instruction_info -{ -   gl_inst_opcode Opcode; -   const char *Name; -   GLuint NumSrcRegs; -   GLuint NumDstRegs; -}; - -/** - * Instruction info - * \note Opcode should equal array index! - */ -static const struct instruction_info InstInfo[MAX_OPCODE] = { -   { OPCODE_NOP,    "NOP",     0, 0 }, -   { OPCODE_ABS,    "ABS",     1, 1 }, -   { OPCODE_ADD,    "ADD",     2, 1 }, -   { OPCODE_AND,    "AND",     2, 1 }, -   { OPCODE_ARA,    "ARA",     1, 1 }, -   { OPCODE_ARL,    "ARL",     1, 1 }, -   { OPCODE_ARL_NV, "ARL_NV",  1, 1 }, -   { OPCODE_ARR,    "ARL",     1, 1 }, -   { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, -   { OPCODE_BGNSUB, "BGNSUB",  0, 0 }, -   { OPCODE_BRA,    "BRA",     0, 0 }, -   { OPCODE_BRK,    "BRK",     0, 0 }, -   { OPCODE_CAL,    "CAL",     0, 0 }, -   { OPCODE_CMP,    "CMP",     3, 1 }, -   { OPCODE_CONT,   "CONT",    0, 0 }, -   { OPCODE_COS,    "COS",     1, 1 }, -   { OPCODE_DDX,    "DDX",     1, 1 }, -   { OPCODE_DDY,    "DDY",     1, 1 }, -   { OPCODE_DP2,    "DP2",     2, 1 }, -   { OPCODE_DP2A,   "DP2A",    3, 1 }, -   { OPCODE_DP3,    "DP3",     2, 1 }, -   { OPCODE_DP4,    "DP4",     2, 1 }, -   { OPCODE_DPH,    "DPH",     2, 1 }, -   { OPCODE_DST,    "DST",     2, 1 }, -   { OPCODE_ELSE,   "ELSE",    0, 0 }, -   { OPCODE_END,    "END",     0, 0 }, -   { OPCODE_ENDIF,  "ENDIF",   0, 0 }, -   { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, -   { OPCODE_ENDSUB, "ENDSUB",  0, 0 }, -   { OPCODE_EX2,    "EX2",     1, 1 }, -   { OPCODE_EXP,    "EXP",     1, 1 }, -   { OPCODE_FLR,    "FLR",     1, 1 }, -   { OPCODE_FRC,    "FRC",     1, 1 }, -   { OPCODE_IF,     "IF",      1, 0 }, -   { OPCODE_KIL,    "KIL",     1, 0 }, -   { OPCODE_KIL_NV, "KIL_NV",  0, 0 }, -   { OPCODE_LG2,    "LG2",     1, 1 }, -   { OPCODE_LIT,    "LIT",     1, 1 }, -   { OPCODE_LOG,    "LOG",     1, 1 }, -   { OPCODE_LRP,    "LRP",     3, 1 }, -   { OPCODE_MAD,    "MAD",     3, 1 }, -   { OPCODE_MAX,    "MAX",     2, 1 }, -   { OPCODE_MIN,    "MIN",     2, 1 }, -   { OPCODE_MOV,    "MOV",     1, 1 }, -   { OPCODE_MUL,    "MUL",     2, 1 }, -   { OPCODE_NOISE1, "NOISE1",  1, 1 }, -   { OPCODE_NOISE2, "NOISE2",  1, 1 }, -   { OPCODE_NOISE3, "NOISE3",  1, 1 }, -   { OPCODE_NOISE4, "NOISE4",  1, 1 }, -   { OPCODE_NOT,    "NOT",     1, 1 }, -   { OPCODE_NRM3,   "NRM3",    1, 1 }, -   { OPCODE_NRM4,   "NRM4",    1, 1 }, -   { OPCODE_OR,     "OR",      2, 1 }, -   { OPCODE_PK2H,   "PK2H",    1, 1 }, -   { OPCODE_PK2US,  "PK2US",   1, 1 }, -   { OPCODE_PK4B,   "PK4B",    1, 1 }, -   { OPCODE_PK4UB,  "PK4UB",   1, 1 }, -   { OPCODE_POW,    "POW",     2, 1 }, -   { OPCODE_POPA,   "POPA",    0, 0 }, -   { OPCODE_PRINT,  "PRINT",   1, 0 }, -   { OPCODE_PUSHA,  "PUSHA",   0, 0 }, -   { OPCODE_RCC,    "RCC",     1, 1 }, -   { OPCODE_RCP,    "RCP",     1, 1 }, -   { OPCODE_RET,    "RET",     0, 0 }, -   { OPCODE_RFL,    "RFL",     1, 1 }, -   { OPCODE_RSQ,    "RSQ",     1, 1 }, -   { OPCODE_SCS,    "SCS",     1, 1 }, -   { OPCODE_SEQ,    "SEQ",     2, 1 }, -   { OPCODE_SFL,    "SFL",     0, 1 }, -   { OPCODE_SGE,    "SGE",     2, 1 }, -   { OPCODE_SGT,    "SGT",     2, 1 }, -   { OPCODE_SIN,    "SIN",     1, 1 }, -   { OPCODE_SLE,    "SLE",     2, 1 }, -   { OPCODE_SLT,    "SLT",     2, 1 }, -   { OPCODE_SNE,    "SNE",     2, 1 }, -   { OPCODE_SSG,    "SSG",     1, 1 }, -   { OPCODE_STR,    "STR",     0, 1 }, -   { OPCODE_SUB,    "SUB",     2, 1 }, -   { OPCODE_SWZ,    "SWZ",     1, 1 }, -   { OPCODE_TEX,    "TEX",     1, 1 }, -   { OPCODE_TXB,    "TXB",     1, 1 }, -   { OPCODE_TXD,    "TXD",     3, 1 }, -   { OPCODE_TXL,    "TXL",     1, 1 }, -   { OPCODE_TXP,    "TXP",     1, 1 }, -   { OPCODE_TXP_NV, "TXP_NV",  1, 1 }, -   { OPCODE_TRUNC,  "TRUNC",   1, 1 }, -   { OPCODE_UP2H,   "UP2H",    1, 1 }, -   { OPCODE_UP2US,  "UP2US",   1, 1 }, -   { OPCODE_UP4B,   "UP4B",    1, 1 }, -   { OPCODE_UP4UB,  "UP4UB",   1, 1 }, -   { OPCODE_X2D,    "X2D",     3, 1 }, -   { OPCODE_XOR,    "XOR",     2, 1 }, -   { OPCODE_XPD,    "XPD",     2, 1 } -}; - - -/** - * Return the number of src registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode) -{ -   ASSERT(opcode < MAX_OPCODE); -   ASSERT(opcode == InstInfo[opcode].Opcode); -   ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); -   return InstInfo[opcode].NumSrcRegs; -} - - -/** - * Return the number of dst registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode) -{ -   ASSERT(opcode < MAX_OPCODE); -   ASSERT(opcode == InstInfo[opcode].Opcode); -   ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); -   return InstInfo[opcode].NumDstRegs; -} - - -GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode) -{ -   return (opcode == OPCODE_TEX || -           opcode == OPCODE_TXB || -           opcode == OPCODE_TXD || -           opcode == OPCODE_TXL || -           opcode == OPCODE_TXP); -} - - -/** - * Check if there's a potential src/dst register data dependency when - * using SOA execution. - * Example: - *   MOV T, T.yxwz; - * This would expand into: - *   MOV t0, t1; - *   MOV t1, t0; - *   MOV t2, t3; - *   MOV t3, t2; - * The second instruction will have the wrong value for t0 if executed as-is. - */ -GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst) -{ -   GLuint i, chan; - -   if (inst->DstReg.WriteMask == WRITEMASK_X || -       inst->DstReg.WriteMask == WRITEMASK_Y || -       inst->DstReg.WriteMask == WRITEMASK_Z || -       inst->DstReg.WriteMask == WRITEMASK_W || -       inst->DstReg.WriteMask == 0x0) { -      /* no chance of data dependency */ -      return GL_FALSE; -   } - -   /* loop over src regs */ -   for (i = 0; i < 3; i++) { -      if (inst->SrcReg[i].File == inst->DstReg.File && -          inst->SrcReg[i].Index == inst->DstReg.Index) { -         /* loop over dest channels */ -         GLuint channelsWritten = 0x0; -         for (chan = 0; chan < 4; chan++) { -            if (inst->DstReg.WriteMask & (1 << chan)) { -               /* check if we're reading a channel that's been written */ -               GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); -               if (swizzle <= SWIZZLE_W && -                   (channelsWritten & (1 << swizzle))) { -                  return GL_TRUE; -               } - -               channelsWritten |= (1 << chan); -            } -         } -      } -   } -   return GL_FALSE; -} - - -/** - * Return string name for given program opcode. - */ -const char * -_mesa_opcode_string(gl_inst_opcode opcode) -{ -   if (opcode < MAX_OPCODE) -      return InstInfo[opcode].Name; -   else { -      static char s[20]; -      _mesa_snprintf(s, sizeof(s), "OP%u", opcode); -      return s; -   } -} - diff --git a/src/glsl/mesa/shader/prog_instruction.h b/src/glsl/mesa/shader/prog_instruction.h deleted file mode 100644 index 2c95d274ca..0000000000 --- a/src/glsl/mesa/shader/prog_instruction.h +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version:  7.3 - * - * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file prog_instruction.h - * - * Vertex/fragment program instruction datatypes and constants. - * - * \author Brian Paul - * \author Keith Whitwell - * \author Ian Romanick <idr@us.ibm.com> - */ - - -#ifndef PROG_INSTRUCTION_H -#define PROG_INSTRUCTION_H - - -#include "main/mtypes.h" - - -/** - * Swizzle indexes. - * Do not change! - */ -/*@{*/ -#define SWIZZLE_X    0 -#define SWIZZLE_Y    1 -#define SWIZZLE_Z    2 -#define SWIZZLE_W    3 -#define SWIZZLE_ZERO 4   /**< For SWZ instruction only */ -#define SWIZZLE_ONE  5   /**< For SWZ instruction only */ -#define SWIZZLE_NIL  7   /**< used during shader code gen (undefined value) */ -/*@}*/ - -#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) -#define SWIZZLE_NOOP           MAKE_SWIZZLE4(0,1,2,3) -#define GET_SWZ(swz, idx)      (((swz) >> ((idx)*3)) & 0x7) -#define GET_BIT(msk, idx)      (((msk) >> (idx)) & 0x1) - -#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) -#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) -#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) -#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) -#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) - - -/** - * Writemask values, 1 bit per component. - */ -/*@{*/ -#define WRITEMASK_X     0x1 -#define WRITEMASK_Y     0x2 -#define WRITEMASK_XY    0x3 -#define WRITEMASK_Z     0x4 -#define WRITEMASK_XZ    0x5 -#define WRITEMASK_YZ    0x6 -#define WRITEMASK_XYZ   0x7 -#define WRITEMASK_W     0x8 -#define WRITEMASK_XW    0x9 -#define WRITEMASK_YW    0xa -#define WRITEMASK_XYW   0xb -#define WRITEMASK_ZW    0xc -#define WRITEMASK_XZW   0xd -#define WRITEMASK_YZW   0xe -#define WRITEMASK_XYZW  0xf -/*@}*/ - - -/** - * Condition codes - */ -/*@{*/ -#define COND_GT  1  /**< greater than zero */ -#define COND_EQ  2  /**< equal to zero */ -#define COND_LT  3  /**< less than zero */ -#define COND_UN  4  /**< unordered (NaN) */ -#define COND_GE  5  /**< greater than or equal to zero */ -#define COND_LE  6  /**< less than or equal to zero */ -#define COND_NE  7  /**< not equal to zero */ -#define COND_TR  8  /**< always true */ -#define COND_FL  9  /**< always false */ -/*@}*/ - - -/** - * Instruction precision for GL_NV_fragment_program - */ -/*@{*/ -#define FLOAT32  0x1 -#define FLOAT16  0x2 -#define FIXED12  0x4 -/*@}*/ - - -/** - * Saturation modes when storing values. - */ -/*@{*/ -#define SATURATE_OFF            0 -#define SATURATE_ZERO_ONE       1 -/*@}*/ - - -/** - * Per-component negation masks - */ -/*@{*/ -#define NEGATE_X    0x1 -#define NEGATE_Y    0x2 -#define NEGATE_Z    0x4 -#define NEGATE_W    0x8 -#define NEGATE_XYZ  0x7 -#define NEGATE_XYZW 0xf -#define NEGATE_NONE 0x0 -/*@}*/ - - -/** - * Program instruction opcodes, for both vertex and fragment programs. - * \note changes to this opcode list must be reflected in t_vb_arbprogram.c - */ -typedef enum prog_opcode { -                     /* ARB_vp   ARB_fp   NV_vp   NV_fp     GLSL */ -                     /*------------------------------------------*/ -   OPCODE_NOP = 0,   /*                                      X   */ -   OPCODE_ABS,       /*   X        X       1.1               X   */ -   OPCODE_ADD,       /*   X        X       X       X         X   */ -   OPCODE_AND,       /*                                          */ -   OPCODE_ARA,       /*                    2                     */ -   OPCODE_ARL,       /*   X                X                     */ -   OPCODE_ARL_NV,    /*                    2                     */ -   OPCODE_ARR,       /*                    2                     */ -   OPCODE_BGNLOOP,   /*                                     opt  */ -   OPCODE_BGNSUB,    /*                                     opt  */ -   OPCODE_BRA,       /*                    2                 X   */ -   OPCODE_BRK,       /*                    2                opt  */ -   OPCODE_CAL,       /*                    2       2             */ -   OPCODE_CMP,       /*            X                             */ -   OPCODE_CONT,      /*                                     opt  */ -   OPCODE_COS,       /*            X       2       X         X   */ -   OPCODE_DDX,       /*                            X         X   */ -   OPCODE_DDY,       /*                            X         X   */ -   OPCODE_DP2,       /*                            2             */ -   OPCODE_DP2A,      /*                            2             */ -   OPCODE_DP3,       /*   X        X       X       X         X   */ -   OPCODE_DP4,       /*   X        X       X       X         X   */ -   OPCODE_DPH,       /*   X        X       1.1                   */ -   OPCODE_DST,       /*   X        X       X       X             */ -   OPCODE_ELSE,      /*                                      X   */ -   OPCODE_END,       /*   X        X       X       X        opt  */ -   OPCODE_ENDIF,     /*                                     opt  */ -   OPCODE_ENDLOOP,   /*                                     opt  */ -   OPCODE_ENDSUB,    /*                                     opt  */ -   OPCODE_EX2,       /*   X        X       2       X         X   */ -   OPCODE_EXP,       /*   X                X                 X   */ -   OPCODE_FLR,       /*   X        X       2       X         X   */ -   OPCODE_FRC,       /*   X        X       2       X         X   */ -   OPCODE_IF,        /*                                     opt  */ -   OPCODE_KIL,       /*            X                             */ -   OPCODE_KIL_NV,    /*                            X         X   */ -   OPCODE_LG2,       /*   X        X       2       X         X   */ -   OPCODE_LIT,       /*   X        X       X       X             */ -   OPCODE_LOG,       /*   X                X                 X   */ -   OPCODE_LRP,       /*            X               X             */ -   OPCODE_MAD,       /*   X        X       X       X         X   */ -   OPCODE_MAX,       /*   X        X       X       X         X   */ -   OPCODE_MIN,       /*   X        X       X       X         X   */ -   OPCODE_MOV,       /*   X        X       X       X         X   */ -   OPCODE_MUL,       /*   X        X       X       X         X   */ -   OPCODE_NOISE1,    /*                                      X   */ -   OPCODE_NOISE2,    /*                                      X   */ -   OPCODE_NOISE3,    /*                                      X   */ -   OPCODE_NOISE4,    /*                                      X   */ -   OPCODE_NOT,       /*                                          */ -   OPCODE_NRM3,      /*                                          */ -   OPCODE_NRM4,      /*                                          */ -   OPCODE_OR,        /*                                          */ -   OPCODE_PK2H,      /*                            X             */ -   OPCODE_PK2US,     /*                            X             */ -   OPCODE_PK4B,      /*                            X             */ -   OPCODE_PK4UB,     /*                            X             */ -   OPCODE_POW,       /*   X        X               X         X   */ -   OPCODE_POPA,      /*                    3                     */ -   OPCODE_PRINT,     /*                    X       X             */ -   OPCODE_PUSHA,     /*                    3                     */ -   OPCODE_RCC,       /*                    1.1                   */ -   OPCODE_RCP,       /*   X        X       X       X         X   */ -   OPCODE_RET,       /*                    2       2             */ -   OPCODE_RFL,       /*            X               X             */ -   OPCODE_RSQ,       /*   X        X       X       X         X   */ -   OPCODE_SCS,       /*            X                             */ -   OPCODE_SEQ,       /*                    2       X         X   */ -   OPCODE_SFL,       /*                    2       X             */ -   OPCODE_SGE,       /*   X        X       X       X         X   */ -   OPCODE_SGT,       /*                    2       X         X   */ -   OPCODE_SIN,       /*            X       2       X         X   */ -   OPCODE_SLE,       /*                    2       X         X   */ -   OPCODE_SLT,       /*   X        X       X       X         X   */ -   OPCODE_SNE,       /*                    2       X         X   */ -   OPCODE_SSG,       /*                    2                     */ -   OPCODE_STR,       /*                    2       X             */ -   OPCODE_SUB,       /*   X        X       1.1     X         X   */ -   OPCODE_SWZ,       /*   X        X                             */ -   OPCODE_TEX,       /*            X       3       X         X   */ -   OPCODE_TXB,       /*            X       3                 X   */ -   OPCODE_TXD,       /*                            X         X   */ -   OPCODE_TXL,       /*                    3       2         X   */ -   OPCODE_TXP,       /*            X                         X   */ -   OPCODE_TXP_NV,    /*                    3       X             */ -   OPCODE_TRUNC,     /*                                      X   */ -   OPCODE_UP2H,      /*                            X             */ -   OPCODE_UP2US,     /*                            X             */ -   OPCODE_UP4B,      /*                            X             */ -   OPCODE_UP4UB,     /*                            X             */ -   OPCODE_X2D,       /*                            X             */ -   OPCODE_XOR,       /*                                          */ -   OPCODE_XPD,       /*   X        X                         X   */ -   MAX_OPCODE -} gl_inst_opcode; - - -/** - * Number of bits for the src/dst register Index field. - * This limits the size of temp/uniform register files. - */ -#define INST_INDEX_BITS 10 - - -/** - * Instruction source register. - */ -struct prog_src_register -{ -   GLuint File:4;	/**< One of the PROGRAM_* register file values. */ -   GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. -                                     * May be negative for relative addressing. -                                     */ -   GLuint Swizzle:12; -   GLuint RelAddr:1; - -   /** Take the component-wise absolute value */ -   GLuint Abs:1; - -   /** -    * Post-Abs negation. -    * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ -    * instruction which allows per-component negation. -    */ -   GLuint Negate:4; -}; - - -/** - * Instruction destination register. - */ -struct prog_dst_register -{ -   GLuint File:4;      /**< One of the PROGRAM_* register file values */ -   GLuint Index:INST_INDEX_BITS;  /**< Unsigned, never negative */ -   GLuint WriteMask:4; -   GLuint RelAddr:1; - -   /** -    * \name Conditional destination update control. -    * -    * \since -    * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, -    * NV_vertex_program2_option. -    */ -   /*@{*/ -   /** -    * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, -    * NE, TR, or UN).  Dest reg is only written to if the matching -    * (swizzled) condition code value passes.  When a conditional update mask -    * is not specified, this will be \c COND_TR. -    */ -   GLuint CondMask:4; - -   /** -    * Condition code swizzle value. -    */ -   GLuint CondSwizzle:12; - -   /** -    * Selects the condition code register to use for conditional destination -    * update masking.  In NV_fragmnet_program or NV_vertex_program2 mode, only -    * condition code register 0 is available.  In NV_vertex_program3 mode, -    * condition code registers 0 and 1 are available. -    */ -   GLuint CondSrc:1; -   /*@}*/ -}; - - -/** - * Vertex/fragment program instruction. - */ -struct prog_instruction -{ -   gl_inst_opcode Opcode; -   struct prog_src_register SrcReg[3]; -   struct prog_dst_register DstReg; - -   /** -    * Indicates that the instruction should update the condition code -    * register. -    * -    * \since -    * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, -    * NV_vertex_program2_option. -    */ -   GLuint CondUpdate:1; - -   /** -    * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the -    * condition code register that is to be updated. -    * -    * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition -    * code register 0 is available.  In GL_NV_vertex_program3 mode, condition -    * code registers 0 and 1 are available. -    * -    * \since -    * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, -    * NV_vertex_program2_option. -    */ -   GLuint CondDst:1; - -   /** -    * Saturate each value of the vectored result to the range [0,1] or the -    * range [-1,1].  \c SSAT mode (i.e., saturation to the range [-1,1]) is -    * only available in NV_fragment_program2 mode. -    * Value is one of the SATURATE_* tokens. -    * -    * \since -    * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. -    */ -   GLuint SaturateMode:2; - -   /** -    * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. -    * -    * \since -    * NV_fragment_program, NV_fragment_program_option. -    */ -   GLuint Precision:3; - -   /** -    * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. -    */ -   /*@{*/ -   /** Source texture unit. */ -   GLuint TexSrcUnit:5; - -   /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ -   GLuint TexSrcTarget:3; - -   /** True if tex instruction should do shadow comparison */ -   GLuint TexShadow:1; -   /*@}*/ - -   /** -    * For BRA and CAL instructions, the location to jump to. -    * For BGNLOOP, points to ENDLOOP (and vice-versa). -    * For BRK, points to BGNLOOP (which points to ENDLOOP). -    * For IF, points to ELSE or ENDIF. -    * For ELSE, points to ENDIF. -    */ -   GLint BranchTarget; - -   /** for debugging purposes */ -   const char *Comment; - -   /** Arbitrary data.  Used for OPCODE_PRINT and some drivers */ -   void *Data; - -   /** for driver use (try to remove someday) */ -   GLint Aux; -}; - - -extern void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count); - -extern struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst); - -extern struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, -                           GLuint numOldInst, GLuint numNewInst); - -extern struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, -                        const struct prog_instruction *src, GLuint n); - -extern void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count); - -extern GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode); - -extern GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode); - -extern GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode); - -extern GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst); - -extern const char * -_mesa_opcode_string(gl_inst_opcode opcode); - - -#endif /* PROG_INSTRUCTION_H */ diff --git a/src/glsl/mesa/shader/prog_print.c b/src/glsl/mesa/shader/prog_print.c deleted file mode 100644 index 3f1cb48e4b..0000000000 --- a/src/glsl/mesa/shader/prog_print.c +++ /dev/null @@ -1,1089 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version:  7.3 - * - * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. - * Copyright (C) 2009  VMware, Inc.  All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file prog_print.c - * Print vertex/fragment programs - for debugging. - * \author Brian Paul - */ - -#if 0 -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#else - -#define _GNU_SOURCE - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> -struct gl_program { -   int Target; -}; - -void _mesa_problem(void *ctx, char *msg) -{ -   (void)ctx; -   fprintf(stderr, "%s", msg); -   exit(1); -} - -#endif - -#include "prog_instruction.h" -#include "prog_print.h" - - - -/** - * Return string name for given program/register file. - */ -static const char * -file_string(gl_register_file f, gl_prog_print_mode mode) -{ -   (void)mode; -   switch (f) { -   case PROGRAM_TEMPORARY: -      return "TEMP"; -   case PROGRAM_LOCAL_PARAM: -      return "LOCAL"; -   case PROGRAM_ENV_PARAM: -      return "ENV"; -   case PROGRAM_STATE_VAR: -      return "STATE"; -   case PROGRAM_INPUT: -      return "INPUT"; -   case PROGRAM_OUTPUT: -      return "OUTPUT"; -   case PROGRAM_NAMED_PARAM: -      return "NAMED"; -   case PROGRAM_CONSTANT: -      return "CONST"; -   case PROGRAM_UNIFORM: -      return "UNIFORM"; -   case PROGRAM_VARYING: -      return "VARYING"; -   case PROGRAM_WRITE_ONLY: -      return "WRITE_ONLY"; -   case PROGRAM_ADDRESS: -      return "ADDR"; -   case PROGRAM_SAMPLER: -      return "SAMPLER"; -   case PROGRAM_UNDEFINED: -      return "UNDEFINED"; -   default: -      { -         static char s[20]; -         snprintf(s, sizeof(s), "FILE%u", f); -         return s; -      } -   } -} - - -/** - * Return ARB_v/f_prog-style input attrib string. - */ -static const char * -arb_input_attrib_string(GLint index, GLenum progType) -{ -   /* -    * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. -    */ -   const char *vertAttribs[] = { -      "vertex.position", -      "vertex.weight", -      "vertex.normal", -      "vertex.color.primary", -      "vertex.color.secondary", -      "vertex.fogcoord", -      "vertex.(six)", -      "vertex.(seven)", -      "vertex.texcoord[0]", -      "vertex.texcoord[1]", -      "vertex.texcoord[2]", -      "vertex.texcoord[3]", -      "vertex.texcoord[4]", -      "vertex.texcoord[5]", -      "vertex.texcoord[6]", -      "vertex.texcoord[7]", -      "vertex.attrib[0]", -      "vertex.attrib[1]", -      "vertex.attrib[2]", -      "vertex.attrib[3]", -      "vertex.attrib[4]", -      "vertex.attrib[5]", -      "vertex.attrib[6]", -      "vertex.attrib[7]", -      "vertex.attrib[8]", -      "vertex.attrib[9]", -      "vertex.attrib[10]", -      "vertex.attrib[11]", -      "vertex.attrib[12]", -      "vertex.attrib[13]", -      "vertex.attrib[14]", -      "vertex.attrib[15]" -   }; -   const char *fragAttribs[] = { -      "fragment.position", -      "fragment.color.primary", -      "fragment.color.secondary", -      "fragment.fogcoord", -      "fragment.texcoord[0]", -      "fragment.texcoord[1]", -      "fragment.texcoord[2]", -      "fragment.texcoord[3]", -      "fragment.texcoord[4]", -      "fragment.texcoord[5]", -      "fragment.texcoord[6]", -      "fragment.texcoord[7]", -      "fragment.varying[0]", -      "fragment.varying[1]", -      "fragment.varying[2]", -      "fragment.varying[3]", -      "fragment.varying[4]", -      "fragment.varying[5]", -      "fragment.varying[6]", -      "fragment.varying[7]" -   }; - -   /* sanity checks */ -   assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); -   assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); - -   if (progType == GL_VERTEX_PROGRAM_ARB) { -      assert((unsigned int)index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); -      return vertAttribs[index]; -   } -   else { -      assert((unsigned int)index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); -      return fragAttribs[index]; -   } -} - - -/** - * Print a vertex program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_vp_inputs(GLbitfield inputs) -{ -   printf("VP Inputs 0x%x: \n", inputs); -   while (inputs) { -      GLint attr = ffs(inputs) - 1; -      const char *name = arb_input_attrib_string(attr, -                                                 GL_VERTEX_PROGRAM_ARB); -      printf("  %d: %s\n", attr, name); -      inputs &= ~(1 << attr); -   } -} - - -/** - * Print a fragment program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_fp_inputs(GLbitfield inputs) -{ -   printf("FP Inputs 0x%x: \n", inputs); -   while (inputs) { -      GLint attr = ffs(inputs) - 1; -      const char *name = arb_input_attrib_string(attr, -                                                 GL_FRAGMENT_PROGRAM_ARB); -      printf("  %d: %s\n", attr, name); -      inputs &= ~(1 << attr); -   } -} - - -#if 0 -/** - * Return ARB_v/f_prog-style output attrib string. - */ -static const char * -arb_output_attrib_string(GLint index, GLenum progType) -{ -   /* -    * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. -    */ -   const char *vertResults[] = { -      "result.position", -      "result.color.primary", -      "result.color.secondary", -      "result.fogcoord", -      "result.texcoord[0]", -      "result.texcoord[1]", -      "result.texcoord[2]", -      "result.texcoord[3]", -      "result.texcoord[4]", -      "result.texcoord[5]", -      "result.texcoord[6]", -      "result.texcoord[7]", -      "result.varying[0]", -      "result.varying[1]", -      "result.varying[2]", -      "result.varying[3]", -      "result.varying[4]", -      "result.varying[5]", -      "result.varying[6]", -      "result.varying[7]" -   }; -   const char *fragResults[] = { -      "result.color", -      "result.color(half)", -      "result.depth", -      "result.color[0]", -      "result.color[1]", -      "result.color[2]", -      "result.color[3]" -   }; - -   if (progType == GL_VERTEX_PROGRAM_ARB) { -      assert(index < sizeof(vertResults) / sizeof(vertResults[0])); -      return vertResults[index]; -   } -   else { -      assert(index < sizeof(fragResults) / sizeof(fragResults[0])); -      return fragResults[index]; -   } -} -#endif - -/** - * Return string representation of the given register. - * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined - * by the ARB/NV program languages so we've taken some liberties here. - * \param f  the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) - * \param index  number of the register in the register file - * \param mode  the output format/mode/style - * \param prog  pointer to containing program - */ -static const char * -reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, -           GLboolean relAddr, const struct gl_program *prog) -{ -   static char str[100]; -   const char *addr = relAddr ? "ADDR+" : ""; - -   str[0] = 0; - -   switch (mode) { -   case PROG_PRINT_DEBUG: -      sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); -      break; -   case PROG_PRINT_ARB: -#if 0 -      switch (f) { -      case PROGRAM_INPUT: -         sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); -         break; -      case PROGRAM_OUTPUT: -         sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); -         break; -      case PROGRAM_TEMPORARY: -         sprintf(str, "temp%d", index); -         break; -      case PROGRAM_ENV_PARAM: -         sprintf(str, "program.env[%s%d]", addr, index); -         break; -      case PROGRAM_LOCAL_PARAM: -         sprintf(str, "program.local[%s%d]", addr, index); -         break; -      case PROGRAM_VARYING: /* extension */ -         sprintf(str, "varying[%s%d]", addr, index); -         break; -      case PROGRAM_CONSTANT: /* extension */ -         sprintf(str, "constant[%s%d]", addr, index); -         break; -      case PROGRAM_UNIFORM: /* extension */ -         sprintf(str, "uniform[%s%d]", addr, index); -         break; -      case PROGRAM_STATE_VAR: -         { -            struct gl_program_parameter *param -               = prog->Parameters->Parameters + index; -            char *state = _mesa_program_state_string(param->StateIndexes); -            sprintf(str, "%s", state); -            free(state); -         } -         break; -      case PROGRAM_ADDRESS: -         sprintf(str, "A%d", index); -         break; -      default: -         _mesa_problem(NULL, "bad file in reg_string()"); -      } -      break; -#else -      assert(0); -      break; -#endif - -   case PROG_PRINT_NV: -      switch (f) { -      case PROGRAM_INPUT: -         if (prog->Target == GL_VERTEX_PROGRAM_ARB) -            sprintf(str, "v[%d]", index); -         else -            sprintf(str, "f[%d]", index); -         break; -      case PROGRAM_OUTPUT: -         sprintf(str, "o[%d]", index); -         break; -      case PROGRAM_TEMPORARY: -         sprintf(str, "R%d", index); -         break; -      case PROGRAM_ENV_PARAM: -         sprintf(str, "c[%d]", index); -         break; -      case PROGRAM_VARYING: /* extension */ -         sprintf(str, "varying[%s%d]", addr, index); -         break; -      case PROGRAM_UNIFORM: /* extension */ -         sprintf(str, "uniform[%s%d]", addr, index); -         break; -      case PROGRAM_CONSTANT: /* extension */ -         sprintf(str, "constant[%s%d]", addr, index); -         break; -      case PROGRAM_STATE_VAR: /* extension */ -         sprintf(str, "state[%s%d]", addr, index); -         break; -      default: -         _mesa_problem(NULL, "bad file in reg_string()"); -      } -      break; - -   default: -      _mesa_problem(NULL, "bad mode in reg_string()"); -   } - -   return str; -} - - -/** - * Return a string representation of the given swizzle word. - * If extended is true, use extended (comma-separated) format. - * \param swizzle  the swizzle field - * \param negateBase  4-bit negation vector - * \param extended  if true, also allow 0, 1 values - */ -const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) -{ -   static const char swz[] = "xyzw01!?";  /* See SWIZZLE_x definitions */ -   static char s[20]; -   GLuint i = 0; - -   if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) -      return ""; /* no swizzle/negation */ - -   if (!extended) -      s[i++] = '.'; - -   if (negateMask & NEGATE_X) -      s[i++] = '-'; -   s[i++] = swz[GET_SWZ(swizzle, 0)]; - -   if (extended) { -      s[i++] = ','; -   } - -   if (negateMask & NEGATE_Y) -      s[i++] = '-'; -   s[i++] = swz[GET_SWZ(swizzle, 1)]; - -   if (extended) { -      s[i++] = ','; -   } - -   if (negateMask & NEGATE_Z) -      s[i++] = '-'; -   s[i++] = swz[GET_SWZ(swizzle, 2)]; - -   if (extended) { -      s[i++] = ','; -   } - -   if (negateMask & NEGATE_W) -      s[i++] = '-'; -   s[i++] = swz[GET_SWZ(swizzle, 3)]; - -   s[i] = 0; -   return s; -} - - -void -_mesa_print_swizzle(GLuint swizzle) -{ -   if (swizzle == SWIZZLE_XYZW) { -      printf(".xyzw\n"); -   } -   else { -      const char *s = _mesa_swizzle_string(swizzle, 0, 0); -      printf("%s\n", s); -   } -} - - -const char * -_mesa_writemask_string(GLuint writeMask) -{ -   static char s[10]; -   GLuint i = 0; - -   if (writeMask == WRITEMASK_XYZW) -      return ""; - -   s[i++] = '.'; -   if (writeMask & WRITEMASK_X) -      s[i++] = 'x'; -   if (writeMask & WRITEMASK_Y) -      s[i++] = 'y'; -   if (writeMask & WRITEMASK_Z) -      s[i++] = 'z'; -   if (writeMask & WRITEMASK_W) -      s[i++] = 'w'; - -   s[i] = 0; -   return s; -} - - -const char * -_mesa_condcode_string(GLuint condcode) -{ -   switch (condcode) { -   case COND_GT:  return "GT"; -   case COND_EQ:  return "EQ"; -   case COND_LT:  return "LT"; -   case COND_UN:  return "UN"; -   case COND_GE:  return "GE"; -   case COND_LE:  return "LE"; -   case COND_NE:  return "NE"; -   case COND_TR:  return "TR"; -   case COND_FL:  return "FL"; -   default: return "cond???"; -   } -} - - -static void -fprint_dst_reg(FILE * f, -               const struct prog_dst_register *dstReg, -               gl_prog_print_mode mode, -               const struct gl_program *prog) -{ -   fprintf(f, "%s%s", -	   reg_string((gl_register_file) dstReg->File, -		      dstReg->Index, mode, dstReg->RelAddr, prog), -	   _mesa_writemask_string(dstReg->WriteMask)); -    -   if (dstReg->CondMask != COND_TR) { -      fprintf(f, " (%s.%s)", -	      _mesa_condcode_string(dstReg->CondMask), -	      _mesa_swizzle_string(dstReg->CondSwizzle, -				   GL_FALSE, GL_FALSE)); -   } - -#if 0 -   fprintf(f, "%s[%d]%s", -	   file_string((gl_register_file) dstReg->File, mode), -	   dstReg->Index, -	   _mesa_writemask_string(dstReg->WriteMask)); -#endif -} - - -static void -fprint_src_reg(FILE *f, -               const struct prog_src_register *srcReg,  -               gl_prog_print_mode mode, -               const struct gl_program *prog) -{ -   const char *abs = srcReg->Abs ? "|" : ""; - -   fprintf(f, "%s%s%s%s", -	   abs, -	   reg_string((gl_register_file) srcReg->File, -		      srcReg->Index, mode, srcReg->RelAddr, prog), -	   _mesa_swizzle_string(srcReg->Swizzle, -				srcReg->Negate, GL_FALSE), -	   abs); -#if 0 -   fprintf(f, "%s[%d]%s", -	   file_string((gl_register_file) srcReg->File, mode), -	   srcReg->Index, -	   _mesa_swizzle_string(srcReg->Swizzle, -				srcReg->Negate, GL_FALSE)); -#endif -} - - -static void -fprint_comment(FILE *f, const struct prog_instruction *inst) -{ -   if (inst->Comment) -      fprintf(f, ";  # %s\n", inst->Comment); -   else -      fprintf(f, ";\n"); -} - - -static void -fprint_alu_instruction(FILE *f, -                       const struct prog_instruction *inst, -                       const char *opcode_string, GLuint numRegs, -                       gl_prog_print_mode mode, -                       const struct gl_program *prog) -{ -   GLuint j; - -   fprintf(f, "%s", opcode_string); -   if (inst->CondUpdate) -      fprintf(f, ".C"); - -   /* frag prog only */ -   if (inst->SaturateMode == SATURATE_ZERO_ONE) -      fprintf(f, "_SAT"); - -   fprintf(f, " "); -   if (inst->DstReg.File != PROGRAM_UNDEFINED) { -      fprint_dst_reg(f, &inst->DstReg, mode, prog); -   } -   else { -      fprintf(f, " ???"); -   } - -   if (numRegs > 0) -      fprintf(f, ", "); - -   for (j = 0; j < numRegs; j++) { -      fprint_src_reg(f, inst->SrcReg + j, mode, prog); -      if (j + 1 < numRegs) -	 fprintf(f, ", "); -   } - -   fprint_comment(f, inst); -} - - -void -_mesa_print_alu_instruction(const struct prog_instruction *inst, -                            const char *opcode_string, GLuint numRegs) -{ -   fprint_alu_instruction(stderr, inst, opcode_string, -                          numRegs, PROG_PRINT_DEBUG, NULL); -} - - -/** - * Print a single vertex/fragment program instruction. - */ -GLint -_mesa_fprint_instruction_opt(FILE *f, -                            const struct prog_instruction *inst, -                            GLint indent, -                            gl_prog_print_mode mode, -                            const struct gl_program *prog) -{ -   GLint i; - -   if (inst->Opcode == OPCODE_ELSE || -       inst->Opcode == OPCODE_ENDIF || -       inst->Opcode == OPCODE_ENDLOOP || -       inst->Opcode == OPCODE_ENDSUB) { -      indent -= 3; -   } -   for (i = 0; i < indent; i++) { -      fprintf(f, " "); -   } - -   switch (inst->Opcode) { -   case OPCODE_PRINT: -      fprintf(f, "PRINT '%s'", (char *) inst->Data); -      if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { -         fprintf(f, ", "); -         fprintf(f, "%s[%d]%s", -		 file_string((gl_register_file) inst->SrcReg[0].File, -			     mode), -		 inst->SrcReg[0].Index, -		 _mesa_swizzle_string(inst->SrcReg[0].Swizzle, -				      inst->SrcReg[0].Negate, GL_FALSE)); -      } -      if (inst->Comment) -         fprintf(f, "  # %s", inst->Comment); -      fprint_comment(f, inst); -      break; -   case OPCODE_SWZ: -      fprintf(f, "SWZ"); -      if (inst->SaturateMode == SATURATE_ZERO_ONE) -         fprintf(f, "_SAT"); -      fprintf(f, " "); -      fprint_dst_reg(f, &inst->DstReg, mode, prog); -      fprintf(f, ", %s[%d], %s", -	      file_string((gl_register_file) inst->SrcReg[0].File, -			  mode), -	      inst->SrcReg[0].Index, -	      _mesa_swizzle_string(inst->SrcReg[0].Swizzle, -				   inst->SrcReg[0].Negate, GL_TRUE)); -      fprint_comment(f, inst); -      break; -   case OPCODE_TEX: -   case OPCODE_TXP: -   case OPCODE_TXL: -   case OPCODE_TXB: -      fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); -      if (inst->SaturateMode == SATURATE_ZERO_ONE) -         fprintf(f, "_SAT"); -      fprintf(f, " "); -      fprint_dst_reg(f, &inst->DstReg, mode, prog); -      fprintf(f, ", "); -      fprint_src_reg(f, &inst->SrcReg[0], mode, prog); -      fprintf(f, ", texture[%d], ", inst->TexSrcUnit); -      switch (inst->TexSrcTarget) { -      case TEXTURE_1D_INDEX:   fprintf(f, "1D");    break; -      case TEXTURE_2D_INDEX:   fprintf(f, "2D");    break; -      case TEXTURE_3D_INDEX:   fprintf(f, "3D");    break; -      case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE");  break; -      case TEXTURE_RECT_INDEX: fprintf(f, "RECT");  break; -      case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; -      case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; -      default: -         ; -      } -      if (inst->TexShadow) -         fprintf(f, " SHADOW"); -      fprint_comment(f, inst); -      break; - -   case OPCODE_KIL: -      fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); -      fprintf(f, " "); -      fprint_src_reg(f, &inst->SrcReg[0], mode, prog); -      fprint_comment(f, inst); -      break; -   case OPCODE_KIL_NV: -      fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); -      fprintf(f, " "); -      fprintf(f, "%s.%s", -	      _mesa_condcode_string(inst->DstReg.CondMask), -	      _mesa_swizzle_string(inst->DstReg.CondSwizzle, -				   GL_FALSE, GL_FALSE)); -      fprint_comment(f, inst); -      break; - -   case OPCODE_ARL: -      fprintf(f, "ARL "); -      fprint_dst_reg(f, &inst->DstReg, mode, prog); -      fprintf(f, ", "); -      fprint_src_reg(f, &inst->SrcReg[0], mode, prog); -      fprint_comment(f, inst); -      break; -   case OPCODE_BRA: -      fprintf(f, "BRA %d (%s%s)", -	      inst->BranchTarget, -	      _mesa_condcode_string(inst->DstReg.CondMask), -	      _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); -      fprint_comment(f, inst); -      break; -   case OPCODE_IF: -      if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { -         /* Use ordinary register */ -         fprintf(f, "IF "); -         fprint_src_reg(f, &inst->SrcReg[0], mode, prog); -         fprintf(f, "; "); -      } -      else { -         /* Use cond codes */ -         fprintf(f, "IF (%s%s);", -		 _mesa_condcode_string(inst->DstReg.CondMask), -		 _mesa_swizzle_string(inst->DstReg.CondSwizzle, -				      0, GL_FALSE)); -      } -      fprintf(f, " # (if false, goto %d)", inst->BranchTarget); -      fprint_comment(f, inst); -      return indent + 3; -   case OPCODE_ELSE: -      fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); -      return indent + 3; -   case OPCODE_ENDIF: -      fprintf(f, "ENDIF;\n"); -      break; -   case OPCODE_BGNLOOP: -      fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); -      return indent + 3; -   case OPCODE_ENDLOOP: -      fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); -      break; -   case OPCODE_BRK: -   case OPCODE_CONT: -      fprintf(f, "%s (%s%s); # (goto %d)", -	      _mesa_opcode_string(inst->Opcode), -	      _mesa_condcode_string(inst->DstReg.CondMask), -	      _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), -	      inst->BranchTarget); -      fprint_comment(f, inst); -      break; - -   case OPCODE_BGNSUB: -      if (mode == PROG_PRINT_NV) { -         fprintf(f, "%s:\n", inst->Comment); /* comment is label */ -         return indent; -      } -      else { -         fprintf(f, "BGNSUB"); -         fprint_comment(f, inst); -         return indent + 3; -      } -   case OPCODE_ENDSUB: -      if (mode == PROG_PRINT_DEBUG) { -         fprintf(f, "ENDSUB"); -         fprint_comment(f, inst); -      } -      break; -   case OPCODE_CAL: -      if (mode == PROG_PRINT_NV) { -         fprintf(f, "CAL %s;  # (goto %d)\n", inst->Comment, inst->BranchTarget); -      } -      else { -         fprintf(f, "CAL %u", inst->BranchTarget); -         fprint_comment(f, inst); -      } -      break; -   case OPCODE_RET: -      fprintf(f, "RET (%s%s)", -	      _mesa_condcode_string(inst->DstReg.CondMask), -	      _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); -      fprint_comment(f, inst); -      break; - -   case OPCODE_END: -      fprintf(f, "END\n"); -      break; -   case OPCODE_NOP: -      if (mode == PROG_PRINT_DEBUG) { -         fprintf(f, "NOP"); -         fprint_comment(f, inst); -      } -      else if (inst->Comment) { -         /* ARB/NV extensions don't have NOP instruction */ -         fprintf(f, "# %s\n", inst->Comment); -      } -      break; -   /* XXX may need other special-case instructions */ -   default: -      if (inst->Opcode < MAX_OPCODE) { -         /* typical alu instruction */ -         fprint_alu_instruction(f, inst, -                                _mesa_opcode_string(inst->Opcode), -                                _mesa_num_inst_src_regs(inst->Opcode), -                                mode, prog); -      } -      else { -         fprint_alu_instruction(f, inst, -                                _mesa_opcode_string(inst->Opcode), -                                3/*_mesa_num_inst_src_regs(inst->Opcode)*/, -                                mode, prog); -      } -      break; -   } -   return indent; -} - - -GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, -                            GLint indent, -                            gl_prog_print_mode mode, -                            const struct gl_program *prog) -{ -   return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); -} - - -void -_mesa_print_instruction(const struct prog_instruction *inst) -{ -   /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ -   _mesa_fprint_instruction_opt(stdout, inst, 0, PROG_PRINT_DEBUG, NULL); -} - -#if 0 -/** - * Print program, with options. - */ -void -_mesa_fprint_program_opt(FILE *f, -                         const struct gl_program *prog, -                         gl_prog_print_mode mode, -                         GLboolean lineNumbers) -{ -   GLuint i, indent = 0; - -   switch (prog->Target) { -   case GL_VERTEX_PROGRAM_ARB: -      if (mode == PROG_PRINT_ARB) -         fprintf(f, "!!ARBvp1.0\n"); -      else if (mode == PROG_PRINT_NV) -         fprintf(f, "!!VP1.0\n"); -      else -         fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); -      break; -   case GL_FRAGMENT_PROGRAM_ARB: -   case GL_FRAGMENT_PROGRAM_NV: -      if (mode == PROG_PRINT_ARB) -         fprintf(f, "!!ARBfp1.0\n"); -      else if (mode == PROG_PRINT_NV) -         fprintf(f, "!!FP1.0\n"); -      else -         fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); -      break; -   } - -   for (i = 0; i < prog->NumInstructions; i++) { -      if (lineNumbers) -         fprintf(f, "%3d: ", i); -      indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, -                                           indent, mode, prog); -   } -} - - -/** - * Print program to stderr, default options. - */ -void -_mesa_print_program(const struct gl_program *prog) -{ -   _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); -} - -/** - * Return binary representation of 64-bit value (as a string). - * Insert a comma to separate each group of 8 bits. - * Note we return a pointer to local static storage so this is not - * re-entrant, etc. - * XXX move to imports.[ch] if useful elsewhere. - */ -static const char * -binary(GLbitfield64 val) -{ -   static char buf[80]; -   GLint i, len = 0; -   for (i = 63; i >= 0; --i) { -      if (val & (1ULL << i)) -         buf[len++] = '1'; -      else if (len > 0 || i == 0) -         buf[len++] = '0'; -      if (len > 0 && ((i-1) % 8) == 7) -         buf[len++] = ','; -   } -   buf[len] = '\0'; -   return buf; -} - - -/** - * Print all of a program's parameters/fields to given file. - */ -static void -_mesa_fprint_program_parameters(FILE *f, -                                GLcontext *ctx, -                                const struct gl_program *prog) -{ -   GLuint i; - -   fprintf(f, "InputsRead: 0x%x (0b%s)\n", -                 prog->InputsRead, binary(prog->InputsRead)); -   fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", -                 prog->OutputsWritten, binary(prog->OutputsWritten)); -   fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); -   fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); -   fprintf(f, "NumParameters=%d\n", prog->NumParameters); -   fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); -   fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); -   fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", -                 prog->SamplersUsed, binary(prog->SamplersUsed)); -   fprintf(f, "Samplers=[ "); -   for (i = 0; i < MAX_SAMPLERS; i++) { -      fprintf(f, "%d ", prog->SamplerUnits[i]); -   } -   fprintf(f, "]\n"); - -   _mesa_load_state_parameters(ctx, prog->Parameters); - -#if 0 -   fprintf(f, "Local Params:\n"); -   for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ -      const GLfloat *p = prog->LocalParams[i]; -      fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); -   } -#endif	 -   _mesa_print_parameter_list(prog->Parameters); -} - - -/** - * Print all of a program's parameters/fields to stderr. - */ -void -_mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) -{ -   _mesa_fprint_program_parameters(stderr, ctx, prog); -} - - -/** - * Print a program parameter list to given file. - */ -static void -_mesa_fprint_parameter_list(FILE *f, -                            const struct gl_program_parameter_list *list) -{ -   const gl_prog_print_mode mode = PROG_PRINT_DEBUG; -   GLuint i; - -   if (!list) -      return; - -   if (0) -      fprintf(f, "param list %p\n", (void *) list); -   fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); -   for (i = 0; i < list->NumParameters; i++){ -      struct gl_program_parameter *param = list->Parameters + i; -      const GLfloat *v = list->ParameterValues[i]; -      fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", -	      i, param->Size, -	      file_string(list->Parameters[i].Type, mode), -	      param->Name, v[0], v[1], v[2], v[3]); -      if (param->Flags & PROG_PARAM_BIT_CENTROID) -         fprintf(f, " Centroid"); -      if (param->Flags & PROG_PARAM_BIT_INVARIANT) -         fprintf(f, " Invariant"); -      if (param->Flags & PROG_PARAM_BIT_FLAT) -         fprintf(f, " Flat"); -      if (param->Flags & PROG_PARAM_BIT_LINEAR) -         fprintf(f, " Linear"); -      fprintf(f, "\n"); -   } -} - - -/** - * Print a program parameter list to stderr. - */ -void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list) -{ -   _mesa_fprint_parameter_list(stderr, list); -} - - -/** - * Write shader and associated info to a file. - */ -void -_mesa_write_shader_to_file(const struct gl_shader *shader) -{ -   const char *type; -   char filename[100]; -   FILE *f; - -   if (shader->Type == GL_FRAGMENT_SHADER) -      type = "frag"; -   else -      type = "vert"; - -   snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); -   f = fopen(filename, "w"); -   if (!f) { -      fprintf(stderr, "Unable to open %s for writing\n", filename); -      return; -   } - -   fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); -   fputs(shader->Source, f); -   fprintf(f, "\n"); - -   fprintf(f, "/* Compile status: %s */\n", -           shader->CompileStatus ? "ok" : "fail"); -   if (!shader->CompileStatus) { -      fprintf(f, "/* Log Info: */\n"); -      fputs(shader->InfoLog, f); -   } -   else { -      fprintf(f, "/* GPU code */\n"); -      fprintf(f, "/*\n"); -      _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); -      fprintf(f, "*/\n"); -      fprintf(f, "/* Parameters / constants */\n"); -      fprintf(f, "/*\n"); -      _mesa_fprint_parameter_list(f, shader->Program->Parameters); -      fprintf(f, "*/\n"); -   } - -   fclose(f); -} - - -/** - * Append the shader's uniform info/values to the shader log file. - * The log file will typically have been created by the - * _mesa_write_shader_to_file function. - */ -void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, -                              const struct gl_program *prog) -{ -   const char *type; -   char filename[100]; -   FILE *f; - -   if (shader->Type == GL_FRAGMENT_SHADER) -      type = "frag"; -   else -      type = "vert"; - -   snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); -   f = fopen(filename, "a"); /* append */ -   if (!f) { -      fprintf(stderr, "Unable to open %s for appending\n", filename); -      return; -   } - -   fprintf(f, "/* First-draw parameters / constants */\n"); -   fprintf(f, "/*\n"); -   _mesa_fprint_parameter_list(f, prog->Parameters); -   fprintf(f, "*/\n"); - -   fclose(f); -} -#endif diff --git a/src/glsl/mesa/shader/prog_print.h b/src/glsl/mesa/shader/prog_print.h deleted file mode 100644 index f0df77b512..0000000000 --- a/src/glsl/mesa/shader/prog_print.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version:  6.5.3 - * - * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef PROG_PRINT_H -#define PROG_PRINT_H - - -/** - * The output style to use when printing programs. - */ -typedef enum { -   PROG_PRINT_ARB, -   PROG_PRINT_NV, -   PROG_PRINT_DEBUG -} gl_prog_print_mode; - - -extern void -_mesa_print_vp_inputs(GLbitfield inputs); - -extern void -_mesa_print_fp_inputs(GLbitfield inputs); - -extern const char * -_mesa_condcode_string(GLuint condcode); - -extern const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); - -const char * -_mesa_writemask_string(GLuint writeMask); - -extern void -_mesa_print_swizzle(GLuint swizzle); - -extern void -_mesa_print_alu_instruction(const struct prog_instruction *inst, -                            const char *opcode_string, GLuint numRegs); - -extern void -_mesa_print_instruction(const struct prog_instruction *inst); - -extern GLint -_mesa_fprint_instruction_opt(FILE *f, -                            const struct prog_instruction *inst, -                            GLint indent, -                            gl_prog_print_mode mode, -                            const struct gl_program *prog); - -extern GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, -                            gl_prog_print_mode mode, -                            const struct gl_program *prog); - -extern void -_mesa_print_program(const struct gl_program *prog); - -extern void -_mesa_fprint_program_opt(FILE *f, -                         const struct gl_program *prog, gl_prog_print_mode mode, -                         GLboolean lineNumbers); - -#if 0 -extern void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list); - -extern void -_mesa_write_shader_to_file(const struct gl_shader *shader); - -extern void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, -                              const struct gl_program *prog); -#endif - - -#endif /* PROG_PRINT_H */ diff --git a/src/glsl/symbol_table.c b/src/glsl/symbol_table.c deleted file mode 100644 index 0f0df7a261..0000000000 --- a/src/glsl/symbol_table.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/imports.h" -#include "symbol_table.h" -#include "hash_table.h" - -struct symbol { -    /** -     * Link to the next symbol in the table with the same name -     * -     * The linked list of symbols with the same name is ordered by scope -     * from inner-most to outer-most. -     */ -    struct symbol *next_with_same_name; - - -    /** -     * Link to the next symbol in the table with the same scope -     * -     * The linked list of symbols with the same scope is unordered.  Symbols -     * in this list my have unique names. -     */ -    struct symbol *next_with_same_scope; - - -    /** -     * Header information for the list of symbols with the same name. -     */ -    struct symbol_header *hdr; - - -    /** -     * Name space of the symbol -     * -     * Name space are arbitrary user assigned integers.  No two symbols can -     * exist in the same name space at the same scope level. -     */ -    int name_space; - -     -    /** -     * Arbitrary user supplied data. -     */ -    void *data; - -   /** Scope depth where this symbol was defined. */ -   unsigned depth; -}; - - -/** - */ -struct symbol_header { -    /** Linkage in list of all headers in a given symbol table. */ -    struct symbol_header *next; - -    /** Symbol name. */ -    const char *name; - -    /** Linked list of symbols with the same name. */ -    struct symbol *symbols; -}; - - -/** - * Element of the scope stack. - */ -struct scope_level { -    /** Link to next (inner) scope level. */ -    struct scope_level *next; -     -    /** Linked list of symbols with the same scope. */ -    struct symbol *symbols; -}; - - -/** - * - */ -struct _mesa_symbol_table { -    /** Hash table containing all symbols in the symbol table. */ -    struct hash_table *ht; - -    /** Top of scope stack. */ -    struct scope_level *current_scope; - -    /** List of all symbol headers in the table. */ -    struct symbol_header *hdr; - -   /** Current scope depth. */ -   unsigned depth; -}; - - -struct _mesa_symbol_table_iterator { -    /** -     * Name space of symbols returned by this iterator. -     */ -    int name_space; - - -    /** -     * Currently iterated symbol -     * -     * The next call to \c _mesa_symbol_table_iterator_get will return this -     * value.  It will also update this value to the value that should be -     * returned by the next call. -     */ -    struct symbol *curr; -}; - - -static void -check_symbol_table(struct _mesa_symbol_table *table) -{ -#if 1 -    struct scope_level *scope; - -    for (scope = table->current_scope; scope != NULL; scope = scope->next) { -        struct symbol *sym; - -        for (sym = scope->symbols -             ; sym != NULL -             ; sym = sym->next_with_same_name) { -            const struct symbol_header *const hdr = sym->hdr; -            struct symbol *sym2; - -            for (sym2 = hdr->symbols -                 ; sym2 != NULL -                 ; sym2 = sym2->next_with_same_name) { -                assert(sym2->hdr == hdr); -            } -        } -    } -#endif -} - -void -_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) -{ -    struct scope_level *const scope = table->current_scope; -    struct symbol *sym = scope->symbols; - -    table->current_scope = scope->next; -    table->depth--; - -    free(scope); - -    while (sym != NULL) { -        struct symbol *const next = sym->next_with_same_scope; -        struct symbol_header *const hdr = sym->hdr; - -        assert(hdr->symbols == sym); - -        hdr->symbols = sym->next_with_same_name; - -        free(sym); - -        sym = next; -    } - -    check_symbol_table(table); -} - - -void -_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) -{ -    struct scope_level *const scope = calloc(1, sizeof(*scope)); -     -    scope->next = table->current_scope; -    table->current_scope = scope; -    table->depth++; -} - - -static struct symbol_header * -find_symbol(struct _mesa_symbol_table *table, const char *name) -{ -    return (struct symbol_header *) hash_table_find(table->ht, name); -} - - -struct _mesa_symbol_table_iterator * -_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, -                                 int name_space, const char *name) -{ -    struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); -    struct symbol_header *const hdr = find_symbol(table, name); -     -    iter->name_space = name_space; - -    if (hdr != NULL) { -        struct symbol *sym; - -        for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { -            assert(sym->hdr == hdr); - -            if ((name_space == -1) || (sym->name_space == name_space)) { -                iter->curr = sym; -                break; -            } -        } -    } - -    return iter; -} - - -void -_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) -{ -    free(iter); -} - - -void * -_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) -{ -    return (iter->curr == NULL) ? NULL : iter->curr->data; -} - - -int -_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) -{ -    struct symbol_header *hdr; - -    if (iter->curr == NULL) { -        return 0; -    } - -    hdr = iter->curr->hdr; -    iter->curr = iter->curr->next_with_same_name; - -    while (iter->curr != NULL) { -        assert(iter->curr->hdr == hdr); - -        if ((iter->name_space == -1) -            || (iter->curr->name_space == iter->name_space)) { -            return 1; -        } - -        iter->curr = iter->curr->next_with_same_name; -    } - -    return 0; -} - - -/** - * Determine the scope "distance" of a symbol from the current scope - * - * \return - * A non-negative number for the number of scopes between the current scope - * and the scope where a symbol was defined.  A value of zero means the current - * scope.  A negative number if the symbol does not exist. - */ -int -_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, -				int name_space, const char *name) -{ -    struct symbol_header *const hdr = find_symbol(table, name); -    struct symbol *sym; - -    if (hdr != NULL) { -       for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { -	  assert(sym->hdr == hdr); - -	  if ((name_space == -1) || (sym->name_space == name_space)) { -	     assert(sym->depth <= table->depth); -	     return sym->depth - table->depth; -	  } -       } -    } - -    return -1; -} - - -void * -_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, -                               int name_space, const char *name) -{ -    struct symbol_header *const hdr = find_symbol(table, name); - -    if (hdr != NULL) { -        struct symbol *sym; - - -        for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { -            assert(sym->hdr == hdr); - -            if ((name_space == -1) || (sym->name_space == name_space)) { -                return sym->data; -            } -        } -    } - -    return NULL; -} - - -int -_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, -                              int name_space, const char *name, -                              void *declaration) -{ -    struct symbol_header *hdr; -    struct symbol *sym; - -    check_symbol_table(table); - -    hdr = find_symbol(table, name); - -    check_symbol_table(table); - -    if (hdr == NULL) { -        hdr = calloc(1, sizeof(*hdr)); -        hdr->name = name; - -        hash_table_insert(table->ht, hdr, name); -	hdr->next = table->hdr; -	table->hdr = hdr; -    } - -    check_symbol_table(table); - -    /* If the symbol already exists in this namespace at this scope, it cannot -     * be added to the table. -     */ -    for (sym = hdr->symbols -	    ; (sym != NULL) && (sym->name_space != name_space) -	    ; sym = sym->next_with_same_name) { -       /* empty */ -    } - -    if (sym && (sym->depth == table->depth)) -       return -1; - -    sym = calloc(1, sizeof(*sym)); -    sym->next_with_same_name = hdr->symbols; -    sym->next_with_same_scope = table->current_scope->symbols; -    sym->hdr = hdr; -    sym->name_space = name_space; -    sym->data = declaration; -    sym->depth = table->depth; - -    assert(sym->hdr == hdr); - -    hdr->symbols = sym; -    table->current_scope->symbols = sym; - -    check_symbol_table(table); -    return 0; -} - - -struct _mesa_symbol_table * -_mesa_symbol_table_ctor(void) -{ -    struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); - -    if (table != NULL) { -       table->ht = hash_table_ctor(32, hash_table_string_hash, -				   hash_table_string_compare); - -       _mesa_symbol_table_push_scope(table); -    } - -    return table; -} - - -void -_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) -{ -   struct symbol_header *hdr; -   struct symbol_header *next; - -   while (table->current_scope != NULL) { -      _mesa_symbol_table_pop_scope(table); -   } - -   for (hdr = table->hdr; hdr != NULL; hdr = next) { -       next = hdr->next; -       _mesa_free(hdr); -   } - -   hash_table_dtor(table->ht); -   free(table); -} diff --git a/src/glsl/symbol_table.h b/src/glsl/symbol_table.h deleted file mode 100644 index 3a9994c1ac..0000000000 --- a/src/glsl/symbol_table.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#ifndef MESA_SYMBOL_TABLE_H -#define MESA_SYMBOL_TABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct _mesa_symbol_table; -struct _mesa_symbol_table_iterator; - -extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); - -extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); - -extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, -    int name_space, const char *name, void *declaration); - -extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, -    int name_space, const char *name); - -extern void *_mesa_symbol_table_find_symbol( -    struct _mesa_symbol_table *symtab, int name_space, const char *name); - -extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); - -extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); - -extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( -    struct _mesa_symbol_table *table, int name_space, const char *name); - -extern void _mesa_symbol_table_iterator_dtor( -    struct _mesa_symbol_table_iterator *); - -extern void *_mesa_symbol_table_iterator_get( -    struct _mesa_symbol_table_iterator *iter); - -extern int _mesa_symbol_table_iterator_next( -    struct _mesa_symbol_table_iterator *iter); - -#ifdef __cplusplus -} -#endif - -#endif /* MESA_SYMBOL_TABLE_H */  | 
