Jump to content

Get complete shader source code on error


PeapBoy
 Share

Recommended Posts

Hi everybody ! :D

While I was writing my latest shader, I juste came up with annoying errors like this one :
annoyingError.png.dc8da8e0ba843cac4c3676ca282e5d40.png

Guess what ? No, my typo is NOT at line 85. :angry:

And I wondered why we couldn't have the real source code. The one after conversion, addition of defines and insertion of includes. Therefore the one where the typo actually IS at line 85.
I know that getVertexShaderSource() function exists but it doesn't work without a successfully compiled program (and on success, no need of debugging).

Guess what ? It's easy to get ! :P
http://www.babylonjs-playground.com/#YX38N7#3
(Open your console)

annoyingError2.png.f6e3b99f9696da1e959887e9e99ebb99.png

I would like to know, @Deltakosh , would you be interested in a PR for that or is it already implemented somewhere/useless ?
Because in my PR I had to compute again the migratedVertexCode and migratedFragmentCode values, but these ones are available when entering the Effect.noError callback in the _prepareEffect() function...

If you're interested, I see two options :
- Just returning the two values in the onError callback and let the user make something with that.
- Or printing the source code with numbered lines by default exactly as you print the defines

Just let me know what you think is better. :)

PeapBoy
 

Link to comment
Share on other sites

Ok, done, thank you. :)

Just one question. Since BabylonJS has a backward compatibility policy, can I remove a function ?
Because I replaced _dumpShadersName (which is only used here) by _dumpShadersSource.

Two other things I think about :
- Maybe some developers do NOT want that random users of their site could see the content of their shaders when it fails to compile ?
- It may add a huge amount of text in the console and it may be uncomfortable if you're not debugging this. I tried to order the content as good as I could though.

Anyway, PR is sent.

annoyingError3.png.b856f6ad9eabf9ba894a75ce17893157.png

annoyingError4.png.75354af6bc246399c9bb78ebcbc786bd.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...