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
f54797ba
Commit
f54797ba
authored
4 months ago
by
Shaun Ren
Committed by
Henri Verbeet
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Support discard for SM1.
parent
2a8c1b28
No related branches found
No related tags found
1 merge request
!1198
vkd3d-shader/hlsl: Support discard for SM1.
Pipeline
#33664
skipped
Changes
2
Pipelines
1
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/hlsl/discard.shader_test
+1
-1
1 addition, 1 deletion
tests/hlsl/discard.shader_test
with
43 additions
and
1 deletion
libs/vkd3d-shader/hlsl_codegen.c
+
42
−
0
View file @
f54797ba
...
...
@@ -4079,6 +4079,44 @@ static bool lower_discard_neg(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
return
true
;
}
static
bool
lower_discard_nz
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
{
struct
hlsl_ir_node
*
cond
,
*
cond_cast
,
*
abs
,
*
neg
;
struct
hlsl_type
*
float_type
;
struct
hlsl_ir_jump
*
jump
;
struct
hlsl_block
block
;
if
(
instr
->
type
!=
HLSL_IR_JUMP
)
return
false
;
jump
=
hlsl_ir_jump
(
instr
);
if
(
jump
->
type
!=
HLSL_IR_JUMP_DISCARD_NZ
)
return
false
;
cond
=
jump
->
condition
.
node
;
float_type
=
hlsl_get_vector_type
(
ctx
,
HLSL_TYPE_FLOAT
,
cond
->
data_type
->
dimx
);
hlsl_block_init
(
&
block
);
if
(
!
(
cond_cast
=
hlsl_new_cast
(
ctx
,
cond
,
float_type
,
&
instr
->
loc
)))
return
false
;
hlsl_block_add_instr
(
&
block
,
cond_cast
);
if
(
!
(
abs
=
hlsl_new_unary_expr
(
ctx
,
HLSL_OP1_ABS
,
cond_cast
,
&
instr
->
loc
)))
return
false
;
hlsl_block_add_instr
(
&
block
,
abs
);
if
(
!
(
neg
=
hlsl_new_unary_expr
(
ctx
,
HLSL_OP1_NEG
,
abs
,
&
instr
->
loc
)))
return
false
;
hlsl_block_add_instr
(
&
block
,
neg
);
list_move_tail
(
&
instr
->
entry
,
&
block
.
instrs
);
hlsl_src_remove
(
&
jump
->
condition
);
hlsl_src_from_node
(
&
jump
->
condition
,
neg
);
jump
->
type
=
HLSL_IR_JUMP_DISCARD_NEG
;
return
true
;
}
static
bool
dce
(
struct
hlsl_ctx
*
ctx
,
struct
hlsl_ir_node
*
instr
,
void
*
context
)
{
switch
(
instr
->
type
)
...
...
@@ -7903,6 +7941,10 @@ static void process_entry_function(struct hlsl_ctx *ctx,
{
hlsl_transform_ir
(
ctx
,
lower_discard_neg
,
body
,
NULL
);
}
else
{
hlsl_transform_ir
(
ctx
,
lower_discard_nz
,
body
,
NULL
);
}
transform_unroll_loops
(
ctx
,
body
);
hlsl_run_const_passes
(
ctx
,
body
);
...
...
This diff is collapsed.
Click to expand it.
tests/hlsl/discard.shader_test
+
1
−
1
View file @
f54797ba
...
...
@@ -21,7 +21,7 @@ shader model >= 3.0
% Check that derivatives are still computed after discarding
% other pixels in the same quad
[pixel shader
todo(sm<4)
]
[pixel shader]
float4 main(float4 pos : sv_position) : sv_target
{
if (frac((floor(pos.x) + floor(pos.y)) / 2) == 0.5)
...
...
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