Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- include/vkd3d_shader.h | 10 +++---- libs/vkd3d-shader/spirv.c | 48 ++++++++++++++++---------------- libs/vkd3d-shader/vkd3d_shader_main.c | 22 +++++++-------- libs/vkd3d-shader/vkd3d_shader_private.h | 2 +- libs/vkd3d/state.c | 38 ++++++++++++------------- 5 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 67d4562..2b07906 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -31,8 +31,8 @@ enum vkd3d_shader_structure_type { /* 1.2 */ VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE_INFO, - VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS, VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO, + VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO, VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO, VKD3D_SHADER_STRUCTURE_TYPE_DOMAIN_SHADER_COMPILE_ARGUMENTS,
@@ -234,7 +234,7 @@ enum vkd3d_shader_target_extension VKD3D_SHADER_TARGET_EXTENSION_SPV_EXT_DEMOTE_TO_HELPER_INVOCATION, };
-struct vkd3d_shader_compile_arguments +struct vkd3d_shader_spirv_target_info { enum vkd3d_shader_structure_type type; const void *next; @@ -268,7 +268,7 @@ enum vkd3d_tessellator_partitioning VKD3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4, };
-/* Extends vkd3d_shader_compile_arguments. */ +/* Extends vkd3d_shader_spirv_target_info. */ struct vkd3d_shader_domain_shader_compile_arguments { enum vkd3d_shader_structure_type type; @@ -635,7 +635,7 @@ struct vkd3d_shader_signature int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, - const struct vkd3d_shader_compile_arguments *compile_args); + const struct vkd3d_shader_spirv_target_info *target_info); void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, @@ -667,7 +667,7 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature typedef int (*PFN_vkd3d_shader_compile_dxbc)(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, - const struct vkd3d_shader_compile_arguments *compile_args); + const struct vkd3d_shader_spirv_target_info *target_info); typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code);
typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc, diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 5a37b8f..31dcc4f 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2078,7 +2078,7 @@ struct vkd3d_dxbc_compiler
struct vkd3d_shader_interface_info shader_interface; struct vkd3d_push_constant_buffer_binding *push_constants; - const struct vkd3d_shader_compile_arguments *compile_args; + const struct vkd3d_shader_spirv_target_info *spirv_target_info;
bool after_declarations_section; const struct vkd3d_shader_signature *input_signature; @@ -2122,7 +2122,7 @@ static void vkd3d_dxbc_compiler_emit_initial_declarations(struct vkd3d_dxbc_comp 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_interface_info *shader_interface, - const struct vkd3d_shader_compile_arguments *compile_args, + const struct vkd3d_shader_spirv_target_info *target_info, const struct vkd3d_shader_scan_info *scan_info) { const struct vkd3d_shader_signature *patch_constant_signature = &shader_desc->patch_constant_signature; @@ -2171,7 +2171,7 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader compiler->push_constants[i].pc = shader_interface->push_constant_buffers[i]; } } - compiler->compile_args = compile_args; + compiler->spirv_target_info = target_info;
compiler->scan_info = scan_info;
@@ -2182,8 +2182,9 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
static enum vkd3d_shader_target vkd3d_dxbc_compiler_get_target(const struct vkd3d_dxbc_compiler *compiler) { - const struct vkd3d_shader_compile_arguments *args = compiler->compile_args; - return args ? args->target : VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; + + return info ? info->target : VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0; }
static bool vkd3d_dxbc_compiler_is_opengl_target(const struct vkd3d_dxbc_compiler *compiler) @@ -2194,12 +2195,12 @@ static bool vkd3d_dxbc_compiler_is_opengl_target(const struct vkd3d_dxbc_compile static bool vkd3d_dxbc_compiler_is_target_extension_supported(const struct vkd3d_dxbc_compiler *compiler, enum vkd3d_shader_target_extension extension) { - const struct vkd3d_shader_compile_arguments *args = compiler->compile_args; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; unsigned int i;
- for (i = 0; args && i < args->target_extension_count; ++i) + for (i = 0; info && i < info->target_extension_count; ++i) { - if (args->target_extensions[i] == extension) + if (info->target_extensions[i] == extension) return true; }
@@ -2594,13 +2595,13 @@ static uint32_t vkd3d_dxbc_compiler_emit_array_variable(struct vkd3d_dxbc_compil static const struct vkd3d_shader_parameter *vkd3d_dxbc_compiler_get_shader_parameter( struct vkd3d_dxbc_compiler *compiler, enum vkd3d_shader_parameter_name name) { - const struct vkd3d_shader_compile_arguments *compile_args = compiler->compile_args; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; unsigned int i;
- for (i = 0; compile_args && i < compile_args->parameter_count; ++i) + for (i = 0; info && i < info->parameter_count; ++i) { - if (compile_args->parameters[i].name == name) - return &compile_args->parameters[i]; + if (info->parameters[i].name == name) + return &info->parameters[i]; }
return NULL; @@ -2635,12 +2636,12 @@ static uint32_t vkd3d_dxbc_compiler_alloc_spec_constant_id(struct vkd3d_dxbc_com { if (!compiler->current_spec_constant_id) { - const struct vkd3d_shader_compile_arguments *compile_args = compiler->compile_args; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; unsigned int i, id = 0;
- for (i = 0; compiler->compile_args && i < compile_args->parameter_count; ++i) + for (i = 0; info && i < info->parameter_count; ++i) { - const struct vkd3d_shader_parameter *current = &compile_args->parameters[i]; + const struct vkd3d_shader_parameter *current = &info->parameters[i];
if (current->type == VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT) id = max(current->u.specialization_constant.id + 1, id); @@ -4206,21 +4207,20 @@ static unsigned int vkd3d_dxbc_compiler_get_output_variable_index( static unsigned int get_shader_output_swizzle(const struct vkd3d_dxbc_compiler *compiler, unsigned int register_idx) { - const struct vkd3d_shader_compile_arguments *compile_args; + const struct vkd3d_shader_spirv_target_info *info;
- if (!(compile_args = compiler->compile_args)) + if (!(info = compiler->spirv_target_info)) return VKD3D_NO_SWIZZLE; - if (register_idx >= compile_args->output_swizzle_count) + if (register_idx >= info->output_swizzle_count) return VKD3D_NO_SWIZZLE; - return compile_args->output_swizzles[register_idx]; + return info->output_swizzles[register_idx]; }
static bool is_dual_source_blending(const struct vkd3d_dxbc_compiler *compiler) { - const struct vkd3d_shader_compile_arguments *compile_args = compiler->compile_args; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info;
- return compiler->shader_type == VKD3D_SHADER_TYPE_PIXEL - && compile_args && compile_args->dual_source_blending; + return compiler->shader_type == VKD3D_SHADER_TYPE_PIXEL && info && info->dual_source_blending; }
static void calculate_clip_or_cull_distance_mask(const struct vkd3d_shader_signature_element *e, @@ -8670,7 +8670,7 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_code *spirv) { - const struct vkd3d_shader_compile_arguments *compile_args = compiler->compile_args; + const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; const struct vkd3d_shader_domain_shader_compile_arguments *ds_args; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_phase *phase; @@ -8685,7 +8685,7 @@ int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
if (compiler->shader_type == VKD3D_SHADER_TYPE_DOMAIN) { - if (compile_args && (ds_args = vkd3d_find_struct(compile_args->next, DOMAIN_SHADER_COMPILE_ARGUMENTS))) + if (info && (ds_args = vkd3d_find_struct(info->next, DOMAIN_SHADER_COMPILE_ARGUMENTS))) { vkd3d_dxbc_compiler_emit_tessellator_output_primitive(compiler, ds_args->output_primitive); vkd3d_dxbc_compiler_emit_tessellator_partitioning(compiler, ds_args->partitioning); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index aa486cc..38cb2ee 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -103,24 +103,24 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser) free_shader_desc(&parser->shader_desc); }
-static int vkd3d_shader_validate_compile_args(const struct vkd3d_shader_compile_arguments *compile_args) +static int vkd3d_shader_validate_spirv_target_info(const struct vkd3d_shader_spirv_target_info *info) { - if (!compile_args) + if (!info) return VKD3D_OK;
- if (compile_args->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS) + if (info->type != VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO) { - WARN("Invalid structure type %#x.\n", compile_args->type); + WARN("Invalid structure type %#x.\n", info->type); return VKD3D_ERROR_INVALID_ARGUMENT; }
- switch (compile_args->target) + switch (info->target) { case VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5: case VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0: break; default: - WARN("Invalid shader target %#x.\n", compile_args->target); + WARN("Invalid shader target %#x.\n", info->target); return VKD3D_ERROR_INVALID_ARGUMENT; }
@@ -130,7 +130,7 @@ static int vkd3d_shader_validate_compile_args(const struct vkd3d_shader_compile_ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_code *spirv, unsigned int compiler_options, const struct vkd3d_shader_interface_info *shader_interface_info, - const struct vkd3d_shader_compile_arguments *compile_args) + const struct vkd3d_shader_spirv_target_info *info) { struct vkd3d_shader_instruction instruction; struct vkd3d_dxbc_compiler *spirv_compiler; @@ -138,8 +138,8 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_parser parser; int ret;
- TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface_info %p, compile_args %p.\n", - dxbc->code, dxbc->size, spirv, compiler_options, shader_interface_info, compile_args); + TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface_info %p, info %p.\n", + dxbc->code, dxbc->size, spirv, compiler_options, shader_interface_info, info);
if (shader_interface_info && shader_interface_info->type != VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE_INFO) { @@ -147,7 +147,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, return VKD3D_ERROR_INVALID_ARGUMENT; }
- if ((ret = vkd3d_shader_validate_compile_args(compile_args)) < 0) + if ((ret = vkd3d_shader_validate_spirv_target_info(info)) < 0) return ret;
scan_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO; @@ -164,7 +164,7 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc, vkd3d_shader_trace(parser.data);
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version, - &parser.shader_desc, compiler_options, shader_interface_info, compile_args, &scan_info))) + &parser.shader_desc, compiler_options, shader_interface_info, info, &scan_info))) { ERR("Failed to create DXBC compiler.\n"); vkd3d_shader_parser_destroy(&parser); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 97371f9..a98eda6 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -822,7 +822,7 @@ 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_interface_info *shader_interface_info, - const struct vkd3d_shader_compile_arguments *compile_args, + const struct vkd3d_shader_spirv_target_info *target_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; diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 11db8b5..3f158d0 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1327,7 +1327,7 @@ struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12Pipeline static HRESULT create_shader_stage(struct d3d12_device *device, struct VkPipelineShaderStageCreateInfo *stage_desc, enum VkShaderStageFlagBits stage, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface, - const struct vkd3d_shader_compile_arguments *compile_args) + const struct vkd3d_shader_spirv_target_info *target_info) { struct vkd3d_shader_code dxbc = {code->pShaderBytecode, code->BytecodeLength}; const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; @@ -1347,7 +1347,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device, shader_desc.pNext = NULL; shader_desc.flags = 0;
- if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface, compile_args)) < 0) + if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface, target_info)) < 0) { WARN("Failed to compile shader, vkd3d result %d.\n", ret); return hresult_from_vkd3d_result(ret); @@ -1990,12 +1990,12 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s const D3D12_STREAM_OUTPUT_DESC *so_desc = &desc->StreamOutput; VkVertexInputBindingDivisorDescriptionEXT *binding_divisor; const struct vkd3d_vulkan_info *vk_info = &device->vk_info; - const struct vkd3d_shader_compile_arguments *compile_args; uint32_t instance_divisors[D3D12_VS_INPUT_REGISTER_COUNT]; + const struct vkd3d_shader_spirv_target_info *target_info; uint32_t aligned_offsets[D3D12_VS_INPUT_REGISTER_COUNT]; - struct vkd3d_shader_compile_arguments ps_compile_args; struct vkd3d_shader_parameter ps_shader_parameters[1]; struct vkd3d_shader_transform_feedback_info xfb_info; + struct vkd3d_shader_spirv_target_info ps_target_info; struct vkd3d_shader_interface_info shader_interface; const struct d3d12_root_signature *root_signature; struct vkd3d_shader_signature input_signature; @@ -2164,24 +2164,24 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s ps_shader_parameters[0].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32; ps_shader_parameters[0].u.immediate_constant.u.u32 = sample_count;
- ps_compile_args.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS; - ps_compile_args.next = NULL; - ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0; - ps_compile_args.target_extension_count = vk_info->shader_extension_count; - ps_compile_args.target_extensions = vk_info->shader_extensions; - ps_compile_args.parameter_count = ARRAY_SIZE(ps_shader_parameters); - ps_compile_args.parameters = ps_shader_parameters; - ps_compile_args.dual_source_blending = is_dual_source_blending(&desc->BlendState.RenderTarget[0]); - ps_compile_args.output_swizzles = ps_output_swizzle; - ps_compile_args.output_swizzle_count = rt_count; + ps_target_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO; + ps_target_info.next = NULL; + ps_target_info.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0; + ps_target_info.target_extensions = vk_info->shader_extensions; + ps_target_info.target_extension_count = vk_info->shader_extension_count; + ps_target_info.parameters = ps_shader_parameters; + ps_target_info.parameter_count = ARRAY_SIZE(ps_shader_parameters); + ps_target_info.dual_source_blending = is_dual_source_blending(&desc->BlendState.RenderTarget[0]); + ps_target_info.output_swizzles = ps_output_swizzle; + ps_target_info.output_swizzle_count = rt_count;
- if (ps_compile_args.dual_source_blending && rt_count > 1) + if (ps_target_info.dual_source_blending && rt_count > 1) { WARN("Only one render target is allowed when dual source blending is used.\n"); hr = E_INVALIDARG; goto fail; } - if (ps_compile_args.dual_source_blending && desc->BlendState.IndependentBlendEnable) + if (ps_target_info.dual_source_blending && desc->BlendState.IndependentBlendEnable) { for (i = 1; i < ARRAY_SIZE(desc->BlendState.RenderTarget); ++i) { @@ -2259,7 +2259,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s if (shader_info.uav_counter_mask) FIXME("UAV counters not implemented for graphics pipelines.\n");
- compile_args = NULL; + target_info = NULL; switch (shader_stages[i].stage) { case VK_SHADER_STAGE_VERTEX_BIT: @@ -2284,7 +2284,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s break;
case VK_SHADER_STAGE_FRAGMENT_BIT: - compile_args = &ps_compile_args; + target_info = &ps_target_info; break;
default: @@ -2295,7 +2295,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s shader_interface.next = shader_stages[i].stage == xfb_stage ? &xfb_info : NULL;
if (FAILED(hr = create_shader_stage(device, &graphics->stages[graphics->stage_count], - shader_stages[i].stage, b, &shader_interface, compile_args))) + shader_stages[i].stage, b, &shader_interface, target_info))) goto fail;
++graphics->stage_count;