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 @@
#include "vkd3d_shader_private.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,
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
}
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_message_context *message_context = ctx->message_context;
unsigned int tmp_idx = ~0u, i;
enum vkd3d_result ret;
......@@ -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,
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};
enum vkd3d_result result;
......@@ -2860,7 +2871,8 @@ static bool lower_switch_to_if_ladder_add_block_mapping(struct lower_switch_to_i
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;
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
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;
struct ssas_to_temps_block_info *info, *block_info = NULL;
......@@ -5271,8 +5284,9 @@ out:
}
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};
enum vkd3d_result ret;
size_t i;
......@@ -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,
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;
size_t i;
......@@ -5731,14 +5746,14 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c
if (ctx->invalid_instruction_idx)
{
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
{
const struct vkd3d_shader_instruction *ins = &ctx->program->instructions.elements[ctx->instruction_idx];
vkd3d_shader_error(ctx->message_context, &ins->location, error,
"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);
......@@ -6243,12 +6258,13 @@ static void vsir_validate_instruction(struct validation_context *ctx)
/* We support two different control flow types in shaders:
* block-based, like DXIL and SPIR-V, and structured, like D3DBC
* and TPF. The shader is detected as block-based when its first
* instruction, except for DCL_* and phases, is a LABEL. Currently
* we mandate that each shader is either purely block-based or
* instruction, except for NOP, DCL_* and phases, is a LABEL.
* Currently we mandate that each shader is either purely block-based or
* purely structured. In principle we could allow structured
* constructs in a block, provided they are confined in a single
* 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)
ctx->cf_type = CF_TYPE_BLOCKS;
......@@ -6610,33 +6626,59 @@ fail:
return VKD3D_ERROR_OUT_OF_MEMORY;
}
enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
#define vsir_transform(ctx, step) vsir_transform_(ctx, #step, step)
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)
return result;
if ((ctx->result = step(ctx->program, ctx)) < 0)
{
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)
return result;
WARN("Validation failed with result %u after transformation \"%s\".\n", ctx->result, step_name);
return;
}
}
if ((result = lower_switch_to_if_ladder(program)) < 0)
return result;
enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
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)
return result;
vsir_transform(&ctx, vsir_program_lower_instructions);
if ((result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0)
return result;
if (program->shader_version.major >= 6)
{
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)
return result;
if (ctx.result < 0)
return ctx.result;
}
else
{
if (ctx.result < 0)
return ctx.result;
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
{
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
return result;
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;
}
......