Commit Graph

45 Commits

Author SHA1 Message Date
Brian Paul
7d56caabe4 Merge branch 'mesa_7_6_branch'
Conflicts:

	src/mesa/shader/lex.yy.c
	src/mesa/shader/program_lexer.l
2009-10-28 11:33:51 -06:00
Ian Romanick
93dae6761b ARB prog parser: Fix epic memory leak in lexer / parser interface
Anything that matched IDENTIFIER was strdup'ed and returned to the
parser.  However, almost every case of IDENTIFIER in the parser just
dropped the returned string on the floor.  Every swizzle string, every
option string, every use of a variable, etc. leaked memory.

Create a temporary buffer in the parser state (string_dumpster and
dumpster_size).  Return strings from the lexer to the parser in the
buffer.  Grow the buffer as needed.  When the parser needs to keep a
string (i.e., delcaring a new variable), let it make a copy then.

The only leak that valgrind now detects is /occasionally/ the copy of
the program string in gl_program::String is leaked.  I'm not seeing
how. :(
2009-10-27 17:06:18 -07:00
Ian Romanick
8df9587d68 ARB prog parser: Don't leak program string
The program string is kept in the program object.  On the second call
into glProgramStringARB the previous kept string would be leaked.
2009-10-27 17:06:18 -07:00
Eric Anholt
49d402e275 Merge remote branch 'origin/mesa_7_6_branch'
Conflicts:
	src/mesa/drivers/dri/intel/intel_fbo.c
	src/mesa/drivers/dri/intel/intel_mipmap_tree.c
	src/mesa/drivers/dri/intel/intel_mipmap_tree.h
	src/mesa/drivers/dri/intel/intel_tex_copy.c
	src/mesa/drivers/dri/intel/intel_tex_image.c
2009-10-23 15:21:05 -07:00
Ian Romanick
dd24501665 ARB prog parser: Fix parameter array size comparison
Array indexes are invalid when >= the maximum, but array sizes are
only in valid when > the maximum.  This prevented programs from
declaring a single maximum size array.

See the piglit vp-max-array test.
2009-10-22 19:20:15 -07:00
Ian Romanick
8130375e77 Merge branch 'asm-shader-rework-2'
Conflicts:
	src/mesa/shader/program_parse.tab.c
2009-09-25 16:57:38 -07:00
Brian Paul
2aad3a855b ARB prog parser: more detailed error message for out of bounds ADDR offsets 2009-09-15 09:40:25 -06:00
Ian Romanick
b8e1e8d2d8 Merge branch 'master' into asm-shader-rework-2
Conflicts:
	src/mesa/shader/lex.yy.c
	src/mesa/shader/program_parse.tab.c
	src/mesa/shader/program_parse.tab.h
2009-09-10 15:33:45 -07:00
Ian Romanick
81722c5d7e NV fp parser: Add support for condition codes
Conditional write masks and the condition-code based KIL instruction
are all supported.  The specific behavior of KIL in the following
shader may or may not match the behavior of other implementations:

!!ARBfp1.0
	TEMP	GT;
	MOVC	GT, fragment.texcoord[0];
	KIL	GT.x;
	END

Should be it interpreted as 'KIL srcReg' or as 'KIL ccTest'?  The
current parser will interpret it as 'KIL srcReg'.
2009-09-10 15:04:24 -07:00
Ian Romanick
0e7953366f ARB prog parser: Differentiate between used and unused names in the lexer
The lexer will return IDENTIFIER only when the name does not have an
associated symbol.  Otherwise USED_IDENTIFIER is returned.
2009-09-10 14:35:33 -07:00
Ian Romanick
d0adebb8d5 NV fp parser: Support instruction and TEMP / OUTPUT sizes
Adds support for declaring TEMP and OUTPUT variables as 'LONG' or
'SHORT' precision.  The precision specifiers are parsed, but they are
currently ignored.  Some support for this may be added in the future,
but neither Intel hardware nor, as far as I'm aware, Radeon hardware
support multiple precisions.

Also adds support for instruction precision ('X', 'H', and 'R')
suffixes and instruction condition code output ('C') suffix.  This
results in a fairly major change to the lexer.  Instructions are
matched with all the possible suffix strings.  The suffix string are
then carved off by a context (i.e., which program mode and options are
set) aware parser that converts the suffixes to bits in
prog_instruction.

This could have been handled in the same way _SAT was originally
handled in the lexer, but it would have resulted in a very large lexer
with lots of opportunity for cut-and-paste errors.
2009-09-04 17:31:05 -07:00
Ian Romanick
9ea4319744 ARB prog parser: Add new constructor for asm_instruction
The new constructor copies fields from the prog_instruction that the
parser expects the lexer to set.
2009-09-04 16:35:50 -07:00
Brian Paul
592a6642fc ARB prog: replace 'unsigned' with 'gl_state_index'
Fixes compilation warnings with MSVC.
2009-09-04 09:17:59 -06:00
Brian Paul
3fedd08779 ARB prog: rename POINT, SIZE to POINT_TOK, SIZE_TOK
Fixes symbol collisions with typedefs in Microsoft headers.
Perhaps we should prefix/suffix all the lexer tokens to avoid this.
2009-09-04 09:17:59 -06:00
Ian Romanick
eeb1402c05 NV fp parser: Add support for absolute value operator on instruction operands 2009-09-03 14:32:48 -07:00
Ian Romanick
b8e389bb03 NV fp parser: Support new scalar constant behavior
ARBfp requires scalar constants have a '.x' suffix, but NVfp_option
does not.  This shows up with instructions that require a scalar
parameter (e.g., COS).
2009-09-03 14:05:18 -07:00
Ian Romanick
8ca6fd8a83 NV fp parser: Parse TXD instruction 2009-09-01 14:16:03 -07:00
Ian Romanick
847bc5c852 ARB prog parser: Fix handling of stateOptModMatNum
The optional array index should clearly be enclosed in square
brackets.  This helps the oglconform test vp_binding.c get a bit
farther, but it still fails.
2009-09-01 11:11:31 -07:00
Ian Romanick
ede0cd4d8c NV fp lexer: Add new opcodes 2009-08-31 17:00:31 -07:00
Brian Paul
4cf27608bc ARB prog parser: use correct context limits 2009-08-24 12:00:35 -07:00
Ian Romanick
ac5551fbb9 ARB prog parser: Revert part of previous change to constant parsing
The commit "ARP prog parser: Implement the spec, not what makes sense"
broke the parsing of scalar constants.  This commit reverts that part
of that commit.  Now vp_swizzle.c passes.
2009-08-20 18:29:41 -07:00
Ian Romanick
565a2a8f38 ARB prog parser: Add support for RGBA components to SWZ instruction in fp 2009-07-30 10:51:43 -07:00
Ian Romanick
17534ab88c ARB prog parser: Prevent NULL ptr deref for KIL instruction
The KIL instruction doesn't have a destination register, so
dereferencing dst in asm_instruction_ctor would cause a segfault.
2009-07-30 09:41:35 -07:00
Ian Romanick
600710907c ARP prog parser: Implement the spec, not what makes sense 2009-07-29 21:07:41 -07:00
Ian Romanick
48183ca8b6 ARB prog parser: Get program limits from the context
Some debug code from the older stand-alone version of the assembler
was hanging around and needed to go.
2009-07-29 20:51:38 -07:00
Ian Romanick
333bb4f291 ARB prog parser: Finish implementing fp state.depth.range 2009-07-29 20:41:48 -07:00
Ian Romanick
8a430dd4da Indentation fixes. 2009-07-29 09:50:06 -07:00
Ian Romanick
4c5879ff31 ARB prog parser: Set NumAttributes based on the number of attribs read 2009-07-29 09:47:14 -07:00
Ian Romanick
648dac4251 ARB prog parser: Set component negation mask for SWZ instruction 2009-07-28 21:57:28 -07:00
Ian Romanick
86b33b5649 ARB prog parser: Set correct register file for OUTPUT variables 2009-07-28 21:56:42 -07:00
Ian Romanick
aafd576259 ARB prog parser: Add support for GL_MESA_texture_array
This isn't really tested yet as no drivers actually support this extension.
2009-07-27 17:22:21 -07:00
Ian Romanick
41d5696628 ARB prog parser: More robust error message for bad OPTION string 2009-07-27 17:10:01 -07:00
Ian Romanick
1edd13bf23 ARB prog parser: Add support for GL_ARB_fragment_program_shadow
Passes the piglit asmparsertest shadow-0[123].txt tests and
progs/demos/shadowtex.
2009-07-27 16:24:49 -07:00
Ian Romanick
88018e2e07 ARB prog parser: Fix handling of RECT
Require that GL_{ARB,EXT,NV}_texture_rectangle be supported before
allowing use of RECT texture target.
2009-07-27 15:47:52 -07:00
Ian Romanick
054ab5a50a ARB prog parser: Correct handling of some extensions that interact w/ARB_vp 2009-07-27 14:18:40 -07:00
Ian Romanick
94b4556704 ARB prog: Clean up several memory leaks
As far as I am able to determine via code inspection and using
Valgrind, that should be all of the leaks in the parser.
2009-07-27 12:21:26 -07:00
Ian Romanick
f3cba9d66a ARB prog parse: Fix cut-and-paste error for constant vectors 2009-07-24 18:01:59 -07:00
Ian Romanick
ef80c2012d parser: Clean up a bunch of silly compiler warnings 2009-07-22 17:13:08 -07:00
Ian Romanick
0db5ef0741 parser: Track a few more frag prog related values 2009-07-22 16:21:54 -07:00
Ian Romanick
28b13038d8 parser: Ensure that param_binding_type is set correctly 2009-07-22 16:03:32 -07:00
Ian Romanick
c2ee82d693 parser: Set NumParameters 2009-07-22 15:27:31 -07:00
Ian Romanick
44843c7533 parser: Clean up generation of error strings during assembly 2009-07-22 15:06:49 -07:00
Ian Romanick
aec4291706 parser: Initialize unused instruction source registers
The 965 driver expects unused source registers (e.g., SrcReg[2] of a
DP3 instruction) to have a register file of PROGRAM_UNDEFINED.
Initializing these source registers ensures that this happens.
2009-07-22 12:29:48 -07:00
Ian Romanick
69d3d19b54 parser: Anonymous constants come from the PROGRAM_CONSTANT file 2009-07-22 10:51:18 -07:00
Ian Romanick
770cebbc29 ARB_fp/vp: Initial import of new ARB vp/fp assembler
This still needs quite a bit of work, but a bunch of the programs in progs/vp
produce correct results.
2009-07-20 17:44:36 -07:00