Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Faye-Lund
mesa
Commits
6d03a7f8
Commit
6d03a7f8
authored
Aug 28, 2020
by
Jesse Natalie
Committed by
Erik Faye-Lund
Oct 28, 2020
Browse files
microsoft/clc: Deal with kernel inputs as uniforms instead of shader_in
parent
80351602
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/microsoft/clc/clc_compiler.c
View file @
6d03a7f8
...
...
@@ -360,44 +360,6 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
static
void
clc_lower_images
(
nir_shader
*
nir
,
struct
clc_image_lower_context
*
context
)
{
/* We'll do this in three steps:
* 1. Change the deref mode for derefs of images/samplers to uniform.
* 2. Run nir_opt_deref to remove casts, now that the deref modes match
* 3. We should have unbroken deref chains from variables to their loads/stores,
* so follow those chains and adjust the variables to something saner.
*/
nir_foreach_function
(
func
,
nir
)
{
if
(
!
func
->
is_entrypoint
)
continue
;
assert
(
func
->
impl
);
nir_builder
b
;
nir_builder_init
(
&
b
,
func
->
impl
);
nir_foreach_block
(
block
,
func
->
impl
)
{
nir_foreach_instr_safe
(
instr
,
block
)
{
if
(
instr
->
type
==
nir_instr_type_deref
)
{
context
->
deref
=
nir_instr_as_deref
(
instr
);
if
(
context
->
deref
->
mode
==
nir_var_shader_in
&&
(
glsl_type_is_image
(
context
->
deref
->
type
)
||
glsl_type_is_sampler
(
context
->
deref
->
type
)))
{
assert
(
context
->
deref
->
deref_type
==
nir_deref_type_var
);
context
->
deref
->
mode
=
nir_var_uniform
;
nir_variable
*
var
=
nir_deref_instr_get_variable
(
context
->
deref
);
var
->
data
.
mode
=
nir_var_uniform
;
exec_node_remove
(
&
var
->
node
);
nir_shader_add_variable
(
nir
,
var
);
}
}
}
}
}
nir_opt_deref
(
nir
);
nir_foreach_function
(
func
,
nir
)
{
if
(
!
func
->
is_entrypoint
)
continue
;
...
...
@@ -1267,7 +1229,7 @@ clc_to_dxil(struct clc_context *ctx,
// Calculate input offsets/metadata.
unsigned
uav_id
=
0
,
sampler_id
=
0
,
offset
=
0
;
dxil_wrap_sampler_state
int_sampler_states
[
PIPE_MAX_SHADER_SAMPLER_VIEWS
]
=
{{{
0
}}};
nir_foreach_variable
(
var
,
&
nir
->
input
s
)
{
nir_foreach_variable
(
var
,
&
nir
->
uniform
s
)
{
int
i
=
var
->
data
.
location
;
if
(
i
<
0
)
continue
;
...
...
@@ -1301,7 +1263,7 @@ clc_to_dxil(struct clc_context *ctx,
// Second pass over inputs to calculate image bindings
unsigned
srv_id
=
0
;
nir_foreach_variable
(
var
,
&
nir
->
input
s
)
{
nir_foreach_variable
(
var
,
&
nir
->
uniform
s
)
{
int
i
=
var
->
data
.
location
;
if
(
i
<
0
)
continue
;
...
...
@@ -1418,6 +1380,7 @@ clc_to_dxil(struct clc_context *ctx,
NIR_PASS_V
(
nir
,
nir_lower_vars_to_ssa
);
NIR_PASS_V
(
nir
,
nir_lower_alu
);
NIR_PASS_V
(
nir
,
nir_opt_dce
);
NIR_PASS_V
(
nir
,
nir_opt_deref
);
// Needs to come before lower_explicit_io
struct
clc_image_lower_context
image_lower_context
=
{
metadata
,
&
srv_id
,
&
uav_id
};
...
...
@@ -1431,7 +1394,7 @@ clc_to_dxil(struct clc_context *ctx,
assert
(
nir
->
scratch_size
==
0
);
NIR_PASS_V
(
nir
,
nir_lower_vars_to_explicit_types
,
nir_var_mem_shared
|
nir_var_function_temp
|
nir_var_
shader_in
|
nir_var_mem_global
|
nir_var_mem_constant
,
nir_var_mem_shared
|
nir_var_function_temp
|
nir_var_
uniform
|
nir_var_mem_global
|
nir_var_mem_constant
,
glsl_get_cl_type_size_align
);
NIR_PASS_V
(
nir
,
dxil_nir_lower_ubo_to_temp
);
...
...
@@ -1445,7 +1408,7 @@ clc_to_dxil(struct clc_context *ctx,
NIR_PASS_V
(
nir
,
nir_lower_explicit_io
,
nir_var_mem_ssbo
,
nir_address_format_32bit_index_offset_pack64
);
NIR_PASS_V
(
nir
,
nir_lower_explicit_io
,
nir_var_mem_shared
|
nir_var_function_temp
|
nir_var_
shader_in
,
nir_var_mem_shared
|
nir_var_function_temp
|
nir_var_
uniform
,
nir_address_format_32bit_offset_as_64bit
);
NIR_PASS_V
(
nir
,
nir_lower_system_values
);
...
...
src/microsoft/clc/clc_nir.c
View file @
6d03a7f8
...
...
@@ -396,8 +396,7 @@ clc_nir_dedupe_const_samplers(nir_shader *nir)
if
(
!
sampler
)
continue
;
assert
(
sampler
->
data
.
mode
==
nir_var_shader_in
||
(
sampler
->
data
.
mode
==
nir_var_uniform
&&
sampler
->
data
.
sampler
.
is_inline_sampler
));
assert
(
sampler
->
data
.
mode
==
nir_var_uniform
);
if
(
!
sampler
->
data
.
sampler
.
is_inline_sampler
)
continue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment