1859788005445414927, 1781724275159728279

This commit is contained in:
ed committed 2026-08-25 01:04:10 -04:00
1 parent 29e5757746
commit d8fd501cfa
8 files changed
+313

No files matched your search

@@ -0,0 +1,35 @@
---
title: "@KostasAAA It's a silly thing on many levels."
type: archive
source: twitter
source_url: "https://x.com/jaap_null/status/1783039982560784428"
author: "Jaap van Muijden"
handle: jaap_null
post_id: "1783039982560784428"
date: 2024-04-24
archived: 2026-08-25
draft: true
tags:
- archive
- twitter
- KostasAAA
description: "@KostasAAA It's a silly thing on many levels."
in_reply_to: ""
parent_post_id: "1781724279798686001"
---
## Source
- URL: https://x.com/jaap_null/status/1783039982560784428
- Author: Jaap van Muijden (@jaap_null)
- Posted: 2024-04-24 07:47:13
## Branch
**1/**
@KostasAAA It's a silly thing on many levels. The entire arch. limitation is awkward, then the way compilers deal (or not deal) with it is just broken. Sad to see it's still around.
## Related
- Spine: [[archive/threads/KostasAAA/2024-04-20-when-using-arrays-of-resources-bindless-its-worth]]
@@ -0,0 +1,39 @@
---
title: "@KostasAAA What's the value of shaderSampledImageArrayDynamicIndexing?"
type: archive
source: twitter
source_url: "https://x.com/matiasgoldberg/status/1783166450733113360"
author: "Matías N. Goldberg"
handle: matiasgoldberg
post_id: "1783166450733113360"
date: 2024-04-24
archived: 2026-08-25
draft: true
tags:
- archive
- twitter
- KostasAAA
description: "@KostasAAA What's the value of shaderSampledImageArrayDynamicIndexing?"
in_reply_to: ""
parent_post_id: "1781724279798686001"
---
## Source
- URL: https://x.com/matiasgoldberg/status/1783166450733113360
- Author: Matías N. Goldberg (@matiasgoldberg)
- Posted: 2024-04-24 16:09:46
## Branch
**1/**
@KostasAAA What's the value of shaderSampledImageArrayDynamicIndexing?
I'm seeing an alarming number of reports (93%!!!) saying this is true, when that'd be a blatant lie.
https://vulkan.gpuinfo.org/listdevicescoverage.php?feature=shaderSampledImageArrayDynamicIndexing&platform=all
## Related
- Spine: [[archive/threads/KostasAAA/2024-04-20-when-using-arrays-of-resources-bindless-its-worth]]
@@ -0,0 +1,44 @@
---
title: "When using arrays of resources/bindless, it's worth paying attention to index divergence."
type: archive
source: twitter
source_url: "https://x.com/KostasAAA/status/1781724275159728279"
author: "Kostas Anagnostou"
handle: KostasAAA
post_id: "1781724275159728279"
date: 2024-04-20
archived: 2026-08-25
draft: true
tags:
- archive
- twitter
- KostasAAA
description: "When using arrays of resources/bindless, it's worth paying attention to index divergence."
in_reply_to: ""
---
## Source
- URL: https://x.com/KostasAAA/status/1781724275159728279
- Author: Kostas Anagnostou (@KostasAAA)
- Posted: 2024-04-20 16:39:04
## Thread
**1/**
When using arrays of resources/bindless, it's worth paying attention to index divergence. Even if using thread divergent indices, the compiler will use the index from the first active thread to access a resource, for all threads in the wave, which can cause hard to find bugs 1/3
![](https://pbs.twimg.com/media/GLnsaWeWoAA0c-x?format=jpg&name=orig)
**2/**
This happens even when compiler knows that the index varies per thread. To fix this you need to use the NonUniformResourceIndex qualifier. The compiler will then add a waterfall loop to batch wave threads by resource index and ensure that each thread accesses the correct one. 2/3
![](https://pbs.twimg.com/media/GLntvM6W0AEVe0L?format=jpg&name=orig)
**3/**
This can have a performance impact though, with the worst case being each thread indexing a different resource, both in terms of thread coherence (looping over each thread individually) and texture cache. For more info https://www.asawicki.info/news_1734_which_values_are_scalar_in_a_shader 3/3
Branches: [[archive/threads/KostasAAA/2024-04-20-when-using-arrays-of-resources-bindless-its-worth/2024-04-24-jaap_null-its-a-silly-thing-on-many-levels-the-entire-arch]], [[archive/threads/KostasAAA/2024-04-20-when-using-arrays-of-resources-bindless-its-worth/2024-04-24-matiasgoldberg-whats-the-value-of]]
+12
View File
@@ -0,0 +1,12 @@
---
title: KostasAAA
type: note
draft: false
description: Archived threads by KostasAAA.
tags:
- archive
- twitter
- KostasAAA
---
- [[archive/threads/KostasAAA/2024-04-20-when-using-arrays-of-resources-bindless-its-worth]]
@@ -0,0 +1,107 @@
---
title: "@NOTimothyLottes Shouldn’t uniform be a scalar?"
type: archive
source: twitter
source_url: "https://x.com/AgileJebrim/status/1859792525218988305"
author: "Jebrim"
handle: AgileJebrim
post_id: "1859792525218988305"
date: 2024-11-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Shouldn’t uniform be a scalar?"
in_reply_to: ""
parent_post_id: "1859791162091110754"
---
## Source
- URL: https://x.com/AgileJebrim/status/1859792525218988305
- Author: Jebrim (@AgileJebrim)
- Posted: 2024-11-22 02:54:25
## Branch
**1/**
@NOTimothyLottes Shouldn’t uniform be a scalar?
**2/**
@AgileJebrim Well 'uniform' in GLSL is a storage qualifier, "Uniforms are so named because they DO NOT CHANGE from one shader invocation to the next within a particular rendering cal" so you probably want another term for SGPR to avoid aliasing qualifiers
**3/**
@NOTimothyLottes Within ISPC, uniform means scalar and varying means vector.
**4/**
@NOTimothyLottes Looking deeper into the definition of SGPRs. They’re uniform just across each wavefront, rather than the entire dispatch yeah?
**5/**
@AgileJebrim Yes it's a separate register file and logic unit that is per-wave instead of per-lane. Since it's introduction in Turing, NV calls them "URX for uniform registers" while AMD calls them SGPRs (scalar general purpose registers)
**6/**
@NOTimothyLottes Almost sounding like we need an alternative IR to SPIR-V. One with predicated instructions and these wavefront-uniform registers/instructions. Maybe a PTX -> RDNA backend compiler?
**7/**
@AgileJebrim As history goes, most re-writes fall into nearly the same problem as before. I'd rather have the fixes be applied to the existing stuff first (fix SPIR-V and GLSL, etc)
**8/**
@NOTimothyLottes Perhaps. That existing PTX Vulkan extension does come to mind though.
**9/**
@AgileJebrim @NOTimothyLottes Its kinda annoying to put sgpr like logic in an ir tho as they have very specific limitations on each platform.
Generalizing them in an ir might actually be a pessimisation.
**10/**
@AgileJebrim @NOTimothyLottes Amd for example can't do float ops on sgprs, so when you would allow float ops in the ir, amd has to move them to a vgpr, perform float op, move them back to sgpr for each ir-sgpr float op.
There are other examples for this.
And nvidias have even other constrains.
**11/**
@CodePotrick @NOTimothyLottes And what’s the alternative right now? Just keep it all in a VGPR all the time?
**12/**
@AgileJebrim @NOTimothyLottes Ideally you'd avoid any float ops as long as you can to keep things in sgprs if you need to save registers/want the uniformity.
If you need float ops on that var its probably best to keep it in vgprs if the alternative would be to transfer between sgpr and vgpr a lot
**13/**
@CodePotrick @NOTimothyLottes I wish I could work solely with integers all the time but if I did that on NV hardware, I’d be losing half the available ALUs.
**14/**
@CodePotrick @NOTimothyLottes I haven’t looked closely at AMD hardware since I don’t work with it much.
**15/**
@AgileJebrim @NOTimothyLottes they have their actual isa public and inspectable which is really nice to know whats actually happening.
Rga is also really good. Feels like im more in control with amd compared to nvidia.
Maybe thats just the low level gremlin in my speaking tho ;).
**16/**
@CodePotrick @NOTimothyLottes I do have access to some of NVIDIA’s NDA documentation and tools…
## Related
- Spine: [[archive/threads/NOTimothyLottes/2024-11-22-sometimes-you-only-want-to-wave-coherent-branch]]
@@ -0,0 +1,74 @@
---
title: "Sometimes you only want to wave-coherent branch to something extremely rarely."
type: archive
source: twitter
source_url: "https://x.com/NOTimothyLottes/status/1859788005445414927"
author: "NOTimothyLottes"
handle: NOTimothyLottes
post_id: "1859788005445414927"
date: 2024-11-22
archived: 2026-08-25
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "Sometimes you only want to wave-coherent branch to something extremely rarely."
in_reply_to: ""
---
## Source
- URL: https://x.com/NOTimothyLottes/status/1859788005445414927
- Author: NOTimothyLottes (@NOTimothyLottes)
- Posted: 2024-11-22 02:36:28
## Thread
**1/**
Sometimes you only want to wave-coherent branch to something extremely rarely. There is no good way in GLSL to describe that. You always get one branch and one disruption of the linear path [RED]. What you want is [GREEN], common path is linear and branch-free. Gotos would enable
![](https://pbs.twimg.com/media/Gc9K3dEXIAA7tGy?format=png&name=orig)
**2/**
In theory wave-coherent branch hint and then providing say a 99% taken branch taken compile hint could enable a compiler to know how to do proper code gen here
**3/**
The other thing, if you know a path is always taken by some of the lanes, and thus on AMD you want NO branches, and instead just EXEC changing, there is no way to express that either. Doing mix(,,bool) could add extra overhead vs simple EXEC masking
**4/**
This second example is why you want to be able to mix 'always-lane-divergent' branch hint, with '50% probability' meaning the HW needs to always execute both paths, and thus use EXEC masking without physical branching (assuming a good compiler)
**5/**
Also the lack of an explicit 'scalar' (aka SGPR) qualifier on variables. The compiler gets this wrong, a qualifier just fixes that problem. Non-SGPR platforms can just ignore the qualifier. And sgpr=readlane(maybeSgpr,0) can sometimes actually become a readlane (fail)
Branches: [[archive/threads/NOTimothyLottes/2024-11-22-sometimes-you-only-want-to-wave-coherent-branch/2024-11-22-AgileJebrim-shouldnt-uniform-be-a-scalar]]
**6/**
Other big thing on AMD's PC side, the HW has all these nice SALU ops which set the SCC (scalar flags register), and there is no good way to trick the compiler to doing basic stuff like branch on SALU overflow ...
**7/**
I tried using GLSL's uaddCarry() but it at the time pushed the whole operation from SALU back to VALU making the code extra horrible, and uaddCarry() and friends = basic fail, the carry is a bool in HW not an integer, silly lack of good pattern matching there applies
**8/**
Anyway this stuff is easily fixable if people just actually cared about it. It's not like you need to scrap the API or invent a new language. Just fix what we have, and people like me will use it, and teach others how to use it well too.
**9/**
Also for obvious reasons, at least provide a PRAGMA "not-stupid" that we can place in shaders to avoid all the overhead generating crap that deoptimizes code to check for junior programmer mistakes at runtime, this stuff is bloody hard (and sometimes) impossible to bypass today
**10/**
Lets add another thing, if(subgroupElect()){} to try to make stuff SALU is broken. Because subgroupElect() will do all the overhead to find the lowest active lane (even in cases the compiler should know otherwise). And if(gl_SubgroupID==0) for that also isn't well optimized
**11/**
Maybe another time we should dive into the problems with shading languages mixing branching with loads and killing all the latency hiding. But too much for this thread...
+1
View File
@@ -32,6 +32,7 @@ tags:
- [[archive/threads/NOTimothyLottes/2024-11-16-that-line-of-thinking-is-universal-solution-to]]
- [[archive/threads/NOTimothyLottes/2024-11-19-after-vk-device-is-open-i-signal-a-background]]
- [[archive/threads/NOTimothyLottes/2024-11-21-32-oh-damn-32-should-probably-stop-now-until-next]]
- [[archive/threads/NOTimothyLottes/2024-11-22-sometimes-you-only-want-to-wave-coherent-branch]]
- [[archive/threads/NOTimothyLottes/2024-12-15-texel-buffer-is-needed-for-whatever-formats-one]]
- [[archive/threads/NOTimothyLottes/2024-12-16-also-i-wouldnt-just-modify-an-existing-compiler]]
- [[archive/threads/NOTimothyLottes/2024-12-16-then-there-are-rough-edges-to-texel-buffer]]
+1
View File
@@ -15,6 +15,7 @@ Example of the note shape (single spine, no branches): [[archive/threads/How to
- [[archive/threads/AgileJebrim]]
- [[archive/threads/FFmpeg]]
- [[archive/threads/KostasAAA]]
- [[archive/threads/NOTimothyLottes]]
- [[archive/threads/SebAaltonen]]
- [[archive/threads/VPCOMPRESSB]]