Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 10:51

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 25.02.2008, 14:39 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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!


Top
 Profile  
Reply with quote  
PostPosted: 25.02.2008, 16:59 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 26.02.2008, 15:00 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group