mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader: Represent descriptor information in the vsir program.
This commit is contained in:
parent
4308fa3f68
commit
2377db33db
Notes:
Henri Verbeet
2025-03-18 16:04:30 +01:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Elizabeth Figura (@zfigura) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1430
@ -64,7 +64,6 @@ struct vkd3d_glsl_generator
|
|||||||
|
|
||||||
const struct vkd3d_shader_interface_info *interface_info;
|
const struct vkd3d_shader_interface_info *interface_info;
|
||||||
const struct vkd3d_shader_descriptor_offset_info *offset_info;
|
const struct vkd3d_shader_descriptor_offset_info *offset_info;
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info;
|
|
||||||
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
|
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -130,7 +129,7 @@ static const struct glsl_resource_type_info *shader_glsl_get_resource_type_info(
|
|||||||
static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor(struct vkd3d_glsl_generator *gen,
|
static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor(struct vkd3d_glsl_generator *gen,
|
||||||
enum vkd3d_shader_descriptor_type type, unsigned int idx, unsigned int space)
|
enum vkd3d_shader_descriptor_type type, unsigned int idx, unsigned int space)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *info = &gen->program->descriptors;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < info->descriptor_count; ++i)
|
for (unsigned int i = 0; i < info->descriptor_count; ++i)
|
||||||
{
|
{
|
||||||
@ -146,7 +145,7 @@ static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor(st
|
|||||||
static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor_by_id(
|
static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor_by_id(
|
||||||
struct vkd3d_glsl_generator *gen, enum vkd3d_shader_descriptor_type type, unsigned int id)
|
struct vkd3d_glsl_generator *gen, enum vkd3d_shader_descriptor_type type, unsigned int id)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *info = &gen->program->descriptors;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < info->descriptor_count; ++i)
|
for (unsigned int i = 0; i < info->descriptor_count; ++i)
|
||||||
{
|
{
|
||||||
@ -2080,7 +2079,7 @@ static void shader_glsl_generate_sampler_declaration(struct vkd3d_glsl_generator
|
|||||||
static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_generator *gen)
|
static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_generator *gen)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_scan_combined_resource_sampler_info *sampler_info = gen->combined_sampler_info;
|
const struct vkd3d_shader_scan_combined_resource_sampler_info *sampler_info = gen->combined_sampler_info;
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *info = &gen->program->descriptors;
|
||||||
const struct vkd3d_shader_descriptor_info1 *descriptor;
|
const struct vkd3d_shader_descriptor_info1 *descriptor;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -2431,7 +2430,6 @@ static void shader_glsl_init_limits(struct vkd3d_glsl_generator *gen, const stru
|
|||||||
|
|
||||||
static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
||||||
struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
||||||
struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
@ -2455,12 +2453,10 @@ static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
|||||||
|
|
||||||
gen->interface_info = vkd3d_find_struct(compile_info->next, INTERFACE_INFO);
|
gen->interface_info = vkd3d_find_struct(compile_info->next, INTERFACE_INFO);
|
||||||
gen->offset_info = vkd3d_find_struct(compile_info->next, DESCRIPTOR_OFFSET_INFO);
|
gen->offset_info = vkd3d_find_struct(compile_info->next, DESCRIPTOR_OFFSET_INFO);
|
||||||
gen->descriptor_info = descriptor_info;
|
|
||||||
gen->combined_sampler_info = combined_sampler_info;
|
gen->combined_sampler_info = combined_sampler_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||||
@ -2474,7 +2470,7 @@ int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
||||||
|
|
||||||
vkd3d_glsl_generator_init(&generator, program, compile_info,
|
vkd3d_glsl_generator_init(&generator, program, compile_info,
|
||||||
descriptor_info, combined_sampler_info, message_context);
|
combined_sampler_info, message_context);
|
||||||
ret = vkd3d_glsl_generator_generate(&generator, out);
|
ret = vkd3d_glsl_generator_generate(&generator, out);
|
||||||
vkd3d_glsl_generator_cleanup(&generator);
|
vkd3d_glsl_generator_cleanup(&generator);
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ void vsir_program_cleanup(struct vsir_program *program)
|
|||||||
shader_signature_cleanup(&program->input_signature);
|
shader_signature_cleanup(&program->input_signature);
|
||||||
shader_signature_cleanup(&program->output_signature);
|
shader_signature_cleanup(&program->output_signature);
|
||||||
shader_signature_cleanup(&program->patch_constant_signature);
|
shader_signature_cleanup(&program->patch_constant_signature);
|
||||||
|
vkd3d_shader_free_scan_descriptor_info1(&program->descriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct vkd3d_shader_parameter1 *vsir_program_get_parameter(
|
const struct vkd3d_shader_parameter1 *vsir_program_get_parameter(
|
||||||
|
@ -44,7 +44,6 @@ struct msl_generator
|
|||||||
bool write_depth;
|
bool write_depth;
|
||||||
|
|
||||||
const struct vkd3d_shader_interface_info *interface_info;
|
const struct vkd3d_shader_interface_info *interface_info;
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void VKD3D_PRINTF_FUNC(3, 4) msl_compiler_error(struct msl_generator *gen,
|
static void VKD3D_PRINTF_FUNC(3, 4) msl_compiler_error(struct msl_generator *gen,
|
||||||
@ -821,7 +820,7 @@ static void msl_generate_cbv_declaration(struct msl_generator *gen,
|
|||||||
|
|
||||||
static void msl_generate_descriptor_struct_declarations(struct msl_generator *gen)
|
static void msl_generate_descriptor_struct_declarations(struct msl_generator *gen)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *info = &gen->program->descriptors;
|
||||||
const struct vkd3d_shader_descriptor_info1 *descriptor;
|
const struct vkd3d_shader_descriptor_info1 *descriptor;
|
||||||
struct vkd3d_string_buffer *buffer = gen->buffer;
|
struct vkd3d_string_buffer *buffer = gen->buffer;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -1171,7 +1170,7 @@ static void msl_generate_entrypoint(struct msl_generator *gen)
|
|||||||
|
|
||||||
vkd3d_string_buffer_printf(gen->buffer, "vkd3d_%s_out shader_entry(\n", gen->prefix);
|
vkd3d_string_buffer_printf(gen->buffer, "vkd3d_%s_out shader_entry(\n", gen->prefix);
|
||||||
|
|
||||||
if (gen->descriptor_info->descriptor_count)
|
if (gen->program->descriptors.descriptor_count)
|
||||||
{
|
{
|
||||||
msl_print_indent(gen->buffer, 2);
|
msl_print_indent(gen->buffer, 2);
|
||||||
/* TODO: Configurable argument buffer binding location. */
|
/* TODO: Configurable argument buffer binding location. */
|
||||||
@ -1195,7 +1194,7 @@ static void msl_generate_entrypoint(struct msl_generator *gen)
|
|||||||
vkd3d_string_buffer_printf(gen->buffer, " %s_main(%s_in, %s_out", gen->prefix, gen->prefix, gen->prefix);
|
vkd3d_string_buffer_printf(gen->buffer, " %s_main(%s_in, %s_out", gen->prefix, gen->prefix, gen->prefix);
|
||||||
if (gen->write_depth)
|
if (gen->write_depth)
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ", shader_out_depth");
|
vkd3d_string_buffer_printf(gen->buffer, ", shader_out_depth");
|
||||||
if (gen->descriptor_info->descriptor_count)
|
if (gen->program->descriptors.descriptor_count)
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ", descriptors");
|
vkd3d_string_buffer_printf(gen->buffer, ", descriptors");
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ");\n");
|
vkd3d_string_buffer_printf(gen->buffer, ");\n");
|
||||||
|
|
||||||
@ -1234,7 +1233,7 @@ static int msl_generator_generate(struct msl_generator *gen, struct vkd3d_shader
|
|||||||
gen->prefix);
|
gen->prefix);
|
||||||
if (gen->write_depth)
|
if (gen->write_depth)
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ", thread float& o_depth");
|
vkd3d_string_buffer_printf(gen->buffer, ", thread float& o_depth");
|
||||||
if (gen->descriptor_info->descriptor_count)
|
if (gen->program->descriptors.descriptor_count)
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ", constant vkd3d_%s_descriptors& descriptors", gen->prefix);
|
vkd3d_string_buffer_printf(gen->buffer, ", constant vkd3d_%s_descriptors& descriptors", gen->prefix);
|
||||||
vkd3d_string_buffer_printf(gen->buffer, ")\n{\n");
|
vkd3d_string_buffer_printf(gen->buffer, ")\n{\n");
|
||||||
|
|
||||||
@ -1276,7 +1275,6 @@ static void msl_generator_cleanup(struct msl_generator *gen)
|
|||||||
|
|
||||||
static int msl_generator_init(struct msl_generator *gen, struct vsir_program *program,
|
static int msl_generator_init(struct msl_generator *gen, struct vsir_program *program,
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
enum vkd3d_shader_type type = program->shader_version.type;
|
enum vkd3d_shader_type type = program->shader_version.type;
|
||||||
@ -1297,13 +1295,11 @@ static int msl_generator_init(struct msl_generator *gen, struct vsir_program *pr
|
|||||||
return VKD3D_ERROR_INVALID_SHADER;
|
return VKD3D_ERROR_INVALID_SHADER;
|
||||||
}
|
}
|
||||||
gen->interface_info = vkd3d_find_struct(compile_info->next, INTERFACE_INFO);
|
gen->interface_info = vkd3d_find_struct(compile_info->next, INTERFACE_INFO);
|
||||||
gen->descriptor_info = descriptor_info;
|
|
||||||
|
|
||||||
return VKD3D_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||||
struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
@ -1315,7 +1311,7 @@ int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
|
|
||||||
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
||||||
|
|
||||||
if ((ret = msl_generator_init(&generator, program, compile_info, descriptor_info, message_context)) < 0)
|
if ((ret = msl_generator_init(&generator, program, compile_info, message_context)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = msl_generator_generate(&generator, out);
|
ret = msl_generator_generate(&generator, out);
|
||||||
msl_generator_cleanup(&generator);
|
msl_generator_cleanup(&generator);
|
||||||
|
@ -3105,7 +3105,6 @@ struct spirv_compiler
|
|||||||
|
|
||||||
uint32_t binding_idx;
|
uint32_t binding_idx;
|
||||||
|
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info;
|
|
||||||
unsigned int input_control_point_count;
|
unsigned int input_control_point_count;
|
||||||
unsigned int output_control_point_count;
|
unsigned int output_control_point_count;
|
||||||
|
|
||||||
@ -3191,7 +3190,6 @@ static void spirv_compiler_destroy(struct spirv_compiler *compiler)
|
|||||||
|
|
||||||
static struct spirv_compiler *spirv_compiler_create(const struct vsir_program *program,
|
static struct spirv_compiler *spirv_compiler_create(const struct vsir_program *program,
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info,
|
|
||||||
struct vkd3d_shader_message_context *message_context, uint64_t config_flags)
|
struct vkd3d_shader_message_context *message_context, uint64_t config_flags)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_interface_info *shader_interface;
|
const struct vkd3d_shader_interface_info *shader_interface;
|
||||||
@ -3334,8 +3332,6 @@ static struct spirv_compiler *spirv_compiler_create(const struct vsir_program *p
|
|||||||
else if (compiler->shader_type != VKD3D_SHADER_TYPE_GEOMETRY)
|
else if (compiler->shader_type != VKD3D_SHADER_TYPE_GEOMETRY)
|
||||||
compiler->emit_point_size = compiler->xfb_info && compiler->xfb_info->element_count;
|
compiler->emit_point_size = compiler->xfb_info && compiler->xfb_info->element_count;
|
||||||
|
|
||||||
compiler->scan_descriptor_info = scan_descriptor_info;
|
|
||||||
|
|
||||||
compiler->phase = VKD3DSIH_INVALID;
|
compiler->phase = VKD3DSIH_INVALID;
|
||||||
|
|
||||||
vkd3d_string_buffer_cache_init(&compiler->string_buffers);
|
vkd3d_string_buffer_cache_init(&compiler->string_buffers);
|
||||||
@ -6732,7 +6728,7 @@ static const struct vkd3d_shader_descriptor_info1 *spirv_compiler_get_descriptor
|
|||||||
struct spirv_compiler *compiler, enum vkd3d_shader_descriptor_type type,
|
struct spirv_compiler *compiler, enum vkd3d_shader_descriptor_type type,
|
||||||
const struct vkd3d_shader_register_range *range)
|
const struct vkd3d_shader_register_range *range)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info = compiler->scan_descriptor_info;
|
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info = &compiler->program->descriptors;
|
||||||
unsigned int register_last = (range->last == ~0u) ? range->first : range->last;
|
unsigned int register_last = (range->last == ~0u) ? range->first : range->last;
|
||||||
const struct vkd3d_shader_descriptor_info1 *d;
|
const struct vkd3d_shader_descriptor_info1 *d;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -11159,11 +11155,12 @@ static void spirv_compiler_emit_io_declarations(struct spirv_compiler *compiler)
|
|||||||
|
|
||||||
static void spirv_compiler_emit_descriptor_declarations(struct spirv_compiler *compiler)
|
static void spirv_compiler_emit_descriptor_declarations(struct spirv_compiler *compiler)
|
||||||
{
|
{
|
||||||
|
const struct vkd3d_shader_scan_descriptor_info1 *descriptors = &compiler->program->descriptors;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < compiler->scan_descriptor_info->descriptor_count; ++i)
|
for (i = 0; i < descriptors->descriptor_count; ++i)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_descriptor_info1 *descriptor = &compiler->scan_descriptor_info->descriptors[i];
|
const struct vkd3d_shader_descriptor_info1 *descriptor = &descriptors->descriptors[i];
|
||||||
struct vkd3d_shader_register_range range;
|
struct vkd3d_shader_register_range range;
|
||||||
|
|
||||||
range.first = descriptor->register_index;
|
range.first = descriptor->register_index;
|
||||||
@ -11354,7 +11351,6 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info,
|
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
@ -11367,7 +11363,7 @@ int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
VKD3D_ASSERT(program->normalisation_level == VSIR_NORMALISED_SM6);
|
||||||
|
|
||||||
if (!(spirv_compiler = spirv_compiler_create(program, compile_info,
|
if (!(spirv_compiler = spirv_compiler_create(program, compile_info,
|
||||||
scan_descriptor_info, message_context, config_flags)))
|
message_context, config_flags)))
|
||||||
{
|
{
|
||||||
ERR("Failed to create SPIR-V compiler.\n");
|
ERR("Failed to create SPIR-V compiler.\n");
|
||||||
return VKD3D_ERROR;
|
return VKD3D_ERROR;
|
||||||
|
@ -1569,7 +1569,7 @@ static enum vkd3d_result convert_descriptor_info(struct vkd3d_shader_scan_descri
|
|||||||
return VKD3D_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info)
|
void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info)
|
||||||
{
|
{
|
||||||
TRACE("scan_descriptor_info %p.\n", scan_descriptor_info);
|
TRACE("scan_descriptor_info %p.\n", scan_descriptor_info);
|
||||||
|
|
||||||
@ -1577,12 +1577,10 @@ static void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_des
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_message_context *message_context,
|
struct vkd3d_shader_message_context *message_context, bool add_descriptor_info)
|
||||||
struct vkd3d_shader_scan_descriptor_info1 *descriptor_info1)
|
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
|
struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
|
||||||
struct vkd3d_shader_scan_hull_shader_tessellation_info *tessellation_info;
|
struct vkd3d_shader_scan_hull_shader_tessellation_info *tessellation_info;
|
||||||
struct vkd3d_shader_scan_descriptor_info1 local_descriptor_info1 = {0};
|
|
||||||
struct vkd3d_shader_scan_descriptor_info *descriptor_info;
|
struct vkd3d_shader_scan_descriptor_info *descriptor_info;
|
||||||
struct vkd3d_shader_scan_signature_info *signature_info;
|
struct vkd3d_shader_scan_signature_info *signature_info;
|
||||||
struct vkd3d_shader_instruction *instruction;
|
struct vkd3d_shader_instruction *instruction;
|
||||||
@ -1591,29 +1589,22 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
descriptor_info = vkd3d_find_struct(compile_info->next, SCAN_DESCRIPTOR_INFO);
|
descriptor_info = vkd3d_find_struct(compile_info->next, SCAN_DESCRIPTOR_INFO);
|
||||||
if (descriptor_info1)
|
if (descriptor_info)
|
||||||
{
|
add_descriptor_info = true;
|
||||||
descriptor_info1->descriptors = NULL;
|
|
||||||
descriptor_info1->descriptor_count = 0;
|
|
||||||
}
|
|
||||||
else if (descriptor_info)
|
|
||||||
{
|
|
||||||
descriptor_info1 = &local_descriptor_info1;
|
|
||||||
}
|
|
||||||
signature_info = vkd3d_find_struct(compile_info->next, SCAN_SIGNATURE_INFO);
|
signature_info = vkd3d_find_struct(compile_info->next, SCAN_SIGNATURE_INFO);
|
||||||
|
|
||||||
if ((combined_sampler_info = vkd3d_find_struct(compile_info->next, SCAN_COMBINED_RESOURCE_SAMPLER_INFO)))
|
if ((combined_sampler_info = vkd3d_find_struct(compile_info->next, SCAN_COMBINED_RESOURCE_SAMPLER_INFO)))
|
||||||
{
|
{
|
||||||
combined_sampler_info->combined_samplers = NULL;
|
combined_sampler_info->combined_samplers = NULL;
|
||||||
combined_sampler_info->combined_sampler_count = 0;
|
combined_sampler_info->combined_sampler_count = 0;
|
||||||
if (!descriptor_info1)
|
add_descriptor_info = true;
|
||||||
descriptor_info1 = &local_descriptor_info1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellation_info = vkd3d_find_struct(compile_info->next, SCAN_HULL_SHADER_TESSELLATION_INFO);
|
tessellation_info = vkd3d_find_struct(compile_info->next, SCAN_HULL_SHADER_TESSELLATION_INFO);
|
||||||
|
|
||||||
vkd3d_shader_scan_context_init(&context, &program->shader_version, compile_info,
|
vkd3d_shader_scan_context_init(&context, &program->shader_version, compile_info,
|
||||||
descriptor_info1, combined_sampler_info, message_context);
|
add_descriptor_info ? &program->descriptors : NULL, combined_sampler_info, message_context);
|
||||||
|
|
||||||
if (TRACE_ON())
|
if (TRACE_ON())
|
||||||
vsir_program_trace(program);
|
vsir_program_trace(program);
|
||||||
@ -1653,7 +1644,7 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ret && descriptor_info)
|
if (!ret && descriptor_info)
|
||||||
ret = convert_descriptor_info(descriptor_info, descriptor_info1);
|
ret = convert_descriptor_info(descriptor_info, &program->descriptors);
|
||||||
|
|
||||||
if (!ret && tessellation_info)
|
if (!ret && tessellation_info)
|
||||||
{
|
{
|
||||||
@ -1667,15 +1658,10 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh
|
|||||||
vkd3d_shader_free_scan_combined_resource_sampler_info(combined_sampler_info);
|
vkd3d_shader_free_scan_combined_resource_sampler_info(combined_sampler_info);
|
||||||
if (descriptor_info)
|
if (descriptor_info)
|
||||||
vkd3d_shader_free_scan_descriptor_info(descriptor_info);
|
vkd3d_shader_free_scan_descriptor_info(descriptor_info);
|
||||||
if (descriptor_info1)
|
|
||||||
vkd3d_shader_free_scan_descriptor_info1(descriptor_info1);
|
|
||||||
if (signature_info)
|
if (signature_info)
|
||||||
vkd3d_shader_free_scan_signature_info(signature_info);
|
vkd3d_shader_free_scan_signature_info(signature_info);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
vkd3d_shader_free_scan_descriptor_info1(&local_descriptor_info1);
|
|
||||||
}
|
|
||||||
vkd3d_shader_scan_context_cleanup(&context);
|
vkd3d_shader_scan_context_cleanup(&context);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1713,7 +1699,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char
|
|||||||
|
|
||||||
if (!(ret = vsir_parse(compile_info, config_flags, &message_context, &program)))
|
if (!(ret = vsir_parse(compile_info, config_flags, &message_context, &program)))
|
||||||
{
|
{
|
||||||
ret = vsir_program_scan(&program, compile_info, &message_context, NULL);
|
ret = vsir_program_scan(&program, compile_info, &message_context, false);
|
||||||
vsir_program_cleanup(&program);
|
vsir_program_cleanup(&program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1730,7 +1716,6 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_scan_combined_resource_sampler_info combined_sampler_info;
|
struct vkd3d_shader_scan_combined_resource_sampler_info combined_sampler_info;
|
||||||
struct vkd3d_shader_scan_descriptor_info1 scan_descriptor_info;
|
|
||||||
struct vkd3d_shader_compile_info scan_info;
|
struct vkd3d_shader_compile_info scan_info;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1746,28 +1731,24 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
combined_sampler_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO;
|
combined_sampler_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO;
|
||||||
combined_sampler_info.next = scan_info.next;
|
combined_sampler_info.next = scan_info.next;
|
||||||
scan_info.next = &combined_sampler_info;
|
scan_info.next = &combined_sampler_info;
|
||||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
if ((ret = vsir_program_scan(program, &scan_info, message_context, true)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = glsl_compile(program, config_flags, &scan_descriptor_info,
|
ret = glsl_compile(program, config_flags,
|
||||||
&combined_sampler_info, compile_info, out, message_context);
|
&combined_sampler_info, compile_info, out, message_context);
|
||||||
vkd3d_shader_free_scan_combined_resource_sampler_info(&combined_sampler_info);
|
vkd3d_shader_free_scan_combined_resource_sampler_info(&combined_sampler_info);
|
||||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VKD3D_SHADER_TARGET_SPIRV_BINARY:
|
case VKD3D_SHADER_TARGET_SPIRV_BINARY:
|
||||||
case VKD3D_SHADER_TARGET_SPIRV_TEXT:
|
case VKD3D_SHADER_TARGET_SPIRV_TEXT:
|
||||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
if ((ret = vsir_program_scan(program, &scan_info, message_context, true)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = spirv_compile(program, config_flags, &scan_descriptor_info,
|
ret = spirv_compile(program, config_flags, compile_info, out, message_context);
|
||||||
compile_info, out, message_context);
|
|
||||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VKD3D_SHADER_TARGET_MSL:
|
case VKD3D_SHADER_TARGET_MSL:
|
||||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
if ((ret = vsir_program_scan(program, &scan_info, message_context, true)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = msl_compile(program, config_flags, &scan_descriptor_info, compile_info, out, message_context);
|
ret = msl_compile(program, config_flags, compile_info, out, message_context);
|
||||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1422,6 +1422,30 @@ enum vsir_normalisation_level
|
|||||||
VSIR_NORMALISED_SM6,
|
VSIR_NORMALISED_SM6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct vkd3d_shader_descriptor_info1
|
||||||
|
{
|
||||||
|
enum vkd3d_shader_descriptor_type type;
|
||||||
|
unsigned int register_space;
|
||||||
|
unsigned int register_index;
|
||||||
|
unsigned int register_id;
|
||||||
|
enum vkd3d_shader_resource_type resource_type;
|
||||||
|
enum vkd3d_shader_resource_data_type resource_data_type;
|
||||||
|
unsigned int flags;
|
||||||
|
unsigned int sample_count;
|
||||||
|
unsigned int buffer_size;
|
||||||
|
unsigned int structure_stride;
|
||||||
|
unsigned int count;
|
||||||
|
uint32_t uav_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct vkd3d_shader_scan_descriptor_info1
|
||||||
|
{
|
||||||
|
struct vkd3d_shader_descriptor_info1 *descriptors;
|
||||||
|
unsigned int descriptor_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
void vkd3d_shader_free_scan_descriptor_info1(struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info);
|
||||||
|
|
||||||
struct vsir_program
|
struct vsir_program
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_version shader_version;
|
struct vkd3d_shader_version shader_version;
|
||||||
@ -1431,6 +1455,8 @@ struct vsir_program
|
|||||||
struct shader_signature output_signature;
|
struct shader_signature output_signature;
|
||||||
struct shader_signature patch_constant_signature;
|
struct shader_signature patch_constant_signature;
|
||||||
|
|
||||||
|
struct vkd3d_shader_scan_descriptor_info1 descriptors;
|
||||||
|
|
||||||
unsigned int parameter_count;
|
unsigned int parameter_count;
|
||||||
const struct vkd3d_shader_parameter1 *parameters;
|
const struct vkd3d_shader_parameter1 *parameters;
|
||||||
bool free_parameters;
|
bool free_parameters;
|
||||||
@ -1508,28 +1534,6 @@ void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, struct vsir_pr
|
|||||||
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
|
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
|
||||||
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
|
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
|
||||||
|
|
||||||
struct vkd3d_shader_descriptor_info1
|
|
||||||
{
|
|
||||||
enum vkd3d_shader_descriptor_type type;
|
|
||||||
unsigned int register_space;
|
|
||||||
unsigned int register_index;
|
|
||||||
unsigned int register_id;
|
|
||||||
enum vkd3d_shader_resource_type resource_type;
|
|
||||||
enum vkd3d_shader_resource_data_type resource_data_type;
|
|
||||||
unsigned int flags;
|
|
||||||
unsigned int sample_count;
|
|
||||||
unsigned int buffer_size;
|
|
||||||
unsigned int structure_stride;
|
|
||||||
unsigned int count;
|
|
||||||
uint32_t uav_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vkd3d_shader_scan_descriptor_info1
|
|
||||||
{
|
|
||||||
struct vkd3d_shader_descriptor_info1 *descriptors;
|
|
||||||
unsigned int descriptor_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void vsir_program_trace(const struct vsir_program *program);
|
void vsir_program_trace(const struct vsir_program *program);
|
||||||
|
|
||||||
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
|
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
|
||||||
@ -1673,7 +1677,6 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
||||||
|
|
||||||
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
||||||
@ -1681,12 +1684,10 @@ int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
|||||||
#define SPIRV_MAX_SRC_COUNT 6
|
#define SPIRV_MAX_SRC_COUNT 6
|
||||||
|
|
||||||
int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *scan_descriptor_info,
|
|
||||||
const struct vkd3d_shader_compile_info *compile_info,
|
const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
||||||
|
|
||||||
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
int msl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||||
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
|
||||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||||
struct vkd3d_shader_message_context *message_context);
|
struct vkd3d_shader_message_context *message_context);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user