Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wine/vkd3d
  • stefan/vkd3d
  • cmccarthy/vkd3d
  • giomasce/vkd3d
  • fcasas/vkd3d
  • jactry/vkd3d
  • ReDress/vkd3d
  • mstorsjo/vkd3d
  • huw/vkd3d
  • julliard/vkd3d
  • bshanks/vkd3d
  • zfigura/vkd3d
  • hverbeet/vkd3d
  • DarkShadow44/vkd3d
  • nsivov/vkd3d
  • dhary686/vkd3d
  • Mystral/vkd3d
  • maljaf/vkd3d
  • smcv/vkd3d
  • flibitijibibo/vkd3d
  • q4a/vkd3d
  • jsikorski/vkd3d
  • alesliehughes/vkd3d-alesliehughes
  • vitorhnn/vkd3d
  • agusev/vkd3d
  • etang-cw/vkd3d
  • petrathekat/vkd3d
  • simon.mr995/vkd3d
  • sgwaki/vkd3d
  • jacek/vkd3d
  • fweimer/vkd3d
  • Clara/vkd3d
  • disini/vkd3d
  • antenabr2/vkd3d
  • gilvbp/vkd3d
  • yshui/vkd3d
  • shaunren/vkd3d
  • jennetsaryyewa96/vkd3d
  • Jamesattay/vkd3d
  • zacemmneeto77/vkd3d
  • GermanAizek/vkd3d
  • opespinach/vkd3d
  • ruslanboyka201/vkd3d
  • navi/vkd3d
  • Feifan/vkd3d
  • yashmhmdly172/vkd3d
  • Sec32fun32/vkd3d
  • ritalat/vkd3d
  • ivyl/vkd3d
  • baikaishiuc/vkd3d
  • austin987/vkd3d
  • TornadoCookie/vkd3d
52 results
Show changes
...@@ -19,6 +19,15 @@ ...@@ -19,6 +19,15 @@
#include "vkd3d_shader_private.h" #include "vkd3d_shader_private.h"
#include "vkd3d_types.h" #include "vkd3d_types.h"
struct vsir_normalisation_context
{
enum vkd3d_result result;
struct vsir_program *program;
uint64_t config_flags;
const struct vkd3d_shader_compile_info *compile_info;
struct vkd3d_shader_message_context *message_context;
};
static int convert_parameter_info(const struct vkd3d_shader_compile_info *compile_info, static int convert_parameter_info(const struct vkd3d_shader_compile_info *compile_info,
unsigned int *ret_count, const struct vkd3d_shader_parameter1 **ret_parameters) unsigned int *ret_count, const struct vkd3d_shader_parameter1 **ret_parameters)
{ {
...@@ -442,9 +451,10 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog ...@@ -442,9 +451,10 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog
} }
static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *program, static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *program,
struct vkd3d_shader_message_context *message_context) struct vsir_normalisation_context *ctx)
{ {
struct vkd3d_shader_instruction_array *instructions = &program->instructions; struct vkd3d_shader_instruction_array *instructions = &program->instructions;
struct vkd3d_shader_message_context *message_context = ctx->message_context;
unsigned int tmp_idx = ~0u, i; unsigned int tmp_idx = ~0u, i;
enum vkd3d_result ret; enum vkd3d_result ret;
...@@ -2789,8 +2799,9 @@ static enum vkd3d_result cf_flattener_iterate_instruction_array(struct cf_flatte ...@@ -2789,8 +2799,9 @@ static enum vkd3d_result cf_flattener_iterate_instruction_array(struct cf_flatte
} }
static enum vkd3d_result vsir_program_flatten_control_flow_constructs(struct vsir_program *program, static enum vkd3d_result vsir_program_flatten_control_flow_constructs(struct vsir_program *program,
struct vkd3d_shader_message_context *message_context) struct vsir_normalisation_context *ctx)
{ {
struct vkd3d_shader_message_context *message_context = ctx->message_context;
struct cf_flattener flattener = {.program = program}; struct cf_flattener flattener = {.program = program};
enum vkd3d_result result; enum vkd3d_result result;
...@@ -2860,7 +2871,8 @@ static bool lower_switch_to_if_ladder_add_block_mapping(struct lower_switch_to_i ...@@ -2860,7 +2871,8 @@ static bool lower_switch_to_if_ladder_add_block_mapping(struct lower_switch_to_i
return true; return true;
} }
static enum vkd3d_result lower_switch_to_if_ladder(struct vsir_program *program) static enum vkd3d_result vsir_program_lower_switch_to_selection_ladder(struct vsir_program *program,
struct vsir_normalisation_context *ctx)
{ {
unsigned int block_count = program->block_count, ssa_count = program->ssa_count, current_label = 0, if_label; unsigned int block_count = program->block_count, ssa_count = program->ssa_count, current_label = 0, if_label;
size_t ins_capacity = 0, ins_count = 0, i, map_capacity = 0, map_count = 0; size_t ins_capacity = 0, ins_count = 0, i, map_capacity = 0, map_count = 0;
...@@ -3050,7 +3062,8 @@ static void ssas_to_temps_block_info_cleanup(struct ssas_to_temps_block_info *bl ...@@ -3050,7 +3062,8 @@ static void ssas_to_temps_block_info_cleanup(struct ssas_to_temps_block_info *bl
vkd3d_free(block_info); vkd3d_free(block_info);
} }
static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_program *program) static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_program *program,
struct vsir_normalisation_context *ctx)
{ {
size_t ins_capacity = 0, ins_count = 0, phi_count, incoming_count, i; size_t ins_capacity = 0, ins_count = 0, phi_count, incoming_count, i;
struct ssas_to_temps_block_info *info, *block_info = NULL; struct ssas_to_temps_block_info *info, *block_info = NULL;
...@@ -5271,8 +5284,9 @@ out: ...@@ -5271,8 +5284,9 @@ out:
} }
static enum vkd3d_result vsir_program_structurize(struct vsir_program *program, static enum vkd3d_result vsir_program_structurize(struct vsir_program *program,
struct vkd3d_shader_message_context *message_context) struct vsir_normalisation_context *ctx)
{ {
struct vkd3d_shader_message_context *message_context = ctx->message_context;
struct vsir_cfg_emit_target target = {0}; struct vsir_cfg_emit_target target = {0};
enum vkd3d_result ret; enum vkd3d_result ret;
size_t i; size_t i;
...@@ -5451,8 +5465,9 @@ static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps_in_f ...@@ -5451,8 +5465,9 @@ static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps_in_f
} }
static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps(struct vsir_program *program, static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps(struct vsir_program *program,
struct vkd3d_shader_message_context *message_context) struct vsir_normalisation_context *ctx)
{ {
struct vkd3d_shader_message_context *message_context = ctx->message_context;
enum vkd3d_result ret; enum vkd3d_result ret;
size_t i; size_t i;
...@@ -5731,14 +5746,14 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c ...@@ -5731,14 +5746,14 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c
if (ctx->invalid_instruction_idx) if (ctx->invalid_instruction_idx)
{ {
vkd3d_shader_error(ctx->message_context, &ctx->null_location, error, "%s", buf.buffer); vkd3d_shader_error(ctx->message_context, &ctx->null_location, error, "%s", buf.buffer);
ERR("VSIR validation error: %s\n", buf.buffer); WARN("VSIR validation error: %s\n", buf.buffer);
} }
else else
{ {
const struct vkd3d_shader_instruction *ins = &ctx->program->instructions.elements[ctx->instruction_idx]; const struct vkd3d_shader_instruction *ins = &ctx->program->instructions.elements[ctx->instruction_idx];
vkd3d_shader_error(ctx->message_context, &ins->location, error, vkd3d_shader_error(ctx->message_context, &ins->location, error,
"instruction %zu: %s", ctx->instruction_idx + 1, buf.buffer); "instruction %zu: %s", ctx->instruction_idx + 1, buf.buffer);
ERR("VSIR validation error: instruction %zu: %s\n", ctx->instruction_idx + 1, buf.buffer); WARN("VSIR validation error: instruction %zu: %s\n", ctx->instruction_idx + 1, buf.buffer);
} }
vkd3d_string_buffer_cleanup(&buf); vkd3d_string_buffer_cleanup(&buf);
...@@ -6243,12 +6258,13 @@ static void vsir_validate_instruction(struct validation_context *ctx) ...@@ -6243,12 +6258,13 @@ static void vsir_validate_instruction(struct validation_context *ctx)
/* We support two different control flow types in shaders: /* We support two different control flow types in shaders:
* block-based, like DXIL and SPIR-V, and structured, like D3DBC * block-based, like DXIL and SPIR-V, and structured, like D3DBC
* and TPF. The shader is detected as block-based when its first * and TPF. The shader is detected as block-based when its first
* instruction, except for DCL_* and phases, is a LABEL. Currently * instruction, except for NOP, DCL_* and phases, is a LABEL.
* we mandate that each shader is either purely block-based or * Currently we mandate that each shader is either purely block-based or
* purely structured. In principle we could allow structured * purely structured. In principle we could allow structured
* constructs in a block, provided they are confined in a single * constructs in a block, provided they are confined in a single
* block, but need for that hasn't arisen yet, so we don't. */ * block, but need for that hasn't arisen yet, so we don't. */
if (ctx->cf_type == CF_TYPE_UNKNOWN && !vsir_instruction_is_dcl(instruction)) if (ctx->cf_type == CF_TYPE_UNKNOWN && instruction->opcode != VKD3DSIH_NOP
&& !vsir_instruction_is_dcl(instruction))
{ {
if (instruction->opcode == VKD3DSIH_LABEL) if (instruction->opcode == VKD3DSIH_LABEL)
ctx->cf_type = CF_TYPE_BLOCKS; ctx->cf_type = CF_TYPE_BLOCKS;
...@@ -6610,33 +6626,59 @@ fail: ...@@ -6610,33 +6626,59 @@ fail:
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
} }
enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags, #define vsir_transform(ctx, step) vsir_transform_(ctx, #step, step)
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context) static void vsir_transform_(
struct vsir_normalisation_context *ctx, const char *step_name,
enum vkd3d_result (*step)(struct vsir_program *program, struct vsir_normalisation_context *ctx))
{ {
enum vkd3d_result result = VKD3D_OK; if (ctx->result < 0)
return;
if ((result = vsir_program_lower_instructions(program, message_context)) < 0) if ((ctx->result = step(ctx->program, ctx)) < 0)
return result; {
WARN("Transformation \"%s\" failed with result %u.\n", step_name, ctx->result);
return;
}
if (program->shader_version.major >= 6) if ((ctx->result = vsir_program_validate(ctx->program, ctx->config_flags,
ctx->compile_info->source_name, ctx->message_context)) < 0)
{ {
if ((result = vsir_program_materialise_phi_ssas_to_temps(program)) < 0) WARN("Validation failed with result %u after transformation \"%s\".\n", ctx->result, step_name);
return result; return;
}
}
if ((result = lower_switch_to_if_ladder(program)) < 0) enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
return result; const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
{
struct vsir_normalisation_context ctx =
{
.result = VKD3D_OK,
.program = program,
.config_flags = config_flags,
.compile_info = compile_info,
.message_context = message_context,
};
enum vkd3d_result result;
if ((result = vsir_program_structurize(program, message_context)) < 0) vsir_transform(&ctx, vsir_program_lower_instructions);
return result;
if ((result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0) if (program->shader_version.major >= 6)
return result; {
vsir_transform(&ctx, vsir_program_materialise_phi_ssas_to_temps);
vsir_transform(&ctx, vsir_program_lower_switch_to_selection_ladder);
vsir_transform(&ctx, vsir_program_structurize);
vsir_transform(&ctx, vsir_program_flatten_control_flow_constructs);
vsir_transform(&ctx, vsir_program_materialize_undominated_ssas_to_temps);
if ((result = vsir_program_materialize_undominated_ssas_to_temps(program, message_context)) < 0) if (ctx.result < 0)
return result; return ctx.result;
} }
else else
{ {
if (ctx.result < 0)
return ctx.result;
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL) if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
{ {
if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0) if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
...@@ -6665,7 +6707,7 @@ enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t ...@@ -6665,7 +6707,7 @@ enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t
return result; return result;
if (compile_info->target_type != VKD3D_SHADER_TARGET_GLSL if (compile_info->target_type != VKD3D_SHADER_TARGET_GLSL
&& (result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0) && (result = vsir_program_flatten_control_flow_constructs(program, &ctx)) < 0)
return result; return result;
} }
......