HxSL internals question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

HxSL internals question

Cauê W.
Hey Nicolas!

Suppose the following simplified code:

var color:Float3;

function vertex()
{
color = [0.0,0.0,0.0,1.0].xyz;
}

This will render something like this:

color = vec4(0.0, 0.0, 0.0, 1.0).xyz; //ok, great!
color.w = vec4(0.0, 0.0, 0.0, 1.0).w; // ?? !!!

Well, I really don't know what the second line is doing there, but it screws up my code, specially because I'm detecting when you promote a variable (e.g. color.w -> vec4(color, 1.0).w) so well, it just doesn't make much sense.

Anyway, GLSL's initial support is almost done, though because of how HxSL preprocesses things, it might be faster if I could process the code in a previous (and higher level) step - to be able to access vector declarations, if() statements, function calls, etc.

Cheers
Cauê

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: HxSL internals question

Cauê W.
If you add a non-constant value it gets even weirder:

var input : {
pos : Float3,
};
var color:Float3;

function vertex()
{
var c = [pos.x, pos.y, pos.z, 1.0];
color = c.xyz;
}

will generate:

vec4 c;
{
vec4 _dollar_tmp_1;
_dollar_tmp_1.x = pos.x; //and so on
...
c = _dollar_tmp_1;
}
color = c.xyz; //ok
//pseudo code
color.w = $c0.w;

Ok, $c0 I know that points to the constants table, index 0. $c0 is typed as a Float4, but there is only one value at the constants table!

so my code looks like this at this last line:

vec4(color, 1.0).w = 1.0.x;

Is it right for $c0 to be typed as a Float4? How can I detect this case?
Thanks!

2011/11/30 Cauê Waneck <[hidden email]>
Hey Nicolas!

Suppose the following simplified code:

var color:Float3;

function vertex()
{
color = [0.0,0.0,0.0,1.0].xyz;
}

This will render something like this:

color = vec4(0.0, 0.0, 0.0, 1.0).xyz; //ok, great!
color.w = vec4(0.0, 0.0, 0.0, 1.0).w; // ?? !!!

Well, I really don't know what the second line is doing there, but it screws up my code, specially because I'm detecting when you promote a variable (e.g. color.w -> vec4(color, 1.0).w) so well, it just doesn't make much sense.

Anyway, GLSL's initial support is almost done, though because of how HxSL preprocesses things, it might be faster if I could process the code in a previous (and higher level) step - to be able to access vector declarations, if() statements, function calls, etc.

Cheers
Cauê


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: HxSL internals question

Cauê W.
Anyway, GLSL's initial support is almost done, though because of how HxSL preprocesses things, it might be faster if I could process the code in a previous (and higher level) step - to be able to access vector declarations, if() statements, function calls, etc.


Maybe it would be better if I used ParsedHxsl to generate the code? I thought about that, but I know they wouldn't be typed. I -could- roll my own type inference, but then again I'm afraid to have subtle differences between hxsl and hxsl-glsl, so I'd rather use format.hxsl.Data. What do you think, Nicolas?

Cheers
Cauê

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: HxSL internals question

Cauê W.
Maybe it would be better if I used ParsedHxsl to generate the code? I thought about that, but I know they wouldn't be typed. I -could- roll my own type inference, but then again I'm afraid to have subtle differences between hxsl and hxsl-glsl, so I'd rather use format.hxsl.Data. What do you think, Nicolas?

Just remembered about the matrix transposition inferencing, so well, I couldn't write my own type inference : )

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: HxSL internals question

Nicolas Cannasse
In reply to this post by Cauê W.
Le 01/12/2011 02:10, Cauê Waneck a écrit :

> Hey Nicolas!
>
> Suppose the following simplified code:
>
> var color:Float3;
>
> function vertex()
> {
>
>     color = [0.0,0.0,0.0,1.0].xyz;
>
> }
>
> This will render something like this:
>
> color = vec4(0.0, 0.0, 0.0, 1.0).xyz; //ok, great!
> color.w = vec4(0.0, 0.0, 0.0, 1.0).w; // ?? !!!

Ok, a bit of explanation is needed here :)

This additional write of the "w" component is added in order to pass the
AGAL bytecode verifier which requires that all components needs to be
written.

I've added a config flag that disable it on SVN.

Set compiler.config.padWrites = false;

Please report me any other strange things that you might see since some
additional code optimization (such as constant propagation) is done in
the AGAL backend so I didn't put much effort in cleaning up the
intermediate code ;)

Best,
Nicolas





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: HxSL internals question

Cauê W.
Amazing, Nicolas!

Thank you very much for the very quick fix !!

2011/12/1 Nicolas Cannasse <[hidden email]>
Le 01/12/2011 02:10, Cauê Waneck a écrit :

Hey Nicolas!

Suppose the following simplified code:

var color:Float3;

function vertex()
{

   color = [0.0,0.0,0.0,1.0].xyz;

}

This will render something like this:

color = vec4(0.0, 0.0, 0.0, 1.0).xyz; //ok, great!
color.w = vec4(0.0, 0.0, 0.0, 1.0).w; // ?? !!!

Ok, a bit of explanation is needed here :)

This additional write of the "w" component is added in order to pass the AGAL bytecode verifier which requires that all components needs to be written.

I've added a config flag that disable it on SVN.

Set compiler.config.padWrites = false;

Please report me any other strange things that you might see since some additional code optimization (such as constant propagation) is done in the AGAL backend so I didn't put much effort in cleaning up the intermediate code ;)

Best,
Nicolas





--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org