Repository navigation
describe texel formats (for storage texture types) - #1112
Conversation
cf3d473 to
89ab927
Compare
f138b03 to
3e49e47
Compare
| <table class='data'> | ||
| <caption>Channel types</caption> | ||
| <thead> | ||
| <tr><td>Channel type<td>Number of stored bits<td>Interpetation of stored bits<td>Shader type<td>Shader value |
There was a problem hiding this comment.
I'd suggest changing this to 1 line per td to make it easier to read/work with
There was a problem hiding this comment.
I did that for the headings.
But I left the rows as-is. I find it easier to both edit and scan for differences when they're horizontally organized
| A <dfn noexport>texel</dfn> is a scalar or vector used as the smallest independently addressible element of a [=texture=]. | ||
| The word *texel* is short for *texture element*. | ||
|
|
||
| A <dfn noexport>texture</dfn> is a grid of texels supporting special operations useful for rendering. |
There was a problem hiding this comment.
nit: multi-dimensional grid (it can be 1, 2, 3 or even 4 if when we support 2D array multisampled textures)
There was a problem hiding this comment.
The bullet points below describe dimensionality, and say it's 1,2,3 dimensions. There is also array-size, when the texture is arrayed.
Note that the compute shader workgroup-grid is 3-dimensional without explicitly calling it out as multi-dimensional.
| including data layouts, data types, and operations that cannot be expressed directly in the shader language. | ||
| Each texel has a unique grid coordinate within the texture. | ||
|
|
||
| An <dfn noexport>arrayed texture</dfn> is a texture which is organized as a homegeneous array of grids of texels. |
There was a problem hiding this comment.
nit: isn't the arrayness just an extra dimension for the multi-dimensional grid?
There was a problem hiding this comment.
I was hoping to treat the array index specially. The regular grid coordinates have interpolation applied to them, but the array index does not. I suggest we add a note to revisit this editorially
|
|
||
| A texture has the following features: | ||
|
|
||
| : <dfn noexport>texel format</dfn> |
There was a problem hiding this comment.
Indeed. I've yet to capture that.
There was a problem hiding this comment.
I added mip levels now. Thanks!
| <tr><td>8uint<td>8<td>unsigned integer |v| ∈ {0,...,255}<td>u32<td> |v| ÷ 255 | ||
| <tr><td>8sint<td>8<td>signed integer |v| ∈ {-128,...,127}<td>i32<td> |v| ÷ 128 | ||
| <tr><td>16uint<td>16<td>unsigned integer |v| ∈ {0,...,65535}<td>u32<td> |v| ÷ 65535 | ||
| <tr><td>16sint<td>16<td>signed integer |v| ∈ {-32768,...,32767}<td>i32<td> |v| ÷ 32768 |
There was a problem hiding this comment.
I don't think that the WGSL spec should talk about the exact bit representation of texture, because there's weird formats like rgb9e5 and compressed ones. Only the component type matters, except for storage textures (which can have an exact bit representation described in this spec).
There was a problem hiding this comment.
I think there is still value in describing the formats we do know and guarantee, such as 8unorm. For rgb9e5 we can figure something out and say it's more platform-dependent.
There was a problem hiding this comment.
I'm not sure I understand, should the WGSL spec just tell you that when you sample a texture with floating point component type you get an f32 and what f32 you get is described by the texture sampling part of the WebGPU specification? This way WGSL wouldn't care if it is r8unorm rg16float or bc1-rgba-unorm?
There was a problem hiding this comment.
well, I'm saying that it's generally useful that, for example, an r8unorm is one of the values between 0/255 and 255/255. This allows authors to adjust their expectations on sampling, or when writing to the color outputs.
Where exactly this is specified (WGSL or WebGPU spec) is not something that I feel strongly about.
There was a problem hiding this comment.
The only reason WGSL needs texel-formats is to parameterize storage textures. The sampled and depth textures do not, and I'd like to eliminate those weirdly-shaped texel formats from the WGSL spec entirely.
See the modifications to the texture-ro and texture-wo sections in this MR.
There was a problem hiding this comment.
After removing the texel formats that require SPIR-V capability StorageImageExtendedFormats, we're left with:
- r32uint
- r32sint
- r32float
- rgba8unorm
- rgba8snorm
- rgba8uint
- rgba8sint
I can delete all the other ones from the tables, and make this much simpler.
There was a problem hiding this comment.
where did 32-bit RG and RGBA formats go?
There was a problem hiding this comment.
Looks like rgba32float and rgba32ui, rgba32i are missing from list above but all of the rg formats appear to be in StorageImageExtendedFormats. https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#Image_Format
There was a problem hiding this comment.
Interesting! So this is different from what Vulkan requires. I guess the StorageImageExtendedFormats on the SPIR-V side becomes an implementation detail, and we don't need to care about it on the API side.
Please just follow the table we have in the spec - https://gpuweb.github.io/gpuweb/#plain-color-formats
There was a problem hiding this comment.
I had been reading the required format support for Vulkan. But I have not been following what was worked out already for WebGPU.
I'll follow the WebGPU table. Thanks!
| The word *texel* is short for *texture element*. | ||
|
|
||
| A <dfn noexport>texture</dfn> is a grid of texels supporting special operations useful for rendering. | ||
| A texture's representation is typically optimized for those operations, with many details hidden from the programmer |
There was a problem hiding this comment.
it's a bit weird to call them "special operations useful for rendering" and then follow with "those operations", which assumes the users know what they are. Would be good to provide examples here
There was a problem hiding this comment.
I wanted to defer those to the details of builtin functions. That's why later in this introductory section we get into the fact there's no direct access to texture storage and that everything is determined by the set of available texture builtins.
Maybe I can think of something that points forward to the builtins without going into details.
Frankly, I'm concerned about having to describe sampling operations. I'd rather not do that in the WGSL spec. Like, there's a lot of content in Vulkan's "14. Image operations". https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#textures
| <tr><td>8uint<td>8<td>unsigned integer |v| ∈ {0,...,255}<td>u32<td> |v| ÷ 255 | ||
| <tr><td>8sint<td>8<td>signed integer |v| ∈ {-128,...,127}<td>i32<td> |v| ÷ 128 | ||
| <tr><td>16uint<td>16<td>unsigned integer |v| ∈ {0,...,65535}<td>u32<td> |v| ÷ 65535 | ||
| <tr><td>16sint<td>16<td>signed integer |v| ∈ {-32768,...,32767}<td>i32<td> |v| ÷ 32768 |
There was a problem hiding this comment.
I think there is still value in describing the formats we do know and guarantee, such as 8unorm. For rgb9e5 we can figure something out and say it's more platform-dependent.
|
TODO: capture the concept of mip-levels. |
| of the shader value to a stored texel value. | ||
| A write-only storage texture type is parameterized by a [=texel format=], which in turn | ||
| determines the conversion function as specified in [[#texel-formats]]. | ||
| The *inverse* of the transfer function is used to convert the shader value to |
There was a problem hiding this comment.
it says "conversion function" and then "transfer function". Is this the same thing?
| of the shader value to a stored texel value. | ||
| A write-only storage texture type is parameterized by a [=texel format=], which in turn | ||
| determines the conversion function as specified in [[#texel-formats]]. | ||
| The *inverse* of the transfer function is used to convert the shader value to |
There was a problem hiding this comment.
it's not clear how the inversion works, i.e. would the values be rounded or truncated, for example
d4f2220 to
935e49a
Compare
|
Rebased against main, and I've updated the gist preview |
|
My comment may have been lost, so repeating it here. Why did you remove RG32 and RGBA32 formats? |
|
The |
|
@dj2 see #1112 (comment) |
|
I've made the list of storage texture formats match what's already listed in the WebGPU table. That adds the Rg32* formats. Even though those have mandatory in Vulkan, they still require the StorageImageExtendedFormats capability in SPIR-V. So I added back the "SPIR-V enabling capability" column. I've updated the HTML preview: https://gistpreview.github.io/?4c60af08a8b1cca4501abecc93beae3f#texel-formats I've added TODOs to move the description about how storage texture accesses work down to the texture builtins section. The write access needs a more explicitly spelled out description. |
5b6339c to
b858722
Compare
|
I've rebased against main, and collapsed the previous contents into a single commit. |
|
I've updated the HTML preview at https://gistpreview.github.io/?4c60af08a8b1cca4501abecc93beae3f Note that other texture type changes are already in flight: #1180, #1182 I'd like to get these changes approved, modulo those other changes, which are basically orthogonal. |
b858722 to
b034fc3
Compare
|
I've rebased on top of recent renamings of storage texture types, and:
Please take a look. |
|
Discussed at 2020-11-17 meeting. Resolved: Accepted. |
- Drafted high level description of textures. - Define texel formats - define texel formats in terms of channel format and channels - define correspondence to SPIR-V image formats - Describe how storage texture types are parameterized by texel formats. - Fix 2D dimensionality on some OpTypeImage translations - Fix signed/unsigned in 32-bit channel formats - Respond to feedback - add brief forward reference to rendering operations as being invoked via texture builtins, then point to the sectionn. - Reorganized arrayed and non-arrayed textures as the two kinds of textures (hence as bullet points) - Add TODO for mip levels - Specify defined shader values for missing texel format channels See gpuweb#1115 - Remove SPIR-V capability column for texel formats We will not allow storage images over texel formats requiring StorageImageExtendedFormats. We will only use those enabled by the basic Shader capability, so there is no reason to list them. - Only keep texel formats used for storage textures - Match list of storage texture formats from WebGPU API - Add cross-reference to texel formats table - Add TODOs to move and strengthen the description of storage texture accesses down to where the texture builtin functions are described.
e7cad3e to
c4853a9
Compare
I'd like to describe textures in more detail so we can more precisely describe the return type on texture builtin functions, and the sampled component type on sampled texture types.
I'd like to point back to a table in the "Texel formats" section introduced in this PR.