Semantic checking on Lab4 Demos

63 views
Skip to first unread message

Min Chen

unread,
Nov 28, 2012, 7:27:03 PM11/28/12
to uoft_csc...@googlegroups.com
Hi Peter,

I got some semantic errors for the *.frag files included in the demos.

1. Reading from a result-qualified variable.
In shader.frag (line 5, col 28), the value of gl_FragCoord is read.

As gl_FragCoord is a predefined "result" variable, shouldn't it be write-only and cannot be written in a if/else scope?

2. Const Initialization by a constructor.

In phong.frag (line 9, col 21)
const vec4 red = vec4(1.0,0.0,0.0,1.0);

In lab 3 spec, it says that "const qualified variables must be initialized with a literal value or with a uniform variable
(see pre-defined variables below), and not an expression."

I thought a constructor call is only an expression but definitely not a literal value. Thus, it shouldn't be allowed to initialize a const variable?

Did I misunderstand anything?

Thanks,

Min

 

Peter Goodman

unread,
Nov 29, 2012, 10:17:54 AM11/29/12
to uoft_csc...@googlegroups.com
1. Typo on my part.  Excellent find.
2. Excellent find! Another corner case I missed when writing the spec. 

SPEC CHANGE!! gl_FragCoord should be considered an attribute variable.

SPEC CHANGE!! Let us say that a constructor is a literal if and only if all of its arguments are literals. Then it is safe to use in the assignment of const vectors.

SPEC CHANGE!! To makes things simpler, you need only support constructors on the right-hand side of assignments. That is, don't need not support anything like: a + vec2(1, 2)[0].

Best Regards,

Peter Goodman,
http://www.petergoodman.me
65 High Park Ave.,
Toronto, Ontario
M6P 2R7




 

--
 
 

jin

unread,
Dec 4, 2012, 4:06:44 AM12/4/12
to uoft_csc...@googlegroups.com
Maybe it would be a good idea to post this as a GIANT notification or something.
I've missed the spec change for the whole day and I was about to give up on a4.
gg no re.

Peter Goodman

unread,
Dec 4, 2012, 4:28:52 PM12/4/12
to uoft_csc...@googlegroups.com

Sorry about that, I figured everyone was just reading all Qs asked because all sorts of little details come up in them.

Sorry for the late reply, was in the hospital all yesterday and last night.

Sent from my mobile device.

--
 
 
Reply all
Reply to author
Forward
0 new messages