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
a950d64a
Commit
a950d64a
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
nir/spirv: Use image type instead of format for load/store intrinsics
parent
3862bd9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
39 deletions
+14
-39
src/compiler/nir/nir_intrinsics.py
src/compiler/nir/nir_intrinsics.py
+10
-11
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/spirv_to_nir.c
+4
-28
No files found.
src/compiler/nir/nir_intrinsics.py
View file @
a950d64a
...
...
@@ -374,11 +374,10 @@ atomic3("atomic_counter_comp_swap")
# All image intrinsics come in three versions. One which take an image target
# passed as a deref chain as the first source, one which takes an index as the
# first source, and one which takes a bindless handle as the first source.
# In the first version, the image variable likely contains the memory and layout
# qualifiers that influence the semantics of the intrinsic. However, for OpenCL
# images, the image variable doesn't contain format information, so it can be
# provided in the intrinsic as well. In the second and third, the image format
# and access qualifiers are provided as constant indices.
# In the first version, the image variable contains the memory and layout
# qualifiers that influence the semantics of the intrinsic. In the second and
# third, the image format and access qualifiers are provided as constant
# indices.
#
# All image intrinsics take a four-coordinate vector and a sample index as
# 2nd and 3rd sources, determining the location within the image that will be
...
...
@@ -387,16 +386,16 @@ atomic3("atomic_counter_comp_swap")
# argument with the value to be written, and image atomic operations take
# either one or two additional scalar arguments with the same meaning as in
# the ARB_shader_image_load_store specification.
def
image
(
name
,
src_comp
=
[],
deref
_indices
=
[],
**
kwargs
):
def
image
(
name
,
src_comp
=
[],
extra
_indices
=
[],
**
kwargs
):
intrinsic
(
"image_deref_"
+
name
,
src_comp
=
[
1
]
+
src_comp
,
indices
=
[
ACCESS
]
+
deref
_indices
,
**
kwargs
)
indices
=
[
ACCESS
]
+
extra
_indices
,
**
kwargs
)
intrinsic
(
"image_"
+
name
,
src_comp
=
[
1
]
+
src_comp
,
indices
=
[
IMAGE_DIM
,
IMAGE_ARRAY
,
FORMAT
,
ACCESS
],
**
kwargs
)
indices
=
[
IMAGE_DIM
,
IMAGE_ARRAY
,
FORMAT
,
ACCESS
]
+
extra_indices
,
**
kwargs
)
intrinsic
(
"bindless_image_"
+
name
,
src_comp
=
[
1
]
+
src_comp
,
indices
=
[
IMAGE_DIM
,
IMAGE_ARRAY
,
FORMAT
,
ACCESS
],
**
kwargs
)
indices
=
[
IMAGE_DIM
,
IMAGE_ARRAY
,
FORMAT
,
ACCESS
]
+
extra_indices
,
**
kwargs
)
image
(
"load"
,
src_comp
=
[
4
,
1
,
1
],
deref
_indices
=
[
FORMAT
],
dest_comp
=
0
,
flags
=
[
CAN_ELIMINATE
])
image
(
"store"
,
src_comp
=
[
4
,
1
,
0
,
1
],
deref
_indices
=
[
FORMAT
])
image
(
"load"
,
src_comp
=
[
4
,
1
,
1
],
extra
_indices
=
[
TYPE
],
dest_comp
=
0
,
flags
=
[
CAN_ELIMINATE
])
image
(
"store"
,
src_comp
=
[
4
,
1
,
0
,
1
],
extra
_indices
=
[
TYPE
])
image
(
"atomic_add"
,
src_comp
=
[
4
,
1
,
1
],
dest_comp
=
1
)
image
(
"atomic_imin"
,
src_comp
=
[
4
,
1
,
1
],
dest_comp
=
1
)
image
(
"atomic_umin"
,
src_comp
=
[
4
,
1
,
1
],
dest_comp
=
1
)
...
...
src/compiler/spirv/spirv_to_nir.c
View file @
a950d64a
...
...
@@ -3118,20 +3118,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
*/
intrin
->
src
[
4
]
=
nir_src_for_ssa
(
image
.
lod
);
if
(
opcode
==
SpvOpImageWrite
)
{
/* Add type info to the intrinsic for storing to untyped OpenCL images */
enum
pipe_format
format
=
vtn_get_value_type
(
b
,
w
[
1
])
->
image_format
;
if
(
format
==
PIPE_FORMAT_NONE
)
{
switch
(
glsl_get_base_type
(
value
->
type
))
{
case
GLSL_TYPE_INT
:
format
=
PIPE_FORMAT_R32G32B32A32_SINT
;
break
;
case
GLSL_TYPE_UINT
:
format
=
PIPE_FORMAT_R32G32B32A32_SINT
;
break
;
case
GLSL_TYPE_FLOAT
:
format
=
PIPE_FORMAT_R32G32B32A32_FLOAT
;
break
;
case
GLSL_TYPE_FLOAT16
:
format
=
PIPE_FORMAT_R16G16B16A16_FLOAT
;
break
;
default:
unreachable
(
"unexpected format"
);
}
}
nir_intrinsic_set_format
(
intrin
,
format
);
}
if
(
opcode
==
SpvOpImageWrite
)
nir_intrinsic_set_type
(
intrin
,
nir_get_nir_type_for_glsl_type
(
value
->
type
));
break
;
}
...
...
@@ -3196,20 +3184,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
vtn_push_nir_ssa
(
b
,
w
[
2
],
result
);
if
(
opcode
==
SpvOpImageRead
)
{
/* Add type info to the intrinsic for reading from OpenCL images */
enum
pipe_format
format
=
vtn_get_value_type
(
b
,
w
[
1
])
->
image_format
;
if
(
format
==
PIPE_FORMAT_NONE
)
{
switch
(
glsl_get_base_type
(
type
->
type
))
{
case
GLSL_TYPE_INT
:
format
=
PIPE_FORMAT_R32G32B32A32_SINT
;
break
;
case
GLSL_TYPE_UINT
:
format
=
PIPE_FORMAT_R32G32B32A32_SINT
;
break
;
case
GLSL_TYPE_FLOAT
:
format
=
PIPE_FORMAT_R32G32B32A32_FLOAT
;
break
;
case
GLSL_TYPE_FLOAT16
:
format
=
PIPE_FORMAT_R16G16B16A16_FLOAT
;
break
;
default:
unreachable
(
"unexpected format"
);
}
}
nir_intrinsic_set_format
(
intrin
,
format
);
}
if
(
opcode
==
SpvOpImageRead
)
nir_intrinsic_set_type
(
intrin
,
nir_get_nir_type_for_glsl_type
(
type
->
type
));
}
else
{
nir_builder_instr_insert
(
&
b
->
nb
,
&
intrin
->
instr
);
}
...
...
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