Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{
description("This test verifies the functionality of rendering with integer texture non-zero base level.");

var red = [255, 0, 0, 255];
var green = [0, 255, 0, 255];

var width = 16;
Expand All @@ -41,12 +42,12 @@
gl.viewport(0, 0, width, height);

var texture = gl.createTexture();
var level = 1;
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, level);
wtu.fillTexture(gl, texture, width, height, green, level, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, gl.RGBA8UI);
wtu.fillTexture(gl, texture, width * 2, height * 2, red, 0, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, gl.RGBA8UI);
wtu.fillTexture(gl, texture, width, height, green, 1, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, gl.RGBA8UI);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

var program = tiu.setupTexturedQuad(gl, "RGBA8UI");
Expand Down
11 changes: 5 additions & 6 deletions sdk/tests/conformance2/rendering/framebuffer-texture-level1.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@
var wtu = WebGLTestUtils;
var gl;

function testFramebufferTextureWithNonZeroBaseLevel(level) {
if (level < 1) {
throw "This test is incorrect if level < 1";
}
function testFramebufferTextureWithNonZeroBaseLevel() {
var width = 32;
var height = 16;
var level = 1;
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texImage2D(gl.TEXTURE_2D, level, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width * 2, height * 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texImage2D(gl.TEXTURE_2D, 1, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, level);
Expand All @@ -52,7 +51,7 @@
var canvas = document.getElementById("canvas");
shouldBeNonNull("gl = wtu.create3DContext(canvas, undefined, 2)");

testFramebufferTextureWithNonZeroBaseLevel(1);
testFramebufferTextureWithNonZeroBaseLevel();

debug("");
var successfullyParsed = true;
Expand Down
1 change: 0 additions & 1 deletion sdk/tests/conformance2/textures/misc/00_test_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ copy-texture-image.html
copy-texture-image-luma-format.html
--min-version 2.0.1 copy-texture-image-same-texture.html
copy-texture-image-webgl-specific.html
--min-version 2.0.1 generate-mipmap-with-large-base-level.html
gl-get-tex-parameter.html
--min-version 2.0.1 immutable-tex-render-feedback.html
--min-version 2.0.1 integer-cubemap-texture-sampling.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "copyTexImage2D should succeed.");
checkFramebuffer([gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT]);

// Make the texture consistent again before base level can be changed
var new_width = 64 * 4;
var new_height = 64 * 4;
for (var level = 0; (new_width >> level) > 0; ++level) {
// Keep level 2 intact
if (level != 2)
gl.texImage2D(gl.TEXTURE_2D, level, gl.RGBA8, new_width >> level, new_height >> level, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}

checkTextureLevelColor(texture, 2, 64, 64, 0, 0, 32, 32, [255, 0, 0, 255]);
checkTextureLevelColor(texture, 2, 64, 64, 0, 32, 64, 32, [0, 0, 0, 0]);
checkTextureLevelColor(texture, 2, 64, 64, 32, 32, 32, 32, [0, 0, 0, 0]);
Expand Down Expand Up @@ -121,6 +130,13 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "copyTexImage2D should succeed.");
checkFramebuffer([gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT]);

// Make the texture consistent again before base level can be changed
for (var level = 0; (64 >> level) > 0; ++level) {
// Keep level 2 intact
if (level != 2)
gl.texImage2D(gl.TEXTURE_2D, level, gl.LUMINANCE_ALPHA, 64 >> level, 64 >> level, 0, gl.LUMINANCE_ALPHA, gl.UNSIGNED_BYTE, null);
}

checkTextureLevelColor(texture, 2, 16, 16, 0, 0, 16, 16, [255, 255, 255, 255]);

gl.deleteFramebuffer(fbo);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_MAG_FILTER) should succeed");
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_MIN_FILTER) should succeed");
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_BASE_LEVEL) should succeed");
gl.texStorage3D(gl.TEXTURE_3D, 4, gl.RGBA8, 32, 16, 8);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texStorage3D should succeed");
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_BASE_LEVEL) should succeed");
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearAndDrawQuad should succeed");
wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
Expand Down
8 changes: 5 additions & 3 deletions sdk/tests/conformance2/textures/misc/tex-base-level-bug.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
var width = 2;
var height = 2;
gl.bindTexture(gl.TEXTURE_2D, tex);
wtu.fillTexture(gl, tex, width * 4, height * 4, [0, 255, 0, 255], 0, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.fillTexture(gl, tex, width * 2, height * 2, [0, 255, 0, 255], 1, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.fillTexture(gl, tex, width, height, [255, 0, 0, 255], 2, gl.RGBA, gl.UNSIGNED_BYTE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 2);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
Expand All @@ -53,9 +55,9 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearAndDrawQuad should succeed");
wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");

width = 1;
height = 1;
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
// Redefining level 0 is ok as long as it's compatible with the existing
// level 0 definition (because base level is not zero).
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width * 4, height * 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texImage2D should succeed");

wtu.clearAndDrawUnitQuad(gl);
Expand Down
20 changes: 16 additions & 4 deletions sdk/tests/conformance2/textures/misc/tex-mipmap-levels.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@
gl.uniform4f(multLoc, 1, 1, 1, 1);

// Test that filling partial levels is enough for mipmapping.
// Since https://github.com/KhronosGroup/WebGL/issues/3802, the levels before
// level 2 must all be defined as well.
gl.bindTexture(gl.TEXTURE_2D, tex);
wtu.fillTexture(gl, tex, 32, 32, [255, 255, 0, 255], 0, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(32x32, level=0) should succeed");
wtu.fillTexture(gl, tex, 16, 16, [255, 0, 255, 255], 1, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(16x16, level=1) should succeed");
wtu.fillTexture(gl, tex, 8, 8, [255, 0, 0, 255], 2, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(8x8, level=2) should succeed");
wtu.fillTexture(gl, tex, 4, 4, [0, 255, 0, 255], 3, gl.RGBA, gl.UNSIGNED_BYTE);
Expand Down Expand Up @@ -114,6 +120,10 @@
// Test incompleteless for partial levels.
tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
wtu.fillTexture(gl, tex, 32, 32, [255, 255, 0, 255], 0, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(8x8, level=2) should succeed");
wtu.fillTexture(gl, tex, 16, 16, [255, 0, 255, 255], 1, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(8x8, level=2) should succeed");
wtu.fillTexture(gl, tex, 8, 8, [255, 0, 0, 255], 2, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(8x8, level=2) should succeed");
wtu.fillTexture(gl, tex, 4, 4, [255, 0, 0, 255], 3, gl.RGBA, gl.UNSIGNED_BYTE);
Expand All @@ -130,6 +140,10 @@
// Test base level texture isn't specified.
tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
wtu.fillTexture(gl, tex, 32, 32, [255, 255, 0, 255], 0, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(32x32, level=0) should succeed");
wtu.fillTexture(gl, tex, 16, 16, [255, 0, 255, 255], 1, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(16x16, level=1) should succeed");
wtu.fillTexture(gl, tex, 8, 8, [255, 0, 0, 255], 2, gl.RGBA, gl.UNSIGNED_BYTE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(8x8, level=2) should succeed");
wtu.fillTexture(gl, tex, 4, 4, [255, 0, 0, 255], 3, gl.RGBA, gl.UNSIGNED_BYTE);
Expand All @@ -138,8 +152,6 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "fillTexture(2x2, level=4) should succeed");
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_BASE_LEVEL) should succeed");
gl.generateMipmap(gl.TEXTURE_2D);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "generateMipmap should fail if base level texture is not specified");
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 2);
gl.generateMipmap(gl.TEXTURE_2D);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "generateMipmap should succeed");
Expand Down Expand Up @@ -205,10 +217,10 @@
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_MAG_FILTER) should succeed");
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_MIN_FILTER) should succeed");
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_BASE_LEVEL) should succeed");
gl.texStorage2D(gl.TEXTURE_2D, 4, gl.RGBA8, 31, 17);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texStorage2D should succeed");
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 1);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameter(TEXTURE_BASE_LEVEL) should succeed");
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearAndDrawQuad should succeed");
wtu.checkCanvas(gl, [255, 0, 0, 255], "non-zero base level texStorage2D: should draw with [255, 0, 0, 255]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1814,10 +1814,6 @@ goog.scope(function() {
// gen texture
texId = gl.createTexture();
gl.bindTexture(textureTarget, texId);
gl.texParameteri(textureTarget, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(textureTarget, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(textureTarget, gl.TEXTURE_BASE_LEVEL, testSize.lodBase);
gl.texParameteri(textureTarget, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);

// set up texture

Expand Down Expand Up @@ -1862,6 +1858,11 @@ goog.scope(function() {
throw new Error('Type not supported');
}

gl.texParameteri(textureTarget, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(textureTarget, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(textureTarget, gl.TEXTURE_BASE_LEVEL, testSize.lodBase);
gl.texParameteri(textureTarget, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);

// test
/** @type {number} */ var colorTolerance = 0.1;
/** @type {tcuSurface.Surface} */ var sample = new tcuSurface.Surface(1, 1);
Expand Down
16 changes: 14 additions & 2 deletions sdk/tests/deqp/functional/gles3/es3fTextureStateQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,21 @@ es3fTextureStateQuery.TextureLevelCase.prototype.testTexture = function() {

this.check(glsStateQuery.verifyTexture(this.m_textureTarget, this.m_levelTarget, this.m_initialValue));

var size = 128;
var is_base_level = this.m_levelTarget == gl.TEXTURE_BASE_LEVEL;
var max_value = is_base_level ? 7 : 64000;

// For BASE_LEVEL, the texture must be well defined before it can be changed.
if (is_base_level) {
if (this.m_textureTarget == gl.TEXTURE_2D_ARRAY || this.m_textureTarget == gl.TEXTURE_3D)
gl.texStorage3D(this.m_textureTarget, 8, gl.RGBA8, size, size, size);
else
gl.texStorage2D(this.m_textureTarget, 8, gl.RGBA8, size, size);
}

var numIterations = 60;
for (var ndx = 0; ndx < numIterations; ++ndx) {
var ref = rnd.getInt(0, 64000);
var ref = rnd.getInt(0, max_value);

gl.texParameteri(this.m_textureTarget, this.m_levelTarget, ref);

Expand All @@ -197,7 +209,7 @@ es3fTextureStateQuery.TextureLevelCase.prototype.testTexture = function() {
var nonSignificantOffsets = [-0.45, -0.25, 0, 0.45]; // offsets O so that for any integers z in Z, o in O roundToClosestInt(z+o)==z

for (var ndx = 0; ndx < numIterations; ++ndx) {
var ref = rnd.getInt(0, 64000);
var ref = rnd.getInt(0, max_value);

for (var i = 0; i < nonSignificantOffsets.length; i++) {
gl.texParameterf(this.m_textureTarget, this.m_levelTarget, ref + nonSignificantOffsets[i]);
Expand Down
17 changes: 16 additions & 1 deletion sdk/tests/js/tests/gl-get-tex-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ for (var ii = 0; ii < targets.length; ++ii) {
var tex = gl.createTexture();
gl.activeTexture(gl.TEXTURE0 + ii);
gl.bindTexture(gl[target], tex);

// Changing base level requires well-defined texture mips.
var size = 128;
for (var level = 0; level <= 7; ++level) {
var level_size = size >> level;
if (gl[target] == gl.TEXTURE_2D_ARRAY || gl[target] == gl.TEXTURE_3D)
gl.texImage3D(gl[target], level, gl.RGBA8, level_size, level_size, gl[target] == gl.TEXTURE_3D ? level_size : size, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
else if (gl[target] == gl.TEXTURE_CUBE_MAP) {
for (var face = 0; face < 6; ++face) {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, level, gl.RGBA8, level_size, level_size, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
}
else
gl.texImage2D(gl[target], level, gl.RGBA8, level_size, level_size, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
}

wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
Expand All @@ -54,7 +69,7 @@ if (contextVersion > 1) {
{ state: 'TEXTURE_WRAP_R', default: 'REPEAT', value1: 'CLAMP_TO_EDGE', value2: 'MIRRORED_REPEAT' },
{ state: 'TEXTURE_COMPARE_FUNC', default: 'LEQUAL', value1: 'GREATER', value2: 'LESS' },
{ state: 'TEXTURE_COMPARE_MODE', default: 'NONE', value1: 'COMPARE_REF_TO_TEXTURE', value2: 'NONE' },
{ state: 'TEXTURE_BASE_LEVEL', default: 0, value1: 100, value2: 99 },
{ state: 'TEXTURE_BASE_LEVEL', default: 0, value1: 7, value2: 6 },
{ state: 'TEXTURE_MAX_LEVEL', default: 1000, value1: 800, value2: 300 },
{ state: 'TEXTURE_MIN_LOD', default: -1000.0, value1: -500.0, value2: -999.0 },
{ state: 'TEXTURE_MAX_LOD', default: 1000.0, value1: 500.0, value2: 999.0 },
Expand Down
2 changes: 1 addition & 1 deletion specs/latest/1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,7 @@ <h4>Texture objects</h4>
By default, these methods generate an <code>INVALID_ENUM</code> error and return
immediately. See <a href="#COMPRESSED_TEXTURE_SUPPORT">Compressed Texture Support</a>.

<dt class="idl-code">void copyTexImage2D(GLenum target, GLint level, GLenum internalformat,
<dt class="idl-code"><a name="COPYTEXIMAGE2D_HTML">void copyTexImage2D</a>(GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height,
GLint border)
<span class="gl-spec">(<a href="http://registry.khronos.org/OpenGL/specs/es/2.0/es_full_spec_2.0.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;3.7.2</a>, <a class="nonnormative" href="https://registry.khronos.org/OpenGL-Refpages/es2.0/xhtml/glCopyTexImage2D.xml">man page</a>)</span>
Expand Down
Loading
Loading