Deftly solving compatibility problems by withholding information

Raymond Chen

One of the continuing compatibility problems that plagued Direct3D was the way it reported texture formats. Historically, the way an application checked which texture formats were available was by calling Enum­Z­Buffer­Formats and passing a callback function which is called once for each supported format. The application’s callback made some sort of decision based on the information it received. The problem was that any time a new format was added, a bunch of programs ended up not working. Either the new format confused them, or the change in the order of the formats violated some assumption. For example, they may have assumed that if a video card supports R8G8B8 format, then it will always be the first one in the list. For a time, the compatibility strategy was to try to detect what flavor of Direct3D the application was designed for and manipulating the list of supported formats in a way to keep that application happy, say by ordering the formats in a particular way or suppressing some formats from the list. In Direct3D 8, a new direction was taken: Ask, don’t tell. Instead of the application being told what formats are available, the application asks, “Do you support format X?” and Direct3D answers “Yes” or “No.” This solves both types of problems: Applications never saw a format they didn’t expect, because if they didn’t expect it, they would never ask for it in the first place. And applications always saw the supported formats in the order they requested, because the application chose what order they asked for them. The main casualties of the new design were diagnostic programs which listed technical details of your video card. They no longer were able to get a list of all supported formats; instead, they had to have a table of all the formats and ask for them one at a time. There was one company that objected to this new design because they wanted their program to support all texture formats, even the ones that didn’t exist at the time the program was written. This is just another variation of Sure, we do that. “Oh look, this video card supports pixel format 826. I’m going to use it! Just one question, though. What’s pixel format 826?”

They broke their problem into two parts and were asking for help with the first part, unaware that even if the managed to solve that part, they were stuck with the impossible second part!


Discussion is closed.

Feedback usabilla icon