Commit 7dfcf4d1 by steve-lunarg

HLSL: Add GatherRed/Green/Blue/Alpha methods, inc 4-offset forms

parent 98a2e92f
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d;
uniform Texture1DArray <float4> g_tTex1df4a : register(t0);
Texture1DArray <int4> g_tTex1di4a;
Texture1DArray <uint4> g_tTex1du4a;
Texture2DArray <float4> g_tTex2df4a;
Texture2DArray <int4> g_tTex2di4a;
Texture2DArray <uint4> g_tTex2du4a;
TextureCubeArray <float4> g_tTexcdf4a;
TextureCubeArray <int4> g_tTexcdi4a;
TextureCubeArray <uint4> g_tTexcdu4a;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
// no 1D gathers
float4 txval00 = g_tTex2df4a . GatherRed(g_sSamp, c3);
int4 txval01 = g_tTex2di4a . GatherRed(g_sSamp, c3);
uint4 txval02 = g_tTex2du4a . GatherRed(g_sSamp, c3);
float4 txval10 = g_tTex2df4a . GatherGreen(g_sSamp, c3);
int4 txval11 = g_tTex2di4a . GatherGreen(g_sSamp, c3);
uint4 txval12 = g_tTex2du4a . GatherGreen(g_sSamp, c3);
float4 txval20 = g_tTex2df4a . GatherBlue(g_sSamp, c3);
int4 txval21 = g_tTex2di4a . GatherBlue(g_sSamp, c3);
uint4 txval22 = g_tTex2du4a . GatherBlue(g_sSamp, c3);
float4 txval30 = g_tTex2df4a . GatherAlpha(g_sSamp, c3);
int4 txval31 = g_tTex2di4a . GatherAlpha(g_sSamp, c3);
uint4 txval32 = g_tTex2du4a . GatherAlpha(g_sSamp, c3);
// no 3D gathers
float4 txval40 = g_tTexcdf4a . GatherRed(g_sSamp, c4);
int4 txval41 = g_tTexcdi4a . GatherRed(g_sSamp, c4);
uint4 txval42 = g_tTexcdu4a . GatherRed(g_sSamp, c4);
float4 txval50 = g_tTexcdf4a . GatherGreen(g_sSamp, c4);
int4 txval51 = g_tTexcdi4a . GatherGreen(g_sSamp, c4);
uint4 txval52 = g_tTexcdu4a . GatherGreen(g_sSamp, c4);
float4 txval60 = g_tTexcdf4a . GatherBlue(g_sSamp, c4);
int4 txval61 = g_tTexcdi4a . GatherBlue(g_sSamp, c4);
uint4 txval62 = g_tTexcdu4a . GatherBlue(g_sSamp, c4);
float4 txval70 = g_tTexcdf4a . GatherAlpha(g_sSamp, c4);
int4 txval71 = g_tTexcdi4a . GatherAlpha(g_sSamp, c4);
uint4 txval72 = g_tTexcdu4a . GatherAlpha(g_sSamp, c4);
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d;
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
// no 1D gathers
float4 txval00 = g_tTex2df4 . GatherRed(g_sSamp, c2);
int4 txval01 = g_tTex2di4 . GatherRed(g_sSamp, c2);
uint4 txval02 = g_tTex2du4 . GatherRed(g_sSamp, c2);
float4 txval10 = g_tTex2df4 . GatherGreen(g_sSamp, c2);
int4 txval11 = g_tTex2di4 . GatherGreen(g_sSamp, c2);
uint4 txval12 = g_tTex2du4 . GatherGreen(g_sSamp, c2);
float4 txval20 = g_tTex2df4 . GatherBlue(g_sSamp, c2);
int4 txval21 = g_tTex2di4 . GatherBlue(g_sSamp, c2);
uint4 txval22 = g_tTex2du4 . GatherBlue(g_sSamp, c2);
float4 txval30 = g_tTex2df4 . GatherAlpha(g_sSamp, c2);
int4 txval31 = g_tTex2di4 . GatherAlpha(g_sSamp, c2);
uint4 txval32 = g_tTex2du4 . GatherAlpha(g_sSamp, c2);
// no 3D gathers
float4 txval40 = g_tTexcdf4 . GatherRed(g_sSamp, c3);
int4 txval41 = g_tTexcdi4 . GatherRed(g_sSamp, c3);
uint4 txval42 = g_tTexcdu4 . GatherRed(g_sSamp, c3);
float4 txval50 = g_tTexcdf4 . GatherGreen(g_sSamp, c3);
int4 txval51 = g_tTexcdi4 . GatherGreen(g_sSamp, c3);
uint4 txval52 = g_tTexcdu4 . GatherGreen(g_sSamp, c3);
float4 txval60 = g_tTexcdf4 . GatherBlue(g_sSamp, c3);
int4 txval61 = g_tTexcdi4 . GatherBlue(g_sSamp, c3);
uint4 txval62 = g_tTexcdu4 . GatherBlue(g_sSamp, c3);
float4 txval70 = g_tTexcdf4 . GatherAlpha(g_sSamp, c3);
int4 txval71 = g_tTexcdi4 . GatherAlpha(g_sSamp, c3);
uint4 txval72 = g_tTexcdu4 . GatherAlpha(g_sSamp, c3);
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d;
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
uniform int o1;
uniform int2 o2;
uniform int3 o3;
uniform int4 o4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
uint status;
// no 1D gathers
float4 txval001 = g_tTex2df4 . GatherRed(g_sSamp, c2, o2);
int4 txval011 = g_tTex2di4 . GatherRed(g_sSamp, c2, o2);
uint4 txval021 = g_tTex2du4 . GatherRed(g_sSamp, c2, o2);
float4 txval004 = g_tTex2df4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2);
int4 txval014 = g_tTex2di4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2);
uint4 txval024 = g_tTex2du4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2);
// float4 txval00s = g_tTex2df4 . GatherRed(g_sSamp, c2, o2, status);
// int4 txval01s = g_tTex2di4 . GatherRed(g_sSamp, c2, o2, status);
// uint4 txval02s = g_tTex2du4 . GatherRed(g_sSamp, c2, o2, status);
// float4 txval004s = g_tTex2df4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2, status);
// int4 txval014s = g_tTex2di4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2, status);
// uint4 txval024s = g_tTex2du4 . GatherRed(g_sSamp, c2, o2, o2, o2, o2, status);
float4 txval101 = g_tTex2df4 . GatherGreen(g_sSamp, c2, o2);
int4 txval111 = g_tTex2di4 . GatherGreen(g_sSamp, c2, o2);
uint4 txval121 = g_tTex2du4 . GatherGreen(g_sSamp, c2, o2);
float4 txval104 = g_tTex2df4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2);
int4 txval114 = g_tTex2di4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2);
uint4 txval124 = g_tTex2du4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2);
// float4 txval10s = g_tTex2df4 . GatherGreen(g_sSamp, c2, o2, status);
// int4 txval11s = g_tTex2di4 . GatherGreen(g_sSamp, c2, o2, status);
// uint4 txval12s = g_tTex2du4 . GatherGreen(g_sSamp, c2, o2, status);
// float4 txval104 = g_tTex2df4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2, status);
// int4 txval114 = g_tTex2di4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2, status);
// uint4 txval124 = g_tTex2du4 . GatherGreen(g_sSamp, c2, o2, o2, o2, o2, status);
float4 txval201 = g_tTex2df4 . GatherBlue(g_sSamp, c2, o2);
int4 txval211 = g_tTex2di4 . GatherBlue(g_sSamp, c2, o2);
uint4 txval221 = g_tTex2du4 . GatherBlue(g_sSamp, c2, o2);
float4 txval204 = g_tTex2df4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2);
int4 txval214 = g_tTex2di4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2);
uint4 txval224 = g_tTex2du4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2);
// float4 txval204s = g_tTex2df4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2, status);
// int4 txval214s = g_tTex2di4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2, status);
// uint4 txval224s = g_tTex2du4 . GatherBlue(g_sSamp, c2, o2, o2, o2, o2, status);
// float4 txval20s = g_tTex2df4 . GatherBlue(g_sSamp, c2, o2, status);
// int4 txval21s = g_tTex2di4 . GatherBlue(g_sSamp, c2, o2, status);
// uint4 txval22s = g_tTex2du4 . GatherBlue(g_sSamp, c2, o2, status);
float4 txval301 = g_tTex2df4 . GatherAlpha(g_sSamp, c2, o2);
int4 txval311 = g_tTex2di4 . GatherAlpha(g_sSamp, c2, o2);
uint4 txval321 = g_tTex2du4 . GatherAlpha(g_sSamp, c2, o2);
float4 txval304 = g_tTex2df4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2);
int4 txval314 = g_tTex2di4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2);
uint4 txval324 = g_tTex2du4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2);
// float4 txval304s = g_tTex2df4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2, status);
// int4 txval314s = g_tTex2di4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2, status);
// uint4 txval324s = g_tTex2du4 . GatherAlpha(g_sSamp, c2, o2, o2, o2, o2, status);
// float4 txval30s = g_tTex2df4 . GatherAlpha(g_sSamp, c2, o2, status);
// int4 txval31s = g_tTex2di4 . GatherAlpha(g_sSamp, c2, o2, status);
// uint4 txval32s = g_tTex2du4 . GatherAlpha(g_sSamp, c2, o2, status);
// no 3D gathers with offset
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d;
uniform Texture1DArray <float4> g_tTex1df4a : register(t0);
Texture1DArray <int4> g_tTex1di4a;
Texture1DArray <uint4> g_tTex1du4a;
Texture2DArray <float4> g_tTex2df4a;
Texture2DArray <int4> g_tTex2di4a;
Texture2DArray <uint4> g_tTex2du4a;
TextureCubeArray <float4> g_tTexcdf4a;
TextureCubeArray <int4> g_tTexcdi4a;
TextureCubeArray <uint4> g_tTexcdu4a;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
uniform int o1;
uniform int2 o2;
uniform int3 o3;
uniform int4 o4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
uint status;
// no 1D gathers
float4 txval001 = g_tTex2df4a . GatherRed(g_sSamp, c3, o2);
int4 txval011 = g_tTex2di4a . GatherRed(g_sSamp, c3, o2);
uint4 txval021 = g_tTex2du4a . GatherRed(g_sSamp, c3, o2);
float4 txval004 = g_tTex2df4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2);
int4 txval014 = g_tTex2di4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2);
uint4 txval024 = g_tTex2du4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2);
// float4 txval00s = g_tTex2df4a . GatherRed(g_sSamp, c3, o2, status);
// int4 txval01s = g_tTex2di4a . GatherRed(g_sSamp, c3, o2, status);
// uint4 txval02s = g_tTex2du4a . GatherRed(g_sSamp, c3, o2, status);
// float4 txval004s = g_tTex2df4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2, status);
// int4 txval014s = g_tTex2di4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2, status);
// uint4 txval024s = g_tTex2du4a . GatherRed(g_sSamp, c3, o2, o2, o2, o2, status);
float4 txval101 = g_tTex2df4a . GatherGreen(g_sSamp, c3, o2);
int4 txval111 = g_tTex2di4a . GatherGreen(g_sSamp, c3, o2);
uint4 txval121 = g_tTex2du4a . GatherGreen(g_sSamp, c3, o2);
float4 txval104 = g_tTex2df4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2);
int4 txval114 = g_tTex2di4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2);
uint4 txval124 = g_tTex2du4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2);
// float4 txval10s = g_tTex2df4a . GatherGreen(g_sSamp, c3, o2, status);
// int4 txval11s = g_tTex2di4a . GatherGreen(g_sSamp, c3, o2, status);
// uint4 txval12s = g_tTex2du4a . GatherGreen(g_sSamp, c3, o2, status);
// float4 txval104 = g_tTex2df4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2, status);
// int4 txval114 = g_tTex2di4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2, status);
// uint4 txval124 = g_tTex2du4a . GatherGreen(g_sSamp, c3, o2, o2, o2, o2, status);
float4 txval201 = g_tTex2df4a . GatherBlue(g_sSamp, c3, o2);
int4 txval211 = g_tTex2di4a . GatherBlue(g_sSamp, c3, o2);
uint4 txval221 = g_tTex2du4a . GatherBlue(g_sSamp, c3, o2);
float4 txval204 = g_tTex2df4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2);
int4 txval214 = g_tTex2di4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2);
uint4 txval224 = g_tTex2du4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2);
// float4 txval204s = g_tTex2df4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2, status);
// int4 txval214s = g_tTex2di4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2, status);
// uint4 txval224s = g_tTex2du4a . GatherBlue(g_sSamp, c3, o2, o2, o2, o2, status);
// float4 txval20s = g_tTex2df4a . GatherBlue(g_sSamp, c3, o2, status);
// int4 txval21s = g_tTex2di4a . GatherBlue(g_sSamp, c3, o2, status);
// uint4 txval22s = g_tTex2du4a . GatherBlue(g_sSamp, c3, o2, status);
float4 txval301 = g_tTex2df4a . GatherAlpha(g_sSamp, c3, o2);
int4 txval311 = g_tTex2di4a . GatherAlpha(g_sSamp, c3, o2);
uint4 txval321 = g_tTex2du4a . GatherAlpha(g_sSamp, c3, o2);
float4 txval304 = g_tTex2df4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2);
int4 txval314 = g_tTex2di4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2);
uint4 txval324 = g_tTex2du4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2);
// float4 txval304s = g_tTex2df4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2, status);
// int4 txval314s = g_tTex2di4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2, status);
// uint4 txval324s = g_tTex2du4a . GatherAlpha(g_sSamp, c3, o2, o2, o2, o2, status);
// float4 txval30s = g_tTex2df4a . GatherAlpha(g_sSamp, c3, o2, status);
// int4 txval31s = g_tTex2di4a . GatherAlpha(g_sSamp, c3, o2, status);
// uint4 txval32s = g_tTex2du4a . GatherAlpha(g_sSamp, c3, o2, status);
// no 3D gathers with offset
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerComparisonState g_sSampCmp : register(s0);
uniform Texture1DArray <float4> g_tTex1df4a : register(t0);
Texture1DArray <int4> g_tTex1di4a;
Texture1DArray <uint4> g_tTex1du4a;
Texture2DArray <float4> g_tTex2df4a;
Texture2DArray <int4> g_tTex2di4a;
Texture2DArray <uint4> g_tTex2du4a;
TextureCubeArray <float4> g_tTexcdf4a;
TextureCubeArray <int4> g_tTexcdi4a;
TextureCubeArray <uint4> g_tTexcdu4a;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
// no 1D gathers
float4 txval00 = g_tTex2df4a . GatherCmpRed(g_sSampCmp, c3, .75);
int4 txval01 = g_tTex2di4a . GatherCmpRed(g_sSampCmp, c3, .75);
uint4 txval02 = g_tTex2du4a . GatherCmpRed(g_sSampCmp, c3, .75);
float4 txval10 = g_tTex2df4a . GatherCmpGreen(g_sSampCmp, c3, .75);
int4 txval11 = g_tTex2di4a . GatherCmpGreen(g_sSampCmp, c3, .75);
uint4 txval12 = g_tTex2du4a . GatherCmpGreen(g_sSampCmp, c3, .75);
float4 txval20 = g_tTex2df4a . GatherCmpBlue(g_sSampCmp, c3, .75);
int4 txval21 = g_tTex2di4a . GatherCmpBlue(g_sSampCmp, c3, .75);
uint4 txval22 = g_tTex2du4a . GatherCmpBlue(g_sSampCmp, c3, .75);
float4 txval30 = g_tTex2df4a . GatherCmpAlpha(g_sSampCmp, c3, .75);
int4 txval31 = g_tTex2di4a . GatherCmpAlpha(g_sSampCmp, c3, .75);
uint4 txval32 = g_tTex2du4a . GatherCmpAlpha(g_sSampCmp, c3, .75);
// no 3D gathers
float4 txval40 = g_tTexcdf4a . GatherCmpRed(g_sSampCmp, c4, .75);
int4 txval41 = g_tTexcdi4a . GatherCmpRed(g_sSampCmp, c4, .75);
uint4 txval42 = g_tTexcdu4a . GatherCmpRed(g_sSampCmp, c4, .75);
float4 txval50 = g_tTexcdf4a . GatherCmpGreen(g_sSampCmp, c4, .75);
int4 txval51 = g_tTexcdi4a . GatherCmpGreen(g_sSampCmp, c4, .75);
uint4 txval52 = g_tTexcdu4a . GatherCmpGreen(g_sSampCmp, c4, .75);
float4 txval60 = g_tTexcdf4a . GatherCmpBlue(g_sSampCmp, c4, .75);
int4 txval61 = g_tTexcdi4a . GatherCmpBlue(g_sSampCmp, c4, .75);
uint4 txval62 = g_tTexcdu4a . GatherCmpBlue(g_sSampCmp, c4, .75);
float4 txval70 = g_tTexcdf4a . GatherCmpAlpha(g_sSampCmp, c4, .75);
int4 txval71 = g_tTexcdi4a . GatherCmpAlpha(g_sSampCmp, c4, .75);
uint4 txval72 = g_tTexcdu4a . GatherCmpAlpha(g_sSampCmp, c4, .75);
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerComparisonState g_sSampCmp : register(s0);
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
// no 1D gathers
float4 txval00 = g_tTex2df4 . GatherCmpRed(g_sSampCmp, c2, 0.75);
int4 txval01 = g_tTex2di4 . GatherCmpRed(g_sSampCmp, c2, 0.75);
uint4 txval02 = g_tTex2du4 . GatherCmpRed(g_sSampCmp, c2, 0.75);
float4 txval10 = g_tTex2df4 . GatherCmpGreen(g_sSampCmp, c2, 0.75);
int4 txval11 = g_tTex2di4 . GatherCmpGreen(g_sSampCmp, c2, 0.75);
uint4 txval12 = g_tTex2du4 . GatherCmpGreen(g_sSampCmp, c2, 0.75);
float4 txval20 = g_tTex2df4 . GatherCmpBlue(g_sSampCmp, c2, 0.75);
int4 txval21 = g_tTex2di4 . GatherCmpBlue(g_sSampCmp, c2, 0.75);
uint4 txval22 = g_tTex2du4 . GatherCmpBlue(g_sSampCmp, c2, 0.75);
float4 txval30 = g_tTex2df4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75);
int4 txval31 = g_tTex2di4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75);
uint4 txval32 = g_tTex2du4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75);
// no 3D gathers
float4 txval40 = g_tTexcdf4 . GatherCmpRed(g_sSampCmp, c3, 0.75);
int4 txval41 = g_tTexcdi4 . GatherCmpRed(g_sSampCmp, c3, 0.75);
uint4 txval42 = g_tTexcdu4 . GatherCmpRed(g_sSampCmp, c3, 0.75);
float4 txval50 = g_tTexcdf4 . GatherCmpGreen(g_sSampCmp, c3, 0.75);
int4 txval51 = g_tTexcdi4 . GatherCmpGreen(g_sSampCmp, c3, 0.75);
uint4 txval52 = g_tTexcdu4 . GatherCmpGreen(g_sSampCmp, c3, 0.75);
float4 txval60 = g_tTexcdf4 . GatherCmpBlue(g_sSampCmp, c3, 0.75);
int4 txval61 = g_tTexcdi4 . GatherCmpBlue(g_sSampCmp, c3, 0.75);
uint4 txval62 = g_tTexcdu4 . GatherCmpBlue(g_sSampCmp, c3, 0.75);
float4 txval70 = g_tTexcdf4 . GatherCmpAlpha(g_sSampCmp, c3, 0.75);
int4 txval71 = g_tTexcdi4 . GatherCmpAlpha(g_sSampCmp, c3, 0.75);
uint4 txval72 = g_tTexcdu4 . GatherCmpAlpha(g_sSampCmp, c3, 0.75);
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerComparisonState g_sSampCmp : register(s0);
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
uniform int o1;
uniform int2 o2;
uniform int3 o3;
uniform int4 o4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
uint status;
// no 1D gathers
float4 txval001 = g_tTex2df4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2);
int4 txval011 = g_tTex2di4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2);
uint4 txval021 = g_tTex2du4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2);
float4 txval004 = g_tTex2df4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
int4 txval014 = g_tTex2di4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
uint4 txval024 = g_tTex2du4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
// float4 txval00s = g_tTex2df4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, status);
// int4 txval01s = g_tTex2di4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, status);
// uint4 txval02s = g_tTex2du4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, status);
// float4 txval004s = g_tTex2df4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// int4 txval014s = g_tTex2di4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// uint4 txval024s = g_tTex2du4 . GatherCmpRed(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
float4 txval101 = g_tTex2df4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2);
int4 txval111 = g_tTex2di4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2);
uint4 txval121 = g_tTex2du4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2);
float4 txval104 = g_tTex2df4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
int4 txval114 = g_tTex2di4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
uint4 txval124 = g_tTex2du4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
// float4 txval10s = g_tTex2df4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, status);
// int4 txval11s = g_tTex2di4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, status);
// uint4 txval12s = g_tTex2du4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, status);
// float4 txval104 = g_tTex2df4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// int4 txval114 = g_tTex2di4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// uint4 txval124 = g_tTex2du4 . GatherCmpGreen(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
float4 txval201 = g_tTex2df4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2);
int4 txval211 = g_tTex2di4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2);
uint4 txval221 = g_tTex2du4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2);
float4 txval204 = g_tTex2df4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
int4 txval214 = g_tTex2di4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
uint4 txval224 = g_tTex2du4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
// float4 txval204s = g_tTex2df4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// int4 txval214s = g_tTex2di4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// uint4 txval224s = g_tTex2du4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// float4 txval20s = g_tTex2df4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, status);
// int4 txval21s = g_tTex2di4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, status);
// uint4 txval22s = g_tTex2du4 . GatherCmpBlue(g_sSampCmp, c2, 0.75, o2, status);
float4 txval301 = g_tTex2df4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2);
int4 txval311 = g_tTex2di4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2);
uint4 txval321 = g_tTex2du4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2);
float4 txval304 = g_tTex2df4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
int4 txval314 = g_tTex2di4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
uint4 txval324 = g_tTex2du4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2);
// float4 txval304s = g_tTex2df4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// int4 txval314s = g_tTex2di4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// uint4 txval324s = g_tTex2du4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, o2, o2, o2, status);
// float4 txval30s = g_tTex2df4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, status);
// int4 txval31s = g_tTex2di4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, status);
// uint4 txval32s = g_tTex2du4 . GatherCmpAlpha(g_sSampCmp, c2, 0.75, o2, status);
// no 3D gathers with offset
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerComparisonState g_sSampCmp : register(s0);
uniform Texture1DArray <float4> g_tTex1df4a : register(t0);
Texture1DArray <int4> g_tTex1di4a;
Texture1DArray <uint4> g_tTex1du4a;
Texture2DArray <float4> g_tTex2df4a;
Texture2DArray <int4> g_tTex2di4a;
Texture2DArray <uint4> g_tTex2du4a;
TextureCubeArray <float4> g_tTexcdf4a;
TextureCubeArray <int4> g_tTexcdi4a;
TextureCubeArray <uint4> g_tTexcdu4a;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
uniform float c1;
uniform float2 c2;
uniform float3 c3;
uniform float4 c4;
uniform int o1;
uniform int2 o2;
uniform int3 o3;
uniform int4 o4;
PS_OUTPUT main()
{
PS_OUTPUT psout;
uint status;
// no 1D gathers
float4 txval001 = g_tTex2df4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2);
int4 txval011 = g_tTex2di4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2);
uint4 txval021 = g_tTex2du4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2);
float4 txval004 = g_tTex2df4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
int4 txval014 = g_tTex2di4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
uint4 txval024 = g_tTex2du4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
// float4 txval00s = g_tTex2df4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, status);
// int4 txval01s = g_tTex2di4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, status);
// uint4 txval02s = g_tTex2du4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, status);
// float4 txval004s = g_tTex2df4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// int4 txval014s = g_tTex2di4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// uint4 txval024s = g_tTex2du4a . GatherCmpRed(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
float4 txval101 = g_tTex2df4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2);
int4 txval111 = g_tTex2di4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2);
uint4 txval121 = g_tTex2du4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2);
float4 txval104 = g_tTex2df4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
int4 txval114 = g_tTex2di4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
uint4 txval124 = g_tTex2du4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
// float4 txval10s = g_tTex2df4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, status);
// int4 txval11s = g_tTex2di4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, status);
// uint4 txval12s = g_tTex2du4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, status);
// float4 txval104 = g_tTex2df4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// int4 txval114 = g_tTex2di4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// uint4 txval124 = g_tTex2du4a . GatherCmpGreen(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
float4 txval201 = g_tTex2df4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2);
int4 txval211 = g_tTex2di4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2);
uint4 txval221 = g_tTex2du4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2);
float4 txval204 = g_tTex2df4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
int4 txval214 = g_tTex2di4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
uint4 txval224 = g_tTex2du4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
// float4 txval204s = g_tTex2df4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// int4 txval214s = g_tTex2di4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// uint4 txval224s = g_tTex2du4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// float4 txval20s = g_tTex2df4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, status);
// int4 txval21s = g_tTex2di4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, status);
// uint4 txval22s = g_tTex2du4a . GatherCmpBlue(g_sSampCmp, c3, 0.75, o2, status);
float4 txval301 = g_tTex2df4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2);
int4 txval311 = g_tTex2di4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2);
uint4 txval321 = g_tTex2du4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2);
float4 txval304 = g_tTex2df4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
int4 txval314 = g_tTex2di4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
uint4 txval324 = g_tTex2du4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2);
// float4 txval304s = g_tTex2df4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// int4 txval314s = g_tTex2di4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// uint4 txval324s = g_tTex2du4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, o2, o2, o2, status);
// float4 txval30s = g_tTex2df4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, status);
// int4 txval31s = g_tTex2di4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, status);
// uint4 txval32s = g_tTex2du4a . GatherCmpAlpha(g_sSampCmp, c3, 0.75, o2, status);
// no 3D gathers with offset
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
...@@ -568,6 +568,17 @@ enum TOperator { ...@@ -568,6 +568,17 @@ enum TOperator {
EOpMethodGather, // ... EOpMethodGather, // ...
EOpMethodCalculateLevelOfDetail, // ... EOpMethodCalculateLevelOfDetail, // ...
EOpMethodCalculateLevelOfDetailUnclamped, // ... EOpMethodCalculateLevelOfDetailUnclamped, // ...
// SM5 texture methods
EOpMethodGatherRed, // These are covered under the above EOpMethodSample comment about
EOpMethodGatherGreen, // translation to existing AST opcodes. They exist temporarily
EOpMethodGatherBlue, // because HLSL arguments are slightly different.
EOpMethodGatherAlpha, // ...
EOpMethodGatherCmp, // ...
EOpMethodGatherCmpRed, // ...
EOpMethodGatherCmpGreen, // ...
EOpMethodGatherCmpBlue, // ...
EOpMethodGatherCmpAlpha, // ...
}; };
class TIntermTraverser; class TIntermTraverser;
......
...@@ -91,6 +91,10 @@ INSTANTIATE_TEST_CASE_P( ...@@ -91,6 +91,10 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.gather.basic.dx10.vert", "main"}, {"hlsl.gather.basic.dx10.vert", "main"},
{"hlsl.gather.offset.dx10.frag", "main"}, {"hlsl.gather.offset.dx10.frag", "main"},
{"hlsl.gather.offsetarray.dx10.frag", "main"}, {"hlsl.gather.offsetarray.dx10.frag", "main"},
{"hlsl.gatherRGBA.array.dx10.frag", "main"},
{"hlsl.gatherRGBA.basic.dx10.frag", "main"},
{"hlsl.gatherRGBA.offset.dx10.frag", "main"},
{"hlsl.gatherRGBA.offsetarray.dx10.frag", "main"},
{"hlsl.getdimensions.dx10.frag", "main"}, {"hlsl.getdimensions.dx10.frag", "main"},
{"hlsl.getdimensions.dx10.vert", "main"}, {"hlsl.getdimensions.dx10.vert", "main"},
{"hlsl.getsampleposition.dx10.frag", "main"}, {"hlsl.getsampleposition.dx10.frag", "main"},
......
...@@ -581,6 +581,15 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt ...@@ -581,6 +581,15 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
} else if (field == "CalculateLevelOfDetail" || } else if (field == "CalculateLevelOfDetail" ||
field == "CalculateLevelOfDetailUnclamped" || field == "CalculateLevelOfDetailUnclamped" ||
field == "Gather" || field == "Gather" ||
field == "GatherRed" ||
field == "GatherGreen" ||
field == "GatherBlue" ||
field == "GatherAlpha" ||
field == "GatherCmp" ||
field == "GatherCmpRed" ||
field == "GatherCmpGreen" ||
field == "GatherCmpBlue" ||
field == "GatherCmpAlpha" ||
field == "GetDimensions" || field == "GetDimensions" ||
field == "GetSamplePosition" || field == "GetSamplePosition" ||
field == "Load" || field == "Load" ||
...@@ -1251,7 +1260,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1251,7 +1260,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
TIntermTyped* argOffset = nullptr; TIntermTyped* argOffset = nullptr;
// Offset is optional // Offset is optional
if (argAggregate->getSequence().size() == 4) if (argAggregate->getSequence().size() > 3)
argOffset = argAggregate->getSequence()[3]->getAsTyped(); argOffset = argAggregate->getSequence()[3]->getAsTyped();
const TOperator textureOp = (argOffset == nullptr ? EOpTextureGather : EOpTextureGatherOffset); const TOperator textureOp = (argOffset == nullptr ? EOpTextureGather : EOpTextureGatherOffset);
...@@ -1261,6 +1270,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1261,6 +1270,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
txgather->getSequence().push_back(txcombine); txgather->getSequence().push_back(txcombine);
txgather->getSequence().push_back(argCoord); txgather->getSequence().push_back(argCoord);
// Offset if not given is implicitly channel 0 (red)
if (argOffset != nullptr) if (argOffset != nullptr)
txgather->getSequence().push_back(argOffset); txgather->getSequence().push_back(argOffset);
...@@ -1272,6 +1282,131 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1272,6 +1282,131 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break; break;
} }
case EOpMethodGatherRed: // fall through...
case EOpMethodGatherGreen: // ...
case EOpMethodGatherBlue: // ...
case EOpMethodGatherAlpha: // ...
case EOpMethodGatherCmpRed: // ...
case EOpMethodGatherCmpGreen: // ...
case EOpMethodGatherCmpBlue: // ...
case EOpMethodGatherCmpAlpha: // ...
{
int channel = 0; // the channel we are gathering
int cmpValues = 0; // 1 if there is a compare value (handier than a bool below)
switch (op) {
case EOpMethodGatherCmpRed: cmpValues = 1; // fall through
case EOpMethodGatherRed: channel = 0; break;
case EOpMethodGatherCmpGreen: cmpValues = 1; // fall through
case EOpMethodGatherGreen: channel = 1; break;
case EOpMethodGatherCmpBlue: cmpValues = 1; // fall through
case EOpMethodGatherBlue: channel = 2; break;
case EOpMethodGatherCmpAlpha: cmpValues = 1; // fall through
case EOpMethodGatherAlpha: channel = 3; break;
default: assert(0); break;
}
// For now, we have nothing to map the component-wise comparison forms
// to, because neither GLSL nor SPIR-V has such an opcode. Issue an
// unimplemented error instead. Most of the machinery is here if that
// should ever become available.
if (cmpValues) {
error(loc, "unimplemented: component-level gather compare", "", "");
return;
}
int arg = 0;
TIntermTyped* argTex = argAggregate->getSequence()[arg++]->getAsTyped();
TIntermTyped* argSamp = argAggregate->getSequence()[arg++]->getAsTyped();
TIntermTyped* argCoord = argAggregate->getSequence()[arg++]->getAsTyped();
TIntermTyped* argOffset = nullptr;
TIntermTyped* argOffsets[4] = { nullptr, nullptr, nullptr, nullptr };
// TIntermTyped* argStatus = nullptr; // TODO: residency
TIntermTyped* argCmp = nullptr;
const TSamplerDim dim = argTex->getType().getSampler().dim;
const int argSize = argAggregate->getSequence().size();
bool hasStatus = (argSize == (5+cmpValues) || argSize == (8+cmpValues));
bool hasOffset1 = false;
bool hasOffset4 = false;
// Only 2D forms can have offsets. Discover if we have 0, 1 or 4 offsets.
if (dim == Esd2D) {
hasOffset1 = (argSize == (4+cmpValues) || argSize == (5+cmpValues));
hasOffset4 = (argSize == (7+cmpValues) || argSize == (8+cmpValues));
}
assert(!(hasOffset1 && hasOffset4));
TOperator textureOp = EOpTextureGather;
// Compare forms have compare value
if (cmpValues != 0)
argCmp = argOffset = argAggregate->getSequence()[arg++]->getAsTyped();
// Some forms have single offset
if (hasOffset1) {
textureOp = EOpTextureGatherOffset; // single offset form
argOffset = argAggregate->getSequence()[arg++]->getAsTyped();
}
// Some forms have 4 gather offsets
if (hasOffset4) {
textureOp = EOpTextureGatherOffsets; // note plural, for 4 offset form
for (int offsetNum = 0; offsetNum < 4; ++offsetNum)
argOffsets[offsetNum] = argAggregate->getSequence()[arg++]->getAsTyped();
}
// Residency status
if (hasStatus) {
// argStatus = argAggregate->getSequence()[arg++]->getAsTyped();
error(loc, "unimplemented: residency status", "", "");
return;
}
TIntermAggregate* txgather = new TIntermAggregate(textureOp);
TIntermAggregate* txcombine = handleSamplerTextureCombine(loc, argTex, argSamp);
TIntermTyped* argChannel = intermediate.addConstantUnion(channel, loc, true);
txgather->getSequence().push_back(txcombine);
txgather->getSequence().push_back(argCoord);
// AST wants an array of 4 offsets, where HLSL has separate args. Here
// we construct an array from the separate args.
if (hasOffset4) {
TType arrayType(EbtInt, EvqTemporary, 2);
TArraySizes arraySizes;
arraySizes.addInnerSize(4);
arrayType.newArraySizes(arraySizes);
TIntermAggregate* initList = new TIntermAggregate(EOpNull);
for (int offsetNum = 0; offsetNum < 4; ++offsetNum)
initList->getSequence().push_back(argOffsets[offsetNum]);
argOffset = addConstructor(loc, initList, arrayType);
}
// Add comparison value if we have one
if (argTex->getType().getSampler().isShadow())
txgather->getSequence().push_back(argCmp);
// Add offset (either 1, or an array of 4) if we have one
if (argOffset != nullptr)
txgather->getSequence().push_back(argOffset);
txgather->getSequence().push_back(argChannel);
txgather->setType(node->getType());
txgather->setLoc(loc);
node = txgather;
break;
}
case EOpMethodCalculateLevelOfDetail: case EOpMethodCalculateLevelOfDetail:
case EOpMethodCalculateLevelOfDetailUnclamped: case EOpMethodCalculateLevelOfDetailUnclamped:
{ {
......
...@@ -101,12 +101,29 @@ bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim ...@@ -101,12 +101,29 @@ bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim
return true; return true;
} }
const bool isGather =
(name == "Gather" ||
name == "GatherRed" ||
name == "GatherGreen" ||
name == "GatherBlue" ||
name == "GatherAlpha");
const bool isGatherCmp =
(name == "GatherCmpRed" ||
name == "GatherCmpGreen" ||
name == "GatherCmpBlue" ||
name == "GatherCmpAlpha");
// Reject invalid Gathers // Reject invalid Gathers
if (name == "Gather") { if (isGather || isGatherCmp) {
if (dim0 == 1 || dim0 == 3) // there are no 1D or 3D gathers if (dim0 == 1 || dim0 == 3) // there are no 1D or 3D gathers
return true; return true;
if (dim0 == 4 && numArgs == 4) // there are no Cube gathers with offset
return true; // no offset on cube or cube array gathers
if (dim0 == 4) {
if ((isGather && numArgs > 3) || (isGatherCmp && numArgs > 4))
return true;
}
} }
// Reject invalid Loads // Reject invalid Loads
...@@ -648,15 +665,14 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c ...@@ -648,15 +665,14 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "Load", /* +sampleidex*/ "V4", nullptr, "$&,V,S", "FIU,I,I", EShLangAll }, { "Load", /* +sampleidex*/ "V4", nullptr, "$&,V,S", "FIU,I,I", EShLangAll },
{ "Load", /* +samplindex, offset*/ "V4", nullptr, "$&,V,S,V", "FIU,I,I,I", EShLangAll }, { "Load", /* +samplindex, offset*/ "V4", nullptr, "$&,V,S,V", "FIU,I,I,I", EShLangAll },
{ "Gather", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangVSPSGS }, { "Gather", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangAll },
{ "Gather", /* O*/ "V4", nullptr, "%@,S,V,V", "FIU,S,F,I", EShLangVSPSGS }, { "Gather", /* O*/ "V4", nullptr, "%@,S,V,V", "FIU,S,F,I", EShLangAll },
{ "CalculateLevelOfDetail", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask }, { "CalculateLevelOfDetail", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask },
{ "CalculateLevelOfDetailUnclamped", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask }, { "CalculateLevelOfDetailUnclamped", "S", "F", "%@,S,V", "FUI,S,F", EShLangFragmentMask },
{ "GetSamplePosition", "V2", "F", "$&2,S", "FUI,I", EShLangVSPSGS }, { "GetSamplePosition", "V2", "F", "$&2,S", "FUI,I", EShLangVSPSGS },
// table of overloads from: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509693(v=vs.85).aspx
// //
// UINT Width // UINT Width
// UINT MipLevel, UINT Width, UINT NumberOfLevels // UINT MipLevel, UINT Width, UINT NumberOfLevels
...@@ -709,10 +725,61 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c ...@@ -709,10 +725,61 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
// UINT Width, UINT Height, UINT Samples // UINT Width, UINT Height, UINT Samples
// UINT Width, UINT Height, UINT Elements, UINT Samples // UINT Width, UINT Height, UINT Elements, UINT Samples
{ "GetDimensions", /* 2DMS */ "-", "-", "$2,>S,,", "FUI,U,,", EShLangAll }, { "GetDimensions", /* 2DMS */ "-", "-", "$2,>S,,", "FUI,U,,", EShLangAll },
{ "GetDimensions", /* 2DMS */ "-", "-", "$2,>S,,", "FUI,U,,", EShLangAll }, { "GetDimensions", /* 2DMS */ "-", "-", "$2,>S,,", "FUI,U,,", EShLangAll },
{ "GetDimensions", /* 2DMSArray */ "-", "-", "&2,>S,,,", "FUI,U,,,", EShLangAll }, { "GetDimensions", /* 2DMSArray */ "-", "-", "&2,>S,,,", "FUI,U,,,", EShLangAll },
{ "GetDimensions", /* 2DMSArray */ "-", "-", "&2,>S,,,", "FUI,U,,,", EShLangAll }, { "GetDimensions", /* 2DMSArray */ "-", "-", "&2,>S,,,", "FUI,U,,,", EShLangAll },
// SM5 texture methods
{ "GatherRed", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangAll },
{ "GatherRed", /* O*/ "V4", nullptr, "%@,S,V,", "FIU,S,F,I", EShLangAll },
{ "GatherRed", /* O, status*/ "V4", nullptr, "%@,S,V,,>S", "FIU,S,F,I,U", EShLangAll },
{ "GatherRed", /* O-4 */ "V4", nullptr, "%@,S,V,,,,", "FIU,S,F,I,,,", EShLangAll },
{ "GatherRed", /* O-4, status */"V4", nullptr, "%@,S,V,,,,,S", "FIU,S,F,I,,,,U",EShLangAll },
{ "GatherGreen", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangAll },
{ "GatherGreen", /* O*/ "V4", nullptr, "%@,S,V,", "FIU,S,F,I", EShLangAll },
{ "GatherGreen", /* O, status*/ "V4", nullptr, "%@,S,V,,>S", "FIU,S,F,I,U", EShLangAll },
{ "GatherGreen", /* O-4 */ "V4", nullptr, "%@,S,V,,,,", "FIU,S,F,I,,,", EShLangAll },
{ "GatherGreen", /* O-4, status */"V4", nullptr, "%@,S,V,,,,,S", "FIU,S,F,I,,,,U",EShLangAll },
{ "GatherBlue", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangAll },
{ "GatherBlue", /* O*/ "V4", nullptr, "%@,S,V,", "FIU,S,F,I", EShLangAll },
{ "GatherBlue", /* O, status*/ "V4", nullptr, "%@,S,V,,>S", "FIU,S,F,I,U", EShLangAll },
{ "GatherBlue", /* O-4 */ "V4", nullptr, "%@,S,V,,,,", "FIU,S,F,I,,,", EShLangAll },
{ "GatherBlue", /* O-4, status */"V4", nullptr, "%@,S,V,,,,,S", "FIU,S,F,I,,,,U",EShLangAll },
{ "GatherAlpha", /*!O*/ "V4", nullptr, "%@,S,V", "FIU,S,F", EShLangAll },
{ "GatherAlpha", /* O*/ "V4", nullptr, "%@,S,V,", "FIU,S,F,I", EShLangAll },
{ "GatherAlpha", /* O, status*/ "V4", nullptr, "%@,S,V,,>S", "FIU,S,F,I,U", EShLangAll },
{ "GatherAlpha", /* O-4 */ "V4", nullptr, "%@,S,V,,,,", "FIU,S,F,I,,,", EShLangAll },
{ "GatherAlpha", /* O-4, status */"V4", nullptr, "%@,S,V,,,,,S", "FIU,S,F,I,,,,U",EShLangAll },
{ "GatherCmpRed", /*!O*/ "V4", nullptr, "%@,S,V,S", "FIU,s,F,", EShLangAll },
{ "GatherCmpRed", /* O*/ "V4", nullptr, "%@,S,V,S,V", "FIU,s,F,,I", EShLangAll },
{ "GatherCmpRed", /* O, status*/ "V4", nullptr, "%@,S,V,S,V,>S", "FIU,s,F,,I,U", EShLangAll },
{ "GatherCmpRed", /* O-4 */ "V4", nullptr, "%@,S,V,S,V,,,", "FIU,s,F,,I,,,", EShLangAll },
{ "GatherCmpRed", /* O-4, status */"V4", nullptr, "%@,S,V,S,V,,V,S","FIU,s,F,,I,,,,U",EShLangAll },
{ "GatherCmpGreen", /*!O*/ "V4", nullptr, "%@,S,V,S", "FIU,s,F,", EShLangAll },
{ "GatherCmpGreen", /* O*/ "V4", nullptr, "%@,S,V,S,V", "FIU,s,F,,I", EShLangAll },
{ "GatherCmpGreen", /* O, status*/ "V4", nullptr, "%@,S,V,S,V,>S", "FIU,s,F,,I,U", EShLangAll },
{ "GatherCmpGreen", /* O-4 */ "V4", nullptr, "%@,S,V,S,V,,,", "FIU,s,F,,I,,,", EShLangAll },
{ "GatherCmpGreen", /* O-4, status */"V4", nullptr, "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll },
{ "GatherCmpBlue", /*!O*/ "V4", nullptr, "%@,S,V,S", "FIU,s,F,", EShLangAll },
{ "GatherCmpBlue", /* O*/ "V4", nullptr, "%@,S,V,S,V", "FIU,s,F,,I", EShLangAll },
{ "GatherCmpBlue", /* O, status*/ "V4", nullptr, "%@,S,V,S,V,>S", "FIU,s,F,,I,U", EShLangAll },
{ "GatherCmpBlue", /* O-4 */ "V4", nullptr, "%@,S,V,S,V,,,", "FIU,s,F,,I,,,", EShLangAll },
{ "GatherCmpBlue", /* O-4, status */"V4", nullptr, "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll },
{ "GatherCmpAlpha", /*!O*/ "V4", nullptr, "%@,S,V,S", "FIU,s,F,", EShLangAll },
{ "GatherCmpAlpha", /* O*/ "V4", nullptr, "%@,S,V,S,V", "FIU,s,F,,I", EShLangAll },
{ "GatherCmpAlpha", /* O, status*/ "V4", nullptr, "%@,S,V,S,V,>S", "FIU,s,F,,I,U", EShLangAll },
{ "GatherCmpAlpha", /* O-4 */ "V4", nullptr, "%@,S,V,S,V,,,", "FIU,s,F,,I,,,", EShLangAll },
{ "GatherCmpAlpha", /* O-4, status */"V4", nullptr, "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll },
// TODO: Cmp forms
// Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet. // Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet.
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }, { nullptr, nullptr, nullptr, nullptr, nullptr, 0 },
...@@ -1012,6 +1079,16 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil ...@@ -1012,6 +1079,16 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("Gather", EOpMethodGather); symbolTable.relateToOperator("Gather", EOpMethodGather);
symbolTable.relateToOperator("CalculateLevelOfDetail", EOpMethodCalculateLevelOfDetail); symbolTable.relateToOperator("CalculateLevelOfDetail", EOpMethodCalculateLevelOfDetail);
symbolTable.relateToOperator("CalculateLevelOfDetailUnclamped", EOpMethodCalculateLevelOfDetailUnclamped); symbolTable.relateToOperator("CalculateLevelOfDetailUnclamped", EOpMethodCalculateLevelOfDetailUnclamped);
// SM5 Texture methods
symbolTable.relateToOperator("GatherRed", EOpMethodGatherRed);
symbolTable.relateToOperator("GatherGreen", EOpMethodGatherGreen);
symbolTable.relateToOperator("GatherBlue", EOpMethodGatherBlue);
symbolTable.relateToOperator("GatherAlpha", EOpMethodGatherAlpha);
symbolTable.relateToOperator("GatherCmpRed", EOpMethodGatherCmpRed);
symbolTable.relateToOperator("GatherCmpGreen", EOpMethodGatherCmpGreen);
symbolTable.relateToOperator("GatherCmpBlue", EOpMethodGatherCmpBlue);
symbolTable.relateToOperator("GatherCmpAlpha", EOpMethodGatherCmpAlpha);
} }
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment