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
033d3ef2
Commit
033d3ef2
authored
Oct 13, 2016
by
baldurk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change enum class to plain enum
parent
31d5d488
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+1
-1
hex_float.h
SPIRV/hex_float.h
+12
-13
No files found.
SPIRV/SpvBuilder.cpp
View file @
033d3ef2
...
...
@@ -797,7 +797,7 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
spvutils
::
HexFloat
<
spvutils
::
FloatProxy
<
float
>>
fVal
(
f16
);
spvutils
::
HexFloat
<
spvutils
::
FloatProxy
<
spvutils
::
Float16
>>
f16Val
(
0
);
fVal
.
castTo
(
f16Val
,
spvutils
::
round_direction
::
k
ToZero
);
fVal
.
castTo
(
f16Val
,
spvutils
::
kRound
ToZero
);
unsigned
value
=
f16Val
.
value
().
getAsFloat
().
get_value
();
...
...
SPIRV/hex_float.h
View file @
033d3ef2
...
...
@@ -226,12 +226,11 @@ struct HexFloatTraits<FloatProxy<Float16>> {
static
const
uint_type
exponent_bias
=
15
;
};
enum
class
round_direction
{
kToZero
,
kToNearestEven
,
kToPositiveInfinity
,
kToNegativeInfinity
,
max
=
kToNegativeInfinity
enum
round_direction
{
kRoundToZero
,
kRoundToNearestEven
,
kRoundToPositiveInfinity
,
kRoundToNegativeInfinity
};
// Template class that houses a floating pointer number.
...
...
@@ -520,15 +519,15 @@ class HexFloat {
// We actually have to narrow the significand here, so we have to follow the
// rounding rules.
switch
(
dir
)
{
case
round_direction
:
:
k
ToZero
:
case
kRound
ToZero
:
break
;
case
round_direction
:
:
k
ToPositiveInfinity
:
case
kRound
ToPositiveInfinity
:
round_away_from_zero
=
!
isNegative
();
break
;
case
round_direction
:
:
k
ToNegativeInfinity
:
case
kRound
ToNegativeInfinity
:
round_away_from_zero
=
isNegative
();
break
;
case
round_direction
:
:
k
ToNearestEven
:
case
kRound
ToNearestEven
:
// Have to round down, round bit is 0
if
((
first_rounded_bit
&
significand
)
==
0
)
{
break
;
...
...
@@ -623,8 +622,8 @@ class HexFloat {
}
bool
round_underflow_up
=
isNegative
()
?
round_dir
==
round_direction
::
k
ToNegativeInfinity
:
round_dir
==
round_direction
::
k
ToPositiveInfinity
;
isNegative
()
?
round_dir
==
kRound
ToNegativeInfinity
:
round_dir
==
kRound
ToPositiveInfinity
;
using
other_int_type
=
typename
other_T
::
int_type
;
// setFromSignUnbiasedExponentAndNormalizedSignificand will
// zero out any underflowing value (but retain the sign).
...
...
@@ -812,7 +811,7 @@ ParseNormalFloat<FloatProxy<Float16>, HexFloatTraits<FloatProxy<Float16>>>(
// Then convert to 16-bit float, saturating at infinities, and
// rounding toward zero.
float_val
.
castTo
(
value
,
round_direction
::
k
ToZero
);
float_val
.
castTo
(
value
,
kRound
ToZero
);
// Overflow on 16-bit behaves the same as for 32- and 64-bit: set the
// fail bit and set the lowest or highest value.
...
...
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