HNHacker News
TopNewBestAskShowJobs

delta_p_delta_x

5,063 karma · joined July 15, 2021

submissionscomments
delta_p_delta_x··on Swapping SIM cards used to be easy, and then came eSIM
> have the digital file sent over Bluetooth and converted by a DAC in the headphones, right

This is not how Bluetooth wireless audio works. PCM audio is re-encoded on-device into any one of a few Bluetooth-capable codecs that is then streamed to the client device. This is a primary cause of latency.

delta_p_delta_x··on Swapping SIM cards used to be easy, and then came eSIM
> "what's wrong with a usb-c to 3.5mm adapter"

I want to charge and listen to music at the same time.

delta_p_delta_x··on Swapping SIM cards used to be easy, and then came eSIM
Worse quality, latency, potential to lose one (or both) earbuds, having to faff with batteries and charging and cases (and charging the charging case) when I can just... plug it in, bam, music in my ears. The knotting is a small price to pay for the improved quality and convenience in every other way.

What's wrong with analogue audio?

delta_p_delta_x··on Swapping SIM cards used to be easy, and then came eSIM
> We gave up the headphone jack. We gave up the microSD card.

Some people might have given it up. I personally own a Sony Xperia phone, and intend to buy another Xperia next year, which will almost certainly still have both. In fact Sony is the one manufacturer that returned to a headphone jack after having removed it for a while. It might be more expensive than the competition, but this is my voting with my wallet.

delta_p_delta_x··on Learn computer graphics from scratch and for free
I have a hot take. Modern computer graphics is very complicated, and it's best to build up fundamentals rather than diving off the deep end into Vulkan, which is really geared at engine professionals who want to shave every last microsecond off their frame-times. Vulkan and D3D12 are great, they provide very fine-grained host-device synchronisation mechanisms that can be used to their maximum by seasoned engine programmers. At the same time a newbie can easily get bogged down by the sheer verbosity, and don't even get me started on how annoying the initial setup boilerplate is, which can be extremely daunting for someone just starting out.

GPUs expose a completely different programming memory model, and the issue I would say is conflating computer graphics with GPU programming. The two are obviously related, don't get me wrong, but they can and do diverge quite significantly at times. This is more true recently with the push towards GPGPU, where GPUs now combine several different coprocessors beyond just the shader cores, and can be programmed with something like a dozen different APIs.

I would instead suggest:

  1) Implement a CPU rasteriser, with just two stages: a primitive assembler, and a rasteriser.
  2) Implement a CPU ray tracer. 
Web links for tutorials respectively:

  https://haqr.eu/tinyrenderer/
  https://raytracing.github.io/books/RayTracingInOneWeekend.html
These can be extended in many, many ways that will keep you sufficiently occupied trying to maximise performance and features. In fact to even achieve some basic correctness will require quite a degree of complexity: the primitive assembler will of course need frustum- and back-face culling (and these will mean re-triangulating some primitives). The rasteriser will need z-buffering. The ray-tracer will need lighting, shadow, and camera intersection algorithms for different primitives, accounting for floating-point divergence; spheres, planes, and triangles can all be individually optimised.

Try adding various anti-aliasing algorithms to the rasteriser. Add shading; begin with flat, then extend to per-vertex to per-fragment. Try adding a tessellator where the level of detail is controlled by camera distance. Add in early discard instead of the usual z-buffering.

To the basic Whitted CPU ray tracer, add BRDFs; add microfacet theory, add subsurface scattering, caustics, photon mapping/light transport, and work towards a general global illumination implementation. Add denoising algorithms. And of course, implement and use acceleration data structures for faster intersection lookups; there are many.

Working on all of these will frankly give you a more detailed and intimate understanding of how GPUs work and why they have been developed a certain way, rather than programming with something like Vulkan, spending time filling in struct after struct.

After this, feel free to explore any one of the two more 'basic' graphics APIs: OpenGL 4.6, or D3D11. shadertoy.com and shaderacademy.com are great resources to understand fragment shaders. There are again several widespread shader languages, though most of industry uses HLSL. GLSL can be simpler, but HLSL is definitely more flexible.

At this point, explore more complicated scenarios: deferred rendering, pre- and post-processing for things like ambient occlusion, mirrors, temporal anti-aliasing, render-to-texture for lighting and shadows, etc. This is video-game focused; you could go another direction by exploring 2D UIs, text rendering, compositing, and more.

As for why I recommend starting with CPUs, only to end up back with GPUs again, and one may ask: 'hey, who uses CPUs any more for graphics?' Let me answer: WARP[1] and LLVMpipe[2] are both production-quality software rasterisers; frequently loaded during remote desktop sessions. In fact 'rasteriser' is an understatement: they expose full-fledged software implementations of D3D10/11 and OpenGL/Vulkan devices respectively. And naturally, most film renderers still run on the CPU, due to their improved floating-point precision; films can't really get away with the ephemeral smudging of video games. Also, CPU cores are quite cheap nowadays, so it's not unusual to see a render farm of a million+ cores chewing away at a complex Pixar or Dreamworks frame.

[1]: https://learn.microsoft.com/en-gb/windows/win32/direct3darti...

[2]: https://docs.mesa3d.org/drivers/llvmpipe.html

delta_p_delta_x··on Learn computer graphics from scratch and for free
Here you go: https://haqr.eu/tinyrenderer/
delta_p_delta_x··on C++ says “We have try... finally at home”
Standard library modules: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p24...

I have thoroughly forgotten which header std::ranges::iota comes from. I don't care either.

delta_p_delta_x··on The Ultimate Windows Utility (2022)
I suspect you'll additionally need to make some GPO changes so that things like Game Bar, Xbox, and Copilot are disabled.
delta_p_delta_x··on The Ultimate Windows Utility (2022)
I would instead suggest two things for power users: installing Windows using autounattend.xml[1], and secondly visiting the mass graves to turn your Windows install into Enterprise (or, if you can wrangle it, get an Education licence from your academic institution/alma mater), which completely gets rid of all consumer-oriented stuff.

To be honest, I don't mind the Windows games. In fact I believe the ones shipped with XP, Vista, and 7 were top-notch. What I mind is games with annoying advertisements in them. I mind when my Weather program is not native and is a glorified web app, also ridden with advertisements.

[1]: https://schneegans.de/windows/unattend-generator/

delta_p_delta_x··on Ask HN: Who here is not working on web apps/server code?
Side project(s): Grokking Windows development from the top of the stack to the kernel; everything from Win32, WinUI, WPF, COM, to user- and kernel-mode driver development. It's fun to write drivers in modern C++. Also, massively procrastinated, Vulkan/D3D12 cross-platform game engine written in C++23/26, work-in-progress.

Full time work: GPU driver development and integration for a smartphone series. It's fun to see how the sauce is made.

Eventually: hope to pick up Rust.

delta_p_delta_x··on RemoveWindowsAI
I use NVIDIA hardware which objectively have superior maximum performance compared to AMD graphics cards. I use HDR high pixel density monitors as well. I like laptops with decent battery life and decent touch pads.

Windows simply offers a cleaner, more well put-together experience when it comes to these edge cases. I have many tiny nitpicks about how Linux behaves, and every time I go back to my Windows Enterprise install it is a breath of fresh air that my 170% scaling and HDR just work. No finagling with a million different environment variables or CLI options. If a program hasn't opted into resolution independent scaling then I just disable it, and somehow the vector elements are still scaled correctly, leaving only the raster elements blurry. Nowadays laptop touch pads feel like they are Macs, which is high praise and a sea change from where Windows touch pads were about a decade ago.

If you strip away all the AI nonsense, Windows is a genuinely decent platform for getting anything done. Seriously, MS Office blows everything else out of the water. I still go back to Word, Excel, and PowerPoint when I want to do productivity. Adobe suite, pro audio tools, Da Vinci Resolve, etc, they just... work. If you haven't programmed in Visual Studio or used WinDbg then you have not used a serious, high-end debugger. GDB and perf are not even in the same league.

As a Windows power user, I want to go back to the Windows 2000 GUI shell, but with all the modernity of Windows 11's kernel and user-space libraries and drivers. I wish Enterprise was the default release, not the annoying Home versions. And I really, really wish Windows was open-sourced. Not just the kernel, but the user mode as well, because the user mode is where a lot of the juice is, and is what makes Windows Windows.

delta_p_delta_x··on RemoveWindowsAI
Yes, that's called

  irm script.ps1 | iex
Famously used in the Windows Activation Scripts.
delta_p_delta_x··on You can't fool the optimizer
> but some compilers don't: https://godbolt.org/z/M7x5qraE6

You've misrepresented the situation. Turn up the optimiser to `/O2` and MSVC returns 5 directly, too.

> This function returns 1 if s is "hello". 0 otherwise. I've added a pointless strlen(). It seems like no compiler is clever enough to remove it.

It's funny how sometimes operating at a higher level of abstraction allows the compiler to optimise the code better: https://godbolt.org/z/EYP5764Mv

In this, the string literal "hello" is lowered not merely into a static string, but a handful of integral immediates that are directly inline in the assembly, no label-dereferencing required, and the 'is equal to "hello"' test is cast as the result of some sign extends and a bitwise-xor.

Of course, one could argue that std::string_view::size() is statically available, but then my counter-argument is that C's zero-terminated strings are a massive pessimisation (which is why the compiler couldn't 'see' what we humans can), and should always be avoided.

delta_p_delta_x··on Addressing the adding situation
It might have been a little bit clearer to say:

  Yesterday we saw how compilers zero out registers efficiently.
Or better still:

  Yesterday we saw how compilers set the values in registers to zero efficiently.
delta_p_delta_x··on Hardening the C++ Standard Library at scale
It seems to me statically checking this should be possible. The liveness of the result of std::vector::front() should be invalidated and be considered dead after the second invocation to push_back(). Then a static analyser would correctly mark the final line with red squiggles. Of course, compilers would still be happy to compile this, which they really ought not to.
delta_p_delta_x··on WinApps: Run Windows apps as if they were a part of the native Linux OS
> UI is sluggish

You absolutely need to pass through a GPU so that DWM.exe is properly accelerated; otherwise, it falls back to the software-accelerated WARP and the performance tanks to ~15 FPS.

It doesn't need to be anything powerful; if you have an idle integrated card that you aren't using on the Linux host because you only interact with it through a Web server or SSH (for instance, Proxmox), then pass that through. It's what I do on my home lab which runs a 9950X.

Before people raise pitchforks against Linux, this applies there, too, for the record: at work I have a Linux instance just to myself that by any other metric is ridiculously powerful: 64-core Epyc, 96 GB memory, but no iGPU, so remote desktop works very poorly.

delta_p_delta_x··on China's BEV trucks and the end of diesel's dominance
We might just replace aeroplanes altogether with ultra-high-speed maglev.

Although the cost calculation for this would be totally different—hundreds of billions up-front for world-crossing tunnels and infrastructure and rolling stock, but then nearly no running cost.

The Chuō Shinkansen will be an interesting small-scale experiment in proper high-speed maglev in regular, long-distance passenger service.

delta_p_delta_x··on Jakarta is now the biggest city in the world
Lots of people labouring under weak and old stereotypes here...

I wonder what people would think if I said that about London, if I only visited central London and said 'it feels like a tourist trap'. London is huge, as is Singapore (for a city, it's pretty big— it has a larger population than all of the Baltics and the Nordic except Sweden).

delta_p_delta_x··on Jakarta is now the biggest city in the world
Oh, for goodness' sake, drop the melodrama and hyperbole. I take it you haven't lived in the country either.

Singapore is not North Korea, the PRC, or any of the Gulf countries, where people just get disappeared (or sawn into pieces and stuffed into a suitcase) for 'criticising the government' or 'criticising the country'.

I am Singaporean.

I can absolutely call the ruling People's Action Party a bunch of ivory tower-dwelling bureaucrats who have lost touch with the issues of the populace, and are mostly far cry from Lee Kuan Yew's days. I can say that Ms Josephine Teo really needs to keep her mouth shut, and that Mr Ng Chee Meng, MP for Jalan Kayu, didn't deserve to win his constituency one jot. I can say the ruling party regularly gerrymander the districts so they keep winning, even though they deny it. I can say they stifle the development of creative pursuits and the arts with their heavy-handed censorship. I can say they have their vices backwards by being extremely light on drink-driving, but simultaneously extremely harsh on cannabis, which smells horrible but isn't a big problem in terms of addiction or withdrawal.

I can say they are strongly influenced by Anglospheric right-wing Christian evangelism, and they need to root it out before it settles too deep into the country's psyche. I can say they are trying to build a cult of personality of Lee Kuan Yew, who has been dead for 10 years; it's time the country, the government, and the ruling party built on his legacy and moved forward instead of circling around him and his memory.

If you want more criticism, how about actually watching the Singapore Parliament, and deciding for yourself?

Oh, and if you ever decide to drop by, leave the hard drugs at home (including weed), if you want to leave with your head on its neck.

As for metrics: Singapore is both on paper and in reality a pretty good place to live, if you can stand the humidity and heat (frankly, that's the only truly oppressive thing about the place, how ruddy hot it gets). Why do you think people still emigrate to it, from lower-income countries, and from the West?

And finally, 'bald JD Vance', I don't understand how US politics is related to Singapore. They are countries hemispheres apart. One occupies a full third of a continent and has a population of 350 million. The other is a tiny island city-state of 6 million.

The politics of the US have also degraded to something worse than sports rivalries and the discourse is generally of extremely poor quality; it is only a reflection of the competence (or lack thereof) of its leadership and the majority of its people.

delta_p_delta_x··on Jakarta is now the biggest city in the world
This comment is proof that the parent commenter has never actually lived in either city.

After a while, a city's 'character', 'charm', and 'charisma' all become annoyances. People live, work, go to school, file taxes, use transport, not just visit tourist attractions. Singapore's quality and efficiency of administration is light-years beyond any other country, perhaps bar Switzerland. 6.1 million people live in Singapore; they're not all multimillionaires.

delta_p_delta_x··on Notes on the Troubleshooting and Repair of Computer and Video Monitors
> replacements of any kind are cheap

Of a bog-standard 1080p 60 Hz monitor, perhaps.

I have a 4K 144 Hz 27-inch monitor I bought in December 2021, and paid nearly $850 for. These monitors still aren't a commodity good, and still end up being pretty expensive.

delta_p_delta_x··on Constant-time support coming to LLVM: Protecting cryptographic code
> want fancy features like autocomplete or structs and functions

I would argue that given a certain ISA, it's probably easier to write an autocomplete extension for assembly targeting that ISA, rather than autocomplete for C, or goodness forbid, C++.

Likewise for structs, functions, jump targets, etc. One could probably set up snippets corresponding to different sorts of conditional execution—loops, if/else/while, switch, etc.

delta_p_delta_x··on How did the Win 95 user interface code get brought to the Windows NT code base?
You still can. Run any program in compatibility mode; the Windows 2000 boxy UI is still there. As is the Windows Vista Aero Basic theme.

Like I always say, the user-mode of Windows is easiest to change, that's why it has been done almost every version.

delta_p_delta_x··on Android and iPhone users can now share files, starting with the Pixel 10
> he only way for the camera to connect to my phone is through some super complicated song and dance, involving my phone requesting a connection over Bluetooth, then the camera running a wifi access point that my phone connects to (during which time my phone disconnects from my home wifi)

Sounds like a Nikon mirrorless. I have a Z6iii, and I am constantly confused with the networking setup. There are something like three duplicated menus, all with very similar functionality.

delta_p_delta_x··on How I learned Vulkan and wrote a small game engine with it (2024)
> Without OpenGL being maintained, we are missing a critical “middle” drawing API.

OpenGL still works. You can set up an old-school glBegin()-glEnd() pipeline in as few as 10 lines of code, set up a camera and vertex transform, link in GLUT for some windowing, and you have the basic triangle/strip of triangles.

OpenGL is a fantastic way to introduce people to basic graphics programming. The really annoying part is textures, which can be gently abstracted over. However, at some point the abstractions will start to be either insufficient in terms of descriptive power, or inefficient, or leaky, and that's when advanced courses can go into Vulkan, CPU and then GPU-accelerated ray tracing, and more.

delta_p_delta_x··on The Geometry Behind Normal Maps
> If we could afford a polygon for every pixel we wouldn’t need textures at all.

Heh; with mesh shaders and Nanite, we sort of can now. Whether older GPUs can render them is a different matter altogether though.

delta_p_delta_x··on .NET 10
> practically all other development is web

This is a pretty ignorant take.

delta_p_delta_x··on Singapore to cane scammers as billions lost in financial crimes
> I’m free to criticise my government in the UK in any way I wish to.

As someone who moved from Singapore to the UK, this assessment is really quite funny. The Online Safety Act says hello.

delta_p_delta_x··on Why I love OCaml (2023)
I would really like to read more about this!
delta_p_delta_x··on Why I love OCaml (2023)
Thanks, this is a very nice article.
← PreviousPage 10 of 34Next →