mesa/st: Don't set alpha if ALPHA_TEST is lowered
[mesa.git] / src / mesa / main / texturebindless.c
index 26b0f58bcd2e6020048f2c93e6dc8f49b9412ce6..a4d700e6362e4909bbfcc45df8021973333e77b1 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);
 }
 
@@ -532,6 +538,21 @@ is_sampler_border_color_valid(struct gl_sampler_object *samp)
    return GL_FALSE;
 }
 
+GLuint64 GLAPIENTRY
+_mesa_GetTextureHandleARB_no_error(GLuint texture)
+{
+   struct gl_texture_object *texObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_texture(ctx, texture);
+   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler,
+                                  ctx->Const.ForceIntegerTexNearest))
+      _mesa_test_texobj_completeness(ctx, texObj);
+
+   return get_texture_handle(ctx, texObj, &texObj->Sampler);
+}
+
 GLuint64 GLAPIENTRY
 _mesa_GetTextureHandleARB(GLuint texture)
 {
@@ -565,9 +586,11 @@ _mesa_GetTextureHandleARB(GLuint texture)
     *  GetTextureSamplerHandleARB if the texture object specified by <texture>
     *  is not complete."
     */
-   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler)) {
+   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler,
+                                  ctx->Const.ForceIntegerTexNearest)) {
       _mesa_test_texobj_completeness(ctx, texObj);
-      if (!_mesa_is_texture_complete(texObj, &texObj->Sampler)) {
+      if (!_mesa_is_texture_complete(texObj, &texObj->Sampler,
+                                     ctx->Const.ForceIntegerTexNearest)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetTextureHandleARB(incomplete texture)");
          return 0;
@@ -583,6 +606,24 @@ _mesa_GetTextureHandleARB(GLuint texture)
    return get_texture_handle(ctx, texObj, &texObj->Sampler);
 }
 
+GLuint64 GLAPIENTRY
+_mesa_GetTextureSamplerHandleARB_no_error(GLuint texture, GLuint sampler)
+{
+   struct gl_texture_object *texObj;
+   struct gl_sampler_object *sampObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_texture(ctx, texture);
+   sampObj = _mesa_lookup_samplerobj(ctx, sampler);
+
+   if (!_mesa_is_texture_complete(texObj, sampObj,
+                                  ctx->Const.ForceIntegerTexNearest))
+      _mesa_test_texobj_completeness(ctx, texObj);
+
+   return get_texture_handle(ctx, texObj, sampObj);
+}
+
 GLuint64 GLAPIENTRY
 _mesa_GetTextureSamplerHandleARB(GLuint texture, GLuint sampler)
 {
@@ -630,9 +671,11 @@ _mesa_GetTextureSamplerHandleARB(GLuint texture, GLuint sampler)
     *  GetTextureSamplerHandleARB if the texture object specified by <texture>
     *  is not complete."
     */
-   if (!_mesa_is_texture_complete(texObj, sampObj)) {
+   if (!_mesa_is_texture_complete(texObj, sampObj,
+                                  ctx->Const.ForceIntegerTexNearest)) {
       _mesa_test_texobj_completeness(ctx, texObj);
-      if (!_mesa_is_texture_complete(texObj, sampObj)) {
+      if (!_mesa_is_texture_complete(texObj, sampObj,
+                                     ctx->Const.ForceIntegerTexNearest)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetTextureSamplerHandleARB(incomplete texture)");
          return 0;
@@ -648,6 +691,17 @@ _mesa_GetTextureSamplerHandleARB(GLuint texture, GLuint sampler)
    return get_texture_handle(ctx, texObj, sampObj);
 }
 
+void GLAPIENTRY
+_mesa_MakeTextureHandleResidentARB_no_error(GLuint64 handle)
+{
+   struct gl_texture_handle_object *texHandleObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texHandleObj = lookup_texture_handle(ctx, handle);
+   make_texture_handle_resident(ctx, texHandleObj, true);
+}
+
 void GLAPIENTRY
 _mesa_MakeTextureHandleResidentARB(GLuint64 handle)
 {
@@ -683,6 +737,17 @@ _mesa_MakeTextureHandleResidentARB(GLuint64 handle)
    make_texture_handle_resident(ctx, texHandleObj, true);
 }
 
+void GLAPIENTRY
+_mesa_MakeTextureHandleNonResidentARB_no_error(GLuint64 handle)
+{
+   struct gl_texture_handle_object *texHandleObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   texHandleObj = lookup_texture_handle(ctx, handle);
+   make_texture_handle_resident(ctx, texHandleObj, false);
+}
+
 void GLAPIENTRY
 _mesa_MakeTextureHandleNonResidentARB(GLuint64 handle)
 {
@@ -718,6 +783,22 @@ _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,
+                                  ctx->Const.ForceIntegerTexNearest))
+      _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)
@@ -771,9 +852,11 @@ _mesa_GetImageHandleARB(GLuint texture, GLint level, GLboolean layered,
     *  <texture> is not a three-dimensional, one-dimensional array, two
     *  dimensional array, cube map, or cube map array texture."
     */
-   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler)) {
+   if (!_mesa_is_texture_complete(texObj, &texObj->Sampler,
+                                  ctx->Const.ForceIntegerTexNearest)) {
       _mesa_test_texobj_completeness(ctx, texObj);
-      if (!_mesa_is_texture_complete(texObj, &texObj->Sampler)) {
+      if (!_mesa_is_texture_complete(texObj, &texObj->Sampler,
+                                     ctx->Const.ForceIntegerTexNearest)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetImageHandleARB(incomplete texture)");
          return 0;
@@ -789,6 +872,17 @@ _mesa_GetImageHandleARB(GLuint texture, GLint level, GLboolean layered,
    return get_image_handle(ctx, texObj, level, layered, layer, format);
 }
 
+void GLAPIENTRY
+_mesa_MakeImageHandleResidentARB_no_error(GLuint64 handle, GLenum access)
+{
+   struct gl_image_handle_object *imgHandleObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   imgHandleObj = lookup_image_handle(ctx, handle);
+   make_image_handle_resident(ctx, imgHandleObj, access, true);
+}
+
 void GLAPIENTRY
 _mesa_MakeImageHandleResidentARB(GLuint64 handle, GLenum access)
 {
@@ -833,6 +927,17 @@ _mesa_MakeImageHandleResidentARB(GLuint64 handle, GLenum access)
    make_image_handle_resident(ctx, imgHandleObj, access, true);
 }
 
+void GLAPIENTRY
+_mesa_MakeImageHandleNonResidentARB_no_error(GLuint64 handle)
+{
+   struct gl_image_handle_object *imgHandleObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   imgHandleObj = lookup_image_handle(ctx, handle);
+   make_image_handle_resident(ctx, imgHandleObj, GL_READ_ONLY, false);
+}
+
 void GLAPIENTRY
 _mesa_MakeImageHandleNonResidentARB(GLuint64 handle)
 {
@@ -869,6 +974,13 @@ _mesa_MakeImageHandleNonResidentARB(GLuint64 handle)
    make_image_handle_resident(ctx, imgHandleObj, GL_READ_ONLY, false);
 }
 
+GLboolean GLAPIENTRY
+_mesa_IsTextureHandleResidentARB_no_error(GLuint64 handle)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   return is_texture_handle_resident(ctx, handle);
+}
+
 GLboolean GLAPIENTRY
 _mesa_IsTextureHandleResidentARB(GLuint64 handle)
 {
@@ -895,6 +1007,13 @@ _mesa_IsTextureHandleResidentARB(GLuint64 handle)
    return is_texture_handle_resident(ctx, handle);
 }
 
+GLboolean GLAPIENTRY
+_mesa_IsImageHandleResidentARB_no_error(GLuint64 handle)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   return is_image_handle_resident(ctx, handle);
+}
+
 GLboolean GLAPIENTRY
 _mesa_IsImageHandleResidentARB(GLuint64 handle)
 {