4 <meta charset='utf-
8'
/>
5 <script src='/tests/SimpleTest/SimpleTest.js'
></script>
6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'
>
7 <script src='ensure-ext.js'
></script>
10 <script id='g_vs' type='text/plain'
>
17 <script id='g_fs' type='text/plain'
>
20 gl_FragColor = vec4(
0);
30 function CheckTexFloatRenderable(rgbaInternal
, type
) {
31 const tex
= gl
.createTexture();
32 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
33 gl
.texImage2D(gl
.TEXTURE_2D
, 0, rgbaInternal
, 1, 1, 0, gl
.RGBA
, type
, null);
35 const fb
= gl
.createFramebuffer();
36 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
37 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, tex
, 0);
38 return gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
) == gl
.FRAMEBUFFER_COMPLETE
;
41 function CheckRbFloatRenderable(format
) {
42 const rb
= gl
.createRenderbuffer();
43 gl
.bindRenderbuffer(gl
.RENDERBUFFER
, rb
);
44 gl
.renderbufferStorage(gl
.RENDERBUFFER
, format
, 1, 1);
46 const fb
= gl
.createFramebuffer();
47 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, fb
);
48 gl
.framebufferRenderbuffer(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.RENDERBUFFER
, rb
);
49 return gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
) == gl
.FRAMEBUFFER_COMPLETE
;
52 function CheckBlending() {
53 function CompileShader(type
, elem
) {
54 const text
= elem
.innerHTML
.trim();
55 const s
= gl
.createShader(type
);
56 gl
.shaderSource(s
, text
);
61 const vs
= CompileShader(gl
.VERTEX_SHADER
, g_vs
);
62 const fs
= CompileShader(gl
.FRAGMENT_SHADER
, g_fs
);
63 const p
= gl
.createProgram();
64 gl
.attachShader(p
, vs
);
65 gl
.attachShader(p
, fs
);
69 gl
.drawArrays(gl
.POINTS
, 0, 1);
70 if (gl
.getError()) throw new Error('Unexpected GL error,');
73 gl
.drawArrays(gl
.POINTS
, 0, 1);
74 return gl
.getError() == 0;
77 function ResetGl(type
) {
79 const ext
= gl
.getExtension('WEBGL_lose_context');
83 const c
= document
.createElement('canvas');
84 gl
= c
.getContext(type
);
88 function HasExt(name
) {
89 return gl
.getSupportedExtensions().indexOf(name
) != -1;
93 if (HasExt('EXT_color_buffer_half_float')) {
94 const ext
= gl
.getExtension('OES_texture_half_float');
95 const implicitEnabled
= CheckTexFloatRenderable(gl
.RGBA
, ext
.HALF_FLOAT_OES
);
96 ok(implicitEnabled
, 'OES_texture_half_float should implicitly enable EXT_color_buffer_half_float.');
100 if (HasExt('WEBGL_color_buffer_float')) {
101 const ext
= gl
.getExtension('OES_texture_float');
102 const implicitEnabled
= CheckTexFloatRenderable(gl
.RGBA
, gl
.FLOAT
);
103 ok(implicitEnabled
, 'OES_texture_float should implicitly enable WEBGL_color_buffer_float.');
105 if (HasExt('EXT_float_blend')) {
106 ok(CheckBlending(), 'OES_texture_float should implicitly enable EXT_float_blend.');
111 if (HasExt('EXT_float_blend')) {
112 const ext
= gl
.getExtension('WEBGL_color_buffer_float');
113 CheckRbFloatRenderable(ext
.RGBA32F_EXT
);
114 const implicitEnabled
= CheckBlending();
115 ok(implicitEnabled
, 'WEBGL_color_buffer_float should implicitly enable EXT_float_blend.');
118 if (ResetGl('webgl2')) {
119 if (HasExt('EXT_float_blend')) {
120 const ext
= gl
.getExtension('EXT_color_buffer_float');
121 CheckTexFloatRenderable(gl
.RGBA32F
, gl
.FLOAT
);
122 const implicitEnabled
= CheckBlending();
123 ok(implicitEnabled
, 'EXT_color_buffer_float should implicitly enable EXT_float_blend.');