yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
99de1a620
master
1//TEST:SIMPLE(filecheck=SAMPLER): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSAMPLER 2//TEST:SIMPLE(filecheck=COMBINED_IMAGE_SAMPLER): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DCOMBINED_IMAGE_SAMPLER 3//TEST:SIMPLE(filecheck=SAMPLED_IMAGE): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSAMPLED_IMAGE 4//TEST:SIMPLE(filecheck=STORAGE_IMAGE): -target spirv -capability spvBindlessTextureNV -stage compute -entry computeMain -DSTORAGE_IMAGE 5 6[[vk::binding(0)]] RWTexture1D<float> t1; 7[[vk::binding(1)]] RWTexture1D<float> t2; 8[[vk::binding(2)]] RWTexture1D<float> t3; 9[[vk::binding(3)]] Texture1D<float> t4; 10 11#ifdef SAMPLER 12//SAMPLER: [[SType:%[0-9]+]] = OpTypeSampler 13//SAMPLER: OpConvertUToSamplerNV [[SType]] 14//SAMPLER: OpSampledImage 15uniform SamplerState.Handle sampler; 16#endif 17 18#ifdef COMBINED_IMAGE_SAMPLER 19//COMBINED_IMAGE_SAMPLER: [[SIType:%[0-9]+]] = OpTypeSampledImage 20//COMBINED_IMAGE_SAMPLER: OpConvertUToSampledImageNV [[SIType]] 21uniform Sampler1DShadow.Handle combinedSampler; 22#endif 23 24#ifdef SAMPLED_IMAGE 25//SAMPLED_IMAGE: [[IType0:%[0-9]+]] = OpTypeImage 26//SAMPLED_IMAGE: [[IType1:%[0-9]+]] = OpTypeImage 27//SAMPLED_IMAGE: OpConvertUToSampledImageNV [[IType1]] 28//SAMPLED_IMAGE: OpImageFetch 29uniform Texture1D<float>.Handle texture; 30#endif 31 32#ifdef STORAGE_IMAGE 33//STORAGE_IMAGE: OpConvertUToSampledImageNV 34//STORAGE_IMAGE: OpImageRead 35//STORAGE_IMAGE: OpConvertUToSampledImageNV 36//STORAGE_IMAGE: OpImageRead 37uniform RWTexture1D<float>.Handle rwTexture1; 38uniform RWTexture2D<float>.Handle rwTexture2; 39#endif 40 41[shader("compute")] 42[numthreads(8, 8, 1)] 43void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 44{ 45 t1[0] = t2[0] + t2[0] + t4[0]; 46 47#ifdef SAMPLER 48 t1[2] = t4.Sample(sampler, 0); 49#endif 50 51#ifdef COMBINED_IMAGE_SAMPLER 52 t1[8] = combinedSampler.Sample(0); 53#endif 54 55#ifdef SAMPLED_IMAGE 56 t1[0] = texture[0]; 57#endif 58 59#ifdef STORAGE_IMAGE 60 t1[11] = rwTexture1[0]; 61 t1[12] = rwTexture2[0]; 62#endif 63} 64