yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Anders LeinoRefresh of disabled WGPU tests (#5614)93f5d13fc

master
3.0 KiB121 linesraw
1//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type
2//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type -vk
3//TEST(compute):COMPARE_RENDER_COMPUTE: -shaderobj -output-using-type -mtl
4
5
6//TEST_INPUT: Texture1D(size=4, content = one):name=t1D
7//TEST_INPUT: Texture2D(size=4, content = one):name=t2D
8//TEST_INPUT: Texture3D(size=4, content = one):name=t3D
9//TEST_INPUT: TextureCube(size=4, content = one):name=tCube
10//TEST_INPUT: Texture1D(size=4, content = one, arrayLength=2):name=t1dArray
11//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=2):name=t2dArray
12//TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name=tCubeArray
13//TEST_INPUT: Sampler:name=samplerState
14//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
15// There is no texture_1d_array type in WGSL https://github.com/shader-slang/slang/issues/5223
16// Not supported in WGSL: 1D array texture not supported in WGSL
17//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu
18
19Texture1D t1D;
20Texture2D t2D;
21Texture3D t3D;
22TextureCube tCube;
23Texture1DArray t1dArray;
24Texture2DArray t2dArray;
25TextureCubeArray tCubeArray;
26SamplerState samplerState;
27RWStructuredBuffer<float> outputBuffer;
28
29cbuffer Uniforms
30{
31	float4x4 modelViewProjection;
32}
33
34struct AssembledVertex
35{
36	float3	position;
37	float3	color;
38    float2  uv;
39};
40
41struct CoarseVertex
42{
43	float3	color;
44    float2  uv;
45};
46
47struct Fragment
48{
49	float4 color;
50};
51
52
53// Vertex  Shader
54
55struct VertexStageInput
56{
57	AssembledVertex assembledVertex	: A;
58};
59
60struct VertexStageOutput
61{
62	CoarseVertex	coarseVertex	: CoarseVertex;
63	float4			sv_position		: SV_Position;
64};
65
66VertexStageOutput vertexMain(VertexStageInput input)
67{
68	VertexStageOutput output;
69
70	float3 position = input.assembledVertex.position;
71	float3 color	= input.assembledVertex.color;
72
73	output.coarseVertex.color = color;
74	output.sv_position = mul(modelViewProjection, float4(position, 1.0));
75    output.coarseVertex.uv = input.assembledVertex.uv;
76	return output;
77}
78
79// Fragment Shader
80
81struct FragmentStageInput
82{
83	CoarseVertex	coarseVertex	: CoarseVertex;
84};
85
86struct FragmentStageOutput
87{
88	Fragment fragment	: SV_Target;
89};
90
91FragmentStageOutput fragmentMain(FragmentStageInput input)
92{
93	FragmentStageOutput output;
94
95	float3 color = input.coarseVertex.color;
96    float2 uv = input.coarseVertex.uv;
97	output.fragment.color = float4(color, 1.0);
98
99    float4 val = 0.0;
100    val += t1D.Sample(samplerState, uv.x);
101    val += t2D.Sample(samplerState, uv);
102    val += t3D.Sample (samplerState, float3(uv, 0.5));
103    val += t1dArray.Sample(samplerState, float2(uv.x, 0.0));
104    
105    val += t2dArray.Sample(samplerState, float3(uv, 0.0));
106    
107    val += tCubeArray.Sample(samplerState, float4(uv, 0.5, 0.0));
108    val += tCube.Sample(samplerState, float3(uv, 0.5));
109
110    val += t2D.Load(int3(0));
111    val += t2dArray.Load(int4(0));
112
113    val += t3D[int3(0)];
114
115    outputBuffer[0] = val.x;
116
117    int w, h, l, lods;
118    t2dArray.GetDimensions(0, w, h, l, lods);
119    outputBuffer[1] = w + h + l + lods;
120	return output;
121}