void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_vertex_buffer_object"); piglit_require_GLSL(); }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { const char *source = "!!ARBvp1.0\n" "OPTION ARB_position_invariant;\n" "MOV result.color, program.local[3];\n" "END\n"; GLuint prog; GLint max_local; GLint i; piglit_require_extension("GL_ARB_vertex_program"); prog = piglit_compile_program(GL_VERTEX_PROGRAM_ARB, source); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog); glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &max_local); /* Limit the test to blowing through 256MB of memory. */ max_local = MIN2(max_local, 1024 * 1024 * 16); for (i = 0; i < max_local; i++) { float values[4]; values[0] = i * 4; values[1] = i * 4 + 1; values[2] = i * 4 + 2; values[3] = i * 4 + 3; glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, values); } for (i = 0; i < max_local; i++) { float values[4], get_values[4]; glGetProgramLocalParameterfvARB(GL_VERTEX_PROGRAM_ARB, i, get_values); values[0] = i * 4; values[1] = i * 4 + 1; values[2] = i * 4 + 2; values[3] = i * 4 + 3; if (memcmp(values, get_values, sizeof(values)) != 0) { fprintf(stderr, "Difference on " "glGetProgramLocalParameterfvARB(%d):\n", i); fprintf(stderr, "expected: %f %f %f %f\n", values[0], values[1], values[2], values[3]); fprintf(stderr, "found: %f %f %f %f\n", get_values[0], get_values[1], get_values[2], get_values[3]); piglit_report_result(PIGLIT_FAIL); } } piglit_report_result(PIGLIT_PASS); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_pixel_buffer_object"); }
void piglit_init(int argc, char **argv) { unsigned r; unsigned c; unsigned i; (void) argc; (void) argv; piglit_require_vertex_program(); piglit_require_fragment_program(); piglit_require_extension("GL_NV_fragment_program_option"); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); vert_prog = piglit_compile_program(GL_VERTEX_PROGRAM_ARB, vert_shader_source); frag_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, frag_shader_source); glClearColor(0.5, 0.5, 0.5, 1.0); i = 0; for (r = 0; r < TEST_ROWS; r++) { for (c = 0; c < TEST_COLS; c++) { position[i + 0] = (float)((BOX_SIZE / 2) + c * (BOX_SIZE + 1) + 1); position[i + 1] = (float)((BOX_SIZE / 2) + r * (BOX_SIZE + 1) + 1); position[i + 2] = 0.0f; position[i + 3] = 1.0f; i += 4; } } /* Generate a bunch of random direction vectors. Based on the random * direction vector, generate an axis such that the reflection of the * random vector across the axis is { 0, 1, 0 }. */ srand(time(NULL)); for (i = 0; i < (ARRAY_SIZE(direction) / 4); i++) { const double d[3] = { random_float(), random_float(), random_float() }; const double inv_mag_d = 1.0 / sqrt((d[0] * d[0]) + (d[1] * d[1]) + (d[2] * d[2])); double a[3]; double mag_a; direction[(i * 4) + 0] = d[0] * inv_mag_d; direction[(i * 4) + 1] = d[1] * inv_mag_d; direction[(i * 4) + 2] = d[2] * inv_mag_d; direction[(i * 4) + 3] = 0.0; a[0] = direction[(i * 4) + 0] + 0.0; a[1] = direction[(i * 4) + 1] + 1.0; a[2] = direction[(i * 4) + 2] + 0.0; mag_a = sqrt((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2])); axis[(i * 4) + 0] = a[0] / mag_a; axis[(i * 4) + 1] = a[1] / mag_a; axis[(i * 4) + 2] = a[2] / mag_a; axis[(i * 4) + 3] = 0.0; } }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_EXT_framebuffer_object"); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_depth_texture"); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_timer_query"); }
enum piglit_result piglit_display(void) { const char *vs_ubo_template = "#extension GL_ARB_uniform_buffer_object : enable\n" "\n" "varying vec4 vary;" "\n" "layout(std140) uniform ubo {\n" " vec4 v[%d];\n" "};\n" "uniform int i;\n" "\n" "void main() {\n" " gl_Position = gl_Vertex;\n" " vary = v[i];\n" "}\n"; const char *fs_template = "#extension GL_ARB_uniform_buffer_object : enable\n" "\n" "varying vec4 vary;" "\n" "void main() {\n" " gl_FragColor = vary;\n" "}\n"; const char *vs_template = "#extension GL_ARB_uniform_buffer_object : enable\n" "\n" "void main() {\n" " gl_Position = gl_Vertex;\n" "}\n"; const char *fs_ubo_template = "#extension GL_ARB_uniform_buffer_object : enable\n" "\n" "layout(std140) uniform ubo {\n" " vec4 v[%d];\n" "};\n" "uniform int i;\n" "\n" "void main() {\n" " gl_FragColor = v[i];\n" "}\n"; char *vs_source, *fs_source; GLint max_size, vec4s, i_location; GLuint vs, fs, prog, bo; GLenum target; float *data; size_t size; bool pass = true; bool may_link_fail; const float green[4] = { 0, 1, 0, 0 }; int test_index; piglit_require_extension("GL_ARB_uniform_buffer_object"); glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_size); printf("Max uniform block size: %d\n", max_size); vec4s = max_size / 4 / 4; switch (mode) { case VS: target = GL_VERTEX_SHADER; may_link_fail = false; test_index = vec4s - 1; break; case VS_EXCEED: target = GL_VERTEX_SHADER; may_link_fail = true; vec4s++; test_index = vec4s - 2; break; case FS: target = GL_FRAGMENT_SHADER; may_link_fail = false; test_index = vec4s - 1; break; case FS_EXCEED: target = GL_FRAGMENT_SHADER; may_link_fail = true; vec4s++; test_index = vec4s - 2; break; default: assert(false); target = GL_NONE; may_link_fail = false; } switch (target) { case GL_VERTEX_SHADER: (void)!asprintf(&vs_source, vs_ubo_template, vec4s); (void)!asprintf(&fs_source, "%s", fs_template); printf("Testing VS with uniform block vec4 v[%d]\n", vec4s); break; case GL_FRAGMENT_SHADER: (void)!asprintf(&vs_source, "%s", vs_template); (void)!asprintf(&fs_source, fs_ubo_template, vec4s); printf("Testing FS with uniform block vec4 v[%d]\n", vec4s); break; default: piglit_report_result(PIGLIT_FAIL); } vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source); prog = glCreateProgram(); glAttachShader(prog, vs); glAttachShader(prog, fs); glLinkProgram(prog); if (may_link_fail) { if (!piglit_link_check_status_quiet(prog)) { printf("Failed to link with uniform block vec4 " "v[%d]\n", vec4s); piglit_report_result(PIGLIT_PASS); } } else { if (!piglit_link_check_status_quiet(prog)) { fprintf(stderr, "Failed to link with uniform block vec4 " "v[%d]\n", vec4s); return PIGLIT_FAIL; } } size = vec4s * 4 * sizeof(float); glGenBuffers(1, &bo); glBindBuffer(GL_UNIFORM_BUFFER, bo); glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_DYNAMIC_DRAW); data = glMapBuffer(GL_UNIFORM_BUFFER, GL_READ_WRITE); memset(data, 0, size); /* The whole uniform buffer will be zeros, except for the * entry at v[test_index] which will be green. */ data[test_index * 4 + 0] = green[0]; data[test_index * 4 + 1] = green[1]; data[test_index * 4 + 2] = green[2]; data[test_index * 4 + 3] = green[3]; glUnmapBuffer(GL_UNIFORM_BUFFER); glUseProgram(prog); i_location = glGetUniformLocation(prog, "i"); glUniform1i(i_location, test_index); glUniformBlockBinding(prog, 0, 0); glBindBufferBase(GL_UNIFORM_BUFFER, 0, bo); piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); glDeleteProgram(prog); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static GLboolean render_and_check_textures(GLenum internal_format) { GLuint rgba_fb; GLuint other_fb; float rgba_image[4 * 64 * 64]; float other_image[4 * 64 * 64]; GLboolean has_green; GLuint vs; GLuint fs; GLint scale_loc; GLint bias_loc; float scale; float bias; piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ARB_texture_rg"); has_green = GL_FALSE; scale = 1.0; bias = 0.0; switch (internal_format) { case GL_RG: case GL_RG8: case GL_RG16: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_RED: case GL_R8: case GL_R16: break; case GL_RG16F: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_R16F: piglit_require_extension("GL_ARB_half_float_pixel"); /* FALLTHROUGH */ case GL_RG32F: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_R32F: scale = 511.0; piglit_require_extension("GL_ARB_texture_float"); break; case GL_RG_INTEGER: case GL_RG8I: case GL_RG16I: case GL_RG32I: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_R8I: case GL_R16I: case GL_R32I: bias = -100.0; scale = 511.0; piglit_require_extension("GL_EXT_texture_integer"); break; case GL_RG8UI: case GL_RG16UI: case GL_RG32UI: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_R16UI: case GL_R32UI: scale = 511.0; piglit_require_extension("GL_EXT_texture_integer"); break; case GL_RG_SNORM: case GL_RG8_SNORM: case GL_RG16_SNORM: has_green = GL_TRUE; /* FALLTHROUGH */ case GL_RED_SNORM: case GL_R8_SNORM: case GL_R16_SNORM: scale = 0.5; bias = -0.5; piglit_require_extension("GL_EXT_texture_snorm"); break; default: fprintf(stderr, "invalid format 0x%04x\n", internal_format); piglit_report_result(PIGLIT_FAIL); break; } glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), positions); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), colors); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert_code); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag_code); fbo_program = piglit_link_simple_program(vs, fs); glBindAttribLocation(fbo_program, 0, "position"); glBindAttribLocation(fbo_program, 1, "color"); glLinkProgram(fbo_program); if (!piglit_link_check_status(fbo_program)) piglit_report_result(PIGLIT_FAIL); scale_loc = glGetUniformLocation(fbo_program, "scale"); if (scale_loc < 0) { fprintf(stderr, "couldn't get uniform location for \"scale\"\n"); piglit_report_result(PIGLIT_FAIL); } bias_loc = glGetUniformLocation(fbo_program, "bias"); if (bias_loc < 0) { fprintf(stderr, "couldn't get uniform location for \"bias\"\n"); piglit_report_result(PIGLIT_FAIL); } glUseProgram(fbo_program); glUniform1f(scale_loc, scale); glUniform1f(bias_loc, bias); /* Draw the reference image to the RGBA texture. */ rgba_fb = create_fbo(64, 64, GL_RGBA); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, rgba_fb); glViewport(0, 0, 64, 64); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, (GLint *) &rgba_tex); glBindTexture(GL_TEXTURE_2D, rgba_tex); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, rgba_image); /* Draw the comparison image to the other texture. */ other_fb = create_fbo(64, 64, internal_format); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, other_fb); glViewport(0, 0, 64, 64); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, (GLint *) &other_tex); glBindTexture(GL_TEXTURE_2D, other_tex); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, other_image); glUseProgram(0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glViewport(0, 0, piglit_width, piglit_height); return compare_texture(rgba_image, other_image, internal_format, GL_RGBA, 64 * 64, has_green); }
void piglit_init(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "coherent")) { coherent = GL_TRUE; continue; } if (!strcmp(argv[i], "read")) { test = READ; continue; } if (!strcmp(argv[i], "draw")) { test = DRAW; continue; } if (!strcmp(argv[i], "client-storage")) { client_storage = GL_TRUE; continue; } printf("Unknown param: %s\n", argv[i]); piglit_report_result(PIGLIT_FAIL); } if (test == NONE) { puts("Wrong parameters."); piglit_report_result(PIGLIT_FAIL); } #ifdef PIGLIT_USE_OPENGL piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); piglit_require_gl_version(15); piglit_require_extension("GL_ARB_buffer_storage"); piglit_require_extension("GL_ARB_map_buffer_range"); if (test == READ) { piglit_require_extension("GL_ARB_copy_buffer"); piglit_require_extension("GL_ARB_sync"); } if (!coherent) { /* for MemoryBarrier */ piglit_require_extension("GL_ARB_shader_image_load_store"); } #else // PIGLIT_USE_OPENGL_ES3 GLuint program; GLuint vertex_index; piglit_require_extension("GL_EXT_buffer_storage"); /* Create program */ program = piglit_build_simple_program(vs_source, fs_source); glUseProgram(program); #endif glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); glBufferStorage(GL_ARRAY_BUFFER, BUF_SIZE, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0) | GL_DYNAMIC_STORAGE_BIT | (client_storage ? GL_CLIENT_STORAGE_BIT : 0)); piglit_check_gl_error(GL_NO_ERROR); map = glMapBufferRange(GL_ARRAY_BUFFER, 0, BUF_SIZE, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0)); piglit_check_gl_error(GL_NO_ERROR); if (!map) piglit_report_result(PIGLIT_FAIL); #ifdef PIGLIT_USE_OPENGL_ES3 /* Gen VAO */ glGenVertexArrays(1, &vao); glBindVertexArray(vao); /* Retrieve indices from vs */ vertex_index = glGetAttribLocation(program, "vertex"); /* Enable vertex attrib array */ glEnableVertexAttribArray(vertex_index); glVertexAttribPointer(vertex_index, 3, GL_FLOAT, GL_FALSE, 0, 0); piglit_check_gl_error(GL_NO_ERROR); #endif glBindBuffer(GL_ARRAY_BUFFER, 0); }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { unsigned int i; GLuint prog; const char *source = "#extension GL_ARB_uniform_buffer_object : enable\n" "uniform ubo1 { float a; };\n" "uniform ubo2 { float bb; float c; };\n" "uniform float dddd;\n" "void main() {\n" " gl_FragColor = vec4(a + bb + c + dddd);\n" "}\n"; int uniforms; bool pass = true; const char *names[4] = {"a", "bb", "c", "dddd"}; bool found[4] = {false, false, false, false}; char no_write; char fill_char = 0xd0; piglit_require_extension("GL_ARB_uniform_buffer_object"); prog = piglit_build_simple_program(NULL, source); glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &uniforms); assert(uniforms == 4); for (i = 0; i < uniforms; i++) { GLint written_strlen = 0; GLint namelen = 9999; char name[1000]; int name_index; /* This is the size including null terminator. */ glGetActiveUniformsiv(prog, 1, &i, GL_UNIFORM_NAME_LENGTH, &namelen); memset(name, 0xd0, sizeof(name)); glGetActiveUniformName(prog, i, sizeof(name), &written_strlen, name); if (written_strlen >= sizeof(name) - 1) { fprintf(stderr, "return strlen %d, longer than the buffer size\n", written_strlen); pass = false; continue; } else if (name[written_strlen] != 0) { fprintf(stderr, "return name[%d] was %d, expected 0\n", written_strlen, name[written_strlen]); pass = false; continue; } else if (strlen(name) != written_strlen) { fprintf(stderr, "return strlen was %d, but \"%s\" " "has strlen %d\n", written_strlen, name, (int)strlen(name)); pass = false; continue; } for (name_index = 0; name_index < ARRAY_SIZE(names); name_index++) { if (strcmp(names[name_index], name) == 0) { if (found[name_index]) { fprintf(stderr, "Uniform name \"%s\" " "returned twice.\n", name); pass = false; } found[name_index] = true; break; } } if (name_index == ARRAY_SIZE(names)) { fprintf(stderr, "uniform \"%s\" is not a known name\n", name); pass = false; continue; } if (namelen != written_strlen + 1) { fprintf(stderr, "uniform \"%s\" had " "GL_UNIFORM_NAME_LENGTH %d, expected %d\n", name, namelen, written_strlen + 1); pass = false; continue; } /* Test for overflow by writing to a bufSize equal to * strlen and checking if a null terminator or * something landed past that. */ memset(name, fill_char, sizeof(name)); glGetActiveUniformName(prog, i, written_strlen, NULL, name); if (name[written_strlen] != fill_char) { fprintf(stderr, "glGetActiveUniformName overflowed: " "name[%d] = 0x%02x instead of 0x%02x\n", written_strlen, name[written_strlen], fill_char); pass = false; } } if (!piglit_khr_no_error) { no_write = fill_char; glGetActiveUniformName(0xd0d0, 0, 1, NULL, &no_write); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; if (no_write != fill_char) pass = false; no_write = fill_char; glGetActiveUniformName(prog, 0, -1, NULL, &no_write); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; if (no_write != fill_char) pass = false; no_write = fill_char; glGetActiveUniformName(prog, uniforms, 1, NULL, &no_write); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; if (no_write != fill_char) pass = false; } glDeleteProgram(prog); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { bool pass = true; GLuint pipe; GLuint vs_prog; GLuint active_prog; GLuint unlinked_prog; GLuint shader; unsigned glsl_version; char *source; piglit_require_extension("GL_ARB_separate_shader_objects"); glsl_version = pick_a_glsl_version(); glGenProgramPipelines(1, &pipe); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; glBindProgramPipeline(pipe); (void)!asprintf(&source, vs_code_template, glsl_version); vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, (const GLchar *const *) &source); pass = piglit_link_check_status(vs_prog) && pass; /* First, make a valid program active. */ glActiveShaderProgram(pipe, vs_prog); pass = piglit_check_gl_error(GL_NO_ERROR) && pass; /* Next, try to make an invalid program active and verify that the * correct error is generated. Also make sure the old program is * still active. * * Section 7.4 (Program Pipeline Objects) under ActiveShaderProgram of * the OpenGL 4.4 spec says: * * "An INVALID_VALUE error is generated if program is not zero and * is not the name of either a program or shader object." */ glActiveShaderProgram(pipe, ~vs_prog); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; glGetProgramPipelineiv(pipe, GL_ACTIVE_PROGRAM, (GLint *) &active_prog); if (active_prog != vs_prog) { printf("glActiveShaderProgram with an invalid program name " "changed the active program state.\n"); pass = false; } else { glActiveShaderProgram(pipe, vs_prog); } /* Try the same thing with a valid shader object (that is not part of * a linked program). Verify that the correct error is generated, and * make sure the old program is still active. * * Section 7.4 (Program Pipeline Objects) under ActiveShaderProgram of * the OpenGL 4.4 spec says: * * "An INVALID_OPERATION error is generated if program is the name * of a shader object." */ shader = piglit_compile_shader_text(GL_VERTEX_SHADER, source); glActiveShaderProgram(pipe, shader); pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; glGetProgramPipelineiv(pipe, GL_ACTIVE_PROGRAM, (GLint *) &active_prog); if (active_prog != vs_prog) { printf("glActiveShaderProgram with a shader object " "changed the active program state.\n"); pass = false; } else { glActiveShaderProgram(pipe, vs_prog); } /* Finally, try the same thing with a valid program that is not * linked. Verify that the correct error is generated, and make sure * the old program is still active. * * Section 7.4 (Program Pipeline Objects) under ActiveShaderProgram of * the OpenGL 4.4 spec says: * * "An INVALID_OPERATION error is generated if program is not zero * and has not been linked, or was last linked unsuccessfully." */ unlinked_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, (const GLchar *const *) &invalid_code); glActiveShaderProgram(pipe, unlinked_prog); pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; glGetProgramPipelineiv(pipe, GL_ACTIVE_PROGRAM, (GLint *) &active_prog); if (active_prog != vs_prog) { printf("glActiveShaderProgram with an unlinked program " "changed the active program state.\n"); pass = false; } else { glActiveShaderProgram(pipe, vs_prog); } free(source); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { bool pass = true; int i; static const GLenum invalidWrapParams[] = { GL_REPEAT, GL_MIRRORED_REPEAT, GL_MIRROR_CLAMP_EXT, GL_MIRROR_CLAMP_TO_BORDER_EXT, /* This has the same value as GL_MIRROR_CLAMP_TO_EDGE, but * glext.h may not be new enough. Just use the _EXT version. */ GL_MIRROR_CLAMP_TO_EDGE_EXT, }; static const GLenum invalidFilterParams[] = { GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR }; if (piglit_get_gl_version() < 33) piglit_require_extension("ARB_texture_rectangle"); /* "...the error INVALID_ENUM is generated if the TEXTURE_WRAP_S, * TEXTURE_WRAP_T, or TEXTURE_WRAP_R parameter is set to REPEAT or * MIRRORED_REPEAT." */ for(i = 0; i < ARRAY_SIZE(invalidWrapParams); i++) { glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, invalidWrapParams[i]); pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, invalidWrapParams[i]); pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_R, invalidWrapParams[i]); pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; } /* "The error INVALID_ENUM is generated if TEXTURE_MIN_FILTER is set * to a value other than NEAREST or LINEAR." */ for (i = 0; i < ARRAY_SIZE(invalidFilterParams); i++) { glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, invalidFilterParams[i]); pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass; } /* "The error INVALID_VALUE is generated if TEXTURE_BASE_LEVEL is set * to any value other than zero." */ glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_BASE_LEVEL, 37); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { bool pass = true; GLuint bo[2]; GLint binding; piglit_require_extension("GL_ARB_uniform_buffer_object"); glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, 0, &binding); if (binding != 0) { fprintf(stderr, "Default UBO binding should be 0, was %d\n", binding); piglit_report_result(PIGLIT_FAIL); } glGenBuffers(2, bo); glBindBuffer(GL_UNIFORM_BUFFER, bo[0]); glBufferData(GL_UNIFORM_BUFFER, 4, NULL, GL_STATIC_DRAW); glBindBufferBase(GL_UNIFORM_BUFFER, 0, bo[0]); glBindBuffer(GL_UNIFORM_BUFFER, bo[1]); glBufferData(GL_UNIFORM_BUFFER, 4, NULL, GL_STATIC_DRAW); glBindBufferRange(GL_UNIFORM_BUFFER, 1, bo[1], 0, 4); glDeleteBuffers(2, bo); if (glIsBuffer(bo[0]) || glIsBuffer(bo[1])) { fprintf(stderr, "Failed to delete buffers\n"); pass = false; } glGetIntegerv(GL_UNIFORM_BUFFER_BINDING, &binding); if (binding != 0) { printf("Failed to unbind glBindBuffer() buffer %d:\n" " binding set to %d, should be 0\n", bo[1], binding); pass = false; } glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, 0, &binding); if (binding != 0) { printf("Failed to unbind glBindBufferBase() buffer %d:\n" " binding set to %d, should be 0\n", bo[0], binding); pass = false; } glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, 1, &binding); if (binding != 0) { printf("Failed to unbind glBindBufferRange() buffer %d:\n" " binding set to %d, should be 0\n", bo[1], binding); pass = false; } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { GLint align, value[2]; GLuint tex, bo; piglit_require_gl_version(20); piglit_require_extension("GL_ARB_texture_buffer_range"); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_BUFFER, tex); glGenBuffers(1, &bo); glBindBuffer(GL_TEXTURE_BUFFER, bo); glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &align); if (align < 1) { fprintf(stderr, "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT == %i, " "should be >= 1\n", align); piglit_report_result(PIGLIT_FAIL); } /* If <offset> is negative or if <size> is * less than or equal to zero or if <offset> + <size> is greater than * the value of BUFFER_SIZE for the buffer bound to <target>, of if * <offset> is not an integer multiple of * TEXTURE_BUFFER_OFFSET_ALIGNMENT, then the error INVALID_VALUE * is generated. */ glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, 4); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glBufferData(GL_TEXTURE_BUFFER, TBO_SIZE, NULL, GL_STATIC_DRAW); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, -align, 4); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, 0); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, -16); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); if (align > 1) { glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, align / 2, 16); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); } glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, align, TBO_SIZE - align); if (!piglit_check_gl_error(GL_NO_ERROR)) { fprintf(stderr, "glTexBufferRange failed\n"); piglit_report_result(PIGLIT_FAIL); } glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_OFFSET, &value[0]); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_SIZE, &value[1]); if (value[0] != align || value[1] != TBO_SIZE - align) { fprintf(stderr, "GL_TEXTURE_BUFFER_OFFSET/SIZE returned %i/%i, " "expected %i/%i\n", value[0], value[1], align, TBO_SIZE - align); piglit_report_result(PIGLIT_FAIL); } /* If <buffer> is zero, then any buffer object attached to the * buffer texture is detached, the values <offset> and <size> are * ignored and the state for <offset> and <size> for the * buffer texture are reset to zero. */ glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, 0, -align, TBO_SIZE * 2); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_OFFSET, &value[0]); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_SIZE, &value[1]); if (value[0] || value[1]) { fprintf(stderr, "buffer detached but " "GL_TEXTURE_BUFFER_OFFSET/SIZE " "not reset to 0\n"); piglit_report_result(PIGLIT_FAIL); } piglit_report_result(PIGLIT_PASS); }
void piglit_init(int argc, char **argv) { static const char *st_r_tf_varying[] = {"gs_output0", NULL}; piglit_require_extension("GL_ARB_program_interface_query"); piglit_require_extension("GL_ARB_separate_shader_objects"); /* Allocate the different programs */ prog_std = piglit_build_simple_program_unlinked_multiple_shaders( GL_VERTEX_SHADER, vs_std, GL_GEOMETRY_SHADER, gs_std, GL_FRAGMENT_SHADER, fs_std, 0); glTransformFeedbackVaryings(prog_std, 1, st_r_tf_varying, GL_INTERLEAVED_ATTRIBS); piglit_check_gl_error(GL_NO_ERROR); /* force the compiler not to optimise away inputs/outputs */ glProgramParameteri(prog_std, GL_PROGRAM_SEPARABLE, GL_TRUE); piglit_check_gl_error(GL_NO_ERROR); glLinkProgram(prog_std); if (!piglit_link_check_status(prog_std)) { glDeleteProgram(prog_std); piglit_report_result(PIGLIT_FAIL); } if (piglit_is_extension_supported("GL_ARB_shader_storage_buffer_object")) { prog_stor = piglit_build_simple_program_multiple_shaders( GL_VERTEX_SHADER, vs_stor, GL_GEOMETRY_SHADER, gs_stor, GL_FRAGMENT_SHADER, fs_stor, 0); prog_buff_blks = piglit_build_simple_program_multiple_shaders( GL_VERTEX_SHADER, vs_buff_blks, GL_FRAGMENT_SHADER, fs_buff_blks, 0); } if (piglit_is_extension_supported("GL_ARB_explicit_attrib_location") && piglit_is_extension_supported("GL_ARB_explicit_uniform_location")) { prog_loc = piglit_build_simple_program_multiple_shaders( GL_VERTEX_SHADER, vs_loc, GL_FRAGMENT_SHADER, fs_loc, 0); } if (piglit_is_extension_supported("GL_ARB_shader_atomic_counters")) { prog_atom = piglit_build_simple_program_unlinked_multiple_shaders( GL_FRAGMENT_SHADER, fs_atom, 0); /* force the compiler not to optimise away inputs/outputs */ glProgramParameteri(prog_atom, GL_PROGRAM_SEPARABLE, GL_TRUE); piglit_check_gl_error(GL_NO_ERROR); glLinkProgram(prog_atom); if (!piglit_link_check_status(prog_atom)) { glDeleteProgram(prog_atom); piglit_report_result(PIGLIT_FAIL); } } if (!piglit_is_extension_supported("GL_ARB_shader_subroutine")) { return; } prog_sub = piglit_build_simple_program_multiple_shaders( GL_VERTEX_SHADER, vs_sub, GL_GEOMETRY_SHADER, gs_sub, GL_FRAGMENT_SHADER, fs_sub, 0); if (piglit_is_extension_supported("GL_ARB_tessellation_shader")) { prog_sub_tess = piglit_build_simple_program_unlinked_multiple_shaders( GL_TESS_CONTROL_SHADER, tcs_sub, 0); /* force the compiler not to optimise away inputs/outputs */ glProgramParameteri(prog_sub_tess, GL_PROGRAM_SEPARABLE, GL_TRUE); piglit_check_gl_error(GL_NO_ERROR); glLinkProgram(prog_sub_tess); if (!piglit_link_check_status(prog_sub_tess)) { glDeleteProgram(prog_sub_tess); piglit_report_result(PIGLIT_FAIL); } } if (piglit_is_extension_supported("GL_ARB_compute_shader")) { prog_cs = piglit_build_simple_program_multiple_shaders( GL_COMPUTE_SHADER, cs_sub, 0); } }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_framebuffer_object"); glClearColor(0.2, 0.2, 0.2, 0.0); }
void piglit_init(int argc, char **argv) { bool pass = true; GLuint fs; GLuint save_index = 0xaaaaaaaa; const GLchar *one_uniform = "a"; const GLchar *uniform_names[] = {"a", "b", "c"}; bool found_index[3] = {false, false, false}; GLuint indices[3], index; int i; piglit_require_extension("GL_ARB_uniform_buffer_object"); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag_shader_text); if (!fs) { printf("Failed to compile FS:\n%s", frag_shader_text); piglit_report_result(PIGLIT_FAIL); } prog = piglit_link_simple_program(0, fs); if (!prog) piglit_report_result(PIGLIT_FAIL); /* From the GL_ARB_uniform_buffer_object spec: * * "The error INVALID_VALUE is generated by GetUniformIndices, * GetActiveUniformsiv, GetActiveUniformName, GetUniformBlockIndex, * GetActiveUniformBlockiv, GetActiveUniformBlockName, and * UniformBlockBinding if <program> is not a value generated by GL. * * ... * * The error INVALID_VALUE is generated by GetUniformIndices and * GetActiveUniformsiv if <uniformCount> is less than zero. * * ... * * "If an error occurs, nothing is written to <uniformIndices>." */ index = save_index; glGetUniformIndices(prog, -1, &one_uniform, &index); if (!piglit_check_gl_error(GL_INVALID_VALUE)) { pass = false; } else if (index != save_index) { printf("Bad program uniform index: 0x%08x\n", index); printf(" Expected 0x%08x\n", save_index); pass = false; } index = save_index; glGetUniformIndices(0xd0d0, 1, &one_uniform, &index); if (!piglit_check_gl_error(GL_INVALID_VALUE)) { pass = false; } else if (index != save_index) { printf("Bad program uniform index: 0x%08x\n", index); printf(" Expected 0x%08x\n", save_index); pass = false; } glGetUniformIndices(prog, 3, uniform_names, indices); if (!piglit_check_gl_error(0)) piglit_report_result(PIGLIT_FAIL); for (i = 0; i < 3; i++) { printf("%s: index %d\n", uniform_names[i], indices[i]); if (indices[i] < 0 || indices[i] > 2 || found_index[indices[i]]) { printf("Expected consecutive numbers starting from 0\n"); pass = false; } found_index[indices[i]] = true; } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_EXT_texture_sRGB"); reshape(piglit_width, piglit_height); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_direct_state_access"); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_texture_cube_map"); }
void piglit_init(int argc, char **argv) { GLint num_compressed_formats; GLenum *compressed_formats = NULL; unsigned i; bool pass = true; piglit_require_extension("GL_ARB_texture_compression"); glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_formats); if (num_compressed_formats == 0) { printf("No compressed formats supported.\n"); } else if (num_compressed_formats < 0) { fprintf(stderr, "Invalid number of compressed formats (%d) reported\n", num_compressed_formats); piglit_report_result(PIGLIT_FAIL); } else { compressed_formats = calloc(num_compressed_formats, sizeof(GLenum)); glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, (GLint *) compressed_formats); printf("Driver reported the following compressed formats:\n"); for (i = 0; i < num_compressed_formats; i++) { printf(" 0x%04x %s\n", compressed_formats[i], piglit_get_gl_enum_name(compressed_formats[i])); } printf("\n"); fflush(stdout); } /* There are some specific formats that are valid for certain generic * formats that are not returned by the GL_COMRPESSED_TEXTURE_FORMATS * query. That query only returns formats that have no restrictions or * caveats for RGB or RGBA base formats. We have to add these formats * to the list of possible formats by hand. */ if (piglit_is_extension_supported("GL_EXT_texture_compression_latc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT); } if (piglit_is_extension_supported("GL_ATI_texture_compression_3dc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 1, 0x8837); } pass = try_formats(arb_texture_compression_formats, ARRAY_SIZE(arb_texture_compression_formats), compressed_formats, num_compressed_formats); /* Remove the various luminance and luminance-alpha formats from the * list since they cannot be used for the later tests. */ if (piglit_is_extension_supported("GL_ATI_texture_compression_3dc")) { num_compressed_formats--; } if (piglit_is_extension_supported("GL_EXT_texture_compression_latc")) { num_compressed_formats -= 4; } /* Add the RGTC formats, then check them. */ if (piglit_is_extension_supported("GL_ARB_texture_rg")) { if (piglit_is_extension_supported("GL_ARB_texture_compression_rgtc") || piglit_is_extension_supported("GL_EXT_texture_compression_rgtc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2); } pass = try_formats(arb_texture_rg_formats, ARRAY_SIZE(arb_texture_rg_formats), compressed_formats, num_compressed_formats) && pass; /* Remove the RGTC formats from the list since they cannot be * used for the later tests. */ if (piglit_is_extension_supported("GL_ARB_texture_compression_rgtc") || piglit_is_extension_supported("GL_EXT_texture_compression_rgtc")) { num_compressed_formats -= 4; } } /* Add the sRGB formats, then check them. */ if (piglit_is_extension_supported("GL_EXT_texture_sRGB")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA, GL_COMPRESSED_SLUMINANCE, GL_COMPRESSED_SLUMINANCE_ALPHA); if (piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT); } pass = try_formats(ext_texture_srgb_formats, ARRAY_SIZE(ext_texture_srgb_formats), compressed_formats, num_compressed_formats) && pass; /* Remove the sRGB formats from the list since they cannot be * used for the later tests. */ num_compressed_formats -= 4; if (piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")) { num_compressed_formats -= 4; } } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_AMD_framebuffer_multisample_advanced"); /* Check enums. */ int num_modes, *modes; glGetIntegerv(GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD, &num_modes); piglit_check_gl_error(GL_NO_ERROR); if (num_modes < 1) piglit_fail("GL_NUM_SUPPORTED_MULTISAMPLED_MODES_AMD expected > 0, got %u\n", num_modes); int max_color_samples, max_color_storage_samples, max_depthstencil_samples; glGetIntegerv(GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD, &max_color_samples); glGetIntegerv(GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD, &max_color_storage_samples); glGetIntegerv(GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD, &max_depthstencil_samples); if (max_color_samples < 4 || max_color_storage_samples < 4 || max_depthstencil_samples < 4) { piglit_fail("GL_MAX_xxx_SAMPLES_AMD expected >= 4, got %u,%u,%u\n", max_color_samples, max_color_storage_samples, max_depthstencil_samples); } if (max_color_samples < max_color_storage_samples) piglit_fail("GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD < GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD\n"); modes = malloc(num_modes * 3 * 4); glGetIntegerv(GL_SUPPORTED_MULTISAMPLE_MODES_AMD, modes); piglit_check_gl_error(GL_NO_ERROR); bool found_max_color = false, found_max_zs = false; for (int i = 0; i < num_modes; i++) { if (modes[i*3] < 2 || modes[i*3+1] < 1 || modes[i*3+2] < 1 || modes[i*3] < modes[i*3+1] || modes[i*3] < modes[i*3+2]) piglit_fail("GL_SUPPORTED_MULTISAMPLE_MODES_AMD invalid mode %u,%u,%u\n", modes[i*3], modes[i*3+1], modes[i*3+2]); if (modes[i*3] == max_color_samples && modes[i*3+1] == max_color_storage_samples) found_max_color = true; if (modes[i*3+2] == max_depthstencil_samples) found_max_zs = true; } if (!found_max_color) piglit_fail("Mode with GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD and ..._STORAGE_SAMPLES_AMD not listed\n"); if (!found_max_zs) piglit_fail("Modes with GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD not listed"); GLuint rb; glGenRenderbuffers(1, &rb); glBindRenderbuffer(GL_RENDERBUFFER, rb); /* Check RenderbufferStorage errors. */ glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 1, -1, GL_RGBA8, 64, 64); piglit_check_gl_error(GL_INVALID_VALUE); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, max_color_samples + 1, max_color_storage_samples, GL_RGBA8, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, max_color_samples, max_color_storage_samples + 1, GL_RGBA8, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 2, 3, GL_RGBA8, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 2, 3, GL_DEPTH_COMPONENT24, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 2, 3, GL_STENCIL_INDEX8, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 3, 2, GL_DEPTH_COMPONENT24, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 3, 2, GL_STENCIL_INDEX8, 64, 64); piglit_check_gl_error(GL_INVALID_OPERATION); glDeleteRenderbuffers(1, &rb); /* Check that all modes can be allocated and are framebuffer complete. */ bool tested_zero_samples = false; for (int i = 0; i < num_modes; i++) { GLuint fb, cb, db, tmp; /* Color */ glGenRenderbuffers(1, &cb); glBindRenderbuffer(GL_RENDERBUFFER, cb); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, modes[i*3], modes[i*3+1], GL_RGBA8, 64, 64); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("color", modes[i*3], modes[i*3+1]); /* Depth stencil */ glGenRenderbuffers(1, &db); glBindRenderbuffer(GL_RENDERBUFFER, db); glRenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, modes[i*3+2], modes[i*3+2], GL_DEPTH24_STENCIL8, 64, 64); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("Z/S", modes[i*3+2], modes[i*3+2]); /* Framebuffer */ glGenFramebuffers(1, &fb); glBindFramebuffer(GL_FRAMEBUFFER, fb); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cb); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, db); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { piglit_fail("Incomplete framebuffer for listed mode %u,%u,%u\n", modes[i*3], modes[i*3+1], modes[i*3+2]); } glDeleteRenderbuffers(1, &cb); glDeleteRenderbuffers(1, &db); glDeleteFramebuffers(1, &fb); piglit_check_gl_error(GL_NO_ERROR); /* Quickly test the other functions and check that * GL_RENDERBUFFER_STORAGE_SAMPLES_AMD is correct. */ glGenRenderbuffers(1, &tmp); glBindRenderbuffer(GL_RENDERBUFFER, tmp); /* Bind-to-create. */ glBindRenderbuffer(GL_RENDERBUFFER, 0); /* Unbind before glNamed*. */ glNamedRenderbufferStorageMultisampleAdvancedAMD(tmp, modes[i*3], modes[i*3+1], GL_RGBA8, 64, 64); glBindRenderbuffer(GL_RENDERBUFFER, tmp); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("color(glNamed..Advanced)", modes[i*3], modes[i*3+1]); glDeleteRenderbuffers(1, &tmp); if (modes[i*3] == modes[i*3+1]) { /* Standard MSAA. */ unsigned s = modes[i*3]; if (piglit_is_extension_supported("GL_ARB_direct_state_access")) { glGenRenderbuffers(1, &tmp); glBindRenderbuffer(GL_RENDERBUFFER, tmp); /* Bind-to-create. */ glBindRenderbuffer(GL_RENDERBUFFER, 0); /* Unbind before glNamed*. */ glNamedRenderbufferStorageMultisample(tmp, s, GL_RGBA8, 64, 64); glBindRenderbuffer(GL_RENDERBUFFER, tmp); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("color(glNamed..Multisample)", s, s); glDeleteRenderbuffers(1, &tmp); if (!tested_zero_samples) { glGenRenderbuffers(1, &tmp); glBindRenderbuffer(GL_RENDERBUFFER, tmp); /* Bind-to-create. */ glBindRenderbuffer(GL_RENDERBUFFER, 0); /* Unbind before glNamed*. */ glNamedRenderbufferStorage(tmp, GL_RGBA8, 64, 64); glBindRenderbuffer(GL_RENDERBUFFER, tmp); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("color(glNamed..Storage)", 0, 0); glDeleteRenderbuffers(1, &tmp); } } glGenRenderbuffers(1, &tmp); glBindRenderbuffer(GL_RENDERBUFFER, tmp); glRenderbufferStorageMultisample(GL_RENDERBUFFER, s, GL_RGBA8, 64, 64); validate_current_renderbuffer("color(gl..Multisample)", s, s); glDeleteRenderbuffers(1, &tmp); if (!tested_zero_samples) { glGenRenderbuffers(1, &tmp); glBindRenderbuffer(GL_RENDERBUFFER, tmp); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 64, 64); piglit_check_gl_error(GL_NO_ERROR); validate_current_renderbuffer("color(gl..Storage)", 0, 0); glDeleteRenderbuffers(1, &tmp); } tested_zero_samples = true; } } piglit_report_result(PIGLIT_PASS); }
bool hiz_run_test_depth_stencil_test_fbo(const struct hiz_fbo_options *fbo_options) { bool pass = true; GLuint fbo = 0; bool has_depth_buffer = fbo_options->depth_format || fbo_options->depth_stencil_format; bool has_stencil_buffer = fbo_options->stencil_format || fbo_options->depth_stencil_format; const float dx = piglit_width / 3.0; const float dy = piglit_height / 3.0; static const float **expected_colors = NULL; static const float *expected_colors_d1s0[9] = { hiz_grey, hiz_blue, hiz_blue, hiz_green, hiz_green, hiz_blue, hiz_green, hiz_green, hiz_grey, }; static const float *expected_colors_d0s1[9] = { hiz_grey, hiz_blue, hiz_grey, hiz_green, hiz_blue, hiz_grey, hiz_green, hiz_green, hiz_grey, }; static const float *expected_colors_d1s1[9] = { hiz_grey, hiz_blue, hiz_grey, hiz_green, hiz_green, hiz_grey, hiz_green, hiz_green, hiz_grey, }; if (has_depth_buffer && !has_stencil_buffer) expected_colors = expected_colors_d1s0; else if (!has_depth_buffer && has_stencil_buffer) expected_colors = expected_colors_d0s1; else if (has_depth_buffer && has_stencil_buffer) expected_colors = expected_colors_d1s1; piglit_require_extension("GL_ARB_framebuffer_object"); /* Create and bind FBO. */ fbo = hiz_make_fbo(fbo_options); assert(fbo != 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); /* Set up depth state. */ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glClearDepth(hiz_clear_z); /* Set up stencil state. The test for 3 < stencil with the * buffer cleared to 3 means the first primitive drawn will be * stenciled out. */ glEnable(GL_STENCIL_TEST); glClearStencil(3); /* 3 is a good canary. */ glStencilFunc(GL_LESS, 3, ~0); glStencilOp(GL_INCR, GL_INCR, GL_INCR); glClearColor(hiz_grey[0], hiz_grey[1], hiz_grey[2], hiz_grey[3]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glViewport(0, 0, piglit_width, piglit_height); piglit_ortho_projection(piglit_width, piglit_height, false); /* Draw a rect 1 on left 2/3 of the screen with clear color, * letting the next drawing there pass stencil. */ glColor4fv(hiz_grey); glDepthRange(hiz_clear_z, hiz_clear_z); piglit_draw_rect(0 * dx, 0 * dy, /* x, y */ 2 * dx, 3 * dy); /* w, h */ /* Draw rect 2. This should pass with or without stencil. */ glColor4fv(hiz_green); glDepthRange(hiz_green_z, hiz_green_z); piglit_draw_rect(0 * dx, 0 * dy, /* x, y */ 2 * dx, 2 * dy); /* w, h */ /* Draw rect 3. This should draw only the left half if stencil * is present (due to rect 1 covering only that much), and * should draw over rect 2 only if depth is not present. */ glColor4fv(hiz_blue); glDepthRange(hiz_blue_z, hiz_blue_z); piglit_draw_rect(1 * dx, 1 * dy, /* x, y */ 2 * dx, 2 * dy); /* w, h */ pass = piglit_check_gl_error(0); pass = hiz_probe_color_buffer(expected_colors) && pass; if (!piglit_automatic) { /* Blit the FBO to the window FB so we can see the results. */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); glBlitFramebuffer(0, 0, piglit_width, piglit_height, 0, 0, piglit_width, piglit_height, GL_COLOR_BUFFER_BIT, GL_NEAREST); piglit_present_results(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); } hiz_delete_fbo(fbo); return pass; }
void piglit_init(int argc, char **argv) { reshape(piglit_width, piglit_height); piglit_require_extension("GL_ARB_pixel_buffer_object"); }
void piglit_init(int argc, char **argv) { bool pass = true; GLsizei length = -5; GLint value; GLsync sync; if (piglit_get_gl_version() < 32) { piglit_require_extension("GL_ARB_sync"); } /* Create a new fence sync */ sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); /* Test initialized as fence type */ glGetSynciv(sync, GL_OBJECT_TYPE, 1, &length, &value); if (length != 1) { printf("length should be 1 but incorrectly returned: %d\n", length); pass = false; } if (value != GL_SYNC_FENCE) { printf("Expected GL_SYNC_FENCE but returned: %s\n", piglit_get_gl_enum_name(value)); pass = false; } /* Test initialized to given condition */ length = -5; glGetSynciv(sync, GL_SYNC_CONDITION, 1, &length, &value); if (length != 1) { printf("length should be 1 but incorrectly returned: %d\n", length); pass = false; } if (value != GL_SYNC_GPU_COMMANDS_COMPLETE) { printf("Expected GL_SYNC_GPU_COMMANDS_COMPLETE but returned: %s\n", piglit_get_gl_enum_name(value)); pass = false; } /* Test initialized to unsignaled */ length = -5; glGetSynciv(sync, GL_SYNC_STATUS, 1, &length, &value); if (length != 1) { printf("length should be 1 but incorrectly returned: %d\n", length); pass = false; } /* We can't test for just GL_UNSIGNALED here, since the driver * may have actually completed any previous rendering (or, in * our case, no rendering at all) already. */ if (value != GL_UNSIGNALED && value != GL_SIGNALED) { printf("Expected GL_UNSIGNALED or GL_SIGNALED but returned: %s\n", piglit_get_gl_enum_name(value)); pass = false; } /* Test initialized with given flag */ length = -5; glGetSynciv(sync, GL_SYNC_FLAGS, 1, &length, &value); if (length != 1) { printf("length should be 1 but incorrectly returned: %d\n", length); pass = false; } if (value != 0) { printf("Expected GL_SYNC_FLAGS == 0 but returned: %d\n", value); pass = false; } glDeleteSync(sync); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { bool pass = true; GLuint buffer[2]; unsigned int i; float ssbo_values[SSBO_SIZE] = {0}; float *map; int index; piglit_require_extension("GL_ARB_shader_storage_buffer_object"); piglit_require_extension("GL_ARB_program_interface_query"); prog = piglit_build_simple_program(vs_pass_thru_text, fs_source); glUseProgram(prog); glClearColor(0, 0, 0, 0); glGenBuffers(2, buffer); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, buffer[0]); glBufferData(GL_SHADER_STORAGE_BUFFER, SSBO_SIZE*sizeof(GLfloat), &ssbo_values[0], GL_DYNAMIC_DRAW); /* Change binding point */ index = glGetProgramResourceIndex(prog, GL_SHADER_STORAGE_BLOCK, "ssbo[0]"); glShaderStorageBlockBinding(prog, index, 4); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, buffer[1]); glBufferData(GL_SHADER_STORAGE_BUFFER, SSBO_SIZE*sizeof(GLfloat), &ssbo_values[0], GL_DYNAMIC_DRAW); glViewport(0, 0, piglit_width, piglit_height); piglit_draw_rect(-1, -1, 2, 2); glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer[0]); map = (float *) glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); /* Former bound buffer should not be modified */ for (i = 0; i < SSBO_SIZE; i++) { if (map[i] != 0) { printf("Wrong %d value in buffer[0]: %.2f\n", i, map[i]); pass = false; } } glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer[1]); map = (float *) glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); for (i = 0; i < SSBO_SIZE; i++) { /* Values should be below ten but different than zero */ if (map[i] == 0 || map[i] > 10) { printf("Wrong %d value in buffer[1]: %.2f\n", i, map[i]); pass = false; } } glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); if (!piglit_check_gl_error(GL_NO_ERROR)) pass = false; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { unsigned glsl_version; GLuint vs_prog_3_out; GLuint vs_prog_1_out; GLuint fs_prog_3_in; GLuint fs_prog_1_in; GLuint vs_fs_prog_separate_inactive; char *vs_source; char *fs_source; GLint max_varying; bool pass = true; piglit_require_vertex_shader(); piglit_require_fragment_shader(); piglit_require_GLSL_version(130); /* Support layout index on output color */ piglit_require_extension("GL_ARB_separate_shader_objects"); piglit_require_extension("GL_ARB_explicit_attrib_location"); piglit_require_extension("GL_ARB_blend_func_extended"); glsl_version = pick_a_glsl_version(); glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &max_varying); max_varying = (max_varying / 4u) - 1u; /* * Program compilation and link */ printf("Compile vs_prog_3_out\n"); vs_prog_3_out = format_and_link_program(GL_VERTEX_SHADER, vs_code_3_out_template, glsl_version); printf("Compile vs_prog_1_out\n"); vs_prog_1_out = format_and_link_program(GL_VERTEX_SHADER, vs_code_1_out_template, glsl_version); printf("Compile fs_prog_3_in\n"); fs_prog_3_in = format_and_link_program(GL_FRAGMENT_SHADER, fs_code_3_in_template, glsl_version); printf("Compile fs_prog_1_in\n"); fs_prog_1_in = format_and_link_program(GL_FRAGMENT_SHADER, fs_code_1_in_template, glsl_version); (void)!asprintf(&vs_source, vs_code_inactive_template, glsl_version, max_varying); (void)!asprintf(&fs_source, fs_code_inactive_template, glsl_version, max_varying); pass &= piglit_check_gl_error(0); printf("Compile vs_fs_prog_separate_inactive\n"); vs_fs_prog_separate_inactive = piglit_build_simple_program_unlinked(vs_source, fs_source); /* Manual linking so we can pack 2 separate-aware shaders into a single program */ glProgramParameteri(vs_fs_prog_separate_inactive, GL_PROGRAM_SEPARABLE, GL_TRUE); glLinkProgram(vs_fs_prog_separate_inactive); if (!piglit_link_check_status(vs_fs_prog_separate_inactive)) { piglit_report_subtest_result(PIGLIT_SKIP, "Unactive varying optimization in multi-shade separated program"); vs_fs_prog_separate_inactive = 0; // Skip program piglit_reset_gl_error(); // Clear pending error } free(vs_source); free(fs_source); /* * Pipeline creation */ glGenProgramPipelines(1, &pipeline_3_out_1_in); glGenProgramPipelines(1, &pipeline_1_out_3_in); glBindProgramPipeline(pipeline_3_out_1_in); glUseProgramStages(pipeline_3_out_1_in, GL_VERTEX_SHADER_BIT, vs_prog_3_out); glUseProgramStages(pipeline_3_out_1_in, GL_FRAGMENT_SHADER_BIT, fs_prog_1_in); glBindProgramPipeline(pipeline_1_out_3_in); glUseProgramStages(pipeline_1_out_3_in, GL_VERTEX_SHADER_BIT, vs_prog_1_out); glUseProgramStages(pipeline_1_out_3_in, GL_FRAGMENT_SHADER_BIT, fs_prog_3_in); if (vs_fs_prog_separate_inactive) { glGenProgramPipelines(1, &pipeline_inactive); glBindProgramPipeline(pipeline_inactive); glUseProgramStages(pipeline_inactive, GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT, vs_fs_prog_separate_inactive); } else { pipeline_inactive = 0; // Skip the test } if (!piglit_check_gl_error(0) || !pass) piglit_report_result(PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_EXT_framebuffer_object"); piglit_require_extension("GL_ARB_texture_cube_map"); }
void piglit_init(int argc, char **argv) { char *vsCode; char *qboFsCode; piglit_require_extension("GL_ARB_query_buffer_object"); piglit_require_extension("GL_ARB_uniform_buffer_object"); query_common_init(); glGenBuffers(1, &qbo); glBindBuffer(GL_QUERY_BUFFER, qbo); glBufferData(GL_QUERY_BUFFER, 4, NULL, GL_DYNAMIC_COPY); vsCode = "#version 150\n" "in vec4 pos_in;\n" "void main() {\n" " gl_Position = pos_in;\n" "}\n"; qboFsCode = "#version 150\n" "#extension GL_ARB_uniform_buffer_object : require\n" "uniform query {\n" " uint result;\n" " uint result_hi;\n" " uint available;\n" " uint available_hi;\n" "};\n" "uniform bool sync_mode;\n" "uniform bool expect_exact;\n" "uniform bool is_64bit;\n" "uniform uint expected;\n" "uniform uint expected_hi;\n" "out vec4 color;\n" "void main() {\n" " uint INIT = uint(0xcccccccc);\n" " bool ready = sync_mode || available != 0u;\n" " if (!is_64bit && (result_hi != INIT || available_hi != INIT)) {\n" " color = vec4(1.0, 0.0, 0.25, 1.0);\n" " } else if ((sync_mode && (available != INIT ||\n" " available_hi != INIT)) ||\n" " (!sync_mode && ((available != 0u && available != 1u) ||\n" " (is_64bit && available_hi != 0u) ||\n" " (!is_64bit && available_hi != INIT)))) {\n" " color = vec4(1.0, 0.0, 0.5, 1.0);\n" " } else {\n" " bool result_ok = false;\n" " if (result == expected &&\n" " (!is_64bit || result_hi == expected_hi))\n" " result_ok = true;\n" " if (!expect_exact &&\n" " ((!is_64bit && result >= expected) ||\n" " (is_64bit && ((result_hi == expected_hi && result >= expected) ||\n" " (result_hi > expected_hi)))))\n" " result_ok = true;\n" " if (!ready && result == INIT && result_hi == INIT)\n" " result_ok = true;\n" " if (result_ok) {\n" " color = vec4(0.0, 1.0, 0.0, 1.0);\n" " } else if (ready) {\n" " color = vec4(1.0, 0.0, 0.0, 1.0);\n" " } else {\n" " color = vec4(1.0, 0.5, 0.0, 1.0);\n" " }\n" " }\n" "}\n"; qbo_prog = piglit_build_simple_program(vsCode, qboFsCode); sync_mode_loc = glGetUniformLocation(qbo_prog, "sync_mode"); expect_exact_loc = glGetUniformLocation(qbo_prog, "expect_exact"); is_64bit_loc = glGetUniformLocation(qbo_prog, "is_64bit"); expected_loc = glGetUniformLocation(qbo_prog, "expected"); expected_hi_loc = glGetUniformLocation(qbo_prog, "expected_hi"); }