Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Defines for HLSL

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
jojoba Posted - Feb 21 2025 : 09:15:56 AM
I used to use the HLSL Tools for Visual Studio extension (https://marketplace.visualstudio.com/items?itemName=TimGJones.HLSLToolsforVisualStudio) for HLSL syntax highlighting but it doesn't work anymore since VS17.12, so I have to rely on VAX for syntax highlighting now, which I'm mostly satisfied with so far.
However, one thing I'm missing is the ability to visualize active/inactive code sections (based on #defines). HLSL tools
handled it very simply by leveraging the "__INTELLISENSE__" define : within a #if defined(__INTELLISENSE__) block, you would set the values of the "active" defines in a given file, just for the purpose of having syntax highlighting work on the code sections that are active and show inactive code elsewhere.
e.g.

#if defined (__INTELLISENSE__)
// Uncomment the appropriate define for enabling syntax highlighting with HLSL Tools for Visual Studio : 
#define SOME_DEFINE 1
//#define SOME_OTHER_DEFINE 1
#endif // defined (__INTELLISENSE__)

#if SOME_DEFINE
[Code Section #1]
#endif // SOME_DEFINE

#if SOME_OTHER_DEFINE
[Code Section #2]
#endif // SOME_OTHER_DEFINE

In such a case, Code Section #1 would appear as active code, with proper syntax hightlighting, and Code Section #2, as inactive code

It comes in pretty handy when developing Unreal Engine shaders as there can be several permutations of such defines for a given shader, so this way, it's very easy to visualize what is active and what is not, for a specific permutation, by just enabling/disabling those defines in the __INTELLISENSE__ section (which otherwise doesn't affect the generated code in the slightest).

Would it be possible to implement a feature such as this? I don't believe it'd be specific to Unreal. At least, in the HLSL Tools extension case, this implementation was very generic.

Thanks!
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Feb 21 2025 : 12:02:36 PM
Many years ago I had a "solution" to this problem, it was an IDE macro, that simply found the start and end of blocks, and then used the outline feature to collapse the marked blocks. Unfortunately so few people used the IDE macro programming language that Microsoft removed it years ago.

If that approach sounds interesting, once you have the idea, and an extension that would let you write a macro, it wasn't to difficult to do.

For this, there was a breaking change in Visual Studio 2022 version 17.12.0 that stopped VA's syntax highlighting working in shader files, and I suspect exactly the same change is what caused the problem for the HLSL Tools extension you were using. I see this extension was last updated in 2022, so I am not sure if anyone is still working on it or not.

For reference, the VA case for fixing this is:

case=165194

Since Microsoft seems to be actively working on Shader support, it is likely they will add support for this themselves sooner or later.

VA is designed to be active in, and working in the inactive code blocks, because you will want editing support even when the code isn't compiling on your current platform. Still, this has been requested with an eye on Unreal Engine, and people who have disabled IDE intellisense, so I have put a note on it, adding your request for this in shader files:

case=110974

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000