nir: Add intrinsic and string ptrs
authorJesse Natalie <jenatali@microsoft.com>
Sun, 21 Jun 2020 21:35:29 +0000 (14:35 -0700)
committerDave Airlie <airlied@redhat.com>
Mon, 28 Dec 2020 23:07:23 +0000 (09:07 +1000)
This just adds the basic nir support for printf,
intrinsic, and support for storing the printf info.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>

src/compiler/nir/nir.h
src/compiler/nir/nir_intrinsics.py

index 33ddfb0..33732db 100644 (file)
@@ -3010,6 +3010,13 @@ typedef struct {
    uint8_t bit_size;
 } nir_parameter;
 
+typedef struct nir_printf_info {
+   unsigned num_args;
+   unsigned *arg_sizes;
+   unsigned string_size;
+   char *strings;
+} nir_printf_info;
+
 typedef struct nir_function {
    struct exec_node node;
 
@@ -3407,6 +3414,9 @@ typedef struct nir_shader {
    void *constant_data;
    /** Size of the constant data associated with the shader, in bytes */
    unsigned constant_data_size;
+
+   unsigned printf_info_count;
+   nir_printf_info *printf_info;
 } nir_shader;
 
 #define nir_foreach_function(func, shader) \
index f1626bb..9406fcb 100644 (file)
@@ -952,6 +952,12 @@ store("scratch", [1], [ALIGN_MUL, ALIGN_OFFSET, WRITE_MASK])
 intrinsic("load_frag_shading_rate", dest_comp=1, bit_sizes=[32],
           flags=[CAN_ELIMINATE, CAN_REORDER])
 
+# OpenCL printf instruction
+# First source is a deref to the format string
+# Second source is a deref to a struct containing the args
+# Dest is success or failure
+intrinsic("printf", src_comp=[1, 1], dest_comp=1, bit_sizes=[32])
+
 # IR3-specific version of most SSBO intrinsics. The only different
 # compare to the originals is that they add an extra source to hold
 # the dword-offset, which is needed by the backend code apart from