How do sRGB color-space textures (especially compressed ones) interact with blending? First, let's define some terms: An image is "sRGB encoded" if the linear colors have been remapped using the sRGB encoding. This encoding is meant for 8-bit storage of the textures and normalized colors from 0.0 to 1.0. The "win" of sRGB encoding is that it uses more of our precious 8 bits on the dark side of the…
As I've mentioned in the past, one of my goals with this blog is to launch my post-development career in tech punditry and eventually author an O'Reilly book with an animal on the cover.* So today I'm going to add click-baity titles to my previous pithy quotes and tell you about that one weird trick that will let you beat the experts and write faster code than the very best libraries and system…
A while ago I tried to make a case for solving domain-specific problems, rather than general ones . My basic view is that engineering is a limited resource, so providing an overly general solution takes away from making the useful specific one more awesome (or quicker/cheaper to develop). Some people have brought up YAGNI , with opinions varying from "yeah, YAGNI is spot on, stop building things…
This is part five of a five part series on coroutines in C++. Getting Past the Names Coroutines Look Like Factories co_await is the .then of Coroutines We Never Needed Stackful Coroutines A Coroutine Can Be An Awaitable The relationship between awaitables and coroutines is a little bit complicated. First, an awaitable is anything that a coroutine can "run after". So an awaitable could be an object…
This is part for of a five part series on coroutines in C++. Getting Past the Names Coroutines Look Like Factories co_await is the .then of Coroutines We Never Needed Stackful Coroutines A Coroutine Can Be An Awaitable You've probably seen libraries that provide a "cooperative threading" API, e.g. threads of execution that yield to each other at specific times, rather than when the Kernel decides…
This is part three of a five part series on coroutines in C++. Getting Past the Names Coroutines Look Like Factories co_await is the .then of Coroutines We Never Needed Stackful Coroutines A Coroutine Can Be An Awaitable One more intuition about coroutines: the co_wait operator is to coroutines as .then (or some other continuation queueing routine) is to a callback/continuation/closure system. In…
This is part two of a five part series on coroutines in C++. Getting Past the Names Coroutines Look Like Factories co_await is the .then of Coroutines We Never Needed Stackful Coroutines A Coroutine Can Be An Awaitable In my previous post I complained about the naming of the various parts of coroutines - the language design is great, but I find myself having to squint at the parts sometimes.…
This is part one of a five part series on coroutines in C++. Getting Past the Names Coroutines Look Like Factories co_await is the .then of Coroutines We Never Needed Stackful Coroutines A Coroutine Can Be An Awaitable I really like the C++20 coroutine language features - coroutines are a great way to write asynchronous code, and the language facilities give us a lot of power and client code that…
Chandler Caruth (I think - I can't for the life of me find the reference) said something in a cppcon talk years ago that blew my mind. More or less, 95% of code performance comes from the memory layout and memory access patters of data structures, and 5% comes from clever instruction selection and instruction stream optimization. That is...terrible news! Instruction selection is now pretty much…
HiZ tracing for screen space reflections is an optimization where the search is done using a hierarchial Z-Buffer (typically stashed in a mip-chain) - the search can take larger skips when the low-res Z buffer indicates that there could not possibly be an occluder. This changes each trace from O(N) to O(logN). The technique was published in GPU Pro 5 , but as best I can tell, the author found out…
Four years ago I wrote a short post describing a dumb race condition in our reference counted art assets. To recap the problem: X-Plane's art assets are immutable and reference counted, so they can be accessed lock-free (read-only) from rendering threads. But X-Plane also has a lookup table from file path to art asset that is functionally a table of weak references; on creation of an art asset we…
I just noticed this effect while I was brushing my teeth. The faucet in the sink is: Chrome (or stainless steel) or some other reflective "metal" and Reasonably glossy and Kinda dirty. As I looked down, I could see specular reflections from the lights above the mirror and I could see calcium deposits on the surface of the faucet itself. And...then I noticed that they didn't have the same parallax.…
A thing I have done is attempt to hard shut down my Mac using the shell (e.g. sudo shutdown -r) and accidentally taken down one of our servers that I was ssh'd into. To fix this and generally have more awareness of what the heck I am doing, I use a .profile script to change the Terminal theme when logging into and out of remote servers via SSH. echo BashRC function tabc { NAME=$1; if [ -z "$NAME"…
Brent Simmons on ETAs for software releases : This is all just to say that app-making is nothing like building a house. It’s more like building the first house ever in the history of houses, with a pile of rusty nails and your bare hands, in a non-stop tornado. He put this at the end of the article, but I think it's the most important lesson here: it's hard to estimate how long a coding task will…
I am looking at performance on our latest revision of X-Plane Mobile, and I've noticed that the performance bottlenecks have changed from past versions. In the past, we have been limited by some of everything - vertex count, CPU-side costs (mostly in the non-graphics code, which is ported from desktop), and fill rate/shading costs. This time around, something has changed - performance is pretty…
OpenGL, Metal and Vulkan all have different ideas about which way is up - that is, where the origin is located and which way the Y axis goes for a framebuffer. This post explains the API differences and suggests a few ways to cope with them. I'm not going to cover the Z axis or Z-buffer here - perhaps that'll be a separate post. Things We Can All Agree On Let's start with some stuff that's the…
Fantastic lightning talk from this year's cppcon : This was what I was trying to get at in advocating for not going to the Nth degree with C++ complexity. We have finite cognitive budgets for detail, and the budget isn't super generous, so maybe don't burn it on Boost?
Two decades ago when I first started working at Avid, one of the tasks I was assigned was porting our product (a consumer video editor - think iMovie before it was cool) from the PCI-card-based video capture we first shipped with to digital video vie 1394/Firewire. Being the fresh-out-of-school programmer was, I looked at this and said "what we need is a hardware abstraction layer!" I dutifully…
Over a decade ago, I wrote a blog post about WorldEditor's file format design and, in particular, why I didn't reuse the serialization code from the undo system to write objects out to disk. The TL;DR version is that the undo system is a straight serialization of the in-memory objects, and I didn't want to tie the permanent file format on disk to the in-memory data model. That was a good design…
Normally I use this blog to complain about things that are broken, but I want to give credit here to Apple, for their WWDC 2018 video turn-around time . The first Metal session ended at 9 pm EDT and at 9:30 AM the next day it's already available for download. That's an incredible turn-around time for produced video, and it shows real commitment to making WWDC be for everyone and not just the…
I have, over the years, written more posts on VBOs and vertex performance in OpenGL than I'd like to admit. At this point, I can't even find them all. Vertex performance is often critical in X-Plane because we draw a lot of stuff in the world; at altitude you can see a lot of little things, and it's useful to be able to just blast all of the geometry through, if we can find a high performance…
When we first put deferred rendering into X-Plane 10.0, complete with lots of spot lights in-scene, I coded up stencil volumes for the lights in an attempt to save some shading power. The basic algorithm is: Do a stencil pre-pass on all light volumes where: The back of the volume failing increments. This happens when geometry is in front of the back of the light volume - this geometry might be…
Here's a riddle: Q: What does a two year old and OpenGL have in common? A: You never know when either of them is going to flush.* In the case of a two-year old, you can wait a few years and he'll find different ways to not listen to you; unfortunately in the case of OpenGL, this is a problem of API design; therefore we have to use a fairly big hammer to fix it. What IS the Flushing Problem? Modern…
I've tried to write this post twice now, and I keep getting bogged down in the background information. In X-Plane 11.10 we fixed our long-standing problem of camera shake, caused by 32-bit floating point transforms in a very large world. I did a literature search on this a few months ago and didn't find anything that met our requirements, namely: Support GPUs without 64-bit floating point (e.g.…
Periodically in the coarse of writing an OpenVR app, I find that SteamVR can't talk to my HMD. One of the 500 processes that collaborate to make VR work has kicked the bucket. Here's the formula to fix it. First, kill the process tree based on OVRServer_x64. All the Oculus stuff should die and then immediately respawn. Minimize their portal thingie. Kill every vrXXX process (vrserver,…