2019-09-04 10:51:29 +01:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © Microsoft Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NIR_TO_DXIL_H
|
|
|
|
|
#define NIR_TO_DXIL_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
#include "nir.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct blob;
|
|
|
|
|
|
|
|
|
|
enum dxil_sysvalue_type {
|
|
|
|
|
DXIL_NO_SYSVALUE = 0,
|
|
|
|
|
DXIL_SYSVALUE,
|
|
|
|
|
DXIL_GENERATED_SYSVALUE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum dxil_sysvalue_type
|
|
|
|
|
nir_var_to_dxil_sysvalue_type(nir_variable *var, uint64_t other_stage_mask);
|
|
|
|
|
|
2021-12-28 21:13:03 +00:00
|
|
|
|
/* Controls how resource decls/accesses are handled. Common to all:
|
|
|
|
|
* Images, textures, and samplers map to D3D UAV, SRV, and sampler types
|
|
|
|
|
* Shared is lowered to explicit I/O and then to a DXIL-specific intrinsic for 4-byte indices instead of byte addressing
|
|
|
|
|
* Input/output are lowered to dedicated intrinsics
|
|
|
|
|
*/
|
|
|
|
|
enum dxil_environment {
|
|
|
|
|
/* In the GL environment:
|
|
|
|
|
* Samplers/textures are lowered, vars/intrinsics use binding to refer to them; dynamic array indexing not yet supported
|
|
|
|
|
* The lowering done by mesa/st assigns bindings from 0 -> N
|
|
|
|
|
* All other resource variables have driver_location set instead, assigned from 0 -> N
|
|
|
|
|
* UBOs may or may not have interface variables, and are declared from ubo_binding_offset -> num_ubos; no dynamic indexing yet
|
|
|
|
|
* SSBOs may or may not have interface variables, and are declared from from 0 -> num_ssbos; no dynamic indexing yet
|
2021-12-31 01:51:41 +00:00
|
|
|
|
* Images are *not* lowered, so that dynamic indexing can deterministically get a base binding via the deref chain
|
|
|
|
|
* No immediate constant buffer, or scratch
|
2021-12-28 21:13:03 +00:00
|
|
|
|
*/
|
|
|
|
|
DXIL_ENVIRONMENT_GL,
|
|
|
|
|
/* In the CL environment:
|
|
|
|
|
* Shader kind is always KERNEL
|
|
|
|
|
* All resources use binding for identification
|
|
|
|
|
* Samplers/textures/images are lowered; dynamic indexing not supported by spec
|
|
|
|
|
* UBOs are arrays of uints in the NIR
|
|
|
|
|
* SSBOs are implicitly declared via num_kernel_globals
|
|
|
|
|
* Variables of shader_temp are used to declare an immediate constant buffer, with load_ptr_dxil intrinsics to access it
|
|
|
|
|
* Scratch is supported and lowered to DXIL-specific intrinsics for scalar 32-bit access
|
|
|
|
|
*/
|
|
|
|
|
DXIL_ENVIRONMENT_CL,
|
|
|
|
|
/* In the Vulkan environment:
|
|
|
|
|
* All resources use binding / descriptor_set for identification
|
|
|
|
|
* Samplers/textures/images are not lowered
|
|
|
|
|
* Deref chains are walked to emit the DXIL handle to the resource; dynamic indexing supported
|
|
|
|
|
* UBOs/SSBOs are struct variables in the NIR, accessed via vulkan_resource_index/load_vulkan_descriptor; dynamic indexing supported
|
|
|
|
|
* Read-only SSBOs, as declared in the SPIR-V, are bound as raw buffer SRVs instead of UAVs
|
|
|
|
|
* No immediate constant buffer or scratch
|
|
|
|
|
*/
|
|
|
|
|
DXIL_ENVIRONMENT_VULKAN,
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-04 10:51:29 +01:00
|
|
|
|
struct nir_to_dxil_options {
|
|
|
|
|
bool interpolate_at_vertex;
|
|
|
|
|
bool lower_int16;
|
|
|
|
|
bool disable_math_refactoring;
|
|
|
|
|
unsigned ubo_binding_offset;
|
|
|
|
|
unsigned provoking_vertex;
|
2020-11-06 16:09:30 +00:00
|
|
|
|
unsigned num_kernel_globals;
|
2021-12-28 21:13:03 +00:00
|
|
|
|
enum dxil_environment environment;
|
2019-09-04 10:51:29 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts,
|
|
|
|
|
struct blob *blob);
|
|
|
|
|
|
|
|
|
|
const nir_shader_compiler_options*
|
|
|
|
|
dxil_get_nir_compiler_options(void);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|