Adam Sawicki - Homepage View RSS

Graphics programming, game programming, C++, games, Windows, Internet and more...
Hide details



Patch WCX - Total Commander Packer Plugin for Diff/Patch Files 7 Nov 12:10 AM (10 days ago)

Working with large diff/patch files can be difficult. If you use Total Commander file manager, my new project can help you with it.

With Patch WCX, you can ➡️ open a patch like an archive, ➡️ navigate its directory tree, and ➡️ view, ➡️ extract, or ➡️ delete just the changes for individual files you need.

Download latest release

I also prepared a short video, where I demonstrate all these features in less than 1 minute. (Recorded and edited manually, not AI-generated.)

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

Block Wizard - Remake of My Old Online Game 30 Oct 12:36 PM (17 days ago)

My puzzle game Block Wizard is back! Originally released in 2010 as a Flash game, it now has a web remaster that you can play directly in a modern browser, with mouse or touch controls.

Block Wizard combines match-3 puzzles with RPG-inspired progression: match blocks by color or symbol, earn experience, upgrade your skills, and spend mana to cast spells. Special blocks and cascading matches add new challenges as you work your way through 50 levels.

Give it a try — it is free to play, with no download or installation required. Can you complete all 50 levels?

PLAY >

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

6 Reasons Why Programming Is Especially Exposed to AI Automation 27 Oct 3:52 AM (21 days ago)

Summary: While AI may transform our world in many ways, it seems to me that programming is especially exposed to automation. Below I share 6 specific reasons why.

Many decades ago, people imagined that advances in cybernetics would give us intelligent machines in the form of humanoid robots, speaking in metallic voices and helping people with various physical tasks.


Robby the Robot from "Forbidden Planet", a sci-fi film from 1956

Things have developed differently. AI in the form of LLMs can do some intellectual work and, together with other models, generate realistic speech, images, and video, while general-purpose robots manipulating physical world are still very clumsy and far for being able to help us in everyday chores.

View Joanna Maciejewska’s post on X

I want AI to do my laundry and dishes so that I can do art and writing, not for AI to do my art and writing so that I can do my laundry and dishes. — Joanna Maciejewska

Switching to programming, I still remember reading the book "The Mythical Man-Month" by Fred Brooks a long time ago. The author argued that despite advancements in more convenient, higher-level programming languages, "there is no silver bullet" - no single development can provide an order of magnitude improvements in programming productivity. The argument behind it was that we can reduce the "accidental complexity" of the code (boilerplate code, manual memory management, friction with language syntax, etc.), but there is always "essential complexity" left to handle. If an app needs to provide 5 features, we need to specify all these 5 features fully and precisely how they should work. No matter how high level is the description, it always ends up being... some form of code.

I was thinking back then that a breakthrough would require computers to think like humans: take imprecise, incomplete requirements and turn them into code. My opinion was that programming requires knowledge, skill, and experience, but also analytical thinking and creativity. If computers could ever do it, surely they could do much of the other intellectual work that humans do, leading to changes much broader than just affecting programmers' jobs. I still share this opinion, except now we know it happened.

AI will likely transform our world in many ways, and I don't dare to predict what the future will bring. Right now, however, it seems to me that the nature of programming makes it especially exposed to automation. If we think about why that is, we can identify a few specific reasons:

  1. Intellectual rather than physical work. Programming is an intellectual job (white-collar), largely involving language: both natural language and programming languages. This makes much of the work accessible to LLMs through a computer interface. Professions less affected for now are those that require working with hands in our 3D physical world (blue-collar), like a barber, plumber, electrician, construction worker, car mechanic, truck driver, policeman, firefighter, soldier, etc.
  2. No direct contact with the client. Programming is about working with data, knowledge, documents, code, and machines, and they do not care whether it's a person or another machine operating them. Sure, doing a good programming job also requires talking to other people, like fellow programmers, and managers, but work happens mostly through digital artifacts. Professions less affected are those that involve direct contact with other people (or animals), like doctors, vets, waiters, bartenders, real estate agents, sales representatives, priests, or teachers.
  3. Few formal barriers to entry. Ordinary software development generally doesn't require a professional license or a particular degree. There are exceptions and requirements in specific industries, but there is usually no rule saying that every piece of code must be written by a certified human programmer. In regulated professions, such as medicine or law, professional licensing can create an additional barrier between automating individual tasks and replacing the person providing the service.
  4. Automatically and objectively verifiable results. The results of programming work can be verified automatically to the large extent thanks to automated testing (unit tests, integration tests, etc.), so LLMs can freely make mistakes and iterate, with no human operator needed to even validate the output. We can see it happening now as increasing number of programmers skip thorough review of the AI-generated code, because this would become the bottleneck. The output of other intellectual work, like copywriters, journalists, artists, etc. is endangered less because it needs a skilled human to at least validate the result.
  5. Responsibility can be separated from implementation. Even if AI can provide great help and significantly speed up the work of doctors, lawyers, accountants, or C-level executives, there are decisions for which a person must take responsibility, sometimes with their name and signature at the bottom of the page and a risk of punishment then they make a catastrophic mistake. Programmers, on the other hand, are not typically punished for making errors in the code. We perform tests on the code instead. That makes it possible to automate substantial parts of the job.
  6. No human face needed. There is another profession that involves working with words, including making promises that may never be delivered: politicians 🙂 But I think politicians are less likely to be replaced by LLMs because, in democratic countries, we want a real human to vote for, showing up on our screens, dressed elegantly and promising various things to us. Something similar applies to musicians: AI can generate music, but part of the appeal of a concert is seeing a real musician perform live. We programmers, on the other hand, are usually not presented to the end users of our software with our faces or names visible on the front page of the app. Users generally care more about whether the software works than whether its code was written by a human or AI.

When thinking about my life, I can see that we have gone through several stages in how programmers are commonly perceived. First, when I was a teenager, there was the stereotype of a computer geek. This was before smartphones or social media, so spending time at home with a computer, playing games or learning programming instead of going out to play football, could make someone seem geeky, weird, or socially awkward. Then the perception flipped as mainstream media noticed that working in IT was a good career with high demand and high salaries. Possibly, we are now entering another phase, as the situation of programmers and the public perception of them change. Some young people I've spoken with are already choosing other careers because they don't believe a career in IT is future-proof.

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

Two articles: Time Measurement in Game Programming, Writing Efficient C++ Code 25 Sep 12:12 PM (last month)

I've translated to English and published two of my articles that have been published in Polish in paper magazine "Programista" many years ago. Some of the information may be outdated, but I think they may still be helpful.

I would like to point especially to the first article, and the chapter about Frames per Second (FPS). This unit is really the number of cycles per second: 1/s = Hz, and as such, it is a non-linear mesure in respect to the time it takes to process or render a single frame. Thus, we shoudln't ever say "I improved my game performance by 5 FPS", because it doesn't mean anything without knowing how many FPS did we have before the opimization. Check the article to learn more…

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

First Look at Epic Games Lore VCS 18 Jun 1:26 PM (5 months ago)

June 17th, 2026, Epic Games announced Lore - a new version control system for software developers, to compete with Git and Perforce. Being old enough to have worked with the old CVS and SVN, and having experience working with Git and Perforce, I am quite interested in what changes this new system brings.

In my article Thoughts Beyond C++ from December 2024, I described my opinion about the problems I can see with current version control systems and the improvements a better one could bring, especially for game development. Let's see whether Lore advances any of these topics.

Key pages about Lore:

I didn't test the app myself so far, but I've read some of the docs to get an idea of what it is and how it compares to Git and Perforce. tl;dr: It looks promising, although not revolutionary. Here is a summary and my thoughts.

General

The fact that it's made by Epic, the company behind Unreal Engine and Fortnite, is already a big plus, because it increases the chances of it being well supported and maintained. Despite being a pre-release version 0.x as a standalone product, it's already battle-tested, because when it was formerly called Unreal Revision Control, it was the built-in version control system for UEFN, where creators have been using it to version their Fortnite islands. Which means its lineage is already used in UEFN, but the standalone open-source product should still be treated as early.

Another advantage is that it's open source, under an MIT license, which also means it's free to use for personal as well as commercial purposes. Git is also open source, but other VCSs like Perforce/P4/Helix Core, Plastic, or Ark are not. Only the desktop client is available as a binary download and is not open source yet because it depends on proprietary components, but Epic is committed to open-sourcing it later.

The fact that it's written in Rust is also a good sign, increasing the chances of good performance (because Rust is a native language, unlike Java, C#, or JavaScript), as well as security and stability (because strong memory safety in Rust helps avoid many bugs that are notorious in C and C++). Offering APIs for C/C++, C#, Rust, Go, Python, and JavaScript is also great, because it can facilitate the development of tools that can integrate with this system - whether alternative GUI clients just for Lore, or support for it added to various text/code/asset editors.

Of course, a VCS like this encompasses many design decisions and many technical details behind the actual implementation or the shape of the API, CLI, or GUI. I will avoid low-level details here (like the use of Merkle trees) and instead focus on what's visible to the user.

Handling large files

The main promise of Lore is better handling of large binary files compared to Git (including Git with LFS). Epic claims that binary files rather than text files are natural to their system, with no conversions like line endings happening in the background, and any text-based processing implemented on top of the core system. Data stored in a repository is deduplicated not only at the level of an entire file, but also per fragment, which saves space even when only a part of a large binary file changes between revisions. Their documentation states that thanks to clever algorithms using data hashing, it works even when some data is inserted in the middle of a file! This is great news for game developers and other developers working with large binary assets.

Moreover, Epic claims that Lore is scalable in multiple "axes", allowing it to work efficiently with many repositories, many branches per repository, many files, large binary files, etc. If this is true, it makes the system a good fit for extensive software projects, like video games.

Lore seems to follow Git's approach of downloading the data from the remote repository first to a hidden directory .lore (similarly to .git), and then copying it to the working directory files. It means that, unlike Perforce, it may require disk space of at least 2x the working copy size, similarly to Git with LFS (subject to compression and deduplication). Lore claims to use sparse/lazy fetching as the default mode, but I suspect this just means that only the selected revision of all the files is downloaded rather than all their historical versions.

The advantage of this approach is, of course, the ability to inspect commit history, switch branches, diff, commit, etc. fully offline (unless it needs fragments that were never fetched into the local cache), which is not possible in Perforce.

One feature that can help limit the required disk space is support for "views", which are inbound filters declaring which paths in the repository the user wants on disk. Unlike views in Perforce, this is not a fully flexible mapping between repository paths and local paths. Another nice feature is the possibility for multiple working copies on a user's machine to share a common local fragment store.

Comparison with Git

Lore's command set looks very similar to Git's, which might be considered an advantage or a disadvantage, depending on how you see it. Cheap and lightweight branches are definitely a plus. But I personally think Git is overly complicated, especially for non-programmers. Lore inherits most of its concepts. There is also a concept of "commit", followed by "push". Yet, Lore simplifies a few things compared to Git:

First, Git is a decentralized version control system at its core. Lore, on the other hand, defines one central repository. There are no multiple "remotes" to be added to the local cloned repo. Support for forks is planned for the future.

In Git, I never liked the concept of staging. The stage (index) in Git stores an additional copy of the files, so we may have a different version of the file contents committed as the latest on the current branch, a different one modified in the working directory, and a third one currently staged. That third version will be committed. I think this is confusing and unnecessary. Lore also has a concept of "stage" followed by "commit", but in Lore, staging pins the path, not the content: the commit captures whatever the file looks like at commit time, which I consider more intuitive.

Update 2026-06-19: As comments to my post on Blusky, Karl Schmidt noticed that Lore docs don't mention anything like "shelf" or "stash", while Sidney said that he considers Git staging useful as lite commits when trying some hacks. I still think that these are convenience features that can be built on top of local branches and commits, provided by a client app, and don't necessary need to be part of the core system.

Just like Git, Lore supports merges with squashing (the design doc mentions it, but I can't find it in the CLI documentation). My understanding is that, just like in Git, a squash commit forms a completely unrelated revision not parented to the branch being merged. So, we still need to choose between squashing (so we have a clean and simple history) or not squashing (so we retain the history of all intermediate commits). I'm hopeful that one day, some VCS will introduce a hierarchical commit history, so we don't need to choose between these options, but instead can expand and collapse a group of fine-grained commits into one larger feature/branch/release. But for now, Lore seems to strictly follow the approach popularized by Git.

Similarly to Git submodules, Lore also offers mounting a linked repository at a path inside another repository. It actually offers two similar features: "link" - which is stored in the repository - and "layer", which stays limited only to the local working copy. Unlike Git submodules, both of these Lore features offer cloning only a selected subdirectory of the repository, which I think is a major improvement.

Another important difference is access control. Lore has a concept of "partitions" as access boundaries: knowing a content hash is not enough to fetch the data unless the user has access to the partition where it lives. At the same time, identical fragments can still be deduplicated internally. This sounds useful for large studios with contractors, external partners, licensed IP, or assets that only some teams should see.

Lore also separates branch identity from branch name. In Git, a branch is basically a named reference to a commit. In Lore, a branch has a stable internal ID, while the human-readable name is a mutable mapping to that ID. This seems like a cleaner model for large centralized repositories with many long-lived, renamed, or archived branches.

Lore considers commit history immutable (kind of like a blockchain?), so there is no force-push or history rewrite. If a secret API key is pushed accidentally or the legal department orders the removal of something that has already been published, the file obliterate command is offered instead. It erases the file content, causing a "this fragment was obliterated" error when trying to fetch that data later. I think it's a nice and clean solution.

By the way, this doesn't solve the problem of removing accidentally leaked data in a commit message. The revision amend command can modify only the latest commit's message. I'm sure they will face this problem sooner or later, and it may be difficult to solve, because the system-design doc says a revision state contains a hash of serialized metadata, and that revision metadata includes the commit message.

Among smaller features, a nice command that I noticed in the docs is branch merge into, allowing the current branch to be merged into a target branch. Git doesn't have that. In Git, we have to switch to the target branch and only then can we merge from a source branch.

Other features

Lore supports file locking, but currently it “informs rather than blocks”. Lock enforcement is planned for the future. But I think this may already be OK, as long as all the client apps using Lore across the company respect these locks.

An interesting group of commands is file dependency. It allows setting dependencies between files. I can imagine the feature being used for huge asset repositories where a user or tool does not want to materialize "some folder," but rather "this asset and everything it needs." The CLI exposes dependency-based selective sync that only clones specified files and their dependencies.

Summary

Overall, I think Lore looks promising. It is very similar to Git, but it improves on many aspects that are important in game development. Epic, as a major player in this area, really has a chance to facilitate its adoption. Whether it really surpasses Git and Perforce in some applications depends a lot on the execution - whether it scales to large projects as well as promised, and whether the GUI client and IDE extensions will offer a good user experience.

But I think it could go further. The game industry faces challenges with managing large files beyond game source code and its accompanying assets. Thanks to the first-class API support, maybe Lore can be utilized not only by programmers' software committing their code changes, but also by other kinds of tools such as:

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

Floor and Ceil Versus Denormals on CPU and GPU 23 May 12:55 AM (5 months ago)

Recently, I dove deep into floating-point numbers and their behavior. Somehow, this topic haunts me in my programming practice since I created Floating-Point Formats Cheatsheet back in 2013 and also released a comprehensive article The Secrets of Floating-Point Numbers in 2024.

This time, I would like to focus on one specific question:

What is the result of floor(-1.175493930432748e-38) ?

Note: Hexadecimal value of our input number is 0x807FFFFD.

Floor, ceil, trunc, round

To recap, floor, ceil, trunc, round are functions available in the standard library of C, C++, as well as shading languages: HLSL and GLSL. Each of them transforms a floating-point number into an integral floating-point value, but using different rounding rules.

Note this is not about a conversion from float to int. The result of these functions is still a float, just having only integral part. When the input is already integral, the value is returned as-is. Otherwise, it gets "snapped" to the nearest integer in a specific direction:

Examples:

Note: IEEE 754 floating-point numbers distinguish between positive and negative zero, so some results below are -0.0 rather than 0.0 to visualize this distinction.

floor( 5.7) =  5.0   ceil( 5.7) =  6.0   trunc( 5.7) =  5.0   round( 5.7) =  6.0
floor( 0.2) =  0.0   ceil( 0.2) =  1.0   trunc( 0.2) =  0.0   round( 0.2) =  0.0
floor(-0.2) = -1.0   ceil(-0.2) = -0.0   trunc(-0.2) = -0.0   round(-0.2) = -0.0
floor(-5.7) = -6.0   ceil(-5.7) = -5.0   trunc(-5.7) = -5.0   round(-5.7) = -6.0

When talking about round, there is also a question what happens when we are exactly halfway, like round(2.5). Various programming languages define it differently:

Knowing all this, we can answer our main question:

According to mathematical rules, floor(-1.175493930432748e-38) = -1.0, because the number is between -1 and 0.

Denormals

However, those of you who know more about the structure of floating-point numbers may notice that our input value is a subnormal. Subnormal numbers, also called denormalized numbers or denormals, are values so small (so close to 0) that they use a special representation where the implicit leading 1 bit is no longer assumed. They have exponent = 0. The minimum positive normalized value representable by 32-bit floats is 1.18 * 10^-38, while the minimum value representable as denormalized is 1.4 * 10^-45, so our number falls in that range.

We wouldn't need to care about denormals if not for the fact that:

This is the problem I stumbled upon recently. In most cases, it doesn't matter. For example, when rendering graphics, the difference between such a small number and 0 would produce an indistinguishable difference in results. After applying functions such as floor and ceil, however, the difference is significant:

If the platform preserves denormals:

floor(-1.175493930432748e-38) = -1.0   ceil(-1.175493930432748e-38) = -0.0
floor( 1.175493930432748e-38) =  0.0   ceil( 1.175493930432748e-38) =  1.0

If the platform flushes denormals to 0:

floor(-1.175493930432748e-38) = -0.0   ceil(-1.175493930432748e-38) = -0.0
floor( 1.175493930432748e-38) =  0.0   ceil( 1.175493930432748e-38) =  0.0

The behavior of a specific platform may depend on many factors, such as flags used during compilation of our source code, as well as some floating-point modes controlled in runtime. It may be an unexpected source of nondeterminism between CPU and GPU, as well as between GPU vendors.

I've performed a few tests. Here are my results:

This is not the first time we can see Nvidia taking shortcuts to achieve maximum performance of their GPUs 😉 We could see another example in the article "Mipmap selection in too much detail" by Pema Malling.

Note: Architectures may support two related modes: flushing denormal results to zero and treating denormal inputs as zero. The behavior observed here suggests the latter.

UPDATE: As Pete Cawley commented on X, DirectX Specification, chapter 3.1.3.2 "Complete Listing of Deviations or Additional Requirements vs. IEEE-754" actually requires GPUs to flush denorms on input and output of any floating point operation.

Deterministic solution

If, for any reason, you need an implementation of these functions that behaves consistently, deterministically, and preserving denormals across CPUs and all GPUs, you can use the following HLSL code implementing custom floor and ceil using simple bit tricks:

float DeterministicFloor(float x)
{
  if ((asuint(x) & 0xFF800000u) == 0x80000000 && // sign = 1, exponent = 0
    (asuint(x) & 0x007FFFFFu) != 0) // mantissa != 0
  {
    return -1.0f;
  }
  return floor(x);
}

float DeterministicCeil(float x)
{
  if ((asuint(x) & 0xFF800000u) == 0 && // sign = 0, exponent = 0
    (asuint(x) & 0x007FFFFFu) != 0) // mantissa != 0
  {
    return 1.0f;
  }
  return ceil(x);
}

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

DirectX 12 News from GDC 2026 - My Comments 15 Mar 1:02 PM (8 months ago)

Game Developers Conference (GDC) just took place on 9–13 March 2026 (renamed this year to “GDC Festival of Gaming”). Microsoft announced lots of interesting news during the event regarding further development of DirectX 12, its accompanying libraries, and tools. I didn’t attend the conference this year, but the announcements were also published on their DirectX Developer Blog. In this article, I will gather and summarize these news items, provide links to the appropriate web pages, and include my comments.

When I was working at AMD, I was deeply involved in this area - writing code, publishing articles on the GPUOpen website, attending GDC, and even giving a talk there twice. Back then, I didn’t post much about it on my personal blog, as I would have needed to watch my words and secure corporate approvals. Now, as I’m just a programmer at Plastic - a small game development studio - I can observe these developments from the outside and comment on them freely, which I am going to do with brutal honesty 🙂 If I had a YouTube channel, I would record a “reaction” type of video, but since I’m writing a blog, this will be my reaction in text form.

Disclaimer: Everything in this article is based on information shared publicly by Microsoft and GPU vendors and could be gathered by any graphics programmer. No insider information was used.

Introduction

Every year, GDC is the pinnacle moment for game developers, including rendering programmers. Whether it’s worth going there is a separate question, considering the cost of travel (especially for someone living in Europe) and the price of a hotel in San Francisco. There are other important events as well: Nvidia has GTC, Epic has Unreal Fest, Vulkan has the Vulkanised conference as its main event, and graphics researchers gather at SIGGRAPH. But GDC in March is the annual opportunity for people from all these worlds to get together, listen to talks, and socialize, so we should all pay attention to what happens there.

DirectX Innovation at GDC 2026 is the article announcing the talks Microsoft delivered during the event. “DirectX State of the Union” is the main one, spanning a variety of topics related to recent DX12 developments. “DirectX is Bringing Console-Level Developer Tools to Windows” is also very interesting, announcing unprecedented progress in graphics tooling, especially PIX. Microsoft was joined on stage by representatives of all four current PC GPU vendors (AMD, Intel, Nvidia, Qualcomm), who normally compete with each other. This is always a sign that something important is happening (like the memorable presentation "Approaching Zero Driver Overhead in OpenGL" from GDC 2014, which I mentioned as part of the story in my article Graphics APIs – Yesterday, Today, and Tomorrow). Hopefully video recordings or slides from this year’s talks will available online after some time. For now, we need to analyze what we have - just the web pages they published.

GPU vendors also posted their announcements simultaneously, expressing support for Microsoft’s announcements.

On one hand, for Microsoft and GPU vendors (also called Independent Hardware Vendors - IHVs), GDC is a major milestone every year. Developers crunch on their code to finish demos, articles and slide decks are prepared, travel and meetings get scheduled... On top of the engineering effort, there is surely politics involved. Cooperation between teams in a big corporation is difficult enough. Here, Microsoft needed to coordinate with all PC GPU vendors. I believe it is even more challenging for Khronos, where all hardware and software vendors that care about graphics (both desktop and mobile) come together, but I’m sure it was a hectic time there as well.

But on the other hand, what has been announced in these talks will only ship to the public in the upcoming months, basically “when it’s done”, so nothing really changed this week. We just received new information that had been secret so far. It’s like watching a teaser video for a new game (when we read an article announcing new technology) or maybe a gameplay trailer (when we can see an actual API spec), with the game shipping later this year.

1. Tool improvements

The main blog post on DirectX Developer Blog:
DirectX: Bringing Console-Level Developer Tools to Windows

This topic is the most interesting and most important for me personally. Compared to the debuggers we have for CPU programming languages (whether high-level like Python or native like C and C++), I think GPU debugging is really in the Stone Age. GPU crashes (also known as Timeout Detection and Recovery - TDR - whether caused by a timeout or a memory page fault) are especially difficult to debug. Sure, frame capture tools like PIX on Windows and RenderDoc are helpful in debugging various problems, but they require a frame that successfully rendered until the Present() call. The Debug Layer and GPU-Based Validation also do a great job. Finally, crash capture tools like DRED and custom vendor tools - Nvidia Aftermath and Radeon GPU Detective - help identify the cause of a crash... when they work, because sometimes they don’t show any meaningful information.

I wish we had a proper debugger for shaders, just like we have debuggers for CPU code - with breakpoints, step-by-step execution, watching the values of local variables, etc. (They would likely need to be conditional breakpoints for a specific frame, draw call, and pixel coordinate or thread ID, because there are thousands of threads running simultaneously on the GPU and millions of them starting every frame.) Sure, PIX and RenderDoc offer shader debugging, but RenderDoc does it by emulating shaders on the CPU, which can break in many cases because it doesn’t show what really happens on the GPU. What if there are timing issues or race conditions, such as a missing barrier? What if there is a bug in the shader compiler for a specific GPU?

Of course, this is not as easy on the GPU as it is on the CPU, where a thread or a process can be suspended while the operating system, IDE, and other apps continue running. On a GPU, the entire chip may be busy executing just a single draw call. However, I can still imagine a scenario where the GPU is stopped, breaking into a debugging session, while the debugger runs on a separate machine or on the same machine with the desktop rendered using integrated graphics. In fact, stopping the entire machine and debugging it from a remote system connected through a network is possible using WinDbg, but that is kernel-mode, low-level, hardcore debugging. So we can say that making GPU debugging possible is mostly a matter of developing good high-level tools.

Despite the confidentiality of console SDKs, it shouldn’t be a secret if Microsoft disclosed it in the title of their talk that consoles like Xbox have better graphics tools than the PC. In DirectX: Bringing Console-Level Developer Tools to Windows, they announced a major update to PIX on Windows, along with other tools and APIs intended for debugging. Let’s see what exactly they announced.

DirectX Dump Files

First of all, they disclosed a plan to support new DirectX Dump Files (.dxdmp), containing a dump of the GPU state after it crashes. They will be available to open in PIX. It’s great to see they have buy-in from all GPU vendors, as this surely requires their deep involvement and support. It’s also great that there will be a toggle to adjust the trade-off between performance overhead and "actionability" (as they called it), since gathering more data may impact performance, which in turn could hide the bug. The “no overhead” mode, where supported, may even be suitable to leave always enabled for end users. Dump files will be available for manual management or collected by Microsoft via Watson.

This all looks very promising. I have just one concern. Based on the example screenshots shown from all four GPU vendors, I suspect this whole system may just be a generic placeholder, with the specific data gathered and displayed being highly dependent on the GPU. We can only hope that the actual crash dumping and the data gathered from the crash will be:

From the screenshots shown:

  1. I would score Nvidia the highest. Given the unreliable nature of GPU crash capturing, showing information like "Confidence: X%" or "Possible Cause 1/2/..." looks like a good direction.
  2. AMD seems to display the same information that the current text-based reports from Radeon GPU Detective contain. (A tool that I had the honor and pleasure to work on.) Which is great, because I know their crash capturing is very reliable. The information shown is sometimes just too low-level. For example, it is known that it shows a "Make Resident" event (also visible in this screenshot) as an internal driver operation, even if the developer didn’t explicitly call ID3D12Device::MakeResident.
  3. Intel scores the worst, as it shows raw GPU registers with cryptic names like VS_INVOCATION_COUNT_RCSUNIT_BE_ and their hexadecimal values. It’s great that they are able to dump the exact state of the GPU at the moment it crashed, but do they really believe game developers will read thousands of pages of their GPU documentation to make sense of it?

PIX API

Next, Microsoft announced the PIX API - a programmatic way to access all the data a PIX capture and the new crash dump can contain, available to C++, C#, and Python. This is a great step forward. It will definitely be useful for various kinds of automation. I can also imagine developing an MCP server, so an AI agent could use such captures to help with graphics debugging or performance optimization. It’s worth mentioning that by doing this, PIX is basically catching up with RenderDoc, which already has its own Python API.

DebugBreak

Next, they are going to add a HLSL intrinsic function DebugBreak(). See the specification: 0039 - Debugging Intrinsics. It will be similar to the assert macro known from C++ and other CPU languages, triggering an instant crash, which can help identify exactly where an asserted condition was hit - in which frame, which draw call or dispatch, and hopefully also with a pixel or thread ID. It definitely has a chance to work more reliably than my hacky ShaderCrashingAssert library.

Too bad they didn’t define any parameter that would allow the shader to return some data to the crash dump. Even a single uint or uint4 would make a huge difference. Dear Microsoft, can we have that, please???

I also wish that together with this “assert” function, they worked on some standardized “printf” function that would let shaders output messages and data while running, even without crashing. Having those two would move GPU debugging to the Medieval Ages. Implementing convenient logging in HLSL has been discussed many times, including in the good article An Experimental Approach to printf in HLSL by Chris Bieneman - still unofficial, despite the fact that he is a Microsoft employee. After this year’s GDC there are still no signs that Microsoft is working on standardizing this, unfortunately.

PIX event configurability

Then we have PIX events (also known as markers) - the begin/end events with custom strings that we use to organize our draw calls into a logical hierarchy for easier debugging in PIX or RenderDoc. Microsoft announced that they will finally be passed to the graphics driver. This is a huge thing. Let me explain why.

There are basically two ways graphics debugging tools can operate. The first is injecting themselves into the game process and intercepting all calls to the graphics API. That’s what PIX, RenderDoc, and GfxReconstruct do. This is great, because it captures all the calls and all the data at a high level, exactly as the game developer passed them. On the other hand, it causes multiple problems:

The second mode is a tool connecting directly to the graphics driver (e.g. through a socket) and fetching data from it. That’s how Radeon Developer Tools operate. It works independently of what game is running or how it was launched. The game process is not altered in any way. A strategic decision to implement tools like this has many advantages. They work very reliably. However, there is one big caveat: the calls that the driver sees are not necessarily the same calls that the game developer made using the graphics API.

In Vulkan, this is not such a big issue, because the driver basically implements the API “on the other side”. It can also expose new extensions (like VK_EXT_debug_utils) that are available to the game code for direct use. With DirectX 12, however, this is not that simple. The sequence looks like this: Game engine code -> DX12 API -> DirectX Runtime (Microsoft code) -> Device Driver Interface (DDI) API -> Driver. Some information gets lost along the way. This includes PIX events. Because of that, AMD had to define their own way of submitting events so they become visible in their tools, in the form of the AMD GPU Services (AGS) library or a replacement header for PIX events. See RGD documentation - Known issues and workarounds for more details. Now, with Microsoft changing their mind and allowing standard PIX events to reach the driver, this will no longer be necessary. Finally!

I hope that together with begin/end events, Microsoft will also pass to the driver the string names that we assign to our textures and buffers using ID3D12Object::SetName calls. Preferably also data set through ID3D12Object::SetPrivateData - that would provide much more flexibility. Their new PIX Markers spec mentions SetName to be passed to DDI. This is great, because currently, AMD tools fetch these names through the Event Tracing for Windows (ETW) mechanism, which is a workaround and doesn’t always work reliably. (Which is not a secret - see the article Viewing DirectX® 12 Named Resources with Radeon™ Memory Visualizer 1.3).

By the way, I personally like the Vulkan approach of formally defining a way to inject layers into the API. I believe it’s high time for Microsoft to do the same. I was secretly hoping they would add such support for layers a long time ago, but they still haven’t, so every tool like PIX, RenderDoc, GfxReconstruct, or GPU Reshape needs to implement its own solution and struggle with numerous issues. Nvidia Streamline seems to be an effort in this direction, providing a generic layer system for DX12, but because it’s made by Nvidia, unfortunately other GPU vendors didn’t join the effort to spread its adoption. (Hopefully they will have more luck with the Slang shading language.)

Live Shader Debugging

Microsoft also announced they are working on “real-time, on-chip shader debugging”. This almost sounds too good to be true. But they are giving themselves time until 2027, so I believe that by then they may be able to achieve it, with intense effort and support from GPU vendors. That would be the holy grail that could bring GPU debugging into modern times, catching up with CPU programming languages.

One big challenge in bringing this feature to PC is stopping the GPU and inspecting its state at the exact moment, as I described above. But another problem is showing and stepping through the shader code. I hope it won’t be the GPU assembly (ISA) or the intermediate language (DXIL, SPIR-V), but the real high-level shader language (HLSL, GLSL) as written by the game developer. Supporting this would require all stages of shader compilation to preserve the correlation between ISA instructions and high-level shader source lines, as well as between GPU registers and variables in the shader source. Shaders are highly optimized, with everything inlined. There is no call stack to inspect. Providing a decent debugging experience must therefore be a complex endeavor.

2. ML advancements

The main blog post on the DirectX Developer Blog:
Evolving DirectX for the ML Era on Windows

Let's say it plainly: machine learning using deep neural networks is, at a low level, largely about matrix multiplication. GPUs are great at that. We still call them "graphics processing units", but developers discovered a long time ago that they perform well for many other kinds of tasks. First it was breaking ciphers, then crypto mining, and now it's AI. At a high level, such workloads may look very similar to graphics, which is also about regular, massively parallel processing of vectors and matrices. However, when we dig deeper, there are many differences, including:

GPU vendors introduced dedicated hardware to accelerate these types of matrix multiplication ML workloads. Nvidia has been the most effective at marketing theirs, making sure that even average gamers have heard about Tensor Cores, but AMD also has its Wave Matrix Multiply-Accumulate (WMMA) instructions, and Intel has its XMX units. The problem is that they are available in purely compute-oriented APIs like Nvidia CUDA, AMD HIP/ROCm, and Intel oneAPI, not in graphics APIs and shader languages. They are also used in proprietary upscaling technologies: DLSS, FSR 4, and XeSS, respectively - all implemented as black-box libraries performing some vendor-specific magic under the hood.

Is this the desired and target state of things? Having a custom, proprietary, high-quality technology like DLSS surely gives a vendor some competitive advantage when gamers decide which graphics card to buy. But on the other hand, do GPU vendors really like the fact that precious transistors on their chips and their potential TOPS of computational power stay idle most of the time? I don't think so. I think the real issue is exposing these capabilities in a way that is unified across vendors, high-level, and convenient enough for game developers on one hand, while still utilizing the full performance potential of the hardware on the other.

Vulkan faces the same problem. They solve it in a typical Vulkan way - by introducing extensions. We have VK_KHR_shader_integer_dot_product, VK_KHR_cooperative_matrix, VK_KHR_shader_float16_int8, VK_EXT_shader_float8, and many others. In DirectX 12, Microsoft has made several attempts to offer similar capabilities, with mixed success.

Side note: GPU Work Graphs are not this kind of technology. This recent addition to the DX12 API allows the execution of entire graphs of different shaders. However, we still need to focus our implementation on individual threads and manually control how they are spawned. There is no automatic operator fusion or other optimization performed automatically, like ML frameworks do. Work Graphs are more intended for compute work serving rendering workloads, as an extension of Indirect calls that let the GPU spawn new work on its own. They provide more flexibility by supporting a switch to a different shader, as opposed to only changing the vertex/index buffers and the number of vertices/instances/threads, as in Indirect calls.

Here we are now, after GDC 2026, and Microsoft's current plans to expose these ML-related hardware capabilities seem to come from both angles at once:

1. As instructions available in normal shaders

These can be useful for implementing inference of small ML models as part of existing vertex/pixel/compute shaders. For example, this could include neural texture (de)compression, approximation of complex material and lighting models (BRDFs), character animation, or approximate physics simulation. In the future, we may have many small models evaluated every render frame.

These are not really news from this week, because they were announced and their specifications have been available for quite some time. Microsoft develops its HLSL language advancements quite openly by sharing HLSL specification proposals.

Long vectors, as specified in proposal 0026 - HLSL Long Vectors. It adds support for vectors with more than four elements, e.g. vector<float, 15>. Note that they are still normal variables, local to an individual shader thread.

Linear algebra, as specified in proposal 0035 - Linear Algebra Matrix. It adds a matrix type, such as Matrix<ComponentType::F16, 8, 32, MatrixUse::A, MatrixScope::Wave>, as well as vector-matrix and matrix-matrix operations like Multiply and MultiplyAccumulate.

Note that the matrix has many template parameters:

This API looks very clean and convenient. I believe they may have found a good abstraction. Hopefully, with enough effort put into developing shader compilers, it can also deliver good performance while utilizing the hardware capabilities of each GPU. My concern is whether the API will keep up with new hardware capabilities that GPU vendors may want to expose. By the time it ships in the retail SDK, they may already want support for more data types (like INT4) or even features that go beyond what the API offers, such as sparsity.

2. DirectX Compute Graph Compiler

That's a new announcement from GDC 2026. Microsoft teased it as a completely new technology that will consume entire ML models and optimize them for efficient execution on a specific GPU. It will feature "graph optimization, memory planning, and operator fusion". This is clearly an approach to executing ML workloads intended to keep the entire GPU busy for some time, similar to upscaling and other screen-space effects. They will likely execute as multiple compute dispatches, maybe even as separate command buffer submissions.

Note that ML frameworks can already do these things. With this project, Microsoft is basically creating another one, but tailored for cooperation with DirectX 12 and graphics workloads.

Note also that the graph approach is well known in the game development community. Advanced game engines often implement their own graphs representing render passes and dependencies between them, like the Render Dependency Graph in Unreal Engine. AMD also developed a similar solution called Render Pipeline Shaders. However, it never gained traction, possibly because developers saw it as overkill to employ LLVM to compile a custom domain-specific language. I'm not sure if it was ever used in any game. The project looks abandoned now. Game engines already have their own graph solutions, which are often simpler and based on C++ templates or macros.

Will the new DirectX Compute Graph Compiler allow game developers to create their own ML-based effects like DLSS or FSR, executed with comparable performance? I hope so. That would finally allow them to fully utilize these GPU hardware capabilities with their own code. But here we are only talking about inference. Designing and training an ML model, and gathering enough high-quality training data, is a separate topic. Training on data from a specific game title could be beneficial in some cases, but on the other hand, IHVs cooperating with many game developers and having access to so many games will still give them a competitive advantage when training their image upscaling super resolution and other models.

3. Advanced Shader Delivery

The main blog post on DirectX Developer Blog:
Advanced Shader Delivery: What’s New at GDC 2026
Specification:
Advanced Shader Delivery - Shader Compiler Plugin

This is basically yet another announcement of what they already announced before. The problem is this: every GPU has a different instruction set, so shaders cannot be compiled to native code like the .exe files of our games. The second stage of shader compilation (from DXIL/SPIR-V intermediate code to GPU ISA) currently happens inside the graphics driver. The shader compiler is basically one of the driver modules.

  1. In the old days of OpenGL and DirectX 11, different states of the graphics pipeline could trigger shader recompilation, so you might toggle some state and the next draw call would cause a massive hitch.
  2. In Vulkan and DirectX 12, we need to create Pipeline State Objects upfront, encapsulating all the states. This gives full control over when shader compilation happens, but one may argue that the cure is worse than the disease, because all the required combinations of states require so many PSOs that it takes a very long time to create them all at startup, or... creating them at runtime causes hitches again, this time explicitly triggered by the game.
  3. What Microsoft now proposes is precompiling and bundling these shaders into packages that can be downloaded over the Internet. Game storefronts like Steam and EGS will participate in this.

I'm not sure it's such a big deal. We will just change "compiling shaders..." to "downloading shaders...", and it will still happen whenever we update the game or the graphics driver. The only hope is that downloading these shaders will be faster than compiling them. The work done by shader compilers is difficult - trying to optimize the shader while still finishing the process within milliseconds. Allowing the compilation to take longer can result in better optimization. I remember debugging a game once that was supposedly hanging on startup, only to find out there were ray tracing shaders taking over a minute each to compile.

But the second feature they’ve announced may provide more performance benefits, even during game development, when shaders keep changing. Partial Graphics Programs will allow creating pipeline objects that contain only "pre-rasterization" shaders (like a vertex shader) or only a pixel shader, and later linking them together, which hopefully won’t require full recompilation at that point.

4. DirectStorage 1.4

The main blog post on DirectX Developer Blog:
DirectStorage 1.4 release adds support for Zstandard

I must admit I don't follow the development of this API very closely. Overall, it looks like a good idea. Update 1.4 brings support for the Zstandard aka zstd compression format, which is open, free, and developed by Meta. Before that, Microsoft promoted the GDeflate algorithm proposed by Nvidia. This change may be perceived as a step in the right direction - toward greater neutrality among GPU vendors.

On top of that, they presented the Game Asset Conditioning Library - a library offering pre-/post-processing of data, swizzling it so the core lossless compression algorithm performs better. Doing such tricks to squeeze the maximum potential out of a compression algorithm is known in the demoscene, for example, and is used to create those amazing intros that fit into 4 KB or 64 KB. The library supports BC1–5 and BC7 texture formats, which also looks like a good idea, considering that textures typically constitute a major portion of game asset data.

There is still some concern about the benefits and adoption of DirectStorage overall. As far as I know, many years after the initial release, we are still waiting to see the API used by a large number of games or integrated and enabled by default in major game engines. Whether that ever happens depends on whether the API can consistently demonstrate sufficient benefits over traditional file reading APIs. It definitely has potential thanks to more direct access to SSD NVMe drives and GPU-accelerated decompression directly into buffers and textures in video memory. Whether we see wider adoption or not, the API is public and production-grade, so it is very unlikely Microsoft will silently kill it, as they did with DirectSR.

5. DXR 2.0

Specification:
DirectX Raytracing (DXR) Functional Spec, Part 2

A new update to the ray tracing API, defined as D3D12_RAYTRACING_TIER_2_0 and Shader Model 6.10, will bring the following features, focused mostly on the process of building and updating acceleration structures:

Cluster Level Acceleration Structure (CLAS). This makes acceleration structures three-level. CLAS will be like a meshlet for ray tracing, representing a small piece of a triangle mesh, up to 256 vertices and 256 triangles. Then, an actual Bottom Level Acceleration Structure (BLAS) can be created from such CLASes. This can improve performance and also distribute the performance cost of building acceleration structures more evenly across frames by splitting it into smaller pieces of work.

Cluster Template - like CLAS but without vertex positions. An actual CLAS can be "instantiated" from such a template by providing vertex positions, possibly many times when the object is animated. This can provide another performance gain. This API is "intended to be an upgrade versus traditional updates / refits".

Interestingly, they also proposed a new compressed representation of vertex positions, called Compressed1 position encoding, which seems to use shared exponents and delta values to save memory. It reminds me of the Dense Geometry Format that AMD proposed some time ago.

Partitioned TLAS (PTLAS) adds another level to the hierarchy by defining a PTLAS as a new kind of Top Level Acceleration Structure (TLAS) that stores references to Partitions, which in turn reference Instances. A Partition holding a range of 100–1000 instances is recommended. This can definitely help solve the problem of rebuilding the entire TLAS every frame, which games typically do today as the set of objects in the virtual world keeps changing dynamically.

Finally, the new specification also introduces acceleration structure building operations as Indirect commands.

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

Total Commander - a Plugin Supporting a Custom Archive Format - a New Article 7 Mar 5:18 AM (8 months ago)

Today I would like to present my new article: "Total Commander – a Plugin Supporting a Custom Archive Format". In this article, we will design our own file format that allows multiple files to be packed and compressed into a single archive, similar to formats like ZIP or 7Z. Using the C++ language and the Visual Studio environment on Windows, we will then write a plugin for the Total Commander file manager that enables creating and manipulating such an archive, including freely adding and removing files inside it.

The article was first published few months ago in Polish in issue 5/2025 (120) of the Programista magazine. Now I have a right to show it publicly for free, so I share it in two language versions:

See also GitHub repository with the source code accompanying the article: sawickiap/TotalCommanderPluginTutorial

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

A Formula for Overall System Load 26 Feb 4:33 AM (8 months ago)

Some time ago I've shared my thoughts about coming up with a nice formula to calculate memory fragmentation. I've recently had another such math puzzle, this time themed around "system load". Below you will find the formula I developed, this time with an interactive demo!

The problem is this: Imagine a system that consists of several sub-systems, each having a gauge indicating the current load, 0...100%. It may be some real device like a computer (with CPU busy %, GPU busy % and the current memory consumption), some vehicle (a car, an airplane), or some virtual contraption, like a spaceship in a sci-fi video game (with the current engine load, force field strength, temperature that can make it overheat, etc.) Apart from the load of the individual subsystems, we want to show a main indicator of the overall system load.

What formula should be used to calculate it? All the load values, displayed as 0...100%, are internally stored as numbers in the range 0.0...1.0. The key principle is that if at least one subsystem is overloaded (at or near 100%), the entire system is considered overloaded. A good formula for the overall system load should have the following properties:

  1. The output is 0 if and only if all inputs are 0. In other words, if any subsystem has load >0%, the overall system load is also >0%.
  2. The output is 1 if at least one input is 1. In other words, it's enough for one subsystem to be fully loaded at 100% to consider the entire system loaded at 100%.
  3. If the output is <1, any increase in any input value should result in some increase in the output value.

Note that these requirements don't specify what happens between 0 and 1. For example, should the output become 0.5 if just one input reaches 0.5, or only after all inputs reach 0.5? We have full freedom here.

#1. My first idea was to use AVERAGE(input[i]). It meets requirement 1 and 3, but it doesn't meet requirement 2, because it requires all inputs to be 1 for the output to become 1.

#2. My second idea was to use MAX(input[i]). It meets requirement 1 and 2, but it doesn't meet requirement 3, because for any input other than the largest one, a change in its value doesn't change the output.

#3. There is a more complex formula that meets all 3 requirements. It may be called the "inverse product" and it looks like this:

output1 = 1.0 - ( (1.0 - input[0]) * (1.0 - input[1]) * ... )

You can think of it as multiplying the "headrooms" left in each subsystem.

#4. Unfortunately, the formula shown above has a tendency to give very high values nearing 100% even for low input values, which is not very user-friendly. A result that is closer to MAX() reflects the overall system load better. Considering this, but still wanting to preserve our requirement 3, I ended up blending AVERAGE() with the inverse product 50/50:

finalOutput = (AVERAGE(input[i]) + output1) * 0.5

Here is an interactive demo of all the formulas described above. You can move the sliders to control the input values.

Further modifications are possible:

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?

Graphics APIs – Yesterday, Today, and Tomorrow - a New Article 20 Jan 12:05 PM (10 months ago)

Today I would like to present my new article: "Graphics APIs – Yesterday, Today, and Tomorrow". In this article, we will take a quick walk through the history of graphics APIs such as DirectX, OpenGL, Vulkan, and the accompanying development of graphics cards on the one hand, and video games on the other, over the years. We will not be learning how to program in any of these APIs. This article should be understandable and may be engaging for anyone curious about games or graphics, or at least for those who played games in childhood.

The article was first published few months ago in Polish in issue 4/2025 (119) (July/August 2025) of the Programista magazine. Now I have a right to show it publicly for free, so I share it in two language versions:

Add post to Blinklist Add post to Blogmarks Add post to del.icio.us Digg this! Add post to My Web 2.0 Add post to Newsvine Add post to Reddit Add post to Simpy Who's linking to this post?