PDA

View Full Version : RayTrace\PhotonMap shader: access all textures



leffka
10-02-2015, 10:19 AM
I'm trying make RayTrace\PhotonMap on GPU and need access all resources in one shader\kernel.
As I understand currently I have following options:
-Use OpenCL 2.0+
-Use CUDA
-Use GLSL and GL_ARB_bindless_texture

CUDA and OpenCL 2.0 is mutual, nvidia supports only OpenCL 1.2.
But bindless texture supported by both AMD and nvidia.

So, if I do not want do same work twice it seems preferred way.
Unfortunately, I found that bindless texture not supported by MESA drivers and there patent issues.

My question is what best approach can be used with MESA?

GClements
10-02-2015, 06:05 PM
Do you actually need bindless texture? You have at least 16 texture units per stage, each of which can hold a 2D array texture, which adds up to a lot of data. The main limitation is that all layers of an array texture must have the same dimensions and format and the same sampler parameters (filtering/repeat modes, etc).

leffka
10-03-2015, 04:59 PM
Yes bindless textures is exact what I need, latest hardware can use all objects from within one shader and I want to use this feature.
When you do RT\PhotonMap it's very hard to decide what objects needed for current pixels and what not.

Yes, array textures is one way to "fall back", but it have also another drawback. When textures count changes - you need to reallocate all set using glTexStorage3D(GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount); (or keep additional space for new textures).
Limitations on format and size is not good too, there at least normal and diffuse textures and sizes can vary are lot.
May be better not use hardware sampling at all, keep textures in buffer and use bi-linear interpolation manually?

GClements
10-03-2015, 05:10 PM
May be better not use hardware sampling at all, keep textures in buffer and use bi-linear interpolation manually?
That assumes that you can create some kind of buffer which is large enough to hold all that data. And you still need a separate buffer for each format unless you're planning on unpacking pixel data manually.

Array textures have limitations, but they may be the only option if you can't rely upon the presence of the bindless texture extension and the amount of data involved exceeds the required minimum size for a texture buffer, UBO or SSBO.