Commit 3ef7852e by LoopDawg

HLSL: Add SampleLevel method

parent 2f003ac4
SamplerState g_sSamp : register(s0);
Texture1DArray g_tTex1df4a : register(t1);
uniform Texture1DArray <float4> g_tTex1df4 : register(t0);
Texture1DArray <int4> g_tTex1di4;
Texture1DArray <uint4> g_tTex1du4;
Texture2DArray <float4> g_tTex2df4;
Texture2DArray <int4> g_tTex2di4;
Texture2DArray <uint4> g_tTex2du4;
TextureCubeArray <float4> g_tTexcdf4;
TextureCubeArray <int4> g_tTexcdi4;
TextureCubeArray <uint4> g_tTexcdu4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
float4 txval10 = g_tTex1df4 . SampleLevel(g_sSamp, float2(0.1, 0.2), 0.75);
int4 txval11 = g_tTex1di4 . SampleLevel(g_sSamp, float2(0.2, 0.3), 0.75);
uint4 txval12 = g_tTex1du4 . SampleLevel(g_sSamp, float2(0.3, 0.4), 0.75);
float4 txval20 = g_tTex2df4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75);
int4 txval21 = g_tTex2di4 . SampleLevel(g_sSamp, float3(0.3, 0.4, 0.5), 0.75);
uint4 txval22 = g_tTex2du4 . SampleLevel(g_sSamp, float3(0.5, 0.6, 0.7), 0.75);
float4 txval40 = g_tTexcdf4 . SampleLevel(g_sSamp, float4(0.1, 0.2, 0.3, 0.4), 0.75);
int4 txval41 = g_tTexcdi4 . SampleLevel(g_sSamp, float4(0.4, 0.5, 0.6, 0.7), 0.75);
uint4 txval42 = g_tTexcdu4 . SampleLevel(g_sSamp, float4(0.7, 0.8, 0.9, 1.0), 0.75);
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;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
float4 txval10 = g_tTex1df4 . SampleLevel(g_sSamp, 0.1, 0.75);
int4 txval11 = g_tTex1di4 . SampleLevel(g_sSamp, 0.2, 0.75);
uint4 txval12 = g_tTex1du4 . SampleLevel(g_sSamp, 0.3, 0.75);
float4 txval20 = g_tTex2df4 . SampleLevel(g_sSamp, float2(0.1, 0.2), 0.75);
int4 txval21 = g_tTex2di4 . SampleLevel(g_sSamp, float2(0.3, 0.4), 0.75);
uint4 txval22 = g_tTex2du4 . SampleLevel(g_sSamp, float2(0.5, 0.6), 0.75);
float4 txval30 = g_tTex3df4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75);
int4 txval31 = g_tTex3di4 . SampleLevel(g_sSamp, float3(0.4, 0.5, 0.6), 0.75);
uint4 txval32 = g_tTex3du4 . SampleLevel(g_sSamp, float3(0.7, 0.8, 0.9), 0.75);
float4 txval40 = g_tTexcdf4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75);
int4 txval41 = g_tTexcdi4 . SampleLevel(g_sSamp, float3(0.4, 0.5, 0.6), 0.75);
uint4 txval42 = g_tTexcdu4 . SampleLevel(g_sSamp, float3(0.7, 0.8, 0.9), 0.75);
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : 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 VS_OUTPUT
{
float4 Pos : SV_Position;
};
VS_OUTPUT main()
{
VS_OUTPUT vsout;
float4 txval10 = g_tTex1df4 . SampleLevel(g_sSamp, 0.1, 0.75);
int4 txval11 = g_tTex1di4 . SampleLevel(g_sSamp, 0.2, 0.75);
uint4 txval12 = g_tTex1du4 . SampleLevel(g_sSamp, 0.3, 0.75);
float4 txval20 = g_tTex2df4 . SampleLevel(g_sSamp, float2(0.1, 0.2), 0.75);
int4 txval21 = g_tTex2di4 . SampleLevel(g_sSamp, float2(0.3, 0.4), 0.75);
uint4 txval22 = g_tTex2du4 . SampleLevel(g_sSamp, float2(0.5, 0.6), 0.75);
float4 txval30 = g_tTex3df4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75);
int4 txval31 = g_tTex3di4 . SampleLevel(g_sSamp, float3(0.4, 0.5, 0.6), 0.75);
uint4 txval32 = g_tTex3du4 . SampleLevel(g_sSamp, float3(0.7, 0.8, 0.9), 0.75);
float4 txval40 = g_tTexcdf4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75);
int4 txval41 = g_tTexcdi4 . SampleLevel(g_sSamp, float3(0.4, 0.5, 0.6), 0.75);
uint4 txval42 = g_tTexcdu4 . SampleLevel(g_sSamp, float3(0.7, 0.8, 0.9), 0.75);
vsout.Pos = float4(0,0,0,0);
return vsout;
}
SamplerState g_sSamp : 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;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
float4 txval10 = g_tTex1df4 . SampleLevel(g_sSamp, 0.1, 0.75, 1);
int4 txval11 = g_tTex1di4 . SampleLevel(g_sSamp, 0.2, 0.75, 1);
uint4 txval12 = g_tTex1du4 . SampleLevel(g_sSamp, 0.3, 0.75, 1);
float4 txval20 = g_tTex2df4 . SampleLevel(g_sSamp, float2(0.1, 0.2), 0.75, int2(1,0));
int4 txval21 = g_tTex2di4 . SampleLevel(g_sSamp, float2(0.3, 0.4), 0.75, int2(1,1));
uint4 txval22 = g_tTex2du4 . SampleLevel(g_sSamp, float2(0.5, 0.6), 0.75, int2(1,-1));
float4 txval30 = g_tTex3df4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75, int3(1,0,1));
int4 txval31 = g_tTex3di4 . SampleLevel(g_sSamp, float3(0.4, 0.5, 0.6), 0.75, int3(1,1,1));
uint4 txval32 = g_tTex3du4 . SampleLevel(g_sSamp, float3(0.7, 0.8, 0.9), 0.75, int3(1,0,-1));
// There are no offset forms of cube textures, so we do not test them.
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
Texture1DArray g_tTex1df4a : register(t1);
uniform Texture1DArray <float4> g_tTex1df4 : register(t0);
Texture1DArray <int4> g_tTex1di4;
Texture1DArray <uint4> g_tTex1du4;
Texture2DArray <float4> g_tTex2df4;
Texture2DArray <int4> g_tTex2di4;
Texture2DArray <uint4> g_tTex2du4;
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
float4 txval10 = g_tTex1df4 . SampleLevel(g_sSamp, float2(0.1, 0.2), 0.75, 0);
int4 txval11 = g_tTex1di4 . SampleLevel(g_sSamp, float2(0.2, 0.3), 0.75, 1);
uint4 txval12 = g_tTex1du4 . SampleLevel(g_sSamp, float2(0.3, 0.4), 0.75, 2);
float4 txval20 = g_tTex2df4 . SampleLevel(g_sSamp, float3(0.1, 0.2, 0.3), 0.75, int2(0,0));
int4 txval21 = g_tTex2di4 . SampleLevel(g_sSamp, float3(0.3, 0.4, 0.5), 0.75, int2(0,0));
uint4 txval22 = g_tTex2du4 . SampleLevel(g_sSamp, float3(0.5, 0.6, 0.7), 0.75, int2(0,1));
// No offset array forms for 3D or cube
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
...@@ -121,6 +121,11 @@ INSTANTIATE_TEST_CASE_P( ...@@ -121,6 +121,11 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.samplegrad.basic.dx10.vert", "main"}, {"hlsl.samplegrad.basic.dx10.vert", "main"},
{"hlsl.samplegrad.offset.dx10.frag", "main"}, {"hlsl.samplegrad.offset.dx10.frag", "main"},
{"hlsl.samplegrad.offsetarray.dx10.frag", "main"}, {"hlsl.samplegrad.offsetarray.dx10.frag", "main"},
{"hlsl.samplelevel.array.dx10.frag", "main"},
{"hlsl.samplelevel.basic.dx10.frag", "main"},
{"hlsl.samplelevel.basic.dx10.vert", "main"},
{"hlsl.samplelevel.offset.dx10.frag", "main"},
{"hlsl.samplelevel.offsetarray.dx10.frag", "main"},
{"hlsl.intrinsics.vert", "VertexShaderFunction"}, {"hlsl.intrinsics.vert", "VertexShaderFunction"},
{"hlsl.matType.frag", "PixelShaderFunction"}, {"hlsl.matType.frag", "PixelShaderFunction"},
{"hlsl.max.frag", "PixelShaderFunction"}, {"hlsl.max.frag", "PixelShaderFunction"},
......
...@@ -1189,6 +1189,38 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1189,6 +1189,38 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break; break;
} }
case EOpMethodSampleLevel:
{
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped();
TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped();
TIntermTyped* argLod = argAggregate->getSequence()[3]->getAsTyped();
TIntermTyped* argOffset = nullptr;
const int numArgs = argAggregate->getSequence().size();
if (numArgs == 5) // offset, if present
argOffset = argAggregate->getSequence()[4]->getAsTyped();
const TOperator textureOp = (argOffset == nullptr ? EOpTextureLod : EOpTextureLodOffset);
TIntermAggregate* txsample = new TIntermAggregate(textureOp);
TIntermAggregate* txcombine = handleSamplerTextureCombine(loc, argTex, argSamp);
txsample->getSequence().push_back(txcombine);
txsample->getSequence().push_back(argCoord);
txsample->getSequence().push_back(argLod);
if (argOffset != nullptr)
txsample->getSequence().push_back(argOffset);
txsample->setType(node->getType());
txsample->setLoc(loc);
node = txsample;
break;
}
default: default:
break; // most pass through unchanged break; // most pass through unchanged
} }
......
...@@ -588,15 +588,15 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c ...@@ -588,15 +588,15 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "SampleGrad", /*!O A*/ "V4", nullptr, "@V,S,V,V,V", "FIU,S,F,F,F", EShLangAll }, { "SampleGrad", /*!O A*/ "V4", nullptr, "@V,S,V,V,V", "FIU,S,F,F,F", EShLangAll },
{ "SampleGrad", /* O A*/ "V4", nullptr, "@V,S,V,V,V,V", "FIU,S,F,F,F,I", EShLangAll }, { "SampleGrad", /* O A*/ "V4", nullptr, "@V,S,V,V,V,V", "FIU,S,F,F,F,I", EShLangAll },
// { "SampleLevel", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangAll }, { "SampleLevel", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangAll },
// { "SampleLevel", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangAll }, { "SampleLevel", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
// { "SampleLevel", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangAll }, { "SampleLevel", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangAll },
// { "SampleLevel", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangAll }, { "SampleLevel", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangAll },
{ "Load", /*!O !A*/ "V4", nullptr, "%V,V", "FIU,I", EShLangAll }, { "Load", /*!O !A*/ "V4", nullptr, "%V,V", "FIU,I", EShLangAll },
{ "Load", /*!O A*/ "V4", nullptr, "@V,V", "FIU,I", EShLangAll }, { "Load", /*!O A*/ "V4", nullptr, "@V,V", "FIU,I", EShLangAll },
{ "Load", /* O !A*/ "V4", nullptr, "%V,V,V", "FIU,I,I", EShLangAll }, { "Load", /* O !A*/ "V4", nullptr, "%V,V,V", "FIU,I,I", EShLangAll },
{ "Load", /* O A*/ "V4", nullptr, "@V,V,V", "FIU,I,I", EShLangAll }, { "Load", /* O A*/ "V4", nullptr, "@V,V,V", "FIU,I,I", EShLangAll },
// TODO: MS variants of Load // TODO: MS variants of Load
// { "Load", /* +sampleidex*/ "V4", nullptr, "$V,V,S", "FIU,I,I", EShLangAll }, // { "Load", /* +sampleidex*/ "V4", nullptr, "$V,V,S", "FIU,I,I", EShLangAll },
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "$V,V,S,V", "FIU,I,I,I", EShLangAll }, // { "Load", /* +samplindex, offset*/ "V4", nullptr, "$V,V,S,V", "FIU,I,I,I", EShLangAll },
...@@ -943,7 +943,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil ...@@ -943,7 +943,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("SampleCmp", EOpMethodSampleCmp); symbolTable.relateToOperator("SampleCmp", EOpMethodSampleCmp);
symbolTable.relateToOperator("SampleCmpLevelZero", EOpMethodSampleCmpLevelZero); symbolTable.relateToOperator("SampleCmpLevelZero", EOpMethodSampleCmpLevelZero);
symbolTable.relateToOperator("SampleGrad", EOpMethodSampleGrad); symbolTable.relateToOperator("SampleGrad", EOpMethodSampleGrad);
// symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel); symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel);
symbolTable.relateToOperator("Load", EOpMethodLoad); symbolTable.relateToOperator("Load", EOpMethodLoad);
symbolTable.relateToOperator("GetDimensions", EOpMethodGetDimensions); symbolTable.relateToOperator("GetDimensions", EOpMethodGetDimensions);
} }
......
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