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
d52eb859
Commit
d52eb859
authored
2 years ago
by
Elizabeth Figura
Committed by
Alexandre Julliard
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Use a hlsl_block to build replacement instructions in lower_int_division().
parent
cdabe172
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!275
hlsl: Replace bare list pointers with hlsl_block, part 4.
Pipeline
#12791
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/vkd3d-shader/hlsl_codegen.c
+45
-18
45 additions, 18 deletions
libs/vkd3d-shader/hlsl_codegen.c
with
45 additions
and
18 deletions
libs/vkd3d-shader/hlsl_codegen.c
+
45
−
18
View file @
d52eb859
...
...
@@ -574,6 +574,37 @@ bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx,
return
progress
;
}
typedef
bool
(
*
PFN_lower_func
)(
struct
hlsl_ctx
*
,
struct
hlsl_ir_node
*
,
struct
hlsl_block
*
);
static
bool
call_lower_func
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
{
PFN_lower_func
func
=
context
;
struct
hlsl_block
block
;
hlsl_block_init
(
&
block
);
if
(
func
(
ctx
,
instr
,
&
block
))
{
struct
hlsl_ir_node
*
replacement
=
LIST_ENTRY
(
list_tail
(
&
block
.
instrs
),
struct
hlsl_ir_node
,
entry
);
list_move_before
(
&
instr
->
entry
,
&
block
.
instrs
);
hlsl_replace_node
(
instr
,
replacement
);
return
true
;
}
else
{
hlsl_block_cleanup
(
&
block
);
return
false
;
}
}
/* Specific form of transform_ir() for passes which convert a single instruction
* to a block of one or more instructions. This helper takes care of setting up
* the block and calling hlsl_replace_node_with_block(). */
static
bool
lower_ir
(
struct
hlsl_ctx
*
ctx
,
PFN_lower_func
func
,
struct
hlsl_block
*
block
)
{
return
hlsl_transform_ir
(
ctx
,
call_lower_func
,
block
,
func
);
}
static
bool
transform_instr_derefs
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
{
bool
res
;
...
...
@@ -2391,9 +2422,9 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *ins
return
&
load
->
node
;
}
static
bool
lower_int_division
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
static
bool
lower_int_division
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
struct
hlsl_block
*
block
)
{
struct
hlsl_ir_node
*
arg1
,
*
arg2
,
*
xor
,
*
and
,
*
abs1
,
*
abs2
,
*
div
,
*
neg
,
*
cast1
,
*
cast2
,
*
cast3
,
*
cond
,
*
high_bit
;
struct
hlsl_ir_node
*
arg1
,
*
arg2
,
*
xor
,
*
and
,
*
abs1
,
*
abs2
,
*
div
,
*
neg
,
*
cast1
,
*
cast2
,
*
cast3
,
*
high_bit
;
struct
hlsl_type
*
type
=
instr
->
data_type
,
*
utype
;
struct
hlsl_constant_value
high_bit_value
;
struct
hlsl_ir_expr
*
expr
;
...
...
@@ -2414,51 +2445,47 @@ static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
if
(
!
(
xor
=
hlsl_new_binary_expr
(
ctx
,
HLSL_OP2_BIT_XOR
,
arg1
,
arg2
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
xor
->
entry
);
hlsl_block_add_instr
(
block
,
xor
);
for
(
i
=
0
;
i
<
type
->
dimx
;
++
i
)
high_bit_value
.
u
[
i
].
u
=
0x80000000
;
if
(
!
(
high_bit
=
hlsl_new_constant
(
ctx
,
type
,
&
high_bit_value
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
high_bit
->
entry
);
hlsl_block_add_instr
(
block
,
high_bit
);
if
(
!
(
and
=
hlsl_new_binary_expr
(
ctx
,
HLSL_OP2_BIT_AND
,
xor
,
high_bit
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
and
->
entry
);
hlsl_block_add_instr
(
block
,
and
);
if
(
!
(
abs1
=
hlsl_new_unary_expr
(
ctx
,
HLSL_OP1_ABS
,
arg1
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
abs1
->
entry
);
hlsl_block_add_instr
(
block
,
abs1
);
if
(
!
(
cast1
=
hlsl_new_cast
(
ctx
,
abs1
,
utype
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
cast1
->
entry
);
hlsl_block_add_instr
(
block
,
cast1
);
if
(
!
(
abs2
=
hlsl_new_unary_expr
(
ctx
,
HLSL_OP1_ABS
,
arg2
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
abs2
->
entry
);
hlsl_block_add_instr
(
block
,
abs2
);
if
(
!
(
cast2
=
hlsl_new_cast
(
ctx
,
abs2
,
utype
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
cast2
->
entry
);
hlsl_block_add_instr
(
block
,
cast2
);
if
(
!
(
div
=
hlsl_new_binary_expr
(
ctx
,
HLSL_OP2_DIV
,
cast1
,
cast2
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
div
->
entry
);
hlsl_block_add_instr
(
block
,
div
);
if
(
!
(
cast3
=
hlsl_new_cast
(
ctx
,
div
,
type
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
cast3
->
entry
);
hlsl_block_add_instr
(
block
,
cast3
);
if
(
!
(
neg
=
hlsl_new_unary_expr
(
ctx
,
HLSL_OP1_NEG
,
cast3
,
&
instr
->
loc
)))
return
false
;
list_add_before
(
&
instr
->
entry
,
&
neg
->
entry
);
hlsl_block_add_instr
(
block
,
neg
);
if
(
!
(
cond
=
hlsl_add_conditional
(
ctx
,
&
instr
->
entry
,
and
,
neg
,
cast3
)))
return
false
;
hlsl_replace_node
(
instr
,
cond
);
return
true
;
return
hlsl_add_conditional
(
ctx
,
&
block
->
instrs
,
and
,
neg
,
cast3
);
}
static
bool
lower_int_modulus
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
...
...
@@ -4268,7 +4295,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
hlsl_transform_ir
(
ctx
,
lower_narrowing_casts
,
body
,
NULL
);
hlsl_transform_ir
(
ctx
,
lower_casts_to_bool
,
body
,
NULL
);
hlsl_transform_ir
(
ctx
,
lower_int_dot
,
body
,
NULL
);
hlsl_transform
_ir
(
ctx
,
lower_int_division
,
body
,
NULL
);
lower
_ir
(
ctx
,
lower_int_division
,
body
);
hlsl_transform_ir
(
ctx
,
lower_int_modulus
,
body
,
NULL
);
hlsl_transform_ir
(
ctx
,
lower_int_abs
,
body
,
NULL
);
hlsl_transform_ir
(
ctx
,
lower_float_modulus
,
body
,
NULL
);
...
...
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