March 2017
Mo Tu We Th Fr Sa Su
<< >>


HxSL Update

Posted on Mar 05 2011

I just pushed an update to HxSL on haxelib !

This is a short list of changes and improvements that were made :

  • register allocation : both vertex and fragment shaders only allow 8 Float4 temporary registers, which are quite a scarce resource. I added some algorithm to perform liveness analysis and it is actually able to store several variables into the same register (for instance if you have 4 Float temporaries, they might be stored into .xyzw fields).
    A first pass try to output the most compact/efficient code, and if too much registers were allocated a second pass will try to pack registers even more agressively.
  • write mask limits : I found during my experiments with register allocation that AGAL (Adobe shader assembler) does compile but not execute correctly exotic write masks such as .zw, which seems conform to shaders 1.3 profile limitations. Right now I have restricted their usage but I might end-up emulating them in HxSL by splitting into several opcodes or using additional mov instructions
  • matrixes : added support for M33 and M34 matrix, matrix row access with m[1] as well as matrix transpose operation, improved matrix transposition inference
  • unbind/draw : the format.hxsl.Shader now have an unbind() method that will clear the stream and textures, as well as a draw(vbuf,ibuf) method that will bind, draw triangles then unbind.
  • for : added support for Haxe for( x in a...b ) loops : it will only work if both a and b are constant integers and will unroll the loop by repeating the loop block and replacing the x variable
  • if : added support of dst = if( color > 0.5 ) a else b (also works with ?: operator), which compiles to dst = (color > 0.5) * a + (color <= 0.5) * b (since the comparison operators are returning 0 or 1, this is the way branches are merged in shaders)
  • ... and some other minor changes and bug fixes

The HxSL documentation has been updated accordingly.

Enjoy !

  • alijaya
    Mar 06, 2011 at 06:21

    excuse me... but i think the link must be

  • Mar 06, 2011 at 11:31

    Indeed ;)

  • ryzed
    May 02, 2011 at 23:24

    Will it be possible to create shaders from the text?
    Something like: shader.create("some text");

  • May 03, 2011 at 20:11

    @ryzed : I have something like this which is working together with hScript, soon to be released

  • ryzed
    May 04, 2011 at 05:08

    Will wait.

Name : Email : Website : Message :