The hlsl_ir_compile node is introduced to represent the "compile"
syntax, and later the CompileShader() and ConstructGSWithSO()
constructs.
It basically represents a function call that remembers its arguments
using hlsl_srcs and keeps its own instruction block, which is discarded
when working on non-effect shaders.
For shader compilations it can be asserted that args_count is 1, and
that this argument (and the last node in hlsl_ir_effect_call.instrs)
is a regular hlsl_ir_call pointing to the declaration of the function
to be compiled.
This node type will be deleted once the hlsl->vsir->d3dbc translation is
complete. For now it serves the purpose of allowing to keep both real
hlsl_ir_nodes and vsir_instructions in the hlsl_block, until all the
former can be translated into the latter.
Avoid overflowing the (Wine) debug log buffer when output lines are too
long, and keep spirv-text output more legible. The output is still valid
SPIR-V asm, as the assembler does not care for which kind of whitespace
is used.
This way the same shader is always dumped to the same path and when
launching the same program over and over we avoid both creating new
copies of the same file each time and overwriting different dumped
shaders.
This is a proposed API change in 946, which won't make it into this release.
The intent is to allow slightly larger constants to be specified in the updated
vkd3d_shader_parameter1 structure. In particular, this is large enough to pass
4-dimensional integer or float vectors inline, which the proposed clip plane
implementation will use, as well as other Direct3D FFP parameters.
We could also simply add vkd3d_shader_immediate_constant1 as a separate union
member in vkd3d_shader_parameter1, but this API is a bit cleaner and simpler.
Commits 343c7942e1 and
94c74d2c00 moved applying the NonReadable
and Coherent decorations from spirv_compiler_emit_resource_declaration()
to spirv_compiler_build_descriptor_variable(), but unfortunately missed
the non-array path in the latter function.
The missing NonReadable decoration causes segmentation faults in
rasteriser-ordered-views.shader_test (among others) on my Intel SKL GT2
setup in particular.
In the case two uav descriptors are mapped to the same variable, and one is
read from while the other is not, the variable would get the NonReadable
decorator, while being read from later.
The existing code reuses the same SPIR-V variable for all descriptors mapped to
the same Vulkan binding, and applies the NonReadable decoration based on the
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ only. This potentially causes the
decoration to be applied twice, should two non-read descriptors be mapped to
the same variable, which isn't allowed in SPIR-V, and the validator complains.
CTAB type correctly reflects matrix majority, unlike effects
type data that does not respond to majority modifiers at all.
It doesn't transpose default values either.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This fixes a lot of internal compiler errors with assignment operators,
especially bitwise ones. The bitwise-assignment test has the motivating
examples.
We need to distinguish between the data type of a resource and the data
type of its components. These are usually the same except for 4.0
profiles where an array (or multi-dimensional array) of resources is
still considered a single resource, so it is possible for it to hold
more than one component.
In the latter case, we often need to access the type of a single
component (all components have the same type) instead of the type of the
whole array which often doesn't contain the required information, such
as sampler dimension.
This patch replaces the extern_resource.data_type field with the
extern_resource.component_type field, which points to the type of a
single component in the resource. Using it relieves many other code
paths from considering the possibility of the resource being an array.
This fixes runtime errors reported by UBSan, such as this:
vkd3d/libs/vkd3d-shader/tpf.c:6075:87: runtime error: load of value 7, which is not a valid value for type '_Bool'
when trying to compile shaders that contain UAV arrays on 4.0 profiles.
Before this commit, tpf.c accesses the
hlsl_type->e.resource.rasteriser_ordered
field, but on 4.0 and 4.1 profiles these code paths can also be reached
by UAV arrays which are HLSL_CLASS_ARRAY and this field is not supposed
to be accessed.
By coincidence, the value of hlsl_type->e.array.elements_count was being
read because these fields have the same offset in the hlsl_type.e union.
This causes a crash in the native compiler, but can only happen in
ps_5_0 were it is possible to declare structs that are both used in the
shader and contain strings.
struct
{
float a;
string b;
} apple = {1, "foobar"};
float4 main() : sv_target
{
return apple.a;
}
In our case, hlsl_type_get_component_offset() triggered an assertion
failure because it does not expect the string type. So this is replaced
by an hlsl_error().
This is achieved by means of creating a variable storing zero,
loading every array element, comparing if the non-constant index
matches the index of that element at runtime, and in that case
store the corresponding element in the variable.
This seems to be the same strategy that the native compiler uses.
We are currently using &offset_node->loc when offset_node is NULL.
A NULL dereference of rel_offset can also happen if
hlsl_offset_from_deref() fails because the dereference is out of
bounds.