+
+ pass &= !ret;
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static enum piglit_result
+delete_texture_sampler_while_handle_is_allocated(void *data)
+{
+ GLuint texture, sampler;
+ GLuint64 handle;
+
+ /* The ARB_bindless_texture spec says:
+ *
+ * "(5) Is there a way to release a texture or image handle
after it
+ * is created?"
+ *
+ * "RESOLVED: No API is provided to release or delete handles
once
+ * they are created. Texture and image handles are automatically
+ * reclaimed when the underlying texture or sampler objects are
finally
+ * deleted. This deletion will happen only when no handle using
the
+ * texture or sampler object is resident on any context."
+ */
+
+ /* Test #1: Create a texture handle and remove it. */
+ texture = piglit_rgbw_texture(GL_RGBA32F, 16, 16, GL_FALSE,
GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ handle = glGetTextureHandleARB(texture);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glDeleteTextures(1, &texture);
+
+ /* Texture handle should have been removed. */
+ glMakeTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ return PIGLIT_FAIL;
+
+ /* Test #2: Create a texture/sampler handle and remove the
sampler. */
+ texture = piglit_rgbw_texture(GL_RGBA32F, 16, 16, GL_FALSE,
GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ /* Texture and sampler have to be consistent. */
+ glGenSamplers(1, &sampler);
+ glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ handle = glGetTextureSamplerHandleARB(texture, sampler);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glDeleteSamplers(1, &sampler);
+
+ /* Texture handle should have been removed. */
+ glMakeTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ return PIGLIT_FAIL;
+
+ return PIGLIT_PASS;
+}
+
+static enum piglit_result
+delete_texture_sampler_while_handle_is_resident(void *data)
+{
+ GLuint texture, sampler;
+ GLuint64 handle;
+ GLboolean ret;
+
+ /* The ARB_bindless_texture_spec says:
+ *
+ * "(7) What happens if you try to delete a texture or sampler
object
+ * with a handle that is resident in another context?"
+ *
+ * "RESOLVED: Deleting the texture will remove the texture from
the
+ * name space and make all handles using the texture
non-resident in
+ * the current context. However, texture or image handles for a
+ * deleted texture are not deleted until the underlying
texture or
+ * sampler object itself is deleted. That deletion won't happen
+ * until the object is not bound anywhere and there are no
handles
+ * using the object that are resident in any context."
+ */
+
+ /* Test #1: Create a texture handle, make it resident and remove
the
+ * texture. */
+ texture = piglit_rgbw_texture(GL_RGBA, 16, 16, GL_FALSE, GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ handle = glGetTextureHandleARB(texture);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glMakeTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glDeleteTextures(1, &texture);
+
+ /* Texture handle should have been removed. */
+ glIsTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ return PIGLIT_FAIL;
+
+ /* Test #2: Create a texture/sampler handle, make it resident and
+ * remove the sampler. */
+ texture = piglit_rgbw_texture(GL_RGBA32F, 16, 16, GL_FALSE,
GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ /* Texture and sampler have to be consistent. */
+ glGenSamplers(1, &sampler);
+ glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ handle = glGetTextureSamplerHandleARB(texture, sampler);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glMakeTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ glDeleteSamplers(1, &sampler);
+
+ /* Texture handle should still be resident. */
+ ret = glIsTextureHandleResidentARB(handle);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return PIGLIT_FAIL;
+
+ if (!ret)
+ return PIGLIT_FAIL;