Example #1
1
void
piglit_init(int argc, char **argv)
{
	static const char *vs_source =
		"#version 150\n"
		"in vec4 piglit_vertex;\n"
		"void main()\n"
		"{\n"
		"	gl_Position = piglit_vertex;\n"
		"}\n";

	static const char *fs_source =
		"#version 150\n"
		"#extension GL_ARB_gpu_shader5: require\n"
		"uniform samplerBuffer s[2];\n"
		"uniform int offset;\n"
		"uniform int index = 1;\n"
		"void main()\n"
		"{\n"
		"	gl_FragColor = texelFetch(s[index], offset);\n"
		"}\n";

	GLuint tex[2], tbo[2];
	GLint indices[2] = { 0, 1 };
	static const uint8_t datag[4] = {0x00, 0xff, 0x00, 0x00};
	static const uint8_t datar[4] = {0xff, 0x00, 0x00, 0x00};
	GLuint prog;
	GLint size = 4;
	piglit_require_extension("GL_ARB_gpu_shader5");

	prog = piglit_build_simple_program(vs_source, fs_source);
	glUseProgram(prog);

	glGenBuffers(2, tbo);
	glGenTextures(2, tex);
	glBindBuffer(GL_TEXTURE_BUFFER, tbo[0]);
	glBindTexture(GL_TEXTURE_BUFFER, tex[0]);
	glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo[0]);
	glBufferData(GL_TEXTURE_BUFFER,
		     size * sizeof(datar), NULL, GL_STATIC_READ);
	glBufferSubData(GL_TEXTURE_BUFFER,
			(size - 1) * sizeof(datar), sizeof(datar), datar);

	glActiveTexture(GL_TEXTURE1);
	glBindBuffer(GL_TEXTURE_BUFFER, tbo[1]);
	glBindTexture(GL_TEXTURE_BUFFER, tex[1]);
	glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo[1]);
	glBufferData(GL_TEXTURE_BUFFER,
		     size * sizeof(datag), NULL, GL_STATIC_READ);
	glBufferSubData(GL_TEXTURE_BUFFER,
			(size - 1) * sizeof(datag), sizeof(datag), datag);

	glUniform1i(glGetUniformLocation(prog, "offset"), size - 1);
	glUniform1iv(glGetUniformLocation(prog, "s"), 2, indices);
}
Example #2
0
void
piglit_init(int argc, char **argv)
{
	piglit_require_extension("GL_EXT_texture_norm16");

	prog = piglit_build_simple_program(vs_source, fs_source);

	if (piglit_is_extension_supported("GL_OES_texture_buffer"))
		buf_prog = piglit_build_simple_program(vs_source,
						       fs_buf_source);
}
void
piglit_init(int argc, char **argv)
{
	GLuint prog = piglit_build_simple_program(
		"#version 140\n"
		"const vec2 verts[4] = vec2[](\n"
		"	vec2(-1, 1),\n"
		"	vec2(-1,-1),\n"
		"	vec2( 1,-1),\n"
		"	vec2( 1, 1)\n"
		");\n"
		"void main() {\n"
		"	gl_Position = vec4(verts[gl_VertexID], 0, 1);\n"
		"}\n",

		"#version 140\n"
		"void main() {\n"
		"	gl_FragColor = vec4(1,0,0,1);\n"
		"}\n");

	GLuint vao;

	glUseProgram(prog);

	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);
}
Example #4
0
void
piglit_init(int argc, char **argv)
{
   GLuint Texture;

   piglit_require_extension("GL_ARB_texture_float");
   piglit_require_extension("GL_ARB_fragment_shader");

   HaveRG = piglit_is_extension_supported("GL_ARB_texture_rg");

   Program = piglit_build_simple_program(NULL, FragShaderText);

   glUseProgram(Program);

   BiasUniform = glGetUniformLocation(Program, "bias");
   ScaleUniform = glGetUniformLocation(Program, "scale");
   TexUniform = glGetUniformLocation(Program, "tex");

   glUniform1f(BiasUniform, Bias);
   glUniform1f(ScaleUniform, Scale);
   glUniform1i(TexUniform, 0);  /* tex unit zero */

   (void) check_error(__FILE__, __LINE__);

   glGenTextures(1, &Texture);
   glBindTexture(GL_TEXTURE_2D, Texture);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

   piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
}
Example #5
0
void
piglit_init(int argc, char **argv)
{
	GLuint prog, i;

	piglit_require_extension("GL_ARB_explicit_attrib_location");
	piglit_require_extension("GL_ARB_explicit_uniform_location");

	prog = piglit_build_simple_program(vs_text, fs_text);

	/* verify that locations are sequential */
	for (i = 0; i < 16; i++) {
		char *element;
		if (asprintf(&element, "a[%d]", i) == -1)
			piglit_report_result(PIGLIT_FAIL);

		if (glGetUniformLocation(prog, element) != 3 + i)
			piglit_report_result(PIGLIT_FAIL);

		free(element);
	}

	glDeleteProgram(prog);
	piglit_report_result(PIGLIT_PASS);
}
Example #6
0
void
piglit_init(int argc, char **argv)
{
    GLuint buf;
    GLint vertex;

    piglit_require_gl_version(20);

    prog = piglit_build_simple_program(vs, fs);
    if (!prog) {
        printf("Failed to compile/link program\n");
        piglit_report_result(PIGLIT_FAIL);
    }

    glUseProgram(prog);

    attr = glGetAttribLocation(prog, "attr");
    vertex = glGetAttribLocation(prog, "vertex");

    glGenBuffers(1, &buf);
    glBindBuffer(GL_ARRAY_BUFFER, buf);
    glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
    glVertexAttribPointer(vertex,
                          2, GL_FLOAT, GL_FALSE, 0, 0);

    glEnableVertexAttribArray(vertex);
}
Example #7
0
void
piglit_init(int argc, char **argv)
{
    piglit_require_GLSL();
    piglit_require_extension("GL_ARB_instanced_arrays");

    Program = piglit_build_simple_program(VertShaderText, FragShaderText);

    glUseProgram(Program);

    PosAttrib = glGetAttribLocation(Program, "Pos");
    ColorAttrib = glGetAttribLocation(Program, "Color");

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-5, 5, -5, 5, 10, 20);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0, 0, -11.0);
    glScalef(0.5, 0.5, 1.0);

    if ((argc >= 2) && (strcmp(argv[1], "vbo") == 0)) {
        use_vbo = GL_TRUE;
    }
}
void
piglit_init(int argc, char *argv[])
{
	GLuint prog, array, buf;

	glGenVertexArrays(1, &array);
	glBindVertexArray(array);
	glGenBuffers(1, &buf);
	glBindBuffer(GL_ARRAY_BUFFER, buf);

	prog = piglit_build_simple_program(vs_src, fs_src);

	glVertexAttribPointer(0, /* index */
			      4, /* size */
			      GL_FLOAT, /* type */
			      GL_FALSE, /* normalized */
			      0, /* stride */
			      NULL /* pointer */);
	glEnableVertexAttribArray(0);

#ifndef DISPLAY
	glEnable(GL_RASTERIZER_DISCARD);
#endif

	do_query_init(queries, ARRAY_SIZE(queries));

	if (!piglit_link_check_status(prog)) {
		glDeleteProgram(prog);
		piglit_report_result(PIGLIT_FAIL);
	}

	glUseProgram(prog);
}
Example #9
0
static void
create_program(struct program *program, const char *type)
{
	char *fs_source, *vs_source;
	GLuint prog;
	char *threshold;

	if (strcmp(type, "") == 0)
		threshold = "vec4(0.02)";
	else
		threshold = "ivec4(1)";

	if (test_vs) {
		asprintf(&vs_source, vs_vert_source, type, type, type, type,
			 threshold);
		fs_source = fs_vert_source;
	} else {
		vs_source = vs_frag_source;
		asprintf(&fs_source, fs_frag_source, type, type, type, type,
			 threshold);
	}

	prog = piglit_build_simple_program(vs_source, fs_source);

	program->prog = prog;
        program->pos_location = glGetUniformLocation(prog, "pos");
        program->expected_location = glGetUniformLocation(prog,
							       "expected");
	vertex_location = glGetAttribLocation(prog, "vertex");
	assert(vertex_location == 0);
}
Example #10
0
void
piglit_init(int argc, char **argv)
{
    /* Create the shaders */
    prog = piglit_build_simple_program(vs_text, fs_text);

    /* Create the multisampled framebuffer */
    glGenFramebuffers(1, &fbo);
    glGenRenderbuffers(1, &rb);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
    glBindRenderbuffer(GL_RENDERBUFFER, rb);
    glRenderbufferStorageMultisample(GL_RENDERBUFFER,
                                     4 /* samples */,
                                     GL_RGBA8 /* internalformat */,
                                     piglit_width, piglit_height);
    glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                              GL_RENDERBUFFER, rb);
    if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)
            != GL_FRAMEBUFFER_COMPLETE) {
        printf("Framebuffer incomplete\n");
        piglit_report_result(PIGLIT_FAIL);
    }

    if (!piglit_check_gl_error(GL_NO_ERROR))
        piglit_report_result(PIGLIT_FAIL);
}
void
piglit_init(int argc, char **argv)
{
	bool pass = true;

	GLint prog = 0;

	GLint active_attribs = 0;
	GLint max_length = 0;

	piglit_require_GLSL_version(150);

	prog = piglit_build_simple_program(vs_source, fs_source);
	glUseProgram(prog);

	glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTES, &active_attribs);
	glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_length);

	/*
	 * Check the size of the given attribute with the
	 * corresponding expected array size.
	 */
	pass = getAttribLocTest(prog, active_attribs, max_length, "a", 1) && pass;
	pass = getAttribLocTest(prog, active_attribs, max_length, "b", 2) && pass;
	pass = getAttribLocTest(prog, active_attribs, max_length, "c", 3) && pass;
	pass = getAttribLocTest(prog, active_attribs, max_length, "d", 4) && pass;
	pass = getAttribLocTest(prog, active_attribs, max_length, "e", 5) && pass;

	glDeleteProgram(prog);

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
void
piglit_init(int argc, char **argv)
{
	GLuint vertIndex;

#ifdef PIGLIT_USE_OPENGL
	piglit_require_extension("GL_ARB_base_instance");
#else
	piglit_require_extension("GL_EXT_base_instance");
#endif

	prog = piglit_build_simple_program(vstext, fstext);

	glUseProgram(prog);

	glGenBuffers(1, &vertBuff);
	glBindBuffer(GL_ARRAY_BUFFER, vertBuff);
	glBufferData(GL_ARRAY_BUFFER, vertSize, vertices, GL_STATIC_DRAW);

	glGenBuffers(1, &indexBuf);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, indSize,
			indices, GL_STATIC_DRAW);

	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);

	vertIndex = glGetAttribLocation(prog, "vertex");

	glBindBuffer(GL_ARRAY_BUFFER, vertBuff);
	glEnableVertexAttribArray(vertIndex);
	glVertexAttribPointer(vertIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
Example #13
0
static bool
try_140_test()
{
	bool pass = true;
	GLint idx;
	GLint binding;

	prog140 = piglit_build_simple_program(vert140_source, frag140_source);

	idx = glGetUniformBlockIndex(prog140, "U");
	if (idx == -1) {
		printf("Failed to get index for \"U\"\n");
		pass = false;
	}

	glGetActiveUniformBlockiv(prog140, idx, GL_UNIFORM_BLOCK_BINDING,
				  &binding);
	if (binding != 2) {
		printf("Expected block binding = 2, got %d\n", binding);
		pass = false;
	}

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	return pass;
}
Example #14
0
static bool
try_150_test()
{
	bool pass = true;
	GLint idx;
	GLint binding;
	unsigned i;

	prog150 = piglit_build_simple_program(vert150_source, frag150_source);

	for (i = 0; i < 2; i++) {
		char name[5] = "U[0]";

		name[2] = '0' + i;

		idx = glGetUniformBlockIndex(prog150, name);
		if (idx == -1) {
			printf("Failed to get index for \"%s\"\n", name);
			pass = false;
		}

		glGetActiveUniformBlockiv(prog150, idx,
					  GL_UNIFORM_BLOCK_BINDING, &binding);
		if (binding != (3 + i)) {
			printf("Expected block binding = %d, got %d\n",
			       3 + i, binding);
			pass = false;
		}
	}

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

	return pass;
}
void piglit_init(int argc, char **argv)
{
	int i;

	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_extension("GL_ARB_texture_storage");
	piglit_require_GLSL_version(120);

	format = GL_RGBA8;

	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "RGB9_E5") == 0) {
			/* Test a non-renderable format. */
			piglit_require_extension("GL_EXT_texture_shared_exponent");
			format = GL_RGB9_E5;
		}
		else {
			assert(0);
		}
	}

	prog = piglit_build_simple_program(NULL, fs_3d);

	glClearColor(0.25, 0.25, 0.25, 0.25);
}
void
piglit_init(int argc, char **argv)
{
	enum piglit_result result;
	GLuint render_program;
	int i;
	float green[4] = { 0.0, 1.0, 0.0, 1.0 };

	cs_ids_common_init();
	cs_ids_set_local_id_test();
	cs_ids_set_local_size(4, 4, 4);
	cs_ids_set_global_size(4, 4, 4);

	render_program =
		piglit_build_simple_program(passthrough_vs_src,
					    green_fs_src);
	glClearColor(0.0, 0.0, 0.0, 0.0);

	for (i = 0; i < 2; i++) {
		result = cs_ids_run_test();
		if (result != PIGLIT_PASS)
			piglit_report_result(result);

		glUseProgram(render_program);
		glClear(GL_COLOR_BUFFER_BIT);
		piglit_draw_rect(-1, -1, 2, 2);
		result = piglit_probe_rect_rgba(0, 0, piglit_width,
						piglit_height, green)
			? PIGLIT_PASS : PIGLIT_FAIL;
	}

	cs_ids_common_destroy();

	piglit_report_result(result);
}
Example #17
0
void
piglit_init(int argc, char **argv)
{
	bool pass = true;
	unsigned int i;
	GLuint prog;

	piglit_require_extension("GL_ARB_uniform_buffer_object");
	prog = piglit_build_simple_program(NULL, source);

	for (i = 0; i < ARRAY_SIZE(uniforms); i++) {
		GLuint index;
		GLint row_major;

		glGetUniformIndices(prog, 1, &uniforms[i].name, &index);
		if (index == GL_INVALID_INDEX) {
			printf("Failed to get index for %s\n",
			       uniforms[i].name);
			pass = false;
			continue;
		}

		glGetActiveUniformsiv(prog, 1, &index, GL_UNIFORM_IS_ROW_MAJOR,
				      &row_major);

		if (row_major != uniforms[i].row_major) {
			fprintf(stderr, "Uniform %s should %sbe row major\n",
				uniforms[i].name,
				uniforms[i].row_major ? "" : "not ");
			pass = false;
		}
	}

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Example #18
0
void
piglit_init(int argc, char **argv)
{
	int i;
	GLint program[2];
	bool pass = true;

	float expected[] = {
		0.0, 1.0, 0.0,
		0.0, 0.0, 0.0
	};

	program[0] = piglit_build_simple_program_multiple_shaders(
						GL_VERTEX_SHADER,   vs_source,
						GL_GEOMETRY_SHADER, gs_source,
						GL_FRAGMENT_SHADER, fs_source,
						0);

	program[1] = piglit_build_simple_program(vs_source, fs_source);

	for( i = 0; i < 2; i++) {
		pass = test_gl_layer(program[i], 2, expected) && pass;
	}

	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Example #19
0
static void
setup_shaders(void)
{
    static const char *vsSrc =
        "#version 150\n"
        "in vec4 Attr0;"
        "in vec4 Attr1;"
        "smooth out vec4 fs_color0;"
        "void main(void) {"
        "   gl_Position = Attr0;"
        "   fs_color0 = Attr1;"
        "}";
    static const char *fsSrc =
        "#version 150\n"
        "smooth in vec4 fs_color0;"
        "out vec4 fragColor0;"
        "void main(void) {"
        "   vec2 psCoords = gl_PointCoord;"
        "   fragColor0 = fs_color0;"
        "}";

    prog = piglit_build_simple_program(vsSrc, fsSrc);
    glBindFragDataLocation(prog, 0, "fragColor0");
    glLinkProgram(prog);
    glUseProgram(prog);
}
Example #20
0
static GLuint
make_program(void)
{
	const char *snippet = sample_function->snippet;
	int glsl_version = sample_function->glsl_version;
	int snippet_length = strlen(snippet);
	int snippet_pos = strstr(fragment_source, "SNIPPET") - fragment_source;
	GLuint program;
	char source[1000], *p = source;

	if (glsl_version > 0) {
		p += sprintf(p, "#version %i\n", glsl_version);
		piglit_require_GLSL_version(glsl_version);
	}

	if (sample_function->extension) {
		p += sprintf(p,
			     "#extension %s : require\n",
			     sample_function->extension);
		piglit_require_extension(sample_function->extension);
	}

	memcpy(p, fragment_source, snippet_pos);
	p += snippet_pos;
	memcpy(p, snippet, snippet_length);
	p += snippet_length;
	memcpy(p,
	       fragment_source + snippet_pos + 7,
	       sizeof fragment_source - snippet_pos - 7);

	program = piglit_build_simple_program(vertex_source, source);

	return program;
}
Example #21
0
void
piglit_init(int argc, char **argv)
{
	char *vsCode;
	char *fsCode;

	piglit_require_extension("GL_ARB_texture_storage");
	piglit_require_extension("GL_ARB_texture_view");
	piglit_require_extension("GL_EXT_texture_array");

	/* setup shaders and program object for 2DArray rendering */
	asprintf(&vsCode,
		 "void main()\n"
		 "{\n"
		 "    gl_Position = gl_Vertex;\n"
		 "    gl_TexCoord[0] = gl_MultiTexCoord0;\n"
		 "}\n");
	asprintf(&fsCode,
		 "#extension GL_EXT_texture_array : enable\n"
		 "uniform sampler2DArray tex;\n"
		 "void main()\n"
		 "{\n"
		 "   vec4 color  = texture2DArray(tex, gl_TexCoord[0].xyz);\n"
		 "   gl_FragColor = vec4(color.xyz, 1.0);\n"
		 "}\n");
	prog2Darray = piglit_build_simple_program(vsCode, fsCode);
	free(fsCode);
	free(vsCode);
	tex_loc_2Darray = glGetUniformLocation(prog2Darray, "tex");

}
Example #22
0
void
piglit_init(int argc, char **argv)
{
	int maxloc;
	GLuint prog;
	char *f_sha;

	piglit_require_extension("GL_ARB_explicit_uniform_location");

	glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	/* test GL_MAX_UNIFORM_LOCATIONS - 1, 0, and a loc in between (1) */
	if (asprintf(&f_sha, fs_template, maxloc - 1, 0, 1) == -1)
		piglit_report_result(PIGLIT_FAIL);

	prog = piglit_build_simple_program(vs_text, f_sha);

	free(f_sha);

	if (glGetUniformLocation(prog, "r") != maxloc - 1)
		piglit_report_result(PIGLIT_FAIL);
	if (glGetUniformLocation(prog, "g") != 0)
		piglit_report_result(PIGLIT_FAIL);
	if (glGetUniformLocation(prog, "b") != 1)
		piglit_report_result(PIGLIT_FAIL);

	glDeleteProgram(prog);
	piglit_report_result(PIGLIT_PASS);
}
Example #23
0
File: drawid.c Project: rib/piglit
void
piglit_init(int argc, char **argv)
{
	GLuint prog;
	char *vs_text;

	if (strcmp(argv[1], "drawid") == 0) {
		(void)!asprintf(&vs_text, vs_template,
			 "ref.x == gl_DrawIDARB");
	} else if (strcmp(argv[1], "vertexid") == 0) {
		(void)!asprintf(&vs_text, vs_template,
			 "ref.x == gl_DrawIDARB && ref.y == gl_VertexID");
	} else {
                printf("Unknown subtest: %s\n", argv[1]);
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_require_GLSL_version(130);

	piglit_require_extension("GL_ARB_shader_draw_parameters");
	piglit_require_extension("GL_ARB_base_instance");

	prog = piglit_build_simple_program(vs_text, fs_text);

	glUseProgram(prog);
}
static bool
test_format(const struct uniform_type *type, bool row_major)
{
	/* Using 140 to get unsigned ints. */
	const char *fs_template =
		"#version 140\n"
		"layout(std140) uniform ubo {\n"
		"	float align_test;\n"
		"	%s%s u;\n"
		"};\n"
		"\n"
		"void main() {\n"
		"	gl_FragColor = vec4(align_test);\n"
		"}\n";
	char *fs_source;
	GLuint prog;
	GLint data_size;
	int expected;
	const struct uniform_type *transposed_type;

	if (row_major)
		transposed_type = get_transposed_type(type);
	else
		transposed_type = type;

	(void)!asprintf(&fs_source, fs_template,
		 row_major ? "layout(row_major) " : "",
		 type->type);
	prog = piglit_build_simple_program(NULL, fs_source);
	free(fs_source);

	/* There's only one block, so it's uniform block 0. */
	glGetActiveUniformBlockiv(prog, 0,
				  GL_UNIFORM_BLOCK_DATA_SIZE,
				  &data_size);

	glDeleteProgram(prog);

	/* "align_test" at the start of the UBO is a float, so our
	 * test uniform would start at byte 4 if not for alignment.
	 */
	expected = 4;

	/* The actual space for our object. */
	expected = align(expected, transposed_type->alignment);
	expected += transposed_type->size;

	/* Finally, align to a vec4 like std140 says. */
	expected = align(expected, 16);

	printf("%-20s %10s %10d %10d%s\n",
	       type->type,
	       row_major ? "y" : "n",
	       data_size,
	       expected,
	       data_size == expected ? "" : " FAIL");

	return data_size == expected;
}
Example #25
0
PIGLIT_GL_TEST_CONFIG_END

enum piglit_result
piglit_display(void)
{
	static const char *vs_source =
		"#version 140\n"
		"in vec4 piglit_vertex;\n"
		"void main()\n"
		"{\n"
		"	gl_Position = piglit_vertex;\n"
		"}\n";

	static const char *fs_source =
		"#version 140\n"
		"uniform samplerBuffer s;\n"
		"void main()\n"
		"{\n"
		"	gl_FragColor = texelFetch(s, 0);\n"
		"}\n";

	bool pass = true;
	GLuint tex, bo;
	GLuint prog;
	float green[] = {0, 1, 0, 0};
	float blue[] =  {0, 0, 1, 0};
	uint8_t g_rgba8[] = {0x00, 0xff, 0x00, 0x00};
	uint8_t b_rgba8[] = {0x00, 0x00, 0xff, 0x00};

	prog = piglit_build_simple_program(vs_source, fs_source);
	glUseProgram(prog);

	glGenBuffers(1, &bo);
	glBindBuffer(GL_TEXTURE_BUFFER, bo);
	/* Make the buffer bigger than the data to trigger the driver
	 * code path we want.
	 */
	glBufferData(GL_TEXTURE_BUFFER, 4096, NULL, GL_STREAM_DRAW);
	glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(g_rgba8), g_rgba8);

	glGenTextures(1, &tex);
	glBindTexture(GL_TEXTURE_BUFFER, tex);
	glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, bo);

	piglit_draw_rect(-1, -1, 1, 2);
	glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(b_rgba8), b_rgba8);
	piglit_draw_rect(0, -1, 1, 2);

	pass = pass && piglit_probe_rect_rgba(0, 0,
					      piglit_width / 2, piglit_height,
					      green);
	pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0,
					      piglit_width / 2, piglit_height,
					      blue);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Example #26
0
void
piglit_init(int argc, char **argv)
{
	piglit_require_extension("GL_ARB_framebuffer_object");
	piglit_require_gl_version(20);

	Program = piglit_build_simple_program(NULL, fragShaderText);
	assert(Program);
}
void
piglit_init(int argc, char **argv)
{
	piglit_require_GLSL_version(130);

	glGenFramebuffers(1, &fbo);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);

	glGenTextures(1, &color0);
	glBindTexture(GL_TEXTURE_2D, color0);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color0, 0);

	glGenTextures(1, &color1);
	glBindTexture(GL_TEXTURE_2D, color1);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, color1, 0);

	glGenTextures(1, &color2);
	glBindTexture(GL_TEXTURE_2D, color2);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, color2, 0);

	glDrawBuffers(3, buffers);

	prog = piglit_build_simple_program(
		"#version 130\n"
		"in vec4 pos;\n"
		"void main() {\n"
		"	gl_Position = pos;\n"
		"}\n",

		"#version 130\n"
		"void main() {\n"
		"	float alpha = float(int(gl_FragCoord.x / 16 + gl_FragCoord.y / 16) % 2);\n"
		"	/*Don't write color to draw buffer zero i.e. gl_FragData[0] */\n"
		"	gl_FragData[1] = vec4(1.0, 0.0, 0.0, alpha);\n"
		"	gl_FragData[2] = vec4(0.0, 1.0, 0.0, 1.0);\n"
		"}\n"
		);

	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("Setup for test failed.\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
		printf("Framebuffer not complete.\n");
		piglit_report_result(PIGLIT_SKIP);
	}
}
Example #28
0
void
piglit_init(int argc, char **argv)
{
	GLuint prog;

	prog = piglit_build_simple_program(vs_source, fs_source);
	glUseProgram(prog);
	color_index = glGetAttribLocation(prog, "in_color");
}
Example #29
0
void
piglit_init(int argc, char **argv)
{
	piglit_require_gl_version(30);
	piglit_require_GLSL();
	piglit_require_GLSL_version(130);
	piglit_require_extension("GL_ARB_cull_distance");
	prog = piglit_build_simple_program(vert, frag);
	glUseProgram(prog);
}
Example #30
0
void
piglit_init(int argc, char **argv)
{
	GLuint prog;

	piglit_require_extension("GL_ARB_draw_instanced");

	prog = piglit_build_simple_program(vs_source, fs_source);

	glUseProgram(prog);
}