You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can source from a texture even if it is a render target BUT
To make sure the values in the target are correct, an application must issue a barrier call (which is essentially a message to a driver to flush the render and texture caches) whenever a fragment is written to that is sampled later.
One can argue that functionality like this is already available to an application via using image-load-store together with its memory barriers. However, from the point of view of a GPU implementation (and thus any driver too) there is a -big- difference very often in what happens underneath. Specifically: render targets are often much better cached and very often lossless compressed too with, more often than not, the lossless compression on a render target is understood by the sampler. In contrast, a number of desktop GPU's don't have any compression on image-load-store elements and the caching is not as efficient.
The use case, like #396, #395 and #391 is, for me, programmable blending.
Again, as an extension, as this makes less than zero sense on tiled-based renderers.
Thank you for writing down the extension request!
I'm afraid this would be quite difficult to fit into our usage model: a resource can only be in a single writable usage at a time, or in a combination of read-only usages (just like D3D12). This means that it can't be bound in a bind group inside a render pass that has it as a target.
That usage model is analogous to GL's restriction of FBO feedback loops and that is the hidden meat of the extension request, allowing for a resource to be both a write and read.
I have not checked what happen in the various APIs (D3D12, Metal and Vulkan) yet or if any of them have a barrier capability. What I'd like to do, or for someone to comment on, is which, if any, of these API's allow for this feature. If it turns out that none of them have, then this idea is dead. If only one, I don't know. If two or more, then I hope we can explore it some.
I don’t think you can do programmable blending in the general case with glTextureBarrier() because of overlapping geometry. Consider trying to render a hundred triangles on top of each other, and have the blending between the different triangles be some custom function. If the barrier is outside of the fragment shader, the intermediate results for each pixel of each overlapping triangle need to be stored somewhere so that the code after the barrier can read from those intermediate results. This means that the storage size requirements are proportional to the number of overlap in the scene, which is generally not achievable.
I don’t think you can do programmable blending in the general case with glTextureBarrier() because of overlapping geometry. Consider trying to render a hundred triangles on top of each other, and have the blending between the different triangles be some custom function.
In my use cases, I can guarantee that a single draw call has zero overlapping triangles (taking into account the depth test) AND I can also pre-compute when texture barrier is needed. I can do this, in my use cases, because I am drawing UI's. It is that use case where I need the programmable blending.
Without this, or other ways to do programmable blending, I will need to either do image-load-store (and issue memory barrier between each call) or do the horrible blit from current render target to texture instead of memory barrier.
devshgraphicsprogramming commented on Oct 28, 2019
I have not checked what happen in the various APIs (D3D12, Metal and Vulkan) yet or if any of them have a barrier capability. What I'd like to do, or for someone to comment on, is which, if any, of these API's allow for this feature.
@krogovin its in the core Vulkan API, its called subpasses and subpass dependencies.
I don’t think you can do programmable blending in the general case with glTextureBarrier() because of overlapping geometry.
You'd usually use it for stuff like depth-based fog without needing to rebind to a different FBO / introduce serialization @litherum
I did it in Build A World EDU for water without refraction, we raster the scene under water, issue a glTextureBarrier(), switch to a deferred fog shader that reads the depth buffer.
On Vulkan we'd do it via subpass inputs, and subpass by region dependency (more fine grained barrier, only barriers the resources you want and only pixel to pixel).
You could probably use this functionality for depth peeling or something similar without having to start new renderpasses (and serialize draw).
Activity
kvark commentedon Sep 19, 2019
Thank you for writing down the extension request!
I'm afraid this would be quite difficult to fit into our usage model: a resource can only be in a single writable usage at a time, or in a combination of read-only usages (just like D3D12). This means that it can't be bound in a bind group inside a render pass that has it as a target.
krogovin commentedon Sep 19, 2019
That usage model is analogous to GL's restriction of FBO feedback loops and that is the hidden meat of the extension request, allowing for a resource to be both a write and read.
I have not checked what happen in the various APIs (D3D12, Metal and Vulkan) yet or if any of them have a barrier capability. What I'd like to do, or for someone to comment on, is which, if any, of these API's allow for this feature. If it turns out that none of them have, then this idea is dead. If only one, I don't know. If two or more, then I hope we can explore it some.
litherum commentedon Sep 20, 2019
I don’t think you can do programmable blending in the general case with
glTextureBarrier()because of overlapping geometry. Consider trying to render a hundred triangles on top of each other, and have the blending between the different triangles be some custom function. If the barrier is outside of the fragment shader, the intermediate results for each pixel of each overlapping triangle need to be stored somewhere so that the code after the barrier can read from those intermediate results. This means that the storage size requirements are proportional to the number of overlap in the scene, which is generally not achievable.krogovin commentedon Sep 20, 2019
In my use cases, I can guarantee that a single draw call has zero overlapping triangles (taking into account the depth test) AND I can also pre-compute when texture barrier is needed. I can do this, in my use cases, because I am drawing UI's. It is that use case where I need the programmable blending.
Without this, or other ways to do programmable blending, I will need to either do image-load-store (and issue memory barrier between each call) or do the horrible blit from current render target to texture instead of memory barrier.
devshgraphicsprogramming commentedon Oct 28, 2019
@krogovin its in the core Vulkan API, its called subpasses and subpass dependencies.
You'd usually use it for stuff like depth-based fog without needing to rebind to a different FBO / introduce serialization @litherum
I did it in Build A World EDU for water without refraction, we raster the scene under water, issue a
glTextureBarrier(), switch to a deferred fog shader that reads the depth buffer.On Vulkan we'd do it via subpass inputs, and subpass by region dependency (more fine grained barrier, only barriers the resources you want and only pixel to pixel).
You could probably use this functionality for depth peeling or something similar without having to start new renderpasses (and serialize draw).
Update group to set in WGSL. (gpuweb#439)