diff options
author | Dave Airlie <airlied@redhat.com> | 2015-10-30 09:24:29 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-10-30 09:24:29 +1000 |
commit | 1a8eb54ff0707b82e827d4c6cc1b5436d9323f01 (patch) | |
tree | adf5f016d63d148121a972a74f4e28c2b460af1c | |
parent | c7c7746a9cc088d1995944aa6593c1fcab58a3f0 (diff) |
add bindless vertex testarb_bindless_texture
-rw-r--r-- | tests/spec/arb_bindless_texture/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_bindless_texture/bindless_texture_vertex.c | 117 |
2 files changed, 118 insertions, 0 deletions
diff --git a/tests/spec/arb_bindless_texture/CMakeLists.gl.txt b/tests/spec/arb_bindless_texture/CMakeLists.gl.txt index d4a2e7d79..968c7ed81 100644 --- a/tests/spec/arb_bindless_texture/CMakeLists.gl.txt +++ b/tests/spec/arb_bindless_texture/CMakeLists.gl.txt @@ -11,5 +11,6 @@ link_libraries ( piglit_add_executable (arb_bindless_texture-bindless-texture bindless_texture.c) piglit_add_executable (arb_bindless_texture-layout bindless_texture_layout.c) +piglit_add_executable (arb_bindless_texture-vertex bindless_texture_vertex.c) piglit_add_executable (arb_bindless_texture-illegal illegal.c) # vim: ft=cmake: diff --git a/tests/spec/arb_bindless_texture/bindless_texture_vertex.c b/tests/spec/arb_bindless_texture/bindless_texture_vertex.c new file mode 100644 index 000000000..9abdb1f56 --- /dev/null +++ b/tests/spec/arb_bindless_texture/bindless_texture_vertex.c @@ -0,0 +1,117 @@ +/* + * 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" + "#extension GL_ARB_bindless_texture : require\n" + "layout (bindless_sampler) in sampler2D samp_in;\n" + "in vec4 piglit_vertex;\n" + "in vec2 tc_in;\n" + "out vec2 texCoord;\n" + "flat out sampler2D samp_vs;\n" + "void main() { gl_Position = piglit_vertex; texCoord = tc_in; samp_vs = samp_in; }\n"; + + static const char *frag = + "#version 330\n" + "#extension GL_ARB_bindless_texture : enable\n" + "flat layout (bindless_sampler) in sampler2D samp_vs;\n" + "in vec2 texCoord;\n" + "out vec4 finalColor;" + "void main()\n" + "{\n" + " finalColor = texture(samp_vs, 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); +} |