Commit Graph

602 Commits

Author SHA1 Message Date
Boris Brezillon 99352b87dc dzn: Take VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT into account
Use a typeless format when VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is
set, so we can cast to compatible types at least. Still doesn't
work when formats are of the same size but from incompatible
types (like R32_FLOAT and RGBA8_UNORM), which Vulkan considers
as compatible while D3D12 doesn't, but it gets us closer to what
the Vulkan API wants.

D3D12_FEATURE_DATA_D3D12_OPTIONS12::RelaxedFormatCastingSupported
should address the remaining limitations.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17368>
2022-07-06 06:15:46 +00:00
Boris Brezillon d132ec924d dzn: Support native image copies when formats are compatible
CopyTextureRegion() works fine if the formats belong to the
same group (matching the same _TYPELESS type), so let's avoid
creating a temporary resource in that case.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17368>
2022-07-06 06:15:46 +00:00
Boris Brezillon 53a352e1cf dzn: Provide a helper to check if 2 formats are compatible
D3D12 supports fomat casting through optional features. Let's
add a helper to query whether 2 formats are compatible or not.
The compatibility depends on the formats+usage pair
(CopyTextureRegion() is less strict than the texture sampling
logic).

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17368>
2022-07-06 06:15:46 +00:00
Boris Brezillon af294d9ba0 dzn: Query D3D12_FEATURE_D3D12_OPTIONS3 features
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17368>
2022-07-06 06:15:46 +00:00
Jesse Natalie 31fab141df dzn: Support Vulkan loader interface v5
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17321>
2022-07-01 14:56:18 +00:00
Boris Brezillon a577acf8f6 dzn: Mark transition barriers as executed when we execute barriers
It was previously done dzn_cmd_buffer_flush_transition_barriers(),
leaving the queue+flush case unhandled. Let's fix that by moving
this piece of code to dzn_cmd_buffer_exec_transition_barriers().

Fixes: 35356b1173 ("dzn: Cache and pack transition barriers")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17314>
2022-07-01 09:42:58 +00:00
Konstantin Seurer 9fc7d5e0e1 dozen: Use nir_test_mask instead of i2b(iand)
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17242>
2022-06-30 18:00:32 +00:00
Konstantin Seurer 39abd90d9e microsoft: Use nir_test_mask instead of i2b(iand)
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17242>
2022-06-30 18:00:32 +00:00
Jason Ekstrand d06335ed76 vulkan: Depend on vk_pipeline_layout in vk_cmd_enqueue
Now that we have a common pipeline layout with reference counting, we
don't need these driver hooks for reference counting anymore.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
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/17286>
2022-06-29 20:31:58 +00:00
Boris Brezillon aa40a04ad9 dzn: Use the vk_pipeline_layout base struct
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17286>
2022-06-29 20:31:58 +00:00
Boris Brezillon 88f287a1d0 dzn: Use the vk_descriptor_set_layout base struct
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17286>
2022-06-29 20:31:58 +00:00
Boris Brezillon 4290c3d5b5 dzn: Fix -Wswitch warnings
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon 804da0806d dzn: Fix {back,front}_wr_uses_ref assignment
We're lacking parens, as reported by clang.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon da493e144f dzn: Fix printf() format in dxgi_get_factory() error message
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon a1715875e1 dzn: Fix 'statement with no effect' warning
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon 97dbebb558 dzn: Fix unused var warnings
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon bb8ca4bafe dzn: Fix copies of block-based formats
D3D12 wants Width, Height and Depth to be aligned on the block width,
height and depth size. But Vulkan allows the width, height or depth to
be unaligned at the image boundary if image.{width,height,depth} is
not aligned.

Let's explicitly align things in the copy paths.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon e3cf48e8f5 dzn: Allow shaders to read from depth/stencil attachments
D3D12_RESOURCE_STATE_DEPTH_READ only provides access for fixed-function
depth/stencil test. If we want the shaders to be able to read the
depth/stencil attachment, we need to combine
D3D12_RESOURCE_STATE_DEPTH_READ and
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:42 -07:00
Boris Brezillon d07befe4f8 dzn: Introduce dzn_cmd_buffer_queue_image_range_state_transition()
Sometimes there's no obvious mappings between a VkImageLayout and
a D3D12_RESOURCE_STATE, so let's just provide a helper that takes
before/after resource states instead of old/new layouts, and use it
to fix the resolve case.

Fixes: 35356b1173 ("dzn: Cache and pack transition barriers")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:38 -07:00
Boris Brezillon ed78cf307b dzn: Rename dzn_cmd_buffer_queue_image_subres_range_transition()
We are about to introduce the same function taking D3D12_RESOURCE_STATES
arguments instead of VkImageLayout ones. Let's rename the function
accordingly.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:33 -07:00
Boris Brezillon 9eb70b5dcf dzn: Don't call dzn_cmd_buffer_queue_transition_barriers() prematurely
We want to pack ResourceBarriers() call as much as we can, so let's
not dzn_cmd_buffer_queue_transition_barriers() when we could still queue
new barriers.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17250>
2022-06-29 09:54:22 -07:00
Boris Brezillon 35356b1173 dzn: Cache and pack transition barriers
Some Vulkan -> D3D12 API mismatches force us to do behind-the-scene
transitions to get resources in the right state when executing
non-native operations. In this case, caching the transition until the
resource is actually used might save us unneeded transitions.

The packing aspect is mostly useful to limit the ExecuteBarriers()
call overhead. Right now we do per-resource packing, and any hole
in the subresource range will trigger several ExecuteBarriers()
calls. This can be improved by collecting barriers in a separate
array, and flushing the collected transition barriers just before
executing the operation using the subresources pointed by those
barriers. While not impossible, it'd be more verbose than what we
have right now, so I'm not entirely convinced it's worth it.

Caching could be improved to avoid any unnecessary flush when we do
blit or copy operations and transition the resources back to their
original state, since the user might decide to transition the image to
a new layout just after that. But doing that would require keeping
track of all resources used by dispatch/draw operations, which in turn
implies keeping info about which of the descriptor set resources are
used by the graphics/compute pipelines. Not sure the it's worth the
extra complexity given D3D12 enhanced barriers are just around the
corner, and those map pretty nicely to the vulkan barrier+image-layout
model.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17274>
2022-06-29 11:39:13 +00:00
Boris Brezillon 3129520a73 ci/dzn: Add pipeline cache tests to the include list
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 91f1bd8f81 dzn: Cache pipeline info
We are already caching DXIL shaders individually, but that forces us
to retrieve the NIR shader, do the linking and binding translation
steps, to finally query the cache for each DXIL shader. This pipeline
caching is about skipping those steps when we can.

Note that a graphics/compute pipeline cache entry doesn't contain the
DXIL shaders, but hashes to retrieve those shaders from the same cache.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon d8b686783e dzn: Cache DXIL shaders
This way we avoid the NIR -> DXIL translation when we have a cache hit.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 52e2ca084a dzn: Caculate a binding translation hash
Binding translation has an impact on the final DXIL shader, and this
binding translation depends on the pipeline layout. Let's extend the
adjust_var_bindings() pass to caculate a hash we can then use in the
DXIL shader hash caculation.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 276c73580d dzn: Cache NIR shaders
Saves us the SPIRV -> NIR translation, and all the lowering passes run
in dxil_spirv_nir_passes().

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 66764904b3 dzn: Move the compute shader compilation logic to a sub-function
Will make things easier when we introduce shader caching.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 6236d1eead dzn: Drop unneeded goto statement in dzn_compute_pipeline_create()
The 'out' label is placed just after the if () block, we can thus
remove the 'goto out;' statement.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon d4630b703d dzn: Add a generic cached blob wrapper
Basically what vk_pipeline_cache's raw_data_object abstraction provides,
but I'm not sure it makes sense to make it generic so I copied it here.
Might be more appropriate to make raw_data_object public.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 06f37025f1 dzn: Hash pipeline layout stages
DXIL shaders depend on the vulkan -> d3d12 binding translation done in
adjust_var_bindings(). In order to maximize our chances to re-use those
shaders, we need to hash the binding translation information and take
this hash into account when computing the DXIL shader hash.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon 391d3251fa dzn: Don't delegate binding translation to dxil_spirv_nir_passes()
We will need to hash var bindings if we want to cache DXIL shaders.
Let's move this pass to dzn_pipeline.c to prepare this transition.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17140>
2022-06-28 13:02:23 +00:00
Boris Brezillon c7b43711f3 dzn: Save a few indentation levels in graphics_pipeline_compile_shaders()
We can compute the yz_flip_mode and force_sample_rate_shading outside
of the foreach_shader loop.

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 84770a90bb dzn: Use vk_to_mesa_shader_stage()
Use vk_to_mesa_shader_stage() to convert a VkShaderStageFlagBits into
its gl_shader_stage counterpart.

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 f4a96675ec dzn: Fix potential nir_shader leak
We leak the nir_shader object f a failure happens between the NIR
shader creation and the DXIL compilation. Let's drop the local
nir_shader pointer and use the one in the graphics_pipeline object
to avoid that.

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 af83f104da dzn: Let dzn_pipeline_init() initialize the root signature in the stream
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 301fb478fe dzn: Drop unused allocator passed to dzn_graphics_pipeline_create()
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 b886619313 dzn: Drop useless while(link_mask != 0)
That's not a `do {} while();`, just a simple `while() {}`, the second
while statement is a NOP.

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 31357f3cf4 dzn: Pass the maximum stream size to d3d12_pipeline_state_stream_new_desc()
This way we can use d3d12_pipeline_state_stream_new_desc() directly
without doing

   if (type == GRAPHICS)
      d3d12_gfx_pipeline_state_stream_new_desc()
   else
      d3d12_compute_pipeline_state_stream_new_desc()

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 e4e531732b dzn: Use d3d12_compute_pipeline_state_stream_new_desc() in the compute path
Fixes: 9feda65a83 ("dzn: Use CreatePipelineState()")
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 d3e6ef195a dzn: Fix assertion in d3d12_pipeline_state_stream_new_desc()
Fixes: 9feda65a83 ("dzn: Use CreatePipelineState()")
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 26ca9a4344 dzn: Add missing D3D12_CACHED_PIPELINE_STATE to MAX_COMPUTE_PIPELINE_STATE_STREAM_SIZE
Fixes: 9feda65a83 ("dzn: Use CreatePipelineState()")
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 c66caa1d58 dzn: Drop dzn_pipeline_cache.c
The core provides a conformant pipeline cache implementation, let's
use it.

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 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