diff options
Diffstat (limited to 'src/compiler/nir/nir_intrinsics.py')
-rw-r--r-- | src/compiler/nir/nir_intrinsics.py | 83 |
1 files changed, 4 insertions, 79 deletions
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 785441c6682..d9d0bbdfccf 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -31,7 +31,7 @@ class Intrinsic(object): """Class that represents all the information about an intrinsic opcode. NOTE: this must be kept in sync with nir_intrinsic_info. """ - def __init__(self, name, src_components, dest_components, num_variables, + def __init__(self, name, src_components, dest_components, indices, flags, sysval): """Parameters: @@ -42,7 +42,6 @@ class Intrinsic(object): - dest_components: number of destination components, -1 means no dest, 0 means number of components given in num_components field in nir_intrinsic_instr. - - num_variables: the number of variables - indices: list of constant indicies - flags: list of semantic flags - sysval: is this a system-value intrinsic @@ -52,7 +51,6 @@ class Intrinsic(object): if src_components: assert isinstance(src_components[0], int) assert isinstance(dest_components, int) - assert isinstance(num_variables, int) assert isinstance(indices, list) if indices: assert isinstance(indices[0], str) @@ -66,7 +64,6 @@ class Intrinsic(object): self.src_components = src_components self.has_dest = (dest_components >= 0) self.dest_components = dest_components - self.num_variables = num_variables self.num_indices = len(indices) self.indices = indices self.flags = flags @@ -114,37 +111,20 @@ CAN_REORDER = "NIR_INTRINSIC_CAN_REORDER" INTR_OPCODES = {} -def intrinsic(name, src_comp=[], dest_comp=-1, num_vars=0, indices=[], +def intrinsic(name, src_comp=[], dest_comp=-1, indices=[], flags=[], sysval=False): assert name not in INTR_OPCODES - INTR_OPCODES[name] = Intrinsic(name, src_comp, dest_comp, num_vars, + INTR_OPCODES[name] = Intrinsic(name, src_comp, dest_comp, indices, flags, sysval) intrinsic("nop", flags=[CAN_ELIMINATE]) intrinsic("load_param", dest_comp=0, indices=[PARAM_IDX], flags=[CAN_ELIMINATE]) -intrinsic("load_var", dest_comp=0, num_vars=1, flags=[CAN_ELIMINATE]) -intrinsic("store_var", src_comp=[0], num_vars=1, indices=[WRMASK]) -intrinsic("copy_var", num_vars=2) - intrinsic("load_deref", dest_comp=0, src_comp=[1], flags=[CAN_ELIMINATE]) intrinsic("store_deref", src_comp=[1, 0], indices=[WRMASK]) intrinsic("copy_deref", src_comp=[1, 1]) -# Interpolation of input. The interp_var_at* intrinsics are similar to the -# load_var intrinsic acting on a shader input except that they interpolate -# the input differently. The at_sample and at_offset intrinsics take an -# additional source that is an integer sample id or a vec2 position offset -# respectively. - -intrinsic("interp_var_at_centroid", dest_comp=0, num_vars=1, - flags=[ CAN_ELIMINATE, CAN_REORDER]) -intrinsic("interp_var_at_sample", src_comp=[1], dest_comp=0, num_vars=1, - flags=[CAN_ELIMINATE, CAN_REORDER]) -intrinsic("interp_var_at_offset", src_comp=[2], dest_comp=0, num_vars=1, - flags=[CAN_ELIMINATE, CAN_REORDER]) - # Interpolation of input. The interp_deref_at* intrinsics are similar to the # load_var intrinsic acting on a shader input except that they interpolate the # input differently. The at_sample and at_offset intrinsics take an @@ -278,17 +258,14 @@ intrinsic("set_vertex_count", src_comp=[1]) # lowered, variants take a constant buffer index and register offset. def atomic(name, flags=[]): - intrinsic(name + "_var", dest_comp=1, num_vars=1, flags=flags) intrinsic(name + "_deref", src_comp=[1], dest_comp=1, flags=flags) intrinsic(name, src_comp=[1], dest_comp=1, indices=[BASE], flags=flags) def atomic2(name): - intrinsic(name + "_var", src_comp=[1], dest_comp=1, num_vars=1) intrinsic(name + "_deref", src_comp=[1, 1], dest_comp=1) intrinsic(name, src_comp=[1, 1], dest_comp=1, indices=[BASE]) def atomic3(name): - intrinsic(name + "_var", src_comp=[1, 1], dest_comp=1, num_vars=1) intrinsic(name + "_deref", src_comp=[1, 1, 1], dest_comp=1) intrinsic(name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE]) @@ -306,33 +283,6 @@ atomic3("atomic_counter_comp_swap") # Image load, store and atomic intrinsics. # -# All image intrinsics take an image target passed as a nir_variable. Image -# variables contain a number of memory and layout qualifiers that influence -# the semantics of the intrinsic. -# -# All image intrinsics take a four-coordinate vector and a sample index as -# first two sources, determining the location within the image that will be -# accessed by the intrinsic. Components not applicable to the image target -# in use are undefined. Image store takes an additional four-component -# 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. -intrinsic("image_var_load", src_comp=[4, 1], dest_comp=4, num_vars=1, - flags=[CAN_ELIMINATE]) -intrinsic("image_var_store", src_comp=[4, 1, 4], num_vars=1) -intrinsic("image_var_atomic_add", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_min", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_max", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_and", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_or", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_xor", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_exchange", src_comp=[4, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_atomic_comp_swap", src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1) -intrinsic("image_var_size", dest_comp=0, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER]) -intrinsic("image_var_samples", dest_comp=1, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER]) - -# Image load, store and atomic intrinsics. -# # All image intrinsics take an image target passed as a nir_variable. The # variable is passed in using a chain of nir_deref_instr with as the first # source of the image intrinsic. Image variables contain a number of memory @@ -389,31 +339,6 @@ intrinsic("vulkan_resource_reindex", src_comp=[1, 1], dest_comp=1, # compute a new value using one of the operations below, write the new value # to memory, and return the original value read. # -# All operations take 1 source except CompSwap that takes 2. These sources -# represent: -# -# 0: The data parameter to the atomic function (i.e. the value to add -# in shared_atomic_add, etc). -# 1: For CompSwap only: the second data parameter. -# -# All operations take 1 variable deref. -intrinsic("var_atomic_add", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_imin", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_umin", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_imax", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_umax", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_and", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_or", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_xor", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_exchange", src_comp=[1], dest_comp=1, num_vars=1) -intrinsic("var_atomic_comp_swap", src_comp=[1, 1], dest_comp=1, num_vars=1) - -# variable atomic intrinsics -# -# All of these variable atomic memory operations read a value from memory, -# compute a new value using one of the operations below, write the new value -# to memory, and return the original value read. -# # All operations take 2 sources except CompSwap that takes 3. These sources # represent: # @@ -484,7 +409,7 @@ intrinsic("shared_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE] intrinsic("shared_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE]) def system_value(name, dest_comp, indices=[]): - intrinsic("load_" + name, [], dest_comp, 0, indices, + intrinsic("load_" + name, [], dest_comp, indices, flags=[CAN_ELIMINATE, CAN_REORDER], sysval=True) system_value("frag_coord", 4) |