Merge branch 'mesa_7_6_branch'

Conflicts:

	src/mesa/shader/lex.yy.c
	src/mesa/shader/program_lexer.l
This commit is contained in:
Brian Paul
2009-10-28 11:33:51 -06:00
10 changed files with 817 additions and 957 deletions

View File

@@ -138,8 +138,10 @@ intel_miptree_create(struct intel_context *intel,
/*
* pitch == 0 || height == 0 indicates the null texture
*/
if (!mt || !mt->pitch || !mt->total_height)
if (!mt || !mt->pitch || !mt->total_height) {
free(mt);
return NULL;
}
mt->region = intel_region_alloc(intel,
tiling,

View File

@@ -163,6 +163,9 @@ static uint32_t x_tile_swizzle(struct intel_renderbuffer *irb,
int x_tile_number, y_tile_number;
int tile_off, tile_base;
x += irb->region->draw_x;
y += irb->region->draw_y;
tile_stride = (irb->region->pitch * irb->region->cpp) << 3;
xbyte = x * irb->region->cpp;
@@ -218,6 +221,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
int x_tile_number, y_tile_number;
int tile_off, tile_base;
x += irb->region->draw_x;
y += irb->region->draw_y;
tile_stride = (irb->region->pitch * irb->region->cpp) << 5;
xbyte = x * irb->region->cpp;

View File

@@ -27,10 +27,6 @@
*
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "main/imports.h"
#include "main/simple_list.h"

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,8 @@
if (condition) { \
return token; \
} else { \
return handle_ident(yyextra, yytext, yylval); \
yylval->string = return_string(yyextra, yytext); \
return IDENTIFIER; \
} \
} while (0)
@@ -70,13 +71,53 @@
yylval->temp_inst.Opcode = OPCODE_ ## opcode; \
return token; \
} else { \
return handle_ident(yyextra, yytext, yylval); \
yylval->string = return_string(yyextra, yytext); \
return IDENTIFIER; \
} \
} while (0)
#define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \
SWIZZLE_NIL, SWIZZLE_NIL)
/**
* Send a string to the parser using asm_parser_state::string_dumpster
*
* Sends a string to the parser using asm_parser_state::string_dumpster as a
* temporary storage buffer. Data previously stored in
* asm_parser_state::string_dumpster will be lost. If
* asm_parser_state::string_dumpster is not large enough to hold the new
* string, the buffer size will be increased. The buffer size is \b never
* decreased.
*
* \param state Assembler parser state tracking
* \param str String to be passed to the parser
*
* \return
* A pointer to asm_parser_state::string_dumpster on success or \c NULL on
* failure. Currently the only failure case is \c ENOMEM.
*/
static char *
return_string(struct asm_parser_state *state, const char *str)
{
const size_t len = strlen(str);
if (len >= state->dumpster_size) {
char *const dumpster = _mesa_realloc(state->string_dumpster,
state->dumpster_size,
len + 1);
if (dumpster == NULL) {
return NULL;
}
state->string_dumpster = dumpster;
state->dumpster_size = len + 1;
}
memcpy(state->string_dumpster, str, len + 1);
return state->string_dumpster;
}
static unsigned
mask_from_char(char c)
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,14 @@
/* A Bison parser, made by GNU Bison 2.4.1. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,7 +16,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -32,7 +33,6 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -146,16 +146,120 @@
DOT = 362
};
#endif
/* Tokens. */
#define ARBvp_10 258
#define ARBfp_10 259
#define ADDRESS 260
#define ALIAS 261
#define ATTRIB 262
#define OPTION 263
#define OUTPUT 264
#define PARAM 265
#define TEMP 266
#define END 267
#define BIN_OP 268
#define BINSC_OP 269
#define SAMPLE_OP 270
#define SCALAR_OP 271
#define TRI_OP 272
#define VECTOR_OP 273
#define ARL 274
#define KIL 275
#define SWZ 276
#define TXD_OP 277
#define INTEGER 278
#define REAL 279
#define AMBIENT 280
#define ATTENUATION 281
#define BACK 282
#define CLIP 283
#define COLOR 284
#define DEPTH 285
#define DIFFUSE 286
#define DIRECTION 287
#define EMISSION 288
#define ENV 289
#define EYE 290
#define FOG 291
#define FOGCOORD 292
#define FRAGMENT 293
#define FRONT 294
#define HALF 295
#define INVERSE 296
#define INVTRANS 297
#define LIGHT 298
#define LIGHTMODEL 299
#define LIGHTPROD 300
#define LOCAL 301
#define MATERIAL 302
#define MAT_PROGRAM 303
#define MATRIX 304
#define MATRIXINDEX 305
#define MODELVIEW 306
#define MVP 307
#define NORMAL 308
#define OBJECT 309
#define PALETTE 310
#define PARAMS 311
#define PLANE 312
#define POINT_TOK 313
#define POINTSIZE 314
#define POSITION 315
#define PRIMARY 316
#define PROGRAM 317
#define PROJECTION 318
#define RANGE 319
#define RESULT 320
#define ROW 321
#define SCENECOLOR 322
#define SECONDARY 323
#define SHININESS 324
#define SIZE_TOK 325
#define SPECULAR 326
#define SPOT 327
#define STATE 328
#define TEXCOORD 329
#define TEXENV 330
#define TEXGEN 331
#define TEXGEN_Q 332
#define TEXGEN_R 333
#define TEXGEN_S 334
#define TEXGEN_T 335
#define TEXTURE 336
#define TRANSPOSE 337
#define TEXTURE_UNIT 338
#define TEX_1D 339
#define TEX_2D 340
#define TEX_3D 341
#define TEX_CUBE 342
#define TEX_RECT 343
#define TEX_SHADOW1D 344
#define TEX_SHADOW2D 345
#define TEX_SHADOWRECT 346
#define TEX_ARRAY1D 347
#define TEX_ARRAY2D 348
#define TEX_ARRAYSHADOW1D 349
#define TEX_ARRAYSHADOW2D 350
#define VERTEX 351
#define VTXATTRIB 352
#define WEIGHT 353
#define IDENTIFIER 354
#define USED_IDENTIFIER 355
#define MASK4 356
#define MASK3 357
#define MASK2 358
#define MASK1 359
#define SWIZZLE 360
#define DOT_DOT 361
#define DOT 362
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 116 "program_parse.y"
{
struct asm_instruction *inst;
struct asm_symbol *sym;
struct asm_symbol temp_sym;
@@ -179,15 +283,13 @@ typedef union YYSTYPE
unsigned xyzw_valid:1;
unsigned negate:1;
} ext_swizzle;
/* Line 1676 of yacc.c */
#line 187 "program_parse.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1489 of yacc.c. */
#line 289 "program_parse.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -206,4 +308,3 @@ typedef struct YYLTYPE
#endif

View File

@@ -2155,7 +2155,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER
"undefined variable binding in ALIAS statement");
YYERROR;
} else {
_mesa_symbol_table_add_symbol(state->st, 0, $2, target);
_mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target);
}
}
;
@@ -2309,10 +2309,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
if (exist != NULL) {
yyerror(locp, state, "redeclared identifier");
} else {
s = calloc(1, sizeof(struct asm_symbol));
s->name = name;
const size_t name_len = strlen(name);
s = calloc(1, sizeof(struct asm_symbol) + name_len + 1);
s->name = (char *)(s + 1);
s->type = t;
memcpy((char *) s->name, name, name_len + 1);
switch (t) {
case at_temp:
if (state->prog->NumTemporaries >= state->limits->MaxTemps) {
@@ -2560,6 +2564,11 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
_mesa_memcpy (strz, str, len);
strz[len] = '\0';
if (state->prog->String != NULL) {
_mesa_free(state->prog->String);
state->prog->String = NULL;
}
state->prog->String = strz;
state->st = _mesa_symbol_table_ctor();
@@ -2649,7 +2658,6 @@ error:
for (sym = state->sym; sym != NULL; sym = temp) {
temp = sym->next;
_mesa_free((void *) sym->name);
_mesa_free(sym);
}
state->sym = NULL;
@@ -2657,5 +2665,10 @@ error:
_mesa_symbol_table_dtor(state->st);
state->st = NULL;
if (state->string_dumpster != NULL) {
_mesa_free(state->string_dumpster);
state->dumpster_size = 0;
}
return result;
}

View File

@@ -38,6 +38,13 @@ enum asm_type {
at_output,
};
/**
* \note
* Objects of this type are allocated as the object plus the name of the
* symbol. That is, malloc(sizeof(struct asm_symbol) + strlen(name) + 1).
* Alternately, asm_symbol::name could be moved to the bottom of the structure
* and declared as 'char name[0];'.
*/
struct asm_symbol {
struct asm_symbol *next; /**< List linkage for freeing. */
const char *name;
@@ -157,6 +164,15 @@ struct asm_parser_state {
/*@}*/
/**
* Buffer to hold strings transfered from the lexer to the parser
*/
/*@{*/
char *string_dumpster; /**< String data transfered. */
size_t dumpster_size; /**< Total size, in bytes, of the buffer. */
/*@}*/
/**
* Selected limits copied from gl_constants
*

View File

@@ -20,12 +20,8 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "main/imports.h"
#include "symbol_table.h"
#include "hash_table.h"
@@ -73,6 +69,9 @@ struct symbol {
/**
*/
struct symbol_header {
/** Linkage in list of all headers in a given symbol table. */
struct symbol_header *next;
/** Symbol name. */
const char *name;
@@ -102,6 +101,9 @@ struct _mesa_symbol_table {
/** Top of scope stack. */
struct scope_level *current_scope;
/** List of all symbol headers in the table. */
struct symbol_header *hdr;
};
@@ -301,6 +303,8 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
hdr->name = name;
hash_table_insert(table->ht, hdr, name);
hdr->next = table->hdr;
table->hdr = hdr;
}
check_symbol_table(table);
@@ -341,10 +345,18 @@ _mesa_symbol_table_ctor(void)
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);
}