J
Josh Barczak
joshbarczak.com · Personal blog · on HN since 2014
Graphics programmer Josh Barczak writes about GPU programming, OpenGL, SPMD models, and shader techniques.
What HN saysHN links it for SPMD programming model posts and an explanation of why geometry shaders were hard to implement efficiently in hardware.
18HN people shared it
7linked it in comments
14stories submitted
988story points
1 year agolast shared
2014people per year2026
Most-shared posts
- 1Why Geometry Shaders Are Slow (Unless You’re Intel)5 people · 100 points · first shared 2015 · 8 comments on HN
- 2Considering performance in the small is not “premature optimization”3 people · 120 points · first shared 2015 · 68 comments on HN
- 3You Compiled This, Driver – Trust Me2 people · 108 points · first shared 2016 · 16 comments on HN
- 4Let’s Close the Buffer Zoo2 people · 35 points · first shared 2016 · 4 comments on HN
- 5A Quick Study on Tokenizing2 people · 24 points · first shared 2016 · 2 comments on HN
- 6OpenGL Is Broken1 people · 156 points · first shared 2014 · 124 comments on HN
- 7GPU Ray Tracing the Wrong Way1 people · 134 points · first shared 2016 · 11 comments on HN
- 8Stop Misquoting Donald Knuth1 people · 131 points · first shared 2015 · 54 comments on HN
- 9Fine, I’ll Go Build My Own Disassembler, with BlackJack1 people · 89 points · first shared 2015 · 4 comments on HN
- 10SPMD Is Not Intel’s Cup of Tea1 people · 89 points · first shared 2016 · 25 comments on HN
- 11Bits and Kibbles1 people · 2 points · first shared 2014 · discussion on HN
- 12Post 7301 people · first shared 2025
What HN people wrote when they linked it
raphlinus · 2021-01-29
Another interesting reference from a few years ago: http://www.joshbarczak.com/blog/?p=1028
Also read the followups (1120 and 1197), as they go into considerably more detail about the SPMD programming model and some use cases.
The author is now at Intel working on ray tracing.
quag · 2025-08-29
It sounds like you've got something specific in mind when you say, "modeling". The term modeling is used in a lot of different situations to mean different things. For example, it could mean to make a 3d model in Blender, it could mean to pose for someone to paint you or to take a photo, with databases it's used to mean modeling the data, with statistics it's used to mean finding a way to simply represent and reason about the data (create a model of it).
The things you've listed out make me guess you want to write 2d or 3d image rendering software. Is that right?
If that's the case, there's no substitute for trying to recreate certain algorithms or curves using a language or tool that you're comfortable with. It'll help you build an intuition about how the mathematical object behaves and what problems it solves (and doesn't). All of these approaches were created to solve problems, understanding the theory of it doesn't quite get you there. If you don't have a good place to try out functions, I recommend https://thebookofshaders.com/05/ , https://www.desmos.com/calculator , or https://www.geogebra.org/calculator .
A good place to start is linear interpolation (lerp). It seems dead simple, but it's used extensively to blend two things together (say positions or colors) and the other things you listed are mostly fancier things built on top of linear interpolation.
https://en.wikipedia.org/wiki/Linear_interpolation
For bezier curves and surfaces here are some links I've…
jsheard · 2024-10-31
They had limited uses and turned out to be incredibly hard to implement efficiently in hardware, so in practice it was nearly always faster to just keep using the proven techniques that GS was supposed to replace.
http://www.joshbarczak.com/blog/?p=667
jkoudys · 2019-05-26
I come across this one all the time, but it's usually in the form of "I know you're wrong, because person X made an argument that I don't understand, but this misunderstood summary of that argument says you're wrong".
Happens all the time with the old Donald Knuth chestnut about "premature optimization". Half the time I hear it, it's from people who don't want to optimize at all. http://www.joshbarczak.com/blog/?p=580
Jasper_ · 2019-01-05
> We dispatch instanced draw calls where each instance corresponds to a segment’s quad. The vertex shader finds all of the information it needs from the primitive offset and segment id of the quad it is working on.
Hm, any reason you're using instanced quads? From my understanding of how GPUs work, instancing only has big gains when you have a lot of vertex data in the draw call [0]. Instead of the instanced quads, have you considered making a vertex buffer containing two shapes: a + for the center/edges, and four quads for the corners. That way you could still do the whole thing in two draw calls, and you're not going through the slow instancing path. And if you have to blend the bg anyway (e.g. rgba background-color), you can just draw the whole vertex buffer in one go to skip the extra draw call.
[0] http://www.joshbarczak.com/blog/?p=667
Const-me · 2018-06-19
Any shader.
You can render a single quad and calculate UV in the pixel shader. Geometrically, this is the most accurate method.
You can do without any shaders, write a CPU code that builds a reasonably dense (about 8x8 pixels/triangle) static geosphere mesh with position and texcoord channels.
You can also build a reasonably dense grid mesh occupying just the screen with just the positions in clip space, and calculate UV channel in the VS based on the rotation.
GS will work too but I’m not sure it makes sense performance-wise. People normally use GS-es to implement small dynamic objects. For static geometry I won’t be surprised an immutable buffer will be faster, just because that’s what hardware & drivers are optimized for. See e.g. this http://www.joshbarczak.com/blog/?p=667
katastic · 2017-10-27
"'Premature optimization is the root of all evil' is the root of evil"
https://medium.com/@okaleniuk/premature-optimization-is-the-root-of-al…
http://ubiquity.acm.org/article.cfm?id=1513451
http://www.joshbarczak.com/blog/?p=580
http://scottdorman.github.io/2009/08/28/premature-optimization-is-the-…
It's basically an excuse to not think about the performance or implementation of your entire product until the end and then, when you use a profiler and chop away "10%" here and "20%" there, you still end up with a slow-as-piss program with every function taking less than 1% total time. Then what do you do?
Oh yeah, what you should have done in the first place. _Think_ about how your program actually functions so you can remove all of the insane systemic, architecture decisions you made that all bleed a fixed amount of time every single function call. That's the difference between an engineer, and script kid. If you're not reasoning about _the entire platform_ (all the way down to the cache lines), you're not engineering. You can abstract all you want, but those abstractions don't magically prevent the underlying hardware and architectural decisions from affecting the product. Abstractions tools (read: approximations!) for high-level reasoning. They're not magic "you don't have to think [about low level implementation]" spells.
Actual experts keep trying to warn you guys about abusing that quote, but nobody apparently…