re-render threads with user handle of reply.
This commit is contained in:
1 parent
1ceb4b1583
commit
f8380db665
515 files changed
+2042
-1496
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1588515348223254528"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @rianflo
|
||||
|
||||
@NOTimothyLottes Welcome Not Back! 🤘🏻♥️
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ in_reply_to: "1588331007622930432"
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@rianflo Vulkan: ~1500 lines of overhead (including header src, as I don't include) for complete hotrod bind-everything-only-once compute-only gfx engine. Not a fan of VK bloatware API complexity, but frankly it can be minimized, and exposes enough to do wonderfull things to the hardware.
|
||||
|
||||
|
||||
+21
-21
@@ -25,86 +25,86 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
GPU Programming Tip Line Thread /
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
[0] Normalization fail case is 'rsq(0)=INF*0=NaN', trim out intermediate INF to fix, 'normalize_safe(x){return x*min(MAX_FLOAT,rsq(dot(x,x)));}'
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
[1] PC FP16 1/denormals generates INFs which can easily eventually result in NaNs, fix positives with 'rcp(max(x,SMALLEST_NORMAL))'
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
[2] 'spirv-opt -Os' (optimize for size) is your weapon against "back-before-its-done--getting-groceries" IHV compile times
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
[3] Driver ignoring your '[[dont_unroll]]', 'int eatThisBuddy=1+/*hidden-zero*/constantBuffer.zero[0];for(i=0;i<1024;i+=eatThisBuddy){...'
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
[4] 'Ship-One-Shader' = One SPIR-V binary, use specialization constants to select shader at PSO generation time, minimizes released shader binary size
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
[5] 'Ship-One-Shader' requires 'spirv-opt -Os'
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
[6] Use signed 'mask=bitfieldExtract(int(v),bit,1)' to turn bit into all 0's or 1's mask
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
[7] On PC for AMD's native V_BFI_B32 (to select bits based on mask) use 'Bfi(int src,int ins,int mask){return (ins&mask)|(src&(~mask));}'
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
[8] Use 'bitfieldInsert(,,0,compileTimeImmediate)' hits fast V_BFI_B32 on AMD, and portable to other vendors
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
[9] AMD ONLY: clamp(a,b,c) is implemented as med3(a,b,c), so can get V_MED3_* without an extension (in a non-portable way)
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
[10] Bools as 0|1 floats '(a&b)|c' can be done via 'saturate(a*b+c)'
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
[11] Bools as 0|1 floats '!(a&b)' can be done via '(-a)*b+1.0'
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
[12] Convert INFs to NaNs via 'x*0.0+x'
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
[13] Semi-persistent workgroup opt = reusing the workgroup for more work before exit (ie processing four 8x8 tiles in a 16x16 footprint using a 64-wide group)
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
[14] Semi-persistent workgroups can be good for up to 10% perf on AMD (YMMV) ... assuming compiler doesn't fail VGPR allocation, check your disassembly
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
[15] Semi-persistent workgroups gain by keeping more local work on the same L0, by factoring out wait for store on wave exit, and better scheduling
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
[16] Merge passes to avoid round trip through DRAM, often huge wins there
|
||||
|
||||
**19/**
|
||||
**19/** @NOTimothyLottes
|
||||
|
||||
[17] Sometimes serial dependent passes can be merged into one shader to keep work in L2 for >10% gains, requires "unsafe you-shouldnt-do-that" logic that works
|
||||
|
||||
**20/**
|
||||
**20/** @NOTimothyLottes
|
||||
|
||||
[18] Proper double rate "packed" 16-bit can provides gains up to 30% depending on workload/platform (except NV)
|
||||
|
||||
**21/**
|
||||
**21/** @NOTimothyLottes
|
||||
|
||||
[19] Even without double rate 16-bit, 16-bit is the most important tool for managing register pressure problems, esp with smaller HW register limits or compiler troubles
|
||||
+1
-1
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Example of "Bind-Everything-Once" Layout Aliasing in Vulkan. Storage image format by aliased name, also bound as sampled image. Choose buffer {readonly,writeonly,volatile (read uncached),atomic} access by aliased name, as either {uint,uint4,float,float4}.
|
||||
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ in_reply_to: "1590003266129383424"
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@olson_dan If only PC vendors with open ISAs (AMD/Intel) would allow loading binary compute shaders in VK built using non-driver toolchains. If Valve enabled binary shaders on Steam Deck in Linux, that would be my new exclusive dev platform, instead of just a possible porting target
|
||||
+1
-1
@@ -25,6 +25,6 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
My prefered method of managing application data was the 'self-modifying-binary': (a.) on launch copy binary to temp file, (b.) launch temp file, (c.) exit, (d.) now temp file execution can freely modify origional binary :)
|
||||
+5
-5
@@ -25,22 +25,22 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
https://gpuopen.com/learn/rgp-1-15-enhanced-isa-view/ Nice Disasm View :) - However op latency isn't useful. Need to see multiwave instruction trace across time, colored by instruction type, enhanced with mark if wave is waiting to issue a given functional unit. Only then will great optimization be possible.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
It would also be best to see overlay of board power (because !/W is the end goal), and an overlay of exactly where there are bubbles in DRAM traffic. Because anything memory bound, the goal is to minimize DRAM bubbles. Need to see how they form dynamically over time to fix ...
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
For GPU profilers, might see say {92% ALU, 50% TEX, 21% L2}, then wonder, where is 8% I'm missing. And only way to start to understand that, is to be seeing how waves are executing instruction wise against each other. CPU-profiler-like averages per disassembly line won't cut it.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
Parallel machines can only be understood by seeing the parallel execution. I still have examples today of taking a vanila 32-bit shader (already designed to be fast) and getting 30% returns on all micro optimizations.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Lastly, side with enabling. Remember people can learn too. And there is typically super skilled people seeded at all companies that teach others how to use advanced tools when they are available.
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BrianKaris
|
||||
|
||||
@NOTimothyLottes Great to see these return. Still have any of the videos?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@BrianKaris I might, but will have to build a machine to attach the old drives. Too busy making new stuff
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BrookeHodgman
|
||||
|
||||
@NOTimothyLottes I remember watching all of these blog entries fondly ❤
|
||||
|
||||
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @Karyuutensei
|
||||
|
||||
@NOTimothyLottes Is the blog still up somewhere?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@Karyuutensei No but I have archives in pieces on old hard drives. So there is a chance I might restore it some day.
|
||||
|
||||
**3/**
|
||||
**3/** @Karyuutensei
|
||||
|
||||
@NOTimothyLottes Speaking of archives, http://archive.org has some from the blogspot here https://web.archive.org/web/20160427173127/http://timothylottes.blogspot.com/ but basically nothing from the github page :S
|
||||
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @oconnorkg
|
||||
|
||||
@NOTimothyLottes Did you write an engine called Atom? Talked about it on the http://OpenGL.org forum?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@oconnorkg There was also Atomontage or something like that by another person. I had a project called Atom, but I don't remember if I was on the OGL message board
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @won3d
|
||||
|
||||
@NOTimothyLottes I remember all those fondly. I also remembered the trick you did to batch logical draw calls with branching in the shader
|
||||
|
||||
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1653559205360553985"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @won3d
|
||||
|
||||
@NOTimothyLottes My former thesis advisor was a big proponent of forth. Apparently SunOS used forth in preboot and you could do all sorts of wacky things. He interfaced with custom compute accelerators this way. I agree that concatenantive programming languages are underexplored
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@won3d I think it is less the exact form of the language but more 'the way to make things simple' that truely important now.
|
||||
|
||||
**3/**
|
||||
**3/** @won3d
|
||||
|
||||
@NOTimothyLottes There's something about Forth-style composition that is has a very nice appeal. It really seems to marry syntax and semantics very directly (but I can appreciate it at a distance, having not done any real work in it as you have)
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1653570742762479620"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @Laxer3A
|
||||
|
||||
@NOTimothyLottes This is when I learned about your work and found it incredible. Nowadays with 4K / 8K, people are really craving for a very good shader/model to emulate as close as possible the CRT feel for arcade / old console etc. (I am serious)
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1653556990302470151"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @arm1n
|
||||
|
||||
@NOTimothyLottes Thanks for digging those up! Great stuff, very inspiring.
|
||||
|
||||
|
||||
+16
-16
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Found some of my old blogs: thread looking back an image at a time. 2007, ellipsoid l-system sprites with temporal feedback, yes temporal reprojection in 2007.
|
||||
|
||||
@@ -33,13 +33,13 @@ Found some of my old blogs: thread looking back an image at a time. 2007, ellips
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-won3d-i-remember-all-those-fondly-i-also-remembered-the]], [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-BrianKaris-great-to-see-these-return-still-have-any-of-the]], [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-Karyuutensei-is-the-blog-still-up-somewhere]], [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-BrookeHodgman-i-remember-watching-all-of-these-blog-entries]], [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-oconnorkg-did-you-write-an-engine-called-atom-talked-about]], [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-06-arm1n-thanks-for-digging-those-up-great-stuff-very]]
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
2007 particle based fluid sim mixed with spring model, this was 2D to work out ideas for later 3D implementation, rastered particle properties along particle paths into mip tree to enable high-speed collision
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
2007 crazy custom language and live editor for x86-64, color forth is like a virus of the mind, no going back once the understanding is there, and the evolutions of those ideas are ground breaking
|
||||
|
||||
@@ -47,7 +47,7 @@ Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blog
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blogs-thread-looking-back-an/2023-05-03-won3d-my-former-thesis-advisor-was-a-big-proponent-of]]
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
2010 digital photography, was compositing exposure brackets to get 16-bit tiffs with good dynamic range and did my own development tools (which had some major flaws I'd only learn about much later in life)
|
||||
|
||||
@@ -56,51 +56,51 @@ Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blog
|
||||

|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
2011 Was using temporal reprojection in my own engines for a while. Posted TSSAA source, an early TAA using viewport jitter for tri raster. I was mostly convinved this was a tech dead end due to the challenges of thin flicker. Decade+ later, and this story has a lot more to it ..
|
||||
|
||||

|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
2011 A simple GIF showing the challenges of {perceptual vs linear} filtering with temporal aliasing high frequency content with {small to large kernel windows}. No negative lobes here.
|
||||
|
||||
<video controls src="https://video.twimg.com/tweet_video/FvKi92TWcAA19un.mp4"></video>
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
2014 simple anti-aliased point based CS rendering engine with fisheye output using stocastic/stratified visiblity and GPU-side scene graph
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
2014 simple non-temporal spatial AA using rotated viewport to provide a good sample distribution with standard non-AA triangle rendering
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
2014 monochrome 120 hz laptop ray marcher desiged for VR, fixed cost trace, leaving scene with holes, temporal holefilling reprojection, faked 'lighting' using hierarchical + directional distance probing in lower LOD scene representations, was amazing to just fly around in there
|
||||
|
||||

|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
2014 was amazing how nice it was possible to get the geometry even when tracing only 1/8 the screen pixels per frame, stratified sample pattern really does wonders to neighborhood stability, no flicker at all
|
||||
|
||||

|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
2014 still distracted by custom code generation and languages, running stuff on CRTs with custom live editors (color forth like), generating binaries with ELF header generation inside the code itself
|
||||
|
||||

|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
2015 some more images inside the live fractal tracer
|
||||
|
||||
@@ -108,13 +108,13 @@ Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blog
|
||||

|
||||

|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
2015 crazy mini x86 OS project (bootloader source below), using codeless binary editor with annotation. Everyone should try generating binaries with no assembler, learn alot in the process
|
||||
|
||||

|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
2015 live realtime 120+ hz on laptop tracer now with spatial/temporal reconstruction on 1 shaded/sample per ray for 'fake' lit fog, did a lot of z based logic in the spatial/temporal reconstruction, realized later I was relying on the 120 Hz to hide perceptual artifacts
|
||||
|
||||
@@ -123,14 +123,14 @@ Branches: [[archive/threads/NOTimothyLottes/2023-05-03-found-some-of-my-old-blog
|
||||

|
||||

|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
2015 still doing the crazy custom languages and tiny OS projects. I feel like there is a real loss in computer evolution, imagine a machine with C64 simplicity that evolved to have a massively parallel vector machine. It would be amazing. It would be approachable by one person.
|
||||
|
||||

|
||||

|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
2015 did some custom CPU-side CRT shader tools for high resolution physical paper prints for someone's book. Wasn't trying to be physically accurate, but rather provide the feeling you'd get from a CRT in paper print form
|
||||
|
||||
|
||||
+39
-39
@@ -26,69 +26,69 @@ parent_post_id: "1671276990987370501"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Or for an APU, a way to have the storage device write direct to DRAM in pages setup for use on the GPU, because anything the CPU writes that the GPU reads is stuck on the strangled snooping bus or the strangled WC buffer limit on store.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
If the app tried to manage GPU memory oversubscription via these strangled CPU mappings you'd literally see many second stalls. One can only assume the kernel can do storage<->DRAM DMA for managing GPU DRAM oversubscription?
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Even if could fill VRAM in 1 sec, just 2x oversubscription of VRAM implies 1 sec delay to context switch (assuming 2 apps accessing all meM). So classic VM multitasking is useless. Only single app focus model with pinned memory makes any useful sense. Release pin on focus change.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
The trend is massive res massive VRAM paired with tiny IO bus. So the case for pinned memory and bus master transfers only grows importance as things evolve.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Back to SteamDeck numbers: GTT (HOST_VISIBLE) + USWC (non-HOST_CACHED) takes 1 sec for 1st 4 GiB BO alloc, but *30 sec* for 2nd 4 GiB alloc. Kernel driver time for memory allocation (maybe page table related) can be brutal (general comment for PCs too).
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Related, I think Chips&Cheese CPU/GPU link DMA and Compute Bandwidths are only measured to a GTT+USWC buffer (only supporting useless uncached CPU reads). Bandwidth exceeds the CPU's bus capacity, implies it is 'garlic' or GPU bus only accesses, direct to DRAM ...
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Since RADV+AMDVLK don't support user-space CPU mapped flush | invalidate, this implies the only supported mapping to read from DRAM direct is USWC (uncached R and write+combine W) ...
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Doing GPU stores to a CPU mapped GTT without USWC would be crippingly slow (limited by the snooping bus rate). But this is unfortunately the only option available for CPU read back. So if doing a shader store, it better be only a few waves and running in parallel.
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
"Use GTT because it's as fast as VRAM on the Deck", could only work if GTT+USWC, as that would be only way to get Garlic (direct to DRAM high bandwidth bus). GTT without USWC would need Onion (slow snooping bus) because AMDgpu's only no-CPU map option is for VRAM!
|
||||
|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Summary of the theory on best Steam Deck practices. This is the plan for my deck-compute-only driver too. Theory -> as in I haven't yet verified the GPU-side parts (my driver isn't that far along yet).
|
||||
|
||||

|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
Possible to do better? MAYBE! CPU readback actually has 2 problems, 1st the slow GPU-side copy (4 GiB copy via snooping bus could be almost 4 sec, but direct to DRAM via USWC might be just 160 ms). Also CPU only has 4 MiB of L3, so the majority of 4 GiB will be uncached later ...
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
Believe UC MTYPE (uncached) forces the CPU into serialized behavior. My test was single thread 8-byte/access reads. https://uops.info/html-instr/VMOVDQA_M256_YMM.html#ZEN2 Looks like Zen2 might be able to get 32-byte/access via VMOVDQA, and going multi-threaded (8 thread), that might be a 32x speed up ..
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
If so might be able to approach under a GB/s for the CPU-side part (UC multithread via VMOVDQA), which would be close enough to the non-USWC running single threaded using the cache.
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
What you'd really want here as a band-aid workaround is ability for the GPU to act as if the CPU map was USWC (so go direct to DRAM), but have the CPU map act as non-USWC, so it goes through the cache. Then some kind of hack to flush the tiny 4 MiB L3 and lower caches on the CPU.
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
CPU readback (reading and summing 8-byte) GTT without USWC:
|
||||
|
||||
@@ -98,7 +98,7 @@ CPU readback (reading and summing 8-byte) GTT without USWC:
|
||||
|
||||
Going multi-core on cached readback doesn't really help much. Proper test, parked threads waiting on futex, signal, last-1st active core timing.
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
Now CPU readback GTT+USWC
|
||||
|
||||
@@ -108,11 +108,11 @@ Now CPU readback GTT+USWC
|
||||
|
||||
So measurements match theory, going multi-core with MOVNTDQA uncached read on GTT+USWC can be made to match 1 thread GTT (without USWC)
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
Both those results above had been using a pair of 4 GiB allocations. The GTT+USWC one used one 4 GiB GTT+USWC for timing, and one 4 GiB GTT (unused). And that test suffered from a 30 sec GTT BO allocation. So something was going very wrong in the page mapping ...
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
When I rerun same test with just one 4 GiB GTT+USWC allocation, the 30 sec stall is gone, and the performance also changes:
|
||||
|
||||
@@ -122,38 +122,38 @@ Oh!
|
||||
|
||||
Perhaps there is some resource limit that kills perf if too much memory gets mapped, page faults?
|
||||
|
||||
**19/**
|
||||
**19/** @NOTimothyLottes
|
||||
|
||||
Top with thread cumulative results doesn't show anything significantly different between the 4 GiB and 8 GiB runs in terms of page faults ... suggests it must be something else
|
||||
|
||||

|
||||

|
||||
|
||||
**20/**
|
||||
**20/** @NOTimothyLottes
|
||||
|
||||
And yet there is obviously a bug in my multi-core tests, you can tell directly from the page fault numbers, only one thread is taking all the faults. So it is back to finding my coding error (fail).
|
||||
|
||||
**21/**
|
||||
**21/** @NOTimothyLottes
|
||||
|
||||
Lunch break and fixed the bug. Two runs now and leaving threads open to get TOP results. First run definitely soaks up the page faults, second run is page fault free (expected). Both around only 7 GB/s.
|
||||
|
||||

|
||||
|
||||
**22/**
|
||||
**22/** @NOTimothyLottes
|
||||
|
||||
And the 8 GiB of BO mapped, but only 4 GiB used run. The first pass gets only 1 GiB/s and the second gets 7 GiB/s. Page fault number is similar to last run, can only conclude page fault costs exploded?
|
||||
|
||||

|
||||
|
||||
**23/**
|
||||
**23/** @NOTimothyLottes
|
||||
|
||||
30 sec BO alloc time + super low bandwidth on 1st pass only (where page faults happen) suggest that Linux Kernel logic explodes in cost if too many pages are used in this way ...
|
||||
|
||||
**24/**
|
||||
**24/** @NOTimothyLottes
|
||||
|
||||
~8K faults for 512 MiB accessed / thread = 64 KiB/fault ... X86-64 has either 4 KiB or 2 MiB for page size. So not using large pages (fail). Probably mapping 16 pages per fault. Not sure if this implies anything about GPU page size (but certainly hoping it isn't 4 KiB, ouch).
|
||||
|
||||
**25/**
|
||||
**25/** @NOTimothyLottes
|
||||
|
||||
Some other very rough measured numbers of GTT+USWC with 8 cores splitting 4 GiB of BO.
|
||||
|
||||
@@ -163,11 +163,11 @@ Some other very rough measured numbers of GTT+USWC with 8 cores splitting 4 GiB
|
||||
|
||||
I think these seem plausable now (so maybe no more code bugs).
|
||||
|
||||
**26/**
|
||||
**26/** @NOTimothyLottes
|
||||
|
||||
One takeaways of all this, is that you need to pre-warm the page tables for large mapped buffers (by touching all pages) when the user isn't waiting on results. And if you are doing batch jobs that {open device, send data to GPU, get data back, close device} you are screwed!
|
||||
|
||||
**27/**
|
||||
**27/** @NOTimothyLottes
|
||||
|
||||
And lastly (maybe) comparison of GTT and GTT+USWC both 8 threads splitting streaming through 4 GiB of mapping (second pass, no page fault issues):
|
||||
|
||||
@@ -175,55 +175,55 @@ R> ~14 GiB/s (GTT) and ~7 GiB/s (GTT+USWC)
|
||||
W+R> ~14 GiB/s (GTT) and ~10 GiB/s (GTT+USWC)
|
||||
W> ~13 GiB/s (GTT) and ~15 GiB/s (GTT+USWC)
|
||||
|
||||
**28/**
|
||||
**28/** @NOTimothyLottes
|
||||
|
||||
So an alternative option summary for those who don't want the extra GPU-side GPU to CPU mapped buffer copy step.
|
||||
|
||||

|
||||
|
||||
**29/**
|
||||
**29/** @NOTimothyLottes
|
||||
|
||||
If anyone is looking to repro the 30 sec stall: amdgpu_bo_alloc() one 4 GiB GTT+USWC, then one 4 GiB GTT buffer, the second alloc causes the Deck to become unresponsive for 30 seconds
|
||||
|
||||
**30/**
|
||||
**30/** @NOTimothyLottes
|
||||
|
||||
madvise() with MADV_HUGEPAGE on mapped 4 GiB region doesn't do anything (still faults at 64 KiB granularity), and none of these MADV_{WILLNEED|POPULATE_READ|POPULATE_WRITE} have any effect either (still waits until use before faulting, causing low initial effective bandwidth)
|
||||
|
||||
**31/**
|
||||
**31/** @NOTimothyLottes
|
||||
|
||||
64KiB strided write through 4 GiB GTT+USWC (to pre-fault) costs the same as writing full 4 GiB, roughly 3 seconds. So it is quite literally massive page fault overhead for 1st access. No possible workaround found at this time for initial load time problems.
|
||||
|
||||
**32/**
|
||||
**32/** @NOTimothyLottes
|
||||
|
||||
If doing two 4 GiB GTT+USWC allocations, there is also a 30 second BO allocate cost on the 2nd one. And this makes the initial page fault cost for access to the first 4 GiB take another 30 seconds. Effectively hangs the machine for a full minute.
|
||||
|
||||
**33/**
|
||||
**33/** @NOTimothyLottes
|
||||
|
||||
Doing two 4 GiB GTT allocations (without USWC), doesn't incure any of the 30 second stalls. So that problem is specific to big USWC allocations. However the initial access page fault problem (extra 3 seconds) is there, so a 2ndary problem with just mapping lots of APU memory.
|
||||
|
||||
**34/**
|
||||
**34/** @NOTimothyLottes
|
||||
|
||||
Allocation of one 4 GiB GTT first then a 4 GiB GTT+USWC doesn't see the 30 second allocation stall. Almost like anything post a big USWC alloc is poisioned. And after mapping both, then accessing the GTT only, the 30 second time for page faulting comes back.
|
||||
|
||||
**35/**
|
||||
**35/** @NOTimothyLottes
|
||||
|
||||
Continuing from before, even if you don't map the 2nd GTT+USWC, the 30 second initial page faulting time is still there, so the act of mapping doesn't matter, simply doing the BO allocation had already doomed the Linux page management.
|
||||
|
||||
**36/**
|
||||
**36/** @NOTimothyLottes
|
||||
|
||||
Despite header docs which imply flag only works on DOMAIN_VRAM, using DOMAIN_GTT+AMDGPU_GEM_CREATE_NO_CPU_ACCESS is apparently what you want for non-mapped GTT allocations. Mapped 4 GiB GTT with 4 GiB GTT+NO_CPU, drops the initial page fault time from 30 seconds to 3 sec.
|
||||
|
||||

|
||||
|
||||
**37/**
|
||||
**37/** @DaveAirlie
|
||||
|
||||
@NOTimothyLottes the problem there is usually tiling, GPUs expect graphicy things in VRAM to be tiled in very specific ways, it's hard to have a storage device do that. Using a transfer engine that can tile/detile makes a lot more sense.
|
||||
|
||||
**38/**
|
||||
**38/** @NOTimothyLottes
|
||||
|
||||
@DaveAirlie The obvious elephant is an engine using only buffers for resource streaming and doing its own GPU-side decompression. This is practical NOW and portable too. But the lack of a bus master no-CPU direct storage transfer is a serious problem for throughput.
|
||||
|
||||
**39/**
|
||||
**39/** @NOTimothyLottes
|
||||
|
||||
@DaveAirlie See raw texture streaming (even with lossless compression) is way less interesting now given modern massive data tech direction, u want substantially better lossy compression simply to fit in launch constraints. So really, buffers are the way to go anyway :)
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1671276990987370501"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @SheriefFYI
|
||||
|
||||
@NOTimothyLottes Great thread!
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1671276990987370501"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @never_released
|
||||
|
||||
@NOTimothyLottes On Linux, NVIDIA has a very good UVM.
|
||||
|
||||
|
||||
+9
-9
@@ -25,55 +25,55 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
How about a mega thread on the mechanics of CPU/GPU communication. Using AMDgpu based timing results on the SteamDeck an example, but relating to the larger picture of PC GFX APIs like Vulkan/etc. I don't claim to know all, so experts feel free to add your wisdom :)
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Both RADV and AMDVLK: Flush/invalidate mapped memory ranges is a NOP. So bus-crossing dGPU traffic to HOST_VISIBLE is automatically snooping CPU caches. The one without HOST_CACHED, is Write+Combined [WC] on store, and Uncached [UC] on read. The one with HOST_CACHED is non-WC/UC
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
In AMDgpu (the kernel driver), likely DEVICE_LOCAL maps to AMDGPU_GEM_DOMAIN_VRAM (also the carve out on APUs) and the non-DEVICE_LOCAL maps to AMDGPU_GEM_DOMAIN_GTT
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
AMD+RADV added {DEVICE_COHERENT_BIT_AMD,
|
||||
DEVICE_UNCACHED_BIT_AMD} variations to the core 4 memory types. Likely to support GPU crash debug. But also provides a way to avoid needing to write-back (flush) GPU caches before CPU read. Likely AMDgpu kernel flag mapping below.
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
This AMDGPU_GEM_CREATE_CPU_GTT_USWC appear to toggle on WriteCombine [WC] for CPU store, and Uncached [US] for CPU reads (cases of HOST_VISIBLE without HOST_CACHED)
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
For review from https://chipsandcheese.com/2023/03/05/van-gogh-amds-steam-deck-apu/ Deck bandwidths: ~71 GB/s GPU, ~43 GB/s DMA, ~34 GB/s shader copy CPU<->GPU, ~25 GB/s CPU/CPU, and damn, brutal 0.27 GB/s CPU mapped GPU buffer reads, 0.71 GB/s CPU mapped GPU buffer writes
|
||||
|
||||

|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
And going direct to AMDgpu instead of VK on the Deck shows these kinds of bandwidths (non-DEVICE_LOCAL, HOST_VISIBLE with HOST_CACHED and without). So using Write-Combined is amazingly painful for stores.
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Implies that the choices one might make on dGPU PC don't necessarily port over to APUs at all. Another challenge: it takes almost 7 seconds to zero-fill using a 64-bit store for() loop the 8-GiB of mapped memory. Hints at why load times are such a challenge even in the best case.
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
This all hints at why PC OS derived systems are lacking in stuffing GPU VRAM. Really need some kind of bus mastered DMA (zero-copy) between non-volatile storage (disk) and GPU DRAM to avoid this CPU-touching performance tax.
|
||||
|
||||
|
||||
+2
-2
@@ -26,13 +26,13 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @SebAaltonen
|
||||
|
||||
@NOTimothyLottes Would be nice to talk a full presentation about this topic, but people want me to show cool tech and pretty pixels instead. Maybe one day.
|
||||
|
||||
I will save your image for that day (if I get approval to use it), since Twitter search is super bad.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@SebAaltonen "Approval", haha, sure it's covered under my favorite license
|
||||
|
||||
|
||||
+2
-2
@@ -26,12 +26,12 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @_spolsh
|
||||
|
||||
@NOTimothyLottes Once in a while people need to be reminded to stop the bloat, understand the machine guts and be self aware about productive process
|
||||
https://tonsky.me/blog/disenchantment/
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@_spolsh That was a fantastic read, thanks
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @domipheus
|
||||
|
||||
@NOTimothyLottes I like this, given I never write code any more.
|
||||
sadly i am still a grumpy git.
|
||||
|
||||
+2
-2
@@ -26,12 +26,12 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @leonard_coder
|
||||
|
||||
@NOTimothyLottes $4e71
|
||||
if you know, you know
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@leonard_coder ${EA, 1A, 3A, 5A, 7A, DA, or FA}
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @CodingFiend
|
||||
|
||||
@NOTimothyLottes @Jonathan_Blow i designed a language Beads, which uses a graph DB, has no memory allocation, super modular, approaches this minimalism as close as humanly possible, but billable hour / job security seeking programmers refuse to try it
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @DefenceForceOrg
|
||||
|
||||
@NOTimothyLottes Many games used to be like that, at least the ones without dynamic content, mods, etc...
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @PierreTerdiman
|
||||
|
||||
@NOTimothyLottes I was calling it "disoriented programming" just the other day.
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @SimonNordon
|
||||
|
||||
@NOTimothyLottes NOP is ideal.
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @TimSweeneyEpic
|
||||
|
||||
@NOTimothyLottes Can teach it in abstinence-only programming classes!
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @asparagiii
|
||||
|
||||
@NOTimothyLottes Looks like a koala
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @azeke1984
|
||||
|
||||
@NOTimothyLottes Best software is absense of it:
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @claudiogonzalo
|
||||
|
||||
@NOTimothyLottes c++ to √c
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @helpful_signage
|
||||
|
||||
@NOTimothyLottes Folks, they're calling it "computer oriented programming". It's where you stop trying to impress peers and just tell the computer the best way to do things
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @mike_acton
|
||||
|
||||
@NOTimothyLottes
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1674757854471806977"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @wyattscarpenter
|
||||
|
||||
@NOTimothyLottes https://github.com/wyattscarpenter/wu
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
"Nothing Oriented Programming" (NOP). Where the goal is to achieve minimal enlightenment by writing as little possible code: no dynamic memory allocation, no thousand files of glue, no includes, no objects. Write nothing, be happy. Even applied it to the logo, zero effort.
|
||||
|
||||
|
||||
+7
-7
@@ -25,38 +25,38 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
SPC: Left off with KEY and GAMEPAD input GPU-accessable. NOP design, no functions, no API, just a fixed VA address and data format to read, dead easy.
|
||||
|
||||

|
||||
|
||||

|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Wrote some console data dumping to aid in bringing up HID parsers for Deck and three generations of PlayStation controllers. Apparently XBox controllers aren't HIDs so not sure how one is supposed to access those.
|
||||
|
||||

|
||||
|
||||

|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Supporting hot plug was a bit of a mess, just trying to open devices every second. Adding open devices to an epoll. {Product, vendor} isn't enough to ID a device, too much aliasing, so I use packet size as well.
|
||||
|
||||

|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
Open devices with matching packet size get set in a bit array, and I collect up to 4 of those device outputs to sent to the GPU. Special logic to always place Steam Deck controls last to make docking work well.
|
||||
|
||||

|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
I'll have to tackle audio at some point, but I'm skipping networking for version 1. But otherwise SPC is good to move on to the next step, which is to build out the GPU side assembler & data editor. Which will be written in binary at first.
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Project is roughly 2000 lines of C at this point. With no includes. Anyone have any suggestions for hosting let me know. Source will be released.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
For anyone tuning in now, SPC is kind of like a Pico8, but instead of being a portable fantasy console, SPC turns the Steam Deck into an actual console for exclusive GPU assembly projects. The way consoles had been done before silly portability became the only focus.
|
||||
+5
-5
@@ -25,26 +25,26 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
SPC: Using 8 deep swap all aliasing same BO (image) fixes Game Mode crash with external display. Pipelined load gets to black screen in 2 ms. Takes 460 ms to allocate 4 GiB GTT video ram, 558 ms to copy 256 MiB cart from page cache to USWC (page faults), all in parallel.
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Clearing page cache to simulate a cold launch: Takes 1.5 sec to read 256 MiB from the stock SSD. This is worst case load time in desktop mode. Won't be any compile/etc after this. So literally in game at this point. Speed of light. This is how it is done.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Forgot the timing capture ... Load from SSD.
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
There are only 3 threads on load: (1.) to open X11 then spin doing present/keyboard, (2.) to open the AMDgpu device, SDMA copy after CART read, and then eventually spin doing dispatchs, (3.) one to load the CART from disk to mapped USWC GTT via read().
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Something I don't know: does read() since it's kernel- side automatically get some multi-core parallelism? Not a good idea to manually thread the read() because SSD needs linear reads to be fast. Not possible to know if the reads are page cache hits in advance either ...
|
||||
+4
-4
@@ -25,22 +25,22 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
1st SPC project: to be based on vintage 640x480 render (VGA style), +fallback to 640x240 for 15 KHz arcade CRTs (PGM-esk), and CRT shader scaling on Deck and OLED/LCD. Use mix of render pixel aspect changes, running less than 480 lines, and letter-box to keep integer Y scaling.
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
My 15 KHz CRT output path when docked is HD Fury Nano (won't do <480p) doing HDMI to VGA, with a sync combiner (to workaround GBS-C bug), into GBS-C which line drops 480p ~60Hz to 240p ~60Hz and outputs component. The 640 width gets maintained even if some CRTs cannot resolve it.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Presents issues for UI, namely that my bitmap fonts need to look good in both 480p and 240p modes, so for editor (assembler) I'm going with a font that uses right angles and designed around 2x2 stroke width, in a 8x16 (pow2) bitmap, so 640x240p still gets a readable 8x8 (below)
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
The next challenge is overscan safety, since real non-VGA CRTs will be used in development. The Y axis has an easy fix, simply keep cursor pinned in the 'safe' zone, but still print lines in the overscan area (so they can be seen when attached to non-overscan CRTs/etc too).
|
||||
@@ -25,75 +25,75 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
SPC: RDNA2 ASSEMBLER [thread] ... Did initial design plan this weekend. The aim is a GPU-side assembler+editor, building RDNA2 binary images for Steam Deck. Live edit, live data view, etc. Assembler and editor running in massive vectorized shader code.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Good reason not to use text input for assembler, instead will use a custom binary format, and treat all 32-bit words in the binary the exact same way (so massively parallel assembly step). This is parallel design 101.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Some basics: RDNA2 instructions are 1-N 32-bit words. Each of the 32-bit components have a bunch of fields. Will typically need 1-6 fields per 32-bit word, as will be joining some fields into one argument (like DLC/GLC) below.
|
||||
|
||||

|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
Could argue that MIMG has the most fields, but in practice many of those fields will be joined (see example), and I'm not likely to be using NSA encoding. So still will only need maximum 6 arguments to build a 32-bit value.
|
||||
|
||||

|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Custom editor, using a custom font, designed for vintage CRTs. Wanted 5-character symbol names for easy packing in 30-bit values. So setup a 6-bit character table. This is using a modified 'right-angle-only' font (like the one below). So some glyphs alias, and only upper case.
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Will need some kind of symbol table, what ends up providing the arguments to the rules that build the 32-bit words that comprise the final binary. The symbol indirection provides a way to name registers for example, and then change the register mapping later.
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Notice SMEM ops have 21-bit immediate offsets. I'll use 20-bits of that for an absolute positive offset from KART base. 1 MiB of easy data. The editor will relink tagged symbols that represent offsets automatically.
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Next will need a collection of rules, how to join the 6 possible symbol arguments together. Rules for example for each of the RDNA2 instruction encodings (VOPC, etc). This reduces to just a 6 entry 5-bit left shift amount associated with each argument.
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
But will need a 7th argument, hard coded to a signed 16-bit *4 relative offset as this is how RDNA2 does all it's relative branches. This will be setup inside the editor to auto relink as source is edited.
|
||||
|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Source then is simple, two 128-bit values per 32-bit word in the binary. One to select {RULE, SYMBOLS, RELATIVE BRANCH}, and another for {LABEL, COMMENT}.
|
||||
|
||||

|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
And then the source editor, shows a line per 32-bit value (so VOP3's for example would take 2 lines). So the 'assembler' is deceptively simple, but powerful enough to do everything required to generate GPU binary code. And all the opcode generation is in the data itself :)
|
||||
|
||||

|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
The editor itself will have 3 views {symbol table, rule table, source table}. The editor itself will use 2 copies of everything, so each edit, it's one entry/lane, reading prior state and updating to the new. Dead simple, dead parallel (not necessarily efficient) :)
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
Yeah, perhaps wildly alien. But for those who grew up with MOD-like trackers (like Impulse Tracker below), the interface will almost feel like home (those had simple {instrument, pattern, arangement} editors, with a very spreadsheet feel).
|
||||
|
||||
|
||||
+6
-6
@@ -26,33 +26,33 @@ parent_post_id: "1688491417109196800"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BlurBusters
|
||||
|
||||
@NOTimothyLottes Very interesting "crosstalk from voltage inversion" artifact. Some repeating patterns or flicker patterns can trigger crosstalk artifacts too. Behavior varies a lot between TN, IPS, and VA, but all of them have to alternate voltage polarity spatially and temporally.
|
||||
|
||||

|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @BlurBusters
|
||||
|
||||
@NOTimothyLottes Related reads:
|
||||
https://www.lagom.nl/lcd-test/inversion.php
|
||||
https://forums.blurbusters.com/viewtopic.php?t=7539
|
||||
http://www.techmind.org/lcd/#:~:text=Inversion
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@BlurBusters I appreciate the links. Came to the same conclusion, for LCDs when doing low scaling like 1:2x2 'CRT' emulation, I'll have to do a stylized blue noise phosphor pattern instead.
|
||||
|
||||
**4/**
|
||||
**4/** @Ak4115x
|
||||
|
||||
@NOTimothyLottes @BlurBusters "VCOM inversion" -if wasn't line2line but frame2frame that'd "flicker" instead at half the refresh rate so that's why it's preferred& there's also another peculiarity of this scheme. Worth looking into, spent a few hours afternoon,it's late evening now maybe share another time.
|
||||
|
||||
**5/**
|
||||
**5/** @BlurBusters
|
||||
|
||||
@Ak4115x @NOTimothyLottes Inversion algorithm is both spatial and temporal on all of them, regardless of spatial pattern of voltage inversion. Line to line is also frame to frame. (lines swaps voltage polarity in next frame)
|
||||
|
||||
**6/**
|
||||
**6/** @Ak4115x
|
||||
|
||||
@BlurBusters @NOTimothyLottes LCOS has singular VCOM there's no pattern to it and no such artifact.
|
||||
|
||||
|
||||
+5
-5
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
CRT emulation on LCDs can be hard. For example it's often easy to generate a pattern that causes a LCD hardware bug. NOT joking. Here is an example on the Steam Deck. The pattern in the window affects the scan (Deck scan is rotated) outside the window.
|
||||
|
||||
@@ -34,22 +34,22 @@ CRT emulation on LCDs can be hard. For example it's often easy to generate a pat
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-08-07-crt-emulation-on-lcds-can-be-hard/2023-08-10-BlurBusters-very-interesting-crosstalk-from-voltage-inversion]]
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
The actual pattern is this (it's a 2x1 pixel checker of {G,RB}).
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
The theory: Deck's 90deg scan results in {(bottom)R, G, B (top)} sub-pixel components. So could alternate {G,RB} only per pixel in a checker pattern to generate a new sub-pixel pattern at a different resolution. In this case trying for 640x400 virtual resolution.
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
For virtual pixel, shift energy into masked virtual phosphor. So 50% brightness red, would be {100%, 0%} for {in, out} of phosphor pixels. Over 50% one starts to increase non-phosphor pixels until some maximum so mask is still visible, but brightness isn't too compromised.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Of course this is done in linear, so it's energy conserving in theory. But when the panel fails, it breaks down and doesn't work. I see this problem on a bunch of different devices. My personal AMD laptop has the exact same fail case (but rotated differently).
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1692560907988029769"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @tomcr2100
|
||||
|
||||
@NOTimothyLottes i am not quite sure what do you mean by subpixel scan? do you override the normal (refresh) scanout process?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@tomcr2100 It's like "clear-type" font rendering where if you know the LCD sub-pixel configuration for the RGB components of a pixel, you can do a much better job of computing and outputing the value at the specific RGB sub-pixel element. So i'm doing this for CRT-like emulation on the Deck
|
||||
|
||||
**3/**
|
||||
**3/** @tomcr2100
|
||||
|
||||
@NOTimothyLottes just curious, i started doing something similar, but this year i have focused more on rest&recover. i went with a trilinear style aperture grill approximation, and just allow prim components to leak into the two others.
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
SPC: CRT shader on the Deck. This time not doing subpix render. Yet RGB vs BGR order matters still. One way it becomes possible to simulate even spaced aperture grill (removing scan fx), and the other more of the scan effect.
|
||||
|
||||

|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Comparing all methods (grille, bad convergence scan, subpix scan)
|
||||
|
||||
@@ -40,13 +40,13 @@ Comparing all methods (grille, bad convergence scan, subpix scan)
|
||||

|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
The non-subpix scan has 1-pixel separation of RGB (intentional bad convergence) to help hide scaling. The subpix scan uses 1/3-pixel separation (less visible misaligned convergence). Pixel as in output pixel.
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-08-18-spc-crt-shader-on-the-deck/2023-08-18-tomcr2100-i-am-not-quite-sure-what-do-you-mean-by-subpixel]]
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
The subpix version is definitely better. Because of the almost 3x doubling of scanline width detail, it just perceptually feels a lot cleaner and easier to reconstruct in the mind.
|
||||
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1692397318471926054"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @Karyuutensei
|
||||
|
||||
@NOTimothyLottes How many passes do you need to produce this result?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@Karyuutensei 1 pass: 12 fetches/outpix, in 2 batches. I use 6 gather4's to grab a 4-wide(x)2-line region for the {R,G,B} channels. Then 6 more fetches to do energy conserving computation of output for each {nearest 2 lines}x{R,G,B} channel based {intensity, position vertically on scan}.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
SPC: Last CRT shader was broken. Corrected it. It's energy conserving now, and correctly doing sub-pixel line width raster using the individual channels. Cell camera shots below at different zooms.
|
||||
|
||||
@@ -33,16 +33,16 @@ SPC: Last CRT shader was broken. Corrected it. It's energy conserving now, and c
|
||||

|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Each scan line is simulated with only 3 pixels. But you get 9 sub-pixels to play with, so that is where the quality comes from. It reaches 7/8th of the display peak brightness, this compromise was so there is always some amount of perceptual scan effect.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
The scan line thickness is adaptive proportional to linear brightness. When the scan thins out it is energy conserving and increases the thin pixel brightness to compensate. When it needs to go bright, it blooms the line. Lines have some overlap in bloom.
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-08-18-spc-last-crt-shader-was-broken/2023-08-18-Karyuutensei-how-many-passes-do-you-need-to-produce-this-result]]
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
One human perceptual reason CRTs feel like they have more contrast than they do, is because an individual scan line is super bright when in focus. So the black surround feels darker to the mind.
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1735631826427732305"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @SebAaltonen
|
||||
|
||||
@NOTimothyLottes They design one API for each separate use case instead of making general purpose flexible SIMD hardware and API for the developers to implement what ever algorithm they need. CPU side got this right. PS2 had correct design, but Nvidia choose hardware T&L for desktop :(
|
||||
|
||||
**2/**
|
||||
**2/** @SebAaltonen
|
||||
|
||||
@NOTimothyLottes I kind of understand hardware T&L back then because it was a new field and programmable hardware didn't exist. But now we have massive amount of wide SIMDs and bandwidth and big caches too. We can do better!
|
||||
|
||||
|
||||
@@ -25,106 +25,106 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
<long thread>
|
||||
Holiday GPU thoughts as a recovering pc/mobile/etc cross platform dev-holic ...
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
[0] Early STP prototypes: had standard-PC-practice multi-dispatch 32-bit version, and hyper-optimized packed-16-bit semi-persistent single-dispatch-ubershader that got L2 reuse. Optimized one was 40% faster in profiling (VK RNDA2 GPU)! Industry has huge untapped opt potential
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
[1] Even for PC, 16-bit is required for optimization because: almost double the amount of register state a shader can leverage. Holds true even when platform lacks double rate 16-bit. Top optimization is pass merging, PC went bandwidth starved. Mobile is actually ALU starved ...
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
[2] Double rate 16-bit done right, is typically good for the smaller of {30% perf, return to non-ALU bound}, can make a GPU feel at least one HW generation faster.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
[3] For PC, I'd personally draw my compatibility line where platforms support 16-bit, and only ship explicit packed 16-bit shaders instead of a separate 32-bit/16-bit shader permutation. AMD it's Vega up, for NV note Maxwell/Pascal's HFMA2: https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#maxwell-and-pascal-instruction-set
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
[4] Suggest doing dev work on a platform with great packed 16-bit support: AMD PC Vulkan on RDNA2, and don't filter through the DXC deoptimizer, so it is actually possible to see the value. Then hammer on vendors who still have spotty compiler related issues.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
[5] Gather4 is the hot optimization for packed 16-bit because data is returned in SoA form. Always explicitly pack 16-bit and alias to/from UINT32 when passing constants to shader (best to alias eight 16-bit values as uint4). Etc.
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
[6] Trick for good 16-bit is range management. Sometimes pre-scaling is needed to avoid overflow,
|
||||
and make sure to bring max values out of denormal before using rcp.
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
[7] Power is a function of data movement. "Touch it Once" is the top optimization, all the "Split it into a Graph, Pipeline Stage it" people are walking themselves towards high-power.
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
[8] Majority of GPU workloads are whole-pass serially dependent, but in practice temporally independent with exception of small localized serial dependency. If you "stick it into a frame graph" you cut off your ability to optimize.
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
[9] Resolution growth is slowing. Mobile's high DPI is beyond good enough. 8k won't be successfull because of the extra 4x scaling TAA tax, or it won't matter because people will just integer scale on scanout.
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
[10] Scaling TAA will converge to consistent higher quality over time, thus PC is likely to locally converge to 720p|1080p rendering for 4k (for high|med FPS). This implies that the industry should hit a point where large L3 can hold full render targets ...
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
[11] TAA scaling, full render targets in L3: Maybe RDNA2 128 MiB L3 was spot on actually, and RNDA3's L3 drop in capacity, and the no L3 consoles had this wrong Tracing and big nets probably need that L3 too.
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
[12] Lots of value getting a good 8x area scale for 4K 120 Hz. Yet devs won't see value until they make the non-pixel costs scale well, and move post before scaling.
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
[13] Triangles are not needed any more. Hint 8x area scaling doesn't know any connectivity. Connectivity is inferred by likeness to accumulated feedback. Shaded samples from non-triangles -> scaling TAA still works. Hint 2: scaling TAA raster is mostly just tri culling.
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
[14] TAA gets quality limited at high scaling because it can only infer correct behavior from geometry similar to what is rendered. Geometric aliasing drops too much thin geo. Fix for that is to change the standard practice, which will obsolete all black boxes.
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
[15] Stratified sampling is good for at least 2x the geo density compared to regular grid ... frame viewport jitter is end-of-life for quality.
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
[16] TAA's ability to correctly infer reprojection validity on skinned objects is crippled by lack of correct forward projection. Fixing that will break the black boxes.
|
||||
|
||||
**19/**
|
||||
**19/** @NOTimothyLottes
|
||||
|
||||
[17] Shading density will end up variable, TAA's disocclusion and convergence logic needs to be out of the black box, and deeply integrated into shading systems too (because it points where to shade more). This evolution will break all the black boxes.
|
||||
|
||||
**20/**
|
||||
**20/** @NOTimothyLottes
|
||||
|
||||
[18] Per-pixel ML people have it wrong, your net is multi-pass, all the top optimizations require less passes. Don't matter if you optimize the matrix math, power is burned in the bandwidth, and you cannot reduce your bandwidth enough to compete with the better options.
|
||||
|
||||
**21/**
|
||||
**21/** @NOTimothyLottes
|
||||
|
||||
[19] GI needs a surface shade cache, might as well object space shade at that point, which enables NUMA, which enables more HW scaling.
|
||||
|
||||
**22/**
|
||||
**22/** @NOTimothyLottes
|
||||
|
||||
[20] HW RT people had it very wrong, top optimization is non-ray-traversal ordered access. Follows: occlusion testing is neighbor-coherent, no trace, just test shared occluders. GI reduces to high frequency occlusion of some lower frequency probe domain.
|
||||
|
||||
**23/**
|
||||
**23/** @NOTimothyLottes
|
||||
|
||||
[21] HW RT's skin-all re-tree before trace won't scale ever. Only stratified visibility gets log scaling on animated geo. HW RT has no system for bounding costs, while stratified visibility does. Think out of the black box, GPU got programmability decade back now.
|
||||
|
||||
**24/**
|
||||
**24/** @NOTimothyLottes
|
||||
|
||||
[22] Love HW people, but they opt for a $ train even as it is derailing: they need to build HW, make it faster, it's what they do. But leave a trail of back-compat debris TS/ROV/GS/etc after each gfx fad. Vote with your engineering, general purpose CS, just say no to black boxes.
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-12-15-long-thread/2023-12-15-SebAaltonen-they-design-one-api-for-each-separate-use-case]]
|
||||
|
||||
**25/**
|
||||
**25/** @NOTimothyLottes
|
||||
|
||||
[23] Scaling TAAs want sparse data each frame, more like a low-frequency pixel control cage displacing a high-frequency reprojected feedback. No pixel centers any more, no need to interpolate before shading. Rather want striped data, so the cachelines group spaced-out samples ...
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1736157335058300999"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Yep put the whole game logic in a game.glsl compute shader.
|
||||
|
||||
**2/**
|
||||
**2/** @AgileJebrim
|
||||
|
||||
If doing a large open world game, set up a paging system to stream data to the GPU in tiles, particularly static data. All dynamic data should be handled on the GPU. If leveraging server, you can pass along the network packets as they are. CPU shouldn’t really be doing much for a game client. It certainly shouldn’t be varying due to scene complexity.
|
||||
|
||||
|
||||
+5
-5
@@ -26,25 +26,25 @@ parent_post_id: "1736147815829565624"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @SheriefFYI
|
||||
|
||||
@NOTimothyLottes two point six seconds?!! D3D12CreateDevice() on my machine is ~300ms..
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@SheriefFYI Yeah and that's a warm second run too. I dev on crippled laptops so when the handicaps are removed the stuff really flies.
|
||||
|
||||
**3/**
|
||||
**3/** @SheriefFYI
|
||||
|
||||
@NOTimothyLottes still that sounds like a lot, what specs / driver? Any weird vk layers loading?
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@SheriefFYI Ok, yeah just reprofiled, and it's down to 269 ms. Best part of the Win10 experience, never know what is actually happening in the background.
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @SheriefFYI
|
||||
|
||||
@NOTimothyLottes *whew* that sounds more normal
|
||||
|
||||
|
||||
+9
-9
@@ -26,17 +26,17 @@ parent_post_id: "1736154923408953499"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @VPCOMPRESSB
|
||||
|
||||
@NOTimothyLottes so you're preallocating every type of descriptor to a max count and aliasing them with various qualifiers/attributes? all that in a single memory layout?
|
||||
|
||||
if this is the case, the program identifier makes sense. you can just swap out the code, leaving the data untouched.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB I use the layout aliasing to choose things like {read-only K$ reads, vs read-write texture cache access} for buffers, for making sure GLC=1 (write through to coherent cache domain) is enabled for stores (image and buffer), as well as selecting the texel format for image access :)
|
||||
|
||||
**3/**
|
||||
**3/** @VPCOMPRESSB
|
||||
|
||||
i revisited last night.
|
||||
|
||||
@@ -48,27 +48,27 @@ i assume your code is laid in stages. each stage corresponds to a specific image
|
||||
|
||||
aliasing supports this even further, with explicit intentions for resources.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB On modern desktop GPUs it is very efficient to have everything bound all the time (bind everything once/frame). On AMD on use the descriptor is loaded into SGPRs. You only pay for what is used. And ideally group descriptors used together near so they share same cache lines.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB Merging independent shaders is then easy. Merging dependent shaders is more complex. You can both do it an unsafe way or a safe way (too long for one tweet)...
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB The unsafe way: launch a N+M sized 1D dispatch. Bank on having enough work in N such that when the dependent M starts that enough of N is finished in practice. This can work when early M depends on only early N workgroups.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB There are various safe ways. For instance if the dependent work isn't done, one can conditionally duplicate the work. Or conditionally use a fallback. Or only use the pre task if it had finished to accelerate the second, for example hierarchical empty space skipping ...
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB The challenge of course is that the obvious stuff like spin waiting isn't safe because of bad API and driver design : no forward progress guarantee (on preemption, etc)
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
@VPCOMPRESSB Quite literally they just need to put in a guarantee that workgroups with lower coords in scan order are launched first and restored first in a partial preemption restore. Then you could safely spin on work in a prior numbered workgroup
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Inspecting my old VK engines. On start I would warm all the pages. Code pages get a read, and data pages got an atomic add of a non-compiler known zero. An attempt to improve initial load time. But in the end nothing helps the 2.6 seconds or so required to just open the VK device
|
||||
|
||||
@@ -33,25 +33,25 @@ Inspecting my old VK engines. On start I would warm all the pages. Code pages ge
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-12-16-inspecting-my-old-vk-engines/2023-12-17-SheriefFYI-two-point-six-seconds-d3d12createdevice-on-my]]
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Since I almost never get crashes I forgot about this, but had written a system to auto relaunch the app on crash or special case exit. No complex error handling, just bank on fast relaunch instead.
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
The hope of single PSO in VK was scrapped because IHV compile times explode. However I did maintain single SPIR-V file, and use spec constants to choose individual shaders. The threads doing compile dump compile times and disassembly in DEV mode.
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
I'm a fan of single file applications. So when not in DEV mode the one SPIR-V file gets pulled from the EXE. Compiling PSOs is always the critical path, the moment the "bind everything once" layout is done, PSO compile goes wide on the machine.
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
"Bind-Everything-Once" in Vulkan looks like this. Bindings {1}=CPU pushing to GPU, {2}=buffer (more on that next), {3}=as UAVs, {4}=as TEX ... No binding logic at runtime ever. Access anything in the most efficient way any time.
|
||||
|
||||
@@ -59,13 +59,13 @@ I'm a fan of single file applications. So when not in DEV mode the one SPIR-V fi
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-12-16-inspecting-my-old-vk-engines/2025-08-08-VPCOMPRESSB-so-youre-preallocating-every-type-of-descriptor]]
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Did something silly but fast for buffers. Here is an example from a dummy test app. The main SSBO gets aliased as 4 structures, each with the same data accessable with four types {uint, uint4, float, float4}. So same binding layout aliasing chooses load type and K$ or V$ access.
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Literally the CPU does almost nothing. All game input gets pushed to the GPU for game logic. Some major advantages in input latency to do player logic on the GPU instead. And it's dead easy.
|
||||
|
||||
@@ -73,16 +73,16 @@ Literally the CPU does almost nothing. All game input gets pushed to the GPU for
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2023-12-16-inspecting-my-old-vk-engines/2023-12-17-AgileJebrim-yep-put-the-whole-game-logic-in-a-game-glsl]]
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
This requires context, I build programs in a hardware style, fixed resources, fixed shaders, and all logic expressed in the data itself. No code or resource variation, no runtime issues period. So another dummy program example, I can just list my resources on load in a table ...
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
Radically simplicity is how I roll personally. Easy to confuse the idea that one needs complexity to express a complex system. It's more like one needs complexity to express a complex solution -> abstractions and hierachical meta feeds on itself until tech debt freezes progess.
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
If there is anything to learn for programming, it is to be more critical of your own ideas than all else, be ruthless, trim until what is left is only what is actually required, question everything constantly.
|
||||
+3
-3
@@ -25,17 +25,17 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Working towards a public-domain release of a cleaned version of my Win32 Vulkan NV+AMD compute graphics platform. What I used last for rapid prototyping (which is also IMO fine for releasable software). Won't call it an 'Engine' because it only provides tools to hang yourself ...
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Simplified the error logger today. Memory mapped file is definitely the way to go, one atomic per message, log multiple sessions, fixed size file acts like a message ring buffer. Background thread keeps the last message updating the same line on the console (for easy debug).
|
||||
|
||||

|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Multi-session is nice, since the binary auto reloads in some cases (crash, etc), want to see why the reload happened, so don't want to clear the log. Yes, I still don't use debuggers, this logger + runtime shader recompile is all I use personally for dev work.
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1742743018929557805"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @kenpex
|
||||
|
||||
@NOTimothyLottes It's what debuggers should be. Debuggers made zero progress in the last decade, but fundamentally they patch running code... just they are limited to patch an interrupt instead of allowing us to do... anything. Even tracepoints, while nice, are a castrated version of livecode.
|
||||
|
||||
|
||||
+2
-2
@@ -25,13 +25,13 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Debug for majority-GPU-side game dev? Run-time recompile and hex viewer. If I want to see a value it is 'ramWI1.hxd[pos]=value;' (write to the memory that the hex dump reads from). Everything else is automatic, just save source and the results show up on screen. Zero's not drawn.
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
IMO this is preferred to a 'debugger'. I can fill values from all workgroups simply by placing them at different positions, etc. Can get timings via shader clock for profiling even. It is transformative in dev productivity.
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1776597200073568623"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @MartinJIFuller
|
||||
|
||||
@NOTimothyLottes @SebAaltonen A worthwhile project, knowledge well worth sharing, but is a book the right format? Perhaps yes, just thinking out loud.
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1776597200073568623"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @RickyAH
|
||||
|
||||
@NOTimothyLottes @SebAaltonen @MartinJIFuller Ha! That won’t save you from my follow
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1776597200073568623"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BenSimsTech
|
||||
|
||||
@NOTimothyLottes @SebAaltonen @MartinJIFuller Oh sick, I'm deep in optimising shaders in an AAA game for GCN hardware right now (You can probably guess the platform(s)) so this is super relevant to me. 😅
|
||||
Going to give it all a thorough read, I'm after all the GCN info I can find right now.
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ in_reply_to: "1776518700230721688"
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@MartinJIFuller @SebAaltonen On https://mastodon.gamedev.place/@NOTimothyLottes I'm collecting posts with AMD GPU disassembly dumps for a book on everything the shader compiler 'isn't doing'. Constant AMD GPU compiler perf bug SPAM is a key part of my online strategy to keep a low follower count.
|
||||
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@Nerfoxingaround @SebAaltonen It was only later when systems forced C ABI library interfaces with it's stacks and junk that things got messy and only because of the C. Then C++ happened and things got much worse. Pure ASM is easy, its interfacing with the bloat world that got hard.
|
||||
+4
-4
@@ -26,19 +26,19 @@ parent_post_id: "1857813028349128825"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @bmcnett
|
||||
|
||||
@NOTimothyLottes So each line is 63 spaces followed by a \n, and those 63 spaces get replaced by printable characters dynamically? I have long dreamed of a text format with a fixed 128 byte line width, and cache line size is gradually switching over from 64 to 128
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@bmcnett Yes fixed character[63]='\n', string fills until then or spaces out. I did 128-char once, but still sometimes use small VGA resolutions. Also written a source editor a few times with this fixed line size, makes for a very simple implementation ...
|
||||
|
||||
**3/**
|
||||
**3/** @bmcnett
|
||||
|
||||
@NOTimothyLottes Variable line width ASCII text files made a lot of sense when storage was 100KB or 100MB or 100GB, but now that it's in the terabytes, why even bother
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@bmcnett That line of thinking is universal solution to most self-inflicted problems of the modern era.
|
||||
|
||||
|
||||
+7
-7
@@ -26,32 +26,32 @@ parent_post_id: "1857805438151983120"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @datenwolf
|
||||
|
||||
@NOTimothyLottes Why the heck do you care about cache lines, if you write to a mmaped file? Of course there's overhead: TLBs aren't free. And TLBs matter… at lot in fact. When you map the file, initially the kernel marks some address space, but doesn't populate it with pages. 1/
|
||||
|
||||
**2/**
|
||||
**2/** @datenwolf
|
||||
|
||||
@NOTimothyLottes On the first write to a non-faulted page, the kernel has to find a free page in memory, associate it in the page table, all the while keeping an eye on all threads process, since changes to a process virtual address space must appear atomic. 2/
|
||||
|
||||
**3/**
|
||||
**3/** @datenwolf
|
||||
|
||||
@NOTimothyLottes Memory maps aren't free. Simple writes to a file will easily outperform and cause less overhead, than naively implemented mmaped I/O. 3/
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@datenwolf BTW, I pre-fault my mapped files. Just like I pre-fault the binary and data segments too. But sure the pre-fault could go stale. And yes TLBs are a system perf issue, but atlas you need admin priv on Windows to play 2 MiB pages for data, so it's off the table
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@datenwolf Why cacheline aligned and sized on the CPU? In theory store the entire line in a short enough timeframe and your Read-Modify-Write becomes just a Write! CPU doesn't have byte-write-mask (I think). If SW+HW is good. And threads keeping to isolated lines means no false sharing. Etc
|
||||
|
||||
**6/**
|
||||
**6/** @datenwolf
|
||||
|
||||
@NOTimothyLottes (That cacheline remark was meant rhetorically; between cache misses and page faults, a page fault will largely overshadow a cache miss in performance overhead.
|
||||
But yes, if you prefault, then that problem is mitigated.)
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
@datenwolf 'Smart' people keep trying to impose (aka force) their will on others through poor system APIs, like not being able to pre-pin pages. Good look buddy, I'll just run a background task that continuously touch walks the pages I want pinned anyway.
|
||||
|
||||
|
||||
+5
-5
@@ -26,15 +26,15 @@ parent_post_id: "1857803914604618029"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @static_assert_0
|
||||
|
||||
@NOTimothyLottes This is super cool, but why map a file and not just stdout?
|
||||
|
||||
**2/**
|
||||
**2/** @vodangkhoa873
|
||||
|
||||
@static_assert_0 @NOTimothyLottes The writes can be done concurrently from many threads?
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@vodangkhoa873 @static_assert_0 Yes, one 'atomicAdd(atomAdr,1)&65535' to get the line number (window of 65536 max lines) then write the line individually. Only contention is on that atomicAdd CPU instruction which is as minimal as possible.
|
||||
|
||||
@@ -42,11 +42,11 @@ I do the atomic add instruction using simple inline ASM (below)
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @static_assert_0
|
||||
|
||||
@NOTimothyLottes @vodangkhoa873 I love this, but are you not able to get that codegen with intrinsics or just normal C?
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@static_assert_0 @vodangkhoa873 I've been hand rolling intrinsics CPU-side in GCC with inline asm since the dawn of support for that. So haven't kept up with the high-level-lang mess fire since.
|
||||
|
||||
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1857804669994565771"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @HerrUppoHoppa
|
||||
|
||||
@NOTimothyLottes Curious why you memory map the 32 bit counter to the file. Also why does it get half the file as opposed to just the end of the mapped region?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@HerrUppoHoppa It's pow2 message lines so fixing wrap is AND(cnt,lines-1). Counter after that and needs to take a page minimum. So yes I could make the size slightly smaller, but just lazy. Counter in file because then multiple runs accumulate in the file for comparison.
|
||||
|
||||
**3/**
|
||||
**3/** @HerrUppoHoppa
|
||||
|
||||
@NOTimothyLottes Ah I see, interesting solution!
|
||||
|
||||
|
||||
+10
-10
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
[0] What a horrible term 'printf-debugging'
|
||||
If you are debugger-free might as well at least be libc-free
|
||||
@@ -33,7 +33,7 @@ Here is how I work CPU C code without any debugger in my engines, and how it wor
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-printf-debugging/2024-11-16-static_assert_0-this-is-super-cool-but-why-map-a-file-and-not]]
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
[1] First I map a '.log' file, so there is no other file IO
|
||||
(a.) First half of this file (log2 sized file) contains lines of a fixed 64-character size (with the \n at the end)
|
||||
@@ -41,17 +41,17 @@ Branches: [[archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-pr
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-printf-debugging/2024-11-17-HerrUppoHoppa-curious-why-you-memory-map-the-32-bit-counter-to]]
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
[2] So writing a line to this log is 100% overhead-free and lock-free, one just increments the atomic counter, and dumps the comment line in the memory mapped file. Note the 64-byte line size matches a cacheline size, so no contention on the write of the line
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-printf-debugging/2024-11-16-datenwolf-why-the-heck-do-you-care-about-cache-lines-if-you]]
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
[3] It's ideal for a multi-thread environment, you get correct temporal ordering captured in the log file without any real effect on the scheduling of threads.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
[4] Lines are always in a fixed format
|
||||
r|sc.milmic|line_|hex_____|0000000000-|string...
|
||||
@@ -62,14 +62,14 @@ hex ... hex print of number
|
||||
000 ... decimal print of the number
|
||||
string ... user msg
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
[5] I write a line with a simple function call
|
||||
Tlk(__LINE__,n,"msg");
|
||||
Where 'n' is the number, "msg" is a string
|
||||
Don't need printf, this is way better
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
[6] Here is an example with a very simple program, just a few first lines. It's nice to automatically see exact timing. Timing since start
|
||||
0.005478 sec ... mapping of the cartridge file
|
||||
@@ -79,19 +79,19 @@ etc
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
[7] Another simple example of a fully pipelined startup, can instantly know where the primary cost is,
|
||||
"Instance begin" and "Instance end" wrap setup of the Vulkan instance, a process which took 2.4 seconds. The 4 PSOs hit in the shader cache at 3k microseconds each
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
[8] The log file keeps multiple runs, so it's easy to compare. Notepad2 it's F5 to reload the log file.
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-printf-debugging/2024-11-16-bmcnett-so-each-line-is-63-spaces-followed-by-a-n-and]]
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
[9] The point: keep it minimal, keep it simple, and keep the number of required things that take human time to the smallest possible. If you don't fall off the 'compile-time' curve, and re-compile/re-start/re-load is 'key-press-time' this works amazingly well (interactive)
|
||||
+8
-8
@@ -25,34 +25,34 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Working towards a new bring up of front-buffering on NV via VK. My last implementation had been tuned on AMD and didn't work on NV any more. NV does seem to accept a 1-deep swap with IMMEDIATE presentation at least on latest drivers, so that is a good start.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Since my image resources are static after init time, only swap images change when the driver kills the swap chain (which once upon a time seemed to happen on ALT+TAB maybe). So it's one descriptor set always bound.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Stopped using VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT (god awful naming length people), because I think it could be a perf hit on NV due to extra indirection. NV driver is free to bake down the single set now before the command buffer is sent over.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
At this stage, to the point of having everything loaded and swap chain created, it's 2700 lines of engine code. That includes embedding headers (no external includes), so it's a one file compile. People claim rolling your own engine is hard? Not really if you keep it focused.
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
So far it's a 0.25 sec hot load time on this NV dGPU laptop. Includes mapping a 4 MiB 'cart' file from pagecache, doing a 512 MiB buffer for GPU usage, hits on all PSOs, allocating some images, and kicking the command buffer that copies in the cart, and clears everything.
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Everything at load-time is multi-threaded to try to minimize start to in-game time. This is in sharp contrast to runtime where the only multi-threading being used is to separate things that are blocking.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
I get some utility on parallelizing {vulkan instance creation, mapping the cart file, warming the TLBs by walking all the pages, bringing up the window} it's about 0.08 seconds in at that point
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
After VK device is open, I signal a background thread to load the SPIR-V module, while building the descriptor set layout, which then unblocks PSO compile on background threads. And the rest of the VK setup runs in parallel. Working towards swap creation.
|
||||
+8
-8
@@ -26,35 +26,35 @@ parent_post_id: "1859369992355021246"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes How reliable in your experience in code like that is the compilation to avoid branches?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim Lots of stuff can get mapped by the compiler to V_CNDMASK_B32 instead of branching by using mix(a,b,bool) syntax. I rarely use branching because of how horrible the code generation is. No way to express that the common path stay code linear either, etc.
|
||||
|
||||
**3/**
|
||||
**3/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes I know in CUDA-land that it likes to create branches for ternaries if it contains more than 4 total instructions in a statement.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim But the real problem is lacking of explicit controls, and lacking implicit branch hints (wave-uniform/non-uniform, expected branch hit rate, etc). Better if we could just do explicit ASM style branch instructions and labels.
|
||||
|
||||
**5/**
|
||||
**5/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Well I seek to ban branches entirely, so that’s the exact opposite of what I want.
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim If your shader I$ is say 32 KiB and your instructions average say 8-bytes. You have 4 K instructions before you are streaming the program not just the data. Code size is actually important. And while micro level unroll is needed, macro level duplication is a problem with tiny I$
|
||||
|
||||
**7/**
|
||||
**7/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes I avoid the duplication of instruction patterns too. I feel it’s a failure to properly parallelize if you’re repeating the same instructions instead of data parallelizing further.
|
||||
|
||||
**8/**
|
||||
**8/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes One more reason why I avoid functions.
|
||||
|
||||
|
||||
+33
-33
@@ -25,11 +25,11 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
[0] Been wanting to do this for a long time, a thread on hard-core shader development. Something that digs into what I've learned and applied over the years. Along with the evolution of the strange syntax I use when writing shaders ...
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
[1] Lets start at one of the early ones, FXAA 3.11. Someone is hosting that here: https://gist.github.com/kosua20/0c506b81b3812ac900048059d2383126 ... most lines, it's an easy map to NV's arch which has predicated instructions (red is the predicate). Many lines are 1:1 mappings with physical HW instructions.
|
||||
|
||||
@@ -37,150 +37,150 @@ in_reply_to: ""
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2024-11-20-0-been-wanting-to-do-this-for-a-long-time-a/2024-11-20-AgileJebrim-how-reliable-in-your-experience-in-code-like-that]]
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
[2] Looking at FSR1: https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/master/ffx-fsr/ffx_fsr1.h - that had 3 permutations {32-bit, 16-bit unpacked, 16-bit packed}, where the packed one maps to how AMD's packed instructions work (everything explicitly packed)
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
[3] Onto STP: https://github.com/Unity-Technologies/Graphics/blob/27341ce4f5c8853d7f15e9420bff499f1087aceb/Packages/com.unity.render-pipelines.core/Runtime/STP/Stp.hlsl - A different set of permutations {32-bit, packed 16-bit} then {implicit mediump vs explicit} in the 32-bit (generic) permutation via types like StpMF4 which aim to allow a compiler on mobile to get some 16-bit register savings
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
[4] Notice for 16-bit path, everything again is explicitly packed (unlike the 32-bit path). And GLSL to SPIR-V would get explicit packing to the IHV driver since SPIR-V has explicit vector types (unlike DX, which was an insane problem). Example, the reprojection filtering below.
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
[5] Then STP had defines to work out differences in sampling capability (like supporting MIN/MAX sampling with UINT or not, or supporting immediate offsets or not). Example in the code doing {z,motion} UINT32 packed nearest dilation:
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
[6] The largest portability nightmare was mixing explicit FP16 with wave ops! So many compiler bugs across vendors = so many permutations in the code. The 32-bit path had to have a conversion from 'StpMF4' (possible implicit medium precision), to 'StpF4' explicit 32-bit.
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
[7] Some of perf death problems had been that DXIL didn't have bitfield ops (unlike SPIR-V), HLSL depends on IHV compilers somehow finding and pattern matching stuff like the crap below (which is MANY OPS to 1 OPCODE). So pre-processing through HLSL on non-Xbox platforms = fail!
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
[8] Go into the shader which is doing wave ops, and the true nightmare of platform workarounds becomes apparent https://github.com/Unity-Technologies/Graphics/blob/27341ce4f5c8853d7f15e9420bff499f1087aceb/Packages/com.unity.render-pipelines.core/Runtime/STP/StpSetup.compute - LSD/waveop permutations, 32-bit/16-bit in 16-bit path, etc
|
||||
|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
[9] So yeah, even in modern times you can hit paths in compilers and toolchains that well never got tested because no one had tried it and tried shipping with it. And I think this might hint that relatively few actually do this level of crazy
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
[10] Part of the formula for getting great gains with 16-bit is simply the register savings. It wouldn't be possible to do good 4x4 kernel lanczos inside a TAA without packed 16-bit support (it's 64 values on load without thinking about all the other mid-algorithm data) ...
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
[11] Looking at STP again, there is a dering, which works with the {min,max} of the near 2x2. If the HW has MIN/MAX sampling, it can fetch that, which means a lot more than 64 values, and if not they need intermediate ALU min/max, which is extra state ...
|
||||
|
||||

|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
[12] Mobile hardware is so register starved (probably due to all that SRAM area going to tiles) that it wasn't possible to do good reprojection filtering PERIOD even with FP16. So STP had a crippled compromise that did bilinear in one direction, and lanczos in the other axis
|
||||
|
||||

|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
[13] Huge wake up call to mobile HW vendors, if you don't match VGPR capacity of PCs, you can never take on where PC workloads will get to. Now given both NV and AMD have packed 16-bit, it is a great time to push pass merging and avoid DRAM traffic by doing more in one shader
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
[14] Another part of the 16-bit perf puzzle is to not use 16-bit FP16 in constants explicitly, but only package them up as aliased as UINT32 binary blobs. And for portable systems that still need 32-bit fallbacks, always build both a packed 16-bit and 32-bit set of constants.
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
[15] So many people tried to 16-bit permute things working from 32-bit float constants, and on PC that is instant perf death. Sure some mobile hardware can do the conversions for lower cost, and some mobile HW could pre-amble the conversions if not, but that isn't perf portable
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
[16] Switching gears. So STP didn't get the most hardcore way I like to write shaders, and I've had a bunch of different permutations of ideas tried over the years ... specifically how to make the code more like GPU assembly!
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
[17] Looking like assembly as in making it exactly clear what the lines map to in HW OPCODEs, and what the variable map to in REGISTERS. So you are designing to what the hardware could do, even if the compiler cannot keep up
|
||||
|
||||
**19/**
|
||||
**19/** @NOTimothyLottes
|
||||
|
||||
[18] Now it's true that NV and AMD HW are quite different in some respects (NV is predicated, and has generic 3 op logic ops, etc), so ultimately one has to pick their shader language abstraction based on what they want to target the most https://docs.nvidia.com/cuda/cuda-binary-utilities/index.html#instruction-set-reference (NV ISA docs)
|
||||
|
||||
**20/**
|
||||
**20/** @NOTimothyLottes
|
||||
|
||||
[19] Since AMD's docs are more complete, and I like to make sure a console port is possible and would be as fast as possible, I prefer to think through all my shaders as if they are getting direct mapped to AMD's RDNA2 these days: https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf
|
||||
|
||||
**21/**
|
||||
**21/** @NOTimothyLottes
|
||||
|
||||
[20] So I usually do a define that maps logic directly to what the associated instruction would be. Some of these actually map to shading language intrinsics already like fma() or bitfieldExtract(). Then write all my shader code using these defines. Example below for the defines
|
||||
|
||||

|
||||
|
||||
**22/**
|
||||
**22/** @NOTimothyLottes
|
||||
|
||||
[21] Like to use ASM like convention for {signed, unsigned}, that all integers are unsigned, and only get converted to signed when required inside the define for a specific opcode (like signed or unsigned bitfield extract). Bit casting (aliasing) is done via SI1_I1() style macros
|
||||
|
||||

|
||||
|
||||
**23/**
|
||||
**23/** @NOTimothyLottes
|
||||
|
||||
[22] And I reduce all types to very simple 3 letter macros of which are described below. I use the same naming convention in CPU land as well. This helps keep code compact and easy to read IMO (highly subjective yes)
|
||||
|
||||

|
||||
|
||||
**24/**
|
||||
**24/** @NOTimothyLottes
|
||||
|
||||
[23] One thing I struggle with to this day is compiler bitcast aliasing perf bugs. Meaning once I tried to always only use UINT4 types everywhere, and then wrap all OPCODE defines in bitcasting defines, that didn't go so well (looking at disassembly on AMD PC).
|
||||
|
||||
**25/**
|
||||
**25/** @NOTimothyLottes
|
||||
|
||||
[24] Compilers depend a lot on pattern matching to NOP stuff, and well there are bugs, lots of bugs. So for the sake of portability, with the exception of {unsigned/signed} bitcasting, I use the native types when possible (no packed-16-bit/32-bit aliasing) exception of waveops
|
||||
|
||||
**26/**
|
||||
**26/** @NOTimothyLottes
|
||||
|
||||
[25] Another aspect of compiler problems is argument passing to function calls causing SSA state explosions, because it's "copy semantics" as defined in the langs. Once I did inout uint4[16] (all VGPRs) as my only argument to all functions. Didn't end well!
|
||||
|
||||
**27/**
|
||||
**27/** @NOTimothyLottes
|
||||
|
||||
[26] Someone on twitter (or was it bsky or mast?) had been doing a one shader game. And addressing these kinds of problems, and reminded us, YES the shader languages support global variables. No need to pass them into function! (bingo)
|
||||
|
||||
**28/**
|
||||
**28/** @NOTimothyLottes
|
||||
|
||||
[27] We have been so seasoned to dislike globals in the past few decades due to well probably early mutli-window programming styles, that it is easy to forget you can just do globals, and they are fast at tool/compile time.
|
||||
|
||||
**29/**
|
||||
**29/** @NOTimothyLottes
|
||||
|
||||
[28] I think the next level up of this design is to go to mostly global variables, but since the shader languages don't support global unions, then have different sets of globals when one needs to do type bitcast aliasing (which is very common with packed 16-bit and 64-bit logic)
|
||||
|
||||
**30/**
|
||||
**30/** @NOTimothyLottes
|
||||
|
||||
[29] I still think the 'fix' for the shader compiler SSA state explosion mapping back to registers problem is to pass in explicit aliasing hints to the vendor compilers, so they have a better base guess at register allocation. But I doubt vendors would get on board with that
|
||||
|
||||
**31/**
|
||||
**31/** @NOTimothyLottes
|
||||
|
||||
[30] My personal x86-64 languages typically worked with unions of structs on globals. Where each struct in the union was a different aliased meaning to the HW registers, and functions had been associated with a given struct in the union. So no stacks or argument passing.
|
||||
|
||||
**32/**
|
||||
**32/** @NOTimothyLottes
|
||||
|
||||
[31] That kind of setup for the GPU is ideal IMO (at least for the type of stuff I do). You can link. Because the union struct for the registers is the calling ABI, and never moves (no stack). So code sharing works amazingly well. And avoiding register state explosion is built in
|
||||
|
||||
**33/**
|
||||
**33/** @NOTimothyLottes
|
||||
|
||||
[32] oh damn [32], should probably stop now, until next time.
|
||||
+16
-16
@@ -26,45 +26,45 @@ parent_post_id: "1859791162091110754"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Shouldn’t uniform be a scalar?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@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/**
|
||||
**3/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Within ISPC, uniform means scalar and varying means vector.
|
||||
|
||||
**4/**
|
||||
**4/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Looking deeper into the definition of SGPRs. They’re uniform just across each wavefront, rather than the entire dispatch yeah?
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@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/**
|
||||
**6/** @AgileJebrim
|
||||
|
||||
@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/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
@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/**
|
||||
**8/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Perhaps. That existing PTX Vulkan extension does come to mind though.
|
||||
|
||||
**9/**
|
||||
**9/** @CodePotrick
|
||||
|
||||
@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/**
|
||||
**10/** @CodePotrick
|
||||
|
||||
@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.
|
||||
|
||||
@@ -72,25 +72,25 @@ There are other examples for this.
|
||||
|
||||
And nvidias have even other constrains.
|
||||
|
||||
**11/**
|
||||
**11/** @AgileJebrim
|
||||
|
||||
@CodePotrick @NOTimothyLottes And what’s the alternative right now? Just keep it all in a VGPR all the time?
|
||||
|
||||
**12/**
|
||||
**12/** @CodePotrick
|
||||
|
||||
@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/**
|
||||
**13/** @AgileJebrim
|
||||
|
||||
@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/**
|
||||
**14/** @AgileJebrim
|
||||
|
||||
@CodePotrick @NOTimothyLottes I haven’t looked closely at AMD hardware since I don’t work with it much.
|
||||
|
||||
**15/**
|
||||
**15/** @CodePotrick
|
||||
|
||||
@AgileJebrim @NOTimothyLottes they have their actual isa public and inspectable which is really nice to know whats actually happening.
|
||||
|
||||
@@ -98,7 +98,7 @@ Rga is also really good. Feels like im more in control with amd compared to nvid
|
||||
|
||||
Maybe thats just the low level gremlin in my speaking tho ;).
|
||||
|
||||
**16/**
|
||||
**16/** @AgileJebrim
|
||||
|
||||
@CodePotrick @NOTimothyLottes I do have access to some of NVIDIA’s NDA documentation and tools…
|
||||
|
||||
|
||||
+11
-11
@@ -25,50 +25,50 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
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/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
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
-1
@@ -26,7 +26,7 @@ parent_post_id: "1868492851170205803"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @axelgneiting
|
||||
|
||||
@NOTimothyLottes @kechogarcia I'm well aware. It's really curious they still stick to this design after so many years.
|
||||
|
||||
|
||||
+6
-6
@@ -25,31 +25,31 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
"Buffer zoo" is more about the silly season of things needed on the Vulkan shader side to do what you actually want which is just get instruction intrinsics. Just the layout and SSBO aliasing (below) hints at brutal stupid API/shader design
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @kechogarcia
|
||||
|
||||
@NOTimothyLottes Dxc hlsl sm 6.5 lets you index into ResourceDescriptorHeap directly and cast to whatever resource type. That and mutable vulkan descriptors, you wouldn't need to go the buffer Zoo route.... But then dxc spirv ...
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@kechogarcia Read<32,64,128>(uint64_t base, uint32_t offset, uint32_t immediate, uint32_t cacheControl, uint32_t format);
|
||||
|
||||
And be done with this stupid mess
|
||||
|
||||
**4/**
|
||||
**4/** @axelgneiting
|
||||
|
||||
@NOTimothyLottes @kechogarcia NVidia can't just do random format conversions without it being a texture descriptor I thought?
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@axelgneiting @kechogarcia Can get the non-conversion {signed/unsigned short/int/long and half/float/double, of {1-4} components}. Which is good enough to start the interface. Then yes for NV you'd need to alias via a storage_texel_buffer to get {10:11:11,10:10:10:2,<u/s>norm*}
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
@axelgneiting @kechogarcia Then there are rough edges to TEXEL_BUFFER
|
||||
|
||||
|
||||
+2
-2
@@ -25,10 +25,10 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
The real "buffer zoo" problem with Vulkan is needing to make your HW instruction emulation macros with overcomplete both {offset, and index} inputs so the emulation can choose the correct one based on whatever crap path is required {SSBO, TEXEL_BUFFER, future pointer}
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
TEXEL_BUFFER is needed for whatever formats one cannot load from SSBOs, and both of those require 'indexes', and whenever the IHVs actually correctly optimize the pointer extension, one needs the byte offsets instead. So deadcode removal nightmare land wins today :(
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1868716773937414589"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes @GustavSterbrant Fair enough. Current compilers are a bloated mess anyways and you’d get much faster times with your own assembler.
|
||||
|
||||
|
||||
+4
-4
@@ -25,19 +25,19 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@GustavSterbrant So I don't know that SPIR-V vs OpTypeInt 24 question, but if someone didn't write tests for that it's likely never been setup to be pattern matched. Most of the problems I see cannot be fixed just by bypassing GLSL and doing SPIR-V directly. So not yet tempted to write a new SL
|
||||
|
||||
**2/**
|
||||
**2/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes @GustavSterbrant If you’re targeting a console with AMD hardware, why don’t you just rewrite the backend compiler? I assume you have the source for it too, so it’s more tweaking an existing compiler than anything else?
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim @GustavSterbrant At-home stuff (aka non-employer) targets Vulkan Windows mostly (unfortunately). No interface in AMD's Windows driver to load binary shaders into Vulkan. If SteamOS ever fully took over PC gaming, then certainly I'd just go direct to the AMD kernel driver and bypass user-mode VK
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim @GustavSterbrant Also I wouldn't just modify an existing compiler, I'd just write an assembler specific for GCN/RDNA/whateversNext family.
|
||||
|
||||
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1870343645926224197"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @AgileJebrim
|
||||
|
||||
@NOTimothyLottes Have you tried using the Intel cache controls extension I shared earlier to see if they work on AMD?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim Not enough free time. Given that AMD's compiler has some serious correctness bugs ignoring memory qualifiers, I doubt they implemented the Intel extension.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@AgileJebrim Will say though that if they ever implement a WMMA access extension (I don't know if they did or didn't yet), and they don't have streaming memory qualifier support they are just shooting their own AI stock$$$ gold rush foot off.
|
||||
|
||||
|
||||
+17
-17
@@ -25,17 +25,17 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Hopefully with this last atomic workaround I'm almost done with cleaning and fixing the 'bind-everything-once' style Vulkan engine design. Work in progress in the images that follow. Setting up the macros to get all the format aliasing is well quite ugly.
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
I end up doing a lot of duplication via macros since memory qualifiers are on the layout aliasing (instead of an argument to the operation like they should be) ...
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Vulkan is missing the streaming qualifiers, but I write the code like they exist for future compat
|
||||
W ... writeonly coherent (all writes)
|
||||
@@ -52,67 +52,67 @@ Branches: [[archive/threads/NOTimothyLottes/2024-12-21-hopefully-with-this-last-
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Texture layout aliasing is well the easy stuff since it's just readonly effectively
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
STORAGE_TEXEL_BUFFER is well complex for aliasing and how to best use. Here is what I'm doing for setup (macro heavy). I have a define for each format descriptor index if I want to reorder them by usage for better cache layout. I only keep 32/64/128 bit types
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
I didn't put in support for 16-bit <U,S>NORM yet because it tends not to get used (bad match for FP16). Likewise no buffer access to 9E5 or sRGB due to HW portability support issues
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
So todays HW
|
||||
(1.) At least for AMD buffer atomics get the signage from the OPCODE so in theory one can use a UINT32 typed TEXEL buffer with both aliased as r32ui and r32i
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
(2.) No buffer compression HW, so unlike images, there is no point in using separate types if the layout aliasing trick works. One could get by with just 32/64/128 bit type descriptors and extra ones for anything with format conversion
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
(3.) In cases like <FP16,UINT16>x<2,4> actually probably better to alias those at UINTx<1,2> because then one is sure the compiler doesn't screw up the implicit NOPing of the undo the the format conversion!
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
(4.) There is a strong desire to keep the number of descriptors down to avoid extra work in SMEM ops and extra SGPR pressure. So that also favors aliasing.
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
(5.) Ideally I'd want TBUFFER support with the HW grabbing the index width from the type in the opcode instead of the descriptor (but I don't think the HW does that, so probably would always need 3 descriptors minimum).
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
(6.) The future? Image compression relies on having the right type info in the descriptor to choose the right compression mode for decorrelation of the data. What happens if GPUs get buffer compression some day and everyone is just type aliasing all the time like SSBOs do?
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
(7.) What is the "right answer"? Even signed vs unsigned could be important for data decorrelation. Certainly float vs int is. But no one wants to burn perf today based on a guess of what is needed in an unknown future.
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
(8.) So my compromise is to have all the types, but write the code to use type aliasing (the fast path on todays HW) when I don't think data compression would help. And only use the right type (slower) if there is a prediction it might help some day if buffer compression shows up
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
(9.) In cases where I need compression today, then I use explicit 2D images (assuming 1D images don't get compression on some HWs). But note this is not great, because often I need that data back in SGPRs (expensive, SMEM doesn't to image loads)
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
Combining the STORAGE_TEXEL_BUFFER tricks (for something a good compiler could optimize from last week or so), I'm down to a few hundred macros for STB access. Showing a few here. It's ugly but the only way to actually implement well.
|
||||
|
||||

|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
Not sure if this is the end of this story yet, but hopefully the holidays I get this back online and can get back to using it. Probably have it down to as optimal as it can get while being as portable and future looking as possible
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1875589737282679108"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @marc_b_reynolds
|
||||
|
||||
@NOTimothyLottes It's pretty amazing how good the Hastings approximations still are. I'd note that they are designed for minimizing absolute error which isn't what you'd want for general purpose usage but it's the right answer for "all angles are equally important" problems.
|
||||
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ parent_post_id: "1875583660545732960"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes Some optimization ideas:
|
||||
|
||||
@@ -36,11 +36,11 @@ parent_post_id: "1875583660545732960"
|
||||
|
||||
3) If FP16 range is ok, gives 2x VALU speed
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@JBrooksBSI Lack of ABS modifiers on V_PK ops basically kills FP16 benefit here unfortunately. I do unroll when not VGPR limited (favorite optimization). Wary though of SALU/VALU crossings due to latency + scheduling behavior (loss of operand cache, etc). VCC probably has special forwarding
|
||||
|
||||
**3/**
|
||||
**3/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes I did an approx equal-area mapping to a 2D texture in 2018
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1875589737282679108"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @pixelmager
|
||||
|
||||
@NOTimothyLottes I was looking at a very similar problem for hemi-octahedrons recently. I definitely need to revisit in the context of this EAM paper, I ended up with a pretty slow polar-coordinate-remapping instead to move precision to the horizon https://www.shadertoy.com/view/wsBXzD
|
||||
|
||||
|
||||
+7
-7
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
For the love of octahedrons: https://fileadmin.cs.lth.se/graphics/research/papers/2008/simdmapping/clarberg_simdmapping08_preprint.pdf
|
||||
|
||||
@@ -33,7 +33,7 @@ Mapping this well to the GPU follows ...
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
At some point the standard Octahedron mapping leaves a lot to be desired due to highly variable texel sizing, so have been using that paper's equal area mapping instead. Spent some time optimizing today, got to this which is in theory just 31ops for the 2D to 3D transform
|
||||
|
||||
@@ -41,29 +41,29 @@ At some point the standard Octahedron mapping leaves a lot to be desired due to
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-01-04-for-the-love-of-octahedrons-https-fileadmin-cs/2025-01-06-JBrooksBSI-some-optimization-ideas-1-for-rdna2-simd-insn]]
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
AMD's latest driver actually does mostly a good job compiling that (32 op clocks compiled, just 1 more instruction somewhere). I'm surprised actually it's now picking up 'cos(x*2pi)' and pattern matching that to just V_COS_F32!
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
And the inverse which should also be around 32 op clk (VALU). This uses the Horner form for the papers atan approximation. Could perhaps make that less or more accurate if desired.
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
AMD's compiler also does a good job there.
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
If AMD evolved to a fused floating point compare and select instead of a separate V_CMP* and V_CNDMASK_B32, it would shave a few cycles. Also if they could push 2 results into a result cache in 1 clk, doing the MIN and MAX in one op would shave a cycle.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Related> Great ref for fast atan2: https://mazzo.li/posts/vectorized-atan2.html
|
||||
I'm using the simplest form from the 1955 paper in horner form scaled by /pi for cylindrical view projection code
|
||||
|
||||
+6
-6
@@ -25,38 +25,38 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
One of the downsides of V_CNDMASK_B32 on AMD is that you burn the SGPRs on the VCC bool, so if you are selecting between constants, those require extra V_MOV_B32 ops. Would be much better to have fused cmp+mask so this limitation would be lifted!
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Another night, another round of AMD compiler bugs. Sometimes AMD fails 'uint32_t packFloat2x16(f16vec2 v)' ... I'm seeing the 16-bit MSB cleared in this constant (yeah it's the slow V_CNDMASK_B32 case in the prior tweet)
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Workaround is to use 'pack32(halfBitsToUint16(a))' instead (ie first convert the packed 16-bit float to packed 16-bit integer, then convert to 32-bit integer) ...
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
One of my favorite AMD instructions V_BFI_B32 is unfortunately one that no intrinsic exists for on PC, and one that the AMD compiler often messes up the pattern matching for, sometimes it reduces to {AND,ADD} instead
|
||||
|
||||

|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Just looking at the next 5 lines of disassembly shows another 2 perf bugs: the compiler transforms 3 operations into 5 operations because it cannot handle mixed packed and unpacked stuff. The 2 V_ANDs can be merged, and the LSHL and CVT should just be one op
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
No way to work around those problems. Looks like bitfieldExtract 'v4' back-propagates something where the compiler ignores the .y in the packed logic, and then makes a mess of things scalarizing it. BFE only uses the 5-bit LSB of 'v4', so it's safe to leave junk in the other bits
|
||||
|
||||
|
||||
+12
-12
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Just for Fun: Started to look into "Cardinal Cubic O-MOMS" for resampling, some refs:
|
||||
https://hhoppe.com/proj/filtering/supp/
|
||||
@@ -33,7 +33,7 @@ https://hhoppe.com/proj/filtering/supp/sample_code.cpp
|
||||
The source paper is math salad:
|
||||
https://www.ee.cuhk.edu.hk/~tblu/monsite/pdfs/blu0101.pdf
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Results are quite nice in repeated reprojection:
|
||||
https://w3.impa.br/~diego/publications/NehHop14.pdf
|
||||
@@ -42,59 +42,59 @@ Lanczos is of course not stable (if you reproject enough with a fast lanczos app
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
However O-MOMS appears to need a pre-pass on the data before running the simple cubic filter. That simple cubic would otherwise blur bad (no negative lobes). So this is about where I stopped dissecting the math salad, and started looking at the code salad
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
That prepass seems to work with 9 coefs in 1 dimension. So this starts to look mighty expensive??? for GPU-side implementation (compared to the existing option of limiting lanczos to make it stable).
|
||||
|
||||

|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Anyway if anyone knows of a less salad-like example of cubic O-MOMS, please post
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
So if you reproject rotate in linear using a bilinear filter, after 16 reprojections you get this slop (very blurry), which is why the old simple TAA's started to look bad very fast
|
||||
|
||||

|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Compared to say this with a clamped approximate lanczos (same 16 reprojections, and linear filtering). The min/max for the clamp is of the inner 2x2 quad of the 4x4 filter window
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
So even after 16 frames, clamped lanczos approximation is already significantly less sharp than source (below). Thing most of the shader TAAs screw up is that even with great reprojection filtering, still need error-correction sharpening on the reprojection to keep it dialed in
|
||||
|
||||

|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
Some don't limit the kernel approximation that has negative lobes, because it's not differentiable, leading to the classic trailing edge halo (dark outline typically seen in DLSS2 at least). After close to 64 frames of reprojection (rotation), easy to see that effect
|
||||
|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Letting that go too long and well it converges to a high contrast black and white mess
|
||||
|
||||

|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
The non-linear limiter (simple clamping) keeps it mostly stable in color, even if the detail still converged to noodles
|
||||
|
||||

|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
Also if you overcook your negative lobes in the approximation (using the RED curve below), it speeds up the noodling process (that is the same 16 reprojections as prior)
|
||||
|
||||
|
||||
+14
-14
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Simple napkin analysis of that high-end CRT scalar (monochome one) ... notes about cleaning up the code.
|
||||
|
||||
@@ -33,17 +33,17 @@ I track state usage throughout the code to ballpark expected max VGPR count. Thi
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
So yeah packed 16-bit is the reason complex shaders like this are possible on PC GPUs. It is the way to single pass and avoid multiple trips through DRAM.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
This code does 2 parallel kernels, but also breaks the computation of each kernel into 4 weighted sums. This is done for 2 reasons: (a.) possibly higher precision, (b.) to enable parallel work to hide VALU latency (ILP)!
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
This shader needs roughly
|
||||
410 VALU op clocks
|
||||
@@ -51,30 +51,30 @@ And 253 of those (more than half)
|
||||
are in the load latency window
|
||||
So this shader will trivially hide a lot of latency without getting to high wave/CU counts
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
BUT
|
||||
Traditionally this has been a curse, because AMD's oldest wave first scheduling breaks down when the oldest is ultra high VALU load without stalls! The other waves often cannot get forward progress to get loads out to debubble the memory sub-system
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
Worst case (no scaling, no compression) this would use 6-bytes/pixel of bandwidth (damn), and amortize closer to 4-bytes/pixel with scaling. And GPUs have capacity often for 32 VALU op clocks per byte. So this is certain to be VALU bound (410+ VALU clocks)
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
But things like Strix Halo (laptops) are quite a bit more bandwidth starved, so generally I try to stay VALU bound to be friendly towards scaling down
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Estimation that something like a 7900 XT would be able to do over 10,000 of these passes at 4K per second, so this technique is good for 480 Hz! Of course I don't have a 7900 XT, and my only working AMD GPU laptop (the other has bad HDMI port) refuses to profile, so numbers later
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
Writing code (below, note FMA_MIX is the hot ticket for free FP32->FP16 conversion) with instruction intrinsic macros (that unfortunately map to high-level shader code). But it at least enables me to ballpark instruction counts. With one exception I count transcendentals as 4 ops
|
||||
|
||||

|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Can compare guesses with actuals on the disassembly/
|
||||
|
||||
@@ -82,17 +82,17 @@ Can compare guesses with actuals on the disassembly/
|
||||
|
||||

|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
I use 13 transcendentals so adjusting my 410 count by -13*3 I get 371 VALU ops. The actual shader uses 438 (and is VALU bound) an extra 18% extra slop somewhere. Some of that is that I didn't count the CS swizzle logic (but that won't account for most of the extra 67 ops) ...
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
Some of the slop, it's not using NSA (this is GFX9), so lots of extra V_MOV_B32s. The gather offsets are packed in an extra VGPR so even if the base {v34,v35} are shared across all the gather4s, it's duplicating those VGPR pairs 8 extra times (no NSA here).
|
||||
|
||||

|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
GFX9 is Vega, so no NSA here, and 1 SGPR read per operation. It was RDNA1 that introduced the good stuffs (NSA and 2 SGPRs/op).
|
||||
|
||||
@@ -102,7 +102,7 @@ Can see below cases where 2 SGPRs are needed Vega will introduce extra V_MOV_B32
|
||||

|
||||

|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
Now some actual compiler bugs,
|
||||
(1.) Vega has V_MAD_MIX, but the compiler won't use it, instead it wastes extra V_CVT_PKRTZ_F16_F32 ops
|
||||
|
||||
+3
-3
@@ -26,15 +26,15 @@ parent_post_id: "1883580512171942335"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @bmcnett
|
||||
|
||||
@NOTimothyLottes My take is similar, but I also feel that a lot of processing is best done predictively in parallel across multiple future frames, one SIMD lane per future frame
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@bmcnett Don't necessarily want to store all predictions raw though. One of the advantages of say simple things like baked directional lightmaps is that one keeps the data for multiple "frames" (or views) in a compressed form until just right before usage, and it's mis-predict safe
|
||||
|
||||
**3/**
|
||||
**3/** @bmcnett
|
||||
|
||||
@NOTimothyLottes Yeah, you need to store many prediction outputs in compressed form, with the time dimension being one over which you compress, in addition to whatever spatial dimensions are relevant
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1883591956598845661"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @noop_dev
|
||||
|
||||
@NOTimothyLottes I thought framegen was just an offspring of mpeg2 motion prediction, at least how it was in TVs for 15 years.
|
||||
|
||||
|
||||
+6
-6
@@ -26,29 +26,29 @@ parent_post_id: "1883569959286313322"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @Varaquilex
|
||||
|
||||
@NOTimothyLottes A visualization of said cold caches on a CS workload from Timothy's GDC 2018 Engine Optimization Hot Lap slides: https://gpuopen.com/wp-content/uploads/2018/05/gdc_2018_sponsored_engine_optimization_hot_lap.pptx
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@Varaquilex Amazingly unfortunate that AMD still doesn't release the tool that those instruction trace captures had been visualized on. It's the best and most useful tool period I've ever seen at any company in the industry.
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@Varaquilex If they did choose to release it, I'd teach the world how to use it well, for free. For hardcore optimization it is close to ideal. RGP doesn't start to really show you what you need to know to make good hardcore engineering decisions on AMD hardware.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@Varaquilex This is a hint for someone like Valve who could take their RADV SQTT (https://www.phoronix.com/news/RADV-SQTT-Profiling-Support) interface and build something truly transformative for GPU shader engineering
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
@Varaquilex Mix that kind of visualization tool with a good shader compiler (and HW intrinsics) and basically it's the kind of crack a serious GPU shader dev cannot say no too
|
||||
|
||||
**6/**
|
||||
**6/** @Varaquilex
|
||||
|
||||
@NOTimothyLottes That tool was one of the most insightful tools I have ever used. I do miss it. It would really be awesome to see it released to the public.
|
||||
|
||||
|
||||
+18
-18
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Often overlooked aspect of GPU perf scaling
|
||||
Shaders run at two rates
|
||||
@@ -33,78 +33,78 @@ Shaders run at two rates
|
||||
(2.) Warm I$ and K$ rate
|
||||
You actually need jobs with small wave count to be sharing the same I$ and K$ across waves (cannot be latency sensitive)
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Big problem with mass amounts of artist graph authored material shaders paired with raster,
|
||||
(1.) More materials
|
||||
(2.) GPU kicks work as wide as possible (due to limited ROP queue size)
|
||||
Both amplify the amount of cold cache work
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Very common to look even at full-screen passes and see quite long first waves/SIMD (cold caches), followed by later warm-cache steady state. As GPUs get huge, it pushes more and more waves into the cold-cache region. Scaling-TAAs do the same by reducing render resolution.
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-01-26-often-overlooked-aspect-of-gpu-perf-scaling/2025-01-27-Varaquilex-a-visualization-of-said-cold-caches-on-a-cs]]
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
So quite literally the smaller the GPU (aka mobile), the more possible benefits from scaling-TAAs getting reduced resolution, because the cold-cache effects are minimized, etc. But with say the 5090, scaling-TAAs can drop whole GPU efficiency by a substantial amount
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
NVIDIA has load prefetch hints (load more lines than required for the load), and AMD should ideally start including the same for both K$ and D$, so one can at least reduce worst case latency. This doesn't solve bandwidth duplication of wide work distribution though.
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
There are a few different perf wins from decoupling shading from raster, one is the reduction of cold cache effects. One can loop through waves of work in the same material shader, without exit, without reload of constants, etc.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Decoupled shading moves a subset of the shading data [material lookup] from interpolated (and thus distributed duplication) to non-temporal streaming (no duplication).
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Likewise if it's same-material same-wave, aka one wave is looping through a local collection of surface, the remaining non-material sampling (that is interpolated) has a higher likely hood of hitting in the cache [less ultimate duplication of data across the chip]
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
In modern times with scaling-TAAs and maximum negative mip-bias, by reducing render resolution and maximizing frame rate, one is also minimizing cache reuse. So instead of say shading all the near samples at the same time, each are now divided across perhaps 32 frames
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Thus a massive mismatch between data layout and data usage. The data is stored (and compressed) localized and layered (multiple textures/material), but is increasingly being used in an effectively random access. Both scaling-TAAs and RT are guilty here.
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
Games that rely on a mix of {heavy deferred shading, scaling-TAAs (reduced render res), RT noise reduction, and frame generation} are scaling poorly (bad engineering) and scale as a function of increased {latency, artifacts}
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
Meanwhile games that are still engineered more like vintage games {high res, low try density, simple baked lightmap textures mostly, MSAA} are scaling relatively well getting high FPS and low latency
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
Ultimately all of this hints that it would be better if the per-frame workloads are closer to the vintage games (no-TAA, no frame-gen), and instead one amortizes shading into something that "bakes" in realtime amortized across many frames into the vintage style engine data
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-01-26-often-overlooked-aspect-of-gpu-perf-scaling/2025-01-26-bmcnett-my-take-is-similar-but-i-also-feel-that-a-lot-of]]
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
All these "AI" spatial-temporal denoise-scaling-TAAs are ultimately just doing really expensive logic to try to reconstruct the surface material properties at high res and local lighting from a blurry/noisy mess then apply the local conditions to the material
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
Which is perhaps stupid given the games already easily know the exact high-res material properties, why try to "infer" them burning TOps of logic and heating your office.
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
Scaling-denoise-TAAs do hint thought that perhaps the academic methods games use for BPR and shading are quite lacking in terms of amortization of costs.
|
||||
|
||||
**17/**
|
||||
**17/** @NOTimothyLottes
|
||||
|
||||
Frame-gen when it "works" ok is just an alpha blend between two states. Clearly an engine could be doing that too instead of reshading everything every frame. And an engine could choose when to do that vs something else to avoid artifacts, something a frame-gen cannot do.
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
Ultimately the industry will choose if to devolve into AI generated slop-ware where IHVs black box more and more of your engine and you get more and more trapped and lazy. Or break out and do something better and control your own destiny.
|
||||
|
||||
|
||||
+8
-8
@@ -26,20 +26,20 @@ parent_post_id: "1884282476195110998"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Just raw spatial scaling in a custom resolve/
|
||||
4xMSAA at 2.25x area is 2.66xAA on edges
|
||||
8xMSAA at 2.25x area scale is 5.33xAA on edges
|
||||
8xMSAA at 4x area scale is 4xAA on edges <--- bingo
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Take 8xMSAA with a view-port jitter pattern (or even PSL) which always maintains the same sample vs axis intersections! <--- double bingo
|
||||
|
||||
Sub-pixel detail is now mostly stable, will show up in all frames in the local neighborhood = stable temporally
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
Bottom line/
|
||||
8xMSAA + smart jitter (or PSL)
|
||||
@@ -49,25 +49,25 @@ ALL in one custom resolve pass
|
||||
|
||||
Something one could make temporally stable without ghosting and still maintain 4xAA (on edges at output resolution) on the worst case in disocclusions
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
It would destroy DLSS4 in terms of classic image quality
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
Note one can inline something like CAS/RCAS (what I did at AMD) into the custom MSAA resolve, by modulating a negative lobe based on a local min/max kernel's min distance to signal peak {0 or 1}. Meaning it's possible to get really sharp output from this combo.
|
||||
|
||||
**6/**
|
||||
**6/** @dankbaker
|
||||
|
||||
@NOTimothyLottes Is there an example shader that does that custom resolve?
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
@dankbaker Probably not in the config you are interested in (I'm assuming spatial with no scaling?) Feel free to DM me. Most of these things need adaption specific to the config. Last one I did was huge spatial scaling for a CRT-styled scalar using this kernel,
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
@dankbaker My project is monochome so the kernel blending logic is single channel, and the content is designed to handle a huge amount of negative lobe well so I don't constrain ringing (BLUE, replace with 'm.y*RINGING'), and everything in linear of course ... but it should provide an idea
|
||||
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1884360689093091618"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot My mindset is more tuned towards rendering without minSampleShading and using the temporal component to get the shading resolution up since base frame rate will be high anyway. So no soft VRS in my line of thinking either (other than whatever falls out of 8xMSAA render)
|
||||
|
||||
**2/**
|
||||
**2/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes That’s pretty much exactly the mindset and what ended up shipping in Killzone Shadow Fall (4xMSAA -> 2x scaling + TAA) and in FarCry4 8xMSAA FMask only + analytical resolve + TAA
|
||||
Doing sub samples in FC4 was challenging due to all that AT foliage.
|
||||
|
||||
+13
-13
@@ -25,65 +25,65 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
So we (the industry) really ever went back to the MSAA based TAA combinations and applied everything we learned in the past decade ...
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-01-28-so-we-the-industry-really-ever-went-back-to-the/2025-01-28-NOTimothyLottes-just-raw-spatial-scaling-in-a-custom-resolve]]
|
||||
|
||||
**2/**
|
||||
**2/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes Hey that’s literally what our VRS is doing with all those tricks and more. We just don’t call it an upsampler ; )
|
||||
On PC we resolve MSAA to texture2DArray to retain plane separation benefits for bandwidth and coherency
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot Larger differences are
|
||||
(1.) Your VRS is PSL'ing to a regular grid? (need the actual 8x pattern for what I'm suggesting)
|
||||
(2.) Sounds like you are getting benefit from FMASK due to the soft VRS, but for what I'm suggesting the NV flat+DCC layout is way better
|
||||
|
||||
**4/**
|
||||
**4/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes 1) it’s 4xMSAA but we DRS only on X axis which is matching your case I believe. Similar how it was done it Killzone Shadowfall.
|
||||
8xMSAA we could explore XY scaling
|
||||
2) depends. On PC it’s flat /w DCC. On gen8 it’s fmask packed. Gen9 is FMask with DCC plane0/1
|
||||
|
||||
**5/**
|
||||
**5/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes But sure I agree that 8x is the way to go for 4K. Our challenge is that we still have gen8 with 1k target and at those resolutions 8x scales really sub linear due to quad occupancy
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot I guess the question then is if you implement variable spatial scaling in the custom resolve, is the 8xMSAA loss something that can easily be covered by increased spatial scale on the low end HW? 8x area scaling at 8xMSAA is still likely good for 3xAA on edges at spatial-only
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-01-28-so-we-the-industry-really-ever-went-back-to-the/2025-01-28-NOTimothyLottes-my-mindset-is-more-tuned-towards-rendering]]
|
||||
|
||||
**7/**
|
||||
**7/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes If low end hw is decent with MSAA AND you can control triangle density effectively to combat quad occupancy loss (we can’t) - that’s the best there is imo.
|
||||
FWIW that’s why we use stencil even for geo edges for MSAA - because we get too many interior edges that don’t do anything
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot I see, yes once authoring pushes tri/pix density then what makes sense changes. I was thinking more of the way things had been authored in the relief mapping era.
|
||||
|
||||
**9/**
|
||||
**9/** @MichalDrobot
|
||||
|
||||
@NOTimothyLottes Then you need invest heavily into visbuffer for “simple draws” and pay setup price to compensate those deficiencies. involved pipeline that is not portable
|
||||
I can totally see your plan working for specific art styles or more retro gaming. There is a huge Indy market for this
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot If tri/pix density is high, even if there are some huge triangles left, without substantially good multi-scale LOD (meaning cluster count scaling), I think soft culling alone falls off the !/$ curve for scaling - hints perhaps past the crossover for non-triangle rendering
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot At that stage I'd have transitioned to direct final view reconstruction from object space domain. Walking object space, atomicMin(MSB{z,ref}LSB) at some good enough density into the final projected space, then use a neighborhood of 'refs' to get back to object space neighborhoods
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot ... for the filtering. One can effectively cancel atomics per lane based on local projected screen-space density to deal with domain stretch (skinning), so it gets to be highly scalable.
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
@MichalDrobot The TAA reconstructions all crossed that threshold of cost where it's easy to swap in reconstruction from something other than screen-space. And with no disocclusion trouble, object space is much less of a challenge to go from.
|
||||
+2
-2
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
Comparing matrix to quaternion code:
|
||||
(A.) https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf
|
||||
@@ -37,7 +37,7 @@ Anything better than those?
|
||||
|
||||

|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
The (B.) alternative method might be just 32 VALU clocks on AMD, wrote up the code below (but warning didn't test it yet).
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
__/ "GELATINOUS PIXEL SOUP!" \__
|
||||
Another spicy Threat Interactive video
|
||||
@@ -34,7 +34,7 @@ https://www.youtube.com/watch?v=KEtb0punTHk
|
||||
Someone willing to challenge the status quo
|
||||
Lets talk about some of his topics ...
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
Finally someone posting ms/frame breakdown!
|
||||
Appears to be using an actual mid-range GPU
|
||||
@@ -46,7 +46,7 @@ Even at 60Hz you'd be giving up the majority of your frame budget to AI
|
||||
|
||||

|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
[ORANGE]
|
||||
Transformer model being almost 2x the cost of the prior CNN model. Double the cost for less ghosting.
|
||||
@@ -55,11 +55,11 @@ Note STP (non-ML) was targeting 1/3 to 1/2 of the cost of that old CNN model wit
|
||||
|
||||

|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
It is certainly possible to engineer a bunch of very low cost and high quality human written shader solutions for scaling-TAAs that do better than the ML ones in !/$ for the non-ray-reconstruction cases
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
NV banking on poorly optimized PC titles though is NOT a new thing: lets rewind to 2012!
|
||||
|
||||
@@ -71,17 +71,17 @@ Yet NV wins because of game-ready drivers
|
||||
|
||||

|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
NVIDIA was always about enabling dev laziness, the RT+AI+Fake era is just the ultimate form of that, where the lazy dev is marginalized to a few % of the total frame budget with AI taking the majority.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
Others playing "follow-the-leader" unfortunately still didn't catch on to the most important point, that Jensen's plan forces consumers to buy into only high-end cards to fix all the PC game problems. Nothing about the AI future scales down!
|
||||
|
||||

|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
Jensen's "Low-End" = 5070 is 1/3 the VALU of a 5090
|
||||
|
||||
@@ -90,7 +90,7 @@ is 1/19 the VALU and 1/7.6 the bandwidth
|
||||
|
||||
Already today, without scaling-TAAs on 5080, many "high-end" PC games either struggle to hit 60Hz at 4K or cannot make it to 120Hz ... ouch
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
So Jensen's AI future depends on big GPU$$$$
|
||||
|
||||
@@ -98,40 +98,40 @@ And all other non-NV IHVs and OEMs build substantially smaller GPUs (Apple) or f
|
||||
|
||||
Following Jensen's path is suicide, because they won't have the baseline GPU mass required to play
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
Should feel extra sorry for someone like Qualcomm who though they could just make an RT core and follow the baseline HW requirements, but completely missed the point that NV would just raise the ray-reconstruction cost to a place Qualcomm could never get to
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
AMD/others can easily extend out 1-fake frame to N-fake frames, and they all have timewarp for VR experience, so doing the fake latency thing is trivial too. And maybe FSR4/etc ML based non-RR scaling-TAAs hit DLSS parity soon
|
||||
|
||||
But NVIDIA has already pivoted to ray reconstruction
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
At the end of the day, it is actually unreasonable to expect IHVs to do anything other than follow NVIDIA if PC engines just eat up RT and get bottle-fed on AI. Even if AMD or anyone makes awesome divergent tech, if it isn't mass market engine adoption it will go no where
|
||||
|
||||
**13/**
|
||||
**13/** @NOTimothyLottes
|
||||
|
||||
Likewise how can we expect major AAA engines to take on the uncertainty and insane R&D challenge of getting off their current NV evolution paths and do something radically different, it's just too high risk
|
||||
|
||||
**14/**
|
||||
**14/** @NOTimothyLottes
|
||||
|
||||
So the industry is somewhat in a live lock condition where it won't make forward progress
|
||||
|
||||
**15/**
|
||||
**15/** @NOTimothyLottes
|
||||
|
||||
Related story. So the reason I left AMD for Unity was because Unity was spinning up an R&D team for scalable high-end graphics. And our target was mobile through high-end PC. And left alone we would have got there. But the stock crashed and we got axed or forced out.
|
||||
|
||||
**16/**
|
||||
**16/** @NOTimothyLottes
|
||||
|
||||
I think ultimately those in the industry who don't like the current status quo, it's on you to build the tech yourself and ship it in an game to prove it is possible. Because it isn't likely that anyone has the pockets deep enough to fund a new general purpose engine on risky R&D
|
||||
|
||||
**17/**
|
||||
**17/** @0xpatrickhan
|
||||
|
||||
@NOTimothyLottes What are some problem areas you think need to be tackled? I’ve read some of what you’ve written in response to some of the gripes of modern day temporal supersampling/AA. What else? Anything that IHVs would be uniquely positioned to do?
|
||||
|
||||
**18/**
|
||||
**18/** @NOTimothyLottes
|
||||
|
||||
@0xpatrickhan There is a laundry list of things IHVs dont expose or expose very poorly for basic compute shaders, making it quite difficult or impossible to get a compiler to do the right thing. Fix those and devs like myself could easily build better than AI tech options
|
||||
+2
-2
@@ -26,11 +26,11 @@ parent_post_id: "1912477061467304351"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BoganBits
|
||||
|
||||
@NOTimothyLottes Could a shader compiler not do this? i.e. detect such inefficient code, and "re-vectorise" it, so to speak i.e. have each shader instance do 2 at once, interleaved
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@BoganBits This is something to be done at the dispatch level, not something a compiler knows about
|
||||
|
||||
|
||||
+2
-2
@@ -26,12 +26,12 @@ parent_post_id: "1912477061467304351"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @BoganBits
|
||||
|
||||
@NOTimothyLottes I would be interested to see a concrete example of this
|
||||
ideally with a benchmark to show the improvement
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@BoganBits Early STP had a mode to pipeline the dependent passes, that was back when it was being developed out of Unity. That mode was way faster. But later it was removed because Unity wouldn't allow resources bound for read+write at the same time = fail.
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ parent_post_id: "1912484261321392231"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @DjMolehill
|
||||
|
||||
@NOTimothyLottes branching, cache locality, and memory handling are key 🔥
|
||||
|
||||
|
||||
+8
-8
@@ -26,7 +26,7 @@ parent_post_id: "1912483968563269946"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes I'd add:
|
||||
|
||||
@@ -34,25 +34,25 @@ Standardized, documented ISA that enables compatibility across multiple GPU gene
|
||||
|
||||
WGP (WorkGroup Processor) mode which doubles the # of SIMD units executing a single threadgroup, halving latency for bottleneck operations.
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@JBrooksBSI Personally I still don't like the WGP+wave32 stuff. Limited dual issue instructions with less operand flexibility (wave64 back to back issue IMO is better, just HW dual pipe transcendentals). WGP's two L0 cache and related resource split issues.
|
||||
|
||||
**3/**
|
||||
**3/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes WGP mode and wave32 are separate features. WGP mode schedules waves within a threadgroup across both CUs (4x SIMDs) in each WGP instead of limiting waves to a single CU (2x SIMD).
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
@JBrooksBSI Yeah so it's more the wave32 that I don't like
|
||||
|
||||
**5/**
|
||||
**5/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes I'd like to discuss this in more detail, as I have found wave32 to be faster than wave64 for everything except some vertex shaders.
|
||||
|
||||
I think the reason wave64 can be faster for vertex shaders is that only half the VS waves get launched, so more occupancy for PS/CS waves per WGP.
|
||||
|
||||
**6/**
|
||||
**6/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes The reasons Wave64 has been slower for me:
|
||||
1) More VGPR pressure = less occupancy
|
||||
@@ -62,7 +62,7 @@ I think the reason wave64 can be faster for vertex shaders is that only half the
|
||||
|
||||
I spot-unroll 2x-4x for more intra-wave parallelism as needed.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
@JBrooksBSI Re
|
||||
1) With what I do, high occupancy is often slower
|
||||
@@ -70,7 +70,7 @@ I spot-unroll 2x-4x for more intra-wave parallelism as needed.
|
||||
3) It's half the K$ loads for wave64
|
||||
4) I use DPP16 at most (no dynamic shuffle)
|
||||
|
||||
**8/**
|
||||
**8/** @JBrooksBSI
|
||||
|
||||
@NOTimothyLottes Wow, that is wildly different from what I do.
|
||||
|
||||
|
||||
@@ -25,24 +25,24 @@ in_reply_to: ""
|
||||
|
||||
## Thread
|
||||
|
||||
**1/**
|
||||
**1/** @NOTimothyLottes
|
||||
|
||||
__/ CS OPTIMIZATION BRAIN DUMPING \__
|
||||
(1.) Sometimes branching can disrupt otherwise regular execution flow leading to a performance regression,
|
||||
while it might be counter intuitive to always do more work, it can sometimes be faster too ->
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
WHY> Branching can cause: I$ misses, branch delays, wave switches that kill operand cache, poor register allocation, extra VALU overheads on the rejoin to move VGPRs, and most importantly poor VMEM behavior (not able to hoist out a speculative load earlier)
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
(2.) Time a shader in isolation, tend to see 3 regions of execution: {cold-start, warm-cache, drain} regions.
|
||||
Early waves are missing through {I$,K$,L0$}, warm-cache waves have lower runtime.
|
||||
|
||||
For this reason it is very important to pipeline (overlap) workloads.
|
||||
|
||||
**4/**
|
||||
**4/** @NOTimothyLottes
|
||||
|
||||
Serially dependent workloads should be broken up spatially and pipelined!
|
||||
|
||||
@@ -50,31 +50,31 @@ I've never seen a dev do this correctly (look at their serially dependent post p
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-04-16-cs-optimization-brain-dumping/2025-04-16-BoganBits-i-would-be-interested-to-see-a-concrete-example]], [[archive/threads/NOTimothyLottes/2025-04-16-cs-optimization-brain-dumping/2025-04-16-BoganBits-could-a-shader-compiler-not-do-this-i-e-detect]]
|
||||
|
||||
**5/**
|
||||
**5/** @NOTimothyLottes
|
||||
|
||||
(3.) If a shader is only going to run a small number of waves on say one CU (like a material used on a few pixels) then budget bandwidth for it's full {shader and constants} (which might be more costly than the textures themselves).
|
||||
|
||||
**6/**
|
||||
**6/** @NOTimothyLottes
|
||||
|
||||
(4.) Back to {cold,warm,drain} -> for small workloads or large 'cold/drain-region' workloads, it is better to force that onto one CU and loop through work (semi or full) persistent waves, to ensure high cache locality and reuse.
|
||||
|
||||
**7/**
|
||||
**7/** @NOTimothyLottes
|
||||
|
||||
... Note, might want to use large CU filling workgroups, because single-wave workgroups might get tossed on different low-level caches.
|
||||
|
||||
**8/**
|
||||
**8/** @NOTimothyLottes
|
||||
|
||||
(5.) For what should be VALU bound stuff, usually the problem on AMD is locally clustered VMEM caused by oldest first scheduling, causing memory bubbles. What you really want is steady VMEM keeping memory working well in parallel with execution ...
|
||||
|
||||
**9/**
|
||||
**9/** @NOTimothyLottes
|
||||
|
||||
... This can be very hard to fix. Sometimes you need to use more VALU to decode better compressed data to go faster (counter intuitive), or even reduce the waves running in parallel (for better cache/wave ratio) [also counter intuitive] ...
|
||||
|
||||
**10/**
|
||||
**10/** @NOTimothyLottes
|
||||
|
||||
There are shader source level transforms which can help too. Meaning you might see a difference batching say by groups of 2x2 (part kernel) instead of say the full kernel size. Yes sometimes the shader compiler will radically re-order, other times not (depends on VGPR pressure)
|
||||
|
||||
**11/**
|
||||
**11/** @NOTimothyLottes
|
||||
|
||||
(6.) The two most important things AMD ever did IMO to their architecture
|
||||
(a.) Packed 16-bit (with double rate)
|
||||
@@ -83,7 +83,7 @@ There are shader source level transforms which can help too. Meaning you might s
|
||||
|
||||
Branches: [[archive/threads/NOTimothyLottes/2025-04-16-cs-optimization-brain-dumping/2025-04-16-JBrooksBSI-id-add-standardized-documented-isa-that-enables]]
|
||||
|
||||
**12/**
|
||||
**12/** @NOTimothyLottes
|
||||
|
||||
... The reasons being that it becomes possible to reduce round trips through memory by pass merging and other techniques -> resulting in shaders with massive state fitting in VGPRs without spilling
|
||||
|
||||
|
||||
+3
-3
@@ -26,17 +26,17 @@ parent_post_id: "1917652589358858332"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @onatt0
|
||||
|
||||
@NOTimothyLottes holy truthnuke - and people think C is the optimal state of possible runtimes when it's a very limited runtime to have state mixed call/data-stacks
|
||||
|
||||
not only you have to keep the whole stack around with replicated state, it limits to serialized execution instead of parallel
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@onatt0 I laugh when people say C is like assembly, they are missing what we actually did in assembly back then, which was all registers and globals and gotos, no stacks. It's radically different than good assembly.
|
||||
|
||||
**3/**
|
||||
**3/** @onatt0
|
||||
|
||||
@NOTimothyLottes when C became *the* execution model, it restricted all future hardware, HW gets built with how the C compiler will compile to it instead of what's ultimately a good design and a malleable macro-lang to map to HW
|
||||
|
||||
|
||||
+3
-3
@@ -26,17 +26,17 @@ parent_post_id: "1917646466417381426"
|
||||
|
||||
## Branch
|
||||
|
||||
**1/**
|
||||
**1/** @onatt0
|
||||
|
||||
@NOTimothyLottes IMO code compilation is inherently sequential+ "execution contextual", dynamic logic execution to get the binary as the essence vs a static lang
|
||||
|
||||
codegen with execution on GPU could work as 2-items(vreg)/stack and 32K cells per lane for AI to map code to data instead of weights?
|
||||
|
||||
**2/**
|
||||
**2/** @NOTimothyLottes
|
||||
|
||||
@onatt0 So for x86 I've many times written code gen with extra nop-prefix padding to fix all instructions to a multiple of known 32-bits. Which means you know in advance sizing of everything, then you can easily do parallel code generation. So need not necessarily all be serial
|
||||
|
||||
**3/**
|
||||
**3/** @NOTimothyLottes
|
||||
|
||||
@onatt0 However I'm often building then instantly using code while generating a baked binary to use later, so that regard much is inherently serially dependent. This bootstrapping technique is perhaps one the great things to learn from things like color forth IMO.
|
||||
|
||||
|
||||
Loaded 100 of 515 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user