glslang/Test/spv.register.autoassign.frag
steve-lunarg 7f7c2ed780 HLSL: Add location offsets per resource type
This PR adds the ability to offset sampler, texture, and UBO bindings
from provided base bindings, and to auto-number bindings that are not
provided with explicit register numbers. The mechanism works as
follows:

- Offsets may be given on the command line for all stages, or
  individually for one or more single stages, in which case the
  offset will be auto-selected according to the stage being
  compiled. There is also an API to set them. The new command line
  options are --shift-sampler-binding, --shift-texture-binding, and
  --shift-UBO-binding.

- Uniforms which are not given explicit bindings in the source code
  are auto-numbered if and only if they are in live code as
  determined by the algorithm used to build the reflection
  database, and the --auto-map-bindings option is given. This auto-numbering
  avoids using any binding slots which were explicitly provided in
  the code, whether or not that explicit use was live. E.g, "uniform
  Texture1D foo : register(t3);" with --shift-texture-binding 10 will
  reserve binding 13, whether or not foo is used in live code.

- Shorter synonyms for the command line options are available.  See
  the --help output.

The testing infrastructure is slightly extended to allow use of the
binding offset API, and two new tests spv.register.(no)autoassign.frag are
added for comparing the resulting SPIR-V.
2016-09-20 20:31:27 -06:00

72 lines
1.6 KiB
GLSL

SamplerState g_sSamp1 : register(s0);
SamplerState g_sSamp2;
SamplerState g_sSamp3[2] : register(s2);
SamplerState g_sSamp4[3];
SamplerState g_sSamp5;
SamplerState g_sSamp_unused1;
SamplerState g_sSamp_unused2;
Texture1D g_tTex1 : register(t1);
const uniform Texture1D g_tTex2;
Texture1D g_tTex3[2] : register(t3);
Texture1D g_tTex4[3];
Texture1D g_tTex5;
Texture1D g_tTex_unused1 : register(t0);
Texture1D g_tTex_unused2 : register(t2);
Texture1D g_tTex_unused3;
struct MyStruct_t {
int a;
float b;
float3 c;
};
uniform MyStruct_t mystruct : register(b4);
struct PS_OUTPUT
{
float4 Color : SV_Target0;
};
uniform float4 myfloat4_a;
uniform float4 myfloat4_b;
uniform int4 myint4_a;
float4 Func1()
{
return
g_tTex1 . Sample(g_sSamp1, 0.1) +
g_tTex2 . Sample(g_sSamp2, 0.2) +
g_tTex3[0] . Sample(g_sSamp3[0], 0.3) +
g_tTex3[1] . Sample(g_sSamp3[1], 0.3) +
g_tTex4[1] . Sample(g_sSamp4[1], 0.4) +
g_tTex4[2] . Sample(g_sSamp4[2], 0.4) +
g_tTex5 . Sample(g_sSamp5, 0.5) +
mystruct.c[1];
}
float4 Func2()
{
return
g_tTex1 . Sample(g_sSamp1, 0.1) +
g_tTex3[1] . Sample(g_sSamp3[1], 0.3);
}
// Not called from entry point:
float4 Func2_unused()
{
return
g_tTex_unused1 . Sample(g_sSamp_unused1, 1.1) +
g_tTex_unused2 . Sample(g_sSamp_unused2, 1.2);
}
PS_OUTPUT main_ep()
{
PS_OUTPUT psout;
psout.Color = Func1() + Func2();
return psout;
}