mirror of
https://github.com/RPCS3/glslang.git
synced 2024-11-24 03:39:51 +00:00
Merge pull request #395 from steve-lunarg/samplers
HLSL: Add tx.GetDimensions method (uint returns only)
This commit is contained in:
commit
f8332509b9
2595
Test/baseResults/hlsl.getdimensions.dx10.frag.out
Normal file
2595
Test/baseResults/hlsl.getdimensions.dx10.frag.out
Normal file
File diff suppressed because it is too large
Load Diff
160
Test/baseResults/hlsl.getdimensions.dx10.vert.out
Normal file
160
Test/baseResults/hlsl.getdimensions.dx10.vert.out
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
hlsl.getdimensions.dx10.vert
|
||||||
|
Shader version: 450
|
||||||
|
0:? Sequence
|
||||||
|
0:28 Function Definition: main( (global structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:11 Function Parameters:
|
||||||
|
0:? Sequence
|
||||||
|
0:21 Sequence
|
||||||
|
0:21 move second child to first child (temp uint)
|
||||||
|
0:21 'sizeQueryTemp' (temp uint)
|
||||||
|
0:21 textureSize (temp uint)
|
||||||
|
0:21 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:21 move second child to first child (temp uint)
|
||||||
|
0:21 'WidthU' (temp uint)
|
||||||
|
0:21 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 Sequence
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 textureSize (temp uint)
|
||||||
|
0:22 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 6 (const uint)
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'WidthU' (temp uint)
|
||||||
|
0:22 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'NumberOfLevelsU' (temp uint)
|
||||||
|
0:22 textureQueryLevels (temp uint)
|
||||||
|
0:22 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:24 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:24 Pos: direct index for structure (temp 4-component vector of float FragCoord)
|
||||||
|
0:24 'vsout' (temp structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:24 Constant:
|
||||||
|
0:24 0 (const int)
|
||||||
|
0:? Constant:
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:26 Branch: Return with expression
|
||||||
|
0:26 'vsout' (temp structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'g_sSamp' (uniform sampler)
|
||||||
|
0:? 'g_tTex1df4' (uniform texture1D)
|
||||||
|
|
||||||
|
|
||||||
|
Linked vertex stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
0:? Sequence
|
||||||
|
0:28 Function Definition: main( (global structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:11 Function Parameters:
|
||||||
|
0:? Sequence
|
||||||
|
0:21 Sequence
|
||||||
|
0:21 move second child to first child (temp uint)
|
||||||
|
0:21 'sizeQueryTemp' (temp uint)
|
||||||
|
0:21 textureSize (temp uint)
|
||||||
|
0:21 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:21 move second child to first child (temp uint)
|
||||||
|
0:21 'WidthU' (temp uint)
|
||||||
|
0:21 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 Sequence
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 textureSize (temp uint)
|
||||||
|
0:22 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:22 Constant:
|
||||||
|
0:22 6 (const uint)
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'WidthU' (temp uint)
|
||||||
|
0:22 'sizeQueryTemp' (temp uint)
|
||||||
|
0:22 move second child to first child (temp uint)
|
||||||
|
0:22 'NumberOfLevelsU' (temp uint)
|
||||||
|
0:22 textureQueryLevels (temp uint)
|
||||||
|
0:22 'g_tTex1df4' (uniform texture1D)
|
||||||
|
0:24 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:24 Pos: direct index for structure (temp 4-component vector of float FragCoord)
|
||||||
|
0:24 'vsout' (temp structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:24 Constant:
|
||||||
|
0:24 0 (const int)
|
||||||
|
0:? Constant:
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 0.000000
|
||||||
|
0:26 Branch: Return with expression
|
||||||
|
0:26 'vsout' (temp structure{temp 4-component vector of float FragCoord Pos})
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'g_sSamp' (uniform sampler)
|
||||||
|
0:? 'g_tTex1df4' (uniform texture1D)
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 40
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
Capability Sampled1D
|
||||||
|
Capability ImageQuery
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Vertex 4 "main"
|
||||||
|
Source HLSL 450
|
||||||
|
Name 4 "main"
|
||||||
|
Name 8 "sizeQueryTemp"
|
||||||
|
Name 12 "g_tTex1df4"
|
||||||
|
Name 16 "WidthU"
|
||||||
|
Name 18 "sizeQueryTemp"
|
||||||
|
Name 23 "NumberOfLevelsU"
|
||||||
|
Name 27 "VS_OUTPUT"
|
||||||
|
MemberName 27(VS_OUTPUT) 0 "Pos"
|
||||||
|
Name 29 "vsout"
|
||||||
|
Name 39 "g_sSamp"
|
||||||
|
Decorate 12(g_tTex1df4) DescriptorSet 0
|
||||||
|
MemberDecorate 27(VS_OUTPUT) 0 BuiltIn FragCoord
|
||||||
|
Decorate 39(g_sSamp) DescriptorSet 0
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeInt 32 0
|
||||||
|
7: TypePointer Function 6(int)
|
||||||
|
9: TypeFloat 32
|
||||||
|
10: TypeImage 9(float) 1D sampled format:Unknown
|
||||||
|
11: TypePointer UniformConstant 10
|
||||||
|
12(g_tTex1df4): 11(ptr) Variable UniformConstant
|
||||||
|
14: TypeInt 32 1
|
||||||
|
20: 6(int) Constant 6
|
||||||
|
26: TypeVector 9(float) 4
|
||||||
|
27(VS_OUTPUT): TypeStruct 26(fvec4)
|
||||||
|
28: TypePointer Function 27(VS_OUTPUT)
|
||||||
|
30: 14(int) Constant 0
|
||||||
|
31: 9(float) Constant 0
|
||||||
|
32: 26(fvec4) ConstantComposite 31 31 31 31
|
||||||
|
33: TypePointer Function 26(fvec4)
|
||||||
|
37: TypeSampler
|
||||||
|
38: TypePointer UniformConstant 37
|
||||||
|
39(g_sSamp): 38(ptr) Variable UniformConstant
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
8(sizeQueryTemp): 7(ptr) Variable Function
|
||||||
|
16(WidthU): 7(ptr) Variable Function
|
||||||
|
18(sizeQueryTemp): 7(ptr) Variable Function
|
||||||
|
23(NumberOfLevelsU): 7(ptr) Variable Function
|
||||||
|
29(vsout): 28(ptr) Variable Function
|
||||||
|
13: 10 Load 12(g_tTex1df4)
|
||||||
|
15: 14(int) ImageQuerySize 13
|
||||||
|
Store 8(sizeQueryTemp) 15
|
||||||
|
17: 6(int) Load 8(sizeQueryTemp)
|
||||||
|
Store 16(WidthU) 17
|
||||||
|
19: 10 Load 12(g_tTex1df4)
|
||||||
|
21: 14(int) ImageQuerySizeLod 19 20
|
||||||
|
Store 18(sizeQueryTemp) 21
|
||||||
|
22: 6(int) Load 18(sizeQueryTemp)
|
||||||
|
Store 16(WidthU) 22
|
||||||
|
24: 10 Load 12(g_tTex1df4)
|
||||||
|
25: 14(int) ImageQueryLevels 24
|
||||||
|
Store 23(NumberOfLevelsU) 25
|
||||||
|
34: 33(ptr) AccessChain 29(vsout) 30
|
||||||
|
Store 34 32
|
||||||
|
35:27(VS_OUTPUT) Load 29(vsout)
|
||||||
|
ReturnValue 35
|
||||||
|
FunctionEnd
|
237
Test/hlsl.getdimensions.dx10.frag
Normal file
237
Test/hlsl.getdimensions.dx10.frag
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
SamplerState g_sSamp : register(s0);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
Texture1DArray <float4> g_tTex1df4a;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
PS_OUTPUT main()
|
||||||
|
{
|
||||||
|
PS_OUTPUT psout;
|
||||||
|
|
||||||
|
uint MipLevel;
|
||||||
|
uint WidthU;
|
||||||
|
uint HeightU;
|
||||||
|
uint ElementsU;
|
||||||
|
uint DepthU;
|
||||||
|
uint NumberOfLevelsU;
|
||||||
|
uint NumberOfSamplesU;
|
||||||
|
|
||||||
|
float WidthF;
|
||||||
|
float HeightF;
|
||||||
|
float ElementsF;
|
||||||
|
float DepthF;
|
||||||
|
float NumberOfLevelsF;
|
||||||
|
float NumberOfSamplesF;
|
||||||
|
|
||||||
|
// 1D, float tx, uint params
|
||||||
|
g_tTex1df4 . GetDimensions(WidthU);
|
||||||
|
g_tTex1df4 . GetDimensions(6, WidthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 1D, int, uint params
|
||||||
|
g_tTex1di4 . GetDimensions(WidthU);
|
||||||
|
g_tTex1di4 . GetDimensions(6, WidthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 1D, uint, uint params
|
||||||
|
g_tTex1du4 . GetDimensions(WidthU);
|
||||||
|
g_tTex1du4 . GetDimensions(6, WidthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 1DArray, float tx, uint params
|
||||||
|
g_tTex1df4a . GetDimensions(WidthU, ElementsU);
|
||||||
|
g_tTex1df4a . GetDimensions(6, WidthU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 1DArray, int, uint params
|
||||||
|
g_tTex1di4a . GetDimensions(WidthU, ElementsU);
|
||||||
|
g_tTex1di4a . GetDimensions(6, WidthU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 1DArray, uint, uint params
|
||||||
|
g_tTex1du4a . GetDimensions(WidthU, ElementsU);
|
||||||
|
g_tTex1du4a . GetDimensions(6, WidthU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2D, float tx, uint params
|
||||||
|
g_tTex2df4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTex2df4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2D, int, uint params
|
||||||
|
g_tTex2di4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTex2di4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2D, uint, uint params
|
||||||
|
g_tTex2du4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTex2du4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2Darray, float tx, uint params
|
||||||
|
g_tTex2df4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTex2df4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2Darray, int, uint params
|
||||||
|
g_tTex2di4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTex2di4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 2Darray, uint, uint params
|
||||||
|
g_tTex2du4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTex2du4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 3D, float tx, uint params
|
||||||
|
g_tTex3df4 . GetDimensions(WidthU, HeightU, DepthU);
|
||||||
|
g_tTex3df4 . GetDimensions(6, WidthU, HeightU, DepthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 3D, int, uint params
|
||||||
|
g_tTex3di4 . GetDimensions(WidthU, HeightU, DepthU);
|
||||||
|
g_tTex3di4 . GetDimensions(6, WidthU, HeightU, DepthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// 3D, uint, uint params
|
||||||
|
g_tTex3du4 . GetDimensions(WidthU, HeightU, DepthU);
|
||||||
|
g_tTex3du4 . GetDimensions(6, WidthU, HeightU, DepthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cube, float tx, uint params
|
||||||
|
g_tTexcdf4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTexcdf4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cube, int, uint params
|
||||||
|
g_tTexcdi4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTexcdi4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cube, uint, uint params
|
||||||
|
g_tTexcdu4 . GetDimensions(WidthU, HeightU);
|
||||||
|
g_tTexcdu4 . GetDimensions(6, WidthU, HeightU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cubearray, float tx, uint params
|
||||||
|
g_tTexcdf4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTexcdf4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cubearray, int, uint params
|
||||||
|
g_tTexcdi4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTexcdi4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
// Cubearray, uint, uint params
|
||||||
|
g_tTexcdu4a . GetDimensions(WidthU, HeightU, ElementsU);
|
||||||
|
g_tTexcdu4a . GetDimensions(6, WidthU, HeightU, ElementsU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: ***************************************************
|
||||||
|
// Change this to 1 to enable float overloads when the HLSL
|
||||||
|
// function overload resolution is fixed.
|
||||||
|
#define OVERLOAD_FIX 0
|
||||||
|
|
||||||
|
// TODO: enable when function overload resolution rules are fixed
|
||||||
|
#if OVERLOAD_FIX
|
||||||
|
// 1D, float tx, float params
|
||||||
|
g_tTex1df4 . GetDimensions(WidthF);
|
||||||
|
g_tTex1df4 . GetDimensions(6, WidthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 1D, int, float params
|
||||||
|
g_tTex1di4 . GetDimensions(WidthF);
|
||||||
|
g_tTex1di4 . GetDimensions(6, WidthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 1D, uint, float params
|
||||||
|
g_tTex1du4 . GetDimensions(WidthF);
|
||||||
|
g_tTex1du4 . GetDimensions(6, WidthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 1DArray, float tx, float params
|
||||||
|
g_tTex1df4a . GetDimensions(WidthF, ElementsF);
|
||||||
|
g_tTex1df4a . GetDimensions(6, WidthF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 1DArray, int, float params
|
||||||
|
g_tTex1di4a . GetDimensions(WidthF, ElementsF);
|
||||||
|
g_tTex1di4a . GetDimensions(6, WidthF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 1DArray, uint, float params
|
||||||
|
g_tTex1du4a . GetDimensions(WidthF, ElementsF);
|
||||||
|
g_tTex1du4a . GetDimensions(6, WidthF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2D, float tx, float params
|
||||||
|
g_tTex2df4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTex2df4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2D, int, float params
|
||||||
|
g_tTex2di4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTex2di4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2D, uint, float params
|
||||||
|
g_tTex2du4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTex2du4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2Darray, float tx, float params
|
||||||
|
g_tTex2df4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTex2df4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2Darray, int, float params
|
||||||
|
g_tTex2di4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTex2di4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 2Darray, uint, float params
|
||||||
|
g_tTex2du4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTex2du4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 3D, float tx, float params
|
||||||
|
g_tTex3df4 . GetDimensions(WidthF, HeightF, DepthF);
|
||||||
|
g_tTex3df4 . GetDimensions(6, WidthF, HeightF, DepthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 3D, int, float params
|
||||||
|
g_tTex3di4 . GetDimensions(WidthF, HeightF, DepthF);
|
||||||
|
g_tTex3di4 . GetDimensions(6, WidthF, HeightF, DepthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// 3D, uint, float params
|
||||||
|
g_tTex3du4 . GetDimensions(WidthF, HeightF, DepthF);
|
||||||
|
g_tTex3du4 . GetDimensions(6, WidthF, HeightF, DepthF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cube, float tx, float params
|
||||||
|
g_tTexcdf4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTexcdf4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cube, int, float params
|
||||||
|
g_tTexcdi4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTexcdi4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cube, uint, float params
|
||||||
|
g_tTexcdu4 . GetDimensions(WidthF, HeightF);
|
||||||
|
g_tTexcdu4 . GetDimensions(6, WidthF, HeightF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cubearray, float tx, float params
|
||||||
|
g_tTexcdf4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTexcdf4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cubearray, int, float params
|
||||||
|
g_tTexcdi4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTexcdi4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
|
||||||
|
// Cubearray, uint, float params
|
||||||
|
g_tTexcdu4a . GetDimensions(WidthF, HeightF, ElementsF);
|
||||||
|
g_tTexcdu4a . GetDimensions(6, WidthF, HeightF, ElementsF, NumberOfLevelsF);
|
||||||
|
#endif // OVERLOAD_FIX
|
||||||
|
|
||||||
|
psout.Color = 1.0;
|
||||||
|
psout.Depth = 1.0;
|
||||||
|
|
||||||
|
return psout;
|
||||||
|
}
|
27
Test/hlsl.getdimensions.dx10.vert
Normal file
27
Test/hlsl.getdimensions.dx10.vert
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
SamplerState g_sSamp : register(s0);
|
||||||
|
|
||||||
|
uniform Texture1D <float4> g_tTex1df4 : register(t0);
|
||||||
|
|
||||||
|
struct VS_OUTPUT
|
||||||
|
{
|
||||||
|
float4 Pos : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
VS_OUTPUT main()
|
||||||
|
{
|
||||||
|
VS_OUTPUT vsout;
|
||||||
|
|
||||||
|
uint WidthU;
|
||||||
|
uint NumberOfLevelsU;
|
||||||
|
|
||||||
|
// Most of the tests are in the hlsl.getdimensions.dx10.frag on the fragment side.
|
||||||
|
// This is just to establish that GetDimensions appears in the vertex stage.
|
||||||
|
|
||||||
|
// 1D, float tx, uint params
|
||||||
|
g_tTex1df4 . GetDimensions(WidthU);
|
||||||
|
g_tTex1df4 . GetDimensions(6, WidthU, NumberOfLevelsU);
|
||||||
|
|
||||||
|
vsout.Pos = float4(0,0,0,0);
|
||||||
|
|
||||||
|
return vsout;
|
||||||
|
}
|
@ -85,6 +85,7 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
|
|||||||
bool isPureSampler() const { return sampler; }
|
bool isPureSampler() const { return sampler; }
|
||||||
bool isTexture() const { return !sampler && !image; }
|
bool isTexture() const { return !sampler && !image; }
|
||||||
bool isShadow() const { return shadow; }
|
bool isShadow() const { return shadow; }
|
||||||
|
bool isArrayed() const { return arrayed; }
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,8 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
{"hlsl.float1.frag", "PixelShaderFunction"},
|
{"hlsl.float1.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.float4.frag", "PixelShaderFunction"},
|
{"hlsl.float4.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.forLoop.frag", "PixelShaderFunction"},
|
{"hlsl.forLoop.frag", "PixelShaderFunction"},
|
||||||
|
{"hlsl.getdimensions.dx10.frag", "main"},
|
||||||
|
{"hlsl.getdimensions.dx10.vert", "main"},
|
||||||
{"hlsl.if.frag", "PixelShaderFunction"},
|
{"hlsl.if.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.inoutquals.frag", "main"},
|
{"hlsl.inoutquals.frag", "main"},
|
||||||
{"hlsl.init.frag", "ShaderFunction"},
|
{"hlsl.init.frag", "ShaderFunction"},
|
||||||
|
@ -661,14 +661,14 @@ bool HlslGrammar::acceptSamplerType(TType& type)
|
|||||||
// read sampler type
|
// read sampler type
|
||||||
const EHlslTokenClass samplerType = peek();
|
const EHlslTokenClass samplerType = peek();
|
||||||
|
|
||||||
TSamplerDim dim = EsdNone;
|
// TSamplerDim dim = EsdNone;
|
||||||
|
|
||||||
switch (samplerType) {
|
switch (samplerType) {
|
||||||
case EHTokSampler: break;
|
case EHTokSampler: break;
|
||||||
case EHTokSampler1d: dim = Esd1D; break;
|
case EHTokSampler1d: /*dim = Esd1D*/; break;
|
||||||
case EHTokSampler2d: dim = Esd2D; break;
|
case EHTokSampler2d: /*dim = Esd2D*/; break;
|
||||||
case EHTokSampler3d: dim = Esd3D; break;
|
case EHTokSampler3d: /*dim = Esd3D*/; break;
|
||||||
case EHTokSamplerCube: dim = EsdCube; break;
|
case EHTokSamplerCube: /*dim = EsdCube*/; break;
|
||||||
case EHTokSamplerState: break;
|
case EHTokSamplerState: break;
|
||||||
case EHTokSamplerComparisonState: break;
|
case EHTokSamplerComparisonState: break;
|
||||||
default:
|
default:
|
||||||
|
@ -964,6 +964,105 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case EOpMethodGetDimensions:
|
||||||
|
{
|
||||||
|
// AST returns a vector of results, which we break apart component-wise into
|
||||||
|
// separate values to assign to the HLSL method's outputs, ala:
|
||||||
|
// tx . GetDimensions(width, height);
|
||||||
|
// float2 sizeQueryTemp = EOpTextureQuerySize
|
||||||
|
// width = sizeQueryTemp.X;
|
||||||
|
// height = sizeQueryTemp.Y;
|
||||||
|
|
||||||
|
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
|
||||||
|
const TType& texType = argTex->getType();
|
||||||
|
|
||||||
|
assert(texType.getBasicType() == EbtSampler);
|
||||||
|
|
||||||
|
const TSampler& texSampler = texType.getSampler();
|
||||||
|
const TSamplerDim dim = texSampler.dim;
|
||||||
|
const int numArgs = argAggregate->getSequence().size();
|
||||||
|
|
||||||
|
int numDims = 0;
|
||||||
|
|
||||||
|
switch (dim) {
|
||||||
|
case Esd1D: numDims = 1; break; // W
|
||||||
|
case Esd2D: numDims = 2; break; // W, H
|
||||||
|
case Esd3D: numDims = 3; break; // W, H, D
|
||||||
|
case EsdCube: numDims = 2; break; // W, H (cube)
|
||||||
|
default:
|
||||||
|
assert(0 && "unhandled texture dimension");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arrayed adds another dimension for the number of array elements
|
||||||
|
if (texSampler.isArrayed())
|
||||||
|
++numDims;
|
||||||
|
|
||||||
|
// Establish whether we're querying mip levels
|
||||||
|
const bool mipQuery = numArgs > (numDims + 1);
|
||||||
|
|
||||||
|
// AST assumes integer return. Will be converted to float if required.
|
||||||
|
TIntermAggregate* sizeQuery = new TIntermAggregate(EOpTextureQuerySize);
|
||||||
|
sizeQuery->getSequence().push_back(argTex);
|
||||||
|
// If we're querying an explicit LOD, add the LOD, which is always arg #1
|
||||||
|
if (mipQuery) {
|
||||||
|
TIntermTyped* queryLod = argAggregate->getSequence()[1]->getAsTyped();
|
||||||
|
sizeQuery->getSequence().push_back(queryLod);
|
||||||
|
}
|
||||||
|
sizeQuery->setType(TType(EbtUint, EvqTemporary, numDims));
|
||||||
|
sizeQuery->setLoc(loc);
|
||||||
|
|
||||||
|
// Return value from size query
|
||||||
|
TVariable* tempArg = makeInternalVariable("sizeQueryTemp", sizeQuery->getType());
|
||||||
|
tempArg->getWritableType().getQualifier().makeTemporary();
|
||||||
|
TIntermSymbol* sizeQueryReturn = intermediate.addSymbol(*tempArg, loc);
|
||||||
|
|
||||||
|
TIntermTyped* sizeQueryAssign = intermediate.addAssign(EOpAssign, sizeQueryReturn, sizeQuery, loc);
|
||||||
|
|
||||||
|
// Compound statement for assigning outputs
|
||||||
|
TIntermAggregate* compoundStatement = intermediate.makeAggregate(sizeQueryAssign, loc);
|
||||||
|
// Index of first output parameter
|
||||||
|
const int outParamBase = mipQuery ? 2 : 1;
|
||||||
|
|
||||||
|
for (int compNum = 0; compNum < numDims; ++compNum) {
|
||||||
|
TIntermTyped* indexedOut = nullptr;
|
||||||
|
|
||||||
|
if (numDims > 1) {
|
||||||
|
TIntermTyped* component = intermediate.addConstantUnion(compNum, loc, true);
|
||||||
|
indexedOut = intermediate.addIndex(EOpIndexDirect, sizeQueryReturn, component, loc);
|
||||||
|
indexedOut->setType(TType(EbtUint, EvqTemporary, 1));
|
||||||
|
indexedOut->setLoc(loc);
|
||||||
|
} else {
|
||||||
|
indexedOut = sizeQueryReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
TIntermTyped* outParam = argAggregate->getSequence()[outParamBase + compNum]->getAsTyped();
|
||||||
|
TIntermTyped* compAssign = intermediate.addAssign(EOpAssign, outParam, indexedOut, loc);
|
||||||
|
|
||||||
|
compoundStatement = intermediate.growAggregate(compoundStatement, compAssign);
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle mip level parameter
|
||||||
|
if (mipQuery) {
|
||||||
|
TIntermTyped* outParam = argAggregate->getSequence()[outParamBase + numDims]->getAsTyped();
|
||||||
|
|
||||||
|
TIntermAggregate* levelsQuery = new TIntermAggregate(EOpTextureQueryLevels);
|
||||||
|
levelsQuery->getSequence().push_back(argTex);
|
||||||
|
levelsQuery->setType(TType(EbtUint, EvqTemporary, 1));
|
||||||
|
levelsQuery->setLoc(loc);
|
||||||
|
|
||||||
|
TIntermTyped* compAssign = intermediate.addAssign(EOpAssign, outParam, levelsQuery, loc);
|
||||||
|
compoundStatement = intermediate.growAggregate(compoundStatement, compAssign);
|
||||||
|
}
|
||||||
|
|
||||||
|
compoundStatement->setOperator(EOpSequence);
|
||||||
|
compoundStatement->setLoc(loc);
|
||||||
|
compoundStatement->setType(TType(EbtVoid));
|
||||||
|
|
||||||
|
node = compoundStatement;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break; // most pass through unchanged
|
break; // most pass through unchanged
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,18 @@ inline const char* FindEndOfArg(const char* arg)
|
|||||||
return *arg == '\0' ? nullptr : arg;
|
return *arg == '\0' ? nullptr : arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a fixed vector size, such as V3, return the size. Else return 0.
|
||||||
|
int FixedVecSize(const char* arg)
|
||||||
|
{
|
||||||
|
while (!IsEndOfArg(arg)) {
|
||||||
|
if (isdigit(*arg))
|
||||||
|
return *arg - '0';
|
||||||
|
++arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // none found.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return pointer to beginning of Nth argument specifier in the string.
|
// Return pointer to beginning of Nth argument specifier in the string.
|
||||||
inline const char* NthArg(const char* arg, int n)
|
inline const char* NthArg(const char* arg, int n)
|
||||||
@ -571,6 +583,61 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
|||||||
// { "Load", /* +sampleidex*/ "V4", nullptr, "@V,V,S", "FIU,I,I", EShLangFragmentMask },
|
// { "Load", /* +sampleidex*/ "V4", nullptr, "@V,V,S", "FIU,I,I", EShLangFragmentMask },
|
||||||
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "@V,V,S,V", "FIU,I,I,I", EShLangFragmentMask },
|
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "@V,V,S,V", "FIU,I,I,I", EShLangFragmentMask },
|
||||||
|
|
||||||
|
// table of overloads from: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509693(v=vs.85).aspx
|
||||||
|
//
|
||||||
|
// UINT Width
|
||||||
|
// UINT MipLevel, UINT Width, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* 1D */ "-", "-", "%V1,>S", "FUI,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1D */ "-", "-", "%V1,>S", "FUI,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1D */ "-", "-", "%V1,S,>S,>S", "FUI,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1D */ "-", "-", "%V1,S,>S,>S", "FUI,U,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Elements
|
||||||
|
// UINT MipLevel, UINT Width, UINT Elements, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* 1DArray */ "-", "-", "@V1,>S,>S", "FUI,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1DArray */ "-", "-", "@V1,>S,>S", "FUI,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1DArray */ "-", "-", "@V1,S,>S,>S,>S", "FUI,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 1DArray */ "-", "-", "@V1,S,>S,>S,>S", "FUI,U,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Height
|
||||||
|
// UINT MipLevel, UINT Width, UINT Height, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* 2D */ "-", "-", "%V2,>S,>S", "FUI,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2D */ "-", "-", "%V2,>S,>S", "FUI,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2D */ "-", "-", "%V2,S,>S,>S,>S", "FUI,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2D */ "-", "-", "%V2,S,>S,>S,>S", "FUI,U,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Height, UINT Elements
|
||||||
|
// UINT MipLevel, UINT Width, UINT Height, UINT Elements, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* 2DArray */ "-", "-", "@V2,>S,>S,>S", "FUI,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2DArray */ "-", "-", "@V2,>S,>S,>S", "FUI,F,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2DArray */ "-", "-", "@V2,S,>S,>S,>S,>S", "FUI,U,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 2DArray */ "-", "-", "@V2,S,>S,>S,>S,>S", "FUI,U,F,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Height, UINT Depth
|
||||||
|
// UINT MipLevel, UINT Width, UINT Height, UINT Depth, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* 3D */ "-", "-", "%V3,>S,>S,>S", "FUI,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 3D */ "-", "-", "%V3,>S,>S,>S", "FUI,F,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 3D */ "-", "-", "%V3,S,>S,>S,>S,>S", "FUI,U,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* 3D */ "-", "-", "%V3,S,>S,>S,>S,>S", "FUI,U,F,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Height
|
||||||
|
// UINT MipLevel, UINT Width, UINT Height, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* Cube */ "-", "-", "%V4,>S,>S", "FUI,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* Cube */ "-", "-", "%V4,>S,>S", "FUI,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* Cube */ "-", "-", "%V4,S,>S,>S,>S", "FUI,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* Cube */ "-", "-", "%V4,S,>S,>S,>S", "FUI,U,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// UINT Width, UINT Height, UINT Elements
|
||||||
|
// UINT MipLevel, UINT Width, UINT Height, UINT Elements, UINT NumberOfLevels
|
||||||
|
{ "GetDimensions", /* CubeArray */ "-", "-", "@V4,>S,>S,>S", "FUI,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* CubeArray */ "-", "-", "@V4,>S,>S,>S", "FUI,F,F,F", EShLangAll },
|
||||||
|
{ "GetDimensions", /* CubeArray */ "-", "-", "@V4,S,>S,>S,>S,>S", "FUI,U,U,U,U,U", EShLangAll },
|
||||||
|
{ "GetDimensions", /* CubeArray */ "-", "-", "@V4,S,>S,>S,>S,>S", "FUI,U,F,F,F,F", EShLangAll },
|
||||||
|
|
||||||
|
// TODO: GetDimensions for Texture2DMS, Texture2DMSArray
|
||||||
|
// UINT Width, UINT Height, UINT Samples
|
||||||
|
// UINT Width, UINT Height, UINT Elements, UINT Samples
|
||||||
|
|
||||||
// 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 },
|
||||||
};
|
};
|
||||||
@ -593,7 +660,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
|||||||
for (const char* argOrder = intrinsic.argOrder; !IsEndOfArg(argOrder); ++argOrder) { // for each order...
|
for (const char* argOrder = intrinsic.argOrder; !IsEndOfArg(argOrder); ++argOrder) { // for each order...
|
||||||
const bool isTexture = IsTextureType(*argOrder);
|
const bool isTexture = IsTextureType(*argOrder);
|
||||||
const bool isArrayed = IsTextureArrayed(*argOrder);
|
const bool isArrayed = IsTextureArrayed(*argOrder);
|
||||||
const int fixedVecSize = isdigit(argOrder[1]) ? (argOrder[1] - '0') : 0;
|
const int fixedVecSize = FixedVecSize(argOrder);
|
||||||
|
|
||||||
// calculate min and max vector and matrix dimensions
|
// calculate min and max vector and matrix dimensions
|
||||||
int dim0Min = 1;
|
int dim0Min = 1;
|
||||||
@ -663,7 +730,10 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fixedVecSize > 0 || isTexture) // skip over special characters
|
// skip over special characters
|
||||||
|
if (isTexture)
|
||||||
|
++argOrder;
|
||||||
|
if (isdigit(argOrder[1]))
|
||||||
++argOrder;
|
++argOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,6 +921,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user