2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL Information
</title>
12 <style type=
"text/css">
21 <script src=
"../js/webgl-test-utils.js"> </script>
26 function createCell(txt
, isTh
) {
27 var str
= txt
.toString();
28 if (typeof txt
!= 'string') {
29 if (txt
.length
!== undefined) {
31 for (var ii
= 0; ii
< txt
.length
; ++ii
) {
32 str
+= (ii
== 0 ? "" : ", ") + txt
[ii
];
36 var t
= document
.createTextNode(str
);
37 var d
= document
.createElement("div");
40 td
= document
.createElement("th");
42 td
= document
.createElement("td");
49 function createRow(values
) {
50 var tr
= document
.createElement("tr");
51 for (var i
= 0; i
< values
.length
; ++i
) {
52 var td
= createCell(values
[i
], i
== 0);
59 var wtu
= WebGLTestUtils
;
61 var canvas
= document
.getElementById("example");
62 var gl
= wtu
.create3DContext(canvas
);
67 var debugRendererInfoRows = function() {
69 var debugExt
= wtu
.getExtensionWithKnownPrefixes(gl
, 'WEBGL_debug_renderer_info');
72 'UNMASKED_VENDOR_WEBGL',
73 'UNMASKED_RENDERER_WEBGL'
75 for (var ii
= 0; ii
< extPnames
.length
; ++ii
) {
76 var pname
= extPnames
[ii
];
77 var value
= gl
.getParameter(debugExt
[pname
]);
78 rows
.push([pname
, value
]);
84 var precisionRows = function() {
87 var addPrecisionRow = function(shaderType
, precision
) {
88 var typeStr
= shaderType
=== gl
.FRAGMENT_SHADER
? 'fragment' : 'vertex';
89 var precisionStr
= 'highp';
90 if (precision
== gl
.MEDIUM_FLOAT
) {
91 precisionStr
= 'mediump';
92 } else if (precision
== gl
.LOW_FLOAT
) {
93 precisionStr
= 'lowp';
95 rows
.push([typeStr
+ ' shader ' + precisionStr
+ ' float', gl
.getShaderPrecisionFormat(shaderType
, precision
).precision
+ ' mantissa bits']);
98 var fSource
= 'precision highp float; uniform float r; void main() { gl_FragColor = vec4(r, 0.0, 0.0, 1.0); }'
99 var f
= wtu
.loadShader(gl
, fSource
, gl
.FRAGMENT_SHADER
);
101 rows
.push(['fragment shader highp float', 'not supported']);
103 addPrecisionRow(gl
.FRAGMENT_SHADER
, gl
.HIGH_FLOAT
);
105 addPrecisionRow(gl
.FRAGMENT_SHADER
, gl
.MEDIUM_FLOAT
);
106 addPrecisionRow(gl
.FRAGMENT_SHADER
, gl
.LOW_FLOAT
);
107 addPrecisionRow(gl
.VERTEX_SHADER
, gl
.HIGH_FLOAT
);
108 addPrecisionRow(gl
.VERTEX_SHADER
, gl
.MEDIUM_FLOAT
);
109 addPrecisionRow(gl
.VERTEX_SHADER
, gl
.LOW_FLOAT
);
113 var renderTargetRows = function() {
115 var oesTextureFloat
= wtu
.getExtensionWithKnownPrefixes(gl
, 'OES_texture_float');
116 var oesTextureHalfFloat
= wtu
.getExtensionWithKnownPrefixes(gl
, 'OES_texture_half_float');
117 var formatsToTest
= [
119 description
: 'RGBA UNSIGNED_BYTE',
121 type
: gl
.UNSIGNED_BYTE
124 description
: 'RGB UNSIGNED_BYTE',
126 type
: gl
.UNSIGNED_BYTE
129 if (oesTextureFloat
) {
131 description
: 'RGBA FLOAT',
136 description
: 'RGB FLOAT (deprecated)',
141 if (oesTextureHalfFloat
) {
143 description
: 'RGBA HALF_FLOAT_OES',
145 type
: oesTextureHalfFloat
.HALF_FLOAT_OES
148 description
: 'RGB HALF_FLOAT_OES',
150 type
: oesTextureHalfFloat
.HALF_FLOAT_OES
153 for (var ii
= 0; ii
< formatsToTest
.length
; ++ii
) {
154 var fb
= gl
.createFramebuffer();
155 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
156 var format
= formatsToTest
[ii
];
157 var tex
= gl
.createTexture();
158 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
159 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MIN_FILTER
, gl
.NEAREST
);
160 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_MAG_FILTER
, gl
.NEAREST
);
161 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_S
, gl
.CLAMP_TO_EDGE
);
162 gl
.texParameteri(gl
.TEXTURE_2D
, gl
.TEXTURE_WRAP_T
, gl
.CLAMP_TO_EDGE
);
163 gl
.texImage2D(gl
.TEXTURE_2D
, 0, format
.format
, 256, 256, 0, format
.format
, format
.type
, null);
164 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
165 if (gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
) == gl
.FRAMEBUFFER_COMPLETE
) {
166 rows
.push([format
.description
, 'supported']);
168 rows
.push([format
.description
, 'not supported']);
170 gl
.deleteFramebuffer(fb
);
171 gl
.deleteTexture(tex
);
184 genRows
: debugRendererInfoRows
187 title
: 'Textures and Viewport',
190 'MAX_CUBE_MAP_TEXTURE_SIZE',
191 'MAX_RENDERBUFFER_SIZE',
196 title
: 'Shader Variables',
198 'MAX_VARYING_VECTORS',
199 'MAX_VERTEX_ATTRIBS',
200 'MAX_VERTEX_UNIFORM_VECTORS',
201 'MAX_FRAGMENT_UNIFORM_VECTORS',
202 'MAX_VERTEX_TEXTURE_IMAGE_UNITS',
203 'MAX_TEXTURE_IMAGE_UNITS',
204 'MAX_COMBINED_TEXTURE_IMAGE_UNITS'
208 title
: 'Shader Precision',
209 genRows
: precisionRows
212 title
: 'Framebuffer Texture Attachment Support',
213 genRows
: renderTargetRows
217 // TODO: max anisotropy, framebuffer depth bits, MSAA samples, max multiple render targets buffers, point size, line width
219 for (var jj
= 0; jj
< info
.length
; ++jj
) {
220 var table
= document
.createElement("table");
221 var tb
= document
.createElement("tbody");
222 if (info
[jj
].pnames
) {
223 var pnames
= info
[jj
].pnames
;
224 for (var ii
= 0; ii
< pnames
.length
; ++ii
) {
225 var pname
= pnames
[ii
];
226 var value
= gl
.getParameter(gl
[pname
]);
227 tb
.appendChild(createRow([pname
, value
]));
230 if (info
[jj
].genRows
) {
231 var genRows
= info
[jj
].genRows();
232 for (var ii
= 0; ii
< genRows
.length
; ++ii
) {
233 tb
.appendChild(createRow(genRows
[ii
]));
236 table
.appendChild(tb
);
237 var header
= document
.createElement("h2");
238 header
.textContent
= info
[jj
].title
;
239 document
.getElementById("info").appendChild(header
);
240 document
.getElementById("info").appendChild(table
);
242 var extensionList
= document
.createElement('ul');
243 var exts
= gl
.getSupportedExtensions();
244 var extsWithPrefixes
= [];
245 while (exts
.length
> 0) {
246 var prefixedNames
= wtu
.getExtensionPrefixedNames(exts
[0]);
247 var supportedPrefixedNames
= [];
248 for (var ii
= 0; ii
< prefixedNames
.length
; ++ii
) {
249 var index
= exts
.indexOf(prefixedNames
[ii
]);
251 supportedPrefixedNames
.push(exts
[index
]);
252 exts
.splice(index
, 1);
255 extsWithPrefixes
.push(supportedPrefixedNames
.join(" / "));
257 extsWithPrefixes
.sort();
258 for (var ii
= 0; ii
< extsWithPrefixes
.length
; ++ii
) {
259 var li
= document
.createElement('li');
260 li
.appendChild(document
.createTextNode(extsWithPrefixes
[ii
]));
261 extensionList
.appendChild(li
);
263 document
.getElementById('extensions').appendChild(extensionList
);
269 <div id=
"info"></div>
270 <h2>WebGL Extensions
</h2>
271 <div id=
"extensions"></div>
272 <canvas id=
"example" width=
"256" height=
"16" style=
"width: 256px; height: 48px;"></canvas>