Mesa (master): glsl: allow NULL to be passed to encode_type_to_blob()

Timothy Arceri tarceri at kemper.freedesktop.org
Thu Aug 24 01:22:16 UTC 2017


Module: Mesa
Branch: master
Commit: 37eb67714e0092a5d80ec40d10ca1fe72fa64657
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=37eb67714e0092a5d80ec40d10ca1fe72fa64657

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Aug 11 13:53:18 2017 +1000

glsl: allow NULL to be passed to encode_type_to_blob()

This will be used by the following commit.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

---

 src/compiler/glsl/shader_cache.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index cc4d24482d..1fd49b82e9 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -79,6 +79,11 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
 {
    uint32_t encoding;
 
+   if (!type) {
+      blob_write_uint32(blob, 0);
+      return;
+   }
+
    switch (type->base_type) {
    case GLSL_TYPE_UINT:
    case GLSL_TYPE_INT:
@@ -149,6 +154,11 @@ static const glsl_type *
 decode_type_from_blob(struct blob_reader *blob)
 {
    uint32_t u = blob_read_uint32(blob);
+
+   if (u == 0) {
+      return NULL;
+   }
+
    glsl_base_type base_type = (glsl_base_type) (u >> 24);
 
    switch (base_type) {




More information about the mesa-commit mailing list