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
The request is to have an extension to support fragment shader interlock as described by VK_EXT_fragment_shader_interlock. Not all hardware can support this feature, but it opens doors together to do quite many interesting effects and operations that require pixel ordering.
This is more a more reasonable request compared to exposing shader framebuffer fetch since AMD and Nvidia hardware can support this extension but let's leave it on the backburner for now because support is pretty rare on AMD hardware since it requires a Vega GPU and up (gfx9+) ...
It's probably for the best to minimize the number of extensions in the not too distant future since it's a rather harmful feature in terms of portability ...
I don't think that is a good way forward. Just as hardware drivers software, software pushes hardware too.
OpenGL is littered with elements that are in core that started as -vendor- specific extensions. By making this and other extensions as soon as possible, WebGPU can push the API's on which it relies to have these features which in turn will push hardware vendors to implement them.
By making it an extension, it provides momentum for it to be more common place. It not being an extension means there is nothing to improve the landscape.
Reacted by Swyter, LifeIsStrange, Pengfei Li and Mike Turitzin
I do not believe WebGPU should be the place intended to push for standardizing new hardware functionality among IHVs since it's supposed to serve as a wrapper for D3D12/Vulkan/Metal. I believe a more appropriate place for that purpose would either be consulting the Khronos Group or Microsoft about this ...
OpenGL being littered with vendor specific extensions also doomed it as well so it should not be taken as a role model ...
Reacted by platonvin
Reacted by Swyter, LifeIsStrange, Pengfei Li and byyourself22
Metal as realized in iOS (I don't have a link offhand).
So, it is an extension that all the API's have, so it should be an extension in WebGPU. In additionally, on the desktop, all newish GPU's have this as well (with only AMD requiring the latest generation where as NVIDIA and Intel have had it for a few years).
[rant]
OpenGL was mostly harmed from that D3D got better than OpenGL and the ARB had too much trouble pushing out a new version of the spec when D3D10 was new and shiny. Worse, when it did push it out there was great disappointment that the cleanup of the API did not happen. That happened because of the hard requirement for backwards compatibility with pervious versions.
The other part that harmed OpenGL on desktop was that driver support was all over the map too often. Compounding it, for MS-Windows, the Direct3D API also by being part of the Win32 API brought in alot of utility stuff that made a developer's life easier.
One of the sad and ironic bits now is that on Linux and MS-Windows across all three major hardware vendors, the OpenGL drivers are pretty good now.
[/rant]
Reacted by Swyter, LifeIsStrange, Pengfei Li and Mike Turitzin
So, it is an extension that all the API's have, so it should be an extension in WebGPU.
Not good enough as I mentioned in the other thread. Need to give AMD some time for it to flourish in their hardware and the equivalent feature in Metal which is raster order groups wasn't even available on iOS until Apple's A11 GPU (2017) so it's the same deal in that case as well ...
One of the sad and ironic bits now is that on Linux and MS-Windows across all three major hardware vendors, the OpenGL drivers are pretty good now.
Wasn't true back then and it isn't now seeing as how everyone else but Nvidia are struggling to make a performant driver implementation. OpenGL is not even compatible with mobile hardware vendors so do not take that API as a reference since it takes far longer for the industry to reliably arrive at a consensus ...
Lets drop the discussion on OpenGL and the state of the drivers across the industry as it is not really relevant here (and I am sorry for brining it up at all) and it is the base of flame-wars that don't get anywhere.
[quote]
Not good enough as I mentioned in the other thread. Need to give AMD some time for it to flourish in their hardware and the equivalent feature in Metal which is raster order groups wasn't even available on iOS until Apple's A11 GPU (2017) so it's the same deal in that case as well ...
[/quote]
I think we will agree to disagree at this point. Your point of view, with which I do emphasize some, is that it needs wide spread support even as an extension; the reason being that this way all web-pages will work and web-developers can just assume. My point is that since this feature is an extension in each of the 3 API's, WebGPU should expose it as such and let web-developers choose to target it to use it or not so that they too can have the more native access as enjoyed by native development. My motivation for my point is that high-performance beautiful graphics is HARD and certain features are game changes for this. FWIW, Intel hardware has had this feature on MS-Windows OpenGL since IvyBridge, their first Direct3D 11 part, which makes the feature REALLY old.
As far as "high-performance" is concerned, it's even recommended by Nvidia in their DX12 advices that the app developer compare using ROVs to alternative approaches ...
Not only is support for this feature recent by some of the IHVs but we have another IHV implicitly shunning it's performance characteristics so I'm not comfortable at all in exposing this functionality very soon.
I'm not against exposing this feature in WebGPU but I don't believe it's the right time for it yet ...
As far as "high-performance" is concerned, it's even recommended by Nvidia in their DX12
advices that the app developer compare using ROVs to alternative approaches ...
Here is the FULL story on that and it is critical.
If an application needs the previous values, then this is the way to go (aside from framebuffer fetch). Strong emphasis on needs. The performance hit comes because it forces some serialization within a GPU. Now, for some things when an application needs this value. An easy example is funky blending not supported by the pixel-backend API (i.e. blend-ops). Without this, the only thing an application can do is to render one call at a time that does not overlap in screen space and do a memoryBarrier() OR do texture barrier OR horrifying copy from framebuffer. All options break draw calls up. The option for texture barrier is DOA on Web. Copying from the framebuffer mid-frame is DOA on tiled based renderers because they force an entire tile walk. The first option is horrifyingly bad for immediate based renderers because it triggers an entire pipeline flush. For tiled based rendering, it is just really bad because it just flushes tile-by-tile if the application does memoryBarrrierByRegion().
Given the alternatives, interlock is great and framebuffer fetch is the best. Fetch is the best because the read for tiled based renderers will come from the tile which is INSIDE the GPU and a very low cycle read. For immediate based renderers, the read from fetch is going to happen from the render cache which is also awesome.
However, interlock gives the option of skipping a write which framebuffer fetch does not, so in some circumstances it is better.
If the thing is an extension, it means not all GPU's support it and a browser can choose to or not to expose the extension even if the hardware does support it. By making it an extension, market and engineering forces can determine what happens.
AMD RX 5700, ROV off -> on (2-node):
Transparent (ms): 0.11 -> 2.18 !!!
Resolve (ms): 0.10 -> 0.07
Opaque (ms): 0.23 -> 0.19
Total (ms): 0.43 -> 2.48 !!!
Given that AMD is 10x slower for the critical section per overdraw factor, I think the idea of using interlocks should be shelved altogether and that web developers should either build per-pixel linked lists or consider exposing Vulkan-like input attachments and subpasses to take advantage of the mobile devices dedicated tile memory or pixel local storage.
If interlock is not exposed as an extension, then mobile devices dedicated tile memory or pixel local storage needs to be exposed. If one reads between the lines on those, they are essentially framebuffer fetch; that feature (atleast with OpenGL) is only exposed on desktop by Intel.
Without this feature, the only way on desktop to get a similar feature is to separate overlapping draws with a memory barrier which will be much slower than interlock.
I strongly disagree that because it is slow on AMD it should not even be exposed as an extension. Since all of the current GPU's on desktop have this extension, the extension should be available even with its performance caveats.
For my use cases, I strongly prefer framebuffer fetch, but that has much less support on desktop than interlock (though framebuffer fetch like is quite prevalent in tiled based renderers).
The best solution, in my opinion is:
Expose interlock extension if hw advertises it
Expose framebuffer fetch if hw has advertises it directly or via tile-memory or pixel local storage
Expose the GPU HW model name so applications can know what to do for their use cases.
Well Vulkan can already make use of dedicated tile memory or pixel local storage with input attachments.
APIs shouldn't just intentionally expose slow paths on certain vendors just for the sake of convenience otherwise we have disasters like OpenGL compatibility profile where users are trying to figure out why there are performance minefields on certain vendors.
You can still do programmable blending efficiently as long as applications don't express primitive ordering inside a draw call/subpass. Per-pixel linked lists are still the most optimal solution on AMD. With overlapping/intersecting draws, you're just going to have to break them down into more smaller draws and this is going to be cheap enough CPU performance wise.
Pixel local storage and dedicated tile memory are not possible on a single desktop GPU because of their nature. Period.
To do programmable blending without interlock or framebuffer fetch one of:
Draws need to be separated so that a single draw does not have any overlap
Whenever there is overlap, one needs to issue a memory barrier.
OR
Allocate a pair of offscreen texture_array whose depth is the maximum overdraw; one for color values and another for ID. Allocate another 32-bit integer surface (not array) for the atomics (32-bit is required because most hardware does not support 8 (or 16) bit atomic ops).
issue an atomic-increment, write the value to the ID surface and write the color value to the color surface
On doing the blend, for each pixel, do a sort.
One of these is what one is going to get no matter what without interlock. The first technique is guaranteed to be slower than interlock and the 2nd is not feasible for a large variety of UI scenes because of the overdraw depth might be in the tens or even higher (!).
So, advertising the HW has the feature and GPU vendor string means an application can decide what is should do rather than people on a Github thread.
Intel is going to have very strong interlock performance because of their ROP architecture. From context clues, I assume this is the vendor that you worked at, since they have been advocating for PSI across the board. NVIDIA/AMD's architectures are much less suited towards it, and on some architectures, PSI has to be emulated.
Flexible blend / ROP is one place where we haven't really settled on a great programming model. I'm not too comfortable exposing it to the web quite yet. FB fetch, on mobile architectures where it can be supported, is likely a better fit.
Intel has the smallest performance loss from interlock compared to NVIDIA and AMD (though because of its architecture it also has greater scaling issues as well).
The is my 2 cents:
FB fetch should be exposed as an extension, especially because of mobile. The general rule of thumb is the simple "if the driver exposes it, then WebGPU should as well."
Interlock should be exposed if the driver exposes it.
As far as programming model and so on. Because WebGPU is essentially just a layer (or even wrapper at times) over a native API, the programming model and semantics with respect to interlock and FB fetch are what the underlying API's dictate. Fortunately, for these two, the API's that have these features have the same jazz.
It is quite odd to not have an extension for a hardware feature that atleast 2/3 of the API's support optionally trivially. Right now, the proposed feature list of WebGPU is (essentially) GLES 3.1 with a hope/promise that it will be faster and have less hitching because it will be realized with the newer API's hen compared against Google's current work-in-progress WebGL2 + Compute. From a developer point of view, having these extensions make it much more attractive to use WebGPU. Indeed, without sufficient extension support, it is quite hard to invest time if native gives more feature possibilities (which can dramatically enhance performance) and a code base already has abstracted much of the 3D API's already.
To give an idea of how important either FB Fetch, Interlock, LocalPixelStorage or even Texture Barrier are, one need only contemplate how to implement any of the blending equation as found in GL_KHR_blend_equation_advanced_coherent . Without any of these, to implement would mean blitting from the current framebuffer to a temporary texture and then drawing. The performance impact of that on tiled based renderers is horrible-severe whereas the impact on immediate based renderers scales with how often that awful operation is done.
As an indication of how old these features already are:
The extension framebuffer fetch dates back to 2013-2014
The extension GL_ARB_fragment_shader_interlock dates back to 2015.
PixelStorage is even older dating back to 2014.
The old trusty standby for immediate renderers, TextureBarrier, dates back to GL3.x, like 10 years ago.
This request, and the ones related to it, are literally request for -extensions- that have been around already for over 4 years each (and some even longer) on the GL API. The jazz for Metal is also quite old too for its nature of local pixel storage.
It is a really hard sale to make a project making WebGPU THE target, when although it is more portable across the web, the feature exposure is much more limited than native.
I understand limiting some, but locking out interlock or FB fetch (as extensions), seems quite unwise for gaining developer traction.
To repeat: I am not advocating that that interlock or fetch are made code, only as extensions.
Honestly, if you're looking to use whatever features you desire then WebGPU is probably not suited to you and you should just favour using native APIs over it because at the end of the day it's essentially just GLES 3.x which can handle some more complex cases as you elaborated.
If you desire to bear the burden of having multiple vendor specific paths (particularly for Intel/mobile GPUs) then you should go the full way with D3D12/Metal/Vulkan because some hardware vendors aren't going to be ever convinced that interlocks or framebuffer fetch is the best way forward.
Extensions here should only be proposed with the unanimous consensus of the hardware vendors. WebGPU shouldn't be a place for a battleground where untested ideas turn out to be bad ideas in the end only for them to languish and die off in the future. WebGPU compromises new/untested features in favour of portability/compatibility to avoid a similar fate as OpenGL did where bad ideas get depreciated from time to time and it becomes a maintenance burden for the application authors to have to update their graphics code to keep up with modern hardware designs.
The extension model you propose for WebGPU is not ideal for maintenance or compatibility purposes ...
The entire point of the above was to demonstrate that these request for extensions were for features that have been available for over 4 years already. In addition, these extensions are all ARB or EXT indicating quite broad HW support. That means it is not an obscure feature or a very vendor-specific features or one that is going off to die.
As I've started before, if most the hardware and most of the API's have a means of supporting this extension, then it should be available as an extension. Moreover, each of these extensions in GL land are wither ARB (which means quite, but not complete, unanimous support) or an EXT (which indicates many HW vendors support the feature). I am not advocating any vendor specific extensions only those that already have very wide support across API's and HW vendors.
Neither FB Fetch or Interlock are ideas that are untested or going away. FB fetch is a big deal for tiled based renderers as it lets them shine in ways that immediate mode renderers cannot. Interlock allows for immediate mode renderers to do things that could not be done before without massive memory usage or much greater computation time. This is why it is optional part of D3D12, it is worth it.
Additionally, if a feature is available across all of the three targeted API's across all hardware, then that feature should be core and not an extension.
TBH, I hope Microsoft find it in themselves to just depreciate interlocks from D3D since it's not too late for them to do so before widespread proliferation of it's usage beyond just tech demos or integration into frameworks because it's just a really bad idea on AMD HW performance wise and they don't really care about memory consumption since their graphics capable devices come with 4GB+ of physical memory so no harm done there either.
In practice, Interlocks are mostly untested since there's hardly any real world applications utilizing this feature. Even 3DMark Time Spy uses PPLL over ROVs and even Nvidia doesn't like the idea of people using ROVs as well. Just because the feature has been available in other APIs for years doesn't mean it's good idea to expose it in WebGPU given it's potential.
Interlocks don't do much for immediate mode renderers like AMD and as for Nvidia, I don't think they really care that much about it either. Interlocks may as well only be ever meant for Intel HW but even then they have on-chip memory to expose framebuffer fetch.
In retrospect, I don't think exposing Interlocks was ever a good idea since two IHVs seem to have varying amounts of trouble with it. I might very well wish for it to secretly die off like how both geometry shaders/transform feedbacks did ...
Some of that which you state is quite incorrect. Lets start with the obvious one first:
Interlocks may as well only be ever meant for Intel HW but even then they have on-chip memory to expose framebuffer fetch.
This is an utterly incorrect statement hands down, Intel HW does not do tiled based rendering. The most it can be said for on-chip memory for the framebuffer is what others have as well: a render cache. Fraembuffer fetch is implemented as essentially as a special "sendc message" to fetch the value in the fraembuffer at the fragment. Internally, this probably attempts the read from the render cache. This feature was added in Gen9, most likely because Gen9 was the first Intel GPU that supported lossless renderbuffer compression and it was an easy-way to do KHR_blend_equations_advanced. The key part of it working correctly is the c in sendc which means "coherent" and essentially tells the hardware unit to wait for overlapping fragments to finish processing before doing the operation. For Intel HW, the end of every fragment shader is also a sendc message to send the fragment shader output to the pixel backend, this is why on Intel HW then FB fetch (and interlock for that matter) were not horribly more expensive: because it had to wait anyways at fragment shader end.
You utterly miss the point of Interlocks over PPLL. Interlocks provide the following benefits over PPLL:
Avoid atomic increment
Massive memory consumption savings (to use PPLL requires an Image2DArray with depth equal to maximum overdraw)
Avoid the sort at the end required by PPLL which is, to say the least, heavy code on a fragment shader. Worse, it is horribly wasteful sense it would be better to essentially sort on split-triangles (for the case of UI, it would be just sort on triangles)
Because of the need for them to draw UI's funky blend modes without truly awful things (or framebuffer fetch), interlocks are wanted and likely are not to die off.
If you want to talk performance issues for common features, then you need to open your eyes beyond just one GPU vendor. For example, bindless texturing, which is a wonderful feature, has a big overhead cost on Intel HW compared to others. No one in their right mind would say that bindless should go away and die though.
FWIW, there is a performance hit on Intel HW with interlocks and FB fetch as well and the perf-hit on NVIDIA is not so awful either (as it is on AMD). Given that one HW vendor implemented it well (and Intel at that), and NVIDIA did a reasonable job on it, I'd say it is just waiting for AMD to make a good implementation.
As features are used, there HW implementations improve and their performance improves thusly. This was the story for features that we take for granted today that we did not years ago. These features, FB fetch and interlock are already years old and quite useful.
Personally, I'd be happy with just FB fetch on mobile and interlock on desktop.
Intel HW does not do tiled based rendering. The most it can be said for on-chip memory for the framebuffer is what others have as well: a render cache. Fraembuffer fetch is implemented as essentially as a special "sendc message" to fetch the value in the fraembuffer at the fragment.
I never implied that they did tile based rendering and Gen 7.5 (Haswell) has 'sendc' as well but no framebuffer fetch and this "render cache" that you spoke of might what I've been referring to as the "on-chip memory" that's likely only available on Cherry Trail/Gen 9+ devices which seems to let them do a framebuffer fetch.
You utterly miss the point of Interlocks over PPLL. Interlocks provide the following benefits over PPLL
The benefits you stated don't look all that compelling to AMD and for Nvidia I imagine that it's a wash for them. Higher memory consumption isn't an issue to them, it's performance.
As for bindless textures, it's ideal for big data/ray tracing thus it's really only suited to desktop GPUs so there's really no point in mobile GPUs implementing or exposing it. Maybe we'll see it implemented in the next decade on mobile GPUs but even I would think that might be a stretch. I guess there's no good solution here since desktop and mobile architectures have to diverge for different purposes ...
I never implied that they did tile based rendering and Gen 7.5 (Haswell) has 'sendc' as well but no framebuffer fetch and this "render cache" that you spoke of might what I've been referring to as the "on-chip memory" that's likely only available on Cherry Trail/Gen 9+ devices which seems to let them do a framebuffer fetch.
I think this is thread has gone horribly off the rails. But let me educate you on Intel HW:
Sendc has been part of Intel HW since Gen4.
All immediate mode renderers have a render-cache for the longest of times. Lacking a render-cache is performance suicide.
The "send" is short hand for "send message" which essentially means the EU sends a message to another part of the GPU to do something. Examples include texture reads, sending color value to pixel backend at shader end, reading pull constants (for example reading from arrays with a dynamic array), all image-load-store operations. The list goes on. The command sendc means do a send, but make it coherent, i.e. waiting for overlapping pixels that come before in API order to finish before continuing.
Framebuffer fetch is realized with a particular sendc message whose function exists on Gen9+.
Gen7, IvyBridge, being a DX11/GL4 part supports image-load-store and thus supports interlock via sendc with a fence message.
Now, this next quote:
As for bindless textures, it's ideal for big data/ray tracing thus it's really only suited to desktop GPUs so there's really no point in mobile GPUs implementing or exposing it. Maybe we'll see it implemented in the next decade on mobile GPUs but even I would think that might be a stretch. I guess there's no good solution here since desktop and mobile architectures have to diverge for different purposes ...
Cough I call ignorance. So firstly, a limited form of bindless texture is on mobile, for example GL_IMG_bindless_texture. In addition, Metal (thus iOS) supports bindless and bindless is to some extent a core part of D3D12. It is only Vulkan where it is not a first class citizen in some form. Secondly, when Vulkan was being made, a fair number of ISV's were really, really wanting bindless texturing but they (sadly) did not get their way. These ISV's were not thinking on ray-tracing at that time, but just regular 3D rendering. Bindlesss has massive big use for UI rendering for example and working around the lack of bindless is quite a bit of work that carries either greater CPU load or greater GPU load or usually both.
Lastly, just because you do not see a use-case for feature X does not mean there is no use case for feature X.
Cough I call ignorance. So firstly, a limited form of bindless texture is on mobile, for example GL_IMG_bindless_texture. In addition, Metal (thus iOS) supports bindless and bindless is to some extent a core part of D3D12. It is only Vulkan where it is not a first class citizen in some form. Secondly, when Vulkan was being made, a fair number of ISV's were really, really wanting bindless texturing but they (sadly) did not get their way. These ISV's were not thinking on ray-tracing at that time, but just regular 3D rendering. Bindlesss has massive big use for UI rendering for example and working around the lack of bindless is quite a bit of work that carries either greater CPU load or greater GPU load or usually both.
You're grasping at straws here. I'm well aware of IMG_bindless_texture but that's just ONE mobile hardware vendor out of the many others and that implementation of it in itself poses TONS of limitations in comparison to doing bindless textures on desktop. As for Metal, it looks like there's some form of pointers via VK_KHR_variable_pointers which are about as powerful as OpenCL's pointers but I don't see anything like buffer references in Metal such as VK_EXT_buffer_device_address or NV_shader_buffer_load/store.
As for CPU overhead, why bother when CPU overhead is already as low as it is on the new APIs ? By itself, implementing bindless textures doesn't seem very attractive to many mobile hardware vendors so the only real compelling use case for it seems to be for ray tracing which will foreseeably be exclusive to to desktop hardware in the future ...
This is so far off the rails, but last one from me.
You're grasping at straws here. I'm well aware of IMG_bindless_texture but that's just ONE mobile hardware vendor out of the many others and that implementation of it in itself poses TONS of limitations in comparison to doing bindless textures on desktop. As for Metal, it looks like there's some form of pointers via VK_KHR_variable_pointers which are about as powerful as OpenCL's pointers but I don't see anything like buffer references in Metal such as VK_EXT_buffer_device_address or NV_shader_buffer_load/store.
That Metal (and thus iOS) has bindless texturing is quite significant with over 20% of the market share. Getting numbers across the GPU architectures on mobile is tricker, but PowerVR continues to be a big player. Bindless does NOT mean pointers necessarily (or virtual pointers like bindless-texture). It means that one does not use a binding table with very few slots. The extension IMG_bindless_texture is often just what is needed for applications: the ability to access "so many the textures" from a single API state vector and to specify to the API what textures must be resident.
As for CPU overhead, why bother when CPU overhead is already as low as it is on the new APIs ? By itself, implementing bindless textures doesn't seem very attractive to many mobile hardware vendors so the only real compelling use case for it seems to be for ray tracing which will foreseeably be exclusive to to desktop hardware in the future ...
Firstly, the new API's still have significant CPU usage if an application is switching textures between every draw and many of those draw being tiny (BTW that is what happens in UI rendering without resorting to bindless or texture atlasing). However, bindless is not just for low CPU overhead. Indeed, a typical GPU implementation has a limited number of "texture bind state vectors" allowed to be in flight. Some hardware that may even only be one, others several. The consequence is that once that number is reached additional draws are stalled until a previous draw drains out to free one of the "texture-bind-state vectors". This cost increases more and more as a GPU has more and more capability. Indeed a GPU design with only one texture-bind-state-vector allowed in flight at a time means that the pipeline has to drain completely between texture changes. It is a HW implementation "detail" how many of these are around and that detail has serious performance impacts which is avoided via bindless.
At this point, I am SO tempted to just close this. The request is valid but I have taken your bait and helped take the thread off its rails.
We return NOW to the actual discussion of the thread: Request as an EXTENSION the functionality of interlock. Your points: it has poor performance on AMD. My points: it is pretty good on some hardware (for example Intel and ok on NVIDIA) and it opens the door to doing things that save memory massively, can save bandwidth, saves lots of ALU and opens the door to doing things that are not possible with current interfaces. I iterate again, just because YOU do not see a way to use feature X, does not mean such uses do not exist.
That Metal (and thus iOS) has bindless texturing is quite significant with over 20% of the market share. Getting numbers across the GPU architectures on mobile is tricker, but PowerVR continues to be a big player. Bindless does NOT mean pointers necessarily (or virtual pointers like bindless-texture). It means that one does not use a binding table with very few slots. The extension IMG_bindless_texture is often just what is needed for applications: the ability to access "so many the textures" from a single API state vector and to specify to the API what textures must be resident.
iOS most certainly does NOT have bindless textures. If you call a texture bind limit of just 31 textures per stage on pre-A11 GPU HW (where Apple used customized PowerVR GPUs) or 96 textures on A11/12/13 GPW HW (where Apple uses their own in-house designed GPUs) to be bindless then just about every FL_11_0 GPU (pre-GCN/Kepler/Skylake) out there is more capable of bindless textures compared to Metal on iOS. IMG_bindless_texture does not even have the residency functions of the ARB variant to make the texture handles resident that you speak of ...
From what I've deduced in Metal about Apple's in-house designed GPUs, bindless texture handles is not a concept that maps to their hardware. If Apple HW truly had bindless textures like on desktop where real bindless texture handles are available then they wouldn't have given us this argument buffers/descriptor indexing/bind everything BS where non-bindless hardware is compatible with this approach.
We return NOW to the actual discussion of the thread: Request as an EXTENSION the functionality of interlock.
Yes, let's get back on track like you said. I hope it's in Google's interests to block this or at least not implement it in Dawn to defend one of their partners which is AMD because they don't have any direct representation in this group ...
going from 0.11ms to 2.11 ms with interlocks is natural if the GPU is highly parallel (you've thrown a 5700 XT with ridiculous 2560 shading units at it), and you're rendering very big alpha blended polygons (remember they have to rasterize in primitive order) into a 0.9 MPix target
MLAB/HT/AT are essentially a form of programmable blending (same problem as rendering and blending RGB9E5).
It needs pixel interlock AND framebuffer fetch in the API, simply because some GPUs implement the former while others implement the latter.
The rule of thumb I follow is that if a GPU implements both, always go with framebuffer fetch.
As far as the performance hit goes: if one has a big triangle with a "meaty" fragment shader then the framebuffer fetch and/or interlock overhead is not so bad... but if the fragment shader is borderline trivial before the fetch along with lots of overlapping pixels the the blocking will harm the performance.
Activity
Degerz commentedon Aug 9, 2019
This is more a more reasonable request compared to exposing shader framebuffer fetch since AMD and Nvidia hardware can support this extension but let's leave it on the backburner for now because support is pretty rare on AMD hardware since it requires a Vega GPU and up (gfx9+) ...
krogovin commentedon Aug 9, 2019
Lets make this an extension very quickly after 1.0 release. It is a game changer for some situations.
Degerz commentedon Aug 9, 2019
It's probably for the best to minimize the number of extensions in the not too distant future since it's a rather harmful feature in terms of portability ...
krogovin commentedon Aug 9, 2019
I don't think that is a good way forward. Just as hardware drivers software, software pushes hardware too.
OpenGL is littered with elements that are in core that started as -vendor- specific extensions. By making this and other extensions as soon as possible, WebGPU can push the API's on which it relies to have these features which in turn will push hardware vendors to implement them.
By making it an extension, it provides momentum for it to be more common place. It not being an extension means there is nothing to improve the landscape.
Degerz commentedon Aug 9, 2019
I do not believe WebGPU should be the place intended to push for standardizing new hardware functionality among IHVs since it's supposed to serve as a wrapper for D3D12/Vulkan/Metal. I believe a more appropriate place for that purpose would either be consulting the Khronos Group or Microsoft about this ...
OpenGL being littered with vendor specific extensions also doomed it as well so it should not be taken as a role model ...
krogovin commentedon Aug 9, 2019
For interlock, each of the targeted API's have this as extension:
So, it is an extension that all the API's have, so it should be an extension in WebGPU. In additionally, on the desktop, all newish GPU's have this as well (with only AMD requiring the latest generation where as NVIDIA and Intel have had it for a few years).
[rant]
OpenGL was mostly harmed from that D3D got better than OpenGL and the ARB had too much trouble pushing out a new version of the spec when D3D10 was new and shiny. Worse, when it did push it out there was great disappointment that the cleanup of the API did not happen. That happened because of the hard requirement for backwards compatibility with pervious versions.
The other part that harmed OpenGL on desktop was that driver support was all over the map too often. Compounding it, for MS-Windows, the Direct3D API also by being part of the Win32 API brought in alot of utility stuff that made a developer's life easier.
One of the sad and ironic bits now is that on Linux and MS-Windows across all three major hardware vendors, the OpenGL drivers are pretty good now.
[/rant]
Degerz commentedon Aug 9, 2019
Not good enough as I mentioned in the other thread. Need to give AMD some time for it to flourish in their hardware and the equivalent feature in Metal which is raster order groups wasn't even available on iOS until Apple's A11 GPU (2017) so it's the same deal in that case as well ...
Wasn't true back then and it isn't now seeing as how everyone else but Nvidia are struggling to make a performant driver implementation. OpenGL is not even compatible with mobile hardware vendors so do not take that API as a reference since it takes far longer for the industry to reliably arrive at a consensus ...
krogovin commentedon Aug 9, 2019
Lets drop the discussion on OpenGL and the state of the drivers across the industry as it is not really relevant here (and I am sorry for brining it up at all) and it is the base of flame-wars that don't get anywhere.
[quote]
Not good enough as I mentioned in the other thread. Need to give AMD some time for it to flourish in their hardware and the equivalent feature in Metal which is raster order groups wasn't even available on iOS until Apple's A11 GPU (2017) so it's the same deal in that case as well ...
[/quote]
I think we will agree to disagree at this point. Your point of view, with which I do emphasize some, is that it needs wide spread support even as an extension; the reason being that this way all web-pages will work and web-developers can just assume. My point is that since this feature is an extension in each of the 3 API's, WebGPU should expose it as such and let web-developers choose to target it to use it or not so that they too can have the more native access as enjoyed by native development. My motivation for my point is that high-performance beautiful graphics is HARD and certain features are game changes for this. FWIW, Intel hardware has had this feature on MS-Windows OpenGL since IvyBridge, their first Direct3D 11 part, which makes the feature REALLY old.
Degerz commentedon Aug 9, 2019
As far as "high-performance" is concerned, it's even recommended by Nvidia in their DX12 advices that the app developer compare using ROVs to alternative approaches ...
Not only is support for this feature recent by some of the IHVs but we have another IHV implicitly shunning it's performance characteristics so I'm not comfortable at all in exposing this functionality very soon.
I'm not against exposing this feature in WebGPU but I don't believe it's the right time for it yet ...
krogovin commentedon Aug 9, 2019
Here is the FULL story on that and it is critical.
If an application needs the previous values, then this is the way to go (aside from framebuffer fetch). Strong emphasis on needs. The performance hit comes because it forces some serialization within a GPU. Now, for some things when an application needs this value. An easy example is funky blending not supported by the pixel-backend API (i.e. blend-ops). Without this, the only thing an application can do is to render one call at a time that does not overlap in screen space and do a memoryBarrier() OR do texture barrier OR horrifying copy from framebuffer. All options break draw calls up. The option for texture barrier is DOA on Web. Copying from the framebuffer mid-frame is DOA on tiled based renderers because they force an entire tile walk. The first option is horrifyingly bad for immediate based renderers because it triggers an entire pipeline flush. For tiled based rendering, it is just really bad because it just flushes tile-by-tile if the application does memoryBarrrierByRegion().
Given the alternatives, interlock is great and framebuffer fetch is the best. Fetch is the best because the read for tiled based renderers will come from the tile which is INSIDE the GPU and a very low cycle read. For immediate based renderers, the read from fetch is going to happen from the render cache which is also awesome.
However, interlock gives the option of skipping a write which framebuffer fetch does not, so in some circumstances it is better.
If the thing is an extension, it means not all GPU's support it and a browser can choose to or not to expose the extension even if the hardware does support it. By making it an extension, market and engineering forces can determine what happens.
Degerz commentedon Aug 30, 2019
After having seen some numbers collected on AMD HW I'm going to have to protest this idea ...
Sample: https://software.intel.com/en-us/articles/oit-approximation-with-pixel-synchronization
Code: https://github.com/GameTechDev/AOIT-Update
AMD RX 5700, ROV off -> on (2-node):
Transparent (ms): 0.11 -> 2.18 !!!
Resolve (ms): 0.10 -> 0.07
Opaque (ms): 0.23 -> 0.19
Total (ms): 0.43 -> 2.48 !!!
Given that AMD is 10x slower for the critical section per overdraw factor, I think the idea of using interlocks should be shelved altogether and that web developers should either build per-pixel linked lists or consider exposing Vulkan-like input attachments and subpasses to take advantage of the mobile devices dedicated tile memory or pixel local storage.
krogovin commentedon Aug 30, 2019
If interlock is not exposed as an extension, then mobile devices dedicated tile memory or pixel local storage needs to be exposed. If one reads between the lines on those, they are essentially framebuffer fetch; that feature (atleast with OpenGL) is only exposed on desktop by Intel.
Without this feature, the only way on desktop to get a similar feature is to separate overlapping draws with a memory barrier which will be much slower than interlock.
I strongly disagree that because it is slow on AMD it should not even be exposed as an extension. Since all of the current GPU's on desktop have this extension, the extension should be available even with its performance caveats.
For my use cases, I strongly prefer framebuffer fetch, but that has much less support on desktop than interlock (though framebuffer fetch like is quite prevalent in tiled based renderers).
The best solution, in my opinion is:
Degerz commentedon Aug 30, 2019
Well Vulkan can already make use of dedicated tile memory or pixel local storage with input attachments.
APIs shouldn't just intentionally expose slow paths on certain vendors just for the sake of convenience otherwise we have disasters like OpenGL compatibility profile where users are trying to figure out why there are performance minefields on certain vendors.
You can still do programmable blending efficiently as long as applications don't express primitive ordering inside a draw call/subpass. Per-pixel linked lists are still the most optimal solution on AMD. With overlapping/intersecting draws, you're just going to have to break them down into more smaller draws and this is going to be cheap enough CPU performance wise.
krogovin commentedon Aug 30, 2019
Sighs.
Pixel local storage and dedicated tile memory are not possible on a single desktop GPU because of their nature. Period.
To do programmable blending without interlock or framebuffer fetch one of:
OR
One of these is what one is going to get no matter what without interlock. The first technique is guaranteed to be slower than interlock and the 2nd is not feasible for a large variety of UI scenes because of the overdraw depth might be in the tens or even higher (!).
So, advertising the HW has the feature and GPU vendor string means an application can decide what is should do rather than people on a Github thread.
3 remaining items
magcius commentedon Aug 31, 2019
Intel is going to have very strong interlock performance because of their ROP architecture. From context clues, I assume this is the vendor that you worked at, since they have been advocating for PSI across the board. NVIDIA/AMD's architectures are much less suited towards it, and on some architectures, PSI has to be emulated.
Flexible blend / ROP is one place where we haven't really settled on a great programming model. I'm not too comfortable exposing it to the web quite yet. FB fetch, on mobile architectures where it can be supported, is likely a better fit.
krogovin commentedon Sep 2, 2019
Intel has the smallest performance loss from interlock compared to NVIDIA and AMD (though because of its architecture it also has greater scaling issues as well).
The is my 2 cents:
As far as programming model and so on. Because WebGPU is essentially just a layer (or even wrapper at times) over a native API, the programming model and semantics with respect to interlock and FB fetch are what the underlying API's dictate. Fortunately, for these two, the API's that have these features have the same jazz.
It is quite odd to not have an extension for a hardware feature that atleast 2/3 of the API's support optionally trivially. Right now, the proposed feature list of WebGPU is (essentially) GLES 3.1 with a hope/promise that it will be faster and have less hitching because it will be realized with the newer API's hen compared against Google's current work-in-progress WebGL2 + Compute. From a developer point of view, having these extensions make it much more attractive to use WebGPU. Indeed, without sufficient extension support, it is quite hard to invest time if native gives more feature possibilities (which can dramatically enhance performance) and a code base already has abstracted much of the 3D API's already.
To give an idea of how important either FB Fetch, Interlock, LocalPixelStorage or even Texture Barrier are, one need only contemplate how to implement any of the blending equation as found in GL_KHR_blend_equation_advanced_coherent . Without any of these, to implement would mean blitting from the current framebuffer to a temporary texture and then drawing. The performance impact of that on tiled based renderers is horrible-severe whereas the impact on immediate based renderers scales with how often that awful operation is done.
As an indication of how old these features already are:
This request, and the ones related to it, are literally request for -extensions- that have been around already for over 4 years each (and some even longer) on the GL API. The jazz for Metal is also quite old too for its nature of local pixel storage.
It is a really hard sale to make a project making WebGPU THE target, when although it is more portable across the web, the feature exposure is much more limited than native.
I understand limiting some, but locking out interlock or FB fetch (as extensions), seems quite unwise for gaining developer traction.
To repeat: I am not advocating that that interlock or fetch are made code, only as extensions.
Degerz commentedon Sep 2, 2019
Honestly, if you're looking to use whatever features you desire then WebGPU is probably not suited to you and you should just favour using native APIs over it because at the end of the day it's essentially just GLES 3.x which can handle some more complex cases as you elaborated.
If you desire to bear the burden of having multiple vendor specific paths (particularly for Intel/mobile GPUs) then you should go the full way with D3D12/Metal/Vulkan because some hardware vendors aren't going to be ever convinced that interlocks or framebuffer fetch is the best way forward.
Extensions here should only be proposed with the unanimous consensus of the hardware vendors. WebGPU shouldn't be a place for a battleground where untested ideas turn out to be bad ideas in the end only for them to languish and die off in the future. WebGPU compromises new/untested features in favour of portability/compatibility to avoid a similar fate as OpenGL did where bad ideas get depreciated from time to time and it becomes a maintenance burden for the application authors to have to update their graphics code to keep up with modern hardware designs.
The extension model you propose for WebGPU is not ideal for maintenance or compatibility purposes ...
krogovin commentedon Sep 3, 2019
The entire point of the above was to demonstrate that these request for extensions were for features that have been available for over 4 years already. In addition, these extensions are all ARB or EXT indicating quite broad HW support. That means it is not an obscure feature or a very vendor-specific features or one that is going off to die.
As I've started before, if most the hardware and most of the API's have a means of supporting this extension, then it should be available as an extension. Moreover, each of these extensions in GL land are wither ARB (which means quite, but not complete, unanimous support) or an EXT (which indicates many HW vendors support the feature). I am not advocating any vendor specific extensions only those that already have very wide support across API's and HW vendors.
Neither FB Fetch or Interlock are ideas that are untested or going away. FB fetch is a big deal for tiled based renderers as it lets them shine in ways that immediate mode renderers cannot. Interlock allows for immediate mode renderers to do things that could not be done before without massive memory usage or much greater computation time. This is why it is optional part of D3D12, it is worth it.
Additionally, if a feature is available across all of the three targeted API's across all hardware, then that feature should be core and not an extension.
Degerz commentedon Sep 3, 2019
TBH, I hope Microsoft find it in themselves to just depreciate interlocks from D3D since it's not too late for them to do so before widespread proliferation of it's usage beyond just tech demos or integration into frameworks because it's just a really bad idea on AMD HW performance wise and they don't really care about memory consumption since their graphics capable devices come with 4GB+ of physical memory so no harm done there either.
In practice, Interlocks are mostly untested since there's hardly any real world applications utilizing this feature. Even 3DMark Time Spy uses PPLL over ROVs and even Nvidia doesn't like the idea of people using ROVs as well. Just because the feature has been available in other APIs for years doesn't mean it's good idea to expose it in WebGPU given it's potential.
Interlocks don't do much for immediate mode renderers like AMD and as for Nvidia, I don't think they really care that much about it either. Interlocks may as well only be ever meant for Intel HW but even then they have on-chip memory to expose framebuffer fetch.
In retrospect, I don't think exposing Interlocks was ever a good idea since two IHVs seem to have varying amounts of trouble with it. I might very well wish for it to secretly die off like how both geometry shaders/transform feedbacks did ...
krogovin commentedon Sep 3, 2019
Some of that which you state is quite incorrect. Lets start with the obvious one first:
This is an utterly incorrect statement hands down, Intel HW does not do tiled based rendering. The most it can be said for on-chip memory for the framebuffer is what others have as well: a render cache. Fraembuffer fetch is implemented as essentially as a special "sendc message" to fetch the value in the fraembuffer at the fragment. Internally, this probably attempts the read from the render cache. This feature was added in Gen9, most likely because Gen9 was the first Intel GPU that supported lossless renderbuffer compression and it was an easy-way to do KHR_blend_equations_advanced. The key part of it working correctly is the c in sendc which means "coherent" and essentially tells the hardware unit to wait for overlapping fragments to finish processing before doing the operation. For Intel HW, the end of every fragment shader is also a sendc message to send the fragment shader output to the pixel backend, this is why on Intel HW then FB fetch (and interlock for that matter) were not horribly more expensive: because it had to wait anyways at fragment shader end.
You utterly miss the point of Interlocks over PPLL. Interlocks provide the following benefits over PPLL:
Because of the need for them to draw UI's funky blend modes without truly awful things (or framebuffer fetch), interlocks are wanted and likely are not to die off.
If you want to talk performance issues for common features, then you need to open your eyes beyond just one GPU vendor. For example, bindless texturing, which is a wonderful feature, has a big overhead cost on Intel HW compared to others. No one in their right mind would say that bindless should go away and die though.
FWIW, there is a performance hit on Intel HW with interlocks and FB fetch as well and the perf-hit on NVIDIA is not so awful either (as it is on AMD). Given that one HW vendor implemented it well (and Intel at that), and NVIDIA did a reasonable job on it, I'd say it is just waiting for AMD to make a good implementation.
As features are used, there HW implementations improve and their performance improves thusly. This was the story for features that we take for granted today that we did not years ago. These features, FB fetch and interlock are already years old and quite useful.
Personally, I'd be happy with just FB fetch on mobile and interlock on desktop.
Degerz commentedon Sep 3, 2019
I never implied that they did tile based rendering and Gen 7.5 (Haswell) has 'sendc' as well but no framebuffer fetch and this "render cache" that you spoke of might what I've been referring to as the "on-chip memory" that's likely only available on Cherry Trail/Gen 9+ devices which seems to let them do a framebuffer fetch.
The benefits you stated don't look all that compelling to AMD and for Nvidia I imagine that it's a wash for them. Higher memory consumption isn't an issue to them, it's performance.
As for bindless textures, it's ideal for big data/ray tracing thus it's really only suited to desktop GPUs so there's really no point in mobile GPUs implementing or exposing it. Maybe we'll see it implemented in the next decade on mobile GPUs but even I would think that might be a stretch. I guess there's no good solution here since desktop and mobile architectures have to diverge for different purposes ...
krogovin commentedon Sep 3, 2019
I think this is thread has gone horribly off the rails. But let me educate you on Intel HW:
Now, this next quote:
Cough I call ignorance. So firstly, a limited form of bindless texture is on mobile, for example GL_IMG_bindless_texture. In addition, Metal (thus iOS) supports bindless and bindless is to some extent a core part of D3D12. It is only Vulkan where it is not a first class citizen in some form. Secondly, when Vulkan was being made, a fair number of ISV's were really, really wanting bindless texturing but they (sadly) did not get their way. These ISV's were not thinking on ray-tracing at that time, but just regular 3D rendering. Bindlesss has massive big use for UI rendering for example and working around the lack of bindless is quite a bit of work that carries either greater CPU load or greater GPU load or usually both.
Lastly, just because you do not see a use-case for feature X does not mean there is no use case for feature X.
Degerz commentedon Sep 3, 2019
You're grasping at straws here. I'm well aware of IMG_bindless_texture but that's just ONE mobile hardware vendor out of the many others and that implementation of it in itself poses TONS of limitations in comparison to doing bindless textures on desktop. As for Metal, it looks like there's some form of pointers via VK_KHR_variable_pointers which are about as powerful as OpenCL's pointers but I don't see anything like buffer references in Metal such as VK_EXT_buffer_device_address or NV_shader_buffer_load/store.
As for CPU overhead, why bother when CPU overhead is already as low as it is on the new APIs ? By itself, implementing bindless textures doesn't seem very attractive to many mobile hardware vendors so the only real compelling use case for it seems to be for ray tracing which will foreseeably be exclusive to to desktop hardware in the future ...
krogovin commentedon Sep 4, 2019
This is so far off the rails, but last one from me.
That Metal (and thus iOS) has bindless texturing is quite significant with over 20% of the market share. Getting numbers across the GPU architectures on mobile is tricker, but PowerVR continues to be a big player. Bindless does NOT mean pointers necessarily (or virtual pointers like bindless-texture). It means that one does not use a binding table with very few slots. The extension IMG_bindless_texture is often just what is needed for applications: the ability to access "so many the textures" from a single API state vector and to specify to the API what textures must be resident.
Firstly, the new API's still have significant CPU usage if an application is switching textures between every draw and many of those draw being tiny (BTW that is what happens in UI rendering without resorting to bindless or texture atlasing). However, bindless is not just for low CPU overhead. Indeed, a typical GPU implementation has a limited number of "texture bind state vectors" allowed to be in flight. Some hardware that may even only be one, others several. The consequence is that once that number is reached additional draws are stalled until a previous draw drains out to free one of the "texture-bind-state vectors". This cost increases more and more as a GPU has more and more capability. Indeed a GPU design with only one texture-bind-state-vector allowed in flight at a time means that the pipeline has to drain completely between texture changes. It is a HW implementation "detail" how many of these are around and that detail has serious performance impacts which is avoided via bindless.
At this point, I am SO tempted to just close this. The request is valid but I have taken your bait and helped take the thread off its rails.
We return NOW to the actual discussion of the thread: Request as an EXTENSION the functionality of interlock. Your points: it has poor performance on AMD. My points: it is pretty good on some hardware (for example Intel and ok on NVIDIA) and it opens the door to doing things that save memory massively, can save bandwidth, saves lots of ALU and opens the door to doing things that are not possible with current interfaces. I iterate again, just because YOU do not see a way to use feature X, does not mean such uses do not exist.
Degerz commentedon Sep 4, 2019
iOS most certainly does NOT have bindless textures. If you call a texture bind limit of just 31 textures per stage on pre-A11 GPU HW (where Apple used customized PowerVR GPUs) or 96 textures on A11/12/13 GPW HW (where Apple uses their own in-house designed GPUs) to be bindless then just about every FL_11_0 GPU (pre-GCN/Kepler/Skylake) out there is more capable of bindless textures compared to Metal on iOS. IMG_bindless_texture does not even have the residency functions of the ARB variant to make the texture handles resident that you speak of ...
From what I've deduced in Metal about Apple's in-house designed GPUs, bindless texture handles is not a concept that maps to their hardware. If Apple HW truly had bindless textures like on desktop where real bindless texture handles are available then they wouldn't have given us this argument buffers/descriptor indexing/bind everything BS where non-bindless hardware is compatible with this approach.
Yes, let's get back on track like you said. I hope it's in Google's interests to block this or at least not implement it in Dawn to defend one of their partners which is AMD because they don't have any direct representation in this group ...
devshgraphicsprogramming commentedon Sep 28, 2021
going from 0.11ms to 2.11 ms with interlocks is natural if the GPU is highly parallel (you've thrown a 5700 XT with ridiculous 2560 shading units at it), and you're rendering very big alpha blended polygons (remember they have to rasterize in primitive order) into a 0.9 MPix target
MLAB/HT/AT are essentially a form of programmable blending (same problem as rendering and blending RGB9E5).
It needs pixel interlock AND framebuffer fetch in the API, simply because some GPUs implement the former while others implement the latter.
krogovin commentedon Sep 28, 2021
The rule of thumb I follow is that if a GPU implements both, always go with framebuffer fetch.
As far as the performance hit goes: if one has a big triangle with a "meaty" fragment shader then the framebuffer fetch and/or interlock overhead is not so bad... but if the fragment shader is borderline trivial before the fetch along with lots of overlapping pixels the the blocking will harm the performance.