Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
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
Nikolay Sivov
vkd3d
Commits
91e7eeb1
Commit
91e7eeb1
authored
7 months ago
by
Nikolay Sivov
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Add an explicit cast to uint for array index access.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
46a1b66d
Branches
array_index
No related tags found
No related merge requests found
Pipeline
#27755
passed with warnings
6 months ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/vkd3d-shader/hlsl_codegen.c
+6
-1
6 additions, 1 deletion
libs/vkd3d-shader/hlsl_codegen.c
tests/hlsl/non-const-indexing.shader_test
+11
-0
11 additions, 0 deletions
tests/hlsl/non-const-indexing.shader_test
with
17 additions
and
1 deletion
libs/vkd3d-shader/hlsl_codegen.c
+
6
−
1
View file @
91e7eeb1
...
...
@@ -49,6 +49,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
case
HLSL_CLASS_ARRAY
:
{
unsigned
int
size
=
hlsl_type_get_array_element_reg_size
(
type
->
e
.
array
.
type
,
regset
);
struct
hlsl_ir_node
*
cast
;
if
(
regset
==
HLSL_REGSET_NUMERIC
)
{
...
...
@@ -60,7 +61,11 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
return
NULL
;
hlsl_block_add_instr
(
block
,
c
);
if
(
!
(
idx_offset
=
hlsl_new_binary_expr
(
ctx
,
HLSL_OP2_MUL
,
c
,
idx
)))
if
(
!
(
cast
=
hlsl_new_cast
(
ctx
,
idx
,
hlsl_get_scalar_type
(
ctx
,
HLSL_TYPE_UINT
),
loc
)))
return
NULL
;
hlsl_block_add_instr
(
block
,
cast
);
if
(
!
(
idx_offset
=
hlsl_new_binary_expr
(
ctx
,
HLSL_OP2_MUL
,
c
,
cast
)))
return
NULL
;
hlsl_block_add_instr
(
block
,
idx_offset
);
...
...
This diff is collapsed.
Click to expand it.
tests/hlsl/non-const-indexing.shader_test
+
11
−
0
View file @
91e7eeb1
...
...
@@ -247,3 +247,14 @@ todo(sm<4 | glsl) draw quad
if(sm<4) todo probe (0,0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=4 & sm<6) todo probe (0,0) rgba (4.0, 4.0, 4.0, 4.0)
if(sm>=6) probe (0,0) rgba (4.0, 3.0, 2.0, 1.0)
[require]
shader model >= 4.0
[pixel shader]
float4 f[2];
float4 main(uint index : INDEX) : sv_target
{
return f[index];
}
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