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
021dbb4c
Commit
021dbb4c
authored
Oct 13, 2016
by
baldurk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change negatable_left_shift and negatable_right_shift to inline funcs
* This avoids an internal compile error on VS2010 possibly related to std::enable_if use.
parent
cabba60a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
31 deletions
+21
-31
hex_float.h
SPIRV/hex_float.h
+21
-31
No files found.
SPIRV/hex_float.h
View file @
021dbb4c
...
...
@@ -456,33 +456,23 @@ class HexFloat {
// constant_number < 0? 0: constant_number
// These convert the negative left-shifts into right shifts.
template
<
int_type
N
,
typename
enable
=
void
>
struct
negatable_left_shift
{
static
uint_type
val
(
uint_type
val
)
{
return
static_cast
<
uint_type
>
(
val
>>
-
N
);
}
};
template
<
typename
int_type
>
uint_type
negatable_left_shift
(
int_type
N
,
uint_type
val
)
{
if
(
N
>=
0
)
return
val
<<
N
;
template
<
int_type
N
>
struct
negatable_left_shift
<
N
,
typename
std
::
enable_if
<
N
>=
0
>::
type
>
{
static
uint_type
val
(
uint_type
val
)
{
return
static_cast
<
uint_type
>
(
val
<<
N
);
}
};
return
val
>>
-
N
;
}
template
<
int_type
N
,
typename
enable
=
void
>
struct
negatable_right_shift
{
static
uint_type
val
(
uint_type
val
)
{
return
static_cast
<
uint_type
>
(
val
<<
-
N
);
}
};
template
<
typename
int_type
>
uint_type
negatable_right_shift
(
int_type
N
,
uint_type
val
)
{
if
(
N
>=
0
)
return
val
>>
N
;
template
<
int_type
N
>
struct
negatable_right_shift
<
N
,
typename
std
::
enable_if
<
N
>=
0
>::
type
>
{
static
uint_type
val
(
uint_type
val
)
{
return
static_cast
<
uint_type
>
(
val
>>
N
);
}
};
return
val
<<
-
N
;
}
// Returns the significand, rounded to fit in a significand in
// other_T. This is shifted so that the most significant
...
...
@@ -499,11 +489,11 @@ class HexFloat {
static
const
uint_type
last_significant_bit
=
(
num_throwaway_bits
<
0
)
?
0
:
negatable_left_shift
<
num_throwaway_bits
>::
val
(
1u
);
:
negatable_left_shift
(
num_throwaway_bits
,
1u
);
static
const
uint_type
first_rounded_bit
=
(
num_throwaway_bits
<
1
)
?
0
:
negatable_left_shift
<
num_throwaway_bits
-
1
>::
val
(
1u
);
:
negatable_left_shift
(
num_throwaway_bits
-
1
,
1u
);
static
const
uint_type
throwaway_mask_bits
=
num_throwaway_bits
>
0
?
num_throwaway_bits
:
0
;
...
...
@@ -525,7 +515,7 @@ class HexFloat {
// do.
if
((
significand
&
throwaway_mask
)
==
0
)
{
return
static_cast
<
other_uint_type
>
(
negatable_right_shift
<
num_throwaway_bits
>::
val
(
significand
));
negatable_right_shift
(
num_throwaway_bits
,
significand
));
}
bool
round_away_from_zero
=
false
;
...
...
@@ -562,11 +552,11 @@ class HexFloat {
if
(
round_away_from_zero
)
{
return
static_cast
<
other_uint_type
>
(
negatable_right_shift
<
num_throwaway_bits
>::
val
(
incrementSignificand
(
negatable_right_shift
(
num_throwaway_bits
,
incrementSignificand
(
significand
,
last_significant_bit
,
carry_bit
)));
}
else
{
return
static_cast
<
other_uint_type
>
(
negatable_right_shift
<
num_throwaway_bits
>::
val
(
significand
));
negatable_right_shift
(
num_throwaway_bits
,
significand
));
}
}
...
...
@@ -620,9 +610,9 @@ class HexFloat {
if
(
is_nan
)
{
typename
other_T
::
uint_type
shifted_significand
;
shifted_significand
=
static_cast
<
typename
other_T
::
uint_type
>
(
negatable_left_shift
<
negatable_left_shift
(
static_cast
<
int_type
>
(
other_T
::
num_fraction_bits
)
-
static_cast
<
int_type
>
(
num_fraction_bits
)
>::
val
(
significand
));
static_cast
<
int_type
>
(
num_fraction_bits
)
,
significand
));
// We are some sort of Nan. We try to keep the bit-pattern of the Nan
// as close as possible. If we had to shift off bits so we are 0, then we
...
...
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