Commit Graph

1218 Commits

Author SHA1 Message Date
Stefan Lienhard
089cf27119 remove newline at eof 2022-04-26 19:15:51 +02:00
Stefan Lienhard
56fd17f552
add qualifiers to reference reflect json output 2022-04-26 14:30:17 +02:00
Hans-Kristian Arntzen
d7cae5e7cd
Merge pull request #1917 from KhronosGroup/fix-1906
GLSL: Support GL_EXT_debug_printf.
2022-04-19 13:08:30 +02:00
Hans-Kristian Arntzen
d2a4f9842b GLSL: Support GL_EXT_debug_printf. 2022-04-19 12:07:54 +02:00
Hans-Kristian Arntzen
5b18fb1bcd MSL: Pass down global RayQuery object to leaf functions. 2022-04-19 11:49:22 +02:00
Hans-Kristian Arntzen
17c52990d5 MSL: Fix goofy bugs in ray query. 2022-03-24 18:14:46 +01:00
Hans-Kristian Arntzen
d000b9e71c
Merge pull request #1898 from KhronosGroup/pr-1859
Merge PR #1859 with minor fixes
2022-03-22 13:50:43 +01:00
Hans-Kristian Arntzen
a7eefbc114 HLSL: Disable FXC testing for rayquery shaders.
Manually tested that it compiles on DXC.
2022-03-22 12:34:43 +01:00
Hans-Kristian Arntzen
cd209ff46d HLSL: Update test from review. 2022-03-22 12:31:52 +01:00
Hans-Kristian Arntzen
c95338e03e Merge branch 'ray_query' of https://github.com/k-payl/SPIRV-Cross into pr-1859 2022-03-22 12:29:49 +01:00
Hans-Kristian Arntzen
7b9eaf0b5e MSL: Handle awkward mix and match of Offset / ArrayStride in constants.
In normal buffer blocks, every member must be declared, but for
constants, you can technically mix and match, causing much pain and
suffering ...
2022-03-22 12:25:09 +01:00
Konstantin Pail
251361bd6f VK_KHR_ray_query implementation 2022-03-15 21:54:29 +03:00
Hans-Kristian Arntzen
4ab5bbb4e5 Fixup names of anonymous inner structs.
Just like we try to fixup struct names for block types, inner structs
can be "anonymous" structs. HLSL codegen from DXC tends to emit this,
and emitting dummy struct names tends to break GL linkage on some
drivers.
2022-03-10 15:45:38 +01:00
Hans-Kristian Arntzen
1ec9d018fd MSL: Handle aliased variable names for resources placed in IB struct.
Just remember to register the names.
2022-03-07 12:00:40 +01:00
Bill Hollings
0c0fd98322 MSL: Use var name instead of var-type name for flattened interface members.
This allows two variables of the same struct type to be flattened
into the same interface struct without a member name conflict.

Add shaders-msl/frag/in_block_with_multiple_structs_of_same_type.frag
unit test shader to demonstrate this.
2022-03-04 11:38:53 -05:00
Hans-Kristian Arntzen
b192b8887a MSL: Consider that gl_IsHelperInvocation can be Volatile.
Just emit simd_is_helper_thread() directly.
2022-03-04 11:46:35 +01:00
Hans-Kristian Arntzen
15d29f00e2 Add test for SPIR-V 1.6 Volatile HelperInvocation. 2022-03-04 11:19:33 +01:00
Hans-Kristian Arntzen
5d9fc2d903 HLSL: Add test for HelperInvocation. 2022-03-04 10:58:40 +01:00
Hans-Kristian Arntzen
31be74a853 Add relax_nan_checks options.
Makes codegen from typical D3D emulation SPIR-V more readable.
Also makes cross compilation with NotEqual more sensible.
It's very rare to actually need the strict NaN-checks in practice.

Also, glslang now emits UnordNotEqual by default it seems, so give up
trying to assume OrdNotEqual. Harmonize for UnordNotEqual as the sane
default.
2022-03-03 14:50:56 +01:00
Hans-Kristian Arntzen
dc62cc792b Handle OpTerminateInvocation. 2022-03-03 10:36:07 +01:00
Bill Hollings
02d588b7e4 MSL: Fix var names in test shaders to avoid reserved identifiers. 2022-03-03 10:19:04 +01:00
Bill Hollings
3d4daab29d MSL: Support input/output blocks containing nested struct arrays
Fixes numerous CTS tests of types
dEQP-VK.pipeline.interface_matching.vector_length.member_of_*,
passing complex nested structs between stages as stage I/O.

- Make add_composite_member_variable_to_interface_block() recursive to allow
  struct members to contain nested structs, building up member names and access
  chains recursively, and only add the resulting flattened leaf members to the
  synthetic input and output interface blocks.
- Recursively generate individual location numbers for the flattened members
  of the input/output block.
- Replace to_qualified_member_name() with append_member_name().
- Update add_variable_to_interface_block() to support arrays as struct members,
  adding a member to input and output interface blocks for each element of the array.
- Pass name qualifiers to add_plain_member_variable_to_interface_block() to allow
  struct members to be arrays of structs, building up member names and access chains,
  and adding multiple distinct flattened leaf members to the synthetic input and
  output interface blocks.
- Generate individual location numbers for the individual array members
  of the input/output block.
- SPIRVCrossDecorationInterfaceMemberIndex references the index of a member
  of a variable that is a struct type. The value is relative to the variable,
  and for structs nested within that top-level struct, the index value needs
  to take into consideration the members within those nested structs.
- Pass var_mbr_idx to add_plain_member_variable_to_interface_block() and
  add_composite_member_variable_to_interface_block(), start at zero for each
  variable, and increment for each member or nested member within that variable.
- Add unit test shaders-msl/vert/out-block-with-nested-struct-array.vert
- Add unit test shaders-msl/vert/out-block-with-struct-array.vert
- Add unit test shaders-msl/tese/in-block-with-nested-struct.tese
2022-03-03 10:18:40 +01:00
Hans-Kristian Arntzen
d16183d1d2
Merge pull request #1873 from KhronosGroup/fix-1861
HLSL: Do not emit VPOS fixup unless position is active.
2022-02-28 12:58:07 +01:00
Hans-Kristian Arntzen
7af0a5f820 HLSL: Do not emit VPOS fixup unless position is active. 2022-02-28 12:09:57 +01:00
Hans-Kristian Arntzen
5555f2784b MSL: Refactor and fix use of quadgroup vs simdgroup. 2022-02-28 11:58:33 +01:00
Hans-Kristian Arntzen
188dc8b13c
Merge pull request #1862 from flokart-world/feature/flatten-ubo-for-hlsl
HLSL: Make --flatten-ubo work correctly
2022-02-16 16:39:45 +01:00
Shintaro Sakahara
ed4ded040e HLSL: Make --flatten-ubo work correctly 2022-02-16 21:53:24 +09:00
Hans-Kristian Arntzen
5d9a95370f GLSL: Ensure correct signed integer type for more texture functions. 2022-02-16 11:14:07 +01:00
Hans-Kristian Arntzen
53d94a982e
Merge pull request #1852 from KhronosGroup/fix-1850
MSL: Rethink how opaque descriptors are passed to leaf functions.
2022-01-18 15:25:32 +01:00
Hans-Kristian Arntzen
5b952d2cbf MSL: Rethink how opaque descriptors are passed to leaf functions.
We were passing arrays by value which the compiler fails to optimize,
causing abyssal performance. To fix this, we need to consider that
descriptors can be in constant or const device address spaces.

Also, lone descriptors are passed by value, so we explicitly remove address
space qualifiers.

One failure case is when shader passes a texture/sampler array as an
argument. It's all UniformConstant in SPIR-V, but in MSL it might be
thread, const device or constant, so that won't work ...
Global variable use works fine though, and that should cover 99.9999999%
of use cases.
2022-01-18 14:40:52 +01:00
Hans-Kristian Arntzen
ac46140ba3 Test aliased names in declared LUTs. 2022-01-18 12:39:16 +01:00
Hans-Kristian Arntzen
48b5a9069f Handle aliased names in spec constants.
Need to register resource name.
2022-01-18 12:31:28 +01:00
Hans-Kristian Arntzen
9b25581d49 MSL: Handle constant construct of block-like array types.
Need this to be context sensitive, since array of block-like struct is
template, but struct of block-like array is C-style.

Also, test a mix and match, so we have constant array of block-like
struct with array inside. :v
2022-01-17 18:28:25 +01:00
Hans-Kristian Arntzen
5a5be7f9b9 MSL: Handle signed atomic min/max.
C++ deduces this based on the pointer type, so cast to atomic_uint/int
if we have to.
2022-01-17 15:40:58 +01:00
Hans-Kristian Arntzen
7dd974b9db
Merge pull request #1847 from KhronosGroup/fix-1775
Rework how loop iteration counts are validated.
2022-01-17 14:55:56 +01:00
Hans-Kristian Arntzen
1d13a3e36a Rework how loop iteration counts are validated.
Introduces an idea of a recompilation making forward progress.

There are some extreme edge cases where we need more than 3 loops, but
only allow this in specific circumstances where we can reason about
forward progress being made.
2022-01-17 14:12:01 +01:00
Hans-Kristian Arntzen
ef6bde6580 Do not forward expressions which carry a huge amount of dependencies.
Need to force temporaries eventually, or compilers have a tendency to
explode.
2022-01-17 13:45:12 +01:00
Hans-Kristian Arntzen
017cdfe25b Update references for GL_EXT_texture_buffer. 2022-01-14 14:57:24 +01:00
Hans-Kristian Arntzen
fe5a0aa72f
Merge pull request #1839 from KhronosGroup/spv1.6
Add sanity test for SPIR-V 1.6 modules.
2022-01-06 15:51:11 +01:00
Hans-Kristian Arntzen
7c12228359 Add sanity test for SPIR-V 1.6 modules.
Just verify that we don't blow up on these modules.
2022-01-06 14:16:28 +01:00
Hans-Kristian Arntzen
7c83fc22fa Add support for LocalSizeId.
WorkgroupSize builtin is deprecated in 1.6 and LocalSizeId is supported
in Vulkan starting with maintenance4.
2022-01-06 13:57:10 +01:00
Hans-Kristian Arntzen
fe8848a6f2 Roll dependencies. 2022-01-05 14:56:01 +01:00
Hans-Kristian Arntzen
be333e0cab MSL: Move float2->3 TessCoord fixup to a better location. 2022-01-05 13:32:17 +01:00
Hans-Kristian Arntzen
2793d22af5 Merge branch 'master' of git://github.com/cfnptr/SPIRV-Cross 2022-01-05 12:53:45 +01:00
Nikita Fediuchin
2acf0e73dd Fix gl_TessCoord arguments presence. Update reference shaders.
* Added check for "gl_TessCoord" presence in the entry point arguments.
* Updated reference tessellation evaluation shaders.
2021-12-20 22:58:21 +02:00
Sebastián Aedo
905b8244e7 Clamp vector element access to vector size.
In cases where we know the size of the vector and the index at compile
time, we can check if it's accessing in bounds and rely in undefined
behavior otherwise.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-12-07 16:00:06 -03:00
Sebastián Aedo
6d8302ef14 MSL: Add 64 bit switch support
Add 64 bit switch support for MSL version 2.2.

* Also fixes a wrong endianness conversion.

Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
2021-11-26 15:54:56 -03:00
Bill Hollings
248e9ae9ed MSL: Don't output depth and stencil values with explicit early fragment tests.
Fragment shaders that require explicit early fragment tests are incompatible
with specifying depth and stencil values within the shader. If explicit early
fragment tests is specified, remove the depth and stencil outputs from the
output structure, and replace them with dummy local variables.

Add CompilerMSL:uses_explicit_early_fragment_test() function to consolidate
testing for whether early fragment tests are required.

Add two unit tests for depth-out with, and without, early fragment tests.
2021-11-12 14:17:00 -05:00
Bill Hollings
fd252b21ff Separate (partially) the tracking of depth images from depth compare ops.
SPIR-V allows an image to be marked as a depth image, but with a non-depth
format. Such images should be read or sampled as vectors instead of scalars,
except when they are subject to compare operations.

Don't mark an OpSampledImage as using a compare operation just because the
image contains a depth marker. Instead, require that a compare operation
is actually used on that image.

Compiler::image_is_comparison() was really testing whether an image is a
depth image, since it incorporates the depth marker. Rename that function
to is_depth_image(), to clarify what it is really testing.

In Compiler::is_depth_image(), do not treat an image  as a depth image
if it has been explicitly marked with a color format, unless the image
is subject to compare operations.

In CompilerMSL::to_function_name(), test for compare operations
specifically, rather than assuming them from the depth-image marker.

CompilerGLSL and CompilerMSL still contain a number of internal tests that
use is_depth_image() both for testing for a depth image, and for testing
whether compare operations are being used. I've left these as they are
for now, but these should be cleaned up at some point.

Add unit tests for fetch/sample depth images with color formats and no compare ops.
2021-11-08 15:59:45 -05:00
Hans-Kristian Arntzen
f1b411c9e8 GLSL: Deal with buffer_reference_align.
This is somewhat awkward to support, but the best effort we can do here
is to analyze various Load/Store opcodes and deduce the ideal overall
alignment based on this. This is not a 100% perfect solution, but should
be correct for any reasonable use case.

Also fix various nitpicks with BDA support while I'm at it.
2021-11-07 17:11:46 +01:00