2014-07-30 23:29:27 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Connor Abbott (cwabbott0@gmail.com)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nir.h"
|
2016-01-18 08:47:13 +00:00
|
|
|
#include "compiler/shader_enums.h"
|
2018-04-22 00:31:22 +01:00
|
|
|
#include "util/half_float.h"
|
2021-02-05 11:25:03 +00:00
|
|
|
#include "util/memstream.h"
|
2021-11-18 14:28:17 +00:00
|
|
|
#include "util/mesa-sha1.h"
|
2018-12-13 22:50:19 +00:00
|
|
|
#include "vulkan/vulkan_core.h"
|
2014-07-30 23:29:27 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-08-14 18:37:18 +01:00
|
|
|
#include <inttypes.h> /* for PRIx64 macro */
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
print_tabs(unsigned num_tabs, FILE *fp)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < num_tabs; i++)
|
|
|
|
fprintf(fp, "\t");
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp;
|
2015-09-15 23:55:48 +01:00
|
|
|
nir_shader *shader;
|
2014-07-30 23:29:27 +01:00
|
|
|
/** map from nir_variable -> printable name */
|
|
|
|
struct hash_table *ht;
|
|
|
|
|
|
|
|
/** set of names used so far for nir_variables */
|
|
|
|
struct set *syms;
|
|
|
|
|
|
|
|
/* an index used to make new non-conflicting names */
|
|
|
|
unsigned index;
|
2016-05-14 20:37:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional table of annotations mapping nir object
|
|
|
|
* (such as instr or var) to message to print.
|
|
|
|
*/
|
|
|
|
struct hash_table *annotations;
|
2015-09-15 23:50:41 +01:00
|
|
|
} print_state;
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2016-05-14 20:37:32 +01:00
|
|
|
static void
|
|
|
|
print_annotation(print_state *state, void *obj)
|
|
|
|
{
|
2019-10-03 19:09:24 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2016-05-14 20:37:32 +01:00
|
|
|
if (!state->annotations)
|
|
|
|
return;
|
|
|
|
|
|
|
|
struct hash_entry *entry = _mesa_hash_table_search(state->annotations, obj);
|
|
|
|
if (!entry)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const char *note = entry->data;
|
|
|
|
_mesa_hash_table_remove(state->annotations, entry);
|
|
|
|
|
2019-10-03 19:09:24 +01:00
|
|
|
fprintf(fp, "%s\n\n", note);
|
2016-05-14 20:37:32 +01:00
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_register(nir_register *reg, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2019-04-06 01:58:46 +01:00
|
|
|
fprintf(fp, "r%u", reg->index);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 19:00:31 +00:00
|
|
|
static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4",
|
2020-11-23 13:05:58 +00:00
|
|
|
"vec5", "error", "error", "vec8",
|
2018-07-12 05:27:49 +01:00
|
|
|
"error", "error", "error", "error",
|
2018-03-12 19:00:31 +00:00
|
|
|
"error", "error", "error", "vec16"};
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_register_decl(nir_register *reg, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2015-08-14 18:37:18 +01:00
|
|
|
fprintf(fp, "decl_reg %s %u ", sizes[reg->num_components], reg->bit_size);
|
2015-09-15 23:50:41 +01:00
|
|
|
print_register(reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
if (reg->num_array_elems != 0)
|
|
|
|
fprintf(fp, "[%u]", reg->num_array_elems);
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_def(nir_ssa_def *def, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2020-09-10 05:08:49 +01:00
|
|
|
|
|
|
|
const char *divergence = "";
|
|
|
|
if (state->shader->info.divergence_analysis_run)
|
|
|
|
divergence = def->divergent ? "div " : "con ";
|
|
|
|
|
|
|
|
fprintf(fp, "%s %2u %sssa_%u", sizes[def->num_components], def->bit_size,
|
|
|
|
divergence, def->index);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2021-11-19 14:28:49 +00:00
|
|
|
static void
|
2021-11-19 14:47:56 +00:00
|
|
|
print_const_from_load(nir_load_const_instr *instr, print_state *state)
|
2021-11-19 14:28:49 +00:00
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares
either about hex or float values, never both.
Before/after:
-vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */)
+vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000)
-vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */)
+vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
2021-11-19 14:35:37 +00:00
|
|
|
/*
|
|
|
|
* we don't really know the type of the constant (if it will be used as a
|
|
|
|
* float or an int), so just print the raw constant in hex for fidelity
|
|
|
|
* and then print in float again for readability.
|
|
|
|
*/
|
|
|
|
|
2021-11-19 14:47:56 +00:00
|
|
|
fprintf(fp, "(");
|
|
|
|
|
2021-11-19 14:28:49 +00:00
|
|
|
for (unsigned i = 0; i < instr->def.num_components; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
|
|
|
switch (instr->def.bit_size) {
|
|
|
|
case 64:
|
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares
either about hex or float values, never both.
Before/after:
-vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */)
+vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000)
-vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */)
+vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
2021-11-19 14:35:37 +00:00
|
|
|
fprintf(fp, "0x%016" PRIx64, instr->value[i].u64);
|
2021-11-19 14:28:49 +00:00
|
|
|
break;
|
|
|
|
case 32:
|
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares
either about hex or float values, never both.
Before/after:
-vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */)
+vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000)
-vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */)
+vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
2021-11-19 14:35:37 +00:00
|
|
|
fprintf(fp, "0x%08x", instr->value[i].u32);
|
2021-11-19 14:28:49 +00:00
|
|
|
break;
|
|
|
|
case 16:
|
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares
either about hex or float values, never both.
Before/after:
-vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */)
+vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000)
-vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */)
+vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
2021-11-19 14:35:37 +00:00
|
|
|
fprintf(fp, "0x%04x", instr->value[i].u16);
|
2021-11-19 14:28:49 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
fprintf(fp, "0x%02x", instr->value[i].u8);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
fprintf(fp, "%s", instr->value[i].b ? "true" : "false");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
nir/print: group hex and float vectors together
Vectors are much easier to follow in this format, because developer cares
either about hex or float values, never both.
Before/after:
-vec4 32 ssa_222 = load_const (0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */, 0x3f800000 /* 1.000000 */)
+vec4 32 ssa_222 = load_const (0x00000000, 0x00000000, 0x3f800000, 0x3f800000) = (0.000000, 0.000000, 1.000000, 1.000000)
-vec1 32 ssa_174 = load_const (0xbf800000 /* -1.000000 */)
+vec1 32 ssa_174 = load_const (0xbf800000 = -1.000000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
2021-11-19 14:35:37 +00:00
|
|
|
if (instr->def.bit_size > 8) {
|
|
|
|
if (instr->def.num_components > 1)
|
|
|
|
fprintf(fp, ") = (");
|
|
|
|
else
|
|
|
|
fprintf(fp, " = ");
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < instr->def.num_components; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
|
|
|
switch (instr->def.bit_size) {
|
|
|
|
case 64:
|
|
|
|
fprintf(fp, "%f", instr->value[i].f64);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
fprintf(fp, "%f", instr->value[i].f32);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
fprintf(fp, "%f", _mesa_half_to_float(instr->value[i].u16));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unreachable("unhandled bit size");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-19 14:28:49 +00:00
|
|
|
fprintf(fp, ")");
|
|
|
|
}
|
|
|
|
|
2021-11-19 14:47:56 +00:00
|
|
|
static void
|
|
|
|
print_load_const_instr(nir_load_const_instr *instr, print_state *state)
|
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
|
|
|
print_ssa_def(&instr->def, state);
|
|
|
|
|
|
|
|
fprintf(fp, " = load_const ");
|
|
|
|
|
|
|
|
print_const_from_load(instr, state);
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_use(nir_ssa_def *def, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "ssa_%u", def->index);
|
2021-11-19 14:47:56 +00:00
|
|
|
nir_instr *instr = def->parent_instr;
|
|
|
|
if (instr->type == nir_instr_type_load_const && NIR_DEBUG(PRINT_CONSTS)) {
|
|
|
|
fprintf(fp, " /*");
|
|
|
|
print_const_from_load(nir_instr_as_load_const(instr), state);
|
|
|
|
fprintf(fp, "*/");
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 20:13:46 +00:00
|
|
|
static void print_src(const nir_src *src, print_state *state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
static void
|
2018-12-19 20:13:46 +00:00
|
|
|
print_reg_src(const nir_reg_src *src, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
print_register(src->reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
if (src->reg->num_array_elems != 0) {
|
|
|
|
fprintf(fp, "[%u", src->base_offset);
|
|
|
|
if (src->indirect != NULL) {
|
|
|
|
fprintf(fp, " + ");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(src->indirect, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
fprintf(fp, "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_reg_dest(nir_reg_dest *dest, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
print_register(dest->reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
if (dest->reg->num_array_elems != 0) {
|
|
|
|
fprintf(fp, "[%u", dest->base_offset);
|
|
|
|
if (dest->indirect != NULL) {
|
|
|
|
fprintf(fp, " + ");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(dest->indirect, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
fprintf(fp, "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-12-19 20:13:46 +00:00
|
|
|
print_src(const nir_src *src, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
|
|
|
if (src->is_ssa)
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_use(src->ssa, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
else
|
2015-09-15 23:50:41 +01:00
|
|
|
print_reg_src(&src->reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_dest(nir_dest *dest, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
|
|
|
if (dest->is_ssa)
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_def(&dest->ssa, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
else
|
2015-09-15 23:50:41 +01:00
|
|
|
print_reg_dest(&dest->reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2019-03-09 16:17:55 +00:00
|
|
|
static const char *
|
|
|
|
comp_mask_string(unsigned num_components)
|
|
|
|
{
|
|
|
|
return (num_components > 4) ? "abcdefghijklmnop" : "xyzw";
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2015-04-02 00:16:52 +01:00
|
|
|
if (instr->src[src].negate)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "-");
|
2015-04-02 00:16:52 +01:00
|
|
|
if (instr->src[src].abs)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "abs(");
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&instr->src[src].src, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2015-03-24 01:20:21 +00:00
|
|
|
bool print_swizzle = false;
|
2018-07-12 02:40:23 +01:00
|
|
|
nir_component_mask_t used_channels = 0;
|
2015-09-22 18:30:05 +01:00
|
|
|
|
2018-07-12 02:40:23 +01:00
|
|
|
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {
|
2015-04-02 00:16:52 +01:00
|
|
|
if (!nir_alu_instr_channel_used(instr, src, i))
|
|
|
|
continue;
|
2015-03-24 01:20:21 +00:00
|
|
|
|
2015-09-22 18:30:05 +01:00
|
|
|
used_channels++;
|
|
|
|
|
2015-04-02 00:16:52 +01:00
|
|
|
if (instr->src[src].swizzle[i] != i) {
|
2015-03-24 01:20:21 +00:00
|
|
|
print_swizzle = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 02:11:12 +01:00
|
|
|
unsigned live_channels = nir_src_num_components(instr->src[src].src);
|
2015-09-22 18:30:05 +01:00
|
|
|
|
|
|
|
if (print_swizzle || used_channels != live_channels) {
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ".");
|
2018-07-12 02:40:23 +01:00
|
|
|
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) {
|
2015-04-02 00:16:52 +01:00
|
|
|
if (!nir_alu_instr_channel_used(instr, src, i))
|
|
|
|
continue;
|
2015-03-24 01:20:21 +00:00
|
|
|
|
2019-03-09 16:17:55 +00:00
|
|
|
fprintf(fp, "%c", comp_mask_string(live_channels)[instr->src[src].swizzle[i]]);
|
2015-03-24 01:20:21 +00:00
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-04-02 00:16:52 +01:00
|
|
|
if (instr->src[src].abs)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_alu_dest(nir_alu_dest *dest, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2014-07-30 23:29:27 +01:00
|
|
|
/* we're going to print the saturate modifier later, after the opcode */
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_dest(&dest->dest, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
if (!dest->dest.is_ssa &&
|
|
|
|
dest->write_mask != (1 << dest->dest.reg.reg->num_components) - 1) {
|
2019-03-09 16:17:55 +00:00
|
|
|
unsigned live_channels = dest->dest.reg.reg->num_components;
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ".");
|
2018-07-12 02:40:23 +01:00
|
|
|
for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
|
2014-07-30 23:29:27 +01:00
|
|
|
if ((dest->write_mask >> i) & 1)
|
2019-03-09 16:17:55 +00:00
|
|
|
fprintf(fp, "%c", comp_mask_string(live_channels)[i]);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_alu_instr(nir_alu_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
|
|
|
print_alu_dest(&instr->dest, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
fprintf(fp, " = %s", nir_op_infos[instr->op].name);
|
2016-03-17 17:50:27 +00:00
|
|
|
if (instr->exact)
|
|
|
|
fprintf(fp, "!");
|
2014-07-30 23:29:27 +01:00
|
|
|
if (instr->dest.saturate)
|
|
|
|
fprintf(fp, ".sat");
|
2019-05-17 21:46:38 +01:00
|
|
|
if (instr->no_signed_wrap)
|
|
|
|
fprintf(fp, ".nsw");
|
|
|
|
if (instr->no_unsigned_wrap)
|
|
|
|
fprintf(fp, ".nuw");
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, " ");
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (i != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_alu_src(instr, i, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-26 18:26:29 +00:00
|
|
|
static const char *
|
|
|
|
get_var_name(nir_variable *var, print_state *state)
|
|
|
|
{
|
|
|
|
if (state->ht == NULL)
|
2017-06-27 01:07:21 +01:00
|
|
|
return var->name ? var->name : "unnamed";
|
2015-12-26 18:26:29 +00:00
|
|
|
|
|
|
|
assert(state->syms);
|
|
|
|
|
|
|
|
struct hash_entry *entry = _mesa_hash_table_search(state->ht, var);
|
|
|
|
if (entry)
|
|
|
|
return entry->data;
|
|
|
|
|
|
|
|
char *name;
|
|
|
|
if (var->name == NULL) {
|
|
|
|
name = ralloc_asprintf(state->syms, "@%u", state->index++);
|
|
|
|
} else {
|
|
|
|
struct set_entry *set_entry = _mesa_set_search(state->syms, var->name);
|
|
|
|
if (set_entry != NULL) {
|
|
|
|
/* we have a collision with another name, append an @ + a unique
|
|
|
|
* index */
|
|
|
|
name = ralloc_asprintf(state->syms, "%s@%u", var->name,
|
|
|
|
state->index++);
|
|
|
|
} else {
|
|
|
|
/* Mark this one as seen */
|
|
|
|
_mesa_set_add(state->syms, var->name);
|
|
|
|
name = var->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_mesa_hash_table_insert(state->ht, var, name);
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:47:58 +01:00
|
|
|
static const char *
|
|
|
|
get_constant_sampler_addressing_mode(enum cl_sampler_addressing_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case SAMPLER_ADDRESSING_MODE_NONE: return "none";
|
|
|
|
case SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: return "clamp_to_edge";
|
|
|
|
case SAMPLER_ADDRESSING_MODE_CLAMP: return "clamp";
|
|
|
|
case SAMPLER_ADDRESSING_MODE_REPEAT: return "repeat";
|
|
|
|
case SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED: return "repeat_mirrored";
|
|
|
|
default: unreachable("Invalid addressing mode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
get_constant_sampler_filter_mode(enum cl_sampler_filter_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case SAMPLER_FILTER_MODE_NEAREST: return "nearest";
|
|
|
|
case SAMPLER_FILTER_MODE_LINEAR: return "linear";
|
|
|
|
default: unreachable("Invalid filter mode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-22 21:50:23 +00:00
|
|
|
static void
|
|
|
|
print_constant(nir_constant *c, const struct glsl_type *type, print_state *state)
|
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
2016-11-30 06:19:28 +00:00
|
|
|
const unsigned rows = glsl_get_vector_elements(type);
|
|
|
|
const unsigned cols = glsl_get_matrix_columns(type);
|
2019-06-06 16:51:25 +01:00
|
|
|
unsigned i;
|
2015-12-22 21:50:23 +00:00
|
|
|
|
|
|
|
switch (glsl_get_base_type(type)) {
|
2018-10-19 17:14:47 +01:00
|
|
|
case GLSL_TYPE_BOOL:
|
|
|
|
/* Only float base types can be matrices. */
|
|
|
|
assert(cols == 1);
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
2019-06-06 16:51:25 +01:00
|
|
|
fprintf(fp, "%s", c->values[i].b ? "true" : "false");
|
2018-10-19 17:14:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-05-10 09:20:47 +01:00
|
|
|
case GLSL_TYPE_UINT8:
|
|
|
|
case GLSL_TYPE_INT8:
|
|
|
|
/* Only float base types can be matrices. */
|
|
|
|
assert(cols == 1);
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
2019-06-06 16:51:25 +01:00
|
|
|
fprintf(fp, "0x%02x", c->values[i].u8);
|
2018-05-10 09:20:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLSL_TYPE_UINT16:
|
|
|
|
case GLSL_TYPE_INT16:
|
|
|
|
/* Only float base types can be matrices. */
|
|
|
|
assert(cols == 1);
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
2019-06-06 16:51:25 +01:00
|
|
|
fprintf(fp, "0x%04x", c->values[i].u16);
|
2018-05-10 09:20:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-12-22 21:50:23 +00:00
|
|
|
case GLSL_TYPE_UINT:
|
|
|
|
case GLSL_TYPE_INT:
|
2016-12-05 19:51:54 +00:00
|
|
|
/* Only float base types can be matrices. */
|
|
|
|
assert(cols == 1);
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
2019-06-06 16:51:25 +01:00
|
|
|
fprintf(fp, "0x%08x", c->values[i].u32);
|
2015-12-22 21:50:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-05-10 09:20:47 +01:00
|
|
|
case GLSL_TYPE_FLOAT16:
|
2015-12-22 21:50:23 +00:00
|
|
|
case GLSL_TYPE_FLOAT:
|
2015-08-14 18:37:18 +01:00
|
|
|
case GLSL_TYPE_DOUBLE:
|
2019-06-06 16:51:25 +01:00
|
|
|
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");
|
2016-11-30 06:19:28 +00:00
|
|
|
}
|
2015-08-14 18:37:18 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-09-01 22:17:49 +01:00
|
|
|
case GLSL_TYPE_UINT64:
|
|
|
|
case GLSL_TYPE_INT64:
|
|
|
|
/* Only float base types can be matrices. */
|
|
|
|
assert(cols == 1);
|
|
|
|
|
|
|
|
for (i = 0; i < cols; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
2019-06-06 16:51:25 +01:00
|
|
|
fprintf(fp, "0x%08" PRIx64, c->values[i].u64);
|
2016-09-01 22:17:49 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-12-22 21:50:23 +00:00
|
|
|
case GLSL_TYPE_STRUCT:
|
2020-07-10 21:58:39 +01:00
|
|
|
case GLSL_TYPE_INTERFACE:
|
2015-12-22 21:50:23 +00:00
|
|
|
for (i = 0; i < c->num_elements; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "{ ");
|
|
|
|
print_constant(c->elements[i], glsl_get_struct_field(type, i), state);
|
|
|
|
fprintf(fp, " }");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLSL_TYPE_ARRAY:
|
|
|
|
for (i = 0; i < c->num_elements; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "{ ");
|
|
|
|
print_constant(c->elements[i], glsl_get_array_element(type), state);
|
|
|
|
fprintf(fp, " }");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-15 09:00:05 +01:00
|
|
|
static const char *
|
2018-03-15 04:45:38 +00:00
|
|
|
get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode)
|
2016-04-15 09:00:05 +01:00
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case nir_var_shader_in:
|
|
|
|
return "shader_in";
|
|
|
|
case nir_var_shader_out:
|
|
|
|
return "shader_out";
|
|
|
|
case nir_var_uniform:
|
|
|
|
return "uniform";
|
2019-01-15 23:09:27 +00:00
|
|
|
case nir_var_mem_ubo:
|
2018-12-14 17:21:50 +00:00
|
|
|
return "ubo";
|
2016-04-15 09:00:05 +01:00
|
|
|
case nir_var_system_value:
|
|
|
|
return "system";
|
2019-01-15 23:11:23 +00:00
|
|
|
case nir_var_mem_ssbo:
|
2018-12-14 17:21:50 +00:00
|
|
|
return "ssbo";
|
2019-01-15 23:12:38 +00:00
|
|
|
case nir_var_mem_shared:
|
2016-04-15 09:00:05 +01:00
|
|
|
return "shared";
|
2018-10-23 13:06:16 +01:00
|
|
|
case nir_var_mem_global:
|
|
|
|
return "global";
|
2020-05-27 22:51:04 +01:00
|
|
|
case nir_var_mem_push_const:
|
|
|
|
return "push_const";
|
2020-08-18 20:02:21 +01:00
|
|
|
case nir_var_mem_constant:
|
|
|
|
return "constant";
|
2021-10-15 18:58:22 +01:00
|
|
|
case nir_var_image:
|
2020-01-08 21:54:47 +00:00
|
|
|
return "image";
|
2019-01-15 22:56:29 +00:00
|
|
|
case nir_var_shader_temp:
|
|
|
|
return want_local_global_mode ? "shader_temp" : "";
|
2019-01-15 23:05:04 +00:00
|
|
|
case nir_var_function_temp:
|
|
|
|
return want_local_global_mode ? "function_temp" : "";
|
2020-07-29 20:00:29 +01:00
|
|
|
case nir_var_shader_call_data:
|
|
|
|
return "shader_call_data";
|
|
|
|
case nir_var_ray_hit_attrib:
|
|
|
|
return "ray_hit_attrib";
|
2022-02-08 01:55:18 +00:00
|
|
|
case nir_var_mem_task_payload:
|
|
|
|
return "task_payload";
|
2016-04-15 09:00:05 +01:00
|
|
|
default:
|
2020-08-15 06:28:55 +01:00
|
|
|
if (mode && (mode & nir_var_mem_generic) == mode)
|
|
|
|
return "generic";
|
2016-04-15 09:00:05 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(nir_variable *var, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "decl_var ");
|
|
|
|
|
2021-09-14 20:28:24 +01:00
|
|
|
const char *const bindless = (var->data.bindless) ? "bindless " : "";
|
2014-07-30 23:29:27 +01:00
|
|
|
const char *const cent = (var->data.centroid) ? "centroid " : "";
|
|
|
|
const char *const samp = (var->data.sample) ? "sample " : "";
|
2015-10-02 08:01:23 +01:00
|
|
|
const char *const patch = (var->data.patch) ? "patch " : "";
|
2014-07-30 23:29:27 +01:00
|
|
|
const char *const inv = (var->data.invariant) ? "invariant " : "";
|
2020-02-11 22:41:05 +00:00
|
|
|
const char *const per_view = (var->data.per_view) ? "per_view " : "";
|
2021-04-29 19:51:57 +01:00
|
|
|
const char *const per_primitive = (var->data.per_primitive) ? "per_primitive " : "";
|
2021-10-20 13:51:43 +01:00
|
|
|
const char *const ray_query = (var->data.ray_query) ? "ray_query " : "";
|
|
|
|
fprintf(fp, "%s%s%s%s%s%s%s%s%s %s ",
|
|
|
|
bindless, cent, samp, patch, inv, per_view, per_primitive, ray_query,
|
2020-02-11 22:41:05 +00:00
|
|
|
get_variable_mode_str(var->data.mode, false),
|
2016-07-07 10:02:38 +01:00
|
|
|
glsl_interp_mode_name(var->data.interpolation));
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2019-11-07 21:53:58 +00:00
|
|
|
enum gl_access_qualifier access = var->data.access;
|
2018-08-16 21:11:12 +01:00
|
|
|
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 " : "";
|
2019-05-31 18:03:48 +01:00
|
|
|
const char *const reorder = (access & ACCESS_CAN_REORDER) ? "reorderable " : "";
|
2021-11-10 09:25:05 +00:00
|
|
|
const char *const stream_cache_policy = (access & ACCESS_STREAM_CACHE_POLICY) ?
|
|
|
|
"stream-cache-policy " : "";
|
2021-10-29 16:04:55 +01:00
|
|
|
const char *const include_helpers = (access & ACCESS_INCLUDE_HELPERS) ?
|
|
|
|
"include-helpers " : "";
|
|
|
|
fprintf(fp, "%s%s%s%s%s%s%s%s", coher, volat, restr, ronly, wonly, reorder,
|
|
|
|
stream_cache_policy, include_helpers);
|
2016-05-05 12:52:38 +01:00
|
|
|
|
2019-11-07 22:54:13 +00:00
|
|
|
if (glsl_get_base_type(glsl_without_array(var->type)) == GLSL_TYPE_IMAGE) {
|
2020-01-10 22:09:43 +00:00
|
|
|
fprintf(fp, "%s ", util_format_short_name(var->data.image.format));
|
2019-11-07 22:54:13 +00:00
|
|
|
}
|
2018-12-13 19:15:07 +00:00
|
|
|
|
2020-03-04 19:54:26 +00:00
|
|
|
if (var->data.precision) {
|
|
|
|
const char *precisions[] = {
|
|
|
|
"",
|
|
|
|
"highp",
|
|
|
|
"mediump",
|
|
|
|
"lowp",
|
|
|
|
};
|
|
|
|
fprintf(fp, "%s ", precisions[var->data.precision]);
|
|
|
|
}
|
|
|
|
|
2016-10-05 19:58:59 +01:00
|
|
|
fprintf(fp, "%s %s", glsl_get_type_name(var->type),
|
|
|
|
get_var_name(var, state));
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2020-01-08 21:54:47 +00:00
|
|
|
if (var->data.mode & (nir_var_shader_in |
|
|
|
|
nir_var_shader_out |
|
|
|
|
nir_var_uniform |
|
|
|
|
nir_var_mem_ubo |
|
|
|
|
nir_var_mem_ssbo |
|
2021-10-15 18:58:22 +01:00
|
|
|
nir_var_image)) {
|
2015-09-15 23:55:48 +01:00
|
|
|
const char *loc = NULL;
|
|
|
|
char buf[4];
|
|
|
|
|
2017-09-15 03:52:38 +01:00
|
|
|
switch (state->shader->info.stage) {
|
2015-09-15 23:55:48 +01:00
|
|
|
case MESA_SHADER_VERTEX:
|
|
|
|
if (var->data.mode == nir_var_shader_in)
|
|
|
|
loc = gl_vert_attrib_name(var->data.location);
|
|
|
|
else if (var->data.mode == nir_var_shader_out)
|
2020-11-27 10:26:34 +00:00
|
|
|
loc = gl_varying_slot_name_for_stage(var->data.location,
|
|
|
|
state->shader->info.stage);
|
2015-09-15 23:55:48 +01:00
|
|
|
break;
|
2021-12-01 18:05:12 +00:00
|
|
|
case MESA_SHADER_TASK:
|
|
|
|
case MESA_SHADER_MESH:
|
2015-09-15 23:55:48 +01:00
|
|
|
case MESA_SHADER_GEOMETRY:
|
|
|
|
if ((var->data.mode == nir_var_shader_in) ||
|
2020-11-27 10:26:34 +00:00
|
|
|
(var->data.mode == nir_var_shader_out)) {
|
|
|
|
loc = gl_varying_slot_name_for_stage(var->data.location,
|
|
|
|
state->shader->info.stage);
|
|
|
|
}
|
2015-09-15 23:55:48 +01:00
|
|
|
break;
|
|
|
|
case MESA_SHADER_FRAGMENT:
|
2020-11-27 10:26:34 +00:00
|
|
|
if (var->data.mode == nir_var_shader_in) {
|
|
|
|
loc = gl_varying_slot_name_for_stage(var->data.location,
|
|
|
|
state->shader->info.stage);
|
|
|
|
} else if (var->data.mode == nir_var_shader_out) {
|
2015-09-15 23:55:48 +01:00
|
|
|
loc = gl_frag_result_name(var->data.location);
|
2020-11-27 10:26:34 +00:00
|
|
|
}
|
2015-09-15 23:55:48 +01:00
|
|
|
break;
|
|
|
|
case MESA_SHADER_TESS_CTRL:
|
|
|
|
case MESA_SHADER_TESS_EVAL:
|
|
|
|
case MESA_SHADER_COMPUTE:
|
2018-11-29 14:21:12 +00:00
|
|
|
case MESA_SHADER_KERNEL:
|
2015-09-15 23:55:48 +01:00
|
|
|
default:
|
|
|
|
/* TODO */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!loc) {
|
2019-12-19 00:46:41 +00:00
|
|
|
if (var->data.location == ~0) {
|
|
|
|
loc = "~0";
|
|
|
|
} else {
|
|
|
|
snprintf(buf, sizeof(buf), "%u", var->data.location);
|
|
|
|
loc = buf;
|
|
|
|
}
|
2015-09-15 23:55:48 +01:00
|
|
|
}
|
|
|
|
|
2017-10-17 18:41:55 +01:00
|
|
|
/* For shader I/O vars that have been split to components or packed,
|
|
|
|
* print the fractional location within the input/output.
|
|
|
|
*/
|
|
|
|
unsigned int num_components =
|
|
|
|
glsl_get_components(glsl_without_array(var->type));
|
|
|
|
const char *components = NULL;
|
2020-01-08 15:09:10 +00:00
|
|
|
char components_local[18] = {'.' /* the rest is 0-filled */};
|
2017-10-17 18:41:55 +01:00
|
|
|
switch (var->data.mode) {
|
|
|
|
case nir_var_shader_in:
|
|
|
|
case nir_var_shader_out:
|
2019-03-09 16:17:55 +00:00
|
|
|
if (num_components < 16 && num_components != 0) {
|
|
|
|
const char *xyzw = comp_mask_string(num_components);
|
2017-10-17 18:41:55 +01:00
|
|
|
for (int i = 0; i < num_components; i++)
|
|
|
|
components_local[i + 1] = xyzw[i + var->data.location_frac];
|
|
|
|
|
|
|
|
components = components_local;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, " (%s%s, %u, %u)%s", loc,
|
|
|
|
components ? components : "",
|
|
|
|
var->data.driver_location, var->data.binding,
|
2016-10-04 04:32:22 +01:00
|
|
|
var->data.compact ? " compact" : "");
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 21:50:23 +00:00
|
|
|
if (var->constant_initializer) {
|
|
|
|
fprintf(fp, " = { ");
|
|
|
|
print_constant(var->constant_initializer, var->type, state);
|
|
|
|
fprintf(fp, " }");
|
|
|
|
}
|
2020-05-01 18:47:58 +01:00
|
|
|
if (glsl_type_is_sampler(var->type) && var->data.sampler.is_inline_sampler) {
|
|
|
|
fprintf(fp, " = { %s, %s, %s }",
|
|
|
|
get_constant_sampler_addressing_mode(var->data.sampler.addressing_mode),
|
|
|
|
var->data.sampler.normalized_coordinates ? "true" : "false",
|
|
|
|
get_constant_sampler_filter_mode(var->data.sampler.filter_mode));
|
|
|
|
}
|
2019-12-10 20:37:53 +00:00
|
|
|
if (var->pointer_initializer)
|
|
|
|
fprintf(fp, " = &%s", get_var_name(var->pointer_initializer, state));
|
2015-12-22 21:50:23 +00:00
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "\n");
|
2016-05-14 20:37:32 +01:00
|
|
|
print_annotation(state, var);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2018-03-15 04:45:38 +00:00
|
|
|
static void
|
2018-12-19 20:13:46 +00:00
|
|
|
print_deref_link(const nir_deref_instr *instr, bool whole_chain, print_state *state)
|
2018-03-15 04:45:38 +00:00
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
|
|
|
if (instr->deref_type == nir_deref_type_var) {
|
|
|
|
fprintf(fp, "%s", get_var_name(instr->var, state));
|
|
|
|
return;
|
|
|
|
} else if (instr->deref_type == nir_deref_type_cast) {
|
|
|
|
fprintf(fp, "(%s *)", glsl_get_type_name(instr->type));
|
|
|
|
print_src(&instr->parent, state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(instr->parent.is_ssa);
|
|
|
|
nir_deref_instr *parent =
|
|
|
|
nir_instr_as_deref(instr->parent.ssa->parent_instr);
|
|
|
|
|
|
|
|
/* Is the parent we're going to print a bare cast? */
|
|
|
|
const bool is_parent_cast =
|
|
|
|
whole_chain && parent->deref_type == nir_deref_type_cast;
|
|
|
|
|
|
|
|
/* If we're not printing the whole chain, the parent we print will be a SSA
|
|
|
|
* value that represents a pointer. The only deref type that naturally
|
|
|
|
* gives a pointer is a cast.
|
|
|
|
*/
|
|
|
|
const bool is_parent_pointer =
|
|
|
|
!whole_chain || parent->deref_type == nir_deref_type_cast;
|
|
|
|
|
|
|
|
/* Struct derefs have a nice syntax that works on pointers, arrays derefs
|
|
|
|
* do not.
|
|
|
|
*/
|
|
|
|
const bool need_deref =
|
|
|
|
is_parent_pointer && instr->deref_type != nir_deref_type_struct;
|
|
|
|
|
|
|
|
/* Cast need extra parens and so * dereferences */
|
|
|
|
if (is_parent_cast || need_deref)
|
|
|
|
fprintf(fp, "(");
|
|
|
|
|
|
|
|
if (need_deref)
|
|
|
|
fprintf(fp, "*");
|
|
|
|
|
|
|
|
if (whole_chain) {
|
|
|
|
print_deref_link(parent, whole_chain, state);
|
|
|
|
} else {
|
|
|
|
print_src(&instr->parent, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_parent_cast || need_deref)
|
|
|
|
fprintf(fp, ")");
|
|
|
|
|
|
|
|
switch (instr->deref_type) {
|
|
|
|
case nir_deref_type_struct:
|
|
|
|
fprintf(fp, "%s%s", is_parent_pointer ? "->" : ".",
|
|
|
|
glsl_get_struct_elem_name(parent->type, instr->strct.index));
|
|
|
|
break;
|
|
|
|
|
2018-11-28 18:26:52 +00:00
|
|
|
case nir_deref_type_array:
|
|
|
|
case nir_deref_type_ptr_as_array: {
|
2019-04-02 03:36:12 +01:00
|
|
|
if (nir_src_is_const(instr->arr.index)) {
|
2019-06-26 12:41:20 +01:00
|
|
|
fprintf(fp, "[%"PRId64"]", nir_src_as_int(instr->arr.index));
|
2018-03-15 04:45:38 +00:00
|
|
|
} else {
|
|
|
|
fprintf(fp, "[");
|
|
|
|
print_src(&instr->arr.index, state);
|
|
|
|
fprintf(fp, "]");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case nir_deref_type_array_wildcard:
|
|
|
|
fprintf(fp, "[*]");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("Invalid deref instruction type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_deref_instr(nir_deref_instr *instr, print_state *state)
|
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
|
|
|
print_dest(&instr->dest, state);
|
|
|
|
|
|
|
|
switch (instr->deref_type) {
|
|
|
|
case nir_deref_type_var:
|
|
|
|
fprintf(fp, " = deref_var ");
|
|
|
|
break;
|
|
|
|
case nir_deref_type_array:
|
|
|
|
case nir_deref_type_array_wildcard:
|
|
|
|
fprintf(fp, " = deref_array ");
|
|
|
|
break;
|
|
|
|
case nir_deref_type_struct:
|
|
|
|
fprintf(fp, " = deref_struct ");
|
|
|
|
break;
|
|
|
|
case nir_deref_type_cast:
|
|
|
|
fprintf(fp, " = deref_cast ");
|
|
|
|
break;
|
2018-11-28 18:26:52 +00:00
|
|
|
case nir_deref_type_ptr_as_array:
|
|
|
|
fprintf(fp, " = deref_ptr_as_array ");
|
|
|
|
break;
|
2018-03-15 04:45:38 +00:00
|
|
|
default:
|
|
|
|
unreachable("Invalid deref instruction type");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only casts naturally return a pointer type */
|
|
|
|
if (instr->deref_type != nir_deref_type_cast)
|
|
|
|
fprintf(fp, "&");
|
|
|
|
|
|
|
|
print_deref_link(instr, false, state);
|
|
|
|
|
2020-08-15 06:28:55 +01:00
|
|
|
fprintf(fp, " (");
|
|
|
|
unsigned modes = instr->modes;
|
|
|
|
while (modes) {
|
|
|
|
int m = u_bit_scan(&modes);
|
|
|
|
fprintf(fp, "%s%s", get_variable_mode_str(1 << m, true),
|
|
|
|
modes ? "|" : "");
|
|
|
|
}
|
|
|
|
fprintf(fp, " %s) ", glsl_get_type_name(instr->type));
|
2018-03-15 04:45:38 +00:00
|
|
|
|
|
|
|
if (instr->deref_type != nir_deref_type_var &&
|
|
|
|
instr->deref_type != nir_deref_type_cast) {
|
|
|
|
/* Print the entire chain as a comment */
|
|
|
|
fprintf(fp, "/* &");
|
|
|
|
print_deref_link(instr, true, state);
|
|
|
|
fprintf(fp, " */");
|
|
|
|
}
|
2019-07-03 20:10:43 +01:00
|
|
|
|
|
|
|
if (instr->deref_type == nir_deref_type_cast) {
|
2020-09-08 20:50:34 +01:00
|
|
|
fprintf(fp, " /* ptr_stride=%u, align_mul=%u, align_offset=%u */",
|
|
|
|
instr->cast.ptr_stride,
|
|
|
|
instr->cast.align_mul, instr->cast.align_offset);
|
2019-07-03 20:10:43 +01:00
|
|
|
}
|
2018-03-15 04:45:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-13 22:50:19 +00:00
|
|
|
static const char *
|
|
|
|
vulkan_descriptor_type_name(VkDescriptorType type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLER: return "sampler";
|
|
|
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: return "texture+sampler";
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: return "texture";
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: return "image";
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: return "texture-buffer";
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: return "image-buffer";
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: return "UBO";
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: return "SSBO";
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: return "UBO";
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: return "SSBO";
|
|
|
|
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: return "input-att";
|
2022-07-01 13:07:26 +01:00
|
|
|
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK: return "inline-UBO";
|
2020-05-14 22:06:52 +01:00
|
|
|
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: return "accel-struct";
|
2018-12-13 22:50:19 +00:00
|
|
|
default: return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 17:43:11 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2016-01-13 23:43:14 +00:00
|
|
|
const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
|
|
|
|
unsigned num_srcs = info->num_srcs;
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2016-01-13 23:43:14 +00:00
|
|
|
if (info->has_dest) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_dest(&instr->dest, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, " = ");
|
|
|
|
}
|
|
|
|
|
2016-01-13 23:43:14 +00:00
|
|
|
fprintf(fp, "intrinsic %s (", info->name);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < num_srcs; i++) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (i != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&instr->src[i], state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, ") (");
|
|
|
|
|
2016-01-13 23:43:14 +00:00
|
|
|
for (unsigned i = 0; i < info->num_indices; i++) {
|
2021-10-19 10:27:40 +01:00
|
|
|
unsigned idx = info->indices[i];
|
|
|
|
bool print_raw = true;
|
2014-12-18 22:01:37 +00:00
|
|
|
if (i != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
2019-03-07 19:07:04 +00:00
|
|
|
switch (idx) {
|
2020-11-24 12:51:59 +00:00
|
|
|
case NIR_INTRINSIC_WRITE_MASK: {
|
2016-01-13 23:43:14 +00:00
|
|
|
/* special case wrmask to show it as a writemask.. */
|
|
|
|
unsigned wrmask = nir_intrinsic_write_mask(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "wrmask=");
|
2019-03-09 16:17:55 +00:00
|
|
|
for (unsigned i = 0; i < instr->num_components; i++)
|
2016-01-13 23:43:14 +00:00
|
|
|
if ((wrmask >> i) & 1)
|
2019-03-09 16:17:55 +00:00
|
|
|
fprintf(fp, "%c", comp_mask_string(instr->num_components)[i]);
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NIR_INTRINSIC_REDUCTION_OP: {
|
2017-08-30 04:09:58 +01:00
|
|
|
nir_op reduction_op = nir_intrinsic_reduction_op(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "reduction_op=%s", nir_op_infos[reduction_op].name);
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NIR_INTRINSIC_IMAGE_DIM: {
|
2018-08-16 21:11:44 +01:00
|
|
|
static const char *dim_name[] = {
|
|
|
|
[GLSL_SAMPLER_DIM_1D] = "1D",
|
|
|
|
[GLSL_SAMPLER_DIM_2D] = "2D",
|
|
|
|
[GLSL_SAMPLER_DIM_3D] = "3D",
|
|
|
|
[GLSL_SAMPLER_DIM_CUBE] = "Cube",
|
|
|
|
[GLSL_SAMPLER_DIM_RECT] = "Rect",
|
|
|
|
[GLSL_SAMPLER_DIM_BUF] = "Buf",
|
|
|
|
[GLSL_SAMPLER_DIM_MS] = "2D-MSAA",
|
|
|
|
[GLSL_SAMPLER_DIM_SUBPASS] = "Subpass",
|
|
|
|
[GLSL_SAMPLER_DIM_SUBPASS_MS] = "Subpass-MSAA",
|
|
|
|
};
|
|
|
|
enum glsl_sampler_dim dim = nir_intrinsic_image_dim(instr);
|
2018-11-26 15:04:30 +00:00
|
|
|
assert(dim < ARRAY_SIZE(dim_name) && dim_name[dim]);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "image_dim=%s", dim_name[dim]);
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NIR_INTRINSIC_IMAGE_ARRAY: {
|
2019-03-28 22:50:54 +00:00
|
|
|
bool array = nir_intrinsic_image_array(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "image_array=%s", array ? "true" : "false");
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-05 18:30:05 +01:00
|
|
|
case NIR_INTRINSIC_FORMAT: {
|
|
|
|
enum pipe_format format = nir_intrinsic_format(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "format=%s", util_format_short_name(format));
|
2020-06-05 18:30:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-07 19:07:04 +00:00
|
|
|
case NIR_INTRINSIC_DESC_TYPE: {
|
2018-12-13 22:50:19 +00:00
|
|
|
VkDescriptorType desc_type = nir_intrinsic_desc_type(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "desc_type=%s", vulkan_descriptor_type_name(desc_type));
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-01 03:20:53 +01:00
|
|
|
case NIR_INTRINSIC_SRC_TYPE: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "src_type=");
|
2020-10-01 03:20:53 +01:00
|
|
|
print_alu_type(nir_intrinsic_src_type(instr), state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NIR_INTRINSIC_DEST_TYPE: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "dest_type=");
|
2020-10-01 03:20:53 +01:00
|
|
|
print_alu_type(nir_intrinsic_dest_type(instr), state);
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NIR_INTRINSIC_SWIZZLE_MASK: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "swizzle_mask=");
|
2018-05-09 19:37:24 +01:00
|
|
|
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);
|
|
|
|
}
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-07-19 00:14:03 +01:00
|
|
|
case NIR_INTRINSIC_MEMORY_SEMANTICS: {
|
|
|
|
nir_memory_semantics semantics = nir_intrinsic_memory_semantics(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "mem_semantics=");
|
2019-07-19 00:14:03 +01:00
|
|
|
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: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "mem_modes=");
|
2019-07-19 00:14:03 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-05-05 08:13:20 +01:00
|
|
|
case NIR_INTRINSIC_EXECUTION_SCOPE:
|
2019-07-19 00:14:03 +01:00
|
|
|
case NIR_INTRINSIC_MEMORY_SCOPE: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "%s=", nir_intrinsic_index_names[idx]);
|
2020-06-05 23:26:47 +01:00
|
|
|
nir_scope scope =
|
|
|
|
idx == NIR_INTRINSIC_MEMORY_SCOPE ? nir_intrinsic_memory_scope(instr)
|
|
|
|
: nir_intrinsic_execution_scope(instr);
|
|
|
|
switch (scope) {
|
2020-05-05 08:13:20 +01:00
|
|
|
case NIR_SCOPE_NONE: fprintf(fp, "NONE"); break;
|
2019-07-19 00:14:03 +01:00
|
|
|
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;
|
2020-08-05 20:50:36 +01:00
|
|
|
case NIR_SCOPE_SHADER_CALL: fprintf(fp, "SHADER_CALL"); break;
|
2019-07-19 00:14:03 +01:00
|
|
|
case NIR_SCOPE_SUBGROUP: fprintf(fp, "SUBGROUP"); break;
|
|
|
|
case NIR_SCOPE_INVOCATION: fprintf(fp, "INVOCATION"); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:29:23 +01:00
|
|
|
case NIR_INTRINSIC_IO_SEMANTICS: {
|
|
|
|
struct nir_io_semantics io = nir_intrinsic_io_semantics(instr);
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "io location=%u slots=%u", io.location, io.num_slots);
|
2021-10-18 14:29:23 +01:00
|
|
|
|
|
|
|
if (io.dual_source_blend_index)
|
|
|
|
fprintf(fp, " dualsrc");
|
|
|
|
|
|
|
|
if (io.fb_fetch_output)
|
|
|
|
fprintf(fp, " fbfetch");
|
|
|
|
|
|
|
|
if (io.per_view)
|
|
|
|
fprintf(fp, " perview");
|
|
|
|
|
|
|
|
if (io.medium_precision)
|
|
|
|
fprintf(fp, " mediump");
|
|
|
|
|
|
|
|
if (io.high_16bits)
|
|
|
|
fprintf(fp, " high_16bits");
|
|
|
|
|
2022-01-03 00:46:45 +00:00
|
|
|
if (io.no_varying)
|
|
|
|
fprintf(fp, " no_varying");
|
|
|
|
|
|
|
|
if (io.no_sysval_output)
|
|
|
|
fprintf(fp, " no_sysval_output");
|
|
|
|
|
2021-10-18 14:40:13 +01:00
|
|
|
if (state->shader &&
|
|
|
|
state->shader->info.stage == MESA_SHADER_GEOMETRY &&
|
|
|
|
(instr->intrinsic == nir_intrinsic_store_output ||
|
|
|
|
instr->intrinsic == nir_intrinsic_store_per_primitive_output ||
|
|
|
|
instr->intrinsic == nir_intrinsic_store_per_vertex_output)) {
|
|
|
|
unsigned gs_streams = io.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);
|
2020-08-15 00:34:27 +01:00
|
|
|
}
|
2021-10-18 14:40:13 +01:00
|
|
|
fprintf(fp, ")");
|
2020-08-15 00:34:27 +01:00
|
|
|
}
|
2021-10-18 14:29:23 +01:00
|
|
|
|
2020-08-15 00:34:27 +01:00
|
|
|
break;
|
2021-10-18 14:29:23 +01:00
|
|
|
}
|
2020-08-15 00:34:27 +01:00
|
|
|
|
2021-12-19 19:20:52 +00:00
|
|
|
case NIR_INTRINSIC_IO_XFB:
|
|
|
|
case NIR_INTRINSIC_IO_XFB2: {
|
|
|
|
/* This prints both IO_XFB and IO_XFB2. */
|
|
|
|
fprintf(fp, "xfb%s(", idx == NIR_INTRINSIC_IO_XFB ? "" : "2");
|
|
|
|
bool first = true;
|
|
|
|
for (unsigned i = 0; i < 2; i++) {
|
|
|
|
unsigned start_comp = (idx == NIR_INTRINSIC_IO_XFB ? 0 : 2) + i;
|
|
|
|
nir_io_xfb xfb = start_comp < 2 ? nir_intrinsic_io_xfb(instr) :
|
|
|
|
nir_intrinsic_io_xfb2(instr);
|
|
|
|
|
|
|
|
if (!xfb.out[i].num_components)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
first = false;
|
|
|
|
|
|
|
|
if (xfb.out[i].num_components > 1) {
|
|
|
|
fprintf(fp, "components=%u..%u",
|
|
|
|
start_comp, start_comp + xfb.out[i].num_components - 1);
|
|
|
|
} else {
|
|
|
|
fprintf(fp, "component=%u", start_comp);
|
|
|
|
}
|
|
|
|
fprintf(fp, " buffer=%u offset=%u",
|
|
|
|
xfb.out[i].buffer, (uint32_t)xfb.out[i].offset * 4);
|
|
|
|
}
|
|
|
|
fprintf(fp, ")");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-09-30 21:19:45 +01:00
|
|
|
case NIR_INTRINSIC_ROUNDING_MODE: {
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "rounding_mode=");
|
2020-09-30 21:19:45 +01:00
|
|
|
switch (nir_intrinsic_rounding_mode(instr)) {
|
|
|
|
case nir_rounding_mode_undef: fprintf(fp, "undef"); break;
|
|
|
|
case nir_rounding_mode_rtne: fprintf(fp, "rtne"); break;
|
|
|
|
case nir_rounding_mode_ru: fprintf(fp, "ru"); break;
|
|
|
|
case nir_rounding_mode_rd: fprintf(fp, "rd"); break;
|
|
|
|
case nir_rounding_mode_rtz: fprintf(fp, "rtz"); break;
|
|
|
|
default: fprintf(fp, "unkown"); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-07 19:07:04 +00:00
|
|
|
default: {
|
2016-01-13 23:43:14 +00:00
|
|
|
unsigned off = info->index_map[idx] - 1;
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, "%s=%d", nir_intrinsic_index_names[idx], instr->const_index[off]);
|
|
|
|
print_raw = false;
|
2019-03-07 19:07:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-13 23:43:14 +00:00
|
|
|
}
|
2021-10-19 10:27:40 +01:00
|
|
|
if (print_raw)
|
|
|
|
fprintf(fp, " /*%d*/", instr->const_index[i]);
|
2016-01-13 23:43:14 +00:00
|
|
|
}
|
2021-10-19 10:27:40 +01:00
|
|
|
fprintf(fp, ")");
|
2016-01-13 23:43:14 +00:00
|
|
|
|
2015-09-17 23:18:45 +01:00
|
|
|
if (!state->shader)
|
|
|
|
return;
|
|
|
|
|
2020-07-20 22:30:37 +01:00
|
|
|
nir_variable_mode var_mode;
|
2015-09-17 23:18:45 +01:00
|
|
|
switch (instr->intrinsic) {
|
|
|
|
case nir_intrinsic_load_uniform:
|
2020-07-20 22:30:37 +01:00
|
|
|
var_mode = nir_var_uniform;
|
2015-09-17 23:18:45 +01:00
|
|
|
break;
|
|
|
|
case nir_intrinsic_load_input:
|
2019-03-27 15:29:56 +00:00
|
|
|
case nir_intrinsic_load_interpolated_input:
|
2015-10-01 08:46:19 +01:00
|
|
|
case nir_intrinsic_load_per_vertex_input:
|
2020-07-20 22:30:37 +01:00
|
|
|
var_mode = nir_var_shader_in;
|
2015-09-17 23:18:45 +01:00
|
|
|
break;
|
2015-10-19 19:44:28 +01:00
|
|
|
case nir_intrinsic_load_output:
|
2015-09-17 23:18:45 +01:00
|
|
|
case nir_intrinsic_store_output:
|
2015-10-02 08:11:01 +01:00
|
|
|
case nir_intrinsic_store_per_vertex_output:
|
2020-07-20 22:30:37 +01:00
|
|
|
var_mode = nir_var_shader_out;
|
2015-09-17 23:18:45 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-20 22:30:37 +01:00
|
|
|
nir_foreach_variable_with_modes(var, state->shader, var_mode) {
|
2016-01-21 19:12:58 +00:00
|
|
|
if ((var->data.driver_location == nir_intrinsic_base(instr)) &&
|
2016-05-23 07:46:46 +01:00
|
|
|
(instr->intrinsic == nir_intrinsic_load_uniform ||
|
2019-02-24 00:17:02 +00:00
|
|
|
(nir_intrinsic_component(instr) >= var->data.location_frac &&
|
|
|
|
nir_intrinsic_component(instr) <
|
|
|
|
(var->data.location_frac + glsl_get_components(var->type)))) &&
|
|
|
|
var->name) {
|
2015-09-17 23:18:45 +01:00
|
|
|
fprintf(fp, "\t/* %s */", var->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_tex_instr(nir_tex_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
|
|
|
print_dest(&instr->dest, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2020-06-11 17:43:11 +01:00
|
|
|
fprintf(fp, " = (");
|
|
|
|
print_alu_type(instr->dest_type, state);
|
|
|
|
fprintf(fp, ")");
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
switch (instr->op) {
|
|
|
|
case nir_texop_tex:
|
|
|
|
fprintf(fp, "tex ");
|
|
|
|
break;
|
|
|
|
case nir_texop_txb:
|
|
|
|
fprintf(fp, "txb ");
|
|
|
|
break;
|
|
|
|
case nir_texop_txl:
|
|
|
|
fprintf(fp, "txl ");
|
|
|
|
break;
|
|
|
|
case nir_texop_txd:
|
|
|
|
fprintf(fp, "txd ");
|
|
|
|
break;
|
|
|
|
case nir_texop_txf:
|
|
|
|
fprintf(fp, "txf ");
|
|
|
|
break;
|
|
|
|
case nir_texop_txf_ms:
|
|
|
|
fprintf(fp, "txf_ms ");
|
|
|
|
break;
|
2019-04-26 18:05:08 +01:00
|
|
|
case nir_texop_txf_ms_fb:
|
|
|
|
fprintf(fp, "txf_ms_fb ");
|
|
|
|
break;
|
2021-07-07 23:06:46 +01:00
|
|
|
case nir_texop_txf_ms_mcs_intel:
|
|
|
|
fprintf(fp, "txf_ms_mcs_intel ");
|
2016-05-03 01:28:38 +01:00
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_texop_txs:
|
|
|
|
fprintf(fp, "txs ");
|
|
|
|
break;
|
|
|
|
case nir_texop_lod:
|
|
|
|
fprintf(fp, "lod ");
|
|
|
|
break;
|
|
|
|
case nir_texop_tg4:
|
|
|
|
fprintf(fp, "tg4 ");
|
|
|
|
break;
|
|
|
|
case nir_texop_query_levels:
|
|
|
|
fprintf(fp, "query_levels ");
|
|
|
|
break;
|
2015-08-28 04:05:03 +01:00
|
|
|
case nir_texop_texture_samples:
|
|
|
|
fprintf(fp, "texture_samples ");
|
|
|
|
break;
|
2015-11-18 01:09:09 +00:00
|
|
|
case nir_texop_samples_identical:
|
|
|
|
fprintf(fp, "samples_identical ");
|
|
|
|
break;
|
2019-07-10 08:48:21 +01:00
|
|
|
case nir_texop_tex_prefetch:
|
|
|
|
fprintf(fp, "tex (pre-dispatchable) ");
|
|
|
|
break;
|
2021-08-05 16:19:51 +01:00
|
|
|
case nir_texop_fragment_fetch_amd:
|
|
|
|
fprintf(fp, "fragment_fetch_amd ");
|
2020-01-07 07:39:39 +00:00
|
|
|
break;
|
2021-08-05 16:19:51 +01:00
|
|
|
case nir_texop_fragment_mask_fetch_amd:
|
|
|
|
fprintf(fp, "fragment_mask_fetch_amd ");
|
2020-01-07 07:39:39 +00:00
|
|
|
break;
|
2022-08-05 16:34:09 +01:00
|
|
|
case nir_texop_descriptor_amd:
|
|
|
|
fprintf(fp, "descriptor_amd ");
|
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
default:
|
|
|
|
unreachable("Invalid texture operation");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-06-30 07:08:05 +01:00
|
|
|
bool has_texture_deref = false, has_sampler_deref = false;
|
2014-07-30 23:29:27 +01:00
|
|
|
for (unsigned i = 0; i < instr->num_srcs; i++) {
|
2019-05-02 22:48:41 +01:00
|
|
|
if (i > 0) {
|
2019-04-28 16:06:12 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2019-05-02 22:48:41 +01:00
|
|
|
print_src(&instr->src[i].src, state);
|
|
|
|
fprintf(fp, " ");
|
|
|
|
|
2015-01-10 04:01:13 +00:00
|
|
|
switch(instr->src[i].src_type) {
|
2021-07-15 00:41:58 +01:00
|
|
|
case nir_tex_src_backend1:
|
|
|
|
fprintf(fp, "(backend1)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_backend2:
|
|
|
|
fprintf(fp, "(backend2)");
|
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_tex_src_coord:
|
|
|
|
fprintf(fp, "(coord)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_projector:
|
|
|
|
fprintf(fp, "(projector)");
|
|
|
|
break;
|
2016-12-12 13:32:38 +00:00
|
|
|
case nir_tex_src_comparator:
|
|
|
|
fprintf(fp, "(comparator)");
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
case nir_tex_src_offset:
|
|
|
|
fprintf(fp, "(offset)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_bias:
|
|
|
|
fprintf(fp, "(bias)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_lod:
|
|
|
|
fprintf(fp, "(lod)");
|
|
|
|
break;
|
2018-10-03 03:15:47 +01:00
|
|
|
case nir_tex_src_min_lod:
|
|
|
|
fprintf(fp, "(min_lod)");
|
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_tex_src_ms_index:
|
|
|
|
fprintf(fp, "(ms_index)");
|
|
|
|
break;
|
2021-07-07 23:06:46 +01:00
|
|
|
case nir_tex_src_ms_mcs_intel:
|
|
|
|
fprintf(fp, "(ms_mcs_intel)");
|
2016-05-03 01:28:38 +01:00
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_tex_src_ddx:
|
|
|
|
fprintf(fp, "(ddx)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_ddy:
|
|
|
|
fprintf(fp, "(ddy)");
|
|
|
|
break;
|
2018-03-19 17:24:59 +00:00
|
|
|
case nir_tex_src_texture_deref:
|
2018-06-30 07:08:05 +01:00
|
|
|
has_texture_deref = true;
|
2018-03-19 17:24:59 +00:00
|
|
|
fprintf(fp, "(texture_deref)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_sampler_deref:
|
2018-06-30 07:08:05 +01:00
|
|
|
has_sampler_deref = true;
|
2018-03-19 17:24:59 +00:00
|
|
|
fprintf(fp, "(sampler_deref)");
|
|
|
|
break;
|
2016-02-06 17:05:10 +00:00
|
|
|
case nir_tex_src_texture_offset:
|
|
|
|
fprintf(fp, "(texture_offset)");
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
2015-11-03 01:58:29 +00:00
|
|
|
case nir_tex_src_sampler_offset:
|
|
|
|
fprintf(fp, "(sampler_offset)");
|
|
|
|
break;
|
2018-10-28 12:52:44 +00:00
|
|
|
case nir_tex_src_texture_handle:
|
|
|
|
fprintf(fp, "(texture_handle)");
|
|
|
|
break;
|
|
|
|
case nir_tex_src_sampler_handle:
|
|
|
|
fprintf(fp, "(sampler_handle)");
|
|
|
|
break;
|
2016-05-02 05:12:48 +01:00
|
|
|
case nir_tex_src_plane:
|
|
|
|
fprintf(fp, "(plane)");
|
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("Invalid texture source type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instr->op == nir_texop_tg4) {
|
2019-05-02 22:48:41 +01:00
|
|
|
fprintf(fp, ", %u (gather_component)", instr->component);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
2018-06-30 07:08:05 +01:00
|
|
|
|
2019-03-18 20:23:59 +00:00
|
|
|
if (nir_tex_instr_has_explicit_tg4_offsets(instr)) {
|
2019-04-28 16:06:12 +01:00
|
|
|
fprintf(fp, ", { (%i, %i)", instr->tg4_offsets[0][0], instr->tg4_offsets[0][1]);
|
2019-03-18 20:23:59 +00:00
|
|
|
for (unsigned i = 1; i < 4; ++i)
|
|
|
|
fprintf(fp, ", (%i, %i)", instr->tg4_offsets[i][0],
|
|
|
|
instr->tg4_offsets[i][1]);
|
2019-04-28 16:06:12 +01:00
|
|
|
fprintf(fp, " } (offsets)");
|
2019-03-18 20:23:59 +00:00
|
|
|
}
|
|
|
|
|
2019-04-26 18:05:08 +01:00
|
|
|
if (instr->op != nir_texop_txf_ms_fb) {
|
|
|
|
if (!has_texture_deref) {
|
|
|
|
fprintf(fp, ", %u (texture)", instr->texture_index);
|
|
|
|
}
|
2018-06-30 07:08:05 +01:00
|
|
|
|
2019-04-26 18:05:08 +01:00
|
|
|
if (!has_sampler_deref) {
|
|
|
|
fprintf(fp, ", %u (sampler)", instr->sampler_index);
|
|
|
|
}
|
2018-06-30 07:08:05 +01:00
|
|
|
}
|
2020-01-01 13:47:14 +00:00
|
|
|
|
|
|
|
if (instr->texture_non_uniform) {
|
|
|
|
fprintf(fp, ", texture non-uniform");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instr->sampler_non_uniform) {
|
|
|
|
fprintf(fp, ", sampler non-uniform");
|
|
|
|
}
|
2020-11-20 15:10:42 +00:00
|
|
|
|
|
|
|
if (instr->is_sparse) {
|
|
|
|
fprintf(fp, ", sparse");
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_call_instr(nir_call_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
fprintf(fp, "call %s ", instr->callee->name);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < instr->num_params; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2018-03-22 23:41:18 +00:00
|
|
|
print_src(&instr->params[i], state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_jump_instr(nir_jump_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
switch (instr->type) {
|
|
|
|
case nir_jump_break:
|
|
|
|
fprintf(fp, "break");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_jump_continue:
|
|
|
|
fprintf(fp, "continue");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_jump_return:
|
|
|
|
fprintf(fp, "return");
|
|
|
|
break;
|
2020-07-02 13:32:04 +01:00
|
|
|
|
2020-05-15 21:46:08 +01:00
|
|
|
case nir_jump_halt:
|
|
|
|
fprintf(fp, "halt");
|
|
|
|
break;
|
|
|
|
|
2020-07-02 13:32:04 +01:00
|
|
|
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;
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_undef_instr(nir_ssa_undef_instr* instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
print_ssa_def(&instr->def, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, " = undefined");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_phi_instr(nir_phi_instr *instr, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
print_dest(&instr->dest, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, " = phi ");
|
2016-04-27 04:16:21 +01:00
|
|
|
nir_foreach_phi_src(src, instr) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (&src->node != exec_list_get_head(&instr->srcs))
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
|
|
|
fprintf(fp, "block_%u: ", src->pred->index);
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&src->src, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-31 04:04:15 +00:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_parallel_copy_instr(nir_parallel_copy_instr *instr, print_state *state)
|
2014-10-31 04:04:15 +00:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2016-04-27 04:21:27 +01:00
|
|
|
nir_foreach_parallel_copy_entry(entry, instr) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (&entry->node != exec_list_get_head(&instr->entries))
|
2014-10-31 04:04:15 +00:00
|
|
|
fprintf(fp, "; ");
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_dest(&entry->dest, state);
|
2014-10-31 04:04:15 +00:00
|
|
|
fprintf(fp, " = ");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&entry->src, state);
|
2014-10-31 04:04:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_instr(const nir_instr *instr, print_state *state, unsigned tabs)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2014-07-30 23:29:27 +01:00
|
|
|
print_tabs(tabs, fp);
|
|
|
|
|
|
|
|
switch (instr->type) {
|
|
|
|
case nir_instr_type_alu:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_alu_instr(nir_instr_as_alu(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
2018-03-15 04:45:38 +00:00
|
|
|
case nir_instr_type_deref:
|
|
|
|
print_deref_instr(nir_instr_as_deref(instr), state);
|
|
|
|
break;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_instr_type_call:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_call_instr(nir_instr_as_call(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_instr_type_intrinsic:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_intrinsic_instr(nir_instr_as_intrinsic(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
2014-12-05 19:03:06 +00:00
|
|
|
case nir_instr_type_tex:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_tex_instr(nir_instr_as_tex(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_instr_type_load_const:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_load_const_instr(nir_instr_as_load_const(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_instr_type_jump:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_jump_instr(nir_instr_as_jump(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_instr_type_ssa_undef:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_ssa_undef_instr(nir_instr_as_ssa_undef(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_instr_type_phi:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_phi_instr(nir_instr_as_phi(instr), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
2014-10-31 04:04:15 +00:00
|
|
|
case nir_instr_type_parallel_copy:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_parallel_copy_instr(nir_instr_as_parallel_copy(instr), state);
|
2014-10-31 04:04:15 +00:00
|
|
|
break;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
default:
|
|
|
|
unreachable("Invalid instruction type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
static void print_cf_node(nir_cf_node *node, print_state *state,
|
|
|
|
unsigned tabs);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_block(nir_block *block, print_state *state, unsigned tabs)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "block block_%u:\n", block->index);
|
|
|
|
|
2021-04-08 16:26:38 +01:00
|
|
|
nir_block **preds = nir_block_get_predecessors_sorted(block, NULL);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "/* preds: ");
|
|
|
|
for (unsigned i = 0; i < block->predecessors->entries; i++) {
|
|
|
|
fprintf(fp, "block_%u ", preds[i]->index);
|
|
|
|
}
|
|
|
|
fprintf(fp, "*/\n");
|
|
|
|
|
2021-04-08 16:26:38 +01:00
|
|
|
ralloc_free(preds);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2016-04-27 02:34:19 +01:00
|
|
|
nir_foreach_instr(instr, block) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_instr(instr, state, tabs);
|
2014-11-05 23:10:37 +00:00
|
|
|
fprintf(fp, "\n");
|
2016-05-14 20:37:32 +01:00
|
|
|
print_annotation(state, instr);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "/* succs: ");
|
|
|
|
for (unsigned i = 0; i < 2; i++)
|
|
|
|
if (block->successors[i]) {
|
|
|
|
fprintf(fp, "block_%u ", block->successors[i]->index);
|
|
|
|
}
|
|
|
|
fprintf(fp, "*/\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_if(nir_if *if_stmt, print_state *state, unsigned tabs)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "if ");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&if_stmt->condition, state);
|
2022-08-29 16:18:56 +01:00
|
|
|
switch (if_stmt->control) {
|
|
|
|
case nir_selection_control_flatten:
|
|
|
|
fprintf(fp, " /* flatten */");
|
|
|
|
break;
|
|
|
|
case nir_selection_control_dont_flatten:
|
|
|
|
fprintf(fp, " /* don't flatten */");
|
|
|
|
break;
|
2022-10-10 09:44:35 +01:00
|
|
|
case nir_selection_control_divergent_always_taken:
|
|
|
|
fprintf(fp, " /* divergent always taken */");
|
|
|
|
break;
|
2022-08-29 16:18:56 +01:00
|
|
|
case nir_selection_control_none:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, " {\n");
|
|
|
|
foreach_list_typed(nir_cf_node, node, node, &if_stmt->then_list) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_cf_node(node, state, tabs + 1);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "} else {\n");
|
|
|
|
foreach_list_typed(nir_cf_node, node, node, &if_stmt->else_list) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_cf_node(node, state, tabs + 1);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "}\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_loop(nir_loop *loop, print_state *state, unsigned tabs)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "loop {\n");
|
|
|
|
foreach_list_typed(nir_cf_node, node, node, &loop->body) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_cf_node(node, state, tabs + 1);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
print_tabs(tabs, fp);
|
|
|
|
fprintf(fp, "}\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_cf_node(nir_cf_node *node, print_state *state, unsigned int tabs)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
|
|
|
switch (node->type) {
|
|
|
|
case nir_cf_node_block:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_block(nir_cf_node_as_block(node), state, tabs);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_cf_node_if:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_if(nir_cf_node_as_if(node), state, tabs);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_cf_node_loop:
|
2015-09-15 23:50:41 +01:00
|
|
|
print_loop(nir_cf_node_as_loop(node), state, tabs);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("Invalid CFG node type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_function_impl(nir_function_impl *impl, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
fprintf(fp, "\nimpl %s ", impl->function->name);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
fprintf(fp, "{\n");
|
|
|
|
|
2021-09-24 17:12:24 +01:00
|
|
|
if (impl->preamble) {
|
|
|
|
fprintf(fp, "\tpreamble %s\n", impl->preamble->name);
|
|
|
|
}
|
|
|
|
|
2020-05-20 16:18:14 +01:00
|
|
|
nir_foreach_function_temp_variable(var, impl) {
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "\t");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach_list_typed(nir_register, reg, node, &impl->registers) {
|
|
|
|
fprintf(fp, "\t");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_register_decl(reg, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nir_index_blocks(impl);
|
|
|
|
|
|
|
|
foreach_list_typed(nir_cf_node, node, node, &impl->body) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_cf_node(node, state, 1);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "\tblock block_%u:\n}\n\n", impl->end_block->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-12-26 18:00:47 +00:00
|
|
|
print_function(nir_function *function, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
|
|
|
|
2018-03-22 23:41:18 +00:00
|
|
|
fprintf(fp, "decl_function %s (%d params)", function->name,
|
|
|
|
function->num_params);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
if (function->impl != NULL) {
|
|
|
|
print_function_impl(function->impl, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
init_print_state(print_state *state, nir_shader *shader, FILE *fp)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
state->fp = fp;
|
2015-09-15 23:55:48 +01:00
|
|
|
state->shader = shader;
|
2019-01-11 19:50:53 +00:00
|
|
|
state->ht = _mesa_pointer_hash_table_create(NULL);
|
2020-01-18 06:38:31 +00:00
|
|
|
state->syms = _mesa_set_create(NULL, _mesa_hash_string,
|
2015-01-15 17:31:18 +00:00
|
|
|
_mesa_key_string_equal);
|
2014-07-30 23:29:27 +01:00
|
|
|
state->index = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
destroy_print_state(print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
|
|
|
_mesa_hash_table_destroy(state->ht, NULL);
|
|
|
|
_mesa_set_destroy(state->syms, NULL);
|
|
|
|
}
|
|
|
|
|
2020-06-17 09:54:44 +01:00
|
|
|
static const char *
|
|
|
|
primitive_name(unsigned primitive)
|
|
|
|
{
|
2022-01-19 03:17:27 +00:00
|
|
|
#define PRIM(X) case SHADER_PRIM_ ## X : return #X
|
2020-06-17 09:54:44 +01:00
|
|
|
switch (primitive) {
|
|
|
|
PRIM(POINTS);
|
|
|
|
PRIM(LINES);
|
|
|
|
PRIM(LINE_LOOP);
|
|
|
|
PRIM(LINE_STRIP);
|
|
|
|
PRIM(TRIANGLES);
|
|
|
|
PRIM(TRIANGLE_STRIP);
|
|
|
|
PRIM(TRIANGLE_FAN);
|
|
|
|
PRIM(QUADS);
|
|
|
|
PRIM(QUAD_STRIP);
|
|
|
|
PRIM(POLYGON);
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
void
|
2016-05-14 20:37:32 +01:00
|
|
|
nir_print_shader_annotated(nir_shader *shader, FILE *fp,
|
|
|
|
struct hash_table *annotations)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
print_state state;
|
|
|
|
init_print_state(&state, shader, fp);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2016-05-14 20:37:32 +01:00
|
|
|
state.annotations = annotations;
|
|
|
|
|
2017-09-15 03:52:38 +01:00
|
|
|
fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->info.stage));
|
2015-09-15 23:55:48 +01:00
|
|
|
|
2021-11-18 14:28:17 +00:00
|
|
|
fprintf(fp, "source_sha1: {");
|
|
|
|
_mesa_sha1_print(fp, shader->info.source_sha1);
|
|
|
|
fprintf(fp, "}\n");
|
|
|
|
|
2017-05-08 17:20:21 +01:00
|
|
|
if (shader->info.name)
|
|
|
|
fprintf(fp, "name: %s\n", shader->info.name);
|
2015-10-26 17:29:45 +00:00
|
|
|
|
2017-05-08 17:20:21 +01:00
|
|
|
if (shader->info.label)
|
|
|
|
fprintf(fp, "label: %s\n", shader->info.label);
|
2015-10-26 17:29:45 +00:00
|
|
|
|
2021-05-05 20:24:44 +01:00
|
|
|
if (gl_shader_stage_uses_workgroup(shader->info.stage)) {
|
2021-05-27 07:53:32 +01:00
|
|
|
fprintf(fp, "workgroup-size: %u, %u, %u%s\n",
|
2021-05-05 20:24:44 +01:00
|
|
|
shader->info.workgroup_size[0],
|
|
|
|
shader->info.workgroup_size[1],
|
|
|
|
shader->info.workgroup_size[2],
|
|
|
|
shader->info.workgroup_size_variable ? " (variable)" : "");
|
2021-04-08 11:30:14 +01:00
|
|
|
fprintf(fp, "shared-size: %u\n", shader->info.shared_size);
|
2017-04-06 16:56:23 +01:00
|
|
|
}
|
2022-02-08 01:55:18 +00:00
|
|
|
if (shader->info.stage == MESA_SHADER_MESH ||
|
|
|
|
shader->info.stage == MESA_SHADER_TASK) {
|
|
|
|
fprintf(fp, "task_payload-size: %u\n", shader->info.task_payload_size);
|
|
|
|
}
|
2017-04-06 16:56:23 +01:00
|
|
|
|
2015-11-04 15:05:32 +00:00
|
|
|
fprintf(fp, "inputs: %u\n", shader->num_inputs);
|
|
|
|
fprintf(fp, "outputs: %u\n", shader->num_outputs);
|
|
|
|
fprintf(fp, "uniforms: %u\n", shader->num_uniforms);
|
2020-05-13 00:25:13 +01:00
|
|
|
if (shader->info.num_ubos)
|
|
|
|
fprintf(fp, "ubos: %u\n", shader->info.num_ubos);
|
2021-04-07 23:52:18 +01:00
|
|
|
fprintf(fp, "shared: %u\n", shader->info.shared_size);
|
2021-10-20 13:51:43 +01:00
|
|
|
fprintf(fp, "ray queries: %u\n", shader->info.ray_queries);
|
2016-12-02 19:36:42 +00:00
|
|
|
if (shader->scratch_size)
|
|
|
|
fprintf(fp, "scratch: %u\n", shader->scratch_size);
|
2020-07-07 20:48:09 +01:00
|
|
|
if (shader->constant_data_size)
|
|
|
|
fprintf(fp, "constants: %u\n", shader->constant_data_size);
|
2015-11-04 15:05:32 +00:00
|
|
|
|
2020-06-17 09:54:44 +01:00
|
|
|
if (shader->info.stage == MESA_SHADER_GEOMETRY) {
|
|
|
|
fprintf(fp, "invocations: %u\n", shader->info.gs.invocations);
|
|
|
|
fprintf(fp, "vertices in: %u\n", shader->info.gs.vertices_in);
|
|
|
|
fprintf(fp, "vertices out: %u\n", shader->info.gs.vertices_out);
|
|
|
|
fprintf(fp, "input primitive: %s\n", primitive_name(shader->info.gs.input_primitive));
|
|
|
|
fprintf(fp, "output primitive: %s\n", primitive_name(shader->info.gs.output_primitive));
|
|
|
|
fprintf(fp, "active_stream_mask: 0x%x\n", shader->info.gs.active_stream_mask);
|
|
|
|
fprintf(fp, "uses_end_primitive: %u\n", shader->info.gs.uses_end_primitive);
|
2021-10-21 10:21:50 +01:00
|
|
|
} else if (shader->info.stage == MESA_SHADER_MESH) {
|
|
|
|
fprintf(fp, "output primitive: %s\n", primitive_name(shader->info.mesh.primitive_type));
|
|
|
|
fprintf(fp, "max primitives out: %u\n", shader->info.mesh.max_primitives_out);
|
|
|
|
fprintf(fp, "max vertices out: %u\n", shader->info.mesh.max_vertices_out);
|
2020-06-17 09:54:44 +01:00
|
|
|
}
|
|
|
|
|
2020-07-20 22:30:37 +01:00
|
|
|
nir_foreach_variable_in_shader(var, shader)
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
foreach_list_typed(nir_function, func, node, &shader->functions) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_function(func, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
destroy_print_state(&state);
|
|
|
|
}
|
2014-11-05 23:10:37 +00:00
|
|
|
|
2016-05-14 20:37:32 +01:00
|
|
|
void
|
|
|
|
nir_print_shader(nir_shader *shader, FILE *fp)
|
|
|
|
{
|
|
|
|
nir_print_shader_annotated(shader, fp, NULL);
|
2018-11-26 19:29:41 +00:00
|
|
|
fflush(fp);
|
2016-05-14 20:37:32 +01:00
|
|
|
}
|
|
|
|
|
2021-02-05 11:25:03 +00:00
|
|
|
char *
|
2021-06-16 19:13:54 +01:00
|
|
|
nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotations, void *mem_ctx)
|
2021-02-05 11:25:03 +00:00
|
|
|
{
|
|
|
|
char *stream_data = NULL;
|
|
|
|
size_t stream_size = 0;
|
|
|
|
struct u_memstream mem;
|
|
|
|
if (u_memstream_open(&mem, &stream_data, &stream_size)) {
|
|
|
|
FILE *const stream = u_memstream_get(&mem);
|
2021-06-16 19:13:54 +01:00
|
|
|
nir_print_shader_annotated(nir, stream, annotations);
|
2021-02-05 11:25:03 +00:00
|
|
|
u_memstream_close(&mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *str = ralloc_size(mem_ctx, stream_size + 1);
|
|
|
|
memcpy(str, stream_data, stream_size);
|
|
|
|
str[stream_size] = '\0';
|
|
|
|
|
|
|
|
free(stream_data);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2021-06-16 19:13:54 +01:00
|
|
|
char *
|
|
|
|
nir_shader_as_str(nir_shader *nir, void *mem_ctx)
|
|
|
|
{
|
|
|
|
return nir_shader_as_str_annotated(nir, NULL, mem_ctx);
|
|
|
|
}
|
|
|
|
|
2014-11-05 23:10:37 +00:00
|
|
|
void
|
2015-02-09 21:42:16 +00:00
|
|
|
nir_print_instr(const nir_instr *instr, FILE *fp)
|
2014-11-05 23:10:37 +00:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
print_state state = {
|
|
|
|
.fp = fp,
|
|
|
|
};
|
2020-08-28 20:27:04 +01:00
|
|
|
if (instr->block) {
|
|
|
|
nir_function_impl *impl = nir_cf_node_get_function(&instr->block->cf_node);
|
|
|
|
state.shader = impl->function->shader;
|
|
|
|
}
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_instr(instr, &state, 0);
|
2021-10-05 23:32:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
nir_instr_as_str(const nir_instr *instr, void *mem_ctx)
|
|
|
|
{
|
|
|
|
char *stream_data = NULL;
|
|
|
|
size_t stream_size = 0;
|
|
|
|
struct u_memstream mem;
|
|
|
|
if (u_memstream_open(&mem, &stream_data, &stream_size)) {
|
|
|
|
FILE *const stream = u_memstream_get(&mem);
|
|
|
|
nir_print_instr(instr, stream);
|
|
|
|
u_memstream_close(&mem);
|
|
|
|
}
|
2015-09-15 23:50:41 +01:00
|
|
|
|
2021-10-05 23:32:33 +01:00
|
|
|
char *str = ralloc_size(mem_ctx, stream_size + 1);
|
|
|
|
memcpy(str, stream_data, stream_size);
|
|
|
|
str[stream_size] = '\0';
|
|
|
|
|
|
|
|
free(stream_data);
|
|
|
|
|
|
|
|
return str;
|
2014-11-05 23:10:37 +00:00
|
|
|
}
|
2018-12-19 20:13:46 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nir_print_deref(const nir_deref_instr *deref, FILE *fp)
|
|
|
|
{
|
|
|
|
print_state state = {
|
|
|
|
.fp = fp,
|
|
|
|
};
|
|
|
|
print_deref_link(deref, true, &state);
|
|
|
|
}
|
2021-06-16 19:13:54 +01:00
|
|
|
|
|
|
|
void nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag,
|
|
|
|
nir_shader *shader, struct hash_table *annotations)
|
|
|
|
{
|
|
|
|
char *str = nir_shader_as_str_annotated(shader, annotations, NULL);
|
|
|
|
_mesa_log_multiline(level, tag, str);
|
|
|
|
ralloc_free(str);
|
|
|
|
}
|