mesa: add Const.BufferCreateMapUnsynchronizedThreadSafe & MESA_MAP_THREAD_SAFE
[mesa.git] / src / mesa / main / texturebindless.c
index a56d6e3b370626c6b805c2028cfc6b6c948ff626..c1cef4b1e4660ba87bca697b25f9385cb47d47c8 100644 (file)
@@ -24,7 +24,7 @@
 #include "glheader.h"
 #include "context.h"
 #include "enums.h"
-#include "imports.h"
+
 #include "hash.h"
 #include "mtypes.h"
 #include "shaderimage.h"
@@ -33,6 +33,7 @@
 #include "texturebindless.h"
 
 #include "util/hash_table.h"
+#include "util/u_memory.h"
 
 /**
  * Return the gl_texture_handle_object for a given 64-bit handle.
@@ -327,6 +328,7 @@ get_image_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
    } else {
       imgObj.Layered = GL_FALSE;
       imgObj.Layer = 0;
+      imgObj._Layer = 0;
    }
 
    /* Request a new image handle from the driver. */
@@ -394,8 +396,12 @@ _mesa_init_shared_handles(struct gl_shared_state *shared)
 void
 _mesa_free_shared_handles(struct gl_shared_state *shared)
 {
-   _mesa_hash_table_u64_destroy(shared->TextureHandles, NULL);
-   _mesa_hash_table_u64_destroy(shared->ImageHandles, NULL);
+   if (shared->TextureHandles)
+      _mesa_hash_table_u64_destroy(shared->TextureHandles, NULL);
+
+   if (shared->ImageHandles)
+      _mesa_hash_table_u64_destroy(shared->ImageHandles, NULL);
+
    mtx_destroy(&shared->HandlesMutex);
 }
 
@@ -771,6 +777,21 @@ _mesa_MakeTextureHandleNonResidentARB(GLuint64 handle)
    make_texture_handle_resident(ctx, texHandleObj, false);
 }
 
+GLuint64 GLAPIENTRY
+_mesa_GetImageHandleARB_no_error(GLuint texture, GLint level, GLboolean layered,
+                                 GLint layer, GLenum format)
+{
+   struct gl_texture_object *texObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_texture(ctx, texture);
+   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler))
+      _mesa_test_texobj_completeness(ctx, texObj);
+
+   return get_image_handle(ctx, texObj, level, layered, layer, format);
+}
+
 GLuint64 GLAPIENTRY
 _mesa_GetImageHandleARB(GLuint texture, GLint level, GLboolean layered,
                         GLint layer, GLenum format)