Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
776c515e
Commit
776c515e
authored
Apr 12, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Support 1.#INF and -1.#INF syntax.
parent
b5e739c2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
257 additions
and
16 deletions
+257
-16
constFold.frag.out
Test/baseResults/constFold.frag.out
+1
-1
hlsl.inf.vert.out
Test/baseResults/hlsl.inf.vert.out
+172
-0
hlsl.inf.vert
Test/hlsl.inf.vert
+12
-0
revision.h
glslang/Include/revision.h
+2
-2
intermOut.cpp
glslang/MachineIndependent/intermOut.cpp
+31
-8
PpContext.h
glslang/MachineIndependent/preprocessor/PpContext.h
+9
-5
PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
+29
-0
Hlsl.FromFile.cpp
gtests/Hlsl.FromFile.cpp
+1
-0
No files found.
Test/baseResults/constFold.frag.out
View file @
776c515e
...
...
@@ -179,7 +179,7 @@ ERROR: node is still EOpNull!
0:83 Constant:
0:83 2147483647 (const int)
0:84 Constant:
0:84
inf
0:84
+1.#INF
0:88 Constant:
0:88 2 (const uint)
0:88 3 (const uint)
...
...
Test/baseResults/hlsl.inf.vert.out
0 → 100755
View file @
776c515e
hlsl.inf.vert
Shader version: 500
0:? Sequence
0:2 Function Definition: @main( ( temp 4-component vector of float)
0:2 Function Parameters:
0:? Sequence
0:3 Sequence
0:3 move second child to first child ( temp float)
0:3 'f1' ( temp float)
0:3 Constant:
0:3 -1.#INF
0:4 Sequence
0:4 move second child to first child ( temp float)
0:4 'f2' ( temp float)
0:4 Constant:
0:4 +1.#INF
0:5 Sequence
0:5 move second child to first child ( temp float)
0:5 'f3' ( temp float)
0:5 Constant:
0:5 +1.#INF
0:6 Sequence
0:6 move second child to first child ( temp float)
0:6 'f4' ( temp float)
0:6 add ( temp float)
0:6 component-wise multiply ( temp float)
0:6 'f2' ( temp float)
0:6 Constant:
0:6 +1.#INF
0:6 Constant:
0:6 +1.#INF
0:10 Branch: Return with expression
0:10 Construct vec4 ( temp 4-component vector of float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 'f1' ( temp float)
0:10 'f2' ( temp float)
0:10 'f3' ( temp float)
0:10 'f4' ( temp float)
0:10 Constant:
0:10 -1.#INF
0:10 Constant:
0:10 1.#IND
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:2 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:2 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' ( out 4-component vector of float Position)
Linked vertex stage:
Shader version: 500
0:? Sequence
0:2 Function Definition: @main( ( temp 4-component vector of float)
0:2 Function Parameters:
0:? Sequence
0:3 Sequence
0:3 move second child to first child ( temp float)
0:3 'f1' ( temp float)
0:3 Constant:
0:3 -1.#INF
0:4 Sequence
0:4 move second child to first child ( temp float)
0:4 'f2' ( temp float)
0:4 Constant:
0:4 +1.#INF
0:5 Sequence
0:5 move second child to first child ( temp float)
0:5 'f3' ( temp float)
0:5 Constant:
0:5 +1.#INF
0:6 Sequence
0:6 move second child to first child ( temp float)
0:6 'f4' ( temp float)
0:6 add ( temp float)
0:6 component-wise multiply ( temp float)
0:6 'f2' ( temp float)
0:6 Constant:
0:6 +1.#INF
0:6 Constant:
0:6 +1.#INF
0:10 Branch: Return with expression
0:10 Construct vec4 ( temp 4-component vector of float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 add ( temp float)
0:10 'f1' ( temp float)
0:10 'f2' ( temp float)
0:10 'f3' ( temp float)
0:10 'f4' ( temp float)
0:10 Constant:
0:10 -1.#INF
0:10 Constant:
0:10 1.#IND
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
0:2 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:2 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' ( out 4-component vector of float Position)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 37
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 35
Source HLSL 500
Name 4 "main"
Name 9 "@main("
Name 12 "f1"
Name 14 "f2"
Name 16 "f3"
Name 17 "f4"
Name 35 "@entryPointOutput"
Decorate 35(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeFunction 7(fvec4)
11: TypePointer Function 6(float)
13: 6(float) Constant 4286578688
15: 6(float) Constant 2139095040
29: 6(float) Constant 4290772992
34: TypePointer Output 7(fvec4)
35(@entryPointOutput): 34(ptr) Variable Output
4(main): 2 Function None 3
5: Label
36: 7(fvec4) FunctionCall 9(@main()
Store 35(@entryPointOutput) 36
Return
FunctionEnd
9(@main(): 7(fvec4) Function None 8
10: Label
12(f1): 11(ptr) Variable Function
14(f2): 11(ptr) Variable Function
16(f3): 11(ptr) Variable Function
17(f4): 11(ptr) Variable Function
Store 12(f1) 13
Store 14(f2) 15
Store 16(f3) 15
18: 6(float) Load 14(f2)
19: 6(float) FMul 18 15
20: 6(float) FAdd 19 15
Store 17(f4) 20
21: 6(float) Load 12(f1)
22: 6(float) Load 14(f2)
23: 6(float) FAdd 21 22
24: 6(float) Load 16(f3)
25: 6(float) FAdd 23 24
26: 6(float) Load 17(f4)
27: 6(float) FAdd 25 26
28: 6(float) FAdd 27 13
30: 6(float) FAdd 28 29
31: 7(fvec4) CompositeConstruct 30 30 30 30
ReturnValue 31
FunctionEnd
Test/hlsl.inf.vert
0 → 100755
View file @
776c515e
float4
main
()
:
SV_Position
{
float
f1
=
-
1
.
#
INF
;
float
f2
=
1
.
#
INF
;
float
f3
=
+
1
.
#
INF
;
float
f4
=
f2
*
1
.
#
INF
+
1
.
#
INF
;
const
float
f5
=
-
1
.
#
INF
;
const
float
f6
=
f5
*
0
.
0
f
;
return
(
float4
)(
f1
+
f2
+
f3
+
f4
+
f5
+
f6
);
}
\ No newline at end of file
glslang/Include/revision.h
View file @
776c515e
...
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.199
4
"
#define GLSLANG_DATE "1
1
-Apr-2017"
#define GLSLANG_REVISION "Overload400-PrecQual.199
5
"
#define GLSLANG_DATE "1
2
-Apr-2017"
glslang/MachineIndependent/intermOut.cpp
View file @
776c515e
...
...
@@ -45,11 +45,31 @@
namespace
{
bool
is_positive_i
nfinity
(
double
x
)
{
bool
IsI
nfinity
(
double
x
)
{
#ifdef _MSC_VER
return
_fpclass
(
x
)
==
_FPCLASS_PINF
;
switch
(
_fpclass
(
x
))
{
case
_FPCLASS_NINF
:
case
_FPCLASS_PINF
:
return
true
;
default
:
return
false
;
}
#else
return
std
::
isinf
(
x
);
#endif
}
bool
IsNan
(
double
x
)
{
#ifdef _MSC_VER
switch
(
_fpclass
(
x
))
{
case
_FPCLASS_SNAN
:
case
_FPCLASS_QNAN
:
return
true
;
default
:
return
false
;
}
#else
return
std
::
is
inf
(
x
)
&&
(
x
>=
0
);
return
std
::
is
nan
(
x
);
#endif
}
...
...
@@ -694,11 +714,14 @@ static void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const
#endif
{
const
double
value
=
constUnion
[
i
].
getDConst
();
// Print infinity in a portable way, for test stability.
// Other cases may be needed in the future: negative infinity,
// and NaNs.
if
(
is_positive_infinity
(
value
))
out
.
debug
<<
"inf
\n
"
;
// Print infinities and NaNs in a portable way.
if
(
IsInfinity
(
value
))
{
if
(
value
<
0
)
out
.
debug
<<
"-1.#INF
\n
"
;
else
out
.
debug
<<
"+1.#INF
\n
"
;
}
else
if
(
IsNan
(
value
))
out
.
debug
<<
"1.#IND
\n
"
;
else
{
const
int
maxSize
=
300
;
char
buf
[
maxSize
];
...
...
glslang/MachineIndependent/preprocessor/PpContext.h
View file @
776c515e
...
...
@@ -92,7 +92,7 @@ namespace glslang {
class
TPpToken
{
public
:
TPpToken
()
:
space
(
false
),
i
val
(
0
),
dval
(
0
.
0
),
i
64val
(
0
)
TPpToken
()
:
space
(
false
),
i64val
(
0
)
{
loc
.
init
();
name
[
0
]
=
0
;
...
...
@@ -108,10 +108,14 @@ public:
bool
operator
!=
(
const
TPpToken
&
right
)
{
return
!
operator
==
(
right
);
}
TSourceLoc
loc
;
bool
space
;
// true if a space (for white space or a removed comment) should also be recognized, in front of the token returned
int
ival
;
double
dval
;
long
long
i64val
;
bool
space
;
// true if a space (for white space or a removed comment) should also be recognized, in front of the token returned
union
{
int
ival
;
double
dval
;
long
long
i64val
;
};
char
name
[
MaxTokenLength
+
1
];
};
...
...
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
776c515e
...
...
@@ -124,6 +124,35 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
HasDecimalOrExponent
=
true
;
saveName
(
ch
);
ch
=
getChar
();
// 1.#INF or -1.#INF
if
(
ch
==
'#'
)
{
if
((
len
<
2
)
||
(
len
==
2
&&
ppToken
->
name
[
0
]
!=
'1'
)
||
(
len
==
3
&&
ppToken
->
name
[
1
]
!=
'1'
&&
!
(
ppToken
->
name
[
0
]
==
'-'
||
ppToken
->
name
[
0
]
==
'+'
))
||
(
len
>
3
))
parseContext
.
ppError
(
ppToken
->
loc
,
"unexpected use of"
,
"#"
,
""
);
else
{
// we have 1.# or -1.# or +1.#, check for 'INF'
if
((
ch
=
getChar
())
!=
'I'
||
(
ch
=
getChar
())
!=
'N'
||
(
ch
=
getChar
())
!=
'F'
)
parseContext
.
ppError
(
ppToken
->
loc
,
"expected 'INF'"
,
"#"
,
""
);
else
{
// we have [+-].#INF, and we are targeting IEEE 754, so wrap it up:
saveName
(
'I'
);
saveName
(
'N'
);
saveName
(
'F'
);
ppToken
->
name
[
len
]
=
'\0'
;
if
(
ppToken
->
name
[
0
]
==
'-'
)
ppToken
->
i64val
=
0xfff0000000000000
;
// -Infinity
else
ppToken
->
i64val
=
0x7ff0000000000000
;
// +Infinity
return
PpAtomConstFloat
;
}
}
}
while
(
ch
>=
'0'
&&
ch
<=
'9'
)
{
saveName
(
ch
);
ch
=
getChar
();
...
...
gtests/Hlsl.FromFile.cpp
View file @
776c515e
...
...
@@ -134,6 +134,7 @@ INSTANTIATE_TEST_CASE_P(
{
"hlsl.identifier.sample.frag"
,
"main"
},
{
"hlsl.if.frag"
,
"PixelShaderFunction"
},
{
"hlsl.implicitBool.frag"
,
"main"
},
{
"hlsl.inf.vert"
,
"main"
},
{
"hlsl.inoutquals.frag"
,
"main"
},
{
"hlsl.init.frag"
,
"ShaderFunction"
},
{
"hlsl.init2.frag"
,
"main"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment