OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
2 "http://www.w3.org/TR/html4/strict.dtd"> | |
3 <html lang="en"> | |
4 <head> | |
5 <meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
6 <title>WebGL WEBGL_compress_texture Extension Draft Specification</title> | |
7 <link rel="stylesheet" type="text/css" href="../../resources/webgl-exten
sion.css" /> | |
8 <link rel="stylesheet" type="text/css" href="../../resources/default.css" /> | |
9 <script src="../../resources/jquery-1.3.2.min.js" type="text/javascript"></s
cript> | |
10 </head> | |
11 <!--begin-logo--> | |
12 <div> | |
13 <a href="http://webgl.org/"><img alt=WebGL height=72 src="../../resources/
WebGL-Logo.png" width=156></a> | |
14 <div class=right> | |
15 <a href="http://khronos.org/"><img alt=Khronos height=60 src="../../resources/
KhronosGroup-3D.png" width=220></a> | |
16 </div> | |
17 </div> | |
18 <!--end-logo--> | |
19 | |
20 <h1>WebGL WEBGL_compress_texture Extension Draft Specification</h1> | |
21 | |
22 <h2 class="no-toc">Name</h2> | |
23 <p> WEBGL_compress_texture </p> | |
24 | |
25 <h2 class="no-toc">Contact</h2> | |
26 <p> <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL worki
ng group</a> (public_webgl 'at' khronos.org) </p> | |
27 | |
28 <h2 class="no-toc">Contributors</h2> | |
29 <p> Members of the WebGL working group </p> | |
30 | |
31 <h2 class="no-toc">Version</h2> | |
32 <p> Last modified date: April 5, 2011 | |
33 </p> | |
34 | |
35 <h2 class="no-toc">Number</h2> | |
36 <p> WebGL extension #6 </p> | |
37 | |
38 <h2 class="no-toc">Dependencies</h2> | |
39 <p> Written against the WebGL API 1.0 specification. </p> | |
40 | |
41 <h2 class="no-toc">Overview</h2> | |
42 <p> | |
43 This extension exposes compressed texture functionality to WebGL. | |
44 </p> | |
45 <p> | |
46 In WebGL we can not expose compressed texture formats directly to authors
because web content | |
47 is supposed to work everywhere. This proposal leaves the compression forma
ts up to the WebGL | |
48 implementation in an opaque way. The user provides hints to the implemenat
ion on what kind of compression | |
49 is appropriate and it is up to the WebGL implemenation to decide on a comp
ression format | |
50 or possibly no compression at all. | |
51 </p> | |
52 <p> | |
53 Because compression can be a slow the process of compression is handled as
ynchronously. The | |
54 user provides that data as an image, video, canvas or ArrayBufferView. The
implementation then | |
55 compressed the image and returns a WebGLCompressedTexture object. That obj
ect can then be | |
56 passed to the standard compressedTexImage2D function although with unneede
d argements removed. | |
57 </p> | |
58 <h2 class="no-toc">IDL</h2> | |
59 <p> | |
60 <pre class="idl"> | |
61 module webgl { | |
62 | |
63 interface WebGLCompressedTexture : WebGLObject { | |
64 readonly attribute long size; | |
65 readonly attribute GLenum error; | |
66 }; | |
67 | |
68 interface WEBGL_compress_texture { | |
69 const GLenum PRESERVE_ALPHA = 0x0001; | |
70 const GLenum PRESERVE_TRANSPARENCY = 0x0002; | |
71 const GLenum PRESERVE_RGB = 0x0004; | |
72 | |
73 compressTexture(GLenum usage, GLsizei width, GLsizei height, GLenum format,
GLenum type, | |
74 ArrayBufferView pixels, Function callback); | |
75 compressTexture(GLenum usage, ImageData pixels, Function callback); | |
76 compressTexture(GLenum usage, HTMLImageElement image, Function callback); | |
77 compressTexture(GLenum usage, HTMLCanvasElement canvas, Function callback); | |
78 compressTexture(GLenum usage, HTMLVideoElement video, Function callback); | |
79 | |
80 compressedTexImage2D(GLenum target, GLint level, GLint border, WebGLCompress
edTexture pixels); | |
81 }; | |
82 | |
83 }; | |
84 </pre> | |
85 <h2 class="no-toc">Description</h2> | |
86 <p> | |
87 All forms are asynchronous. When compression is finished the <code>callback<
/code> | |
88 is called and passed a <code>WebGLCompressedTexture</code> | |
89 object which can then be used with <code>compressedTexImage2D</code>. | |
90 </p> | |
91 <p> | |
92 <code>compressTexture</code> takes 5 forms. The first form takes an <code>Ar
rayBufferView</code>. | |
93 The <code>width</code>, <code>height</code>, <code>format</code>, and <code>
type</code> | |
94 arguments have the same meaning as they do in <code>texImage2D</code>. They
describe the format | |
95 of the pixels in the <code>ArrayBufferView</code>. | |
96 </p> | |
97 <p> | |
98 The other 4 forms of <code>compressTexture</code> take an <code>ImageData</c
ode>, | |
99 <code>HTMLImageElement</code>, <code>HTMLCanvasElement</code>, or an <code>H
TMLVideoElement</code> | |
100 repsectively. As such they derive width, height, type and format from the el
ement. | |
101 </p> | |
102 <p> | |
103 <code>usage</code> is a kind of hint to the implementation to help it choose
a | |
104 compression format. <code>usage</code> is some logical OR of the following b
its | |
105 </p> | |
106 <dl> | |
107 <dt><code>PRESERVE_ALPHA</code></dt> | |
108 <dd>The compression format chosen must support alpha more than 1 bit of alph
a. | |
109 </dd> | |
110 <dt><code>PRESERVE_TRANSPARENCY</code></dt> | |
111 <dd>The compression format chosen must have at least 1 bit of alpha | |
112 </dd> | |
113 <dt><code>PRESERVE_RGB</code></dt> | |
114 <dd>The compression format chosen must not be lossy to a specific | |
115 color. In other words, it can not weight R less than G because | |
116 the intended use of the texture is not for color. | |
117 </dd> | |
118 </dl> | |
119 <p> | |
120 The implementation must choose a compression format that respects the <code>
usage</code> argument. | |
121 If no such compression format is available the implementation must choose an
uncompressed format. | |
122 </p> | |
123 <p class="issue"> | |
124 Should the spec define what is acceptable compression? For example PRESERVE_
TRANSPARENCY basically means use DXT1 where as | |
125 PRESERVE_ALPHA means use DXT5 on systems that support those formats. On syst
ems with no compression | |
126 using 5_6_5 or 5_5_5_1 is also fine assuming PRESERVE_ALPHA is not requested
. | |
127 Is 5_6_5 okay for PRESERVE_RGB? Is 4_4_4_4 ok for PRESERVE_ALPHA? | |
128 </p> | |
129 <p>The <code>callback</code> is always called and passed a <code>WebGLCompre
ssedTexture</code> object. If there was an error | |
130 the <code>error</code> attribute will be set to standard GL error value. Oth
erwise it is set to <code>NO_ERROR</code>. | |
131 </p> | |
132 <p><code>size</code> is the number of bytes used by the compressed texture.
It will be 0 | |
133 if there was an error. | |
134 </p> | |
135 <p>Passing a <code>WebGLCompressedTexture</code> who's <code>error</code> at
tribute is not <code>NO_ERROR</code> to <code>compressTexImage2D</code> generate
s | |
136 <code>INVALID_OPERATION</code>.</p> | |
137 <h2 class="no-toc">Errors</h2> | |
138 <p> | |
139 Errors are returned on the WebGLCompressedTexture object's <code>error</code
> attribute. | |
140 </p> | |
141 <p> | |
142 <code>error</code> is set to <code>INVALID_VALUE</code> if | |
143 <code>width</code> or <code>height</code> would generate an <code>INVALID_VA
LUE</code> when calling | |
144 texImage2D. | |
145 </p> | |
146 <p> | |
147 <code>error</code> is set to <code>INVALID_ENUM</code> if type or format is
not one of the types | |
148 or formats excepted by texImage2D. | |
149 </p> | |
150 <p> | |
151 <code>error</code> is set to <code>INVALID_OPERATION</code> if the size of t
he <code>ArrayBufferView</code> is | |
152 not greater than or equal to the size of the data described by width, height
, format and type. | |
153 </p> | |
154 <h2 class="no-toc">Notes</h2> | |
155 <p> | |
156 compressedTexSubImage2D is not implemented. | |
157 </p> | |
158 <p> | |
159 <code>texSubImage2D</code> and <code>copyTexSubImage2D</code> must both fa
il on textures created with <code>compressedTexImage2D</code>. | |
160 For consistency this is true even if the implementation did not actually c
ompress the texture. | |
161 </p> | |
162 <p> | |
163 Rendering to a framebuffer object with an attached texture created by <cod
e>compressedTexImage2D</code> must fail | |
164 with <code>INVALID_FRAMEBUFFER_OPERATION</code> even if the implemenation
did not actually compress the texture. | |
165 </p> | |
166 <p> | |
167 <code>compressTexture</code> must succeed for all valid dimensions defined
by <code>gl.getParameter(gl.MAX_TEXTURE_SIZE).</code> | |
168 That means for example a 7x5 texture passed to compressTexture on a system
who's texture compression | |
169 format requires textures that are a multiple of 4 or 8 in each dimension w
ould choose not to compress | |
170 a 7x5 texture but instead provide it uncompressed or in some other format
that can handle a 7x5 texture. | |
171 </p> | |
172 <p> | |
173 If both <code>PRESERVE_ALPHA</code> and <code>PRESERVE_TRANSPARENCY</code> a
re specified | |
174 <code>PRESERVE_ALPHA</code> takes precedence. In other words the implementio
n must choose | |
175 a compression format with more than 1 bit of alpha. | |
176 </p> | |
177 <h2 class="no-toc">Unresolved issues</h2> | |
178 <h2 class="no-toc">Revision History</h2> | |
179 <p> | |
180 <ul> | |
181 <li> 2011/04/04 Initial draft.</li> | |
182 <li> 2011/04/05 Fixed typos. Changed error mechanism. Added size.</li> | |
183 </ul> | |
184 </p> | |
185 </body> | |
186 </html> | |
OLD | NEW |