shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

Support glslang [[spv::format_formatName]] syntax #3786

Open ArielG-NV opened 3 months ago

ArielG-NV commented 3 months ago

nv-ray-tracing-motion-blur.slang & raygen.slang both used for the output image:

layout(rgba8)
RWTexture2D<float4> outputImage;

glslang cross compiles this (HLSL->SPIR-V) incorrectly into:

%251 = OpTypeImage %float 2D 0 0 0 2 Rgba32f

Slang does not follow this behavior due to parsing a format modifier from layout(format). Slang outputs %251 = OpTypeImage %float 2D 0 0 0 2 Rgba8f

glslang covers the incorrect compiling case with the solution of [[spv::format_rgba8]] as general syntax for specifying layout if spirv is the target. Slang should support this syntax to properly compile with a larger subset of GLSL syntax.

bmillsNV commented 1 month ago

Nice to have. Lowering Priority to P3 and setting Milestone to Q3