Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Clang format for shader files

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
4JMark Posted - May 30 2023 : 05:53:14 AM
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
7   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Feb 19 2024 : 12:59:09 PM
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.
snv Posted - Feb 19 2024 : 06:32:45 AM
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?
feline Posted - Jun 02 2023 : 2:25:34 PM
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
4JMark Posted - Jun 01 2023 : 09:59:10 AM
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


feline Posted - Jun 01 2023 : 07:33:10 AM
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.
4JMark Posted - May 31 2023 : 09:29:09 AM
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
feline Posted - May 31 2023 : 07:44:18 AM
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?

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