microsoft/clc: Support passing specialization consts to spirv_to_nir
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322>
This commit is contained in:
@@ -1040,6 +1040,7 @@ clc_spirv_to_dxil(struct clc_libclc *lib,
|
||||
const struct clc_parsed_spirv *parsed_data,
|
||||
const char *entrypoint,
|
||||
const struct clc_runtime_kernel_conf *conf,
|
||||
const struct clc_spirv_specialization_consts *consts,
|
||||
const struct clc_logger *logger,
|
||||
struct clc_dxil_object *out_dxil)
|
||||
{
|
||||
@@ -1093,7 +1094,8 @@ clc_spirv_to_dxil(struct clc_libclc *lib,
|
||||
glsl_type_singleton_init_or_ref();
|
||||
|
||||
nir = spirv_to_nir(linked_spirv->data, linked_spirv->size / 4,
|
||||
NULL, 0,
|
||||
consts ? (struct nir_spirv_specialization *)consts->specializations : NULL,
|
||||
consts ? consts->num_specializations : 0,
|
||||
MESA_SHADER_KERNEL, entrypoint,
|
||||
&spirv_options,
|
||||
&nir_options);
|
||||
|
||||
@@ -278,12 +278,37 @@ struct clc_runtime_kernel_conf {
|
||||
unsigned support_workgroup_id_offsets;
|
||||
};
|
||||
|
||||
typedef union {
|
||||
bool b;
|
||||
float f32;
|
||||
double f64;
|
||||
int8_t i8;
|
||||
uint8_t u8;
|
||||
int16_t i16;
|
||||
uint16_t u16;
|
||||
int32_t i32;
|
||||
uint32_t u32;
|
||||
int64_t i64;
|
||||
uint64_t u64;
|
||||
} clc_spirv_const_value;
|
||||
|
||||
struct clc_spirv_specialization {
|
||||
uint32_t id;
|
||||
clc_spirv_const_value value;
|
||||
bool defined_on_module;
|
||||
};
|
||||
|
||||
struct clc_spirv_specialization_consts {
|
||||
const struct clc_spirv_specialization *specializations;
|
||||
unsigned num_specializations;
|
||||
};
|
||||
bool
|
||||
clc_spirv_to_dxil(struct clc_libclc *lib,
|
||||
const struct clc_binary *linked_spirv,
|
||||
const struct clc_parsed_spirv *parsed_data,
|
||||
const char *entrypoint,
|
||||
const struct clc_runtime_kernel_conf *conf,
|
||||
const struct clc_spirv_specialization_consts *consts,
|
||||
const struct clc_logger *logger,
|
||||
struct clc_dxil_object *out_dxil);
|
||||
|
||||
|
||||
@@ -869,7 +869,7 @@ ComputeTest::configure(Shader &shader,
|
||||
clc_free_dxil_object(dxil);
|
||||
delete dxil;
|
||||
});
|
||||
if (!clc_spirv_to_dxil(compiler_ctx, shader.obj.get(), shader.metadata.get(), "main_test", conf, &logger, shader.dxil.get()))
|
||||
if (!clc_spirv_to_dxil(compiler_ctx, shader.obj.get(), shader.metadata.get(), "main_test", conf, nullptr, &logger, shader.dxil.get()))
|
||||
throw runtime_error("failed to compile kernel!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user