Commit Graph

11 Commits

Author SHA1 Message Date
Jordan Justen 3a133223b3
compiler/blob: Add blob_skip_bytes
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2018-07-09 23:02:33 -07:00
Jordan Justen 4c7a1ec62a blob: Don't set overrun if reading 0 bytes at end of data
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-10-31 23:36:54 -07:00
Jason Ekstrand 1cec500c69 blob: Use intptr_t instead of ssize_t
ssize_t is a GNU extension and is not available on Windows or MacOS.
Instead, we use intptr_t which should be effectively equivalent and is
part of the C standard.  This should fix the Windows and Mac OS builds.

Fixes: 3af1c82989
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103253
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Tested-by: Vinson Lee <vlee@freedesktop.org>
2017-10-13 15:02:34 -07:00
Jason Ekstrand 6a41a52e62 compiler/blob: Make some parameters void instead of uint8_t
There are certain advantages to using uint8_t internally such as
well-defined arithmetic on all platforms.  However, interfaces that
work in terms of raw data should use a void* type.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 4d56ff0a71 compiler/blob: Constify the reader
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 3af1c82989 compiler/blob: Add (reserve|overwrite)_(uint32|intptr) helpers
These helpers not only call blob_reserve_bytes but also make sure that
the blob is properly aligned as if blob_write_* were called.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Connor Abbott 6935440967 compiler/blob: make blob_reserve_bytes() more useful
Despite the name, it could only be used if you immediately wrote to the
pointer. Noboby was using it outside of one test, so clearly this
behavior wasn't that useful. Instead, make it return an offset into the
data buffer so that the result isn't invalidated if you later write to
the blob. In conjunction with blob_overwrite_bytes(), this will be
useful for leaving a placeholder and then filling it in later, which
we'll need to do for handling phi nodes when serializing NIR.

v2 (Jason Ekstrand):
 - Detect overflow in the offset + to_write computation

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 8ae03af4ed compiler/blob: Allow for fixed-size blobs with a NULL data pointer
These can be used to easily count up the number of bytes that will be
required by "writing" it into the NULL blob.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 26f6d4e5c7 compiler/blob: Add a concept of a fixed-allocation blob
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 49bb9f785a compiler/blob: Switch to init/finish instead of create/destroy
There's no reason why that tiny bit of memory needs to be on the heap.
We always put blob_reader on the stack, so why not do the same with the
writable blob.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Jason Ekstrand 0e3bd56c6e compiler: Move blob up a level
We're going to want to use the blob for Vulkan pipeline caching so it
makes sense to have it in libcompiler not libglsl.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-10-12 21:47:06 -07:00
Renamed from src/compiler/glsl/blob.c (Browse further)