Commit Graph

138 Commits

Author SHA1 Message Date
Jesse Natalie eb0cefae6d microsoft/compiler: Map I/O base locations to input IDs
When dealing with a vertex input that takes multiple rows, the value of
nir_intrinsic_base points to a driver-location-based index, but we need
to emit a location-based index (or more specifically, an index that
increments once per input, not once per register). Add a mapping to
the module of base -> ID.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie efe5c2d6f3 microsoft/compiler: Process signatures before the shader code
This lets us set up some metadata based on I/O vars without having
to do multiple passes over them.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie cdc49fb605 microsoft/compiler: Lower 64bit I/O to 32 and then run lower_pack
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie b24cfd0d40 microsoft/compiler: Handle b2f64
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie 4d17393ba0 microsoft/compiler: Set dx11_1_double_extensions flag for dfma/ddiv
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie c8bd830dfb microsoft/compiler: Fix make_double and split_double to respect swizzles
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie dde3b04d44 microsoft/compiler: It's possible to have doubles without int64
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie 3b9483e89d microsoft/compiler: Add never-supported double ops to lower_doubles bitmask
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie ce6dbbabf9 microsoft/compiler: Only treat tess level location as special if it's a patch constant
Fixes: a550c059 ("microsoft/compiler: For load_input from DS, use loadPatchConstant")
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie 0c711dc823 microsoft/compiler: Only prep phis for the current function
Fixes: 41af9620 ("microsoft/compiler: Emit all NIR functions into the DXIL module")
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie 87d22c2465 microsoft/compiler: Lower mul_2x32_64
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-By: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14837>
2022-02-04 00:07:53 +00:00
Jesse Natalie 895cdbd6f0 microsoft/compiler: Correctly support I/O on variables with location_frac
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14787>
2022-01-31 13:34:27 -08:00
Jesse Natalie 2d4ee41df0 microsoft/compiler: Fix UAV resource ID counting for static indexed handles
Skip resource space 2 after computing the ID it would've used.

Fixes: e5f353f2 ("microsoft/compiler: Emit statically-indexed resource handles and scratch later")
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14787>
2022-01-31 13:13:12 -08:00
Boris Brezillon a4c8508c37 microsoft/compiler: textureLoad() doesn't take a LOD on MS textures
Make sure the LOD is zero in that case.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13993>
2022-01-31 16:37:47 +00:00
Boris Brezillon 678b94c2d8 microsoft/compiler: Fix sampler/texture array emission
Those need to be declared as sampler/SRV arrays, as we do for UAVs and
CBVs.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13993>
2022-01-31 16:37:47 +00:00
Louis-Francis Ratté-Boulianne 54c32aeba6 microsoft/compiler: Use SRVs for read-only images
Acked-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13993>
2022-01-31 16:37:47 +00:00
Louis-Francis Ratté-Boulianne ef5283d37d microsoft/compiler: add support for load_layer_id
We simply return 0 for now as we don't support multi-view yet.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13993>
2022-01-31 16:37:47 +00:00
Jesse Natalie 973bff335f microsoft/compiler: Handle clip/cull distance as an input to tess shaders
In order to get the semantics right, we need to know how many of the clip/
cull fields are designated for which purpose. In the case of a shader that
can receive these fields as both input and output, the shader_info property
is reserved to store the output info. We could add a dedicated input field
to shader_info, but since it'd probably only be useful for us, just send
it through a side channel during shader linking.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 4da51aa88f microsoft/compiler: Primitive ID should only be added as a sysval in geometry shaders
Docs say that its presence in signatures as a "shadow" element (meaning it's not
accessed via load/store, but with a dedicated opcode) is legacy. It seems it
wasn't carried forward when HS/DS were added in D3D11.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie ec415a274e microsoft/compiler: Emit DS PSV validation and entrypoint metadata
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 9aca56b137 microsoft/compiler: Handle domain location intrinsic
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 8524d04783 microsoft/compiler: Handle load_output in the HS stage as reading a previously written patch constant
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie a39881b788 microsoft/compiler: Handle load_per_vertex_output as LoadOutputControlPoint
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie a550c059c7 microsoft/compiler: For load_input from DS, use loadPatchConstant
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie cc6104dd3f microsoft/compiler: For store_output from HS, use storePatchConstant
In HS, store_per_vertex_output maps to storeOutput in DXIL. The data
that isn't per-vertex is patch constants.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 97b6ea71a0 microsoft/compiler: Add a pass for hull and domain shaders to shrink tess level vars
DXIL validation will complain if the tess factor signature entries have the
wrong number of components for the shader's domain. Make sure that both
hull and domain shaders have the right number, and drop loads and stores
from the removed components.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie bd2a4fb1b8 microsoft/compiler: Add patch constant signature into PSV and as container blob
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 4bb4d0454d microsoft/compiler: Overlap patch and non-patch varyings so both are separately 0-indexed
Also add tess factors to the list of sysvals that can cause vars to be sorted last.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie b346f28453 microsoft/compiler: Emit HS PSV validation and entrypoint metadata
Note that this requires the shader info "tess" data to be correct.
For GLSL tess control shaders, only the output primitive count is
automatically available. The rest will need to be either guessed
or filled in from a matching tess eval (domain) shader. This is handled
by the d3d12 driver in a later patch.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie f511354a64 microsoft/compiler: Split hull (tess ctrl) shaders into main and patch constant funcs
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie ad2233616c microsoft/compiler: Handle store_per_vertex_output for HS outputs
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 41af962099 microsoft/compiler: Emit all NIR functions into the DXIL module
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie f6a333f010 microsoft/compiler: Emit functions with actual function names
Once we start writing multiple functions, we can't keep calling all
of them "main"

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 72812fe9b5 microsoft/compiler: Support emitting multiple functions into a DXIL module
The instruction and block lists are moved into a new "function definition"
struct, and the DXIL module tracks one at a time for adding instructions
into. The NIR side still only emits the main function here though.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie e5f353f2f2 microsoft/compiler: Emit statically-indexed resource handles and scratch later
The resource declarations are module-wide, but the resource handles
are function-local. A future change will add multi-function support,
but requires these handles to be potentially emitted multiple times.
The alloca used for scratch is also function-local.

This is the same pattern that the DXBC to DXIL converter uses.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie b5cb81f8c1 microsoft/compiler: Add mapping from MESA_SHADER_* to DXIL_*_SHADER for tessellation
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
2022-01-26 01:31:35 +00:00
Jesse Natalie 7f9ac5bba2 d3d12: Support dynamic UBO/SSBO indexing
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie f915bc56a4 microsoft/compiler: Lower helper invocations
DXIL adds this in SM6.6, so when we get around to being able to
emit SM6.6, we can conditionally turn this off and support emitting
the new intrinsic. Until then, this is easy.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 1022435845 microsoft/compiler: Handle msb/lsb/bfrev
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie ac94bcf046 microsoft/compiler: Use ibfe/ubfe for bitfield extract instead of lowering to shifts
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 80e782d5ed microsoft/compiler: Handle bitfield_insert
This *almost* matches what GLSL wants, except for the handling of
large widths. You can see this in the lowering algorithm:
   (('bitfield_insert', 'base', 'insert', 'offset', 'bits'),
    ('bcsel', ('ult', 31, 'bits'), 'insert',
              ('bfi', ('bfm', 'bits', 'offset'), 'insert', 'base')),
    'options->lower_bitfield_insert'),

DXIL's 'bfi' instruction is an inseparable pairing of NIR's 'bfi(bfm(...), ...)',
so we just apply the additional bcsel in the backend.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 8938c6e032 microsoft/compiler: Emit samplers as array types
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 7502b08900 microsoft/compiler: Handle load_invocation_id for GS and HS
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie fe6f7b5265 microsoft/compiler: Handle tex texture/sampler offset srcs
Note that these offsets are 0-based, so to make them binding IDs we
need to explicitly add the base ID to them.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 7748e4799d microsoft/compiler: Handle input coverage
Note that GL requires input coverage for sample execution mode to
be only the single bit corresponding to the executing sample, so
rearrange things to understand during shader emitting if we're
executing per-sample to emit the right coverage value.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 777a42e309 microsoft/compiler: Handle textureGatherCmp
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 30a44e4c3d microsoft/compiler: Handle 'pull model' explicit interpolation intrinsics
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 5b51842b58 microsoft/compiler: Always have at least one GS active stream
DXIL validation will fail if there's no stream that has a valid
primitive topology, which is what happens in the case of no
active streams.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie a8373ca8de microsoft/compiler: Handle load_sample_pos_at_id
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie 2837e67b9b microsoft/compiler: Handle more GL memory barriers
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14367>
2022-01-11 01:36:56 +00:00