<!--Copyright (c) 2023 The Khronos Group Inc.Use of this source code is governed by an MIT-style license that can befound in the LICENSE.txt file.--><!DOCTYPE html><html><head><metacharset="utf-8"><title>gl.texSubImage2D() test to Wasm Memory 16GB in size.</title><linkrel="stylesheet"href="../../resources/js-test-style.css"/><scriptsrc="../../js/js-test-pre.js"></script><scriptsrc="../../js/webgl-test-utils.js"></script></head><body><canvasid="canvas"width="2"height="2"style="width: 40px; height: 40px;"></canvas><divid="description"></div><divid="console"></div><script>"use strict";description(document.title);debug("Tests that gl.texSubImage2D() can be called on WebAssembly Memory 16GB in size.");debug("");letwtu=WebGLTestUtils;letgl=wtu.create3DContext("canvas",undefined,2);constPAGE=65536;constSIZE=16*1024*1024*1024;letview=newUint8Array(newWebAssembly.Memory({index:'i64',initial:SIZE/PAGE}).buffer);functioncompileShader(type,src){letshader=gl.createShader(type);gl.shaderSource(shader,src);gl.compileShader(shader);letlog=gl.getShaderInfoLog(shader);if(log)debug(log);returnshader;}functioncreateProgram(vs,fs){letprogram=gl.createProgram();gl.attachShader(program,vs);gl.attachShader(program,fs);gl.bindAttribLocation(program,0,'pos');gl.linkProgram(program);gl.useProgram(program);returnprogram;}letprogram=createProgram(compileShader(gl.VERTEX_SHADER,` varying vec2 uv; attribute vec2 pos; void main() { uv = pos; gl_Position = vec4(pos*2.0-vec2(1.0,1.0),0,1); }`),compileShader(gl.FRAGMENT_SHADER,` precision lowp float; uniform sampler2D tex; varying vec2 uv; void main() { gl_FragColor = texture2D(tex,uv); }`));gl.bindBuffer(gl.ARRAY_BUFFER,gl.createBuffer());gl.bufferData(gl.ARRAY_BUFFER,newFloat32Array([0,0,1,0,0,1,1,1]),gl.STATIC_DRAW);gl.vertexAttribPointer(0,2,gl.FLOAT,gl.FALSE,0,0);gl.enableVertexAttribArray(0);lettexture=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,texture);// Test uploading an imageconstexpectedColor=[42,84,128,255];constoffset=SIZE-4;view.set(expectedColor,offset);gl.texStorage2D(gl.TEXTURE_2D,1,gl.RGBA8,1,1);gl.texSubImage2D(gl.TEXTURE_2D,0,0,0,1,1,gl.RGBA,gl.UNSIGNED_BYTE,view,offset);wtu.glErrorShouldBe(gl,gl.NO_ERROR);// Test rendering with that imagegl.drawArrays(gl.TRIANGLE_STRIP,0,4);// Verify that we rendered what we expectedwtu.checkCanvasRect(gl,0,0,1,1,expectedColor,"texSubImage2D produced expected color");varsuccessfullyParsed=true;</script><scriptsrc="../../js/js-test-post.js"></script></body></html>