spirv: Convert the supported_extensions struct to spirv_options
This is a bit more general and lets us pass additional options into the spirv_to_nir pass beyond what capabilities we support. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
This commit is contained in:
@@ -196,19 +196,22 @@ radv_shader_compile_to_nir(struct radv_device *device,
|
|||||||
spec_entries[i].data32 = *(const uint32_t *)data;
|
spec_entries[i].data32 = *(const uint32_t *)data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const struct nir_spirv_supported_extensions supported_ext = {
|
const struct spirv_to_nir_options spirv_options = {
|
||||||
.draw_parameters = true,
|
.caps = {
|
||||||
.float64 = true,
|
.draw_parameters = true,
|
||||||
.image_read_without_format = true,
|
.float64 = true,
|
||||||
.image_write_without_format = true,
|
.image_read_without_format = true,
|
||||||
.tessellation = true,
|
.image_write_without_format = true,
|
||||||
.int64 = true,
|
.tessellation = true,
|
||||||
.multiview = true,
|
.int64 = true,
|
||||||
.variable_pointers = true,
|
.multiview = true,
|
||||||
|
.variable_pointers = true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
entry_point = spirv_to_nir(spirv, module->size / 4,
|
entry_point = spirv_to_nir(spirv, module->size / 4,
|
||||||
spec_entries, num_spec_entries,
|
spec_entries, num_spec_entries,
|
||||||
stage, entrypoint_name, &supported_ext, &nir_options);
|
stage, entrypoint_name,
|
||||||
|
&spirv_options, &nir_options);
|
||||||
nir = entry_point->shader;
|
nir = entry_point->shader;
|
||||||
assert(nir->info.stage == stage);
|
assert(nir->info.stage == stage);
|
||||||
nir_validate_shader(nir);
|
nir_validate_shader(nir);
|
||||||
|
@@ -42,24 +42,26 @@ struct nir_spirv_specialization {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nir_spirv_supported_extensions {
|
struct spirv_to_nir_options {
|
||||||
bool float64;
|
struct {
|
||||||
bool image_ms_array;
|
bool float64;
|
||||||
bool tessellation;
|
bool image_ms_array;
|
||||||
bool draw_parameters;
|
bool tessellation;
|
||||||
bool image_read_without_format;
|
bool draw_parameters;
|
||||||
bool image_write_without_format;
|
bool image_read_without_format;
|
||||||
bool int64;
|
bool image_write_without_format;
|
||||||
bool multiview;
|
bool int64;
|
||||||
bool variable_pointers;
|
bool multiview;
|
||||||
|
bool variable_pointers;
|
||||||
|
} caps;
|
||||||
};
|
};
|
||||||
|
|
||||||
nir_function *spirv_to_nir(const uint32_t *words, size_t word_count,
|
nir_function *spirv_to_nir(const uint32_t *words, size_t word_count,
|
||||||
struct nir_spirv_specialization *specializations,
|
struct nir_spirv_specialization *specializations,
|
||||||
unsigned num_specializations,
|
unsigned num_specializations,
|
||||||
gl_shader_stage stage, const char *entry_point_name,
|
gl_shader_stage stage, const char *entry_point_name,
|
||||||
const struct nir_spirv_supported_extensions *ext,
|
const struct spirv_to_nir_options *options,
|
||||||
const nir_shader_compiler_options *options);
|
const nir_shader_compiler_options *nir_options);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -2675,7 +2675,7 @@ stage_for_execution_model(SpvExecutionModel model)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define spv_check_supported(name, cap) do { \
|
#define spv_check_supported(name, cap) do { \
|
||||||
if (!(b->ext && b->ext->name)) \
|
if (!(b->options && b->options->caps.name)) \
|
||||||
vtn_warn("Unsupported SPIR-V capability: %s", \
|
vtn_warn("Unsupported SPIR-V capability: %s", \
|
||||||
spirv_capability_to_string(cap)); \
|
spirv_capability_to_string(cap)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
@@ -3316,8 +3316,8 @@ nir_function *
|
|||||||
spirv_to_nir(const uint32_t *words, size_t word_count,
|
spirv_to_nir(const uint32_t *words, size_t word_count,
|
||||||
struct nir_spirv_specialization *spec, unsigned num_spec,
|
struct nir_spirv_specialization *spec, unsigned num_spec,
|
||||||
gl_shader_stage stage, const char *entry_point_name,
|
gl_shader_stage stage, const char *entry_point_name,
|
||||||
const struct nir_spirv_supported_extensions *ext,
|
const struct spirv_to_nir_options *options,
|
||||||
const nir_shader_compiler_options *options)
|
const nir_shader_compiler_options *nir_options)
|
||||||
{
|
{
|
||||||
const uint32_t *word_end = words + word_count;
|
const uint32_t *word_end = words + word_count;
|
||||||
|
|
||||||
@@ -3339,7 +3339,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
exec_list_make_empty(&b->functions);
|
exec_list_make_empty(&b->functions);
|
||||||
b->entry_point_stage = stage;
|
b->entry_point_stage = stage;
|
||||||
b->entry_point_name = entry_point_name;
|
b->entry_point_name = entry_point_name;
|
||||||
b->ext = ext;
|
b->options = options;
|
||||||
|
|
||||||
/* Handle all the preamble instructions */
|
/* Handle all the preamble instructions */
|
||||||
words = vtn_foreach_instruction(b, words, word_end,
|
words = vtn_foreach_instruction(b, words, word_end,
|
||||||
@@ -3351,7 +3351,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->shader = nir_shader_create(NULL, stage, options, NULL);
|
b->shader = nir_shader_create(NULL, stage, nir_options, NULL);
|
||||||
|
|
||||||
/* Set shader info defaults */
|
/* Set shader info defaults */
|
||||||
b->shader->info.gs.invocations = 1;
|
b->shader->info.gs.invocations = 1;
|
||||||
|
@@ -467,7 +467,7 @@ struct vtn_builder {
|
|||||||
nir_builder nb;
|
nir_builder nb;
|
||||||
|
|
||||||
nir_shader *shader;
|
nir_shader *shader;
|
||||||
const struct nir_spirv_supported_extensions *ext;
|
const struct spirv_to_nir_options *options;
|
||||||
struct vtn_block *block;
|
struct vtn_block *block;
|
||||||
|
|
||||||
/* Current file, line, and column. Useful for debugging. Set
|
/* Current file, line, and column. Useful for debugging. Set
|
||||||
|
@@ -132,20 +132,22 @@ anv_shader_compile_to_nir(struct anv_pipeline *pipeline,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct nir_spirv_supported_extensions supported_ext = {
|
struct spirv_to_nir_options spirv_options = {
|
||||||
.float64 = device->instance->physicalDevice.info.gen >= 8,
|
.caps = {
|
||||||
.int64 = device->instance->physicalDevice.info.gen >= 8,
|
.float64 = device->instance->physicalDevice.info.gen >= 8,
|
||||||
.tessellation = true,
|
.int64 = device->instance->physicalDevice.info.gen >= 8,
|
||||||
.draw_parameters = true,
|
.tessellation = true,
|
||||||
.image_write_without_format = true,
|
.draw_parameters = true,
|
||||||
.multiview = true,
|
.image_write_without_format = true,
|
||||||
.variable_pointers = true,
|
.multiview = true,
|
||||||
|
.variable_pointers = true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
nir_function *entry_point =
|
nir_function *entry_point =
|
||||||
spirv_to_nir(spirv, module->size / 4,
|
spirv_to_nir(spirv, module->size / 4,
|
||||||
spec_entries, num_spec_entries,
|
spec_entries, num_spec_entries,
|
||||||
stage, entrypoint_name, &supported_ext, nir_options);
|
stage, entrypoint_name, &spirv_options, nir_options);
|
||||||
nir_shader *nir = entry_point->shader;
|
nir_shader *nir = entry_point->shader;
|
||||||
assert(nir->info.stage == stage);
|
assert(nir->info.stage == stage);
|
||||||
nir_validate_shader(nir);
|
nir_validate_shader(nir);
|
||||||
|
Reference in New Issue
Block a user