aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/blob.c
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add blob_overwrite_bytes and blob_overwrite_uint32Tapani Pälli2015-01-161-0/+23
| | | | | | | | | | | | | | | | | | 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 <[email protected]>
* glsl: Add blob.c---a simple interface for serializing dataCarl Worth2015-01-161-0/+300
This new interface allows for writing a series of objects to a chunk of memory (a "blob").. The allocated memory is maintained within the blob itself, (and re-allocated by doubling when necessary). There are also functions for reading objects from a blob as well. If code attempts to read beyond the available memory, the read functions return 0 values (or its moral equivalent) without reading past the allocated memory. Once the caller is done with the reads, it can check blob->overrun to ensure whether any invalid values were previously returned due to attempts to read too far. Reviewed-by: Jason Ekstrand <[email protected]>