• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_half_float
4
5Name Strings
6
7    GL_NV_half_float
8
9Contact
10
11    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
12
13Notice
14
15    Copyright NVIDIA Corporation, 2001-2002.
16
17IP Status
18
19    NVIDIA Proprietary.
20
21Status
22
23    Implemented in CineFX (NV30) Emulation driver, August 2002.
24    Shipping in Release 40 NVIDIA driver for CineFX hardware, January 2003.
25
26Version
27
28    Last Modified Date:         02/25/2004
29    NVIDIA Revision:            9
30
31Number
32
33    283
34
35Dependencies
36
37    Written based on the wording of the OpenGL 1.3 specification.
38
39    OpenGL 1.1 is required.
40
41    NV_float_buffer affects the definition of this extension.
42
43    EXT_fog_coord affects the definition of this extension.
44
45    EXT_secondary_color affects the definition of this extension.
46
47    EXT_vertex_weighting affects the definition of this extension.
48
49    NV_vertex_program affects the definition of this extension.
50
51Overview
52
53    This extension introduces a new storage format and data type for
54    half-precision (16-bit) floating-point quantities.  The floating-point
55    format is very similar to the IEEE single-precision floating-point
56    standard, except that it has only 5 exponent bits and 10 mantissa bits.
57    Half-precision floats are smaller than full precision floats and provide a
58    larger dynamic range than similarly-sized normalized scalar data types.
59
60    This extension allows applications to use half-precision floating point
61    data when specifying vertices or pixel data.  It adds new commands to
62    specify vertex attributes using the new data type, and extends the
63    existing vertex array and image specification commands to accept the new
64    data type.
65
66    This storage format is also used to represent 16-bit components in the
67    floating-point frame buffers, as defined in the NV_float_buffer extension.
68
69Issues
70
71    What should the new data type be called?  "half"?  "hfloat"?  In addition,
72    what should the immediate mode function suffix be?  "h"?  "hf"?
73
74        RESOLVED:  half and "h".  This convention builds on the convention of
75        using the type "double" to describe double-precision floating-point
76        numbers.  Here, "half" will refer to half-precision floating-point
77        numbers.
78
79        Even though the 16-bit float data type is a first-class data type, it
80        is still more problematic than the other types in the sense that no
81        native programming languages support the data type.  "hfloat/hf" would
82        have reflected a second-class status better than "half/h".
83
84        Both names are not without conflicting precedents.  The name "half" is
85        used to connote 16-bit scalar values on some 32-bit CPU architectures
86        (e.g., PowerPC).  The name "hfloat" has been used to describe 128-bit
87        floating-point data on VAX systems.
88
89    Should we provide immediate-mode entry points for half-precision
90    floating-point data types?
91
92        RESOLVED:  Yes, for orthogonality.  Also useful as a fallback for the
93        "general" case for ArrayElement.
94
95    Should we support half-precision floating-point color index data?
96
97        RESOLVED:  No.
98
99    Should half-precision data be accepted by all commands that accept pixel
100    data or only a subset?
101
102        RESOLVED:  All functions.  Note that some textures or frame buffers
103        may store the half-precision floating-point data natively.
104
105        Since half float data would be accepted in some cases, it will be
106        necessary for drivers to provide some data conversion code.  This code
107        can be reused to handle the less common commands.
108
109
110New Procedures and Functions
111
112    void Vertex2hNV(half x, half y);
113    void Vertex2hvNV(const half *v);
114    void Vertex3hNV(half x, half y, half z);
115    void Vertex3hvNV(const half *v);
116    void Vertex4hNV(half x, half y, half z, half w);
117    void Vertex4hvNV(const half *v);
118    void Normal3hNV(half nx, half ny, half nz);
119    void Normal3hvNV(const half *v);
120    void Color3hNV(half red, half green, half blue);
121    void Color3hvNV(const half *v);
122    void Color4hNV(half red, half green, half blue, half alpha);
123    void Color4hvNV(const half *v);
124    void TexCoord1hNV(half s);
125    void TexCoord1hvNV(const half *v);
126    void TexCoord2hNV(half s, half t);
127    void TexCoord2hvNV(const half *v);
128    void TexCoord3hNV(half s, half t, half r);
129    void TexCoord3hvNV(const half *v);
130    void TexCoord4hNV(half s, half t, half r, half q);
131    void TexCoord4hvNV(const half *v);
132    void MultiTexCoord1hNV(enum target, half s);
133    void MultiTexCoord1hvNV(enum target, const half *v);
134    void MultiTexCoord2hNV(enum target, half s, half t);
135    void MultiTexCoord2hvNV(enum target, const half *v);
136    void MultiTexCoord3hNV(enum target, half s, half t, half r);
137    void MultiTexCoord3hvNV(enum target, const half *v);
138    void MultiTexCoord4hNV(enum target, half s, half t, half r, half q);
139    void MultiTexCoord4hvNV(enum target, const half *v);
140    void VertexAttrib1hNV(uint index, half x);
141    void VertexAttrib1hvNV(uint index, const half *v);
142    void VertexAttrib2hNV(uint index, half x, half y);
143    void VertexAttrib2hvNV(uint index, const half *v);
144    void VertexAttrib3hNV(uint index, half x, half y, half z);
145    void VertexAttrib3hvNV(uint index, const half *v);
146    void VertexAttrib4hNV(uint index, half x, half y, half z, half w);
147    void VertexAttrib4hvNV(uint index, const half *v);
148    void VertexAttribs1hvNV(uint index, sizei n, const half *v);
149    void VertexAttribs2hvNV(uint index, sizei n, const half *v);
150    void VertexAttribs3hvNV(uint index, sizei n, const half *v);
151    void VertexAttribs4hvNV(uint index, sizei n, const half *v);
152
153    (added if EXT_fog_coord is supported)
154
155    void FogCoordhNV(half fog);
156    void FogCoordhvNV(const half *fog);
157
158    (added if EXT_secondary_color is supported)
159
160    void SecondaryColor3hNV(half red, half green, half blue);
161    void SecondaryColor3hvNV(const half *v);
162
163    (added if EXT_vertex_weighting is supported)
164
165    void VertexWeighthNV(half weight);
166    void VertexWeighthvNV(const half *weight);
167
168New Tokens
169
170    Accepted by the <type> argument of VertexPointer, NormalPointer,
171    ColorPointer, TexCoordPointer, FogCoordPointerEXT,
172    SecondaryColorPointerEXT, VertexWeightPointerEXT, VertexAttribPointerNV,
173    DrawPixels, ReadPixels, TexImage1D, TexImage2D, TexImage3D, TexSubImage1D,
174    TexSubImage2D, TexSubImage3D, and GetTexImage:
175
176        HALF_FLOAT_NV                                   0x140B
177
178Additions to Chapter 2 of the OpenGL 1.3 Specification (OpenGL Operation)
179
180    Modify Section 2.3, GL Command Syntax (p. 7)
181
182    (Modify the last paragraph, p. 7.  In the text below, "e*" represents the
183     epsilon character used to indicate no character.)
184
185    These examples show the ANSI C declarations for these commands. In
186    general, a command declaration has the form
187
188        rtype Name{e*1234}{e* b s i h f d ub us ui}{e*v}
189          ( [args ,] T arg1, ... , T argN [, args]);
190
191    (Modify Table 2.1, p. 8 -- add new row)
192
193        Letter  Corresponding GL Type
194        ------  ---------------------
195           h           half
196
197    (add after last paragraph, p. 8) The half data type is a floating-point
198    data type encoded in an unsigned scalar data type.  If the unsigned scalar
199    holding a half has a value of N, the corresponding floating point number
200    is
201
202        (-1)^S * 0.0,                        if E == 0 and M == 0,
203        (-1)^S * 2^-14 * (M / 2^10),         if E == 0 and M != 0,
204        (-1)^S * 2^(E-15) * (1 + M/2^10),    if 0 < E < 31,
205        (-1)^S * INF,                        if E == 31 and M == 0, or
206        NaN,                                 if E == 31 and M != 0,
207
208    where
209
210        S = floor((N mod 65536) / 32768),
211        E = floor((N mod 32768) / 1024), and
212        M = N mod 1024.
213
214    INF (Infinity) is a special representation indicating numerical overflow.
215    NaN (Not a Number) is a special representation indicating the result of
216    illegal arithmetic operations, such as computing the square root or
217    logarithm of a negative number.  Note that all normal values, zero, and
218    INF have an associated sign.  -0.0 and +0.0 are considered equivalent for
219    the purposes of comparisons.  Note also that half is not a native type in
220    most CPUs, so some special processing may be required to generate or
221    interpret half data.
222
223    (Modify Table 2.2, p. 9 -- add new row)
224
225                    Minimum
226        GL Type    Bit Width    Description
227        -------    ---------    -----------------------------------
228        half          16        half-precision floating-point value
229                                encoded in an unsigned scalar
230
231    Modify Section 2.7, Vertex Specification, p. 19
232
233    (Modify the descriptions of the immediate mode functions in this section,
234     including those introduced by extensions.)
235
236        void Vertex[234][sihfd]( T coords );
237        void Vertex[234][sihfd]v( T coords );
238    ...
239        void TexCoord[1234][sihfd]( T coords );
240        void TexCoord[1234][sihfd]v( T coords );
241    ...
242        void MultiTexCoord[1234][sihfd](enum texture, T coords);
243        void MultiTexCoord[1234][sihfd]v(enum texture, T coords);
244    ...
245        void Normal3[bsihfd][ T coords );
246        void Normal3[bsihfd]v( T coords );
247    ...
248        void Color[34][bsihfd ubusui]( T components );
249        void Color[34][bsihfd ubusui]v( T components );
250    ...
251        void FogCoord[fd]EXT(T fog);
252        void FogCoordhNV(T fog);
253        void FogCoord[fd]vEXT(T fog);
254        void FogCoordhvNV(T fog);
255    ...
256        void SecondaryColor3[bsihfd ubusui]( T components );
257        void SecondaryColor3hNV( T components );
258        void SecondaryColor3[bsihfd ubusui]v( T components );
259        void SecondaryColor3hvNV( T components );
260    ...
261        void VertexWeightfEXT(T weight);
262        void VertexWeighthNV(T weight);
263        void VertexWeightfvEXT(T weight);
264        void VertexWeighthvNV(T weight);
265    ...
266        void VertexAttrib[1234][shfd]NV(uint index, T components);
267        void VertexAttrib4ubNV(uint index, T components);
268        void VertexAttrib[1234][shfd]vNV(uint index, T components);
269        void VertexAttrib4ubvNV(uint index, T components);
270        void VertexAttribs[1234][shfd]vNV(uint index, sizei n, T components);
271        void VertexAttribs4ubvNV(uint index, sizei n, T components);
272    ....
273
274    Modify Section 2.8, Vertex Arrays, p. 21
275
276    (Modify 1st paragraph on p. 22) ... For <type>, the values BYTE, SHORT,
277    INT, FLOAT, HALF_FLOAT_NV, and DOUBLE indicate types byte, short, int,
278    float, half, and double, respectively. ...
279
280    (Modify Table 2.4, p. 23)
281
282        Command                   Sizes      Types
283        ------------------        -------    ---------------------------------
284        VertexPointer             2,3,4      short, int, float, half, double
285        NormalPointer             3          byte, short, int, float, half,
286                                             double
287        ColorPointer              3,4        byte, ubyte, short, ushort, int,
288                                             uint, float, half, double
289        IndexPointer              1          ubyte, short, int, float, double
290        TexCoordPointer           1,2,3,4    short, int, float, half, double
291        EdgeFlagPointer           1          boolean
292        FogCoordPointerEXT        1          float, half, double
293        SecondaryColorPointerEXT  3          byte, ubyte, short, ushort, int,
294                                             uint, float, half, double
295        VertexWeightPointerEXT    1          float, half
296
297        Table 2.4: Vertex array sizes (values per vertex) and data types.
298
299    Modify Section 2.13, Colors and Coloring, p.44
300
301    (Modify Table 2.6, p. 45)  Add new row to the table:
302
303         GL Type    Conversion
304         -------    ----------
305         half          c
306
307    Modify NV_vertex_program_spec, Section 2.14.3, Vertex Arrays for Vertex
308    Attributes.
309
310    (modify paragraph describing VertexAttribPointer) ... type specifies the
311    data type of the values stored in the array.  type must be one of SHORT,
312    FLOAT, HALF_FLOAT_NV, DOUBLE, or UNSIGNED_BYTE and these values correspond
313    to the array types short, int, float, half, double, and ubyte
314    respectively. ...
315
316    (add to end of paragraph describing mapping of vertex arrays to
317    immediate-mode functions) ... For each vertex attribute, the corresponding
318    command is VertexAttrib[size][type]v, where size is one of [1,2,3,4], and
319    type is one of [s,f,h,d,ub], corresponding to the array types short, int,
320    float, half, double, and ubyte respectively.
321
322
323Additions to Chapter 3 of the OpenGL 1.3 Specification (Rasterization)
324
325    Modify Section 3.6.4, Rasterization of Pixel Rectangles (p. 91)
326
327    (Modify Table 3.5, p. 94 -- add new row)
328
329        type Parameter     Corresponding       Special
330        Token Name         GL Data Type     Interpretation
331        --------------     -------------    --------------
332        HALF_FLOAT_NV         half               No
333
334Additions to Chapter 4 of the OpenGL 1.3 Specification (Per-Fragment
335Operations and the Frame Buffer)
336
337    Modify Section 4.3.2, Reading Pixels (p. 173)
338
339    (modify Final Conversion, p. 177) For an index, if the type is not FLOAT
340    or HALF_FLOAT_NV, final conversion consists of masking the index with the
341    value given in Table 4.6; if the type is FLOAT or HALF_FLOAT_NV, then the
342    integer index is converted to a GL float or half data value.  For an RGBA
343    color, components are clamped depending on the data type of the buffer
344    being read.  For fixed-point buffers, each component is clamped to [0.1].
345    For floating-point buffers, if <type> is not FLOAT or HALF_FLOAT_NV, each
346    component is clamped to [0,1] if <type> is unsigned or [-1,1] if <type> is
347    signed and then converted according to Table 4.7.
348
349    (Modify Table 4.7, p. 178 -- add new row)
350
351        type Parameter    GL Data Type    Component Conversion Formula
352        --------------    ------------    ----------------------------
353        HALF_FLOAT_NV        half                  c = f
354
355Additions to Chapter 5 of the OpenGL 1.3 Specification (Special Functions)
356
357    None.
358
359Additions to Chapter 6 of the OpenGL 1.3 Specification (State and
360State Requests)
361
362    None.
363
364Additions to Appendix A of the OpenGL 1.3 Specification (Invariance)
365
366    None.
367
368Additions to the AGL/GLX/WGL Specifications
369
370    None.
371
372GLX Protocol (Modification to the GLX 1.3 Protocol Encoding Specification)
373
374    Add to Section 1.4 (p.2), Common Types
375
376        FLOAT16     A 16-bit floating-point value in the format specified
377                    in the NV_half_float extension specification.
378
379    Modify Section 2.3.3 (p. 79), GL Rendering Commands
380
381      The following rendering commands are sent to the server as part of a
382      glXRender request:
383
384         Vertex2hvNV
385            2           8               rendering command length
386            2           4240            rendering command opcode
387            2           FLOAT16         v[0]
388            2           FLOAT16         v[1]
389
390         Vertex3hvNV
391            2           12              rendering command length
392            2           4241            rendering command opcode
393            2           FLOAT16         v[0]
394            2           FLOAT16         v[1]
395            2           FLOAT16         v[2]
396            2                           unused
397
398         Vertex4hvNV
399            2           12              rendering command length
400            2           4242            rendering command opcode
401            2           FLOAT16         v[0]
402            2           FLOAT16         v[1]
403            2           FLOAT16         v[2]
404            2           FLOAT16         v[3]
405
406         Normal3hvNV
407            2           12              rendering command length
408            2           4243            rendering command opcode
409            2           FLOAT16         v[0]
410            2           FLOAT16         v[1]
411            2           FLOAT16         v[2]
412            2                           unused
413
414         Color3hvNV
415            2           12              rendering command length
416            2           4244            rendering command opcode
417            2           FLOAT16         v[0]
418            2           FLOAT16         v[1]
419            2           FLOAT16         v[2]
420            2                           unused
421
422         Color4hvNV
423            2           12              rendering command length
424            2           4245            rendering command opcode
425            2           FLOAT16         v[0]
426            2           FLOAT16         v[1]
427            2           FLOAT16         v[2]
428            2           FLOAT16         v[3]
429
430         TexCoord1hvNV
431            2           8               rendering command length
432            2           4246            rendering command opcode
433            2           FLOAT16         v[0]
434            2                           unused
435
436         TexCoord2hvNV
437            2           8               rendering command length
438            2           4247            rendering command opcode
439            2           FLOAT16         v[0]
440            2           FLOAT16         v[1]
441
442         TexCoord3hvNV
443            2           12              rendering command length
444            2           4248            rendering command opcode
445            2           FLOAT16         v[0]
446            2           FLOAT16         v[1]
447            2           FLOAT16         v[2]
448            2                           unused
449
450         TexCoord4hvNV
451            2           12              rendering command length
452            2           4249            rendering command opcode
453            2           FLOAT16         v[0]
454            2           FLOAT16         v[1]
455            2           FLOAT16         v[2]
456            2           FLOAT16         v[3]
457
458         MultiTexCoord1hvNV
459            2           12              rendering command length
460            2           4250            rendering command opcode
461            4           ENUM            target
462            2           FLOAT16         v[0]
463            2                           unused
464
465         MultiTexCoord2hvNV
466            2           12              rendering command length
467            2           4251            rendering command opcode
468            4           ENUM            target
469            2           FLOAT16         v[0]
470            2           FLOAT16         v[1]
471
472         MultiTexCoord3hvNV
473            2           16              rendering command length
474            2           4252            rendering command opcode
475            4           ENUM            target
476            2           FLOAT16         v[0]
477            2           FLOAT16         v[1]
478            2           FLOAT16         v[2]
479            2                           unused
480
481         MultiTexCoord4hvNV
482            2           16              rendering command length
483            2           4253            rendering command opcode
484            4           ENUM            target
485            2           FLOAT16         v[0]
486            2           FLOAT16         v[1]
487            2           FLOAT16         v[2]
488            2           FLOAT16         v[3]
489
490         FogCoordhvNV
491            2           8               rendering command length
492            2           4254            rendering command opcode
493            2           FLOAT16         v[0]
494            2                           unused
495
496         SecondaryColor3hvNV
497            2           12              rendering command length
498            2           4255            rendering command opcode
499            2           FLOAT16         v[0]
500            2           FLOAT16         v[1]
501            2           FLOAT16         v[2]
502            2                           unused
503
504         VertexWeighthvNV
505            2           8               rendering command length
506            2           4256            rendering command opcode
507            2           FLOAT16         v[0]
508            2                           unused
509
510         VertexAttrib1hvNV
511            2           12              rendering command length
512            2           4257            rendering command opcode
513            4           CARD32          index
514            2           FLOAT16         v[0]
515            2                           unused
516
517         VertexAttrib2hvNV
518            2           12              rendering command length
519            2           4258            rendering command opcode
520            4           CARD32          index
521            2           FLOAT16         v[0]
522            2           FLOAT16         v[1]
523
524         VertexAttrib3hvNV
525            2           16              rendering command length
526            2           4259            rendering command opcode
527            4           CARD32          index
528            2           FLOAT16         v[0]
529            2           FLOAT16         v[1]
530            2           FLOAT16         v[2]
531            2                           unused
532
533         VertexAttrib4hvNV
534            2           16              rendering command length
535            2           4260            rendering command opcode
536            4           CARD32          index
537            2           FLOAT16         v[0]
538            2           FLOAT16         v[1]
539            2           FLOAT16         v[2]
540            2           FLOAT16         v[3]
541
542         VertexAttribs1hvNV
543            2           12+2*n+p        rendering command length
544            2           4261            rendering command opcode
545            4           CARD32          index
546            4           CARD32          n
547            2*n         LISTofFLOAT16   v
548            p                           unused, p=pad(2*n)
549
550         VertexAttribs2hvNV
551            2           12+4*n          rendering command length
552            2           4262            rendering command opcode
553            4           CARD32          index
554            4           CARD32          n
555            4*n         LISTofFLOAT16   v
556
557         VertexAttribs3hvNV
558            2           12+6*n+p        rendering command length
559            2           4263            rendering command opcode
560            4           CARD32          index
561            4           CARD32          n
562            6*n         LISTofFLOAT16   v
563            p                           unused, p=pad(6*n)
564
565         VertexAttribs4hvNV
566            2           12+8*n          rendering command length
567            2           4264            rendering command opcode
568            4           CARD32          index
569            4           CARD32          n
570            8*n         LISTofFLOAT16   v
571
572
573    Modify Section 2.3.4, GL Rendering Commands That May Be Large (p. 127)
574
575     (Modify the ARRAY_INFO portion of the DrawArrays encoding (p.129) to
576      reflect the new data type supported by vertex arrays.)
577
578         ARRAY_INFO
579
580            4       enum                    data type
581                    0x1400   i=1            BYTE
582                    0x1401   i=1            UNSIGNED_BYTE
583                    0x1402   i=2            SHORT
584                    ...
585                    0x140B   i=2            HALF_FLOAT_NV
586            4       INT32                   j
587            4       ENUM                    array type
588                ...
589
590    Modify Appendix A, Pixel Data (p. 148)
591
592      (Modify Table A.1, p. 149 -- add new row for HALF_FLOAT_NV data)
593
594          type             Encoding    Protocol Type    nbytes
595          -------------    --------    -------------    ------
596          HALF_FLOAT_NV    0x140B      CARD16           2
597
598
599Dependencies on NV_float_buffer
600
601    If NV_float_buffer is not supported, the fixed and floating-point color
602    buffer language in ReadPixels "Final Conversion" should be removed.
603
604
605Dependencies on EXT_fog_coord, EXT_secondary_color, and EXT_vertex_weighting
606
607    If EXT_fog_coord, EXT_secondary_color, or EXT_vertex_weighting are not
608    supported, references to FogCoordPointerEXT, SecondaryColorPointerEXT, and
609    VertexWeightPointerEXT, respectively, should be removed.
610
611    If EXT_fog_coord is not supported, remove language adding immediate mode
612    FogCoordh[v]NV APIs.
613
614    If EXT_secondary_color is not supported, remove language adding immediate
615    mode SecondaryColor3h[v]NV APIs.
616
617    If EXT_vertex_weighting is not supported, remove language adding immediate
618    mode VertexWeighth[v]NV APIs.
619
620Dependencies on NV_vertex_program
621
622    If NV_vertex_program is not supported, references to VertexAttribPointerNV
623    should be removed, as should references to VertexAttrib*h[v] commands.
624
625
626Errors
627
628    None.
629
630
631New State
632
633    None.
634
635
636New Implementation Dependent State
637
638    None.
639
640
641Revision History
642
643    Rev.    Date    Author   Changes
644    ----  -------- --------  --------------------------------------------
645     10   03/21/10  pbrown   Clarify that FogCoord*, SecondaryColor*, and
646                             VertexWeight* APIs are supported only if
647                             corresponding extensions are also supported.
648                             Recent NVIDIA drivers and GPUs do not support
649                             EXT_vertex_weighting.
650
651      9   02/25/04  pbrown   Fixed incorrect language using division by zero
652                             as an example of something producing a NaN.
653
654      8   07/19/02  pbrown   Add GLX protocol.  Modified enumerant value for
655                             HALF_FLOAT_NV to use new value assigned from the
656                             registry.
657
658      7   01/31/02  pbrown   Add revision history.
659
660      6   12/26/01  pbrown   Add immediate-mode entry points for all functions
661                             that may accept half-precision float vertex data.
662
663      4   10/19/01  pbrown   Fixed incorrect description of encoding of hfloat
664                             denorms.  Addressed issue that there's no reason
665                             to require hfloats to be exactly 16 bits on all
666                             architectures.  Instead, they are documented as
667                             needing to be at least 16 bits, and as using only
668                             the 16 least significant bits.  Practically
669                             speaking, they will probably always be 16 bits.
670