Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
hlsl source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
AMD RGA 2.10
AMD RGA 2.11
AMD RGA 2.12
AMD RGA 2.13
AMD RGA 2.9.1
Clang (trunk)
DXC (trunk)
DXC 1.6.2112
DXC 1.7.2207
DXC 1.7.2212
DXC 1.7.2308
DXC 1.8.2306-preview
DXC 1.8.2403
DXC 1.8.2403.1
DXC 1.8.2403.2
DXC 1.8.2405
DXC 1.8.2407
DXC 1.8.2502
DXC 1.8.2505
DXC 1.8.2505.1
RGA 2.6.1 (DXC 1.6.2112)
RGA 2.6.1 (DXC 1.7.2207)
RGA 2.6.2 (DXC 1.6.2112)
RGA 2.6.2 (DXC 1.7.2207)
RGA 2.6.2 (DXC trunk)
RGA 2.9.0 (DXC trunk)
Options
Source code
// fxc -T vs_5_0 // dxc -T vs_6_0 // Foo defines name of cbuffer for reflection purposes, but does not define a // symbol available to reference in HLSL. // Declarations inside a cbuffer block are global declarations and their scope // is unaffected by the cbuffer declaration. cbuffer Foo { // float f; // Offset: 0 Size: 4 float f; } // 'k' is in $Globals, and $Globals is allocated first register(b0). float k; // One difference between FXC and DXC in nested case: // FXC binds Bar before nested cbuffers, while DXC binds Bar after nested // cbuffers. FXC behavior seems better here. cbuffer Bar { // float h; // Offset: 0 Size: 4 float h; // Nested cbuffer decl is legal, and doesn't impact the outer cbuffer // Second 'Foo' cbuffer is legal, as it does not define a symbol. // It shows up as another cbuffer named 'Foo' in reflection, rather than // adding to the previously declared 'Foo' cbuffer. cbuffer Foo { // float g; // Offset: 0 Size: 4 float g; // Nesting fine, even if the name matches the outer cbuffer. cbuffer Foo { float j; } } // namespaces may be used inside or around cbuffer declarations namespace NS { // next declaration unaffected by nested cbuffer declaration // float NS::i; // Offset: 4 Size: 4 float i; // any other global declaration may exist inside a cbuffer block. float foo() { return f * i + g * h + j * k; } } } float main() : OUT { return NS::foo(); }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree