Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Clang format for shader files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

4JMark
New Member

United Kingdom
3 Posts

Posted - May 30 2023 :  05:53:14 AM  Show Profile  Reply with Quote
Hi,
we use clang format for our shader files, and also use this extension to format on save.

https://marketplace.visualstudio.com/items?itemName=WinstonFeng.VSFormatOnSave2022

Unfortunately, when we enable VA shader support, format on save no longer works. Could this be looked into for a future build please?

Thanks
Mark

Mark Hughes

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - May 31 2023 :  07:44:18 AM  Show Profile  Reply with Quote
I have installed this extension on a clean test system, VA has never been and is not currently installed.

I have opened a .USF file, and made a mess of the formatting. Saving the file does nothing. Looking at the plugin description, it says it does the same as telling the IDE to format the document. So I selected everything and trigger CTRL-K, CTRL-F, and I get the error message that Format Selection is not currently available.

What do I need to know to make this work?

zen is the art of being at one with the two'ness
Go to Top of Page

4JMark
New Member

United Kingdom
3 Posts

Posted - May 31 2023 :  09:29:09 AM  Show Profile  Reply with Quote
OK, I've been testing with files that have a .hlsl extension here, not .usf

Ignoring the plugin for now, if I just edit a .hlsl file, I can normally invoke
edit->Advanced->Format Document Ctrl+K Ctrl+D
or
edit->Advanced->Format Selection Ctrl+K Ctrl+F
and it will run clang format.

If I then check the box "Enable support for shader file (beta)" in the VA options and reboot VS, both those format options are missing from the edit-Advanced menu, so there isn't any way to format the doc.

Just checking with a test .usf file here, and yeah, I can confirm that both those format options are missing from VS even with VA disabled, but then VS isn't aware of what a .usf file is, so doesn't syntax colour either.
Hope that all makes sense.

Thanks
Mark

Mark Hughes
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jun 01 2023 :  07:33:10 AM  Show Profile  Reply with Quote
Which version of Visual Studio 2022 are you using?

Do you have a ".clang-format" file in your solution directory tree? If so, would it be possible to get a copy of this file. It is possible that is a factor, since so far I still cannot get formatting to do anything. I have opened a HLSL file, and the IDE menu:

Edit -> Advanced

is several items shorter when I have a HLSL file open, and the format document and format selection entries are missing.

Or it could be down to the components of VS2022 you have installed.

zen is the art of being at one with the two'ness
Go to Top of Page

4JMark
New Member

United Kingdom
3 Posts

Posted - Jun 01 2023 :  09:59:10 AM  Show Profile  Reply with Quote
VS2022 Version 17.5.1
I've included the contents of our clang format file below, and also a screenshot of the installed VS components.
Thanks again for looking into this.





AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators : false
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: false
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth : 4
Cpp11BracedListStyle: true
FixNamespaceComments: true
IncludeCategories:
  - Regex:           '^("stdafx.h"|"pch.h")'
    Priority:        -1
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
PointerAlignment: Left
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Always
SpacesInLineCommentPrefix:
  Minimum:         0
  Maximum:         -1



Mark Hughes
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jun 02 2023 :  2:25:34 PM  Show Profile  Reply with Quote
Thank you for the details, I am now seeing the same problem here. It turns out that the rules for the IDE formatting a shader file change in VS2022 version 17.6.0, which complicated my tests.

It turns out that the format document menu option disappears from VS2022 with VA shader support enabled in versions of VS2022 earlier than 17.6.0

case=149601

zen is the art of being at one with the two'ness
Go to Top of Page

snv
Starting Member

1 Posts

Posted - Feb 19 2024 :  06:32:45 AM  Show Profile  Reply with Quote
Hi!
We are also facing the same issue. VA is up-to-date and we are using VS 2022. As soon as the shader support is enabled, auto-formatting doesn't work anymore. Is there a workaround for this or any update on the ticket?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Feb 19 2024 :  12:59:09 PM  Show Profile  Reply with Quote
Unfortunately no update on this yet. As a possible work around, assuming you don't need to have the file formatted all of the time while editing, you can disable VA via:

VAssistX -> Enable/Disable Visual Assist X

and this enables the IDE formatting command, so you can then tell the IDE to format the entire shader file, and then enable VA again afterwards. It's not the same, but perhaps helpful.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000