gallium: add threads per block TGSI property
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 28 Mar 2016 00:40:03 +0000 (02:40 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 1 Apr 2016 23:50:59 +0000 (01:50 +0200)
The value 0 for unknown has been chosen to so that
drivers using tgsi_scan_shader do not need to detect
missing properties if they zero-initialize the struct.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/gallium/docs/source/tgsi.rst
src/gallium/include/pipe/p_shader_tokens.h
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index ae779a8320a5d7852cb93b6498ef5a99ddc8daa0..d613f5e8cfb187ae5e2d8ced8fe9faf84726d724 100644 (file)
@@ -146,6 +146,9 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
    "NUM_CULLDIST_ENABLED",
    "FS_EARLY_DEPTH_STENCIL",
    "NEXT_SHADER",
+   "CS_FIXED_BLOCK_WIDTH",
+   "CS_FIXED_BLOCK_HEIGHT",
+   "CS_FIXED_BLOCK_DEPTH"
 };
 
 const char *tgsi_return_type_names[TGSI_RETURN_TYPE_COUNT] =
index 3ac6ba3c25a209046bd2d4497bf98a49fe6f9fff..ac6052a244a974163397b96239645cffdd1cdf63 100644 (file)
@@ -3220,6 +3220,12 @@ Which shader stage will MOST LIKELY follow after this shader when the shader
 is bound. This is only a hint to the driver and doesn't have to be precise.
 Only set for VS and TES.
 
+TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH / HEIGHT / DEPTH
+"""""""""""""""""""""""""""""""""""""""""""""""""""
+
+Threads per block in each dimension, if known at compile time. If the block size
+is known all three should be at least 1. If it is unknown they should all be set
+to 0 or not set.
 
 Texture Sampling and Texture Formats
 ------------------------------------
index 5cc18a293d3538eb611b0572c10b17c9138a4ef9..c25786e871e947e2746a96cb47d7ef6d339b42c3 100644 (file)
@@ -276,7 +276,10 @@ union tgsi_immediate_data
 #define TGSI_PROPERTY_NUM_CULLDIST_ENABLED   16
 #define TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL 17
 #define TGSI_PROPERTY_NEXT_SHADER            18
-#define TGSI_PROPERTY_COUNT                  19
+#define TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH   19
+#define TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT  20
+#define TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH   21
+#define TGSI_PROPERTY_COUNT                  22
 
 struct tgsi_property {
    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
index 23786b855294706f96e409fb3db9c8985936f75b..cd481c166e70d6285776112061961a96c6d53e1c 100644 (file)
@@ -5935,6 +5935,20 @@ find_array(unsigned attr, struct array_decl *arrays, unsigned count,
    return false;
 }
 
+static void
+emit_compute_block_size(const struct gl_program *program,
+                        struct ureg_program *ureg) {
+   const struct gl_compute_program *cp =
+      (const struct gl_compute_program *)program;
+
+   ureg_property(ureg, TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH,
+                       cp->LocalSize[0]);
+   ureg_property(ureg, TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT,
+                       cp->LocalSize[1]);
+   ureg_property(ureg, TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH,
+                       cp->LocalSize[2]);
+}
+
 /**
  * Translate intermediate IR (glsl_to_tgsi_instruction) to TGSI format.
  * \param program  the program to translate
@@ -6180,6 +6194,10 @@ st_translate_program(
       }
    }
 
+   if (procType == TGSI_PROCESSOR_COMPUTE) {
+      emit_compute_block_size(proginfo, ureg);
+   }
+
    /* Declare address register.
     */
    if (program->num_address_regs > 0) {