Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vkd3d
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Francisco Casas
vkd3d
Commits
b3c62095
Commit
b3c62095
authored
2 years ago
by
Elizabeth Figura
Committed by
Alexandre Julliard
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Apply latent type modifiers to matrix array typedefs.
parent
2a412670
No related branches found
Branches containing commit
Tags
wine-0.9.54
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/vkd3d-shader/hlsl.y
+14
-11
14 additions, 11 deletions
libs/vkd3d-shader/hlsl.y
tests/hlsl-majority-pragma.shader_test
+45
-0
45 additions, 0 deletions
tests/hlsl-majority-pragma.shader_test
with
59 additions
and
11 deletions
libs/vkd3d-shader/hlsl.y
+
14
−
11
View file @
b3c62095
...
...
@@ -882,12 +882,6 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
unsigned int default_majority = 0;
struct hlsl_type *new_type;
/* This function is only used for declarations (i.e. variables and struct
* fields), which should inherit the matrix majority. We only explicitly set
* the default majority for declarations—typedefs depend on this—but we
* want to always set it, so that an hlsl_type object is never used to
* represent two different majorities (and thus can be used to store its
* register size, etc.) */
if (!(*modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
&& !(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
&& type->type == HLSL_CLASS_MATRIX)
...
...
@@ -1003,7 +997,8 @@ static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields,
return true;
}
static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type *orig_type, struct list *list)
static bool add_typedef(struct hlsl_ctx *ctx, const unsigned int modifiers,
struct hlsl_type *const orig_type, struct list *list)
{
struct parse_variable_def *v, *v_next;
struct hlsl_type *type;
...
...
@@ -1014,15 +1009,26 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
{
if (!v->arrays.count)
{
/* Do not use apply_type_modifiers() here. We should not apply the
* latent matrix majority to plain matrix types. */
if (!(type = hlsl_type_clone(ctx, orig_type, 0, modifiers)))
{
free_parse_variable_def(v);
continue;
}
if (type->type != HLSL_CLASS_MATRIX)
check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
}
else
{
type = orig_type;
unsigned int var_modifiers = modifiers;
if (!(type = apply_type_modifiers(ctx, orig_type, &var_modifiers, v->loc)))
{
free_parse_variable_def(v);
continue;
}
}
ret = true;
...
...
@@ -1048,9 +1054,6 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
vkd3d_free((void *)type->name);
type->name = v->name;
if (type->type != HLSL_CLASS_MATRIX)
check_invalid_matrix_modifiers(ctx, type->modifiers, v->loc);
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
...
...
This diff is collapsed.
Click to expand it.
tests/hlsl-majority-pragma.shader_test
+
45
−
0
View file @
b3c62095
...
...
@@ -128,6 +128,31 @@ float4 main() : sv_target
}
% This applies to arrays as well. Note that struct fields already have latent
% majority applied (even if there have been no pragmas, as shown below), so the
% question of typedefs is moot there.
[pixel shader]
#pragma pack_matrix(row_major)
typedef float2x2 myarray_t[2];
#pragma pack_matrix(column_major)
uniform myarray_t a;
float4 main() : sv_target
{
return float4(a[0][0], a[1][1]);
}
[test]
uniform 0 float4 0.3 0.4 0.0 0.0
uniform 4 float4 0.0 0.0 0.0 0.0
uniform 8 float4 0.0 0.0 0.0 0.0
uniform 12 float4 0.5 0.6 0.0 0.0
draw quad
probe all rgba (0.3, 0.4, 0.5, 0.6)
% However, if no pack_matrix directive has been used yet, a typedef has no
% defined majority, and the majority can be overwritten, including by a
% subsequent pragma.
...
...
@@ -178,3 +203,23 @@ uniform 0 float4 0.2 0.4 0.0 0.0
uniform 4 float4 0.3 0.5 0.0 0.0
draw quad
probe all rgba (0.2, 0.3, 0.4, 0.5)
[pixel shader]
typedef float2x2 myarray_t[2];
#pragma pack_matrix(row_major)
typedef myarray_t myarray2_t;
uniform myarray2_t a;
float4 main() : sv_target
{
return float4(a[0][0], a[1][1]);
}
[test]
uniform 0 float4 0.3 0.0 0.0 0.0
uniform 4 float4 0.4 0.0 0.0 0.0
uniform 8 float4 0.0 0.5 0.0 0.0
uniform 12 float4 0.0 0.6 0.0 0.0
draw quad
probe all rgba (0.3, 0.4, 0.5, 0.6)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment