[Piglit] [RFC PATCH 2/5] add API-related tests for ARB_bindless_texture
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed Mar 29 11:10:47 UTC 2017
All the requested changes have been fixed locally. Thanks Tim!
On 03/29/2017 02:14 AM, Timothy Arceri wrote:
>
> <snip/>
>
>>>> +
>>>> + return PIGLIT_PASS;
>>>> +}
>>>> +
>>>> +static enum piglit_result
>>>> +check_MakeImageHandleNonResident_invalid_operations(void *data)
>>>> +{
>>>> + GLuint64 handle;
>>>> + GLuint tex;
>>>> +
>>>> + if
>>>> (!piglit_is_extension_supported("GL_ARB_shader_image_load_store"))
>>>> + return PIGLIT_SKIP;
>>>> +
>>>> + /* The ARB_bindless_texture spec says:
>>>> + *
>>>> + * "The error INVALID_OPERATION is generated by
>>>> + * MakeImageHandleNonResidentARB if <handle> is not a valid image
>>>> + * handle, or if <handle> is not resident in the current GL
>>>> context."
>>>> + */
>>>> +
>>>> + /* Invalid handle */
>>>> + glMakeImageHandleNonResidentARB(42);
>>>> + if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>>>> + return PIGLIT_FAIL;
>>>> +
>>>> + tex = piglit_rgbw_texture(GL_RGBA32F, 16, 16, GL_FALSE, GL_FALSE,
>>>> + GL_UNSIGNED_NORMALIZED);
>>>> + glBindTexture(GL_TEXTURE_2D, 0);
>>>> +
>>>> + handle = glGetImageHandleARB(tex, 0, GL_FALSE, 0, GL_RGBA32F);
>>>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>>>> + return PIGLIT_FAIL;
>>>> +
>>>> + /* Handle not resident. */
>>>> + glMakeImageHandleNonResidentARB(handle);
>>>> + if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>>>> + return PIGLIT_FAIL;
>>>
>>>
>>> Again like the texture test maybe add the handle then remove it twice?
>>
>> What do you mean?
>
>
> I mean you test that an error is generated when the handle was never
> made resident, you should probably test that it still errors when we
> make it resident then non-resident again:
>
> glMakeImageHandleResidentARB(handle, GL_READ_WRITE);
> glMakeImageHandleNonResidentARB(handle);
> if (!piglit_check_gl_error(GL_NO_ERROR))
> return PIGLIT_FAIL;
>
> glMakeImageHandleNonResidentARB(handle);
> if (!piglit_check_gl_error(GL_INVALID_OPERATION))
> return PIGLIT_FAIL;
>
>
>
>>>
>>>> +
>>>> + 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;
>>>
>>> Should you now do:
>>>
>>>
>>> glDeleteTextures(1, &texture);
>>>
>>> /* Texture handle should have been removed. */
>>> glIsTextureHandleResidentARB(handle);
>>> if (!piglit_check_gl_error(GL_INVALID_OPERATION))
>>> return PIGLIT_FAIL;
>>>
>>> ?
>>
>> Not necessarily, it's similar to test #1.
>
>
> I disagree. If you don't test that the handle is removed when deleting
> the texture you don't even know that the reference was removed by
> glDeleteSamplers(1, &sampler);
>
> Also this is calling glGetTextureSamplerHandleARB(texture, sampler) not
> glGetTextureHandleARB() or glGetTextureSamplerHandleARB() which have
> been tested elsewhere including test #1.
>
> The only way to make sure glGetTextureSamplerHandleARB() doesn't do
> something funny that results in the handle hanging around is to delete
> both the sampler and texture.
>
>
>>
>>>
>>>> +
>>>> + return PIGLIT_PASS;
>>>> +}
>>>> +
>
>
> <snip/>
>
>>>> diff --git a/tests/spec/arb_bindless_texture/limit.c
>>>> b/tests/spec/arb_bindless_texture/limit.c
>>>> new file mode 100644
>>>> index 000000000..960027597
>>>> --- /dev/null
>>>> +++ b/tests/spec/arb_bindless_texture/limit.c
>>>> @@ -0,0 +1,302 @@
>>>> +/*
>>>
>>> There should be a copyright here???
>>
>> No. The original file doesn't have one.
>
> That looks like a mistake to me. It should have one, its referenced by
> the license itself:
>
> "The above copyright notice and this permission notice (including
> the next paragraph) shall be included in all copies or substantial
> portions of the Software."
>
>>
>>>
>>>> + * Permission is hereby granted, free of charge, to any person
>>>> obtaining a
>>>> + * copy of this software and associated documentation files (the
>>>> "Software"),
>>>> + * to deal in the Software without restriction, including without
>>>> limitation
>>>> + * the rights to use, copy, modify, merge, publish, distribute,
>>>> sublicense,
>>>> + * and/or sell copies of the Software, and to permit persons to whom
>>>> the
>>>> + * Software is furnished to do so, subject to the following
>>>> conditions:
>>>> + *
>>>> + * The above copyright notice and this permission notice (including
>>>> the next
>>>> + * paragraph) shall be included in all copies or substantial portions
>>>> of the
>>>> + * Software.
>>>> + *
>>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>>>> EXPRESS OR
>>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>>>> MERCHANTABILITY,
>>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
>>>> SHALL
>>>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
>>>> OR OTHER
>>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
>>>> ARISING
>>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>>>> OTHER DEALINGS
>>>> + * IN THE SOFTWARE.
>>>> + *
>>>> + * Authors:
>>>> + * Marek Olšák <maraeo at gmail.com>
>>>> + * Samuel Pitoiset <samuel.pitoiset at gmail.com>
>>>> + */
>>>> +
>>>> +/**
>>>> + * Test that samplers accessed using texture handles are not counted
>>>> against
>>>> + * the texture limits.
>>>> + * Derived from Marek's max-samplers test.
>>>> + */
>
> <snip/>
More information about the Piglit
mailing list