-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGPURenderer: Read Only and Read/Write Storage Textures #28455
Conversation
…. Still need to gain a comprehensive understanding of what texture formats are permitted to be accessed in which ways (for instance, testing revealed that rgba16floats seemingly cannot be accessed with a GPUTextureAccess of 'read-write'. Instead, it only works with 'read-only' or 'write-only' according to the wgsl compiler errors
Nice! You no longer need to use two textures and a ping-pong pattern, as you can now use the same texture with read-write access for both input and output. I've updated the example accordingly if you want to try it: Edit: Did revert the example, here for archive purpose: const pingPong = storageTexture( pingTexture ).setAccess( 'read-write' );
const computeBlurWGSL = wgslFn( `
fn computeBlurWGSL( readWriteTex: texture_storage_2d<${wgslFormat}, read_write>, index: u32 ) -> void {
let posX = index % ${ width };
let posY = index / ${ width };
let indexUV = vec2i( i32( posX ), i32( posY ) );
let color = blur( readWriteTex, indexUV ).rgb;
textureStore( readWriteTex, indexUV, vec4f( color * 1.05, 1 ) );
}
`, [ rand2 ] );
//
computeToPong = computeBlurWGSL( { readWriteTex: pingPong, index: instanceIndex } ).compute( width * height ); This will probably interest @Spiri0 😄 |
I think the WebGPU errors are explicit enough for users to understand what's happening, and trying to catch too many WebGPU errors might simply end up obfuscating the real issue. The combination of access and formats is indeed quite tricky, and we might at least document somewhere what the currently supported ones are (gpuweb/gpuweb#3838 (comment)). Regading the last point I'm not sure if @sunag prefers |
Yes, that sounds very good. I will then update my ocean repository with the next three.js release 😊 |
I think would be better create a new example from this maybe |
It's interesting that we have these shortcuts because of the syntax style, is closer to a shader programming language. |
Sure! I just reverted my changes. I will add an example for Also while playing with this I realized WebGPUTextures are missing a bunch of format its the backend such as UnsignedIntType, IntType and so on. I will PR something to fix this too. /cc @sunag |
Added a few feedback and did some cleanup. It should be good to merge @sunag 😊 By the way I think we could easily extend this access property feature to full TSL support (for example in I quickly tried by introducing something like |
Thanks for the changes, and apologies for not addressing the formatting issues sooner. I'm also addressing some issues with Read-Only Storage Buffers, so hopefully that can get merged in today as well. |
Merging... :) |
Follow-up to #28435, with the similar purpose of allowing for the creation of storage textures with the additional read-only and read-write access modes in Chrome r124.
Changes include:
Despite the basic functionality of the pull request being complete, I've left the pull request in draft for a couple of reasons.