nir: Add a conversion and rounding intrinsic

This new intrinsic is capable of handling the full range of conversions
from OpenCL including rounding modes and possible saturation.  The
intention is that we'll emit this intrinsic directly from spirv_to_nir
and then lower it to ALU ops later.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6945>
This commit is contained in:
Jason Ekstrand
2020-09-30 15:19:45 -05:00
committed by Marge Bot
parent 0aa08ae2f6
commit 588bb6686b
5 changed files with 73 additions and 4 deletions

View File

@@ -124,9 +124,9 @@ ALIGN_MUL = "NIR_INTRINSIC_ALIGN_MUL"
ALIGN_OFFSET = "NIR_INTRINSIC_ALIGN_OFFSET"
# The vulkan descriptor type for vulkan_resource_index
DESC_TYPE = "NIR_INTRINSIC_DESC_TYPE"
# The nir_alu_type of input data to a store
# The nir_alu_type of input data to a store or conversion
SRC_TYPE = "NIR_INTRINSIC_SRC_TYPE"
# The nir_alu_type of the data output from a load
# The nir_alu_type of the data output from a load or conversion
DEST_TYPE = "NIR_INTRINSIC_DEST_TYPE"
# The swizzle mask for quad_swizzle_amd & masked_swizzle_amd
SWIZZLE_MASK = "NIR_INTRINSIC_SWIZZLE_MASK"
@@ -141,6 +141,10 @@ MEMORY_SCOPE = "NIR_INTRINSIC_MEMORY_SCOPE"
# Scope of a control barrier
EXECUTION_SCOPE = "NIR_INTRINSIC_EXECUTION_SCOPE"
IO_SEMANTICS = "NIR_INTRINSIC_IO_SEMANTICS"
# Rounding mode for conversions
ROUNDING_MODE = "NIR_INTRINSIC_ROUNDING_MODE"
# Whether or not to saturate in conversions
SATURATE = "NIR_INTRINSIC_SATURATE"
#
# Possible flags:
@@ -170,6 +174,10 @@ def intrinsic(name, src_comp=[], dest_comp=-1, indices=[],
intrinsic("nop", flags=[CAN_ELIMINATE])
intrinsic("convert_alu_types", dest_comp=0, src_comp=[0],
indices=[SRC_TYPE, DEST_TYPE, ROUNDING_MODE, SATURATE],
flags=[CAN_ELIMINATE, CAN_REORDER])
intrinsic("load_param", dest_comp=0, indices=[PARAM_IDX], flags=[CAN_ELIMINATE])
intrinsic("load_deref", dest_comp=0, src_comp=[-1],