Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

SenorBlanco
Copy link
Contributor

Add sections to the compatbility-mode proposal to reflect the consensus on mip level and array layer constraints: one mip level per texture, and no array layer subsetting.

Copy link
Contributor

github-actions bot commented Nov 6, 2023

Previews, as seen when this build job started (0c0b2cc):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt


**Justification**: OpenGL ES does not support texture views, but one mip level subset may be specified per texture using `glTexParameter*()` via the `GL_TEXTURE_BASE_LEVEL` and `GL_TEXTURE_MAX_LEVEL` parameters.

### 6. Array texture views used in draw calls must consist of the entire array. That is, `baseArrayLayer` must be zero, and `arrayLayerCount` must be equal to the size of the texture array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could say "in bind groups" since that could be validated at bind-group creation. The paragraph below would need an update too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For mip levels it's actually at draw time since you might have different sub level ranges in different bind groups.

Should we validate both that at createBindGroup that there is not more than 1 sub level range or or should we skip that since at draw time we need to validate there is only 1 sub level range across all bind groups?

For layers sub ranges it would be at createBindGroup time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct that for mip levels it would be at draw time, but here the comment was just for array layers. I agree that mip levels should just be validated at draw time. (with optimization possible in browsers to validate at createBindGroup if they find that this is helping perf)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

I also modified the paragraph below to address storage textures: "Only views of the entire array are supported for sampling or storage bindings." LMK if that's incorrect.


### 5. Views of the same texture used in a single draw may not differ in mip levels.

A draw call may not bind two views of the same texture differing in `baseMipLevel` or `mipLevelCount`. Only a single mip level range range per texture is supported. This is enforced via validation at encode time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How specific should we get in the proposal vs the actual spec?

This is valid

setBindGroup(0, subView1);  
setBindGroup(1, subView2);  // incompatible with subView1
draw()                      // pipeline that only uses subView1 (via group(0))

both setBindGroup and draw are "encoding". Not sure if that's being too nit-picky but the final spec will need to make that clear that it's only validated on draw and only cares about bindgroups actually used. (or even if it cares about all of them it still has to at draw cmd encoding, not setBindGroup cmd encoding)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to be fairly precise in proposals, so that translation to spec text doesn't require roundtrips to the group ideally. +1 that this should be checked on draw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've changed it to "draw time". Now maybe I'm being overly picky, but to me draw time is when the draw command is executed, not when it is encoded. OTOH, no validation occurs on execution, so perhaps it's ok in this case. Futher wordsmithing welcome.)


### 6. Array texture views used in bind groups must consist of the entire array. That is, `baseArrayLayer` must be zero, and `arrayLayerCount` must be equal to the size of the texture array.

A bind group may not reference a subset of array layers. Only views of the entire array are supported for sampling or storage bindings. This is enforced via validation at bind group creation time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this will come up or needs to be mentioned. I think it might have been brought up before. This is enforced at bind group creation and not create view time because it's still valid to make a sub range of 1 layer use as a render attachment

@greggman
Copy link
Contributor

greggman commented Nov 9, 2023

The issue of validating out "2d" of more than 1 layer is not mentioned in this proposal. It seems like it came up in the meeting.

In other words,

createTexture({
  size: [1,1,2],  // so 2 or more layers
  textureBindingViewDimension: '2d',  // the default would be '2d-array' but user choose '2d'
  ...
});

Should fail with a validation error

I think similarly

createTexture({
  size: [1,1,2],  // not 6 layers
  textureBindingViewDimension: 'cube',
  ...
});

should fail with a validation error. This would already fail at view creation time but seems like it should fail here because GL can't create a 2 layer cube map which is what's being asking for here

@SenorBlanco SenorBlanco merged commit 3e3e21a into gpuweb:main Nov 10, 2023
@SenorBlanco
Copy link
Contributor Author

The issue of validating out "2d" of more than 1 layer is not mentioned in this proposal. It seems like it came up in the meeting.

In other words,

createTexture({
  size: [1,1,2],  // so 2 or more layers
  textureBindingViewDimension: '2d',  // the default would be '2d-array' but user choose '2d'
  ...
});

Should fail with a validation error

I think similarly

createTexture({
  size: [1,1,2],  // not 6 layers
  textureBindingViewDimension: 'cube',
  ...
});

should fail with a validation error. This would already fail at view creation time but seems like it should fail here because GL can't create a 2 layer cube map which is what's being asking for here

These are good points. We discussed the first one in the meeting, but not the cube map one. I think they probably belong under the first restriction ("Texture view dimension may be specified") rather than in the arrayLayers restriction. I'll add it to my backlog of PRs.

@SenorBlanco SenorBlanco deleted the consensus-3 branch November 14, 2023 19:11
@kainino0x kainino0x added the compat WebGPU Compatibility Mode label Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat WebGPU Compatibility Mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants