On Tue, Jan 2, 2018 at 6:30 PM, Jason Ekstrand <[email protected]> wrote:
> ---
>  src/compiler/spirv/spirv_to_nir.c | 29 +++++++++++++++++++++++++++++
>  src/compiler/spirv/vtn_private.h  |  1 +
>  2 files changed, 30 insertions(+)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c 
> b/src/compiler/spirv/spirv_to_nir.c
> index dcff56f..751fb03 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -31,6 +31,9 @@
>  #include "nir/nir_constant_expressions.h"
>  #include "spirv_info.h"
>
> +#include <fcntl.h>
> +#include <unistd.h>
> +
>  void
>  vtn_log(struct vtn_builder *b, enum nir_spirv_debug_level level,
>          size_t spirv_offset, const char *message)
> @@ -94,6 +97,27 @@ vtn_log_err(struct vtn_builder *b,
>     ralloc_free(msg);
>  }
>
> +static void
> +vtn_dump_shader(struct vtn_builder *b, const char *path, const char *prefix)
> +{
> +   static int idx = 0;
> +
> +   char filename[1024];
> +   int len = snprintf(filename, sizeof(filename), "%s/%s-%d.spirv",
> +                      path, prefix, idx++);
> +   if (len < 0 || len >= sizeof(filename))
> +      return;
> +
> +   int fd = open(filename, O_CREAT | O_CLOEXEC | O_WRONLY, 0777);
> +   if (fd < 0)
> +      return;
> +
> +   write(fd, b->spirv, b->spirv_word_count * 4);

Feel free to ignore, but what about * sizeof(b->spirv[0]) ?

also, this emits a not-so-useful warning for me:
warning: ignoring return value of ‘write’, declared with attribute
warn_unused_result [-Wunused-result]
(and no, sticking (void) before write() doesn't help)

Gražvydas
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to