Commit 92aff546 by LoopDawg

HLSL: add offset Sample() form and arrayed texture support

parent f02bea28
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 . Sample(g_sSamp, float2(0.1, 0.2));
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, float2(0.2, 0.3));
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, float2(0.3, 0.4));
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float3(0.3, 0.4, 0.5));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float3(0.5, 0.6, 0.7));
float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float4(0.1, 0.2, 0.3, 0.4));
int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float4(0.4, 0.5, 0.6, 0.7));
uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float4(0.7, 0.8, 0.9, 1.0));
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 . Sample(g_sSamp, float2(0.1, 0.2), 0);
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, float2(0.2, 0.3), 1);
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, float2(0.3, 0.4), 2);
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3), int2(0,0));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float3(0.3, 0.4, 0.5), int2(0,0));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float3(0.5, 0.6, 0.7), int2(0,1));
// No offset array forms for 3D or cube
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 PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1, 1);
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2, 1);
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3, 1);
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2), int2(1,0));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4), int2(1,1));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6), int2(1,-1));
float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3), int3(1,0,1));
int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6), int3(1,1,1));
uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9), 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;
}
...@@ -93,7 +93,10 @@ INSTANTIATE_TEST_CASE_P( ...@@ -93,7 +93,10 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.intrinsics.negative.comp", "ComputeShaderFunction"}, {"hlsl.intrinsics.negative.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.negative.frag", "PixelShaderFunction"}, {"hlsl.intrinsics.negative.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.negative.vert", "VertexShaderFunction"}, {"hlsl.intrinsics.negative.vert", "VertexShaderFunction"},
{"hlsl.sample.basicarraydx10.frag", "main"},
{"hlsl.sample.basicdx10.frag", "main"}, {"hlsl.sample.basicdx10.frag", "main"},
{"hlsl.sample.offsetdx10.frag", "main"},
{"hlsl.sample.offsetarraydx10.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"},
......
...@@ -1236,9 +1236,17 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1236,9 +1236,17 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
switch (op) { switch (op) {
case EOpMethodSample: case EOpMethodSample:
{ {
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped(); TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped(); TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped();
TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped(); TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped();
TIntermTyped* argOffset = nullptr;
TOperator textureOp = EOpTexture;
if (argAggregate->getSequence().size() == 4) { // 4th parameter is offset form
textureOp = EOpTextureOffset;
argOffset = argAggregate->getSequence()[3]->getAsTyped();
}
TIntermAggregate* txcombine = new TIntermAggregate(EOpConstructTextureSampler); TIntermAggregate* txcombine = new TIntermAggregate(EOpConstructTextureSampler);
...@@ -1249,9 +1257,11 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1249,9 +1257,11 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
txcombine->setType(TType(samplerType, EvqTemporary)); txcombine->setType(TType(samplerType, EvqTemporary));
txcombine->setLoc(loc); txcombine->setLoc(loc);
TIntermAggregate* txsample = new TIntermAggregate(EOpTexture); TIntermAggregate* txsample = new TIntermAggregate(textureOp);
txsample->getSequence().push_back(txcombine); txsample->getSequence().push_back(txcombine);
txsample->getSequence().push_back(argCoord); txsample->getSequence().push_back(argCoord);
if (argOffset != nullptr)
txsample->getSequence().push_back(argOffset);
txsample->setType(node->getType()); txsample->setType(node->getType());
txsample->setLoc(loc); txsample->setLoc(loc);
node = txsample; node = txsample;
......
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