webgpu icon indicating copy to clipboard operation
webgpu copied to clipboard

How to use descriptor indexing for texture?

Open yyc-git opened this issue 4 years ago • 9 comments

Now I'm implementing Path Tracer refer to your WebGPU-Path-Tracer. Your project is using array texture, but I want to use descriptor indexing to support unbound texture!

I know you have already implemet it in your dawn fork, can you give me a example to show how to use descriptor indexing with this project(webgpu node)?

Thanks very much!

yyc-git avatar Sep 17 '20 02:09 yyc-git

I'm not sure what you're referring to, do you mean this?

maierfelix avatar Sep 17 '20 08:09 maierfelix

I refer to the VK_EXT_descriptor_indexing extension, How to use it with webgpu node?

yyc-git avatar Sep 17 '20 08:09 yyc-git

I don't remember if I actually enabled this extension, why do you need unbound textures?

maierfelix avatar Sep 17 '20 08:09 maierfelix

in https://github.com/maierfelix/webgpu/issues/23#issuecomment-641824422 , you say:

the current alternative is descriptor indexing which is enabled in my fork

yyc-git avatar Sep 17 '20 08:09 yyc-git

I want to sample textures with different sizes. I don't know what's your meaning:

If you want to sample textures with different sizes, then use a plain buffer and do the texture filtering (e.g. linear) inside the shader

storage all textures with different size into one plain buffer(uniform buffer?)? how to do the texture filtering?

yyc-git avatar Sep 17 '20 08:09 yyc-git

I see, so you can use NonUniformEXT as a workaround as I did here for example. The problem is that this approach doesn't support textures of different sizes.

storage all textures with different size into one plain buffer(uniform buffer?)? how to do the texture filtering?

You can do the texture filtering yourself in the shader (though that probably looses hardware acceleration). Just search for e.g. bilinear or trilinear glsl texture filtering

maierfelix avatar Sep 17 '20 08:09 maierfelix

OK, I know how to use NonUniformEXT. Can you give some references(or the example code) to show how to do the "storage all textures with different size into one plain buffer"?

yyc-git avatar Sep 17 '20 08:09 yyc-git

There are different ways to implement it, here is an idea:

  • 1 shader array containing texture information (width, height, offset)
  • 1 shader array containing the texture data. Each texture is referenced through offset in the first shader array

Another way is to dynamically generate the shaders based on the used materials/textures which is not an uncommon practice.

maierfelix avatar Sep 17 '20 08:09 maierfelix

I understand your solution, Thanks very much~

yyc-git avatar Sep 17 '20 09:09 yyc-git