OSDN Git Service

glsl: Add blob_overwrite_bytes and blob_overwrite_uint32
authorTapani Pälli <tapani.palli@intel.com>
Thu, 13 Nov 2014 07:16:51 +0000 (23:16 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 16 Jan 2015 21:47:40 +0000 (13:47 -0800)
commitffcad3a54839bd6704b4cac5dfe9f52a4f299dae
treeadaa807fc49b62bb3a8cf2f0889733351accc031
parent1c9877327ead37b7dd5a0ca3a8c7912e924328e5
glsl: Add blob_overwrite_bytes and blob_overwrite_uint32

These functions are useful when serializing an unknown number of items
to a blob. The caller can first save the current offset, write a
placeholder uint32, write out (and count) the items, then use
blob_overwrite_uint32 with the saved offset to replace the placeholder
value.

Then, when deserializing, the reader will first read the count and
know how many subsequent items to expect.

(I wrote this code after reading a very similar patch written by
Tapani when he wrote serialization code for IR. Since I re-used the
idea of his code so directly, I've credited him as the author of this
code. --Carl)

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/blob.c
src/glsl/blob.h