Commit graph

116 commits

Author SHA1 Message Date
Jesse Natalie
9702ddccc2 microsoft/compiler: Don't duplicate work from gather_info in var sorting
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28535>
2024-04-04 20:29:10 +00:00
Jesse Natalie
d4a15a048b microsoft/compiler: Expect front-facing var as an input
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28535>
2024-04-04 20:29:10 +00:00
Jesse Natalie
6d8461f545 d3d12: Subgroup ballot
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27528>
2024-02-08 20:41:58 +00:00
Faith Ekstrand
80376146ed nak: Encode program headers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:06 +00:00
Jesse Natalie
9fe88dd9b9 d3d12: Support enhanced layouts for VS inputs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26156>
2023-11-14 00:18:53 +00:00
Jesse Natalie
72341747f4 d3d12: Split dvec3 interpolatns into devc2 and double
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26156>
2023-11-14 00:18:53 +00:00
Jesse Natalie
a07bdf0152 d3d12: Initialize shader key swizzle for non-int textures
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26104>
2023-11-07 22:31:20 +00:00
Yonggang Luo
4a8ec0db90 d3d12: Switch to use nir_foreach_function_impl
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/23920>
2023-06-29 11:29:54 +00:00
Jesse Natalie
42877c8b63 dxil: Don't generate load_ubo_dxil directly
Just use load_ubo and let it get lowered appropriately later on.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
2023-06-13 00:43:36 +00:00
Jesse Natalie
f121d8fe12 microsoft/compiler: Un-lower shared/scratch to derefs
Derefs have index-based access semantics, which means we don't need
custom intrinsics to encode an index instead of a byte offset.

Remove the "masked" store intrinsics and just emit the pair of atomics
directly. This massively reduces duplication between scratch, shared,
and constant, while also moving more things into nir so more optimizations
can be done.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
2023-06-13 00:43:36 +00:00
Yonggang Luo
12256136e0 compiler: Rename shader_prim to mesa_prim and replace all usage of pipe_prim_type with mesa_prim
This is a prepare step to remove depends on p_defines.h in src/util/*

This is done by:
replace pipe_prim_type with mesa_prim
replace shader_prim with mesa_prim
replace PIPE_PRIM_MAX  with MESA_PRIM_COUNT
replace SHADER_PRIM_  with MESA_PRIM_
replace PIPE_PRIM_ with MESA_PRIM_

This patch only replace code only

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23369>
2023-06-03 03:29:03 +00:00
Thomas H.P. Andersen
1a6ffb3e9d d3d12: remove unused tgsi includes
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22838>
2023-05-25 08:20:32 +00:00
Jesse Natalie
9dc009e7ae d3d12: Convert from D3D shader model to Mesa shader model earlier
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22952>
2023-05-11 21:56:31 +00:00
Jesse Natalie
b723962418 d3d12: Move forward-front-face pass to common DXIL code
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22277>
2023-04-04 21:48:19 +00:00
Jesse Natalie
79725115c6 d3d12: Remove now-unused UAV format from shader info
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22093>
2023-03-23 18:34:52 +00:00
Giancarlo Devich
70af7fd5e8 d3d12: Unroll shader variant selection loop
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21909>
2023-03-17 07:43:08 +00:00
Giancarlo Devich
777e6b43bc d3d12: Reduce gs variant key init cost; unnecessary validate gs calls
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21909>
2023-03-17 07:43:08 +00:00
Giancarlo Devich
9bbf5505f0 d3d12: Use short circuit in shader key compare; update key hash
Move common key compare to the final step; change to short circuit from
memcmp.

Update key hash to treat varying pointers as uint64.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21909>
2023-03-17 07:43:08 +00:00
Giancarlo Devich
32e058017d d3d12: Use context-level sampler_state array for filling shader keys
This significantly reduces the size of d3d12_shader_key

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21909>
2023-03-17 07:43:08 +00:00
Giancarlo Devich
7854f9283c d3d12: Don't unnecessarily recompute manual_depth_range
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21909>
2023-03-17 07:43:08 +00:00
Giancarlo Devich
f53188b7fa d3d12: Cache varying info to reduce compare/copy cost
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>
2023-03-01 19:40:06 +00:00
Giancarlo Devich
e4ba343ac9 d3d12: Compare shader key common parts with memcmp, instead of if's
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>
2023-03-01 19:40:06 +00:00
Giancarlo Devich
623a01827c d3d12: Compare shader keys with union-encompassing fields all at once
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>
2023-03-01 19:40:06 +00:00
Giancarlo Devich
ebd925e79c d3d12: Compare shader keys with a switch, instead of cascading if's
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>
2023-03-01 19:40:06 +00:00
Giancarlo Devich
bf6c214b25 d3d12: Create varying structures as necessary, reference them
This changes instances of d3d12_varying_info to d3d12_varying_info*,
significantly reducing the size of the d3d12_shader_key,
d3d12_gs_variant_key, and d3d12_tcs_variant_key.

Associated changes to key fill, compare, hashing, and gs and tcs variant
maps significantly reduce the amount of time spent clearing and
comparing memory.

The biggest win here is not having to re-zero _or_ re-fill varyings in
d3d12_fill_shader_key, validate_geometry_shader_variant, and
validate_tess_ctrl_shader_variant.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21527>
2023-02-27 22:05:34 +00:00
Giancarlo Devich
41d5e76f2c d3d12: Don't memcmp gs/tcs keys
This is unnecessary and incomplete. Not only is it covered by the hash
map lookup, but also does not consider the other key members.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21527>
2023-02-27 22:05:34 +00:00
Giancarlo Devich
30883c0145 d3d12: Don't unnecessarily zero out gs/tcs keys
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21527>
2023-02-27 22:05:34 +00:00
Giancarlo Devich
56d30bf591 d3d12: Track max varying slot, set and compare less bytes
Often, the full range of available slots don't need to participate in
the comparison or be zeroed out.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21527>
2023-02-27 22:05:34 +00:00
Giancarlo Devich
9a3820fe11 d3d12: Don't recompute has_flat_varyings or missing_dual_src_outputs
Per shader selection, these two flags can be expensive to compute.
Instead, recompute their values as neccessary, and save them in the
context.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21527>
2023-02-27 22:05:34 +00:00
Giancarlo Devich
11bec22647 d3d12: Don't clear d3d12_shader_key
The shader key structure is quite large and memsetting it to zero to be
able to create or often simply find an existing shader is responsible
for a large portion of CPU usage during benchmarks.

This change is more surgical about what, when, and how things get
cleared.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21247>
2023-02-13 22:57:03 +00:00
Giancarlo Devich
b2e5484171 d3d12: Add unions to encompass shader key stage vars, use in hashing
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21247>
2023-02-13 22:57:03 +00:00
Giancarlo Devich
806f100ad2 d3d12: Use varying comparison function for TESS stage key compare
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21247>
2023-02-13 22:57:03 +00:00
Jesse Natalie
58e7acb0e2 microsoft/compiler: Support lowering SSBO accesses to 16bit vectors
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21029>
2023-02-11 06:12:23 +00:00
Ian Romanick
2f467fb154 gallium/draw: Enable polygon stipple NIR helpers to generate bool1 or bool32 Booleans
It appears that only softpipe, llvmpipe, and d3d12 hit any of this
code. If some NIR-to-TGSI driver that doesn't have native integers
(e.g., i915 or r300) wants to use this path in the future, it should be
easy to add float32 support.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20869>
2023-01-28 20:42:32 -08:00
Giancarlo Devich
f13a42e5a1 Fix incorrect stage reference
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20616>
2023-01-11 07:18:42 +00:00
Giancarlo Devich
63345d59b0 d3d12: Unionize shader variables in d3d12_shader_key to reduce size
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20616>
2023-01-11 07:18:42 +00:00
Ian Romanick
1fae751d49 microsoft/compiler: Simplify nir_intrinsic_load_front_face handling
It is invalid to have Boolean variables as either shader inputs or
outputs, so there is no point to try to lower them in general.  The only
use for this was some two-phase lowering of
nir_intrinsic_load_front_face that could be done in a single phase.
Create the SYSTEM_VALUE_FRONT_FACE as a uint and compare it with zero at
the same time.

No shader-db or fossil-db changes on any Intel platform.

v2: Remove dxil_nir_lower_bool_input from dxil_nir.h and drop it from
the other caller in the spirv_to_dxil codepath.  Noticed by Jesse.  Fix
setting bit size when loading SYSTEM_VALUE_FRONT_FACE.  Caught by CI.

v3: Use nir_ine_imm.  Change type of gl_FrontFacing GS output in
d3d12_nir_passes from Boolean to integer.  Both suggested by Jesse.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15121>
2022-12-14 06:23:21 +00:00
Jesse Natalie
1399f37a3b d3d12: Move lower_sample_pos to microsoft/compiler
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19471>
2022-11-04 01:40:17 +00:00
Pedro J. Estébanez
0bf5bbb3e4 microsoft/spirv2dxil: Refactor to make SM and validator versions public
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19227>
2022-10-24 16:15:31 +00:00
Jesse Natalie
85359eba03 d3d12: Get max supported shader model
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18022>
2022-08-25 21:22:49 +00:00
Ian Romanick
1aacd9492d radeonsi: r600: d3d12: st: Use NIR lowering for tg4 offset arrays instead of GLSL lowering
I think I got all the drivers that need updating.  This is only
necessary in drivers that support GLSL 4.00 / GL_ARB_gpu_shader5 and
have PIPE_CAP_TEXTURE_GATHER_OFFSETS = 0.

v2: Don't (accidentally) condition tg4 offsets lowering on tex rect
lowering.  Noticed by Qiang.

v3: Add missing bool() cast.

v4: don't use designated initializers

Fixes: 640f909862 ("glsl: add _texture related sparse texture builtin functions")
Closes: #6365
Tested-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16547>
2022-08-23 01:10:23 +00:00
Michael Tang
55b3980e78 microsoft/compiler: Add dxil_logger type and parameter to nir_to_dxil
v2 (jenatali): Add a default logger which aborts via unreachable,
and use NULL from GL/Vulkan to use the default logger.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12510>
2022-08-11 16:17:46 +00:00
Jesse Natalie
ef7635b1cb d3d12: Retrieve validator version
For platforms where there's no validator available, leave the field zero-initialized
to let the DXIL backend choose whatever target validator version it wants.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17603>
2022-07-23 14:48:17 +00:00
Jesse Natalie
6af22121cf microsoft/compiler: Add a max validator version
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17603>
2022-07-23 14:48:17 +00:00
Jesse Natalie
c8f63e07da microsoft/compiler: Add a max shader model option
Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17603>
2022-07-23 14:48:17 +00:00
Jesse Natalie
fccd6e275c d3d12: Support clip halfz
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17567>
2022-07-22 00:00:54 +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
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
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
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