2023-04-16 10:38:58 -07:00
|
|
|
% Uppercase register set names
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer Constants : register(B1)
|
|
|
|
{
|
|
|
|
};
|
|
|
|
Texture2D tex : register(T1);
|
|
|
|
float4 foo : register(C0);
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
2023-04-16 10:38:58 -07:00
|
|
|
|
2024-03-27 18:22:15 -07:00
|
|
|
[pixel shader fail(sm>=6)]
|
|
|
|
// Annotations
|
|
|
|
cbuffer cb : register(b1) < int i = 1; >
|
|
|
|
{
|
|
|
|
float4 m1;
|
|
|
|
};
|
|
|
|
|
|
|
|
cbuffer cb < int i = 2; >
|
|
|
|
{
|
|
|
|
float4 m2;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return m1 + m2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-31 14:13:26 -07:00
|
|
|
[pixel shader]
|
|
|
|
// Test empty constant buffer.
|
|
|
|
cbuffer Constants : register(b1)
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 foo;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2024-02-24 17:51:58 -08:00
|
|
|
[pixel shader fail(sm>=6)]
|
|
|
|
// The 'single' modifier is not a keyword. It's meaningful only for fx_5_0.
|
|
|
|
single cbuffer cb
|
|
|
|
{
|
|
|
|
float4 single;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return single;
|
|
|
|
}
|
|
|
|
|
2022-10-31 14:13:26 -07:00
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
2023-02-21 15:16:23 -08:00
|
|
|
|
2024-02-24 17:51:58 -08:00
|
|
|
[pixel shader fail(sm>=6)]
|
|
|
|
// 'single' modifier is usable when there is a variable with the same name
|
|
|
|
cbuffer cb
|
|
|
|
{
|
|
|
|
float4 single;
|
|
|
|
};
|
|
|
|
|
|
|
|
single cbuffer cb2
|
|
|
|
{
|
|
|
|
float4 var;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return single;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
2024-02-24 17:51:58 -08:00
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
typedef float4 single;
|
|
|
|
single var;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
2024-02-24 17:51:58 -08:00
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
typedef float4 single;
|
|
|
|
single cbuffer cb
|
|
|
|
{
|
|
|
|
float4 var;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
2023-02-21 15:16:23 -08:00
|
|
|
% SM1 buffer offset allocation follows different rules than SM4.
|
|
|
|
% Those would have to be tested separately.
|
|
|
|
[require]
|
|
|
|
shader model >= 4.0
|
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c1invalid_extra_chars);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-21 15:16:23 -08:00
|
|
|
% Respect register boundaries
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float2 a;
|
|
|
|
float2 b;
|
|
|
|
float2 c;
|
|
|
|
float3 d;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return float4(a.x, b.x, c.x, d.x);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 1.0 2.0 3.0
|
|
|
|
uniform 4 float4 4.0 5.0 6.0 7.0
|
|
|
|
uniform 8 float4 8.0 9.0 10.0 11.0
|
|
|
|
uniform 12 float4 12.0 13.0 14.0 15.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (0.0, 2.0, 4.0, 8.0)
|
2023-02-21 15:16:23 -08:00
|
|
|
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float a;
|
|
|
|
float b[2];
|
|
|
|
float c;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return float4(a, b[0], b[1], c);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 1.0 2.0 3.0
|
|
|
|
uniform 4 float4 4.0 5.0 6.0 7.0
|
|
|
|
uniform 8 float4 8.0 9.0 10.0 11.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (0.0, 4.0, 8.0, 9.0)
|
2023-02-21 15:16:23 -08:00
|
|
|
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float a;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float b;
|
|
|
|
float c;
|
|
|
|
} p;
|
|
|
|
float d;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return float4(a, p.b, p.c, d);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 1.0 2.0 3.0
|
|
|
|
uniform 4 float4 4.0 5.0 6.0 7.0
|
|
|
|
uniform 8 float4 8.0 9.0 10.0 11.0
|
|
|
|
uniform 12 float4 12.0 13.0 14.0 15.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (0.0, 4.0, 5.0, 6.0)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Elements cannot overlap if buffer is used.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float c : packoffset(c0);
|
|
|
|
float4 a[2] : packoffset(c1);
|
|
|
|
float4 b[2] : packoffset(c2);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
2023-09-14 02:29:24 -07:00
|
|
|
return float4(c, a[1].x, b[0].x, b[1].x);
|
2023-02-06 14:17:24 -08:00
|
|
|
}
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 0.0 0.0 0.0
|
|
|
|
uniform 4 float4 2.0 0.0 0.0 0.0
|
|
|
|
uniform 8 float4 3.0 0.0 0.0 0.0
|
|
|
|
uniform 12 float4 4.0 0.0 0.0 0.0
|
2023-10-10 21:33:27 -07:00
|
|
|
todo(sm<6) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 3.0, 3.0, 4.0)
|
2023-09-14 02:29:24 -07:00
|
|
|
|
2023-02-06 14:17:24 -08:00
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Elements can overlap if buffer is not used.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a[2] : packoffset(c1);
|
|
|
|
float4 b[2] : packoffset(c2);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c1);
|
2023-04-16 10:43:14 -07:00
|
|
|
float4 b : packoffset(C2);
|
2023-02-06 14:17:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 100 * a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
|
|
|
uniform 4 float4 5.0 6.0 7.0 8.0
|
|
|
|
uniform 8 float4 9.0 10.0 11.0 12.0
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (509, 610, 711, 812)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
struct apple
|
|
|
|
{
|
|
|
|
float2 a;
|
|
|
|
float b;
|
|
|
|
float4 c;
|
|
|
|
};
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c3);
|
|
|
|
struct apple bar : packoffset(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 1000 * foo + 100 * float4(bar.a, 0, 0) + 10 * float4(bar.b, 0, 0, 0) + bar.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 1.0 2.0 3.0
|
|
|
|
uniform 4 float4 4.0 5.0 6.0 7.0
|
|
|
|
uniform 8 float4 8.0 9.0 10.0 11.0
|
|
|
|
uniform 12 float4 12.0 13.0 14.0 15.0
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (12468.0, 13509.0, 14010.0, 15011.0)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float2 c : packoffset(c0.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return float4(c, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (2.0, 3.0, 2.0, 3.0)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
2023-02-21 12:08:39 -08:00
|
|
|
[pixel shader fail]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Elements must respect register boundaries.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 c : packoffset(c0.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Matrices must be aligned.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float1x1 m : packoffset(c0.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Arrays must be aligned.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float a[1] : packoffset(c0.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Structs must be aligned.
|
|
|
|
struct apple
|
|
|
|
{
|
|
|
|
float p;
|
|
|
|
};
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
struct apple a : packoffset(c0.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-21 12:08:39 -08:00
|
|
|
[pixel shader fail]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Invalid offset on unused buffer.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float3 a : packoffset(c0.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-21 12:08:39 -08:00
|
|
|
[pixel shader fail]
|
2023-02-06 14:17:24 -08:00
|
|
|
// Invalid offset on unused variable.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float a : packoffset(c0);
|
|
|
|
float3 b : packoffset(c0.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c1);
|
|
|
|
float1 b : packoffset(c0);
|
|
|
|
float1 c : packoffset(c0.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 100 * a + 10 * b + c;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float 1.0
|
|
|
|
uniform 1 float 2.0
|
|
|
|
uniform 4 float4 5.0 6.0 7.0 8.0
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (512.0, 612.0, 712.0, 812.0)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-02-06 14:17:24 -08:00
|
|
|
// packoffset cannot be used unless all elements use it.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c0);
|
|
|
|
float4 b;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-22 09:53:17 -08:00
|
|
|
[pixel shader]
|
2023-02-06 14:17:24 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float2 c : packoffset(c0.b);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return float4(c, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (3.0, 4.0, 3.0, 4.0)
|
2023-02-06 14:17:24 -08:00
|
|
|
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float2 c : packoffset(c0.xy);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4x4 mat : packoffset(c0._m00);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c0._m00);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float2 c : packoffset(c0.xz);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
% packoffset cannot be used outside a constant buffer.
|
|
|
|
[pixel shader fail]
|
|
|
|
float4 a : packoffset(c0);
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
float4 foo(float4 a : packoffset(c0))
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
float4 foo(float4 a) : packoffset(c0)
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
struct apple
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c0);
|
|
|
|
};
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
struct apple a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float4 a : packoffset(c0);
|
|
|
|
} s;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2023-03-01 09:28:12 -08:00
|
|
|
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2023-03-01 09:28:12 -08:00
|
|
|
0.0 0.0 0.0 4.0
|
|
|
|
|
|
|
|
[sampler 0]
|
|
|
|
filter linear linear linear
|
|
|
|
address clamp clamp clamp
|
|
|
|
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
// Resources are allowed inside constant buffers but they behave as regular resources.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 a;
|
|
|
|
Texture2D tex;
|
|
|
|
sampler sam;
|
|
|
|
float4 b;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return a + b + tex.Sample(sam, float2(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 0.0 0.0 0.0
|
|
|
|
uniform 4 float4 0.0 2.0 0.0 0.0
|
|
|
|
uniform 8 float4 0.0 0.0 3.0 0.0
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 0.0, 4.0)
|
2023-03-01 09:28:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
% packoffset() cannot be used to specify other types of registers
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
sampler sam : packoffset(s0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
Texture2D tex : packoffset(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2023-03-01 09:28:12 -08:00
|
|
|
1.0 1.0 1.0 1.0
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 1]
|
|
|
|
size (2d, 1, 1)
|
2023-03-01 09:28:12 -08:00
|
|
|
2.0 2.0 2.0 2.0
|
|
|
|
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
// packoffset() can be used in Textures, doesn't change the allocated t register.
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
Texture2D tex : packoffset(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return tex.Load(int3(0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-03-19 04:36:23 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
|
2023-03-01 09:28:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
% Samplers cannot have packoffset(), unless register() is also specified, or they are not used.
|
|
|
|
% Note: In SM1 the rules are different: packoffset() is allowed for samplers, but they cannot be
|
|
|
|
% used together with other numeric fields, which seems like a bug.
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6) todo]
|
2023-03-01 09:28:12 -08:00
|
|
|
Texture2D tex;
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
sampler sam : packoffset(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return tex.Sample(sam, float2(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader todo]
|
|
|
|
Texture2D tex;
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
sampler sam : packoffset(c1) : register(s0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return tex.Sample(sam, float2(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
sampler sam : packoffset(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
sampler sam : packoffset(c1);
|
|
|
|
float4 a : packoffset(c0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
% When packoffset is used in one field, resources are also expected to have a reservation.
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c0);
|
|
|
|
Texture2D tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c0);
|
|
|
|
sampler sam;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
% register() can be used instead of packoffset().
|
2023-03-01 10:57:31 -08:00
|
|
|
[pixel shader]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c0);
|
2023-04-16 10:38:58 -07:00
|
|
|
Texture2D tex : register(T1);
|
2023-03-01 09:28:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-01 10:57:31 -08:00
|
|
|
[pixel shader]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c0);
|
|
|
|
sampler sam : register(s1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
% Using register() alone is considered manual packing for resources, so the other fields expect packoffset().
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo;
|
|
|
|
Texture2D tex : register(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-09-14 02:29:24 -07:00
|
|
|
[pixel shader fail(sm<6)]
|
2023-03-01 09:28:12 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo;
|
|
|
|
sampler sam : register(s1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-01-26 14:58:42 -08:00
|
|
|
% register(c#) is ignored and does not count as manual packing.
|
2023-03-01 09:28:12 -08:00
|
|
|
[pixel shader]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
2024-01-26 14:58:42 -08:00
|
|
|
float4 foo : register(c1);
|
2023-03-01 09:28:12 -08:00
|
|
|
Texture2D tex;
|
|
|
|
}
|
|
|
|
|
2024-01-26 14:58:42 -08:00
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
|
|
|
uniform 4 float4 0.0 0.0 0.0 0.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
2024-01-26 14:58:42 -08:00
|
|
|
|
|
|
|
[pixel shader fail(sm<6)]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : register(c1);
|
|
|
|
Texture2D tex : register(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
% However, valid register reservations count as manual packing even if they
|
|
|
|
% don't make sense for the given variable.
|
|
|
|
% sm6 just rejects incorrect reservations.
|
|
|
|
|
|
|
|
[pixel shader fail(sm>=6)]
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 bar : register(t1);
|
|
|
|
}
|
|
|
|
|
2023-03-01 09:28:12 -08:00
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-01-26 14:59:34 -08:00
|
|
|
[pixel shader fail(sm>=6)]
|
2024-01-26 14:58:42 -08:00
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c0);
|
|
|
|
float4 bar : register(t1);
|
|
|
|
Texture2D tex : register(s2);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return foo + bar;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
|
|
|
uniform 4 float4 0.1 0.2 0.3 0.4
|
2021-08-28 02:02:54 -07:00
|
|
|
draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.1, 2.2, 3.3, 4.4)
|
2024-01-26 14:58:42 -08:00
|
|
|
|
2023-03-01 09:28:12 -08:00
|
|
|
|
|
|
|
[require]
|
|
|
|
shader model >= 5.0
|
|
|
|
|
2024-01-24 11:11:17 -08:00
|
|
|
[srv 0]
|
|
|
|
size (2d, 1, 1)
|
2023-03-01 09:28:12 -08:00
|
|
|
0.0 0.0 0.0 0.5
|
|
|
|
|
2024-01-26 14:59:34 -08:00
|
|
|
[pixel shader]
|
2023-03-01 09:28:12 -08:00
|
|
|
struct apple
|
|
|
|
{
|
|
|
|
float2 a;
|
|
|
|
Texture2D tex;
|
|
|
|
float b;
|
|
|
|
};
|
|
|
|
|
|
|
|
cbuffer buffer
|
|
|
|
{
|
|
|
|
float4 foo : packoffset(c3);
|
|
|
|
struct apple bar : packoffset(c1);
|
2024-01-26 14:58:42 -08:00
|
|
|
struct apple baz : register(u3);
|
2023-03-01 09:28:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 10 * foo + float4(bar.a, 0, 0) + float4(0, 0, bar.b, 0) + bar.tex.Load(int3(0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 0.0 1.0 2.0 3.0
|
|
|
|
uniform 4 float4 4.0 5.0 6.0 7.0
|
|
|
|
uniform 8 float4 8.0 9.0 10.0 11.0
|
|
|
|
uniform 12 float4 12.0 13.0 14.0 15.0
|
2024-01-26 14:58:42 -08:00
|
|
|
uniform 16 float4 16.0 17.0 18.0 19.0
|
2024-01-26 14:59:34 -08:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (124.0, 135.0, 146.0, 150.5)
|
2024-05-24 00:43:39 -07:00
|
|
|
|
|
|
|
[require]
|
|
|
|
shader model >= 5.1
|
|
|
|
|
2024-05-27 15:31:51 -07:00
|
|
|
[pixel shader fail]
|
2024-05-24 00:43:39 -07:00
|
|
|
float4 ConstantBuffer;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return ConstantBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
[pixel shader fail]
|
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 cb;
|
|
|
|
ConstantBuffer<s> cb;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-05-27 15:31:51 -07:00
|
|
|
[pixel shader fail(sm>=6)]
|
2024-05-24 00:43:39 -07:00
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
// Local variable do not create resource definitions,
|
|
|
|
// acting like a constant
|
|
|
|
ConstantBuffer<s> cb = (s)1;
|
|
|
|
float4 var = 0.1f;
|
|
|
|
var += cb.m;
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
2024-05-27 15:31:51 -07:00
|
|
|
todo(glsl) draw quad
|
2024-02-10 11:16:22 -08:00
|
|
|
probe (0, 0) rgba (1.1, 1.1, 1.1, 1.1)
|
2024-05-24 00:43:39 -07:00
|
|
|
|
2024-05-27 15:31:51 -07:00
|
|
|
[pixel shader]
|
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
ConstantBuffer<s> cb;
|
|
|
|
|
|
|
|
float4 func(s arg)
|
|
|
|
{
|
|
|
|
return arg.m;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return func(cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
[test]
|
|
|
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
2024-02-24 15:35:48 -08:00
|
|
|
draw quad
|
2024-05-27 15:31:51 -07:00
|
|
|
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
|
|
|
|
|
|
|
[pixel shader fail todo]
|
2024-05-24 00:43:39 -07:00
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
ConstantBuffer<s> cb = (s)0;
|
|
|
|
cb.m = 1.0f;
|
|
|
|
return cb.m;
|
|
|
|
}
|
|
|
|
|
2024-05-27 15:31:51 -07:00
|
|
|
[pixel shader]
|
2024-05-24 00:43:39 -07:00
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 var;
|
|
|
|
|
|
|
|
ConstantBuffer<s> cb[2][3] : register(b1);
|
|
|
|
cbuffer cb
|
|
|
|
{
|
|
|
|
float4 m2;
|
|
|
|
};
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-05-27 15:31:51 -07:00
|
|
|
[pixel shader fail todo]
|
|
|
|
struct s
|
|
|
|
{
|
|
|
|
float4 m;
|
|
|
|
};
|
|
|
|
|
|
|
|
ConstantBuffer<s> func(s arg)
|
|
|
|
{
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-05-24 00:43:39 -07:00
|
|
|
[require]
|
|
|
|
shader model >= 2.0
|
|
|
|
shader model < 5.1
|
|
|
|
|
|
|
|
[pixel shader]
|
|
|
|
float4 ConstantBuffer;
|
|
|
|
|
|
|
|
float4 main() : sv_target
|
|
|
|
{
|
|
|
|
return ConstantBuffer;
|
|
|
|
}
|