forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathilmbase_half.patch
289 lines (235 loc) · 6.61 KB
/
ilmbase_half.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
--- openexr/IlmBase/Half/half.cpp 2019-09-09 23:40:27.186426000 -0700
+++ ilmbase_half.cpp 2019-08-05 18:07:51.371334000 -0700
@@ -45,18 +45,27 @@
//---------------------------------------------------------------------------
#include <assert.h>
-#include "half.h"
+
+#include "pxr/pxr.h"
+#include "pxr/base/gf/ilmbase_half.h"
+
+#include <istream>
+#include <ostream>
using namespace std;
+PXR_NAMESPACE_OPEN_SCOPE
+
+namespace pxr_half {
+
//-------------------------------------------------------------
// Lookup tables for half-to-float and float-to-half conversion
//-------------------------------------------------------------
-HALF_EXPORT const half::uif half::_toFloat[1 << 16] =
- #include "toFloat.h"
-HALF_EXPORT const unsigned short half::_eLut[1 << 9] =
- #include "eLut.h"
+GF_API const half::uif half::_toFloat[1 << 16] =
+ #include "pxr/base/gf/ilmbase_toFloat.h"
+GF_API const unsigned short half::_eLut[1 << 9] =
+ #include "pxr/base/gf/ilmbase_eLut.h"
//-----------------------------------------------
// Overflow handler for float-to-half conversion;
@@ -64,7 +73,7 @@
// which may be trapped by the operating system.
//-----------------------------------------------
-HALF_EXPORT float
+GF_API float
half::overflow ()
{
volatile float f = 1e10;
@@ -81,7 +90,7 @@
// zeroes, denormalized numbers and exponent overflows.
//-----------------------------------------------------
-HALF_EXPORT short
+GF_API short
half::convert (int i)
{
//
@@ -221,7 +230,7 @@
// Stream I/O operators
//---------------------
-HALF_EXPORT ostream &
+GF_API ostream &
operator << (ostream &os, half h)
{
os << float (h);
@@ -229,7 +238,7 @@
}
-HALF_EXPORT istream &
+GF_API istream &
operator >> (istream &is, half &h)
{
float f;
@@ -244,7 +253,7 @@
// floats and halfs, mostly for debugging
//---------------------------------------
-HALF_EXPORT void
+GF_API void
printBits (ostream &os, half h)
{
unsigned short b = h.bits();
@@ -259,7 +268,7 @@
}
-HALF_EXPORT void
+GF_API void
printBits (ostream &os, float f)
{
half::uif x;
@@ -275,7 +284,7 @@
}
-HALF_EXPORT void
+GF_API void
printBits (char c[19], half h)
{
unsigned short b = h.bits();
@@ -292,7 +301,7 @@
}
-HALF_EXPORT void
+GF_API void
printBits (char c[35], float f)
{
half::uif x;
@@ -308,3 +317,7 @@
c[34] = 0;
}
+
+} // namespace pxr_half
+
+PXR_NAMESPACE_CLOSE_SCOPE
--- openexr/IlmBase/Half/half.h 2019-09-09 23:42:36.452479000 -0700
+++ ilmbase_half.h 2019-09-09 14:25:22.287651000 -0700
@@ -82,11 +82,17 @@
//
//---------------------------------------------------------------------------
-#ifndef _HALF_H_
-#define _HALF_H_
+#ifndef PXR_HALF_H
+#define PXR_HALF_H
-#include "halfExport.h" // for definition of HALF_EXPORT
-#include <iostream>
+#include "pxr/pxr.h"
+#include "pxr/base/gf/api.h"
+
+#include <iosfwd>
+
+PXR_NAMESPACE_OPEN_SCOPE
+
+namespace pxr_half {
class half
{
@@ -96,9 +102,11 @@
// Constructors
//-------------
- half (); // no initialization
+ half () = default; // no initialization
half (float f);
+ constexpr half (const half& h) = default;
+
//--------------------
// Conversion to float
@@ -118,7 +126,7 @@
// Assignment
//-----------
- half & operator = (half h);
+ half & operator = (const half &) = default;
half & operator = (float f);
half & operator += (half h);
@@ -197,8 +205,8 @@
// Access to the internal representation
//--------------------------------------
- HALF_EXPORT unsigned short bits () const;
- HALF_EXPORT void setBits (unsigned short bits);
+ GF_API unsigned short bits () const;
+ GF_API void setBits (unsigned short bits);
public:
@@ -211,13 +219,13 @@
private:
- HALF_EXPORT static short convert (int i);
- HALF_EXPORT static float overflow ();
+ GF_API static short convert (int i);
+ GF_API static float overflow ();
unsigned short _h;
- HALF_EXPORT static const uif _toFloat[1 << 16];
- HALF_EXPORT static const unsigned short _eLut[1 << 9];
+ GF_API static const uif _toFloat[1 << 16];
+ GF_API static const unsigned short _eLut[1 << 9];
};
@@ -226,18 +234,18 @@
// Stream I/O
//-----------
-HALF_EXPORT std::ostream & operator << (std::ostream &os, half h);
-HALF_EXPORT std::istream & operator >> (std::istream &is, half &h);
+GF_API std::ostream & operator << (std::ostream &os, half h);
+GF_API std::istream & operator >> (std::istream &is, half &h);
//----------
// Debugging
//----------
-HALF_EXPORT void printBits (std::ostream &os, half h);
-HALF_EXPORT void printBits (std::ostream &os, float f);
-HALF_EXPORT void printBits (char c[19], half h);
-HALF_EXPORT void printBits (char c[35], float f);
+GF_API void printBits (std::ostream &os, half h);
+GF_API void printBits (std::ostream &os, float f);
+GF_API void printBits (char c[19], half h);
+GF_API void printBits (char c[35], float f);
//-------------------------------------------------------------------------
@@ -414,17 +422,6 @@
//---------------------------------------------------------------------------
-//--------------------
-// Simple constructors
-//--------------------
-
-inline
-half::half ()
-{
- // no initialization
-}
-
-
//----------------------------
// Half-from-float constructor
//----------------------------
@@ -573,14 +570,6 @@
inline half &
-half::operator = (half h)
-{
- _h = h._h;
- return *this;
-}
-
-
-inline half &
half::operator = (float f)
{
*this = half (f);
@@ -758,4 +747,8 @@
_h = bits;
}
+} // namespace pxr_half
+
+PXR_NAMESPACE_CLOSE_SCOPE
+
#endif
--- openexr/IlmBase/Half/halfLimits.h 2019-09-09 23:40:27.206431000 -0700
+++ ilmbase_halfLimits.h 2019-08-05 18:07:51.394336000 -0700
@@ -38,8 +38,8 @@
// Rod Bogart <[email protected]>
-#ifndef INCLUDED_HALF_LIMITS_H
-#define INCLUDED_HALF_LIMITS_H
+#ifndef PXR_HALF_LIMITS_H
+#define PXR_HALF_LIMITS_H
//------------------------------------------------------------------------
@@ -49,13 +49,16 @@
//------------------------------------------------------------------------
#include <limits>
-#include "half.h"
+#include "pxr/base/gf/ilmbase_half.h"
namespace std {
template <>
-class numeric_limits <half>
+class numeric_limits <PXR_NS::pxr_half::half>
{
+ private:
+ using half = PXR_NS::pxr_half::half;
+
public:
static const bool is_specialized = true;