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 (assertions trunk)
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
struct LineStyle { const static uint32_t StipplePatternMaxSize = 14u; // common data float32_t4 color; float screenSpaceLineWidth; float worldSpaceLineWidth; // stipple pattern data int32_t stipplePatternSize; float reciprocalStipplePatternLen; uint32_t stipplePattern[StipplePatternMaxSize]; // packed float into uint (top two msb indicate leftIsDotPattern and rightIsDotPattern as an optimization) uint32_t isRoadStyleFlag; uint32_t rigidSegmentIdx; // TODO: can be more mem efficient with styles by packing this along other values, since stipple pattern size is bounded by StipplePatternMaxSize float getStippleValue(const uint32_t ix) { const uint32_t floatValBis = 0xffffffff >> 2; // clear two msb bits reserved for something else return (stipplePattern[ix] & floatValBis) / float(1u << 29); } void setStippleValue(const uint32_t ix, const float val) { stipplePattern[ix] = (uint32_t)(val * (1u << 29u)); } bool isLeftDot(const uint32_t ix) { // stipplePatternSize is odd by construction (pattern starts with + and ends with -) return (stipplePattern[ix] & (1u << 30)) > 0; } bool isRightDot(const uint32_t ix) { // stipplePatternSize is odd by construction (pattern starts with + and ends with -) return (stipplePattern[ix] & (1u << 31)) > 0; } bool hasStipples() { return stipplePatternSize > 0 ? true : false; } void stretch(float stretch) { reciprocalStipplePatternLen /= stretch; } }; inline bool operator==(const LineStyle& lhs, const LineStyle& rhs) { const bool areParametersEqual = lhs.color == rhs.color && lhs.screenSpaceLineWidth == rhs.screenSpaceLineWidth && lhs.worldSpaceLineWidth == rhs.worldSpaceLineWidth && lhs.stipplePatternSize == rhs.stipplePatternSize && lhs.reciprocalStipplePatternLen == rhs.reciprocalStipplePatternLen && lhs.isRoadStyleFlag == rhs.isRoadStyleFlag && lhs.rigidSegmentIdx == rhs.rigidSegmentIdx; if (!areParametersEqual) return false; const bool isStipplePatternArrayEqual = (lhs.stipplePatternSize > 0) ? (std::memcmp(lhs.stipplePattern, rhs.stipplePattern, sizeof(uint32_t) * lhs.stipplePatternSize) == 0) : true; return isStipplePatternArrayEqual; } struct PSInput { float4 color : COLOR; }; float4 PSMain(PSInput input) : SV_TARGET { return input.color; }
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