yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
404e95cdd
master
1#version 450 core 2#extension GL_EXT_texture_shadow_lod : enable 3 4//TEST:SIMPLE(filecheck=CHECK_GLSL_QUAD_C): -allow-glsl -stage compute -entry computeMain -target glsl -DCOMPUTE -DQUAD 5// CHECK_GLSL_QUAD_C: GL_NV_compute_shader_derivatives 6// CHECK_GLSL_QUAD_C: layout(derivative_group_quadsNV) 7 8//TEST:SIMPLE(filecheck=CHECK_GLSL_LINEAR_C): -allow-glsl -stage compute -entry computeMain -target glsl -DCOMPUTE -DLINEAR 9// CHECK_GLSL_LINEAR_C: GL_NV_compute_shader_derivatives 10// CHECK_GLSL_LINEAR_C: layout(derivative_group_linearNV) 11 12//TEST:SIMPLE(filecheck=CHECK_SPV_QUAD_C): -allow-glsl -stage compute -entry computeMain -target spirv -DQUAD -DCOMPUTE 13// CHECK_SPV_QUAD_C: DerivativeGroupQuads{{NV|KHR}} 14// CHECK_SPV_QUAD_C-NOT: DerivativeGroupQuads{{NV|KHR}} 15// CHECK_SPV_QUAD_C: "SPV_KHR_compute_shader_derivatives" 16// CHECK_SPV_QUAD_C-NOT: "SPV_KHR_compute_shader_derivatives" 17 18//TEST:SIMPLE(filecheck=CHECK_SPV_LINEAR_C): -allow-glsl -stage compute -entry computeMain -target spirv -DLINEAR -DCOMPUTE 19// CHECK_SPV_LINEAR_C: DerivativeGroupLinear{{NV|KHR}} 20// CHECK_SPV_LINEAR_C-NOT: DerivativeGroupLinear{{NV|KHR}} 21// CHECK_SPV_LINEAR_C: "SPV_KHR_compute_shader_derivatives" 22// CHECK_SPV_LINEAR_C-NOT: "SPV_KHR_compute_shader_derivatives" 23 24//TEST:SIMPLE(filecheck=CHECK_HLSL_C): -allow-glsl -stage compute -entry computeMain -target hlsl -DCOMPUTE 25// CHECK_HLSL_C: computeMain( 26 27//TEST:SIMPLE(filecheck=CHECK_GLSL_F): -allow-glsl -stage fragment -entry computeMain -target glsl 28// CHECK_GLSL_F-NOT: GL_NV_compute_shader_derivatives 29 30//TEST:SIMPLE(filecheck=CHECK_SPV_QUAD_F): -allow-glsl -stage fragment -entry computeMain -target spirv -DQUAD 31// CHECK_SPV_QUAD_F-NOT: DerivativeGroupQuads{{NV|KHR}} 32// CHECK_SPV_QUAD_F-NOT: "SPV_KHR_compute_shader_derivatives" 33 34//TEST:SIMPLE(filecheck=CHECK_SPV_LINEAR_F): -allow-glsl -stage fragment -entry computeMain -target spirv -DLINEAR 35// CHECK_SPV_LINEAR_F-NOT: DerivativeGroupLinear{{NV|KHR}} 36// CHECK_SPV_LINEAR_F-NOT: "SPV_KHR_compute_shader_derivatives" 37 38//TEST:SIMPLE(filecheck=CHECK_GLSL_QUAD_F): -allow-glsl -stage fragment -entry computeMain -target glsl 39// CHECK_GLSL_QUAD_F-NOT: GL_NV_compute_shader_derivatives 40// CHECK_GLSL_QUAD_F-NOT: layout(derivative_group_quadsNV) 41 42//TEST:SIMPLE(filecheck=CHECK_HLSL_F): -allow-glsl -stage fragment -entry computeMain -target hlsl 43// CHECK_HLSL_F: computeMain( 44 45buffer MyBlockName 46{ 47 int result; 48} outputBuffer; 49 50uniform sampler1D uniform_sampler1D; 51 52__generic<T : ITexelElement> 53bool textureFuncs(Sampler1D<T> gsampler1D) 54{ 55 typealias gvec4 = vector<T.Element,4>; 56 57 constexpr ivec2 ivec2_0 = ivec2(0); 58 59 return true 60 // 8.9.1. Texture Query Functions 61 && int(0) == textureSize(gsampler1D, int(0)) 62 && vec2(0) == textureQueryLod(gsampler1D, float(0)) 63 && int(0) == textureQueryLevels(gsampler1D) 64 && gvec4(T.Element(0)) == texture(gsampler1D, float(0)) 65 && gvec4(T.Element(0)) == texture(gsampler1D, float(0), float(0)) 66 && gvec4(T.Element(0)) == textureProj(gsampler1D, vec2(0)) 67 && gvec4(T.Element(0)) == textureProj(gsampler1D, vec2(0), float(0)) 68 && gvec4(T.Element(0)) == textureProj(gsampler1D, vec4(0)) 69 && gvec4(T.Element(0)) == textureProj(gsampler1D, vec4(0), float(0)) 70 && gvec4(T.Element(0)) == textureLod(gsampler1D, float(0), float(0)) 71 && gvec4(T.Element(0)) == textureOffset(gsampler1D, float(0), __LINE__) 72 && gvec4(T.Element(0)) == textureOffset(gsampler1D, float(0), __LINE__, float(0)) 73 && gvec4(T.Element(0)) == texelFetch(gsampler1D, int(0), int(0)) 74 && gvec4(T.Element(0)) == texelFetchOffset(gsampler1D, int(0), int(0), __LINE__) 75 && gvec4(T.Element(0)) == textureProjOffset(gsampler1D, vec2(0), __LINE__) 76 && gvec4(T.Element(0)) == textureProjOffset(gsampler1D, vec2(0), __LINE__, float(0)) 77 && gvec4(T.Element(0)) == textureProjOffset(gsampler1D, vec4(0), __LINE__) 78 && gvec4(T.Element(0)) == textureProjOffset(gsampler1D, vec4(0), __LINE__,float(0)) 79 && gvec4(T.Element(0)) == textureLodOffset(gsampler1D, float(0), float(0), __LINE__) 80 && gvec4(T.Element(0)) == textureProjLod(gsampler1D, vec2(0), float(0)) 81 && gvec4(T.Element(0)) == textureProjLod(gsampler1D, vec4(0), float(0)) 82 && gvec4(T.Element(0)) == textureProjLodOffset(gsampler1D, vec2(0), float(0), __LINE__) 83 && gvec4(T.Element(0)) == textureProjLodOffset(gsampler1D, vec4(0), float(0), __LINE__) 84 && gvec4(T.Element(0)) == textureGrad(gsampler1D, float(0), float(0), float(0)) 85 && gvec4(T.Element(0)) == textureGradOffset(gsampler1D, float(0), float(0), float(0), __LINE__) 86 && gvec4(T.Element(0)) == textureProjGrad(gsampler1D, vec2(0), float(0), float(0)) 87 && gvec4(T.Element(0)) == textureProjGrad(gsampler1D, vec4(0), float(0), float(0)) 88 && gvec4(T.Element(0)) == textureProjGradOffset(gsampler1D, vec2(0), float(0), float(0), __LINE__) 89 && gvec4(T.Element(0)) == textureProjGradOffset(gsampler1D, vec4(0), float(0), float(0), __LINE__) 90 && vec4(0) == texture1D(uniform_sampler1D, float(0)) 91 && vec4(0) == texture1D(uniform_sampler1D, float(0), float(0)) 92 && vec4(0) == texture1DProj(uniform_sampler1D, vec2(0)) 93 && vec4(0) == texture1DProj(uniform_sampler1D, vec2(0), float(0)) 94 && vec4(0) == texture1DProj(uniform_sampler1D, vec4(0)) 95 && vec4(0) == texture1DProj(uniform_sampler1D, vec4(0), float(0)) 96 && vec4(0) == texture1DLod(uniform_sampler1D, float(0), float(0)) 97 && vec4(0) == texture1DProjLod(uniform_sampler1D, vec2(0), float(0)) 98 && vec4(0) == texture1DProjLod(uniform_sampler1D, vec4(0), float(0)) 99 ; 100} 101 102bool derivativeFunc() 103{ 104 return true 105 && dFdx(1.0f) != -1.0f 106 && dFdy(1.0f) != -1.0f 107 && dFdxFine(1.0f) != -1.0f 108 && dFdyFine(1.0f) != -1.0f 109 && dFdxCoarse(1.0f) != -1.0f 110 && dFdyCoarse(1.0f) != -1.0f 111 && fwidth(1.0f) != -1.0f 112 && fwidthFine(1.0f) != -1.0f 113 && fwidthCoarse(1.0f) != -1.0f 114 ; 115} 116 117 118#ifdef QUAD 119[DerivativeGroupQuad] 120#endif 121#ifdef LINEAR 122[DerivativeGroupLinear] 123#endif 124#ifdef COMPUTE 125[numthreads(2, 2, 1)] 126#endif 127void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 128{ 129 // CHECK_SPV: OpEntryPoint 130 outputBuffer.result = true 131 && textureFuncs(uniform_sampler1D) 132 && derivativeFunc() 133 ; 134}