mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
microsoft/spirv_to_dxil: Allow dumping NIR
Dumping NIR shaders is a useful debug feature. Let's tweak the spirv_to_nir() helper so we can pass debugging options and add one to allow dumping NIR. 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/14765>
This commit is contained in:
parent
27790c4a7a
commit
225867684a
3 changed files with 14 additions and 1 deletions
|
|
@ -135,11 +135,15 @@ main(int argc, char **argv)
|
|||
conf.runtime_data_cbv.register_space = 31;
|
||||
conf.zero_based_vertex_instance_id = true;
|
||||
|
||||
struct dxil_spirv_debug_options dbg_opts = {
|
||||
.dump_nir = false,
|
||||
};
|
||||
|
||||
struct dxil_spirv_object obj;
|
||||
memset(&obj, 0, sizeof(obj));
|
||||
if (spirv_to_dxil((uint32_t *)file_contents, word_count, NULL, 0,
|
||||
(dxil_spirv_shader_stage)shader_stage, entry_point,
|
||||
&conf, &obj)) {
|
||||
&dbg_opts, &conf, &obj)) {
|
||||
|
||||
if (validate && !validate_dxil(&obj)) {
|
||||
fprintf(stderr, "Failed to validate DXIL\n");
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
|
|||
struct dxil_spirv_specialization *specializations,
|
||||
unsigned int num_specializations, dxil_spirv_shader_stage stage,
|
||||
const char *entry_point_name,
|
||||
const struct dxil_spirv_debug_options *dgb_opts,
|
||||
const struct dxil_spirv_runtime_conf *conf,
|
||||
struct dxil_spirv_object *out_dxil)
|
||||
{
|
||||
|
|
@ -319,6 +320,9 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
|
|||
|
||||
struct nir_to_dxil_options opts = {.environment = DXIL_ENVIRONMENT_VULKAN};
|
||||
|
||||
if (dgb_opts->dump_nir)
|
||||
nir_print_shader(nir, stderr);
|
||||
|
||||
struct blob dxil_blob;
|
||||
if (!nir_to_dxil(nir, &opts, &dxil_blob)) {
|
||||
if (dxil_blob.allocated)
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ struct dxil_spirv_runtime_conf {
|
|||
bool zero_based_vertex_instance_id;
|
||||
};
|
||||
|
||||
struct dxil_spirv_debug_options {
|
||||
bool dump_nir;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile a SPIR-V module into DXIL.
|
||||
* \param words SPIR-V module to compile
|
||||
|
|
@ -126,6 +130,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
|
|||
struct dxil_spirv_specialization *specializations,
|
||||
unsigned int num_specializations, dxil_spirv_shader_stage stage,
|
||||
const char *entry_point_name,
|
||||
const struct dxil_spirv_debug_options *debug_options,
|
||||
const struct dxil_spirv_runtime_conf *conf,
|
||||
struct dxil_spirv_object *out_dxil);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue