-
Notifications
You must be signed in to change notification settings - Fork 685
Add offset test to webgl-compressed-texture-astc #3750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DavidPeicho
wants to merge
1
commit into
KhronosGroup:main
Choose a base branch
from
DavidPeicho:test/astc-offset-upload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2163,20 +2163,6 @@ | |
| } | ||
|
|
||
| function uploadSubData(target) { | ||
| function checkResult(target, expectations, dim) { | ||
| switch (target) { | ||
| case gl.TEXTURE_2D: | ||
| wtu.glErrorShouldBe(gl, expectations[0], "uploading compressed 2D texture data via compressedTexSubImage" + dim); | ||
| break; | ||
| case gl.TEXTURE_2D_ARRAY: | ||
| wtu.glErrorShouldBe(gl, expectations[1], "uploading compressed 2D array texture data via compressedTexSubImage" + dim); | ||
| break; | ||
| case gl.TEXTURE_3D: | ||
| wtu.glErrorShouldBe(gl, expectations[2], "uploading compressed 3D texture data via compressedTexSubImage" + dim); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| gl.compressedTexSubImage2D(target, 0, 0, 0, width, height, format, data); | ||
| checkResult(target, [gl.NO_ERROR, gl.INVALID_ENUM, gl.INVALID_ENUM ], "2D"); | ||
|
|
||
|
|
@@ -2186,6 +2172,31 @@ | |
| } | ||
| } | ||
|
|
||
| function uploadSubDataOffset(target) { | ||
| const blockSize = getBlockDimensions(format); | ||
| if ((width % blockSize.width) || (height % blockSize.height)) { | ||
| // Skip test for unaligned blocks | ||
| return; | ||
| } | ||
|
|
||
| const x = blockSize.width; | ||
| const y = blockSize.height; | ||
| const blitWidth = width - x; | ||
| const blitHeight = height - y; | ||
|
|
||
| // Offset the update by one horizontal and one vertical rows. | ||
| // ASTC block size is always 16 bytes (128 bits) | ||
| const offset = (width / blockSize.width + height / blockSize.height - 1) * 16; | ||
|
|
||
| gl.compressedTexSubImage2D(target, 0, x, y, blitWidth, blitHeight, format, data, offset); | ||
| checkResult(target, [gl.NO_ERROR, gl.INVALID_ENUM, gl.INVALID_ENUM ], "2D", true); | ||
|
|
||
| if (useES3) { | ||
| gl.compressedTexSubImage3D(target, 0, x, y, 0, blitWidth, blitHeight, 1, format, data, offset); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| checkResult(target, [gl.INVALID_ENUM, gl.NO_ERROR, gl.NO_ERROR], "3D", true); | ||
| } | ||
| } | ||
|
|
||
| function setupFilledTexture(target) { | ||
| var tex = gl.createTexture(); | ||
| gl.bindTexture(target, tex); | ||
|
|
@@ -2277,6 +2288,12 @@ | |
| checkSampling(gl.TEXTURE_2D) | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // Upload with offsets | ||
| tex = setupEmptyTexture(gl.TEXTURE_2D, false); | ||
| wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed texture array via compressedTexImage3D"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect message |
||
| uploadSubDataOffset(gl.TEXTURE_2D); | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // mutable filled | ||
| tex = setupFilledTexture(gl.TEXTURE_2D); | ||
| wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating filled compressed texture via compressedTexImage2D"); | ||
|
|
@@ -2304,6 +2321,12 @@ | |
| checkSampling(gl.TEXTURE_2D_ARRAY) | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // Upload with offsets | ||
| tex = setupEmptyTexture(gl.TEXTURE_2D_ARRAY, false); | ||
| wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed texture array via compressedTexImage3D"); | ||
| uploadSubDataOffset(gl.TEXTURE_2D_ARRAY); | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // mutable filled | ||
| tex = setupFilledTexture(gl.TEXTURE_2D_ARRAY); | ||
| wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating filled compressed texture array via compressedTexImage3D"); | ||
|
|
@@ -2338,6 +2361,17 @@ | |
| } | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // Upload with offsets | ||
| tex = setupEmptyTexture(gl.TEXTURE_3D, false); | ||
| if (hasHdr) { | ||
| wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed sliced 3D texture via compressedTexImage3D"); | ||
| checkErrorColor(); | ||
| uploadSubDataOffset(gl.TEXTURE_3D); | ||
| } else { | ||
| wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "allocating empty compressed sliced 3D texture via compressedTexImage3D"); | ||
| } | ||
| gl.deleteTexture(tex); | ||
|
|
||
| // mutable filled | ||
| tex = setupFilledTexture(gl.TEXTURE_3D); | ||
| if (hasHdr) { | ||
|
|
@@ -2420,6 +2454,21 @@ | |
| } | ||
| } | ||
|
|
||
| function checkResult(target, expectations, dim, offsets = false) { | ||
| const offsetStr = offsets ? " with x/y offsets" : ""; | ||
| switch (target) { | ||
| case gl.TEXTURE_2D: | ||
| wtu.glErrorShouldBe(gl, expectations[0], "uploading compressed 2D texture data via compressedTexSubImage" + dim + offsetStr); | ||
| break; | ||
| case gl.TEXTURE_2D_ARRAY: | ||
| wtu.glErrorShouldBe(gl, expectations[1], "uploading compressed 2D array texture data via compressedTexSubImage" + dim + offsetStr); | ||
| break; | ||
| case gl.TEXTURE_3D: | ||
| wtu.glErrorShouldBe(gl, expectations[2], "uploading compressed 3D texture data via compressedTexSubImage" + dim + offsetStr); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| // Builds several tests from two arrays | ||
| // data gives each Uint8Array encoded data to use | ||
| // formats the associate format to decode the data | ||
|
|
@@ -2484,7 +2533,7 @@ | |
| return { | ||
| width: parseInt(match[1], 10), | ||
| height: parseInt(match[2], 10) | ||
| }; | ||
| }; | ||
| } | ||
| } | ||
| testFailed('Could not find block dimensions for format ' + ctu.formatToString(ext, format)); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness, please also test the length override parameter like