Source

GL Profile Suite / tests / interleave_arrays / suite.lua

Full commit

suite "interleave_arrays"
	desc "Determine how much better interleaved arrays perform compared to non-interleaved and multiple-buffered arrays."
	
	includes "<boost/range.hpp>"
	includes { "<sstream>", "<boost/range/irange.hpp>" }
	
	params
	{
		attribute_count = closed_range(3, 8),
		vertex_count = {25000, 50000, 100000},
	}
	
	timings {"gpu_time", "gpu_latency",}
	executions(3)
	
	variables {
		separateArrayBuffers = "gl list buffer object",
		individualArrayBuffer = "gl buffer object",
		interleavedArrayBuffers = "gl list buffer object",

		individualOffsets = "std::vector<int>",
		interleavedStrides = "std::vector<int>",
		interleavedOffsets = "std::vector<int>",

		attribSize = "std::vector<GLint>",
		attribType = "std::vector<GLenum>",
		attribNormalized = "std::vector<GLboolean>",

		programs = "gl list program",

		indexBuffer = "gl buffer object"
	}
	
	local attribute_list = dofile("attrib_data.lua")
	
	--Generate buffer storage.
	init(stmtlua("init.lua"))
	
test "arrayIndivSep"
	desc "Separate arrays, where each array is within its own buffer object."
	
	flags {--[["finish", "swap"]]}
	render_flags {"discard"}
	
	variables {
		vaos = "gl list vao",
	}
	
	init [[
vaos = util::CreateVertexArrays($attribute_count.count);
BOOST_FOREACH(int numAttribs, $attribute_count.range())
{
	glBindVertexArray(vaos[numAttribs - $attribute_count.min]);
	for(int attrib = 0; attrib < numAttribs; ++attrib)
	{
		glEnableVertexAttribArray(attrib);
		glBindBuffer(GL_ARRAY_BUFFER, suite.separateArrayBuffers[attrib]);
		glVertexAttribPointer(
			attrib,
			suite.attribSize[attrib],
			suite.attribType[attrib],
			suite.attribNormalized[attrib],
			0,
			0);
	}
}

glBindVertexArray(0);
]]

	execinit [[
glBindVertexArray(vaos[$attribute_count.index]);
glUseProgram(suite.programs[$attribute_count.index]);
]]

	exec [[glDrawArrays(GL_POINTS, 0, $vertex_count.value);
]]


	execfinal [[
glBindVertexArray(0);
glUseProgram(0);
]]