From: Marek Olšák <marek.ol...@amd.com> --- src/gallium/auxiliary/tgsi/tgsi_scan.c | 47 ++++++++++++++++++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_scan.h | 4 +++ 2 files changed, 51 insertions(+)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index bf614db..885a60d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -108,20 +108,67 @@ static void scan_src_operand(struct tgsi_shader_info *info, const struct tgsi_full_instruction *fullinst, const struct tgsi_full_src_register *src, unsigned src_index, unsigned usage_mask, bool is_interp_instruction, bool *is_mem_inst) { int ind = src->Register.Index; + if (info->processor == PIPE_SHADER_COMPUTE && + src->Register.File == TGSI_FILE_SYSTEM_VALUE) { + unsigned swizzle[4], i, name; + + name = info->system_value_semantic_name[src->Register.Index]; + swizzle[0] = src->Register.SwizzleX; + swizzle[1] = src->Register.SwizzleY; + swizzle[2] = src->Register.SwizzleZ; + swizzle[3] = src->Register.SwizzleW; + + switch (name) { + case TGSI_SEMANTIC_THREAD_ID: + case TGSI_SEMANTIC_BLOCK_ID: + for (i = 0; i < 4; i++) { + switch (swizzle[i]) { + case TGSI_SWIZZLE_X: + if (name == TGSI_SEMANTIC_THREAD_ID) + info->uses_thread_id[0] = true; + else + info->uses_block_id[0] = true; + break; + case TGSI_SWIZZLE_Y: + if (name == TGSI_SEMANTIC_THREAD_ID) + info->uses_thread_id[1] = true; + else + info->uses_block_id[1] = true; + break; + case TGSI_SWIZZLE_Z: + if (name == TGSI_SEMANTIC_THREAD_ID) + info->uses_thread_id[2] = true; + else + info->uses_block_id[2] = true; + break; + } + } + break; + case TGSI_SEMANTIC_BLOCK_SIZE: + /* The block size is translated to IMM with a fixed block size. */ + if (info->properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH] == 0) + info->uses_block_size = true; + break; + case TGSI_SEMANTIC_GRID_SIZE: + info->uses_grid_size = true; + break; + } + } + /* Mark which inputs are effectively used */ if (src->Register.File == TGSI_FILE_INPUT) { if (src->Register.Indirect) { for (ind = 0; ind < info->num_inputs; ++ind) { info->input_usage_mask[ind] |= usage_mask; } } else { assert(ind >= 0); assert(ind < PIPE_MAX_SHADER_INPUTS); info->input_usage_mask[ind] |= usage_mask; diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h index 3854827..98387c9 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h @@ -114,20 +114,24 @@ struct tgsi_shader_info boolean uses_linear_opcode_interp_centroid; boolean uses_linear_opcode_interp_offset; boolean uses_linear_opcode_interp_sample; boolean uses_instanceid; boolean uses_vertexid; boolean uses_vertexid_nobase; boolean uses_basevertex; boolean uses_primid; boolean uses_frontface; boolean uses_invocationid; + boolean uses_thread_id[3]; + boolean uses_block_id[3]; + boolean uses_block_size; + boolean uses_grid_size; boolean writes_position; boolean writes_psize; boolean writes_clipvertex; boolean writes_primid; boolean writes_viewport_index; boolean writes_layer; boolean writes_memory; /**< contains stores or atomics to buffers or images */ boolean is_msaa_sampler[PIPE_MAX_SAMPLERS]; boolean uses_doubles; /**< uses any of the double instructions */ boolean uses_derivatives; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev