https://github.com/shader-slang/slang
Raw File
Tip revision: 56e49feea3956d66e41b819c26628c65b3c28197 authored by Tim Foley on 22 November 2017, 19:28:29 UTC
Fix emitting of loop attributes for HLSL pass-through (#296)
Tip revision: 56e49fe
README.md
Binding Generation Tests
========================

These tests ensure that the compiler can correctly add explicit binding information (e.g., HLSL `register` semantics) to code that does not originally have them.

Example
-------

Given code like:

    Texture2D ta;
    Texture2D tb;

We expect to produce output like:

    Texture2D ta : register(t0);
    Texture2D tb : register(t1);

The resulting code guarantees that `tb` will always be assigned to the same location, regardless of how these values are (or are not) used in later shader code.

Methodology
-----------

These tests currently rely on the ability to run the same HLSL code through the Spire compiler driver and execute either Spire, or HLSL. We write an example like the above by wrapping explicit `register` semantics in a macro:

    Texture2D ta R(: register(t0));
    Texture2D tb R(: register(t1));

In the HLSL case, these annotations will manually place things where we want them, while in the Spire case, we define the macro to have an empty expansion, so that the annotations express our expectation for what the compiler will auto-generate.
back to top