Skip to content
Snippets Groups Projects
Commit e0a801e7 authored by Francisco Casas's avatar Francisco Casas Committed by Alexandre Julliard
Browse files

vkd3d-shader/hlsl: Improve tracking of used components running DCE before.

track_object_components_usage() had to be improved to also
register derefs on resource stores.
It was not doing it because it assumed that for every resource store
there was a resource load already, which was true, before calling DCE.
parent 657e460d
No related branches found
No related tags found
1 merge request!851tests: Fix SM1 constant register allocation for numerics.
...@@ -4248,34 +4248,38 @@ static bool track_object_components_sampler_dim(struct hlsl_ctx *ctx, struct hls ...@@ -4248,34 +4248,38 @@ static bool track_object_components_sampler_dim(struct hlsl_ctx *ctx, struct hls
return false; return false;
} }
static bool track_object_components_usage(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) static void register_deref_usage(struct hlsl_ctx *ctx, struct hlsl_deref *deref)
{ {
struct hlsl_ir_resource_load *load; struct hlsl_ir_var *var = deref->var;
struct hlsl_ir_var *var; enum hlsl_regset regset = hlsl_deref_get_regset(ctx, deref);
enum hlsl_regset regset;
unsigned int index; unsigned int index;
if (instr->type != HLSL_IR_RESOURCE_LOAD) if (!hlsl_regset_index_from_deref(ctx, deref, regset, &index))
return false; return;
load = hlsl_ir_resource_load(instr);
var = load->resource.var;
regset = hlsl_deref_get_regset(ctx, &load->resource);
if (!hlsl_regset_index_from_deref(ctx, &load->resource, regset, &index)) if (regset <= HLSL_REGSET_LAST_OBJECT)
return false; {
var->objects_usage[regset][index].used = true;
var->bind_count[regset] = max(var->bind_count[regset], index + 1);
}
}
var->objects_usage[regset][index].used = true; static bool track_object_components_usage(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
var->bind_count[regset] = max(var->bind_count[regset], index + 1); {
if (load->sampler.var) switch (instr->type)
{ {
var = load->sampler.var; case HLSL_IR_RESOURCE_LOAD:
if (!hlsl_regset_index_from_deref(ctx, &load->sampler, HLSL_REGSET_SAMPLERS, &index)) register_deref_usage(ctx, &hlsl_ir_resource_load(instr)->resource);
return false; if (hlsl_ir_resource_load(instr)->sampler.var)
register_deref_usage(ctx, &hlsl_ir_resource_load(instr)->sampler);
break;
case HLSL_IR_RESOURCE_STORE:
register_deref_usage(ctx, &hlsl_ir_resource_store(instr)->resource);
break;
var->objects_usage[HLSL_REGSET_SAMPLERS][index].used = true; default:
var->bind_count[HLSL_REGSET_SAMPLERS] = max(var->bind_count[HLSL_REGSET_SAMPLERS], index + 1); break;
} }
return false; return false;
...@@ -5440,6 +5444,11 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry ...@@ -5440,6 +5444,11 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
hlsl_transform_ir(ctx, track_object_components_sampler_dim, body, NULL); hlsl_transform_ir(ctx, track_object_components_sampler_dim, body, NULL);
if (profile->major_version >= 4) if (profile->major_version >= 4)
hlsl_transform_ir(ctx, lower_combined_samples, body, NULL); hlsl_transform_ir(ctx, lower_combined_samples, body, NULL);
do
compute_liveness(ctx, entry_func);
while (hlsl_transform_ir(ctx, dce, body, NULL));
hlsl_transform_ir(ctx, track_object_components_usage, body, NULL); hlsl_transform_ir(ctx, track_object_components_usage, body, NULL);
sort_synthetic_separated_samplers_first(ctx); sort_synthetic_separated_samplers_first(ctx);
......
...@@ -318,7 +318,7 @@ probe all rgba (2.0, 3.0, 3.0, 2.0) ...@@ -318,7 +318,7 @@ probe all rgba (2.0, 3.0, 3.0, 2.0)
% Objects can be used, but their types have to be identical. % Objects can be used, but their types have to be identical.
[pixel shader todo(sm<4)] [pixel shader]
Texture2D t; Texture2D t;
float4 main() : sv_target float4 main() : sv_target
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment