Mesa (master): nir/print: fix printing of 8/16 bit constant variables
Karol Herbst
karolherbst at kemper.freedesktop.org
Tue May 29 11:46:18 UTC 2018
Module: Mesa
Branch: master
Commit: 56792a0876ba088fa3d2ea63b2ab87f41ad52598
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=56792a0876ba088fa3d2ea63b2ab87f41ad52598
Author: Karol Herbst <kherbst at redhat.com>
Date: Thu May 10 10:20:47 2018 +0200
nir/print: fix printing of 8/16 bit constant variables
v2 (Jose Maria Casanova Crespo <jmcasanova at igalia.com>): add float16 support
Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
---
src/compiler/nir/nir_print.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 97b2d6164c..fad274e62f 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -299,6 +299,28 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state
unsigned i, j;
switch (glsl_get_base_type(type)) {
+ 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, ", ");
+ fprintf(fp, "0x%02x", c->values[0].u8[i]);
+ }
+ 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, ", ");
+ fprintf(fp, "0x%04x", c->values[0].u16[i]);
+ }
+ break;
+
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
@@ -311,6 +333,15 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state
}
break;
+ case GLSL_TYPE_FLOAT16:
+ for (i = 0; i < cols; i++) {
+ for (j = 0; j < rows; j++) {
+ if (i + j > 0) fprintf(fp, ", ");
+ fprintf(fp, "%f", _mesa_half_to_float(c->values[i].u16[j]));
+ }
+ }
+ break;
+
case GLSL_TYPE_FLOAT:
for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
More information about the mesa-commit
mailing list