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"
|
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
|
|
|
|
2016-04-13 18:19:51 +01:00
|
|
|
#if defined(_WIN32) && !defined(snprintf)
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#endif
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
fprintf(stderr, "%s\n\n", note);
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-30 23:29:27 +01:00
|
|
|
if (reg->name != NULL)
|
|
|
|
fprintf(fp, "/* %s */ ", reg->name);
|
|
|
|
if (reg->is_global)
|
|
|
|
fprintf(fp, "gr%u", reg->index);
|
|
|
|
else
|
|
|
|
fprintf(fp, "r%u", reg->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4" };
|
|
|
|
|
|
|
|
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);
|
2014-07-30 23:29:27 +01:00
|
|
|
if (reg->is_packed)
|
|
|
|
fprintf(fp, "(packed) ");
|
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;
|
2014-07-30 23:29:27 +01:00
|
|
|
if (def->name != NULL)
|
|
|
|
fprintf(fp, "/* %s */ ", def->name);
|
2015-08-14 18:37:18 +01:00
|
|
|
fprintf(fp, "%s %u ssa_%u", sizes[def->num_components], def->bit_size,
|
|
|
|
def->index);
|
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
|
|
|
if (def->name != NULL)
|
|
|
|
fprintf(fp, "/* %s */ ", def->name);
|
|
|
|
fprintf(fp, "ssa_%u", def->index);
|
|
|
|
}
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
static void print_src(nir_src *src, print_state *state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_reg_src(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
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
for (unsigned i = 0; i < 4; 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-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_swizzle) {
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ".");
|
2015-03-24 01:20:21 +00:00
|
|
|
for (unsigned i = 0; i < 4; 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-04-02 00:16:52 +01:00
|
|
|
fprintf(fp, "%c", "xyzw"[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) {
|
|
|
|
fprintf(fp, ".");
|
|
|
|
for (unsigned i = 0; i < 4; i++)
|
|
|
|
if ((dest->write_mask >> i) & 1)
|
|
|
|
fprintf(fp, "%c", "xyzw"[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
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)
|
|
|
|
return var->name;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
unsigned total_elems = glsl_get_components(type);
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
switch (glsl_get_base_type(type)) {
|
|
|
|
case GLSL_TYPE_UINT:
|
|
|
|
case GLSL_TYPE_INT:
|
|
|
|
case GLSL_TYPE_BOOL:
|
|
|
|
for (i = 0; i < total_elems; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "0x%08x", c->value.u[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLSL_TYPE_FLOAT:
|
|
|
|
for (i = 0; i < total_elems; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "%f", c->value.f[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-08-14 18:37:18 +01:00
|
|
|
case GLSL_TYPE_DOUBLE:
|
|
|
|
for (i = 0; i < total_elems; i++) {
|
|
|
|
if (i > 0) fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "%f", c->value.d[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-12-22 21:50:23 +00:00
|
|
|
case GLSL_TYPE_STRUCT:
|
|
|
|
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 *
|
|
|
|
get_variable_mode_str(nir_variable_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case nir_var_shader_in:
|
|
|
|
return "shader_in";
|
|
|
|
case nir_var_shader_out:
|
|
|
|
return "shader_out";
|
|
|
|
case nir_var_uniform:
|
|
|
|
return "uniform";
|
|
|
|
case nir_var_shader_storage:
|
|
|
|
return "shader_storage";
|
|
|
|
case nir_var_system_value:
|
|
|
|
return "system";
|
|
|
|
case nir_var_shared:
|
|
|
|
return "shared";
|
|
|
|
case nir_var_param:
|
|
|
|
case nir_var_global:
|
|
|
|
case nir_var_local:
|
|
|
|
default:
|
|
|
|
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 ");
|
|
|
|
|
|
|
|
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 " : "";
|
2016-04-15 09:00:05 +01:00
|
|
|
fprintf(fp, "%s%s%s%s%s %s ",
|
|
|
|
cent, samp, patch, inv, get_variable_mode_str(var->data.mode),
|
2016-07-07 10:02:38 +01:00
|
|
|
glsl_interp_mode_name(var->data.interpolation));
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2016-05-05 12:52:38 +01:00
|
|
|
const char *const coher = (var->data.image.coherent) ? "coherent " : "";
|
|
|
|
const char *const volat = (var->data.image._volatile) ? "volatile " : "";
|
|
|
|
const char *const restr = (var->data.image.restrict_flag) ? "restrict " : "";
|
|
|
|
const char *const ronly = (var->data.image.read_only) ? "readonly " : "";
|
|
|
|
const char *const wonly = (var->data.image.write_only) ? "writeonly " : "";
|
|
|
|
fprintf(fp, "%s%s%s%s%s", coher, volat, restr, ronly, wonly);
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
glsl_print_type(var->type, fp);
|
|
|
|
|
2015-12-26 18:26:29 +00:00
|
|
|
fprintf(fp, " %s", get_var_name(var, state));
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
if (var->data.mode == nir_var_shader_in ||
|
|
|
|
var->data.mode == nir_var_shader_out ||
|
2015-05-18 14:47:18 +01:00
|
|
|
var->data.mode == nir_var_uniform ||
|
|
|
|
var->data.mode == nir_var_shader_storage) {
|
2015-09-15 23:55:48 +01:00
|
|
|
const char *loc = NULL;
|
|
|
|
char buf[4];
|
|
|
|
|
|
|
|
switch (state->shader->stage) {
|
|
|
|
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)
|
|
|
|
loc = gl_varying_slot_name(var->data.location);
|
|
|
|
break;
|
|
|
|
case MESA_SHADER_GEOMETRY:
|
|
|
|
if ((var->data.mode == nir_var_shader_in) ||
|
|
|
|
(var->data.mode == nir_var_shader_out))
|
|
|
|
loc = gl_varying_slot_name(var->data.location);
|
|
|
|
break;
|
|
|
|
case MESA_SHADER_FRAGMENT:
|
|
|
|
if (var->data.mode == nir_var_shader_in)
|
|
|
|
loc = gl_varying_slot_name(var->data.location);
|
|
|
|
else if (var->data.mode == nir_var_shader_out)
|
|
|
|
loc = gl_frag_result_name(var->data.location);
|
|
|
|
break;
|
|
|
|
case MESA_SHADER_TESS_CTRL:
|
|
|
|
case MESA_SHADER_TESS_EVAL:
|
|
|
|
case MESA_SHADER_COMPUTE:
|
|
|
|
default:
|
|
|
|
/* TODO */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!loc) {
|
|
|
|
snprintf(buf, sizeof(buf), "%u", var->data.location);
|
|
|
|
loc = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, " (%s, %u)", loc, var->data.driver_location);
|
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, " }");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var(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;
|
2015-12-26 18:26:29 +00:00
|
|
|
fprintf(fp, "%s", get_var_name(var, state));
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-13 04:41:19 +00:00
|
|
|
static void
|
|
|
|
print_arg(nir_variable *var, print_state *state)
|
|
|
|
{
|
|
|
|
FILE *fp = state->fp;
|
|
|
|
glsl_print_type(var->type, fp);
|
|
|
|
fprintf(fp, " %s", get_var_name(var, state));
|
|
|
|
}
|
|
|
|
|
2014-07-30 23:29:27 +01:00
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref_var(nir_deref_var *deref, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var(deref->var, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref_array(nir_deref_array *deref, 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, "[");
|
2014-11-19 20:53:08 +00:00
|
|
|
switch (deref->deref_array_type) {
|
|
|
|
case nir_deref_array_type_direct:
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, "%u", deref->base_offset);
|
2014-11-19 20:53:08 +00:00
|
|
|
break;
|
|
|
|
case nir_deref_array_type_indirect:
|
2014-07-30 23:29:27 +01:00
|
|
|
if (deref->base_offset != 0)
|
2014-11-19 20:53:08 +00:00
|
|
|
fprintf(fp, "%u + ", deref->base_offset);
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&deref->indirect, state);
|
2014-11-19 20:53:08 +00:00
|
|
|
break;
|
2014-11-19 20:59:57 +00:00
|
|
|
case nir_deref_array_type_wildcard:
|
|
|
|
fprintf(fp, "*");
|
|
|
|
break;
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
fprintf(fp, "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-11-26 05:36:25 +00:00
|
|
|
print_deref_struct(nir_deref_struct *deref, const struct glsl_type *parent_type,
|
2015-09-15 23:50:41 +01:00
|
|
|
print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2015-09-15 23:50:41 +01:00
|
|
|
FILE *fp = state->fp;
|
2014-11-26 05:36:25 +00:00
|
|
|
fprintf(fp, ".%s", glsl_get_struct_elem_name(parent_type, deref->index));
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref(nir_deref_var *deref, print_state *state)
|
2014-07-30 23:29:27 +01:00
|
|
|
{
|
2014-11-26 05:36:25 +00:00
|
|
|
nir_deref *tail = &deref->deref;
|
|
|
|
nir_deref *pretail = NULL;
|
|
|
|
while (tail != NULL) {
|
|
|
|
switch (tail->deref_type) {
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_deref_type_var:
|
2014-11-26 05:36:25 +00:00
|
|
|
assert(pretail == NULL);
|
|
|
|
assert(tail == &deref->deref);
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref_var(deref, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_deref_type_array:
|
2014-11-26 05:36:25 +00:00
|
|
|
assert(pretail != NULL);
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref_array(nir_deref_as_array(tail), state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nir_deref_type_struct:
|
2014-11-26 05:36:25 +00:00
|
|
|
assert(pretail != NULL);
|
|
|
|
print_deref_struct(nir_deref_as_struct(tail),
|
2015-09-15 23:50:41 +01:00
|
|
|
pretail->type, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("Invalid deref type");
|
|
|
|
}
|
|
|
|
|
2014-11-26 05:36:25 +00:00
|
|
|
pretail = tail;
|
|
|
|
tail = pretail->child;
|
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_variables; 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_deref(instr->variables[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++) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (i != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2016-01-15 23:24:11 +00:00
|
|
|
fprintf(fp, "%d", instr->const_index[i]);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, ")");
|
2015-09-17 23:18:45 +01:00
|
|
|
|
2016-01-13 23:43:14 +00:00
|
|
|
static const char *index_name[NIR_INTRINSIC_NUM_INDEX_FLAGS] = {
|
|
|
|
[NIR_INTRINSIC_BASE] = "base",
|
|
|
|
[NIR_INTRINSIC_WRMASK] = "wrmask",
|
|
|
|
[NIR_INTRINSIC_STREAM_ID] = "stream-id",
|
|
|
|
[NIR_INTRINSIC_UCP_ID] = "ucp-id",
|
2015-11-24 21:52:49 +00:00
|
|
|
[NIR_INTRINSIC_RANGE] = "range",
|
2016-03-25 17:17:28 +00:00
|
|
|
[NIR_INTRINSIC_DESC_SET] = "desc-set",
|
|
|
|
[NIR_INTRINSIC_BINDING] = "binding",
|
2016-05-23 07:46:46 +01:00
|
|
|
[NIR_INTRINSIC_COMPONENT] = "component",
|
nir: Add new intrinsics for fragment shader input interpolation.
Backends can normally handle shader inputs solely by looking at
load_input intrinsics, and ignore the nir_variables in nir->inputs.
One exception is fragment shader inputs. load_input doesn't capture
the necessary interpolation information - flat, smooth, noperspective
mode, and centroid, sample, or pixel for the location. This means
that backends have to interpolate based on the nir_variables, then
associate those with the load_input intrinsics (say, by storing a
map of which variables are at which locations).
With GL_ARB_enhanced_layouts, we're going to have multiple varyings
packed into a single vec4 location. The intrinsics make this easy:
simply load N components from location <loc, component>. However,
working with variables and correlating the two is very awkward; we'd
much rather have intrinsics capture all the necessary information.
Fragment shader input interpolation typically works by producing a
set of barycentric coordinates, then using those to do a linear
interpolation between the values at the triangle's corners.
We represent this by introducing five new load_barycentric_* intrinsics:
- load_barycentric_pixel (ordinary variable)
- load_barycentric_centroid (centroid qualified variable)
- load_barycentric_sample (sample qualified variable)
- load_barycentric_at_sample (ARB_gpu_shader5's interpolateAtSample())
- load_barycentric_at_offset (ARB_gpu_shader5's interpolateAtOffset())
Each of these take the interpolation mode (smooth or noperspective only)
as a const_index, and produce a vec2. The last two also take a sample
or offset source.
We then introduce a new load_interpolated_input intrinsic, which
is like a normal load_input intrinsic, but with an additional
barycentric coordinate source.
The intention is that flat inputs will still use regular load_input
intrinsics. This makes them distinguishable from normal inputs that
need fancy interpolation, while also providing all the necessary data.
This nicely unifies regular inputs and interpolateAt functions.
Qualifiers and variables become irrelevant; there are just
load_barycentric intrinsics that determine the interpolation.
v2: Document the interp_mode const_index value, define a new
BARYCENTRIC() helper rather than using SYSTEM_VALUE() for
some of them (requested by Jason Ekstrand).
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2016-07-12 09:46:43 +01:00
|
|
|
[NIR_INTRINSIC_INTERP_MODE] = "interp_mode",
|
2016-01-13 23:43:14 +00:00
|
|
|
};
|
|
|
|
for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
|
|
|
|
if (!info->index_map[idx])
|
|
|
|
continue;
|
|
|
|
fprintf(fp, " /*");
|
|
|
|
if (idx == 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++)
|
|
|
|
if ((wrmask >> i) & 1)
|
|
|
|
fprintf(fp, "%c", "xyzw"[i]);
|
|
|
|
} else {
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
fprintf(fp, " */");
|
|
|
|
}
|
|
|
|
|
2015-09-17 23:18:45 +01:00
|
|
|
if (!state->shader)
|
|
|
|
return;
|
|
|
|
|
|
|
|
struct exec_list *var_list = NULL;
|
|
|
|
|
|
|
|
switch (instr->intrinsic) {
|
|
|
|
case nir_intrinsic_load_uniform:
|
|
|
|
var_list = &state->shader->uniforms;
|
|
|
|
break;
|
|
|
|
case nir_intrinsic_load_input:
|
2015-10-01 08:46:19 +01:00
|
|
|
case nir_intrinsic_load_per_vertex_input:
|
2015-09-17 23:18:45 +01:00
|
|
|
var_list = &state->shader->inputs;
|
|
|
|
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:
|
2015-09-17 23:18:45 +01:00
|
|
|
var_list = &state->shader->outputs;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, var_list) {
|
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 ||
|
|
|
|
var->data.location_frac == nir_intrinsic_component(instr)) &&
|
2015-09-17 23:18:45 +01:00
|
|
|
var->name) {
|
|
|
|
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
|
|
|
|
|
|
|
fprintf(fp, " = ");
|
|
|
|
|
|
|
|
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;
|
2016-05-03 01:28:38 +01:00
|
|
|
case nir_texop_txf_ms_mcs:
|
|
|
|
fprintf(fp, "txf_ms_mcs ");
|
|
|
|
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;
|
2014-07-30 23:29:27 +01:00
|
|
|
default:
|
|
|
|
unreachable("Invalid texture operation");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < instr->num_srcs; i++) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_src(&instr->src[i].src, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
|
|
|
fprintf(fp, " ");
|
|
|
|
|
2015-01-10 04:01:13 +00:00
|
|
|
switch(instr->src[i].src_type) {
|
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;
|
|
|
|
case nir_tex_src_comparitor:
|
|
|
|
fprintf(fp, "(comparitor)");
|
|
|
|
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;
|
|
|
|
case nir_tex_src_ms_index:
|
|
|
|
fprintf(fp, "(ms_index)");
|
|
|
|
break;
|
2016-05-03 01:28:38 +01:00
|
|
|
case nir_tex_src_ms_mcs:
|
|
|
|
fprintf(fp, "(ms_mcs)");
|
|
|
|
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;
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instr->op == nir_texop_tg4) {
|
|
|
|
fprintf(fp, "%u (gather_component), ", instr->component);
|
|
|
|
}
|
|
|
|
|
2016-02-06 17:05:10 +00:00
|
|
|
if (instr->texture) {
|
|
|
|
print_deref(instr->texture, state);
|
2015-11-03 01:58:29 +00:00
|
|
|
fprintf(fp, " (texture)");
|
|
|
|
if (instr->sampler) {
|
|
|
|
print_deref(instr->sampler, state);
|
|
|
|
fprintf(fp, " (sampler)");
|
|
|
|
}
|
2014-07-30 23:29:27 +01:00
|
|
|
} else {
|
2015-11-03 01:58:29 +00:00
|
|
|
assert(instr->sampler == NULL);
|
|
|
|
fprintf(fp, "%u (texture) %u (sampler)",
|
|
|
|
instr->texture_index, instr->sampler_index);
|
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, ", ");
|
|
|
|
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref(instr->params[i], state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (instr->return_deref != NULL) {
|
|
|
|
if (instr->num_params != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "returning ");
|
2015-09-15 23:50:41 +01:00
|
|
|
print_deref(instr->return_deref, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-15 23:50:41 +01:00
|
|
|
print_load_const_instr(nir_load_const_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-12-16 01:32:56 +00:00
|
|
|
|
|
|
|
fprintf(fp, " = load_const (");
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2014-12-16 01:32:56 +00:00
|
|
|
for (unsigned i = 0; i < instr->def.num_components; i++) {
|
2014-12-18 22:01:37 +00:00
|
|
|
if (i != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 the float in a comment for readability.
|
|
|
|
*/
|
|
|
|
|
2015-08-14 18:37:18 +01:00
|
|
|
if (instr->def.bit_size == 64)
|
|
|
|
fprintf(fp, "0x%16" PRIx64 " /* %f */", instr->value.u64[i],
|
|
|
|
instr->value.f64[i]);
|
|
|
|
else
|
|
|
|
fprintf(fp, "0x%08x /* %f */", instr->value.u32[i], instr->value.f32[i]);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
2015-04-10 05:09:48 +01:00
|
|
|
|
|
|
|
fprintf(fp, ")");
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
compare_block_index(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const nir_block *block1 = *((const nir_block **) p1);
|
|
|
|
const nir_block *block2 = *((const nir_block **) p2);
|
|
|
|
|
|
|
|
return (int) block1->index - (int) block2->index;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* sort the predecessors by index so we consistently print the same thing */
|
|
|
|
|
|
|
|
nir_block **preds =
|
|
|
|
malloc(block->predecessors->entries * sizeof(nir_block *));
|
|
|
|
|
|
|
|
struct set_entry *entry;
|
|
|
|
unsigned i = 0;
|
|
|
|
set_foreach(block->predecessors, entry) {
|
|
|
|
preds[i++] = (nir_block *) entry->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(preds, block->predecessors->entries, sizeof(nir_block *),
|
|
|
|
compare_block_index);
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
free(preds);
|
|
|
|
|
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);
|
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
|
|
|
|
|
|
|
for (unsigned i = 0; i < impl->num_params; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2016-02-13 04:41:19 +00:00
|
|
|
print_arg(impl->params[i], state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (impl->return_var != NULL) {
|
|
|
|
if (impl->num_params != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "returning ");
|
2016-02-13 04:41:19 +00:00
|
|
|
print_arg(impl->return_var, state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "{\n");
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &impl->locals) {
|
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;
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
fprintf(fp, "decl_function %s ", function->name);
|
2014-07-30 23:29:27 +01:00
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
for (unsigned i = 0; i < function->num_params; i++) {
|
2014-07-30 23:29:27 +01:00
|
|
|
if (i != 0)
|
|
|
|
fprintf(fp, ", ");
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
switch (function->params[i].param_type) {
|
2014-07-30 23:29:27 +01:00
|
|
|
case nir_parameter_in:
|
|
|
|
fprintf(fp, "in ");
|
|
|
|
break;
|
|
|
|
case nir_parameter_out:
|
|
|
|
fprintf(fp, "out ");
|
|
|
|
break;
|
|
|
|
case nir_parameter_inout:
|
|
|
|
fprintf(fp, "inout ");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unreachable("Invalid parameter type");
|
|
|
|
}
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
glsl_print_type(function->params[i].type, fp);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-12-26 18:00:47 +00:00
|
|
|
if (function->return_type != NULL) {
|
|
|
|
if (function->num_params != 0)
|
2014-07-30 23:29:27 +01:00
|
|
|
fprintf(fp, ", ");
|
|
|
|
fprintf(fp, "returning ");
|
2015-12-26 18:00:47 +00:00
|
|
|
glsl_print_type(function->return_type, fp);
|
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;
|
2014-07-30 23:29:27 +01:00
|
|
|
state->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
|
|
|
|
_mesa_key_pointer_equal);
|
2015-01-15 17:31:18 +00:00
|
|
|
state->syms = _mesa_set_create(NULL, _mesa_key_hash_string,
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-09-15 23:55:48 +01:00
|
|
|
fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->stage));
|
|
|
|
|
2015-10-26 17:29:45 +00:00
|
|
|
if (shader->info.name)
|
|
|
|
fprintf(fp, "name: %s\n", shader->info.name);
|
|
|
|
|
|
|
|
if (shader->info.label)
|
|
|
|
fprintf(fp, "label: %s\n", shader->info.label);
|
|
|
|
|
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);
|
2016-01-18 17:44:31 +00:00
|
|
|
fprintf(fp, "shared: %u\n", shader->num_shared);
|
2015-11-04 15:05:32 +00:00
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &shader->uniforms) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &shader->inputs) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &shader->outputs) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2016-01-09 01:16:29 +00:00
|
|
|
nir_foreach_variable(var, &shader->shared) {
|
|
|
|
print_var_decl(var, &state);
|
|
|
|
}
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &shader->globals) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_var_decl(var, &state);
|
2014-07-30 23:29:27 +01:00
|
|
|
}
|
|
|
|
|
2015-10-03 02:15:06 +01:00
|
|
|
nir_foreach_variable(var, &shader->system_values) {
|
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, &shader->registers) {
|
2015-09-15 23:50:41 +01:00
|
|
|
print_register_decl(reg, &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);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
print_instr(instr, &state, 0);
|
|
|
|
|
2014-11-05 23:10:37 +00:00
|
|
|
}
|