Summary: | [WEBGL] Implement OES_texture_half_float in WebKit | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Nayan Kumar K <nayankk> | ||||
Component: | WebGL | Assignee: | Nayan Kumar K <nayankk> | ||||
Status: | RESOLVED DUPLICATE | ||||||
Severity: | Normal | CC: | bajones, bfulgham, dino, gman, kbr, zmo | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Bug Depends on: | 110818, 110936, 111194 | ||||||
Bug Blocks: | 111196, 111197 | ||||||
Attachments: |
|
Description
Nayan Kumar K
2013-02-14 12:35:38 PST
Created attachment 188407 [details]
An attemp to implement OES_texture_half_float
PFA a WIP patch to implement OES_texture_half_float. Code closely follows the implementation of OES_texture_float. However, I still do not see the expected results. Am I missing something? Please help. BTW, OES_texture_half_float expects the texture data in 16-bit floating point representation. However, the only floating point TypedArray representation is Float32Array. Shouldn't we need something like Float16Array to support OES_texture_half_float? Thanks, (In reply to comment #2) > PFA a WIP patch to implement OES_texture_half_float. Code closely follows the implementation of OES_texture_float. However, I still do not see the expected results. Am I missing something? Please help. > > BTW, OES_texture_half_float expects the texture data in 16-bit floating point representation. However, the only floating point TypedArray representation is Float32Array. Shouldn't we need something like Float16Array to support OES_texture_half_float? The working group discussed this and decided not to add such a type. No CPU supports 16-bit floating point values efficiently, so the performance of Float16Array would be very poor. For this reason, the WebGL extension OES_texture_half_float does not support uploading data from typed arrays, only HTML elements. I'll comment on the patch separately. Comment on attachment 188407 [details] An attemp to implement OES_texture_half_float View in context: https://bugs.webkit.org/attachment.cgi?id=188407&action=review > Source/WebCore/html/canvas/WebGLRenderingContext.cpp:5125 > + case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float This is incorrect; per the spec, only NULL is allowed when calling the overload taking ArrayBufferView with HALF_FLOAT_OES type. > Source/WebCore/platform/graphics/GraphicsContext3D.cpp:646 > +template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR16F, float, float>(const float* source, float* destination, unsigned pixelsPerRow) All of these conversions are incorrect. You need to define a GC3DhalfFloat typedef (probably to short) and add routines which create half-floats. Because the WebGL OES_texture_half_float extension doesn't support typed arrays being passed in, you don't need the unpacking routines; you'll never see one of the half-float formats used as a source, only a destination. However, you need to support all of the formats of HTML elements. I think this amounts to just doing unsigned byte to half-float conversion but am not sure. For references see http://en.wikipedia.org/wiki/Half-precision_floating-point_format ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf I think the conversion you need (uint8 to half float) is essentially just an unsigned cast because the low 8 bits of the half-float are the mantissa and you won't have an exponent. Again, I'm not 100% sure. > LayoutTests/fast/canvas/webgl/oes-texture-half-float.html:5 > +<title>WebGL OES_texture_float Conformance Tests</title> You'll need to modify this test more extensively for half-float. In particular, you can only upload HTML elements, not typed arrays. You still should test that rendering to a half-float texture, when supported, preserves the extended range.
> The working group discussed this and decided not to add such a type. No CPU supports 16-bit floating point values efficiently, so the performance of Float16Array would be very poor. For this reason, the WebGL extension OES_texture_half_float does not support uploading data from typed arrays, only HTML elements.
>
> I'll comment on the patch separately.
Thanks for the pointers. I will modify the patch accordingly and resubmit.
I think this support is now landed in WebKit. We can probably close this patch out. *** This bug has been marked as a duplicate of bug 124871 *** |