Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
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
wine
vkd3d
Commits
4448d114
Commit
4448d114
authored
2 years ago
by
Francisco Casas
Committed by
Alexandre Julliard
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Detect overlaps in cbuffer offsets.
parent
7777c32c
No related branches found
No related tags found
1 merge request
!106
vkd3d-shader/hlsl: packoffset() support.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/vkd3d-shader/hlsl_codegen.c
+42
-0
42 additions, 0 deletions
libs/vkd3d-shader/hlsl_codegen.c
tests/cbuffer.shader_test
+1
-1
1 addition, 1 deletion
tests/cbuffer.shader_test
with
43 additions
and
1 deletion
libs/vkd3d-shader/hlsl_codegen.c
+
42
−
0
View file @
4448d114
...
...
@@ -2952,6 +2952,46 @@ static void calculate_buffer_offset(struct hlsl_ctx *ctx, struct hlsl_ir_var *va
buffer
->
used_size
=
max
(
buffer
->
used_size
,
var
->
buffer_offset
+
var_reg_size
);
}
static
void
validate_buffer_offsets
(
struct
hlsl_ctx
*
ctx
)
{
struct
hlsl_ir_var
*
var1
,
*
var2
;
struct
hlsl_buffer
*
buffer
;
LIST_FOR_EACH_ENTRY
(
var1
,
&
ctx
->
extern_vars
,
struct
hlsl_ir_var
,
extern_entry
)
{
if
(
!
var1
->
is_uniform
||
var1
->
data_type
->
class
==
HLSL_CLASS_OBJECT
)
continue
;
buffer
=
var1
->
buffer
;
if
(
!
buffer
->
used_size
)
continue
;
LIST_FOR_EACH_ENTRY
(
var2
,
&
ctx
->
extern_vars
,
struct
hlsl_ir_var
,
extern_entry
)
{
unsigned
int
var1_reg_size
,
var2_reg_size
;
if
(
!
var2
->
is_uniform
||
var2
->
data_type
->
class
==
HLSL_CLASS_OBJECT
)
continue
;
if
(
var1
==
var2
||
var1
->
buffer
!=
var2
->
buffer
)
continue
;
/* This is to avoid reporting the error twice for the same pair of overlapping variables. */
if
(
strcmp
(
var1
->
name
,
var2
->
name
)
>=
0
)
continue
;
var1_reg_size
=
var1
->
data_type
->
reg_size
[
HLSL_REGSET_NUMERIC
];
var2_reg_size
=
var2
->
data_type
->
reg_size
[
HLSL_REGSET_NUMERIC
];
if
(
var1
->
buffer_offset
<
var2
->
buffer_offset
+
var2_reg_size
&&
var2
->
buffer_offset
<
var1
->
buffer_offset
+
var1_reg_size
)
hlsl_error
(
ctx
,
&
buffer
->
loc
,
VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION
,
"Invalid packoffset() reservation: Variables %s and %s overlap."
,
var1
->
name
,
var2
->
name
);
}
}
}
static
void
allocate_buffers
(
struct
hlsl_ctx
*
ctx
)
{
struct
hlsl_buffer
*
buffer
;
...
...
@@ -2969,6 +3009,8 @@ static void allocate_buffers(struct hlsl_ctx *ctx)
}
}
validate_buffer_offsets
(
ctx
);
LIST_FOR_EACH_ENTRY
(
buffer
,
&
ctx
->
buffers
,
struct
hlsl_buffer
,
entry
)
{
if
(
!
buffer
->
used_size
)
...
...
This diff is collapsed.
Click to expand it.
tests/cbuffer.shader_test
+
1
−
1
View file @
4448d114
...
...
@@ -106,7 +106,7 @@ draw quad
probe all rgba (0.0, 4.0, 5.0, 6.0)
[pixel shader fail
todo
]
[pixel shader fail]
// Elements cannot overlap if buffer is used.
cbuffer buffer
{
...
...
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