2
* Copyright © Microsoft Corporation
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
37
enum dxil_sysvalue_type {
40
DXIL_GENERATED_SYSVALUE
43
enum dxil_sysvalue_type
44
nir_var_to_dxil_sysvalue_type(nir_variable *var, uint64_t other_stage_mask);
46
/* Controls how resource decls/accesses are handled. Common to all:
47
* Images, textures, and samplers map to D3D UAV, SRV, and sampler types
48
* Shared is lowered to explicit I/O and then to a DXIL-specific intrinsic for 4-byte indices instead of byte addressing
49
* Input/output are lowered to dedicated intrinsics
51
enum dxil_environment {
52
/* In the GL environment:
53
* Samplers/textures are lowered, vars/intrinsics use binding to refer to them; dynamic array indexing not yet supported
54
* The lowering done by mesa/st assigns bindings from 0 -> N
55
* All other resource variables have driver_location set instead, assigned from 0 -> N
56
* UBOs may or may not have interface variables, and are declared from ubo_binding_offset -> num_ubos; no dynamic indexing yet
57
* SSBOs may or may not have interface variables, and are declared from from 0 -> num_ssbos; no dynamic indexing yet
58
* Images are *not* lowered, so that dynamic indexing can deterministically get a base binding via the deref chain
59
* No immediate constant buffer, or scratch
62
/* In the CL environment:
63
* Shader kind is always KERNEL
64
* All resources use binding for identification
65
* Samplers/textures/images are lowered; dynamic indexing not supported by spec
66
* UBOs are arrays of uints in the NIR
67
* SSBOs are implicitly declared via num_kernel_globals
68
* Variables of shader_temp are used to declare an immediate constant buffer, with load_ptr_dxil intrinsics to access it
69
* Scratch is supported and lowered to DXIL-specific intrinsics for scalar 32-bit access
72
/* In the Vulkan environment:
73
* All resources use binding / descriptor_set for identification
74
* Samplers/textures/images are not lowered
75
* Deref chains are walked to emit the DXIL handle to the resource; dynamic indexing supported
76
* UBOs/SSBOs are struct variables in the NIR, accessed via vulkan_resource_index/load_vulkan_descriptor; dynamic indexing supported
77
* Read-only SSBOs, as declared in the SPIR-V, are bound as raw buffer SRVs instead of UAVs
78
* No immediate constant buffer or scratch
80
DXIL_ENVIRONMENT_VULKAN,
83
struct nir_to_dxil_options {
84
bool interpolate_at_vertex;
86
bool disable_math_refactoring;
88
bool last_ubo_is_not_arrayed;
89
unsigned provoking_vertex;
90
unsigned num_kernel_globals;
91
unsigned input_clip_size;
92
enum dxil_environment environment;
96
nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
99
const nir_shader_compiler_options*
100
dxil_get_nir_compiler_options(void);