Update your bookmarks! This blog is now hosted on http://xoofx.com/blog

Thursday, May 20, 2010

NShader 1.1, hlsl, glsl, cg syntax coloring for Visual Studio 2008 & 2010

I have recently released NShader 1.1 which adds support for Visual Studio 2010 as well as bugfixes for hlsl/glsl syntax highlighting.

While this plugin is quite cool to add a basic syntax highlighting for shader languages, It lacks intellisense/completion/error markers to improve the editor experience. I didn't have time to add such a functionality in this release as... I don't really have too much time dedicated to this project... and well, I have so much to learn from effectively practicing a lot more shader languages that I'm fine with this basic syntax highlighting! ;) Is it a huge task to add intellisense? It depends, but concretely, I need to implement for each shading language a full grammar/lexer parser in order to provide a reliable intellisense. Of course, a very basic intellisense would be feasible without this, but I would rather not to use an annoying/unreliable intellisense popup.

Although, I did some research about existing lexers for shading languages, surprisingly, this is not something you can find easily. For hlsl for example, afaik, there is no bnf grammar published by Microsoft, so If you want to do it yourself, you need to go through the whole HLSL reference documentation and compile yourself a bnf... and that's something I can't afford in my spare time. One could argue that there are some startup code available on the net (O3D from google has an antlr parser/lexer, or a relative simpler one from Christian Schladetsch), agree with that, but well... It still ask a bit more time to patch them, add support for SM5.0, handle correctly preprocessor directives... and so on... After that, I need to integrate it through the language service API, not the worst part. Anyway, If someone is motivated to help me on this, we could come with something. We will follow also if Intelishade is able to resurrect in an open source way... a joint venture would be interesting.

Also, what's my feedback about migrating VS2008 language service to VS2010? Well, It was pretty straightforward! I did follow the sdk instructions about "Migrating a Legacy Language Service" but It was not fully working as expected. In fact, the only remaining problem was that the WSIX VS2001 installer didn't register automatically the NShader Language Service. I was forced to add manually the pkgdef file (containing registry update for the language service) to the vsix archive. While I was working on the migration to VS2010, I had a look at the new extensibility framework and was surprised to see that the new framework is by far much easier to implement in VS2010. Although, I didn't take the time to migrate NShader to use this new framework, It seems to be pretty easy... also nice thing is that they did provide a compatibility layer for legacy Language Service, so I didn't bother with the new api. But If I had to write a new plugin for VS, I would definitely use the new API, although It would only work with VS2010+ versions...

One small recurrent disappointment : Visual Studio is still restricting to provide plugins for Express editions. From a "commercial point of view", I understand this restriction, although for the thousands (million maybe?) of people using express edition, this is a huge lack of functionality.I'm sure that allowing community plugins into Express Editions would in fact improve a lot more Visual Studio adoption.

My next post should be about the making of Ergon at BP2010. I have a couple of things to share about it, but I'm quite lazy at that time to write this post... but It's on the way! ;)

3 comments:

  1. Hi Alexandre,

    "Visual Studio is still restricting to provide plugins for Express editions"

    If I remember correctly, there is Visual Studio Shell: it's free and you can have plugins.

    LLB / Ctrl-Alt-Test

    ReplyDelete
  2. Hi LLB!
    Well, indeed I forgot to mention the shell, but the shell is just an empty shell no? I mean, the main interest for using NShader is to have it integrated in a c++ or c# IDE, avoiding the coder to switch to another external IDE... Or am I missing something here?

    ReplyDelete
  3. I uninstalled visual studio 2008 and installed visual studio 2010. Then when I try to uninstall nshader 1.0 I have an error message saying that "NShader 1.0 requires Visual Studio 2008". I don't want to re-install visual studio 2008, just for uninstalling NShader 1.0. How do you check if visual studio 2008 is installed ? Is that a registry key ? I could add it, unstall NShader 1.0 and then delete the registry key.

    Thank you

    ReplyDelete

Comments are disabled

Note: Only a member of this blog may post a comment.