There was some code replication around getting string and integer
values out of an attribute map. This adds new methods to the
TAttributeMap class to encapsulate some accessor details.
A single texture can statically appear in code mixed with a shadow sampler
and a non-shadow sampler. This would be create invalid SPIR-V, unless
one of them is provably dead.
The previous detection of this happened before DCE, so some shaders would
trigger the error even though they wouldn't after DCE. To handle that
case, this PR splits the texture into two: one with each mode. It sets
"needsLegalization" (if that happens for any texture) to warn that this shader
will need post-compilation legalization.
If the texture is only used with one of the two modes, behavior is as it
was before.
Add support for Subpass Input proposal of issue #1069.
Subpass input types are given as:
layout(input_attachment_index = 1) SubpassInput<float4> subpass_f;
layout(input_attachment_index = 2) SubpassInput<int4> subpass_i;
layout(input_attachment_index = 3) SubpassInput<uint4> subpass_u;
layout(input_attachment_index = 1) SubpassInputMS<float4> subpass_ms_f;
layout(input_attachment_index = 2) SubpassInputMS<int4> subpass_ms_i;
layout(input_attachment_index = 3) SubpassInputMS<uint4> subpass_ms_u;
The input attachment may also be specified using attribute syntax:
[[vk::input_attachment_index(7)]] SubpassInput subpass_2;
The template type may be a shorter-than-vec4 vector, but currently user
structs are not supported. (An unimplemented error will be issued).
The load operations are methods on objects of the above type:
float4 result = subpass_f.SubpassLoad();
int4 result = subpass_i.SubpassLoad();
uint4 result = subpass_u.SubpassLoad();
float4 result = subpass_ms_f.SubpassLoad(samp);
int4 result = subpass_ms_i.SubpassLoad(samp);
uint4 result = subpass_ms_u.SubpassLoad(samp);
Additionally, the AST printer could not print EOpSubpass* nodes. Now it can.
Fixes#1069
- support C++11 style brackets [[...]]
- support namespaces [[vk::...]]
- support these on parameter declarations in functions
- support location, binding/set, input attachments
Also, remove assumption that if something is opaque that it
must be in the UniformConstant storage class.
This allows function declarations to know all parameters will
be in the Function storage class.
Texture shadow mode must match the state of the sampler they are
combined with. This change does that, both for the AST and the
symbol table. Note that the texture cannot easily be *created*
the right way, because this may not be known at that time. Instead,
the texture is subsequently patched.
This cannot work if a single texture is used with both a shadow and
non-shadow sampler, so that case is detected and generates an error.
This is permitted by the HLSL language, however. See #1073 discussion.
Fixed one test source that was using a texture with both shadow and
non-shadow samplers.
Also added known-good mechanism to fetch latest validated spirv-tools.
Also added -Od and -Os to disable optimizer and optimize for size.
Fetching spirv-tools is optional for both glsl and hlsl. Legalization
of hlsl is done by default if spirv-opt is present at cmake time.
Optimization for glsl is currently done through the option -Os.
Legalization testing is currently only done on four existing shaders.
A separate baseLegalResults directory holds those results. All previous
testing is done with the optimizer disabled.