texture-copying-feedback-loops.html (3361B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 10 <meta charset="utf-8"> 11 <title>WebGL Texture Copying Feedback Loops Test</title> 12 <link rel="stylesheet" href="../../../resources/js-test-style.css"/> 13 <script src="../../../js/js-test-pre.js"></script> 14 <script src="../../../js/webgl-test-utils.js"></script> 15 </head> 16 <body> 17 <canvas id="example" width="1" height="1" style="width: 40px; height: 40px;"></canvas> 18 <div id="description"></div> 19 <div id="console"></div> 20 21 <script> 22 "use strict"; 23 description("Checks that texture copying feedback loops fail correctly."); 24 var wtu = WebGLTestUtils; 25 var gl = wtu.create3DContext("example"); 26 27 var texture = gl.createTexture(); 28 gl.bindTexture(gl.TEXTURE_2D, texture); 29 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 30 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); 31 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); 32 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 33 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); 34 35 var texture2 = gl.createTexture(); 36 gl.bindTexture(gl.TEXTURE_2D, texture2); 37 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); 38 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); 39 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); 40 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 41 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); 42 43 var framebuffer = gl.createFramebuffer(); 44 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); 45 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); 46 assertMsg(gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE, 47 "framebuffer should be FRAMEBUFFER_COMPLETE."); 48 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setup"); 49 50 debug(""); 51 debug("testing copyTexImage2D"); 52 gl.bindTexture(gl.TEXTURE_2D, texture); 53 gl.copyTexImage2D(gl.TEXTURE_2D, 1, gl.RGBA, 0, 0, 2, 2, 0); 54 wtu.glErrorShouldBe(gl, gl.NO_ERROR, 55 "after copyTexImage2D to same texture but different level"); 56 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 2, 2, 0); 57 wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, 58 "after copyTexImage2D to same texture same level, invalid feedback loop"); 59 gl.bindTexture(gl.TEXTURE_2D, texture2); 60 gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 2, 2, 0); 61 wtu.glErrorShouldBe(gl, gl.NO_ERROR, 62 "after copyTexImage2D to different texture"); 63 64 debug(""); 65 debug("testing copyTexSubImage2D"); 66 gl.bindTexture(gl.TEXTURE_2D, texture); 67 gl.copyTexSubImage2D(gl.TEXTURE_2D, 1, 0, 0, 0, 0, 1, 1); 68 wtu.glErrorShouldBe(gl, gl.NO_ERROR, 69 "after copyTexSubImage2D to same texture but different level"); 70 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); 71 wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, 72 "after copyTexSubImage2D to same texture same level, invalid feedback loop"); 73 gl.bindTexture(gl.TEXTURE_2D, texture2); 74 gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); 75 wtu.glErrorShouldBe(gl, gl.NO_ERROR, 76 "after copyTexSubImage2D to different texture"); 77 var successfullyParsed = true; 78 </script> 79 <script src="../../../js/js-test-post.js"></script> 80 81 </body> 82 </html>