Support for shader_explicit_arithmetic_types and shader_16bit_storage - #1001
Conversation
|
On 1:
On 2: Perhaps Alternatively, would you be opposed to a bitmask for enum {
GPU_FEATURE_SUPPORT_8 = (1 << 0),
GPU_FEATURE_SUPPORT_16 = (1 << 1),
GPU_FEATURE_SUPPORT_32 = (1 << 2),
GPU_FEATURE_SUPPORT_64 = (1 << 3),
};
// All support 32-bit, and you would never query this, but nice from a "correctness" POV
uint8 integer = GPU_FEATURE_SUPPORT_32;
uint8 float = GPU_FEATURE_SUPPORT_32;
uint8 storage = GPU_FEATURE_SUPPORT_32;
uint8 uniform = GPU_FEATURE_SUPPORT_32;Of course, with bit fields, this becomes more compact and all four of these fit in 2 bytes. |
|
One idea to simplify the graphics features a bit might be to document them as like:
That way there can just be top-level |
I'm okay with this, but for clarity, this feature in WGPU essentially checks for So I guess for true parity, we may as well do the same. Bit of a shame, since I think this limits 100% support to Nvidia RTX and forward or ~8 years vs. ~11 years. |
1286a1a to
7792ccf
Compare
|
All feedback addressed, only change worth noting, is I made int16 align with the rest here, which is a breaking change. I don't know how many people use lovr on mobile, but support for i16 types and storage/uniform buffer support is probably the worst on those devices. I presume this wouldn't be the case on stuff like the Quest and other standalone headsets though. So it may be worth regression testing if you've got anything to test on (I've a Quest 3 lying around, but no projects to test with). Granted, I suspect not many people were using that anyway. |
|
It's fine to make int16 a little more restrictive. Since we get to decide between:
I think I'd probably pick (2) here? It seems better to advertise the feature more (esp. on Quest) rather than strictly follow WebGPU's semantics. Either way, it's definitely niche. |
|
|
Here's what support looks like right now: Oculus Go:shaderInt16 Oculus Quest 2 / Pro:shaderInt8, shaderInt16, shaderFloat16, storageBuffer16BitAccess Oculus Quest 3 / 3S:shaderInt8, shaderInt16, shaderInt64, shaderFloat16, storageBuffer8BitAccess, storageBuffer16BitAccess Apple Vision Pro (M2):shaderInt8, shaderInt16, shaderFloat16, storageBuffer8BitAccess, uniformAndStorageBuffer8BitAccess, storageBuffer16BitAccess, uniformAndStorageBuffer16BitAccess Apple Vision Pro (M5):shaderInt8, shaderInt16, shaderInt64, shaderFloat16, storageBuffer8BitAccess, uniformAndStorageBuffer8BitAccess, storageBuffer16BitAccess, uniformAndStorageBuffer16BitAccess Interestingly Qualcomm GPUs do not support uniformAndStorageBuffer at all - so if mobile is a big area for y'all I think that seals the deal as the minimum target. |
7792ccf to
e80b1a9
Compare
e80b1a9 to
eb2837e
Compare
|
I don't think you need to run checks for this one, but decided to resolve that / code style issues in Think this is ready to merge, so I'll restrain myself from further code golfing. :) |
…r_16bit_storage`
eb2837e to
6ec0895
Compare
|
Looks good, thanks for the PR! |
|
(Added support for reading back the new formats in |
These two extensions are useful when working with compute shaders, and by extension raster shaders if they're fed packed data.
My specific use case was doing some mesh generation in a compute pass where I needed atomics to write packed data. Using
shader_8bit_storage: requireallows me to remove all atomics by ensuring each byte is only touched by up to at most one thread. So it's a fairly good win, especially considering 8-bit / 16-bit storage has been fairly well supported for the last ~10 years.Some early feedback received, but not yet address:
vec3types are not widely supported for vertex attributes, and are not supported by wgpu at allstorage/uniformfeaturesPlease note, I have not tested the wgpu backend yet, but I imagine it works just fine since the changes are fairly mechanical. One thing to call out there is the explicit errors added if you manage to break alignment rules for vertex attributes. Ostensibly this means, you're fine to use types like
u16vec3if you're not usingscalar/packedrules - the padding saves your bacon. Otherwise, you'll hit these new errors.