~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/microsoft/compiler/nir_to_dxil.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © Microsoft Corporation
3
 
 *
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:
10
 
 *
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
13
 
 * Software.
14
 
 *
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
21
 
 * IN THE SOFTWARE.
22
 
 */
23
 
 
24
 
#ifndef NIR_TO_DXIL_H
25
 
#define NIR_TO_DXIL_H
26
 
 
27
 
#include <stdbool.h>
28
 
 
29
 
#include "nir.h"
30
 
 
31
 
#ifdef __cplusplus
32
 
extern "C" {
33
 
#endif
34
 
 
35
 
struct blob;
36
 
 
37
 
enum dxil_sysvalue_type {
38
 
   DXIL_NO_SYSVALUE = 0,
39
 
   DXIL_SYSVALUE,
40
 
   DXIL_GENERATED_SYSVALUE
41
 
};
42
 
 
43
 
enum dxil_sysvalue_type
44
 
nir_var_to_dxil_sysvalue_type(nir_variable *var, uint64_t other_stage_mask);
45
 
 
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
50
 
 */
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
60
 
    */
61
 
   DXIL_ENVIRONMENT_GL,
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
70
 
    */
71
 
   DXIL_ENVIRONMENT_CL,
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
79
 
    */
80
 
   DXIL_ENVIRONMENT_VULKAN,
81
 
};
82
 
 
83
 
struct nir_to_dxil_options {
84
 
   bool interpolate_at_vertex;
85
 
   bool lower_int16;
86
 
   bool disable_math_refactoring;
87
 
   bool no_ubo0;
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;
93
 
};
94
 
 
95
 
bool
96
 
nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
97
 
            struct blob *blob);
98
 
 
99
 
const nir_shader_compiler_options*
100
 
dxil_get_nir_compiler_options(void);
101
 
 
102
 
#ifdef __cplusplus
103
 
}
104
 
#endif
105
 
 
106
 
#endif