Horde3D http://www.horde3d.org/forums/ |
|
Shader system improvements http://www.horde3d.org/forums/viewtopic.php?f=8&t=244 |
Page 1 of 1 |
Author: | marciano [ 25.02.2008, 14:39 ] |
Post subject: | Shader system improvements |
One thing that is bugging me when writing complex shaders is locating an error. At the moment the line numbers that the shader compiler is telling you for errors/warnings don't make really sense. One factor that complicates this whole issue is that shaders can be split in several files. Fortunately GLSL has the directive #line which can overwrite the shader compiler's line counter. A shader context in Horde consits of several DefCode and InsCode blocks. My idea is to encode the block number in the line numbers. For example an error in line 3005 could tell you that there is a problem in the third block at line 5. Another thing I want to add is a general shader preamble. This is just a string settable through the API that is added at the beginning of all shaders. The shader preamble could contain platform-specific defines that make it possible to write conditional code paths using #ifdef. For example you could create different paths for shader model 2.0 and 3.0 hardware. Finally I was thinking about implementing a small preprocessor that makes it possible to use #inlcude in the shaders. This would repalce the current InsCode/DefCode mechanism. The advantage is that also plain text code resources could include other code resources. But on the other hand that would prohibit the described system for the line numbers. So I dropped the idea again. Any comments and propositions on this topic are welcome! |
Author: | swiftcoder [ 25.02.2008, 16:59 ] |
Post subject: | Re: Shader system improvements |
marciano wrote: Another thing I want to add is a general shader preamble. This is just a string settable through the API that is added at the beginning of all shaders. The shader preamble could contain platform-specific defines that make it possible to write conditional code paths using #ifdef. For example you could create different paths for shader model 2.0 and 3.0 hardware. This is a very good idea. marciano wrote: Finally I was thinking about implementing a small preprocessor that makes it possible to use #inlcude in the shaders. This would repalce the current InsCode/DefCode mechanism. The advantage is that also plain text code resources could include other code resources. But on the other hand that would prohibit the described system for the line numbers. So I dropped the idea again.
Scratch what I just said. My solution would have required parsing the glsl error logs manually, and I don't imagine that the error logs are portable. |
Author: | marciano [ 26.02.2008, 15:00 ] |
Post subject: | |
Thanks for your feedback! Yeah, I read your idea yesterday but had the same thoughs as you now. It would be cool to have but would really require to guess where the line number is in the error message. So I think we better keep the system as it is now. I have already implemented preambles and the line number encoding is working too. Was all quite trivial to do. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |