Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Erik Faye-Lund
mesa
Commits
181afca5
Commit
181afca5
authored
Aug 20, 2020
by
Jesse Natalie
Committed by
Erik Faye-Lund
Oct 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
microsoft/clc: Use image type instead of format for image load/store lowering
parent
59d40ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
44 deletions
+18
-44
src/microsoft/clc/clc_compiler.c
src/microsoft/clc/clc_compiler.c
+18
-44
No files found.
src/microsoft/clc/clc_compiler.c
View file @
181afca5
...
...
@@ -98,30 +98,6 @@ clc_print_kernels_info(const struct clc_object *obj)
}
}
static
enum
glsl_base_type
glsl_base_type_for_image_pipe_format
(
enum
pipe_format
format
)
{
switch
(
format
)
{
case
PIPE_FORMAT_R32G32B32A32_FLOAT
:
return
GLSL_TYPE_FLOAT
;
case
PIPE_FORMAT_R16G16B16A16_FLOAT
:
return
GLSL_TYPE_FLOAT16
;
case
PIPE_FORMAT_R32G32B32A32_SINT
:
return
GLSL_TYPE_INT
;
case
PIPE_FORMAT_R32G32B32A32_UINT
:
return
GLSL_TYPE_UINT
;
default:
unreachable
(
"Unexpected image format"
);
}
}
static
enum
pipe_format
pipe_format_for_nir_format
(
enum
nir_alu_type
format
)
{
switch
(
format
)
{
case
nir_type_float
:
return
PIPE_FORMAT_R32G32B32A32_FLOAT
;
case
nir_type_float16
:
return
PIPE_FORMAT_R16G16B16A16_FLOAT
;
case
nir_type_int
:
return
PIPE_FORMAT_R32G32B32A32_SINT
;
case
nir_type_uint
:
return
PIPE_FORMAT_R32G32B32A32_UINT
;
default:
unreachable
(
"Unexpected nir format"
);
}
}
struct
clc_image_lower_context
{
struct
clc_dxil_metadata
*
metadata
;
...
...
@@ -135,12 +111,11 @@ struct clc_image_lower_context
static
nir_ssa_def
*
lower_image_deref_impl
(
nir_builder
*
b
,
struct
clc_image_lower_context
*
context
,
const
struct
glsl_type
*
new_var_type
,
unsigned
*
num_bindings
,
enum
pipe_format
image_format
)
unsigned
*
num_bindings
)
{
nir_variable
*
in_var
=
nir_deref_instr_get_variable
(
context
->
deref
);
nir_variable
*
uniform
=
nir_variable_create
(
b
->
shader
,
nir_var_uniform
,
new_var_type
,
NULL
);
uniform
->
data
.
access
=
in_var
->
data
.
access
;
uniform
->
data
.
image
.
format
=
image_format
;
uniform
->
data
.
binding
=
in_var
->
data
.
binding
;
if
(
context
->
num_buf_ids
>
0
)
{
// Need to assign a new binding
...
...
@@ -156,7 +131,7 @@ lower_image_deref_impl(nir_builder *b, struct clc_image_lower_context *context,
static
nir_ssa_def
*
lower_read_only_image_deref
(
nir_builder
*
b
,
struct
clc_image_lower_context
*
context
,
enum
pipe_format
image_
format
)
nir_alu_type
image_
type
)
{
nir_variable
*
in_var
=
nir_deref_instr_get_variable
(
context
->
deref
);
...
...
@@ -165,20 +140,20 @@ lower_read_only_image_deref(nir_builder *b, struct clc_image_lower_context *cont
const
struct
glsl_type
*
new_var_type
=
glsl_sampler_type
(
glsl_get_sampler_dim
(
in_var
->
type
),
false
,
glsl_sampler_type_is_array
(
in_var
->
type
),
glsl_base_type_for_
image_pipe_format
(
image_
format
));
return
lower_image_deref_impl
(
b
,
context
,
new_var_type
,
context
->
num_srvs
,
image_format
);
nir_get_
glsl_base_type_for_
nir_type
(
image_
type
));
return
lower_image_deref_impl
(
b
,
context
,
new_var_type
,
context
->
num_srvs
);
}
static
nir_ssa_def
*
lower_read_write_image_deref
(
nir_builder
*
b
,
struct
clc_image_lower_context
*
context
,
enum
pipe_format
image_
format
)
nir_alu_type
image_
type
)
{
nir_variable
*
in_var
=
nir_deref_instr_get_variable
(
context
->
deref
);
const
struct
glsl_type
*
new_var_type
=
glsl_image_type
(
glsl_get_sampler_dim
(
in_var
->
type
),
glsl_sampler_type_is_array
(
in_var
->
type
),
glsl_base_type_for_
image_pipe_format
(
image_
format
));
return
lower_image_deref_impl
(
b
,
context
,
new_var_type
,
context
->
num_uavs
,
image_format
);
nir_get_
glsl_base_type_for_
nir_type
(
image_
type
));
return
lower_image_deref_impl
(
b
,
context
,
new_var_type
,
context
->
num_uavs
);
}
static
void
...
...
@@ -230,22 +205,22 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
switch
(
intrinsic
->
intrinsic
)
{
case
nir_intrinsic_image_deref_load
:
case
nir_intrinsic_image_deref_store
:
{
enum
pipe_format
intr_format
=
nir_intrinsic_
format
(
intrinsic
);
dest_type
=
nir_intrinsic_
type
(
intrinsic
);
switch
(
intr_format
)
{
case
PIPE_FORMAT_R32G32B32A32_FLOAT
:
type
=
FLOAT4
;
dest_type
=
nir_type_float
;
break
;
case
PIPE_FORMAT_R32G32B32A32_SINT
:
type
=
INT4
;
dest_type
=
nir_type_int
;
break
;
case
PIPE_FORMAT_R32G32B32A32_UINT
:
type
=
UINT4
;
dest_type
=
nir_type_uint
;
break
;
default:
unreachable
(
"Unsupported image
format
for load."
);
switch
(
nir_alu_type_get_base_type
(
dest_type
)
)
{
case
nir_type_float
:
type
=
FLOAT4
;
break
;
case
nir_type_int
:
type
=
INT4
;
break
;
case
nir_type_uint
:
type
=
UINT4
;
break
;
default:
unreachable
(
"Unsupported image
type
for load."
);
}
nir_ssa_def
*
image_deref
=
uniform_deref_dests
[
type
];
if
(
!
image_deref
)
{
const
struct
glsl_type
*
new_var_type
;
if
(
in_var
->
data
.
access
&
ACCESS_NON_WRITEABLE
)
{
image_deref
=
lower_read_only_image_deref
(
b
,
context
,
intr_format
);
image_deref
=
lower_read_only_image_deref
(
b
,
context
,
dest_type
);
}
else
{
image_deref
=
lower_read_write_image_deref
(
b
,
context
,
intr_format
);
image_deref
=
lower_read_write_image_deref
(
b
,
context
,
dest_type
);
}
uniform_deref_dests
[
type
]
=
image_deref
;
...
...
@@ -302,9 +277,9 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
type
=
FLOAT4
;
const
struct
glsl_type
*
new_var_type
;
if
(
in_var
->
data
.
access
&
ACCESS_NON_WRITEABLE
)
{
image_deref
=
lower_read_only_image_deref
(
b
,
context
,
PIPE_FORMAT_R32G32B32A32_FLOAT
);
image_deref
=
lower_read_only_image_deref
(
b
,
context
,
nir_type_float32
);
}
else
{
image_deref
=
lower_read_write_image_deref
(
b
,
context
,
PIPE_FORMAT_R32G32B32A32_FLOAT
);
image_deref
=
lower_read_write_image_deref
(
b
,
context
,
nir_type_float32
);
}
uniform_deref_dests
[
type
]
=
image_deref
;
...
...
@@ -375,9 +350,8 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
nir_ssa_def
*
image_deref
=
uniform_deref_dests
[
type
];
if
(
!
image_deref
)
{
enum
pipe_format
image_format
=
pipe_format_for_nir_format
(
tex
->
dest_type
);
image_deref
=
uniform_deref_dests
[
type
]
=
lower_read_only_image_deref
(
b
,
context
,
image_format
);
lower_read_only_image_deref
(
b
,
context
,
tex
->
dest_type
);
}
nir_src
uniform_src
=
nir_src_for_ssa
(
image_deref
);
...
...
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