Commit Graph

659 Commits

Author SHA1 Message Date
Boris Brezillon b59abbe3d5 dzn: Initialize UUIDs
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:22 +00:00
Boris Brezillon be019e69e2 dzn: Fix indentation
Replace tabs by spaces

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:22 +00:00
Boris Brezillon 0371b1707b dzn: Hook-up device-lost detection
Provide a vk_device::check_status() implementation so the code can
call it at key moments to detect when a device-lost event (device-removed
in D3D12) has been received.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17249>
2022-06-28 09:38:27 +00:00
Jesse Natalie 59944831a7 microsoft/clc: Add a unit test for unused image kernel args
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17246>
2022-06-27 16:54:27 +00:00
Jesse Natalie ca23a4af67 microsoft/clc: Remove dead image vars
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17246>
2022-06-27 16:54:27 +00:00
Jesse Natalie fd37959680 microsoft/clc: Fix test double free in the case of compilation failure
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17246>
2022-06-27 16:54:27 +00:00
Jesse Natalie d69e258e8e microsoft/clc: Enable tests that pass on server 2022
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17246>
2022-06-27 16:54:27 +00:00
Boris Brezillon ab0e09803a dzn: Enable the depthClamp feature
depthClampEnable is actually the case we support properly.

!depthClampEnable requires extra work to make sure the
depth clamping that's forced by D3D12 is inactive (setting the
viewport depth range to [0,1] and dealing with the actual range
at the shader level), and clamp the depth value read by the
fragment shader in that case. This will be addressed separately.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17231>
2022-06-27 10:05:56 +00:00
Boris Brezillon a7d6f52821 dzn: Enable shader{Clip,Cull}Distance
DXIL has clip/cull distance builtins too.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17231>
2022-06-27 10:05:55 +00:00
Boris Brezillon 716aeafb67 dzn: Enable dynamic indexing on all kind of descriptors
nir_to_dxil() supports it.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17231>
2022-06-27 10:05:55 +00:00
Boris Brezillon 8f4fe3d21f dzn: Advertise shaderImageGatherExtended support
nir_to_dxil() takes tg4 offsets into account.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17231>
2022-06-27 10:05:55 +00:00
Boris Brezillon 7988e966fc dzn: Advertise anisotropic filtering support
We support it already, let's toggle the switch to expose it.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17231>
2022-06-27 10:05:55 +00:00
Jason Ekstrand 6216c59dbb vulkan/render_pass: Use a special layout for self-dependencies
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16953>
2022-06-24 22:37:53 +00:00
Boris Brezillon e9c37e5ba8 microsoft/compiler: Fix emit_ubo_var()
get_dword_size() is misleading, its name implies it's returning
a size in dwords, but it's actually returning a size in bytes.
This led to a wrong size passed to emit_cbv(). Instead of fixing
get_dword_size(), let's inline the code in emit_ubo_var().

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17230>
2022-06-24 17:56:56 +00:00
Boris Brezillon 8e710f2cf3 dzn: Transition resource to RENDER_TARGET/DEPTH_WRITE before clears
When clear_attachment() is called, we must ensure the resource is
in the DEPTH_WRITE or RENDER_TARGET state.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17229>
2022-06-24 17:42:11 +00:00
Boris Brezillon 02002c8f12 dzn: Clamp depthBiasConstantFactor when doing the float -> int conversion
If we don't do that, we might end up with an integer overflow/underflow.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17236>
2022-06-24 16:45:12 +00:00
Boris Brezillon 9527fbe596 dzn: Fix CmdPushConstants()
The original offset value is overwritten in our first for(i: num_states)
iteration, messing up the compute push constant update if stageFlags
applies to both compute and graphics.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17233>
2022-06-24 16:13:39 +00:00
Enrico Galli f367c55573 microsoft/spirv_to_dxil: Fix discard semantics
Unlike in nir, discard is not a super return in DXIL. Therefore, we
will lower discard and terminate to demote + return.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17179>
2022-06-23 22:04:32 +00:00
Yonggang Luo d52f280bd7 dzn: Fixes incompatible pointer type error
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16084>
2022-06-23 09:27:06 +00:00
Yonggang Luo a387c9284a microsoft/clc: Disable clc_compiler_test on non-windows platform
The test can compile, but can not pass, so compile it but not running it

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16084>
2022-06-23 09:27:06 +00:00
Yonggang Luo e1e94f8c81 microsoft/clc: Fixes narrowing error in clc_compiler_test.cpp with mingw/gcc
errors:
../../src/microsoft/clc/clc_compiler_test.cpp:563:19: error: narrowing conversion of '268435457' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Wnarrowing]
  563 |       0x00000000, 0x10000001, 0x20000020, 0x30000300,
      |                   ^~~~~~~~~~
../../src/microsoft/clc/clc_compiler_test.cpp:563:31: error: narrowing conversion of '536870944' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Wnarrowing]
  563 |       0x00000000, 0x10000001, 0x20000020, 0x30000300,
      |                               ^~~~~~~~~~
../../src/microsoft/clc/clc_compiler_test.cpp:563:43: error: narrowing conversion of '805307136' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Wnarrowing]
  563 |       0x00000000, 0x10000001, 0x20000020, 0x30000300,

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16084>
2022-06-23 09:27:06 +00:00
Boris Brezillon d232f5a026 dzn: Fix the 2DMSArray case in dzn_image_get_dsv_desc()
Texture2DMSArray element is not initialized, making 2DMSArray DS
views buggy.

Reported-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17158>
2022-06-21 08:39:40 +00:00
Vinson Lee 081b1eeacd microsoft/compiler: Fix assert.
Fix defect reported by Coverity Scan.

Side effect in assertion (ASSERT_SIDE_EFFECT)
assignment_where_comparison_intended: Assignment var->type =
glsl_int_type() has a side effect. This code will work differently in a
non-debug build.

Fixes: afb64e10c1 ("microsoft/compiler: Move d3d12_fix_io_uint_type() to dxil_nir.c")
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17097>
2022-06-21 06:54:18 +00:00
Boris Brezillon 1987fb0091 ci/dzn: Move to a .toml description
This way we don't force a CI run on all platforms anytime we add a
group of test, and, as a bonus, we make dozen CI consistent with other
platforms.

Suggested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Suggested-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17074>
2022-06-20 14:48:51 +00:00
Erik Faye-Lund 419b8c7f8d dzn: correct order of src_subres and dst_subres args
Fixes: 2d0798440b ("dzn: Add support for dynamic rendering")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17133>
2022-06-20 11:16:15 +00:00
Jesse Natalie 7a9617b869 dzn: Skip another test that times out occasionally
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17089>
2022-06-16 23:00:27 +00:00
Yonggang Luo d39553da10 ci/vs2019: Upgrade Windows 10 SDK version to 20348
This comes with stdalign.h for more C11 conformance

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17044>
2022-06-16 21:49:54 +00:00
Boris Brezillon db2d264989 dzn: Enable support for geometry shaders
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>
2022-06-15 22:04:01 +00:00
Boris Brezillon e9066ff2be dzn: Disable rasterization if the last geometry stage doesn't write the position
If we don't do that, and we get passed a dummy geometry shader (one
that has no EmitVertex() calls) we get a DXIL validation error.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>
2022-06-15 22:04:00 +00:00
Boris Brezillon e11035bf6d microsoft/compiler: Support gl_Layer
Maps pretty nicely to SV_RenderTargetArrayIndex, so nothing complicated
here.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>
2022-06-15 22:04:00 +00:00
Boris Brezillon 9c45ee3f86 microsoft/compiler: Fix Layer type
DXIL wants a uint, but we get passed an int.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>
2022-06-15 22:04:00 +00:00
Boris Brezillon afb64e10c1 microsoft/compiler: Move d3d12_fix_io_uint_type() to dxil_nir.c
We currently have two implementations of the same logic. Let's pick
the d3d12 one, move it to dxil_nir.c and let nir_to_dxil() call it
when appropriate.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17039>
2022-06-15 22:04:00 +00:00
Emma Anholt ae432b67b7 ci/dzn: Skip a test that intermittently times out at a minute.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17054>
2022-06-15 20:30:46 +00:00
Yonggang Luo 29baa326b9 microsoft/spirv_to_dxil: Fixes maybe-uninitialized compiling error in dxil_spirv_nir.c
Fixes following errors:
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c
In file included from ../src/compiler/nir/nir_builder.h:365,
                 from ../src/microsoft/compiler/dxil_nir.h:29,
                 from ../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c:28:
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c: In function 'dxil_spirv_nir_passes':
src/compiler/nir/nir_builder_opcodes.h:1321:11: error: 'dyn_yz_flip_mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1321 |    return nir_build_alu2(build, nir_op_iand, src0, src1);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c:290:59: note: 'dyn_yz_flip_mask' was declared here
  290 |    nir_ssa_def *y_flip_mask = NULL, *z_flip_mask = NULL, *dyn_yz_flip_mask;
      |                                                           ^~~~~~~~~~~~~~~~

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo 2e79e4b6d8 microsoft/clc: Add missing void to no-parameter function signature
Fixes this warning:
../../src/microsoft/clc/clc_compiler.c:1218:10: error: no previous prototype for 'clc_compiler_get_version' [-Werror=missing-prototypes]
 1218 | uint64_t clc_compiler_get_version()
      |          ^~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo 484658a74b microsoft/clc: Delete unused local variables
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo a88ac30d38 microsoft/spirv_to_dxil: Delete unused local variable
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo beaaa84cea dxil: Fixes warning about comparing different enum value and enum literal
warnings:
../../src/microsoft/spirv_to_dxil/spirv_to_dxil.c: In function 'spirv_to_dxil':
../../src/microsoft/spirv_to_dxil/spirv_to_dxil.c:101:14: warning: comparison between 'dxil_spirv_shader_stage' and 'enum <anonymous>' [-Wenum-compare]
  101 |    if (stage == MESA_SHADER_NONE || stage == MESA_SHADER_KERNEL)
      |              ^~
../../src/microsoft/spirv_to_dxil/spirv_to_dxil.c:101:43: warning: comparison between 'dxil_spirv_shader_stage' and 'enum <anonymous>' [-Wenum-compare]
  101 |    if (stage == MESA_SHADER_NONE || stage == MESA_SHADER_KERNEL)
      |                                           ^~

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo 0d0283f698 dxil: Sync dxil_spirv_shader_stage with gl_shader_stage
Add STATIC_ASSERT to guard `dxil_spirv_shader_stage` and `gl_shader_stage`
to be same for each enum value.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo ed7e78b084 dxil: Fixes compiling dxcapi.h with mingw.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo 4ae6cf2a74 microsoft/compiler: Fix error from double extern
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Yonggang Luo 2e61138d97 microsoft/compiler: Include stddef.h before using size_t
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16671>
2022-06-15 11:38:24 +00:00
Vinson Lee fd91295473 microsoft/spirv_to_dxil: Fix missing-prototypes errors.
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c: At top level:
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c:646:1: error: no previous prototype for ‘dxil_spirv_nir_link’ [-Werror=missing-prototypes]
  646 | dxil_spirv_nir_link(nir_shader *nir, nir_shader *prev_stage_nir)
      | ^~~~~~~~~~~~~~~~~~~
../src/microsoft/spirv_to_dxil/dxil_spirv_nir.c:666:1: error: no previous prototype for ‘dxil_spirv_nir_passes’ [-Werror=missing-prototypes]
  666 | dxil_spirv_nir_passes(nir_shader *nir,
      | ^~~~~~~~~~~~~~~~~~~~~

Fixes: c86ea7daa3 ("microsoft/spirv_to_dxil: Extract NIR passes out of spirv_to_dxil()")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17011>
2022-06-15 01:29:04 +00:00
Boris Brezillon e46f4ec5f3 ci/windows: Skip dEQP-VK.api.command_buffers.record_many_draws*
Those tend to timeout, so let's skip them for now.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon dd78dc25e7 ci/windows: Add dEQP-VK.dynamic_state.* to the test list
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 672447be7f ci/windows: Allow skipping deqp tests if we have to
Useful to skip tests that are known to crash.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 1acf0b4bd4 dzn: Support dynamic line width
.wideLines = false, which forbids the user to set the line width
to something different than 1. We're thus safe to claim support
for dynamic line width and do nothing in CmdSetLineWidth() other
than checking the value passed is 1.0f.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 7d9afb93cc dzn: Support dynamic depth testing parameters properly
Now that we have support for pipeline variants, we can take the dynamic
depth testing parameters into account and create a new pipeline state
using those dynamic parameters.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 91f3c7a9fb dzn: Fix triangle-fan emulation
We were completely ignoring the primitive-restart case in the
index-rewrite logic used to emulate triangle fans. Unfortunately, this
case is way more complicated than a regular index rewrite:

- we need to skip all primitive-restart entries when turning the triangle
  fan into a triangle list, which implies serializing the index buffer
  rewrite procedure (at least I didn't find any clever way to parallelize
  things)
- the number of triangles can no longer be extrapolated from the number
  of indices in the original index buffer, thus forcing us to lower
  direct indexed draws into indirect draws and patching the indexCount
  value when the new index buffer is forged

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 741b5ded49 dzn: Fix primitiveRestart support
We can't hardcode the strip cut value to 0xffffffff, otherwise we break
support for 16-bit index buffers. Let's use the pipeline variant
infrastructure to deal with that case.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon 81fb1cfdad dzn: Prepare support for pipeline variants
Some D3D12 states can't be updated dynamically and require the creation
of a new pipeline state. In order to support setting those dynamically
we will have to support creating pipeline variants at draw time.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16971>
2022-06-15 00:10:42 +00:00
Boris Brezillon b3b53952b0 dzn: Vulkan 1.1 wants maxPerSetDescriptors >= 1024
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 59a6ddd85c dzn: Implement GetDescriptorSetLayoutSupport()
The 2048 descriptors limit comes from the maximum number of samplers
per heap, but the limit for other descriptors is actually much bigger.
Let's implement GetDescriptorSetLayoutSupport() to reflect that.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 1554ece8bd dzn: Add a dzn_desc_type_has_sampler() helper
Add a dzn_desc_type_has_sampler() helper instead of duplicating
the SAMPLER || COMBINED_IMAGE_SAMPLER test everywhere.

Suggested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon fb52be9376 dzn: Lower alignment requirements when allocating buffers or single-sample images
VkMemoryDedicatedAllocateInfo, when present, provides us with extra
information about the memory usage, which allow us to lower the alignment
requirements.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 96a7f81072 dzn: Check that no export is requested in the memory allocation path
We don't support exporting memory objects yet, so let's make sure the
user doesn't request that.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 8c23d9db0b dzn: Add dummy {Create,Destroy}SamplerYcbcrConversion() implementations
We don't support Ycbcr sampler conversion. Add dummy implementations to
make us Vulkan 1.1 compliant.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 439b1fc8e8 dzn: Add a dummy GetImageSparseMemoryRequirements2()
We don't support sparse memory yet, but this function needs to be
present.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon cd8e322816 dzn: Add a dummy GetDeviceGroupPeerMemoryFeatures()
We don't support device groups, but Vulkan 1.1 requires a
GetDeviceGroupPeerMemoryFeatures() implementation, so let's just
advertise no peer-memory features.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon cc7158fe2f dzn: Return empty external properties
We don't support importing/exporting images yet, so let's zero out the
whole external properties struct, if present.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon fa79d036f1 dzn: Decorrelate external image info and external image properties
One can be present without the other.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon cd4bc4893b microsoft/compiler: Support load_sample_id_no_per_sample
It's like load_sample_id except it shouldn't force per-sample shading
when not already enabled. In that case, we simply return 0.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 65309dab45 microsoft/compiler: s/assert()/unreachable()/ in emit_intrinsic()
Use an unreachable() statement instead of the incorrect assertion in the
unsupported intrinsic path.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 82d3433d2a microsoft/compiler: Set typed_uav_load_additional_formats when appropriate
This flag should be set to true when the RWTexture is attached a vector,
and we always declare a vec4 right now, so it should always be true.
Might be worth reworking the dxil_module_get_res_type() to use a scalar
when the image only has one component.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Boris Brezillon 303175cfec microsoft/compiler: Images are no longer reprensented by uniform vars
emit_barrier_impl() was still checking the nir_var_uniform flag to
detect images, which is no longer correct.

Fixes: cfdc7ee066 ("spirv: Use nir_var_mem_image")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926>
2022-06-14 22:44:42 +00:00
Louis-Francis Ratté-Boulianne ac34866166 dzn: Allow some non-native formats to be used as vertex inputs
This requires shader-side lowering, which is handled in
dxil_nir_lower_vs_vertex_conversion().

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15955>
2022-06-14 17:42:51 +00:00
Louis-Francis Ratté-Boulianne b53f9011b1 microsoft/compiler: Add support for more scaled formats
Lower 8 and 16 bit scaled formats to integer formats.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15955>
2022-06-14 17:42:51 +00:00
Louis-Francis Ratté-Boulianne b0b9b50077 d3d12: Move d3d12_nir_lower_vs_vertex_conversion() to a common place
So we can re-use it in dozen.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15955>
2022-06-14 17:42:51 +00:00
Erik Faye-Lund 7c864499eb dzn: enable two more exts
These are already implemented, so let's turn them on!

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17027>
2022-06-14 14:55:27 +00:00
Erik Faye-Lund b45f1e24ae dzn: use a null-rtv to handle no-attachment
This fixes a crash in this test:
dEQP-VK.renderpass2.suballocation.simple.color_unused_omit_blend_state

Fixes: 2d0798440b ("dzn: Add support for dynamic rendering")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17027>
2022-06-14 14:55:27 +00:00
Boris Brezillon bd4c8f562c microsoft/compiler: Truncate function names when needed
DXIL metadata strings and function names have a limited size. Truncate
the name when they don't fit. This is a quick&dirty workaround since it
doesn't address the problem for all kind of strings, and doesn't ensure
there's no collision in the function names after the truncation. That's
not an issue right now because I don't think we have implementations
keeping more than one function (the entrypoint), but it might be a
problem at some point.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16961>
2022-06-14 14:15:55 +00:00
Boris Brezillon 69339066fc microsoft/compiler: Pick a type that matches interpolation mode for structs
We can't use linear interpolation on integer types, and varyings using
a struct type might actually contain only fp32 members, in which case
interpolation should happen as requested.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16961>
2022-06-14 14:15:55 +00:00
Erik Faye-Lund 4ab49e2530 dzn: handle stencil-attachment-optimal layout
We missed this one, whoops.

Fixes: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16997>
2022-06-14 10:35:59 +00:00
Erik Faye-Lund 7dc5255469 dzn: correct assert-condition
This logic accidentally got flipped in a refactoring. Let's correct it!

Fixes: e293691a99 ("dzn: Get rid of the render pass logic")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16997>
2022-06-14 10:35:59 +00:00
Erik Faye-Lund 5288fe31b4 microsoft/spirv_to_dxil: lower cube-images to 2d arrays
textureLoad() doesn't work on cube images. We need to lower cube
images to 2D arrays.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>
2022-06-10 22:14:14 +00:00
Erik Faye-Lund 00837c6bef microsoft/compiler: make sampler-lowering optional
We don't want this in DZN, so let's make it optional.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>
2022-06-10 22:14:14 +00:00
Erik Faye-Lund fff03d2bd3 microsoft/compiler: mark image-functions as such
These functions only deal with images, so let's make that clear.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>
2022-06-10 22:14:14 +00:00
Erik Faye-Lund b386802bb9 d3d12: move cubemap-lowering to common-code
We're going to want to do part of this in DZN as well.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>
2022-06-10 22:14:14 +00:00
Boris Brezillon b12417a2c7 microsoft/compiler: Lower fquantize2f16
As far as I can't tell, there's no native operation doing this
equivalent of fquantize2f16. Let's lower this operation to

   if (val < MIN_FLOAT16)
      return -INFINITY;
   else if (val > MAX_FLOAT16)
      return -INFINITY;
   else if (fabs(val) < SMALLER_NORMALIZED_FLOAT16)
      return 0;
   else
      return val;

which matches the definition of OpQuantizeToF16:

"
If Value is an infinity, the result is the same infinity.
If Value is a NaN, the result is a NaN, but not necessarily the same NaN.
If Value is positive with a magnitude too large to represent as a 16-bit
floating-point value, the result is positive infinity. If Value is negative
with a magnitude too large to represent as a 16-bit floating-point value,
the result is negative infinity. If the magnitude of Value is too small to
represent as a normalized 16-bit floating-point value, the result may be
either +0 or -0.
"

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16959>
2022-06-10 07:45:05 +00:00
Jesse Natalie e60bb58de7 dzn: Init sync types before wsi
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4037>
2022-06-10 01:33:12 +00:00
Jesse Natalie cc805aef69 d3d12: Properly set HS input control point count
Looks like some hardware needs this info in the shader to match the
topology. Since there's no spot in the shader info for it, we're
currently using the array size of the TCS input vars to store it.

Cc: mesa-stable
Reviewed-by: Paul Dodzweit <paul.dodzweit@amd.com>
Tested-by: Paul Dodzweit <paul.dodzweit@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16920>
2022-06-09 17:08:18 +00:00
Boris Brezillon e6301b886b dzn: Enable depth-bounds testing
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16948>
2022-06-09 08:21:14 -07:00
Boris Brezillon 9feda65a83 dzn: Use CreatePipelineState()
This way we can easily extend the logic to support new features, like
depth-bounds testing.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16948>
2022-06-09 08:21:09 -07:00
Boris Brezillon 83c7fab53f dzn: Drop an unused argument passed to dzn_graphics_pipeline_translate_vi()
The 'out' argument is not used, let's drop it.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16948>
2022-06-09 08:21:04 -07:00
Boris Brezillon 185bae4c60 dzn: Switch to ID3D12Device2
So we can use the CreatePipelineState method and unlock new features
like depth-bounds tests.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16948>
2022-06-09 08:20:54 -07:00
Boris Brezillon 35dd4ac886 microsoft/compiler: Drop the auto_link parameter passed to nir_to_dxil()
Now that all nir_to_dxil() have transitioned to explicit linking, we
can drop the auto_link parameter and simplify the signature logic along
the way.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 74c94faf32 microsoft/spirv_to_dxil: Let spirv_to_dxil() handle the linking
That's still a dummy linking we do here, and it's likely to be
incorrect for complex scenarios. Not sure the previous situation
was any better though, and at least, doing that allows us to
get rid of the special cases we have in dxil_signature.c.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 77c81357f4 dzn: Fix vertex input handling
Vertex shaders are allowed to define input variables pointing to the
same location but a different, or even variables that overlap other
variables, as long as only one of them is used in a shader invocation.

One way to support that case would be to merge overlapping variables,
but we can also declare one input element per variable, and make those
point to the same input slot/offset. The only limitation with the
second approach is the maximum number of VS input registers, meaning
that only (32 - num_sysvals) input variables can be defined.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 4f1cb63bf3 dzn: Fix unitialized var access in dzn_meta_compile_shader()
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon df63772f76 dzn: Handle varying linking explicitly
Now that dxil_spirv_nir.h exposes an helper to run the
DXIL-SPIRV specific passes, we can handle the varying linking
on our side and tell nir_to_dxil() we don't want automatic
varying index/register assignment, which should fix a bunch
of compiler errors.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon dc52e557ff dzn: Fix maxVertexInputAttributes limit
The current implementation doesn't allow more than
MAX_VERTEX_GENERIC_ATTRIBS vertex attributes.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon a4fa63a103 microsoft/spirv_to_dxil: vectorize IOs
DXIL doesn't like when 2 different variables occupy the same slot, so
let's vectorize IOs to avoid that.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 45f8b2ee50 microsoft/compiler: Allow vulkan users to handle varyings linking
Letting the compiler decide which slot should be used for varyings when
it doesn't know about the varyings written/read by the previous/next
stage doesn't work well. So let's the caller decide when it wants
automatic index/register assignment through a dedicated parameter,
instead of assuming Vulkan users always want that.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon d105a16408 microsoft/spirv_to_dxil: Add a linking helper
Linking should be done in reverse order, starting from the last
pipeline stage and going backward, so we can eliminate outputs from the
previous stage that are never used by the next stage, and possibly
kill some instructions and input variables too.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 424bb7357f microsoft/spirv_to_dxil: Remove dead IO vars at the end of dxil_spirv_nir_passes()
No need to keep them around if they're unused. Moreover, this should
allow the linking step to get rid of outputs when the next stage
doesn't use them.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon d3e321c853 microsoft/compiler: Make input_mappings immune to driver_location holes
Right now, nir_to_dxil() assumes driver_location on inputs will be
contiguous, which is true for GL, and also true for Vulkan shaders
with the current implementation. But we are trying to delegate
the varying linking step to Dozen, and that means the driver will
assign the driver_location field.

For everything except vertex shaders this works fine, because we
are in control of the ID we assign to each variable, and can make
sure no holes exists in this assignment, but vertex inputs expect
the index value (which is directly extracted from the
driver_location field) to match the input index defined at pipeline
creation time. The compiler has a hack to treat Vulkan differently
and extract the index from the var->data.location field instead,
but that's a bit confusing.

Moreover, the input_mappings[] array is already indexed with
the var->data.driver_location field in the input load emission
path, so it makes sense to index it with the same field when
emitting signatures.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon e8fd20da90 microsoft/spirv_to_dxil: Constify the descriptor binding mapping fields
spirv_to_dxil() doesn't modify those, so let's constify them.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon c86ea7daa3 microsoft/spirv_to_dxil: Extract NIR passes out of spirv_to_dxil()
Extract NIR passes out of spirv_to_dxil() so we can re-use them
without separately and do the varying linking in Dozen. This way
we will also be able to use vk_shader_module_to_nir() which
takes care of the SPIRV -> NIR translation, plus a bunch of
common lowering passes.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon ca5520c3cb microsoft/compiler: Make sure all SV_Position components are written
Not entirely sure if writing to only some components of
gl_Position/SPIRV-PositionBuiltin from a vertex-processing stage is
allowed, but
https://github.com/dneto0/spirv-samples/blob/main/spvasm/SpvModuleScopeVarParserTest_BuiltinPosition_StorePositionMember_OneAccessChain.spvasm
does exactly that.

Let's make sure all SV_Position components are written, otherwise the
DXIL validator complains.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 9368641c3f microsoft/spirv2dxil: Add a debug option
So we can dump NIR shaders.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon 447d448513 ci/windows: Bump spirv-samples commit-ID
We need the fix adding a Block decoration to the BuiltIn struct in
SpvModuleScopeVarParserTest_BuiltinPosition_BuiltIn_Position_Initializer.spvasm.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
2022-06-08 15:17:05 +00:00
Boris Brezillon c06b265ec7 dzn: Emit missing transition barriers for rendering attachments
VkRenderingAttachmentInitialLayoutInfoMESA provides information about
the initialLayout -> currentLayout that's expected when we begin a
render pass. Let's take it into account.

Fixes: 2d0798440b ("dzn: Add support for dynamic rendering")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16792>
2022-06-07 08:15:25 +00:00
Yonggang Luo ca700dcb0a microsoft/clc: Fixes compiling of microsoft clc with mingw
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16767>
2022-06-03 16:33:00 +00:00
Yonggang Luo 1720672e33 dzn: Fixes compiling error by include `<unknwn.h>`
In mingw's `<unknwn.h>`, it's defeind __REQUIRED_RPCNDR_H_VERSION__ to 475,
so that gcc/mingw won't raise compiling error that because directx/d3d12.h
define __REQUIRED_RPCNDR_H_VERSION__ to 500, but the maximal supported __REQUIRED_RPCNDR_H_VERSION__ in mingw
are 475.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16767>
2022-06-03 16:33:00 +00:00
Yonggang Luo 0445bfdc1b dzn: Fixes compiling error when build with msys2/mingw
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16767>
2022-06-03 16:33:00 +00:00
Boris Brezillon 2feef505c1 microsoft/spirv_to_dxil: Fix the push_constant UBO size calculation
Right now, we just consider the size of the accessed portion of the
push constant array, but it doesn't necessarily reflect the size
of the UBO we should declare.

Fixes: de1e941c59 ("microsoft/spirv_to_dxil: Lower push constant loads to UBO loads")
Reviewed-by: Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16703>
2022-06-03 10:43:18 +00:00
Boris Brezillon 6783a88455 microsoft/spirv_to_dxil: Fix push_constants type declaration
We're not declaring an array of bytes but an array of uint32. Let's
fix the element_count we pass to glsl_array_type().

Fixes: de1e941c59 ("microsoft/spirv_to_dxil: Lower push constant loads to UBO loads")
Reviewed-by: Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16703>
2022-06-03 10:43:17 +00:00
Erik Faye-Lund 8901df12ab dzn: add debug option to redirect stdout/stderr
For applications that doesn't have a terminal, it's useful to get output
like nir_log etc output somewhere.

This outputs these to stderr.txt and stdout.txt in the current user's
home directory, typically in C:\Users\my-user\.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16640>
2022-06-01 08:54:22 +00:00
Erik Faye-Lund 9f3a5b4313 dzn: add a debug-flag to wait for the debugger
It's geneunely useful to wait for the debugger to attach in some cases.
So let's add a debug-flag and staill untik the debugger has attached.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16640>
2022-06-01 08:54:21 +00:00
Jesse Natalie cb2cc69ebb dzn: Update fails/flakes
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16756>
2022-05-31 18:32:59 +00:00
Jesse Natalie a56d47b0ba microsoft/compiler: Fixup sampler derefs in tex instrs that don't *need* samplers
Sometimes you can end up with tex instructions that have sampler deref srcs, even though
they don't need them, e.g. a txs. In this case, still fix up those derefs in the sampler
splitting pass rather than leaving them pointing to a typed sampler.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16639>
2022-05-30 07:28:50 +00:00
Boris Brezillon 47c6f7ccf3 dzn: Use the correct ICD path on Win32
Similar to commit c6cddd2e17 ("lavapipe: Use the correct ICD path on
Win32"), but applied to dozen.

Suggested-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16634>
2022-05-23 08:45:24 +00:00
Boris Brezillon 1eaba553e2 dzn: Use the vk_sync_binary abstraction
D3D12 fences are capable of handling binary operations, but the
current dzn_sync implementation doesn't match vk_sync expectations
when sync objects are used to back semaphores. In that case, the wait
operation is supposed to set the sync object back to an unsignaled
state after the wait succeeded, but there's no way of knowing what
the sync object is used for, and this implicit-reset behavior is not
expected on fence objects, which also use the sync primitive.
That means we currently have a semaphore implementation that works
only once, and, as soon as the semaphore object has been signaled it
stays in a signaled state until it's destroyed.

We could extend the sync framework to pass an
implicit-reset-after-wait flag, but, given no one else seems to
need that, it's probably simpler to drop the binary sync
capability and rely on the binary-on-top-of-timeline emulation provided
by the core.

Fixes: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16629>
2022-05-23 08:09:15 +00:00
Jesse Natalie be5c7c0351 dzn: Add new parameter to vk_image_view_init call
Fixes: fc8d2543 ("vulkan,v3dv: Add a driver_internal flag to vk_image_view_init/create")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16589>
2022-05-18 11:03:26 -07:00
Timothy Arceri 2a2a2e58d1 d3d12: switch to NIR loop unrolling
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16543>
2022-05-17 02:12:21 +00:00
Boris Brezillon 3999fcba15 dzn: Fix dzn_cmd_buffer_collect_queries()
We can have an empty dzn_cmd_buffer_query_pool_state::collect
bitset, handle that case properly.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16396>
2022-05-16 07:46:57 +00:00
Erik Faye-Lund 0ef28ca34a dzn: reset correct list
It makes no sense to add the active heaps to the free heaps, just to
remove them again. Instead, let's move them from the one list to the
other.

This fixes a crash in Doom 2016 after a while, due to resource
exhaustion.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16514>
2022-05-16 07:20:37 +00:00
Karol Herbst 9c5fd100cc nir: add a nir_remove_non_entrypoints helper
This code just got duplicated a lot. There is still more, but the
remaining instances do a bit more than just removing other functions.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16348>
2022-05-10 03:37:44 +00:00
Jesse Natalie ab9d649ac3 microsoft/compiler: Unload DXIL validator library *after* calling Release()
Otherwise, the code to actually run Release() might not be loaded or
callable anymore.

Fixes: 193cf76c ("microsoft/compiler: add common dxil-validator API")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16225>
2022-04-29 16:16:22 +00:00
Erik Faye-Lund 41fcffeda0 microsoft/compiler: fixup indentation
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16079>
2022-04-29 07:08:57 +00:00
Erik Faye-Lund f8fe225840 microsoft/clc: fixup indentation
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16079>
2022-04-29 07:08:57 +00:00
Emma Anholt 536c8ee96d nir/lower_tex: Make the adding a 0 LOD to nir_op_tex in the VS optional.
This controls the whole lowering of "make tex ops with implicit
derivatives on non-implicit-derivative stages be tex ops with an explicit
lod of 0 instead", but it's really hard to describe that in a git commit
summary.

All existing callers get it added except:
- nir_to_tgsi which didn't want it.
- nouveau, which didn't want it (fixes regressions in shadowcube and
  shadow2darray with NIR, since the shading languages don't expose txl of
  those sampler types and thus it's not supported in HW)
- optional lowering passes in mesa/st (lower_rect, YUV lowering, etc)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16156>
2022-04-28 21:26:08 +00:00
Boris Brezillon 1999e927b0 dzn: Fix the STATIC_ASSERT() in dzn_meta_blits_get_context()
We care about the object key size, not the size of a pointer.

Fixes: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16109>
2022-04-22 20:45:04 +00:00
Boris Brezillon 3328f6be06 dzn: Pass the dzn_event pointer to _mesa_hash_table_insert()
The key is supposed to be the dzn_event pointer, not the VkEvent
object, even if they do match in practice on 64bit builds.

Fixes: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16109>
2022-04-22 20:45:04 +00:00
Boris Brezillon cb9ad71d75 dzn: Add missing VKAPI_{ATTR,CALL} specifiers to BeginCommandBuffer()
Fixes: a012b21964 ("microsoft: Initial vulkan-on-12 driver")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16109>
2022-04-22 20:45:04 +00:00
Boris Brezillon e018311b35 dzn: Add KHR_draw_indirect_count support
Unfortunately it's not as simple as passing the indirect draw count
buffer to ExecuteIndirect. The compute job that populate the execute
buffer also needs to know the number of entries that need to be
patched. Instead of transitioning the indirect count buffer from
GENERIC_READ to INDIRECT_ARGUMENT we just keep at as a read-only
resource and copy the draw_count value to the exec buffer in the
compute job.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15914>
2022-04-22 10:01:51 +00:00
Boris Brezillon ece5e27a7f dzn: Allow multiDrawIndirect and drawIndirectFirstInstance
Those are already supported, let's just toggle the switch.

Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15914>
2022-04-22 10:01:51 +00:00
Boris Brezillon e293691a99 dzn: Get rid of the render pass logic
The core provides generic render-pass -> dynamic-rendering wrappers,
so let's rely on them instead of implementing our own logic.

Suggested-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:51 -07:00
Boris Brezillon 2d0798440b dzn: Add support for dynamic rendering
This is how D3D12 works, so nothing really complicated here. We just
add a bunch of states to the render state, patch the pipeline building
logic to support dynamic rendering, and add new functions to

Suggested-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:49 -07:00
Boris Brezillon 076eac0e62 dzn: Inline dzn_cmd_buffer_clear_attachments()
It's only called from dzn_CmdClearAttachments(), so let's move the
code there.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:22 -07:00
Boris Brezillon 70b06e775b dzn: Move all render-related states to a substruct
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:22 -07:00
Boris Brezillon d3836df8d4 dzn: Set MAX_RTS to D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT
D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT == 8, so no functional change
here, it's just cleaner to use the D3D12 definition.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:22 -07:00
Boris Brezillon 39851688df dzn: Pass an image view to dzn_cmd_buffer_clear_attachment()
Let the caller extract the image view from the attachment index, so
we can make this function framebuffer-agnostic and re-use it in the
dynamic rendering path.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
2022-04-22 01:07:22 -07:00
Boris Brezillon 3420110ee7 dzn: Advertise KHR_shader_draw_parameters
We already pass those parameters to shaders, so let's advertise the
feature.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15912>
2022-04-22 07:31:44 +00:00
Boris Brezillon 2eadd8dd16 dzn: Update the draw_id sysval when issuing indirect draws
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15912>
2022-04-22 07:31:44 +00:00
Boris Brezillon 02d8436bbd dzn: Simplify the triangle_fan_rewrite_index shader
We don't need the first_vertex argument when turning non-indexed
triangle-fan draws into indexed triangle-list ones, the firstVertex
argument can simply be passed as a vertexOffset.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15912>
2022-04-22 07:31:44 +00:00
Boris Brezillon 1cefda7cb4 dzn: Fix exec_buf_stride calculation
The stride depends on the indirect draw arguments which are different if
triangle-fan emulation is required.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15912>
2022-04-22 07:31:44 +00:00
Boris Brezillon 7673697256 microsoft/spirv_to_dxil: Add a draw_id field to vertex_runtime_data
So we can support the draw_id system value.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15912>
2022-04-22 07:31:44 +00:00
Erik Faye-Lund 4300b5d914 dzn: remove stale cpp_args
We no longer use C++, so we don't need to set cpp_args here.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16076>
2022-04-21 11:21:06 +00:00
Erik Faye-Lund 85d0d3fede dzn: fixup indent
This seems to be all tab-indents we have in our code-base.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16076>
2022-04-21 11:21:06 +00:00
Erik Faye-Lund dee89ea027 dzn: drop needless enum-casts
After rewriting to C, we also don't need these casts.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16076>
2022-04-21 11:21:06 +00:00
Erik Faye-Lund f854e6ec9b dzn: add space before += operator
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16052>
2022-04-21 10:52:44 +00:00
Erik Faye-Lund 52cde4a1ad dzn: clean up pointer syntax
The code-style we use have a space before the first asterisk for
pointers. Fix a few inconsistencies.

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16052>
2022-04-21 10:52:44 +00:00
Erik Faye-Lund 92964d2bfd dzn: remove some needless casts
Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16052>
2022-04-21 10:52:44 +00:00
Boris Brezillon b8d41d5919 dzn: Add support for KHR_descriptor_update_template
Create update templates where the offset in the descriptor heap is
pre-calculated.

Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15691>
2022-04-21 10:43:31 +00:00
Boris Brezillon 4da5524c9b dzn: Split the write desc helpers in two halves
Split the write desc helpers in two halves, one taking a descriptor
offset directly, and the other one taking a descriptor set pointer.

This will allow us to pre-calculate descriptor offsets when creating
a descriptor_update template and speed up a bit the write step in that
case.

Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15691>
2022-04-21 10:43:30 +00:00
Boris Brezillon 31dc341f3a dzn: Pass layout objects to various dzn_descriptor_set_ptr_xxx helpers
Needed if we want to support KHR_descriptor_update_template, since
we won't have access to the final descriptor set when calculating heap
offsets in that case.

Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15691>
2022-04-21 10:43:30 +00:00
Boris Brezillon fe68cfe82a dzn: Rename a bunch of dzn_descriptor_set helpers
Let's be consistent with other helpers taking a dzn_descriptor_set_ptr
object and prefix all such functions with dzn_descriptor_set_ptr_.

We also rename dzn_descriptor_set_ptr_get_desc_vk_type() into
dzn_descriptor_set_ptr_get_vk_type() to shorten it a bit.

Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15691>
2022-04-21 10:43:30 +00:00
Boris Brezillon 3af6631c6d dzn: Add support for EXT_vertex_attribute_divisor
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15915>
2022-04-21 00:31:18 -07:00
Boris Brezillon d01a149b8b ci/windows: Split the windows-related tests
Should help with the timeouts we see in CI right now.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16042>
2022-04-20 23:45:28 -07:00