Hxsl bind()?

57 views
Skip to first unread message

Bo Huang

unread,
Sep 10, 2014, 1:46:17 AM9/10/14
to haxe...@googlegroups.com
Hi

I've been using hxsl for Flash. My draw calls are roughly:

for( i in 0...60) {
//Different texture for each vertex buffer
  texturemappingShader.tex=texture2d[i];
  texturemappingShader.bind( contex3d, vertexBuffer3d[i] );

//No more than 500 triangles for each index buffer
  context3d.drawTriangles( indexBuffer3d[i], 0, nTriangles[i]);
  texturemappingShader.tex = null;
  texturemappingShader.unbind(context3d);
}

When I debug step into hxsl.Shader.bind(), which calls ShaderInstance.getInstance(), I see that the updateParams() is always called because the class member 'modified' is true.
Then the debugger steps into
@:autoBuild(hxsl.ShaderMacros.buildShader())
class Shader {

Does that mean my texture shader is rebuilt each time hxsl.Shader.bind() is called? Is that expensive?

I need to optimize and figure out why is my app rather slow.

Thanks

Nicolas Cannasse

unread,
Sep 11, 2014, 2:19:49 PM9/11/14
to haxe...@googlegroups.com
The shader should be the same if you don't change any constant. In HXSL2, updateParams will just copy the parameters from the class fields to the arrays (texture array in you case)

Best,
Nicolas

Reply all
Reply to author
Forward
0 new messages