vkd3d-shader: Pass compile options as an array instead of as flags.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet
2020-06-19 16:13:35 +04:30
committed by Alexandre Julliard
parent 9312979b56
commit b07c304440
7 changed files with 89 additions and 26 deletions

View File

@@ -2062,7 +2062,7 @@ struct vkd3d_dxbc_compiler
{
struct vkd3d_spirv_builder spirv_builder;
uint32_t options;
bool strip_debug;
struct rb_tree symbol_table;
uint32_t temp_id;
@@ -2123,8 +2123,7 @@ static bool is_control_point_phase(const struct vkd3d_shader_phase *phase)
static void vkd3d_dxbc_compiler_emit_initial_declarations(struct vkd3d_dxbc_compiler *compiler);
struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version,
const struct vkd3d_shader_desc *shader_desc, uint32_t compiler_options,
const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_scan_info *scan_info)
{
const struct vkd3d_shader_signature *patch_constant_signature = &shader_desc->patch_constant_signature;
@@ -2164,7 +2163,22 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
}
vkd3d_spirv_builder_init(&compiler->spirv_builder);
compiler->options = compiler_options;
for (i = 0; i < compile_info->option_count; ++i)
{
const struct vkd3d_shader_compile_option *option = &compile_info->options[i];
switch (option->name)
{
case VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG:
compiler->strip_debug = !!option->value;
break;
default:
WARN("Ignoring unrecognised option %#x with value %#x.\n", option->name, option->value);
break;
}
}
rb_init(&compiler->symbol_table, vkd3d_symbol_compare);
@@ -8723,7 +8737,7 @@ int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
vkd3d_dxbc_compiler_emit_shader_epilogue_function(compiler);
}
if (compiler->options & VKD3D_SHADER_STRIP_DEBUG)
if (compiler->strip_debug)
vkd3d_spirv_stream_clear(&builder->debug_stream);
if (!vkd3d_spirv_compile_module(builder, spirv))

View File

@@ -103,8 +103,7 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
free_shader_desc(&parser->shader_desc);
}
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *spirv, unsigned int compiler_options)
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv)
{
struct vkd3d_shader_instruction instruction;
struct vkd3d_dxbc_compiler *spirv_compiler;
@@ -112,8 +111,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_in
struct vkd3d_shader_parser parser;
int ret;
TRACE("compile_info %p, spirv %p, compiler_options %#x.\n",
compile_info, spirv, compiler_options);
TRACE("compile_info %p, spirv %p.\n", compile_info, spirv);
if (compile_info->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO)
{
@@ -135,7 +133,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_compile_info *compile_in
vkd3d_shader_trace(parser.data);
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version,
&parser.shader_desc, compiler_options, compile_info, &scan_info)))
&parser.shader_desc, compile_info, &scan_info)))
{
ERR("Failed to create DXBC compiler.\n");
vkd3d_shader_parser_destroy(&parser);

View File

@@ -820,8 +820,7 @@ int shader_parse_input_signature(const void *dxbc, size_t dxbc_length,
struct vkd3d_dxbc_compiler;
struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version,
const struct vkd3d_shader_desc *shader_desc, uint32_t compiler_options,
const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN;
int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;