mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Sort synthetic separated samplers first for SM4.
This commit is contained in:
parent
81afe43569
commit
37cfbe47d7
Notes:
Alexandre Julliard
2023-08-15 22:06:06 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/299
@ -2191,6 +2191,44 @@ static bool lower_combined_samples(struct hlsl_ctx *ctx, struct hlsl_ir_node *in
|
||||
return true;
|
||||
}
|
||||
|
||||
static void insert_ensuring_decreasing_bind_count(struct list *list, struct hlsl_ir_var *to_add,
|
||||
enum hlsl_regset regset)
|
||||
{
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, list, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (var->bind_count[regset] < to_add->bind_count[regset])
|
||||
{
|
||||
list_add_before(&var->extern_entry, &to_add->extern_entry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
list_add_tail(list, &to_add->extern_entry);
|
||||
}
|
||||
|
||||
static bool sort_synthetic_separated_samplers_first(struct hlsl_ctx *ctx)
|
||||
{
|
||||
struct list separated_resources;
|
||||
struct hlsl_ir_var *var, *next;
|
||||
|
||||
list_init(&separated_resources);
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(var, next, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (var->is_separated_resource)
|
||||
{
|
||||
list_remove(&var->extern_entry);
|
||||
insert_ensuring_decreasing_bind_count(&separated_resources, var, HLSL_REGSET_TEXTURES);
|
||||
}
|
||||
}
|
||||
|
||||
list_move_head(&ctx->extern_vars, &separated_resources);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Lower DIV to RCP + MUL. */
|
||||
static bool lower_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||
{
|
||||
@ -4318,6 +4356,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
||||
if (profile->major_version >= 4)
|
||||
hlsl_transform_ir(ctx, lower_combined_samples, body, NULL);
|
||||
hlsl_transform_ir(ctx, track_object_components_usage, body, NULL);
|
||||
sort_synthetic_separated_samplers_first(ctx);
|
||||
|
||||
if (profile->major_version < 4)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (10, 10, 10, 11)
|
||||
probe all rgba (10, 10, 10, 11)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
@ -74,7 +74,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (21, 21, 21, 11)
|
||||
probe all rgba (21, 21, 21, 11)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
@ -105,7 +105,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (104, 104, 104, 111)
|
||||
probe all rgba (104, 104, 104, 111)
|
||||
|
||||
|
||||
% Sampler arrays with components that have different usage dimensions are only forbidden in SM4 upwards.
|
||||
|
@ -131,7 +131,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (450, 139, 876, 333)
|
||||
probe all rgba (450, 139, 876, 333)
|
||||
|
||||
|
||||
% Same as the first test, but inverting the declaration order.
|
||||
@ -184,7 +184,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (450, 138, 796, 333)
|
||||
probe all rgba (450, 138, 796, 333)
|
||||
|
||||
|
||||
% Same as the first test, but inverting the resource loads order.
|
||||
@ -237,7 +237,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (478, 913, 256, 333)
|
||||
probe all rgba (478, 913, 256, 333)
|
||||
|
||||
|
||||
% We can conclude that for declared texture arrays, if they are used, the "allocation size" is the
|
||||
@ -270,7 +270,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (215, 215, 215, 111)
|
||||
probe all rgba (215, 215, 215, 111)
|
||||
|
||||
|
||||
% Test that textures created from SM1-style samples allocation order is in decreasing "bind count".
|
||||
@ -300,4 +300,4 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (5, 4, 2, 0)
|
||||
probe all rgba (5, 4, 2, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user