diff options
author | Dave Airlie <airlied@redhat.com> | 2015-10-25 14:35:35 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-06-08 05:12:35 +1000 |
commit | e3f490183b36eb51820386ec728fc5f9f58f357c (patch) | |
tree | 64869165d74092da3fd179ae88d2b6daf2f5060f | |
parent | 83b8fcca2d9cabeea12710d0e98ae357b91c3045 (diff) |
initial bindless texture test
-rw-r--r-- | tests/spec/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_bindless_texture/CMakeLists.gl.txt | 14 | ||||
-rw-r--r-- | tests/spec/arb_bindless_texture/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_bindless_texture/bindless_texture.c | 116 |
4 files changed, 132 insertions, 0 deletions
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 27c60c43a..952de9957 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory (amd_performance_monitor) add_subdirectory (amd_pinned_memory) add_subdirectory (arb_arrays_of_arrays) add_subdirectory (arb_base_instance) +add_subdirectory (arb_bindless_texture) add_subdirectory (arb_buffer_storage) add_subdirectory (arb_clear_buffer_object) add_subdirectory (arb_clear_texture) diff --git a/tests/spec/arb_bindless_texture/CMakeLists.gl.txt b/tests/spec/arb_bindless_texture/CMakeLists.gl.txt new file mode 100644 index 000000000..b8544964f --- /dev/null +++ b/tests/spec/arb_bindless_texture/CMakeLists.gl.txt @@ -0,0 +1,14 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (arb_bindless_texture-bindless-texture bindless_texture.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_bindless_texture/CMakeLists.txt b/tests/spec/arb_bindless_texture/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/arb_bindless_texture/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_bindless_texture/bindless_texture.c b/tests/spec/arb_bindless_texture/bindless_texture.c new file mode 100644 index 000000000..77043ef1c --- /dev/null +++ b/tests/spec/arb_bindless_texture/bindless_texture.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2015 Red Hat + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS + * 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. + */ + +/** + * Tests GL_ARB_bindless_texture + */ + +#include "piglit-util-gl.h" + +#include <GL/glx.h> +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint prog; +GLuint texid; +GLuint loc; +GLuint64 texhandle; +void +compile_shader(void) +{ + GLuint vs; + GLuint fs; + GLboolean ok; + static const char *vert = + "#version 130\n" + "in vec4 piglit_vertex;\n" + "in vec2 tc_in;\n" + "out vec2 texCoord;\n" + "void main() { gl_Position = piglit_vertex; texCoord = tc_in; }\n"; + + static const char *frag = + "#version 330\n" + "#extension GL_ARB_bindless_texture : enable\n" + "layout (bindless_sampler) uniform sampler2D mysamp;\n" + "in vec2 texCoord;\n" + "out vec4 finalColor;" + "void main()\n" + "{\n" + " finalColor = texture(mysamp, texCoord);\n" + "}\n"; + + vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert); + fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag); + prog = piglit_link_simple_program(vs, fs); + + ok = piglit_link_check_status(prog); + if (!ok) + piglit_report_result(PIGLIT_FAIL); + loc = glGetUniformLocation(prog, "mysamp"); + glUseProgram(prog); +} + +typedef GLuint64 (*gth)(GLuint texture); +typedef void (*guh)(GLuint loc, GLuint64 handle); +typedef void (*resident)(GLuint64 handle); + +gth GetTextureHandle; +guh GetUniformHandle; +resident MakeRes, MakeNonRes; +enum piglit_result +piglit_display(void) +{ + bool pass = true; + + MakeRes(texhandle); + piglit_draw_rect_tex(-1, -1, 2, 2, + 0, 0, 1, 1); + MakeNonRes(texhandle); + + if (!piglit_automatic) + piglit_present_results(); + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_bindless_texture"); + + compile_shader(); + + GetTextureHandle = (gth)glXGetProcAddress("glGetTextureHandleARB"); + GetUniformHandle = glXGetProcAddress("glUniformHandleui64ARB"); + MakeRes = (resident)glXGetProcAddress("glMakeTextureHandleResidentARB"); + MakeNonRes = (resident)glXGetProcAddress("glMakeTextureHandleNonResidentARB"); + texid = piglit_rgbw_texture(GL_RGBA, 64, 64, GL_FALSE, GL_TRUE, GL_UNSIGNED_NORMALIZED); + texhandle = GetTextureHandle(texid); + + GetUniformHandle(loc, texhandle); +} |