yum-mirror/slang

Making it easier to work with shaders

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

Yong HeLower varying parameters as pointers instead of SSA values. (#5919)c43f6fa55

master
1.9 KiB84 linesraw
1//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=ROWMAJOR): -vk -output-using-type
2//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=ROWMAJOR): -d3d11 -output-using-type
3
4//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=COLMAJOR): -vk -output-using-type -emit-spirv-directly -xslang -DCOLUMN_MAJOR
5//TEST(compute):COMPARE_RENDER_COMPUTE(filecheck-buffer=COLMAJOR): -d3d11 -output-using-type -xslang -DCOLUMN_MAJOR
6
7// Check that row_major and column_major matrix typed vertex input are correctly handled.
8
9//TEST_INPUT: Texture2D(size=4, content = one):name t
10//TEST_INPUT: Sampler:name s
11//TEST_INPUT: ubuffer(data=[0], stride=4):out, name outputBuffer
12
13Texture2D t;
14SamplerState s;
15RWStructuredBuffer<float> outputBuffer;
16
17cbuffer Uniforms
18{
19	float4x4 modelViewProjection;
20}
21
22struct AssembledVertex
23{
24	float3	position;
25	float3	color;
26    float2  uv;
27#ifdef COLUMN_MAJOR
28    column_major float4x4 m;
29#else
30    row_major float4x4 m;
31#endif
32};
33
34struct CoarseVertex
35{
36	float3	color;
37};
38
39struct Fragment
40{
41	float4 color;
42};
43
44// Vertex  Shader
45
46struct VertexStageInput
47{
48	AssembledVertex assembledVertex	: A;
49};
50
51struct VertexStageOutput
52{
53	CoarseVertex	coarseVertex	: CoarseVertex;
54	float4			sv_position		: SV_Position;
55};
56
57VertexStageOutput vertexMain(VertexStageInput input)
58{
59	VertexStageOutput output;
60	output.coarseVertex.color = input.assembledVertex.m[1][2];
61    output.sv_position = mul(modelViewProjection, float4(input.assembledVertex.position, 1.0));
62	return output;
63}
64
65struct FragmentStageInput
66{
67	CoarseVertex	coarseVertex	: CoarseVertex;
68};
69
70struct FragmentStageOutput
71{
72	Fragment fragment	: SV_Target;
73};
74
75FragmentStageOutput fragmentMain(FragmentStageInput input)
76{
77	FragmentStageOutput output;
78	float3 color = input.coarseVertex.color;
79	output.fragment.color = float4(color, 1.0);
80	outputBuffer[0] = color.x;
81    // ROWMAJOR: 7.0
82    // COLMAJOR: 10.0
83	return output;
84}