X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Fcompiler%2Fnir%2Fnir_print.c;h=6e871b6c9506ff968d454966b406dbfaafa6f41e;hp=42053dc2d8cf1f38d2e8b89e7b6634414bfce578;hb=a3a8322dcd7aaede8dedff131c7d73bdbe3f06f9;hpb=18ed82b084c79bf63666f2da22e5d675fb01aa26 diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 42053dc2d8c..6e871b6c950 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -62,6 +62,8 @@ typedef struct { static void print_annotation(print_state *state, void *obj) { + FILE *fp = state->fp; + if (!state->annotations) return; @@ -72,7 +74,7 @@ print_annotation(print_state *state, void *obj) const char *note = entry->data; _mesa_hash_table_remove(state->annotations, entry); - fprintf(stderr, "%s\n\n", note); + fprintf(fp, "%s\n\n", note); } static void @@ -169,6 +171,12 @@ print_dest(nir_dest *dest, print_state *state) print_reg_dest(&dest->reg, state); } +static const char * +comp_mask_string(unsigned num_components) +{ + return (num_components > 4) ? "abcdefghijklmnop" : "xyzw"; +} + static void print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state) { @@ -204,7 +212,7 @@ print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state) if (!nir_alu_instr_channel_used(instr, src, i)) continue; - fprintf(fp, "%c", "xyzw"[instr->src[src].swizzle[i]]); + fprintf(fp, "%c", comp_mask_string(live_channels)[instr->src[src].swizzle[i]]); } } @@ -222,10 +230,11 @@ print_alu_dest(nir_alu_dest *dest, print_state *state) if (!dest->dest.is_ssa && dest->write_mask != (1 << dest->dest.reg.reg->num_components) - 1) { + unsigned live_channels = dest->dest.reg.reg->num_components; fprintf(fp, "."); for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) if ((dest->write_mask >> i) & 1) - fprintf(fp, "%c", "xyzw"[i]); + fprintf(fp, "%c", comp_mask_string(live_channels)[i]); } } @@ -241,6 +250,10 @@ print_alu_instr(nir_alu_instr *instr, print_state *state) fprintf(fp, "!"); if (instr->dest.saturate) fprintf(fp, ".sat"); + if (instr->no_signed_wrap) + fprintf(fp, ".nsw"); + if (instr->no_unsigned_wrap) + fprintf(fp, ".nuw"); fprintf(fp, " "); for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { @@ -291,7 +304,7 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state FILE *fp = state->fp; const unsigned rows = glsl_get_vector_elements(type); const unsigned cols = glsl_get_matrix_columns(type); - unsigned i, j; + unsigned i; switch (glsl_get_base_type(type)) { case GLSL_TYPE_BOOL: @@ -300,7 +313,7 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state for (i = 0; i < rows; i++) { if (i > 0) fprintf(fp, ", "); - fprintf(fp, "%s", c->values[0].b[i] ? "true" : "false"); + fprintf(fp, "%s", c->values[i].b ? "true" : "false"); } break; @@ -311,7 +324,7 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state for (i = 0; i < rows; i++) { if (i > 0) fprintf(fp, ", "); - fprintf(fp, "0x%02x", c->values[0].u8[i]); + fprintf(fp, "0x%02x", c->values[i].u8); } break; @@ -322,7 +335,7 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state for (i = 0; i < rows; i++) { if (i > 0) fprintf(fp, ", "); - fprintf(fp, "0x%04x", c->values[0].u16[i]); + fprintf(fp, "0x%04x", c->values[i].u16); } break; @@ -333,33 +346,43 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state for (i = 0; i < rows; i++) { if (i > 0) fprintf(fp, ", "); - fprintf(fp, "0x%08x", c->values[0].u32[i]); + fprintf(fp, "0x%08x", c->values[i].u32); } break; case GLSL_TYPE_FLOAT16: - for (i = 0; i < cols; i++) { - for (j = 0; j < rows; j++) { - if (i + j > 0) fprintf(fp, ", "); - fprintf(fp, "%f", _mesa_half_to_float(c->values[i].u16[j])); - } - } - break; - case GLSL_TYPE_FLOAT: - for (i = 0; i < cols; i++) { - for (j = 0; j < rows; j++) { - if (i + j > 0) fprintf(fp, ", "); - fprintf(fp, "%f", c->values[i].f32[j]); - } - } - break; - case GLSL_TYPE_DOUBLE: - for (i = 0; i < cols; i++) { - for (j = 0; j < rows; j++) { - if (i + j > 0) fprintf(fp, ", "); - fprintf(fp, "%f", c->values[i].f64[j]); + if (cols > 1) { + for (i = 0; i < cols; i++) { + if (i > 0) fprintf(fp, ", "); + print_constant(c->elements[i], glsl_get_column_type(type), state); + } + } else { + switch (glsl_get_base_type(type)) { + case GLSL_TYPE_FLOAT16: + for (i = 0; i < rows; i++) { + if (i > 0) fprintf(fp, ", "); + fprintf(fp, "%f", _mesa_half_to_float(c->values[i].u16)); + } + break; + + case GLSL_TYPE_FLOAT: + for (i = 0; i < rows; i++) { + if (i > 0) fprintf(fp, ", "); + fprintf(fp, "%f", c->values[i].f32); + } + break; + + case GLSL_TYPE_DOUBLE: + for (i = 0; i < rows; i++) { + if (i > 0) fprintf(fp, ", "); + fprintf(fp, "%f", c->values[i].f64); + } + break; + + default: + unreachable("Cannot get here from the first level switch"); } } break; @@ -371,11 +394,12 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state for (i = 0; i < cols; i++) { if (i > 0) fprintf(fp, ", "); - fprintf(fp, "0x%08" PRIx64, c->values[0].u64[i]); + fprintf(fp, "0x%08" PRIx64, c->values[i].u64); } break; case GLSL_TYPE_STRUCT: + case GLSL_TYPE_INTERFACE: for (i = 0; i < c->num_elements; i++) { if (i > 0) fprintf(fp, ", "); fprintf(fp, "{ "); @@ -438,64 +462,34 @@ print_var_decl(nir_variable *var, print_state *state) const char *const samp = (var->data.sample) ? "sample " : ""; const char *const patch = (var->data.patch) ? "patch " : ""; const char *const inv = (var->data.invariant) ? "invariant " : ""; - fprintf(fp, "%s%s%s%s%s %s ", - cent, samp, patch, inv, get_variable_mode_str(var->data.mode, false), + const char *const per_view = (var->data.per_view) ? "per_view " : ""; + fprintf(fp, "%s%s%s%s%s%s %s ", + cent, samp, patch, inv, per_view, + get_variable_mode_str(var->data.mode, false), glsl_interp_mode_name(var->data.interpolation)); - enum gl_access_qualifier access = var->data.image.access; + enum gl_access_qualifier access = var->data.access; const char *const coher = (access & ACCESS_COHERENT) ? "coherent " : ""; const char *const volat = (access & ACCESS_VOLATILE) ? "volatile " : ""; const char *const restr = (access & ACCESS_RESTRICT) ? "restrict " : ""; const char *const ronly = (access & ACCESS_NON_WRITEABLE) ? "readonly " : ""; const char *const wonly = (access & ACCESS_NON_READABLE) ? "writeonly " : ""; - fprintf(fp, "%s%s%s%s%s", coher, volat, restr, ronly, wonly); - -#define FORMAT_CASE(x) case x: fprintf(stderr, #x " "); break - switch (var->data.image.format) { - FORMAT_CASE(GL_RGBA32F); - FORMAT_CASE(GL_RGBA32UI); - FORMAT_CASE(GL_RGBA32I); - FORMAT_CASE(GL_R32F); - FORMAT_CASE(GL_R32UI); - FORMAT_CASE(GL_R32I); - FORMAT_CASE(GL_RG32F); - FORMAT_CASE(GL_RG32UI); - FORMAT_CASE(GL_RG32I); - FORMAT_CASE(GL_R8); - FORMAT_CASE(GL_RG8); - FORMAT_CASE(GL_RGBA8); - FORMAT_CASE(GL_R8_SNORM); - FORMAT_CASE(GL_RG8_SNORM); - FORMAT_CASE(GL_RGBA8_SNORM); - FORMAT_CASE(GL_R16); - FORMAT_CASE(GL_RG16); - FORMAT_CASE(GL_RGBA16); - FORMAT_CASE(GL_R16_SNORM); - FORMAT_CASE(GL_RG16_SNORM); - FORMAT_CASE(GL_RGBA16_SNORM); - FORMAT_CASE(GL_R16F); - FORMAT_CASE(GL_RG16F); - FORMAT_CASE(GL_RGBA16F); - FORMAT_CASE(GL_R8UI); - FORMAT_CASE(GL_R8I); - FORMAT_CASE(GL_RG8UI); - FORMAT_CASE(GL_RG8I); - FORMAT_CASE(GL_RGBA8UI); - FORMAT_CASE(GL_RGBA8I); - FORMAT_CASE(GL_R16UI); - FORMAT_CASE(GL_R16I); - FORMAT_CASE(GL_RG16UI); - FORMAT_CASE(GL_RG16I); - FORMAT_CASE(GL_RGBA16UI); - FORMAT_CASE(GL_RGBA16I); - FORMAT_CASE(GL_R11F_G11F_B10F); - FORMAT_CASE(GL_RGB9_E5); - FORMAT_CASE(GL_RGB10_A2); - FORMAT_CASE(GL_RGB10_A2UI); - default: /* Including the normal GL_NONE */ - break; + const char *const reorder = (access & ACCESS_CAN_REORDER) ? "reorderable " : ""; + fprintf(fp, "%s%s%s%s%s%s", coher, volat, restr, ronly, wonly, reorder); + + if (glsl_get_base_type(glsl_without_array(var->type)) == GLSL_TYPE_IMAGE) { + fprintf(fp, "%s ", util_format_short_name(var->data.image.format)); + } + + if (var->data.precision) { + const char *precisions[] = { + "", + "highp", + "mediump", + "lowp", + }; + fprintf(fp, "%s ", precisions[var->data.precision]); } -#undef FORMAT_CASE fprintf(fp, "%s %s", glsl_get_type_name(var->type), get_var_name(var, state)); @@ -536,8 +530,12 @@ print_var_decl(nir_variable *var, print_state *state) } if (!loc) { - snprintf(buf, sizeof(buf), "%u", var->data.location); - loc = buf; + if (var->data.location == ~0) { + loc = "~0"; + } else { + snprintf(buf, sizeof(buf), "%u", var->data.location); + loc = buf; + } } /* For shader I/O vars that have been split to components or packed, @@ -546,12 +544,12 @@ print_var_decl(nir_variable *var, print_state *state) unsigned int num_components = glsl_get_components(glsl_without_array(var->type)); const char *components = NULL; - char components_local[6] = {'.' /* the rest is 0-filled */}; + char components_local[18] = {'.' /* the rest is 0-filled */}; switch (var->data.mode) { case nir_var_shader_in: case nir_var_shader_out: - if (num_components < 4 && num_components != 0) { - const char *xyzw = "xyzw"; + if (num_components < 16 && num_components != 0) { + const char *xyzw = comp_mask_string(num_components); for (int i = 0; i < num_components; i++) components_local[i + 1] = xyzw[i + var->data.location_frac]; @@ -573,6 +571,8 @@ print_var_decl(nir_variable *var, print_state *state) print_constant(var->constant_initializer, var->type, state); fprintf(fp, " }"); } + if (var->pointer_initializer) + fprintf(fp, " = &%s", get_var_name(var->pointer_initializer, state)); fprintf(fp, "\n"); print_annotation(state, var); @@ -637,9 +637,8 @@ print_deref_link(const nir_deref_instr *instr, bool whole_chain, print_state *st case nir_deref_type_array: case nir_deref_type_ptr_as_array: { - nir_const_value *const_index = nir_src_as_const_value(instr->arr.index); - if (const_index) { - fprintf(fp, "[%u]", const_index->u32[0]); + if (nir_src_is_const(instr->arr.index)) { + fprintf(fp, "[%"PRId64"]", nir_src_as_int(instr->arr.index)); } else { fprintf(fp, "["); print_src(&instr->arr.index, state); @@ -702,6 +701,10 @@ print_deref_instr(nir_deref_instr *instr, print_state *state) print_deref_link(instr, true, state); fprintf(fp, " */"); } + + if (instr->deref_type == nir_deref_type_cast) { + fprintf(fp, " /* ptr_stride=%u */", instr->cast.ptr_stride); + } } static const char * @@ -724,6 +727,26 @@ vulkan_descriptor_type_name(VkDescriptorType type) } } +static void +print_alu_type(nir_alu_type type, print_state *state) +{ + FILE *fp = state->fp; + unsigned size = nir_alu_type_get_type_size(type); + const char *name; + + switch (nir_alu_type_get_base_type(type)) { + case nir_type_int: name = "int"; break; + case nir_type_uint: name = "uint"; break; + case nir_type_bool: name = "bool"; break; + case nir_type_float: name = "float"; break; + default: name = "invalid"; + } + if (size) + fprintf(fp, "%s%u", name, size); + else + fprintf(fp, "%s", name); +} + static void print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) { @@ -772,26 +795,44 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) [NIR_INTRINSIC_IMAGE_DIM] = "image_dim", [NIR_INTRINSIC_IMAGE_ARRAY] = "image_array", [NIR_INTRINSIC_ACCESS] = "access", + [NIR_INTRINSIC_SRC_ACCESS] = "src-access", + [NIR_INTRINSIC_DST_ACCESS] = "dst-access", [NIR_INTRINSIC_FORMAT] = "format", [NIR_INTRINSIC_ALIGN_MUL] = "align_mul", [NIR_INTRINSIC_ALIGN_OFFSET] = "align_offset", [NIR_INTRINSIC_DESC_TYPE] = "desc_type", + [NIR_INTRINSIC_TYPE] = "type", + [NIR_INTRINSIC_SWIZZLE_MASK] = "swizzle_mask", + [NIR_INTRINSIC_DRIVER_LOCATION] = "driver_location", + [NIR_INTRINSIC_MEMORY_SEMANTICS] = "mem_semantics", + [NIR_INTRINSIC_MEMORY_MODES] = "mem_modes", + [NIR_INTRINSIC_MEMORY_SCOPE] = "mem_scope", + [NIR_INTRINSIC_EXECUTION_SCOPE] = "exec_scope", + [NIR_INTRINSIC_IO_SEMANTICS] = "io_semantics", }; + for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) { if (!info->index_map[idx]) continue; fprintf(fp, " /*"); - if (idx == NIR_INTRINSIC_WRMASK) { + switch (idx) { + case NIR_INTRINSIC_WRMASK: { /* special case wrmask to show it as a writemask.. */ unsigned wrmask = nir_intrinsic_write_mask(instr); fprintf(fp, " wrmask="); - for (unsigned i = 0; i < 4; i++) + for (unsigned i = 0; i < instr->num_components; i++) if ((wrmask >> i) & 1) - fprintf(fp, "%c", "xyzw"[i]); - } else if (idx == NIR_INTRINSIC_REDUCTION_OP) { + fprintf(fp, "%c", comp_mask_string(instr->num_components)[i]); + break; + } + + case NIR_INTRINSIC_REDUCTION_OP: { nir_op reduction_op = nir_intrinsic_reduction_op(instr); fprintf(fp, " reduction_op=%s", nir_op_infos[reduction_op].name); - } else if (idx == NIR_INTRINSIC_IMAGE_DIM) { + break; + } + + case NIR_INTRINSIC_IMAGE_DIM: { static const char *dim_name[] = { [GLSL_SAMPLER_DIM_1D] = "1D", [GLSL_SAMPLER_DIM_2D] = "2D", @@ -806,16 +847,118 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) enum glsl_sampler_dim dim = nir_intrinsic_image_dim(instr); assert(dim < ARRAY_SIZE(dim_name) && dim_name[dim]); fprintf(fp, " image_dim=%s", dim_name[dim]); - } else if (idx == NIR_INTRINSIC_IMAGE_ARRAY) { + break; + } + + case NIR_INTRINSIC_IMAGE_ARRAY: { bool array = nir_intrinsic_image_array(instr); fprintf(fp, " image_array=%s", array ? "true" : "false"); - } else if (idx == NIR_INTRINSIC_DESC_TYPE) { + break; + } + + case NIR_INTRINSIC_DESC_TYPE: { VkDescriptorType desc_type = nir_intrinsic_desc_type(instr); fprintf(fp, " desc_type=%s", vulkan_descriptor_type_name(desc_type)); - } else { + break; + } + + case NIR_INTRINSIC_TYPE: { + fprintf(fp, " type="); + print_alu_type(nir_intrinsic_type(instr), state); + break; + } + + case NIR_INTRINSIC_SWIZZLE_MASK: { + fprintf(fp, " swizzle_mask="); + unsigned mask = nir_intrinsic_swizzle_mask(instr); + if (instr->intrinsic == nir_intrinsic_quad_swizzle_amd) { + for (unsigned i = 0; i < 4; i++) + fprintf(fp, "%d", (mask >> (i * 2) & 3)); + } else if (instr->intrinsic == nir_intrinsic_masked_swizzle_amd) { + fprintf(fp, "((id & %d) | %d) ^ %d", mask & 0x1F, + (mask >> 5) & 0x1F, + (mask >> 10) & 0x1F); + } else { + fprintf(fp, "%d", mask); + } + break; + } + + case NIR_INTRINSIC_MEMORY_SEMANTICS: { + nir_memory_semantics semantics = nir_intrinsic_memory_semantics(instr); + fprintf(fp, " mem_semantics="); + switch (semantics & (NIR_MEMORY_ACQUIRE | NIR_MEMORY_RELEASE)) { + case 0: fprintf(fp, "NONE"); break; + case NIR_MEMORY_ACQUIRE: fprintf(fp, "ACQ"); break; + case NIR_MEMORY_RELEASE: fprintf(fp, "REL"); break; + default: fprintf(fp, "ACQ|REL"); break; + } + if (semantics & (NIR_MEMORY_MAKE_AVAILABLE)) fprintf(fp, "|AVAILABLE"); + if (semantics & (NIR_MEMORY_MAKE_VISIBLE)) fprintf(fp, "|VISIBLE"); + break; + } + + case NIR_INTRINSIC_MEMORY_MODES: { + fprintf(fp, " mem_modes="); + unsigned int modes = nir_intrinsic_memory_modes(instr); + while (modes) { + nir_variable_mode m = u_bit_scan(&modes); + fprintf(fp, "%s%s", get_variable_mode_str(1 << m, true), modes ? "|" : ""); + } + break; + } + + case NIR_INTRINSIC_EXECUTION_SCOPE: + case NIR_INTRINSIC_MEMORY_SCOPE: { + fprintf(fp, " %s=", index_name[idx]); + nir_scope scope = + idx == NIR_INTRINSIC_MEMORY_SCOPE ? nir_intrinsic_memory_scope(instr) + : nir_intrinsic_execution_scope(instr); + switch (scope) { + case NIR_SCOPE_NONE: fprintf(fp, "NONE"); break; + case NIR_SCOPE_DEVICE: fprintf(fp, "DEVICE"); break; + case NIR_SCOPE_QUEUE_FAMILY: fprintf(fp, "QUEUE_FAMILY"); break; + case NIR_SCOPE_WORKGROUP: fprintf(fp, "WORKGROUP"); break; + case NIR_SCOPE_SUBGROUP: fprintf(fp, "SUBGROUP"); break; + case NIR_SCOPE_INVOCATION: fprintf(fp, "INVOCATION"); break; + } + break; + } + + case NIR_INTRINSIC_IO_SEMANTICS: + fprintf(fp, " location=%u slots=%u", + nir_intrinsic_io_semantics(instr).location, + nir_intrinsic_io_semantics(instr).num_slots); + if (state->shader) { + if (state->shader->info.stage == MESA_SHADER_FRAGMENT && + instr->intrinsic == nir_intrinsic_store_output && + nir_intrinsic_io_semantics(instr).dual_source_blend_index) { + fprintf(fp, " dualsrc=1"); + } + if (state->shader->info.stage == MESA_SHADER_FRAGMENT && + instr->intrinsic == nir_intrinsic_load_output && + nir_intrinsic_io_semantics(instr).fb_fetch_output) { + fprintf(fp, " fbfetch=1"); + } + if (state->shader->info.stage == MESA_SHADER_GEOMETRY && + instr->intrinsic == nir_intrinsic_store_output) { + unsigned gs_streams = nir_intrinsic_io_semantics(instr).gs_streams; + fprintf(fp, " gs_streams("); + for (unsigned i = 0; i < 4; i++) { + fprintf(fp, "%s%c=%u", i ? " " : "", "xyzw"[i], + (gs_streams >> (i * 2)) & 0x3); + } + fprintf(fp, ")"); + } + } + break; + + default: { unsigned off = info->index_map[idx] - 1; assert(index_name[idx]); /* forgot to update index_name table? */ fprintf(fp, " %s=%d", index_name[idx], instr->const_index[off]); + break; + } } fprintf(fp, " */"); } @@ -823,27 +966,26 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) if (!state->shader) return; - struct exec_list *var_list = NULL; - + nir_variable_mode var_mode; switch (instr->intrinsic) { case nir_intrinsic_load_uniform: - var_list = &state->shader->uniforms; + var_mode = nir_var_uniform; break; case nir_intrinsic_load_input: case nir_intrinsic_load_interpolated_input: case nir_intrinsic_load_per_vertex_input: - var_list = &state->shader->inputs; + var_mode = nir_var_shader_in; break; case nir_intrinsic_load_output: case nir_intrinsic_store_output: case nir_intrinsic_store_per_vertex_output: - var_list = &state->shader->outputs; + var_mode = nir_var_shader_out; break; default: return; } - nir_foreach_variable(var, var_list) { + nir_foreach_variable_with_modes(var, state->shader, var_mode) { if ((var->data.driver_location == nir_intrinsic_base(instr)) && (instr->intrinsic == nir_intrinsic_load_uniform || (nir_intrinsic_component(instr) >= var->data.location_frac && @@ -863,7 +1005,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) print_dest(&instr->dest, state); - fprintf(fp, " = "); + fprintf(fp, " = ("); + print_alu_type(instr->dest_type, state); + fprintf(fp, ")"); switch (instr->op) { case nir_texop_tex: @@ -884,6 +1028,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) case nir_texop_txf_ms: fprintf(fp, "txf_ms "); break; + case nir_texop_txf_ms_fb: + fprintf(fp, "txf_ms_fb "); + break; case nir_texop_txf_ms_mcs: fprintf(fp, "txf_ms_mcs "); break; @@ -905,6 +1052,15 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) case nir_texop_samples_identical: fprintf(fp, "samples_identical "); break; + case nir_texop_tex_prefetch: + fprintf(fp, "tex (pre-dispatchable) "); + break; + case nir_texop_fragment_fetch: + fprintf(fp, "fragment_fetch "); + break; + case nir_texop_fragment_mask_fetch: + fprintf(fp, "fragment_mask_fetch "); + break; default: unreachable("Invalid texture operation"); break; @@ -912,8 +1068,11 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) bool has_texture_deref = false, has_sampler_deref = false; for (unsigned i = 0; i < instr->num_srcs; i++) { - print_src(&instr->src[i].src, state); + if (i > 0) { + fprintf(fp, ", "); + } + print_src(&instr->src[i].src, state); fprintf(fp, " "); switch(instr->src[i].src_type) { @@ -978,28 +1137,36 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) unreachable("Invalid texture source type"); break; } - - fprintf(fp, ", "); } if (instr->op == nir_texop_tg4) { - fprintf(fp, "%u (gather_component), ", instr->component); + fprintf(fp, ", %u (gather_component)", instr->component); } if (nir_tex_instr_has_explicit_tg4_offsets(instr)) { - fprintf(fp, "{ (%i, %i)", instr->tg4_offsets[0][0], instr->tg4_offsets[0][1]); + fprintf(fp, ", { (%i, %i)", instr->tg4_offsets[0][0], instr->tg4_offsets[0][1]); for (unsigned i = 1; i < 4; ++i) fprintf(fp, ", (%i, %i)", instr->tg4_offsets[i][0], instr->tg4_offsets[i][1]); - fprintf(fp, " } (offsets), "); + fprintf(fp, " } (offsets)"); + } + + if (instr->op != nir_texop_txf_ms_fb) { + if (!has_texture_deref) { + fprintf(fp, ", %u (texture)", instr->texture_index); + } + + if (!has_sampler_deref) { + fprintf(fp, ", %u (sampler)", instr->sampler_index); + } } - if (!has_texture_deref) { - fprintf(fp, "%u (texture), ", instr->texture_index); + if (instr->texture_non_uniform) { + fprintf(fp, ", texture non-uniform"); } - if (!has_sampler_deref) { - fprintf(fp, "%u (sampler), ", instr->sampler_index); + if (instr->sampler_non_uniform) { + fprintf(fp, ", sampler non-uniform"); } } @@ -1039,21 +1206,21 @@ print_load_const_instr(nir_load_const_instr *instr, print_state *state) switch (instr->def.bit_size) { case 64: - fprintf(fp, "0x%16" PRIx64 " /* %f */", instr->value.u64[i], - instr->value.f64[i]); + fprintf(fp, "0x%16" PRIx64 " /* %f */", instr->value[i].u64, + instr->value[i].f64); break; case 32: - fprintf(fp, "0x%08x /* %f */", instr->value.u32[i], instr->value.f32[i]); + fprintf(fp, "0x%08x /* %f */", instr->value[i].u32, instr->value[i].f32); break; case 16: - fprintf(fp, "0x%04x /* %f */", instr->value.u16[i], - _mesa_half_to_float(instr->value.u16[i])); + fprintf(fp, "0x%04x /* %f */", instr->value[i].u16, + _mesa_half_to_float(instr->value[i].u16)); break; case 8: - fprintf(fp, "0x%02x", instr->value.u8[i]); + fprintf(fp, "0x%02x", instr->value[i].u8); break; case 1: - fprintf(fp, "%s", instr->value.b[i] ? "true" : "false"); + fprintf(fp, "%s", instr->value[i].b ? "true" : "false"); break; } } @@ -1078,6 +1245,19 @@ print_jump_instr(nir_jump_instr *instr, print_state *state) case nir_jump_return: fprintf(fp, "return"); break; + + case nir_jump_goto: + fprintf(fp, "goto block_%u", + instr->target ? instr->target->index : -1); + break; + + case nir_jump_goto_if: + fprintf(fp, "goto block_%u if ", + instr->target ? instr->target->index : -1); + print_src(&instr->condition, state); + fprintf(fp, " else block_%u", + instr->else_target ? instr->else_target->index : -1); + break; } } @@ -1293,7 +1473,7 @@ print_function_impl(nir_function_impl *impl, print_state *state) fprintf(fp, "{\n"); - nir_foreach_variable(var, &impl->locals) { + nir_foreach_function_temp_variable(var, impl) { fprintf(fp, "\t"); print_var_decl(var, state); } @@ -1334,7 +1514,7 @@ init_print_state(print_state *state, nir_shader *shader, FILE *fp) state->fp = fp; state->shader = shader; state->ht = _mesa_pointer_hash_table_create(NULL); - state->syms = _mesa_set_create(NULL, _mesa_key_hash_string, + state->syms = _mesa_set_create(NULL, _mesa_hash_string, _mesa_key_string_equal); state->index = 0; } @@ -1375,33 +1555,16 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp, fprintf(fp, "inputs: %u\n", shader->num_inputs); fprintf(fp, "outputs: %u\n", shader->num_outputs); fprintf(fp, "uniforms: %u\n", shader->num_uniforms); + if (shader->info.num_ubos) + fprintf(fp, "ubos: %u\n", shader->info.num_ubos); fprintf(fp, "shared: %u\n", shader->num_shared); if (shader->scratch_size) fprintf(fp, "scratch: %u\n", shader->scratch_size); + if (shader->constant_data_size) + fprintf(fp, "constants: %u\n", shader->constant_data_size); - nir_foreach_variable(var, &shader->uniforms) { - print_var_decl(var, &state); - } - - nir_foreach_variable(var, &shader->inputs) { + nir_foreach_variable_in_shader(var, shader) print_var_decl(var, &state); - } - - nir_foreach_variable(var, &shader->outputs) { - print_var_decl(var, &state); - } - - nir_foreach_variable(var, &shader->shared) { - print_var_decl(var, &state); - } - - nir_foreach_variable(var, &shader->globals) { - print_var_decl(var, &state); - } - - nir_foreach_variable(var, &shader->system_values) { - print_var_decl(var, &state); - } foreach_list_typed(nir_function, func, node, &shader->functions) { print_function(func, &state);