mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 18:10:17 +01:00
glsl2: Remove files that had been imported for standalone.
This commit is contained in:
parent
e82ddb781a
commit
f4869f3326
11 changed files with 0 additions and 3261 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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)
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -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 */
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 */
|
||||
Loading…
Add table
Reference in a new issue