mesa.git
14 years agoget_lvalue_copy doesn't need all the checking of do_assignment().
Eric Anholt [Wed, 23 Jun 2010 21:43:50 +0000 (14:43 -0700)]
get_lvalue_copy doesn't need all the checking of do_assignment().

14 years agoast_to_hir: Clone LHS derefs of assignment expressions.
Eric Anholt [Wed, 23 Jun 2010 19:40:17 +0000 (12:40 -0700)]
ast_to_hir: Clone LHS derefs of assignment expressions.

14 years agoir_function_inlining: Allow inlining of loops and conditionals.
Eric Anholt [Wed, 23 Jun 2010 19:19:07 +0000 (12:19 -0700)]
ir_function_inlining: Allow inlining of loops and conditionals.

The new cloning code handles them.

14 years agoAdd a virtual clone() method to ir_instruction.
Eric Anholt [Wed, 23 Jun 2010 18:37:12 +0000 (11:37 -0700)]
Add a virtual clone() method to ir_instruction.

This will be used by function inlining, the linker, and avoiding double
usage of the LHS deref chains in ++, *=, and similar operations.

14 years agoAvoid using the same ir_constant 0.0 multiple times in mat constructors.
Eric Anholt [Wed, 23 Jun 2010 21:33:30 +0000 (14:33 -0700)]
Avoid using the same ir_constant 0.0 multiple times in mat constructors.

14 years agoglcpp: Support line continuations within preprocessor directives.
Kenneth Graunke [Wed, 23 Jun 2010 19:31:09 +0000 (12:31 -0700)]
glcpp: Support line continuations within preprocessor directives.

Fixes CorrectPreprocess5.frag.

14 years agoglcpp: Make standalone binary use preprocess().
Kenneth Graunke [Wed, 23 Jun 2010 21:00:27 +0000 (14:00 -0700)]
glcpp: Make standalone binary use preprocess().

This prevents the two code paths from getting out of sync.  Also, future
work will need the shader source as a string anyway.

Unfortunately, this copies and pastes load_text_file from main.cpp, with
small changes (support for reading from stdin, talloc).

14 years agoglcpp: Fix "dangerous trailing context" warning.
Kenneth Graunke [Mon, 21 Jun 2010 22:15:34 +0000 (15:15 -0700)]
glcpp: Fix "dangerous trailing context" warning.

Flex couldn't be sure whether "def" and "ndef" were part of the #ifdef
and #ifndef patterns or the trailing context of the #if pattern.

14 years agoRemove comment support from the main lexer.
Kenneth Graunke [Mon, 21 Jun 2010 22:12:34 +0000 (15:12 -0700)]
Remove comment support from the main lexer.

Now handled by the preprocessor.

14 years agoglcpp: Recognize plain "//" as a comment.
Kenneth Graunke [Mon, 21 Jun 2010 22:11:01 +0000 (15:11 -0700)]
glcpp: Recognize plain "//" as a comment.

Found in glsl-orangebook-ch06-bump.(frag|vert).  This was resulting in
the comments getting passed through to the main compiler's lexer.

14 years agoGenerate errors for empty constructors instead of asserting
Ian Romanick [Wed, 23 Jun 2010 20:58:34 +0000 (13:58 -0700)]
Generate errors for empty constructors instead of asserting

This causes the following tests to pass:

     glslparsertest/glsl2/constructor-10.vert

14 years agolinker: Update some comments, remove a couple FINISHMEs
Ian Romanick [Wed, 23 Jun 2010 19:18:21 +0000 (12:18 -0700)]
linker: Update some comments, remove a couple FINISHMEs

14 years agolinker: Use InfoLog in assign_attribute_locations
Ian Romanick [Wed, 23 Jun 2010 19:14:02 +0000 (12:14 -0700)]
linker: Use InfoLog in assign_attribute_locations

Since the program is now passed in, refactor the parameter list to the
function as well.

14 years agolinker: Refactor parameters to cross_validate_uniforms
Ian Romanick [Wed, 23 Jun 2010 19:09:14 +0000 (12:09 -0700)]
linker: Refactor parameters to cross_validate_uniforms

14 years agolinker: Write errors to info log instead of stdout
Ian Romanick [Wed, 23 Jun 2010 19:07:22 +0000 (12:07 -0700)]
linker: Write errors to info log instead of stdout

14 years agolinker: Initial implementation of varying slot allocation
Ian Romanick [Wed, 23 Jun 2010 18:23:01 +0000 (11:23 -0700)]
linker: Initial implementation of varying slot allocation

14 years agolinker: Limit attribute allocation to MAX_VERTEX_ATTRIBS
Ian Romanick [Wed, 23 Jun 2010 00:41:37 +0000 (17:41 -0700)]
linker: Limit attribute allocation to MAX_VERTEX_ATTRIBS

14 years agolinker: Support matrix and array vertex inputs
Ian Romanick [Wed, 23 Jun 2010 00:29:19 +0000 (17:29 -0700)]
linker: Support matrix and array vertex inputs

14 years agolinker: Initial implementation of attribute slot allocation
Ian Romanick [Tue, 22 Jun 2010 00:18:31 +0000 (17:18 -0700)]
linker: Initial implementation of attribute slot allocation

14 years agoImport some bits Mesa's mtypes.h
Ian Romanick [Tue, 22 Jun 2010 20:41:50 +0000 (13:41 -0700)]
Import some bits Mesa's mtypes.h

14 years agoImport gl_program_parameter and gl_program_parameter_list types from Mesa
Ian Romanick [Tue, 22 Jun 2010 00:08:51 +0000 (17:08 -0700)]
Import gl_program_parameter and gl_program_parameter_list types from Mesa

14 years agolinker: Store the par-linked per-stage shaders in the glsl_program
Ian Romanick [Mon, 21 Jun 2010 23:16:05 +0000 (16:16 -0700)]
linker: Store the par-linked per-stage shaders in the glsl_program

14 years agolinker: Initial implementation of uniform slot allocation
Ian Romanick [Mon, 21 Jun 2010 23:10:42 +0000 (16:10 -0700)]
linker: Initial implementation of uniform slot allocation

14 years agoImport gl_uniform and gl_uniform_list types from Mesa
Ian Romanick [Mon, 21 Jun 2010 23:06:07 +0000 (16:06 -0700)]
Import gl_uniform and gl_uniform_list types from Mesa

14 years agoir_variable: Add query to get number of slots used by a variable
Ian Romanick [Mon, 21 Jun 2010 23:05:29 +0000 (16:05 -0700)]
ir_variable: Add query to get number of slots used by a variable

14 years agoglsl_type: Add method to get number of slots used by a type
Ian Romanick [Mon, 21 Jun 2010 23:05:00 +0000 (16:05 -0700)]
glsl_type: Add method to get number of slots used by a type

14 years agolinker: Document what remains to be done
Ian Romanick [Mon, 21 Jun 2010 19:03:24 +0000 (12:03 -0700)]
linker: Document what remains to be done

14 years agoir_variable: Set locations for shader built-in variables
Ian Romanick [Mon, 21 Jun 2010 18:42:57 +0000 (11:42 -0700)]
ir_variable: Set locations for shader built-in variables

14 years agoir_variable: Track the location of uniforms, varings, attributes, etc.
Ian Romanick [Mon, 21 Jun 2010 18:42:02 +0000 (11:42 -0700)]
ir_variable: Track the location of uniforms, varings, attributes, etc.

14 years agolinker: Initial implementation of interstage input / output validation
Ian Romanick [Sat, 19 Jun 2010 02:02:10 +0000 (19:02 -0700)]
linker: Initial implementation of interstage input / output validation

14 years agoir_variable: Add method to get string representing interpolation qualifier
Ian Romanick [Sat, 19 Jun 2010 02:00:28 +0000 (19:00 -0700)]
ir_variable: Add method to get string representing interpolation qualifier

14 years agolinker: Initial implementation of interstage uniform validation
Ian Romanick [Sat, 19 Jun 2010 00:13:42 +0000 (17:13 -0700)]
linker: Initial implementation of interstage uniform validation

14 years agoir_constant: Add method to determine if two constants have the same value
Ian Romanick [Fri, 18 Jun 2010 02:50:36 +0000 (19:50 -0700)]
ir_constant: Add method to determine if two constants have the same value

14 years agoFix multiple usage of an rvalue in constructor component splitting.
Eric Anholt [Tue, 22 Jun 2010 21:22:42 +0000 (14:22 -0700)]
Fix multiple usage of an rvalue in constructor component splitting.

Store the thing in a variable and deref it for each swizzle if we have to.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
14 years agoir_validate: Use callback functionality in ir_hierarchical_visitor
Ian Romanick [Wed, 23 Jun 2010 01:41:50 +0000 (18:41 -0700)]
ir_validate: Use callback functionality in ir_hierarchical_visitor

14 years agoir_hierarchical_visitor: Add generic callback functionality
Ian Romanick [Wed, 23 Jun 2010 01:37:12 +0000 (18:37 -0700)]
ir_hierarchical_visitor: Add generic callback functionality

14 years agoir_validate: New pass for checking our invariants.
Eric Anholt [Tue, 22 Jun 2010 19:07:21 +0000 (12:07 -0700)]
ir_validate: New pass for checking our invariants.

14 years agoir: Give ir_instruction a print visitor helper.
Eric Anholt [Tue, 22 Jun 2010 19:09:21 +0000 (12:09 -0700)]
ir: Give ir_instruction a print visitor helper.

This avoids spamming each file with includes of ir_print_visitor.h
because someone was doing debugging at some point, and is less typing
when doing debugging.

14 years agoHook up texturing in the hierarchical visitor.
Eric Anholt [Tue, 22 Jun 2010 17:45:15 +0000 (10:45 -0700)]
Hook up texturing in the hierarchical visitor.

14 years agoInclude stdio.h and stdlib.h everywhere, and don't cook our own #define NULL.
Eric Anholt [Tue, 22 Jun 2010 17:38:52 +0000 (10:38 -0700)]
Include stdio.h and stdlib.h everywhere, and don't cook our own #define NULL.

14 years agoAdd missing build products to gitignore
Ian Romanick [Tue, 22 Jun 2010 19:24:42 +0000 (12:24 -0700)]
Add missing build products to gitignore

14 years agoglcpp: Initialize error state.
Kenneth Graunke [Mon, 21 Jun 2010 20:55:12 +0000 (13:55 -0700)]
glcpp: Initialize error state.

14 years agoglcpp: Accept #elif without an expression if the expression doesn't matter.
Kenneth Graunke [Mon, 21 Jun 2010 19:20:22 +0000 (12:20 -0700)]
glcpp: Accept #elif without an expression if the expression doesn't matter.

Issue a warning.  nVidia's compiler seems to accept this; apparently
GCC < 4.4 did as well: http://gcc.gnu.org/gcc-4.4/porting_to.html

14 years agoglcpp: Print to the main compiler's infolog, not stdout.
Kenneth Graunke [Mon, 21 Jun 2010 18:47:55 +0000 (11:47 -0700)]
glcpp: Print to the main compiler's infolog, not stdout.

14 years agoUse yy_scan_string and stop caring about shader->SourceLen.
Kenneth Graunke [Mon, 21 Jun 2010 18:43:42 +0000 (11:43 -0700)]
Use yy_scan_string and stop caring about shader->SourceLen.

We had to call strlen on the preprocessed source, which seemed a bit
pointless; also, we updated shader->SourceLen but not shader->Source,
which was even more confusing.  Just leave both untouched.

14 years agoglcpp: Rework handling of "defined" operator.
Kenneth Graunke [Sat, 19 Jun 2010 06:06:54 +0000 (23:06 -0700)]
glcpp: Rework handling of "defined" operator.

It's now done in the grammar, and as a result, can easily handle
parenthesis.  defined ( identifier ) is now supported.

Fixes glcpp/tests/065-if-defined-parens.c.

14 years agoglcpp/tests: Add a test for #if defined (identifier)
Kenneth Graunke [Sat, 19 Jun 2010 06:04:44 +0000 (23:04 -0700)]
glcpp/tests: Add a test for #if defined (identifier)

Previously we only tested #if defined identifier (without parenthesis).

14 years agoglcpp: Ignore junk tokens at end of #ifdef/#ifndef (with warning)
Kenneth Graunke [Sat, 19 Jun 2010 03:08:15 +0000 (20:08 -0700)]
glcpp: Ignore junk tokens at end of #ifdef/#ifndef (with warning)

Both nVidia's compiler and GCC accept this.
Fixes CorrectPreprocess11.frag.

14 years agoglcpp: Add glcpp_warning for printing warnings to the info log.
Kenneth Graunke [Sat, 19 Jun 2010 02:54:25 +0000 (19:54 -0700)]
glcpp: Add glcpp_warning for printing warnings to the info log.

14 years agoglcpp: Add boolean 'error' flag.
Kenneth Graunke [Mon, 21 Jun 2010 19:39:49 +0000 (12:39 -0700)]
glcpp: Add boolean 'error' flag.

We used to check if the info log is non-empty, but when we print
warnings, this will no longer be valid.

14 years agoglcpp: Rename "errors" to "info_log."
Kenneth Graunke [Sat, 19 Jun 2010 02:52:36 +0000 (19:52 -0700)]
glcpp: Rename "errors" to "info_log."

Eventually, we'll want to be be able to print out warnings as well.

14 years agoglcpp: Don't include newlines as part of #version-passthrough.
Kenneth Graunke [Fri, 18 Jun 2010 22:41:00 +0000 (15:41 -0700)]
glcpp: Don't include newlines as part of #version-passthrough.

Fixes glcpp/tests/064-version.c.

14 years agoglcpp/tests: Add a test for #version followed by #define.
Kenneth Graunke [Fri, 18 Jun 2010 22:34:50 +0000 (15:34 -0700)]
glcpp/tests: Add a test for #version followed by #define.

This isn't really a C file, but...that's probably okay.

14 years agoglcpp: Fix line and column numbering.
Kenneth Graunke [Fri, 18 Jun 2010 22:23:50 +0000 (15:23 -0700)]
glcpp: Fix line and column numbering.

Lines were off by one, and column numbering was completely daft.

14 years agoglcpp: Remove calls to exit().
Kenneth Graunke [Thu, 17 Jun 2010 19:58:54 +0000 (12:58 -0700)]
glcpp: Remove calls to exit().

Calling exit() would be really bad once integrated into mesa.  Even in
the standalone binary, we want to print the error log first.

Since each case already flags an error, compilation will still fail,
but it may go on (with something fudged) and generate more errors.

14 years agoglcpp: Add line locations to "Unterminated #if" error message.
Kenneth Graunke [Thu, 17 Jun 2010 19:41:46 +0000 (12:41 -0700)]
glcpp: Add line locations to "Unterminated #if" error message.

14 years agoglcpp: Add line locations to various mismatched #if error messages.
Kenneth Graunke [Thu, 17 Jun 2010 19:30:57 +0000 (12:30 -0700)]
glcpp: Add line locations to various mismatched #if error messages.

14 years agoglcpp: Add line locations to "reserved name" error messages.
Kenneth Graunke [Thu, 17 Jun 2010 19:21:53 +0000 (12:21 -0700)]
glcpp: Add line locations to "reserved name" error messages.

14 years agoglcpp: Print locations in error messages where possible.
Kenneth Graunke [Thu, 17 Jun 2010 00:31:50 +0000 (17:31 -0700)]
glcpp: Print locations in error messages where possible.

14 years agoglcpp: Introduce new glcpp_error function.
Kenneth Graunke [Thu, 17 Jun 2010 19:03:25 +0000 (12:03 -0700)]
glcpp: Introduce new glcpp_error function.

14 years agoglcpp: Set locations on tokens.
Kenneth Graunke [Wed, 16 Jun 2010 23:58:31 +0000 (16:58 -0700)]
glcpp: Set locations on tokens.

14 years agoglcpp: Set line locations in the lexer.
Kenneth Graunke [Thu, 17 Jun 2010 00:41:12 +0000 (17:41 -0700)]
glcpp: Set line locations in the lexer.

14 years agoglcpp: Add plumbing to support line locations.
Kenneth Graunke [Wed, 16 Jun 2010 23:35:57 +0000 (16:35 -0700)]
glcpp: Add plumbing to support line locations.

14 years agoglcpp: Add %error-verbose.
Kenneth Graunke [Thu, 17 Jun 2010 20:07:13 +0000 (13:07 -0700)]
glcpp: Add %error-verbose.

14 years agoglcpp: Actually support #ifdef and #ifndef.
Kenneth Graunke [Thu, 17 Jun 2010 21:36:34 +0000 (14:36 -0700)]
glcpp: Actually support #ifdef and #ifndef.

Strangely, the lexer never created these tokens, even though the parser
already had code to handle them.

14 years agoglcpp: Build a reentrant parser.
Kenneth Graunke [Wed, 16 Jun 2010 23:26:28 +0000 (16:26 -0700)]
glcpp: Build a reentrant parser.

14 years agoglcpp: Print errors on stdout instead of stderr (non-standalone version).
Kenneth Graunke [Wed, 16 Jun 2010 20:19:27 +0000 (13:19 -0700)]
glcpp: Print errors on stdout instead of stderr (non-standalone version).

Otherwise, piglit marks tests as "warn" when the shader was (correctly)
failing.

14 years agoglcpp/tests: Add extra newline at the end of expected output.
Kenneth Graunke [Thu, 17 Jun 2010 21:49:40 +0000 (14:49 -0700)]
glcpp/tests: Add extra newline at the end of expected output.

This newline at EOF is harmless and generated by the previous commit.

14 years agoglcpp: Handle missing newline at EOF.
Kenneth Graunke [Wed, 16 Jun 2010 19:53:19 +0000 (12:53 -0700)]
glcpp: Handle missing newline at EOF.

Fixes CorrectFuncOverload.vert.

14 years agoglcpp: Complain about unrecognized directives.
Kenneth Graunke [Wed, 16 Jun 2010 19:41:37 +0000 (12:41 -0700)]
glcpp: Complain about unrecognized directives.

14 years agoglcpp: Pass #version, #extension, and #pragma directives through unchanged.
Kenneth Graunke [Wed, 16 Jun 2010 19:21:17 +0000 (12:21 -0700)]
glcpp: Pass #version, #extension, and #pragma directives through unchanged.

Let the main compiler's lexer/parser handle them.

14 years agoMake the main compiler call the preprocessor.
Kenneth Graunke [Wed, 16 Jun 2010 19:18:00 +0000 (12:18 -0700)]
Make the main compiler call the preprocessor.

By using a single function, the main compiler doesn't need to include
glcpp.h, which currently has a lot of details about the preprocessor
internals.  In particular, this prevents the two yacc grammars from
seeing each other, which would be rather messy to sort out.

14 years agoComplain and exit if the given shader file doesn't exist.
Kenneth Graunke [Wed, 16 Jun 2010 19:10:55 +0000 (12:10 -0700)]
Complain and exit if the given shader file doesn't exist.

14 years agoglcpp: Add support for lexing from a string.
Kenneth Graunke [Wed, 16 Jun 2010 19:01:17 +0000 (12:01 -0700)]
glcpp: Add support for lexing from a string.

The standalone binary still reads from stdin, however.

14 years agoglcpp: Output to a buffer and error log rather than directly printing.
Kenneth Graunke [Wed, 16 Jun 2010 18:57:48 +0000 (11:57 -0700)]
glcpp: Output to a buffer and error log rather than directly printing.

In the standalone case, simply print the buffers when done.

14 years agoglcpp: Fix a case of == where = probably ought to be.
Kenneth Graunke [Wed, 16 Jun 2010 18:56:36 +0000 (11:56 -0700)]
glcpp: Fix a case of == where = probably ought to be.

Caught by a GCC warning.

14 years agoAdd glcpp to the build.
Kenneth Graunke [Wed, 16 Jun 2010 18:54:01 +0000 (11:54 -0700)]
Add glcpp to the build.

14 years agoSpecify %option prefix="glcpp_" in the source code, not the Makefile.
Kenneth Graunke [Wed, 16 Jun 2010 18:51:43 +0000 (11:51 -0700)]
Specify %option prefix="glcpp_" in the source code, not the Makefile.

14 years agoMerge Carl's preprocessor into the glcpp subdirectory.
Kenneth Graunke [Mon, 21 Jun 2010 18:22:11 +0000 (11:22 -0700)]
Merge Carl's preprocessor into the glcpp subdirectory.

14 years agoPrint out the info log if compilation fails.
Kenneth Graunke [Sat, 19 Jun 2010 18:31:01 +0000 (11:31 -0700)]
Print out the info log if compilation fails.

14 years agoChange error/warning functions to print to the info log.
Kenneth Graunke [Thu, 17 Jun 2010 22:15:35 +0000 (15:15 -0700)]
Change error/warning functions to print to the info log.

14 years agoInitialize the shader info log
Ian Romanick [Sat, 19 Jun 2010 08:39:14 +0000 (01:39 -0700)]
Initialize the shader info log

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
14 years agoMake shader a talloc context.
Kenneth Graunke [Sat, 19 Jun 2010 18:24:33 +0000 (11:24 -0700)]
Make shader a talloc context.

14 years agoLink against talloc. We're going to be using it.
Kenneth Graunke [Thu, 17 Jun 2010 22:14:47 +0000 (15:14 -0700)]
Link against talloc.  We're going to be using it.

14 years agoFix crash when running glsl on a signle fragment shader.
Kenneth Graunke [Thu, 17 Jun 2010 22:37:26 +0000 (15:37 -0700)]
Fix crash when running glsl on a signle fragment shader.

14 years agoRename prog to shader. Less confusing.
Kenneth Graunke [Thu, 17 Jun 2010 22:28:34 +0000 (15:28 -0700)]
Rename prog to shader.  Less confusing.

14 years agoFix compile on 64-bit.
Kenneth Graunke [Thu, 17 Jun 2010 22:28:13 +0000 (15:28 -0700)]
Fix compile on 64-bit.

14 years agoEnsure that shader_in and shader_out are correctly set in declarations
Ian Romanick [Sat, 19 Jun 2010 01:57:31 +0000 (18:57 -0700)]
Ensure that shader_in and shader_out are correctly set in declarations

14 years agoglsl_lexer: centroid and invariant are not reserved words in GLSL 1.10
Ian Romanick [Sat, 19 Jun 2010 01:40:12 +0000 (18:40 -0700)]
glsl_lexer: centroid and invariant are not reserved words in GLSL 1.10

14 years agoglsl_lexer: Handle interpolation qualifiers
Ian Romanick [Sat, 19 Jun 2010 01:36:51 +0000 (18:36 -0700)]
glsl_lexer: Handle interpolation qualifiers

14 years agolinker: Add some function header comments
Ian Romanick [Thu, 17 Jun 2010 22:20:22 +0000 (15:20 -0700)]
linker: Add some function header comments

14 years agoTODO: Add note about initializers for constants
Ian Romanick [Fri, 18 Jun 2010 03:37:17 +0000 (20:37 -0700)]
TODO: Add note about initializers for constants

14 years agoAllow initializers for uniforms
Ian Romanick [Fri, 18 Jun 2010 03:09:34 +0000 (20:09 -0700)]
Allow initializers for uniforms

14 years agoDon't link shaders by default
Ian Romanick [Fri, 18 Jun 2010 02:51:48 +0000 (19:51 -0700)]
Don't link shaders by default

Add a command line option to trigger linking.  This "fixes" all the
failing test cases.  Oops.

14 years agolinker: Initial bits of the linker
Ian Romanick [Thu, 17 Jun 2010 22:04:20 +0000 (15:04 -0700)]
linker: Initial bits of the linker

No linking is done yet, but some of the semantic checking is done.

14 years agoUse glsl_program instead of an open-coded vector of shaders
Ian Romanick [Thu, 17 Jun 2010 19:59:45 +0000 (12:59 -0700)]
Use glsl_program instead of an open-coded vector of shaders

14 years agoAdd glsl_program that is similar to Mesa's gl_shader_program
Ian Romanick [Thu, 17 Jun 2010 19:59:27 +0000 (12:59 -0700)]
Add glsl_program that is similar to Mesa's gl_shader_program

14 years agoChange glsl_program to glsl_shader
Ian Romanick [Thu, 17 Jun 2010 19:54:24 +0000 (12:54 -0700)]
Change glsl_program to glsl_shader

14 years agoCompile multiple shaders listed on the command line
Ian Romanick [Thu, 17 Jun 2010 19:22:16 +0000 (12:22 -0700)]
Compile multiple shaders listed on the command line

14 years agoExtract compilation to a separate routine
Ian Romanick [Thu, 17 Jun 2010 19:01:18 +0000 (12:01 -0700)]
Extract compilation to a separate routine

Pull all of the code that actually compiles shaders into a separate
function.  Use a glsl_program to track data about the compiled shader.