Giter Club home page Giter Club logo

tgjones / hlsltools Goto Github PK

View Code? Open in Web Editor NEW
544.0 30.0 94.0 7.93 MB

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files

Home Page: http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released

License: Other

C# 44.24% GLSL 0.21% C 0.32% C++ 0.11% HLSL 51.34% PowerShell 0.11% TypeScript 0.09% ShaderLab 3.58% Batchfile 0.01%
hlsl visual-studio parser

hlsltools's Introduction

HLSL Tools for Visual Studio Join the chat at https://gitter.im/tgjones/HlslTools Build Status

This extension is for Visual Studio 2019 / 2022. Go here for the Visual Studio Code extension.

HLSL Tools is a Visual Studio 2019 / 2022 extension that provides enhanced support for editing High Level Shading Language (HLSL) files.

Download the extension at the Visual Studio Marketplace.

See the changelog for changes.

Why use HLSL Tools?

Since Visual Studio 2012, Visual Studio has shipped with basic support for editing HLSL files. In addition to that basic feature set, HLSL Tools includes many more navigational and editing features:

VS2019 / VS2022 VS2019 / VS2022 with HLSL Tools
Syntax highlighting Syntax highlighting
Automatic formatting Automatic formatting
Brace matching Brace matching
Brace completion Brace completion
Outlining Outlining
Statement completion
Signature help
Reference highlighting
Navigation bar
Navigate to (Ctrl+,)
Live errors
Go to definition
Quick info
Gray out code excluded by preprocessor
HLSL-specific preferences

There are more features on the roadmap.

Features

Statement completion

Just start typing, and HLSL Tools will show you a list of the available symbols (variables, functions, etc.) at that location. You can manually trigger this with the usual shortcuts: Ctrl+J, Ctrl+Space, etc.

Statement completion demo

Signature help

Signature help (a.k.a. parameter info) shows you all the overloads for a function call, along with information (from MSDN) about the function, its parameters, and return types. Typing an open parenthesis will trigger statement completion, as will the standard Ctrl+Shift+Space shortcut. Signature help is available for all HLSL functions and methods, including the older tex2D-style texture sampling functions, and the newer Texture2D.Sample-style methods.

Signature help demo

Reference highlighting

Placing the cursor within a symbol (local variable, function name, etc.) will cause all references to that symbol to be highlighted. Navigate between references using Ctrl+Shift+Up and Ctrl+Shift+Down.

Reference highlighting demo

Navigation bar

Navigation bar demo

Navigate To

HLSL Tools supports Visual Studio's Navigate To feature. Activate it with Ctrl+,, and start typing the name of the variable, function, or other symbol that you want to find.

Navigate To demo

Live errors

HLSL Tools shows you syntax and semantic errors immediately. No need to wait till compilation! Errors are shown as squigglies and in the error list.

Live errors demo

Go to definition

Press F12 to go to a symbol definition. Go to definition works for variables, fields, functions, classes, macros, and more.

Go to definition demo

Quick info

Hover over almost anything (variable, field, function call, macro, semantic, type, etc.) to see a Quick Info tooltip.

Quick info demo

Preprocessor support

HLSL Tools evaluates preprocessor directives as it parses your code, and grays out excluded code. If you want to make a code block visible to, or hidden from, HLSL Tools, use the __INTELLISENSE__ macro:

INTELLISENSE macro demo

Options

Configure HLSL-specific IntelliSense and formatting options. If you really want to, you can disable IntelliSense altogether and just use HLSL Tools' other features. You can also set HLSL-specific highlighting colours in Tools > Options > Environment > Fonts and Colors.

Options demo

Extras

The code

HLSL Tools includes a handwritten HLSL parser. It initially used an ANTLR lexer and parser, but the handwritten version was faster, and offered better error recovery.

HLSL Tools has a reasonable test suite - although it can certainly be improved. Amongst more granular tests, it includes a suite of 433 shaders, including all of the shaders from the DirectX and Nvidia SDKs. If you want to contribute gnarly source files which push HLSL to its limit, that would be great!

Syntax visualizer

Inspired by Roslyn, HLSL Tools includes a syntax visualizer. It's primarily of interest to HLSL Tools developers, but may be of interest to language nerds, so it's included in the main extension. Open it using View > Other Windows > HLSL Syntax Visualizer.

Syntax visualizer demo

Custom preprocessor definitions and additional include directories

HLSL Tools has a built-in preprocessor to handle #define and #include directives. The behavior of this preprocessor can be customised by creating a file named shadertoolsconfig.json:

{
  "hlsl.preprocessorDefinitions": {
    "MY_PREPROCESSOR_DEFINE_1": "Foo",
    "MY_PREPROCESSOR_DEFINE_2": 1
  },
  "hlsl.additionalIncludeDirectories": [
    "C:\\Code\\MyDirectoryA",
    "C:\\Code\\MyDirectoryB",
    ".",
    "..\\RelativeDirectory"
  ],
  "hlsl.virtualDirectoryMappings": {
    "/Project": "C:\\MyProject\\Shaders"
  }
}
  • hlsl.preprocessorDefinitions: It's normal for additional preprocessor definitions to be defined as part of a project build. In some cases, the shader won't compile correcty without these. To handle this, you can add those additional preprocessor definitions here.
  • hlsl.additionalIncludeDirectories: HLSL Tools will, by default, only use the directory containing the source file to search for #include files. Additional include directories can be added here.
  • hlsl.virtualDirectoryMappings: Use this to configure the virtual directory mappings required by Unreal Engine. The virtual directory (/Project in the example above) must start with a forward slash or backslash.

HLSL Tools will look for a file named shadertoolsconfig.json in the directory of an opened file, and in every parent directory. A search for shadertoolsconfig.json files will stop when the drive root is reached or a shadertoolsconfig.json file with "root": true is found. If multiple config files are found during this search, they will be combined, with properties in closer files taking precedence.

Config files are cached for performance reasons. If you make make changes to a config file, you'll need to close and re-open any source files that use that config file.

Getting involved

You can ask questions in our Gitter room. If you find a bug or want to request a feature, create an issue here . You can find me on Twitter at @_tim_jones_ and I tweet about HLSL Tools using the #hlsltools hashtag.

Contributions are always welcome. Please read the contributing guide first.

Maintainer(s)

Acknowledgements

  • Much of the code structure, and some of the actual code, comes from Roslyn.
  • NQuery-vnext is a nice example of a simplified Roslyn-style API, and HLSL Tools borrows some of its ideas and code.
  • Node.js Tools for Visual Studio and Python Tools for Visual Studio are amongst the best examples of how to build a language service for Visual Studio, and were a great help.
  • ScriptSharp is one of the older open-source .NET-related compilers, and is still a great example of how to structure a compiler.
  • LangSvcV2 includes many nice abstractions for some of the more complicated parts of Visual Studio's language service support.

hlsltools's People

Contributors

cgavalos avatar jjagg avatar jkunstwald avatar kstocky avatar lua9520 avatar mrvux avatar nielsbishere avatar ondrejpetrzilka avatar reedbeta avatar stef-levesque avatar tgjones avatar upwindspring01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hlsltools's Issues

Not handling # operator (stringification) in preprocesser macros

Example macro:

#define TEX_COMP_FULL(format, packed) string Build_TexComp_DdsFormat = #format; string Build_TexComp_IsPacked = #packed

Example usage:

TEX_COMP_FULL(dxt5, true);

Reports all these errors for the same line and column:
Error 1 Invalid expression term '#'.
Error 2 Found '#' but expected ''.
Error 3 Found '#' but expected ';'.
Error 4 Found 'dxt5' but expected '>'.
Error 5 Unexpected token 'dxt5'.
Error 6 Unexpected token '#'.
Error 7 Invalid expression term '#'.
Error 8 Found '#' but expected ''.
Error 9 Found '#' but expected ';'.
Error 10 Unexpected token '#'.

Exception when going to options/formatting/spacing page.

Using Visual Studio 2013 and HLSL tools v0.9.75. When I went to the spacing page of the formatting options of the HLSL editor options I get and exception.

The Activity log has this as the error:

  <entry>
    <record>897</record>
    <time>2016/04/05 20:16:41.290</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentException: The specified ITextSnapshot doesn&apos;t belong to the correct TextBuffer.&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.SnapshotSpan.TranslateTo(ITextSnapshot targetSnapshot, SpanTrackingMode spanTrackingMode)&#x000D;&#x000A;   at HlslTools.VisualStudio.Tagging.AsyncTagger`1.&lt;&gt;c__DisplayClass4_0.&lt;GetTags&gt;b__1(LineBasedTagSpan x)&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()&#x000D;&#x000A;   at System.Linq.Enumerable.&lt;TakeWhileIterator&gt;d__26`1.MoveNext()&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()&#x000D;&#x000A;   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&#x000D;&#x000A;   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)&#x000D;&#x000A;   at HlslTools.VisualStudio.Tagging.AsyncTagger`1.GetTags(SnapshotSpan targetSnapshotSpan)&#x000D;&#x000A;   at System.Linq.Enumerable.&lt;SelectManyIterator&gt;d__16`2.MoveNext()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.&lt;GetTagsForBuffer&gt;d__5.MoveNext()</description>
  </entry>

IntelliSense fails with NullReferenceException

From @UpwindSpring01:

Crashes with a NullReferenceException on autocomplete when using the extension.

Steps to reproduce:

Create a new vertex shader.

Add the boilerplate code:

float4 main( float4 pos : POSITION ) : SV_POSITION
{
    return pos;
}

Now place your cursor at the very front of the first line and type a letter so you get:

mfloat4 main( float4 pos : POSITION ) : SV_POSITION
{
    return pos;
}

It will crash.

@UpwindSpring01's suggested patch:

patch.txt

Implement keyword completion

Within a .hlsl file, if you type "return" then hit space it will be autocompleted and replaced by "reflect" an hlsl function.

Make SourceFieldSymbol public?

Hi,
I'm using SourceFieldSymbol to access Syntax property (VariableDeclaratorSyntax), would be possible to make it public, no need public constructor.

Thank you

Integer suffix not recognized

It looks as though integer suffixes are not recognized by the parser (I don't think the octal prefix is either), for example:

uint numFoo = 4u;

causes the rest of the line to parse incorrectly giving context dependent (but incorrect) errors.

Struct with methods

HLSL supports struct with methods, but it's not yet supported into HlslTools.

I should be fairly simple, since classes with methods are already implemented.

Feature: Add support for min16<type>types

Hello!

First off, thanks for the extension, I'm a big fan.

My request is to add support for the min16float3(etc...) types. I'm using VS2015 and HLSLTools and they are not recognized.

IntrinsicTypes.GetVectorType and GetMatrixType wrong access

I found out that the type return is wrong, the access should be:

public static TypeSymbol GetVectorType(ScalarType scalarType, int numComponents)
{
    var index = (((int)scalarType - 1) * 4) + numComponents;
    return AllVectorTypes[index - 1];
    //return AllVectorTypes[(((int)scalarType - 1) * 4) + (numComponents - 1)];
}
public static TypeSymbol GetMatrixType(ScalarType scalarType, int numRows, int numCols)
{
    var index = (((int)scalarType - 2) * 16) + (numRows * 4) + (numCols * 4);
    return AllMatrixTypes[index - 1];
    //return AllMatrixTypes[(((int)scalarType - 1) * 16) + (numRows * 4) + numCols];
}

Not handling ##

Reports "Found '##' but expected '#'."

is valid in HLSL preprocessor.

export statement missing for library shader units

Hello,
as mentioned in the title, when requiring compilation with "lib_5_0" (in order to use function linking graph of function reflection), we need the export keyword, which for now brings a syntax error.

This is easy to reproduce:

export float3 TestFunction(float3 input)
{
      return input * 2.0f;
}

Is valid when using D3DCompile and library profile, but produces :
Unexpected token 'export'

error message

Class fields cannot be accessed

See example below.
Maybe it considers fields private-by-default like in C++ class? In HLSL there are no private fields.

Example:

class Rng
{
    uint state;
    void SetState(uint seed) { state = seed; }
    // some methods omitted
};

// Creates random number generator
Rng CreateRng(uint seed)
{
    Rng r;
    r.state = seed; // Error: Type 'Rng' does not have a field 'state'.
    r.SetState(seed); // Works fine
    return r;
}

struct inheritance not recognized

using struct inheritance in the following example causes an error on the line declaring 'Bar':

Found ':' but expected '{'.
Unexpected token ':'.
Found ':' but expected '}'.

Additionally, autocomplete fails to understand member accessors for inherited members.

struct Foo
{
    float foo1;
    float foo2;
};

struct Bar : Foo
{
    float bar1;
};

void main()
{
    Bar bar = { 0, 0, 0 };
    float foo1 = bar.foo1;
}

Implement comma operator

(Thanks @reltham for the example shader where I noticed this.)

The parser in HLSL Tools needs to support the comma operator:

int a, b;
a = 0, b = 1;

Incorrect error report on number of params to macro.

Reports "Not enough actual parameters for macro 'RANGED_PARAM_DEFN'."

The macro in question takes 6 params, and 6 params are passed.

Example usage:
RANGED_PARAM_DEFN(float, g_Transparency, Transparency, "Transparency", 0, 1) = 0.5;

Macro definition:

#define RANGED_PARAM_DEFN(type, name, semantic, desc, min, max) type name: semantic <string InstanceCached="true"; string FriendlyName=desc; type UIMin=min; type MinValue=min; type UIMax=max; type MaxValue=max;>

I get this for a few different macro definitions that are similar to this one.

Macro argument '2D' treated as integer, causes error

This test of macros:

#define EXTRA_FULL_TEX_DEFN(name, desc, semantic, sampler_type, addressing, default_file, min_filter, mag_filter, mip_filter, anisotropy) texture name##Texture : semantic \
< \
    string UIName = desc; \
    string ResourceType = #sampler_type; \
    string ResourceName = DEF_TEXTURE_PATH##default_file;\
>; \
sampler name##Sampler = sampler_state { \
    Texture = <name##Texture>; \
    addressu = addressing; addressv = addressing; addressw = addressing; \
    minfilter = min_filter; magfilter = mag_filter; mipfilter = mip_filter;  \
    MaxAnisotropy = anisotropy; \
}

#define FULL_TEX_DEFN(name, desc, semantic, sampler_type, addressing, default_file) EXTRA_FULL_TEX_DEFN(name, desc, semantic, sampler_type, addressing, default_file, Anisotropic, linear, linear, 16)

#define STANDARD_TEX_DEFN(name, desc, default_file) FULL_TEX_DEFN(name, desc, name, 2D, wrap, default_file)

#define STANDARD_TEXTURE_SAMPLER_DEFN(name, semantic, desc) FULL_TEX_DEFN(name, desc, name, 2D, wrap, DEF_TEXTURE_PATH "white.tga")

Reports this error several times per line:
Error 8 '2D' is not a valid integer.

Please don't enforce a specific brace style.

I really love this plugin, but it moves my braces all the time and it really drives me up the wall.

Could we get an option in the settings to disable this behavior?

Thank you for the plugin!

Fails install on VS 2013 Pro.

Attempting to install into VS 2013 Pro (Update 5). Fails with dialog saying "This extension is not installable on any currently installed products."

Error spew from installer:

10/6/2015 1:30:11 PM - Microsoft VSIX Installer
10/6/2015 1:30:11 PM - -------------------------------------------
10/6/2015 1:30:11 PM - Initializing Install...
10/6/2015 1:30:12 PM - Extension Details...
10/6/2015 1:30:12 PM - Identifier : 7def6c01-a05e-42e6-953d-3fdea1891737
10/6/2015 1:30:12 PM - Name : HLSL Tools for Visual Studio
10/6/2015 1:30:12 PM - Author : Tim Jones
10/6/2015 1:30:12 PM - Version : 0.9.10
10/6/2015 1:30:12 PM - Description : Enhanced support for editing HLSL in Visual Studio
10/6/2015 1:30:12 PM - Locale : en-US
10/6/2015 1:30:12 PM - MoreInfoURL : https://github.com/tgjones/HlslTools
10/6/2015 1:30:12 PM - InstalledByMSI : False
10/6/2015 1:30:12 PM - SupportedFrameworkVersionRange : [4.5,)
10/6/2015 1:30:12 PM -
10/6/2015 1:30:12 PM - Supported Products :
10/6/2015 1:30:12 PM - Microsoft.VisualStudio.Community
10/6/2015 1:30:12 PM - Version : [12.0,15.0)
10/6/2015 1:30:12 PM -
10/6/2015 1:30:12 PM - References :
10/6/2015 1:30:12 PM - -------------------------------------------------------
10/6/2015 1:30:12 PM - Identifier : Microsoft.VisualStudio.MPF.12.0
10/6/2015 1:30:12 PM - Name : Visual Studio MPF 12.0
10/6/2015 1:30:12 PM - Version : [12.0]
10/6/2015 1:30:12 PM - MoreInfoURL :
10/6/2015 1:30:12 PM - Nested : No
10/6/2015 1:30:12 PM -
10/6/2015 1:30:12 PM -
10/6/2015 1:30:12 PM - Searching for applicable products...
10/6/2015 1:30:12 PM - Found installed product - Microsoft Visual Studio 2010 Professional
10/6/2015 1:30:12 PM - Found installed product - Microsoft Visual Studio Professional 2013
10/6/2015 1:30:12 PM - Found installed product - Microsoft Visual Studio 2013 Shell (Integrated)
10/6/2015 1:30:12 PM - Found installed product - Global Location
10/6/2015 1:30:12 PM - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
at VSIXInstaller.App.InitializeInstall()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Problems with ## in macro body

These macros:

#define JUST_PS_TECH_FULL(name, channels, uvchannels, outputfunc, state) float4 PS_Just##name(PS_INPUT IN): COLOR { \
    float4 alpha = 1; \
    alpha.channels = tex2D(g_##name##Sampler, IN.##uvchannels ).channels; \
    return float4(outputfunc((float3)tex2D(g_##name##Sampler, IN.##uvchannels ).channels), alpha.a); } \
technique Just##name {  pass p0 { state \
    Vertexshader = compile vs_3_0 VS_Default();  pixelshader = compile ps_3_0 PS_Just##name(); }}

#define JUST_PS_TECH(name, channels, uvchannels) JUST_PS_TECH_FULL(name, channels, uvchannels, Float3PassthroughFunc, AlphaBlendEnable = false;)

Example Usage:

JUST_PS_TECH(Color, rgb, v4TexCoords.xy);

Reports these errors for any line attempting to use JUST_PS_TECH(...):
Error 254 Found '##' but expected ')'.
Error 255 Found '##' but expected ';'.
Error 256 Unexpected token '##'.
Error 257 Found '##' but expected '}'.
Error 258 Found ',' but expected ';'.
Error 259 Unexpected token ','.
Error 260 Found ',' but expected '}'.
Error 261 Unexpected token '.'.
Error 262 Found ')' but expected ';'.
Error 263 Unexpected token ')'.
Error 264 Found ')' but expected '}'.
Error 265 Found ';' but expected ''.
Error 266 Found '##' but expected ')'.
Error 267 Found '##' but expected ')'.
Error 268 Found '##' but expected ')'.
Error 269 Found '##' but expected ';'.
Error 270 Unexpected token '##'.
Error 271 Found '##' but expected '}'.
Error 272 Found ',' but expected ';'.
Error 273 Unexpected token ','.
Error 274 Found ',' but expected '}'.
Error 275 Unexpected token '.'.
Error 276 Found ')' but expected ';'.
Error 277 Unexpected token ')'.
Error 278 Found ')' but expected '}'.
Error 279 Found ')' but expected ';'.
Error 280 Unexpected token ')'.
Error 281 Found ')' but expected '}'.
Error 282 Unexpected token ')'.

Errors appear when accessing namespace members

As an example, the following code snippet produces the errors on the line assigning 'bar':

Found ';' but expected '('.
Invalid expression term ';'
Found ';' but expected ''.
Found ';' but expected ')'.

namespace NS
{
    static const int foo = 4;
}

void main()
{
    int bar = NS::foo;
}

Macros does not work with #ifdef

I have added my defined by accessing:
options.PreprocessorDefines.Add("VERTEX_COLOR")

Then in my shader if I have #if VERTEX_COLOR it works, but if I have #ifdef VERTEX_COLOR does not work.

Feature request: define macros in project settings

Unreal Engine 4 shaders are heavily #ifdefed, and most of those are defined at shader compile time by CPU code. This results in large parts of code being greyed out in the VS editor due to #if arguments evaluating to 0.

Thus, it would be nice to define these from a dialog somewhere, preferably associated with the project.

Error with function declared in macro

I'm seeing some rather confusing behaviour when I have a preprocessor macro that defines a function. The most obvious issue is that the Intellisense gives an error saying the function is not declared:

errortooltip

Then, if I hover over the declaration in the macro, the tooltip is all screwy:

badtooltip

Then, if I manually declare the function as well, it (correctly) gives a re-definition error. So obviously it was able to parse the macro and expand the definition, but for whatever reason it isn't found at the callsite.

redefinitionerror

I did have a quick go at debugging this, and there seems to be some oddities for the names of identifiers for things that have been expanded from macros, but it could just be me misunderstanding. I'm afraid I then got a bit lost and gave up :(.

I'm using the latest preview version from vsixgallery, 1.0.146, but the behaviour appears to be unchanged from the previous version I was using (don't know what that was though).

Here's the file that reproduces the problem:
FunctionMacroRepro.zip

typedef does not work

doing a typedef in hlsl results in an error "Unexpected token 'typedef'." and of course those types are reported as unrecognized in the proceeding code.

typedef float2 Point;
Point p;

Line numbers for errors don't always match actual error.

Getting lots of the false preprocessor errors being reported on the wrong lines.

The red underline thing seems to be right.

Additional info:
I'm seeing this in included files. Primarily ones that get included by a lot of shaders in my solution. We have around 50 shaders and another 50 or so shader headers, many of which are included by a bunch of the shaders. I end up with dozens of the same error on the same line of the fxh files, sometimes with different line numbers. Would be nice if the error in an include said what file it was included from.

Not properly handling quotation marks in macros

These macros:

#define START_DEFAULT_TEX_LIST string Build_SourceDefaults = "{"
#define DEFAULT_TEX(name, value) "'"#name"':'"#value"',"
#define END_DEFAULT_TEX_LIST "}";

Usage example:

texture g_NormalTexture
<
    // other stuff here snipped

    START_DEFAULT_TEX_LIST
        DEFAULT_TEX(g_OverlayMaskTexture, art/shaders/DefaultTextures/White.tga)    
        DEFAULT_TEX(g_EmissiveTexture, art/shaders/DefaultTextures/Black.tga)   
    END_DEFAULT_TEX_LIST
>;

Reports these errors for the the lines that have DEFAULT_TAX(...):
Error 1 Found '"',"' but expected ';'.
Error 2 Found 'tga' but expected '>'.
Error 3 Found 'tga' but expected ';'.
Error 4 Unexpected token '"',"'.
Error 5 Found '"',"' but expected ''.
Error 6 Found '"',"' but expected ';'.
Error 7 Unexpected token '"',"'.

Add ConstantBufferSymbol support

Now all constant buffers variables are added as global VariableSymbol, would be nice to have also the ConstantBuffer symbol support.

lineadj keyword unrecognized

using the lineadj keyword on a parameter to your shaders main function causes the errors:

Unexpected token 'lineadj'.
Found 'lineadj' but expected ')'.

error when casting array with const variable size

doing an array cast (for initialization) works fine with a number inline, but seems to confuse the parser if the size of the array is specified as a constant.

static const uint numFoo = 4;

void main()
{
    uint bars[4] = (uint[4])0;  <- Fine
    uint foos[numFoo] = (uint[numFoo])0; <- Errors
}

Incorrect autocomplete

If you have a Texture2D named NormalMap, and then inside a function you declare a float3 called normal, then later, when typing normal, it will autochange it to NormalMap with any input ("." or " ") apart from right arrow key.

Extract HLSL Preprocessor Definitions / Additional Include Directories from Visual C++ property pages

Hey,
I'm now creating the issue here, since VSGallery does not notify me on your answers.

Our directorystructure looks like this:
image

If I now include a Pixelshader from within another Pixelshader - everything works fine.
image

Includes from other directories (SpecularLighting.hlsli is in the folder "Globals") are shown as errors.

The Globals and BufferLayouts however are set as Addition Include Directories in in the Property Pages of the Shaderfile:
image

So it compiles without a problem, but the hlsltools think it's an error.

best regards!

Visual Studio crashes when HLSL file is opened, v1.0.144

Visual Studio crashes when HLSL file is opened, v1.0.144

VS2015 Community, Update 3, Win7 x64 SP1.

Download and open project
Open test.hlsl file in root
Crash

Stack trace:
https://paste2.org/VjeC5OGw

Project:
https://1drv.ms/u/s!AiK6FU3sliYQeVuCfpzX5ixZbO8

EDIT:
1.0.133 does not crash

EDIT 2:
Crash is here:

foreach (var preprocessorDefinition in configFile.HlslPreprocessorDefinitions)

NullReferenceException, configFile.HlslPreprocessorDefinitions can be null

Crash when commenting out #if conditions

As mentioned on Twitter, going from this:
#if FOO
To this:
#if //FOO
Causes MSVS to crash some 1-2 seconds after releasing the slash key. My intention was to temporarily disable the condition for testing by replacing it with a 1.

When attaching another MSVS instance to debug, I get the following callstack:

>   mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ThrowAsync.AnonymousMethod__5(object state) + 0x35 bytes    
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x42 bytes 
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xb4 bytes  
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes  
    mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes 
    mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x153 bytes  
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0xa bytes 
    [Native to Managed Transition]  

Threads:

Not Flagged     5840    28  Worker Thread   <No Name>       Normal
Not Flagged     13748   1   Main Thread Main Thread System.Windows.DescendentsWalker<System.Windows.InheritablePropertyChangeInfo>.VisitNode()  Normal
Not Flagged     0   0   Unknown Thread  [Thread Destroyed]      
Not Flagged     14460   2   Worker Thread   <No Name>       Highest
Not Flagged     10764   0   Worker Thread   <No Name>       Normal
Not Flagged     15104   6   Worker Thread   <No Name>   System.Threading.Monitor.Wait() Normal
Not Flagged     11096   7   Worker Thread   StatusBar   [Managed to Native Transition]  Normal
Not Flagged     15264   0   Worker Thread   <No Name>       Normal
Not Flagged     10796   0   Worker Thread   <No Name>       Normal
Not Flagged     7484    18  Worker Thread   <No Name>   System.Threading.WaitHandle.WaitAny()   Normal
Not Flagged     10964   20  Worker Thread   <No Name>   System.Threading.WaitHandle.WaitAny()   Normal
Not Flagged     13928   21  Worker Thread   Worker Thread   System.Threading.WaitHandle.WaitAny()   Normal
Not Flagged     14396   24  Worker Thread   <No Name>       Normal
Not Flagged     6540    0   Worker Thread   <No Name>       Normal
Not Flagged     14308   39  Worker Thread   <No Name>       Normal
Not Flagged >   15136   10  Worker Thread   Worker Thread   System.Runtime.CompilerServices.AsyncMethodBuilderCore.ThrowAsync.AnonymousMethod__5()  Normal
Not Flagged     0   0   Unknown Thread  [Thread Destroyed]      

Visual Studio version is Community 2013 with all the latest updates.

Not allowing 'default' as macro argument name

This Macro:

#define BASE_TINT_MASK(suffix, default) \
STANDARD_TEX_DEFN(g_BaseTintMask##suffix, "Base tint " #suffix " mask [UV0] (TM)", #default ".tga");

Reports these errors:
Error 16 Found 'default' but expected ''.
Error 17 Unexpected token 'default'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.