GL Profile Suite / tests / generate.lua

alfonse d862a85 














Jason McKesson 38affaf 







alfonse eca81cf 
Jason McKesson a947be4 
alfonse eca81cf 









Jason McKesson a947be4 











Jason McKesson df613ff 



alfonse d862a85 













Jason McKesson a947be4 
alfonse d862a85 
Jason McKesson 38affaf 
alfonse d862a85 
























alfonse eca81cf 




































Jason McKesson a947be4 









































































alfonse d862a85 
local gen = {}

function gen.GetMainFilename(suiteName)
	return suiteName .. "_codegen.cpp"
end

function gen.GetSuiteClassname(suiteName)
	return suiteName .. "_suite"
end

function gen.GetTestClassname(testName)
	return testName .. "_test"
end

function gen.GetParamArrayVarname(paramName)
	return "g_" .. paramName .. "_array"
end

function gen.GetParamDefVarname(paramName)
	return "g_" .. paramName .. "_def"
end

function gen.GetParamArgVarname()
	return "test_parameters"
end

function gen.GetParamArgDef()
	return "const ParamValue *" .. gen.GetParamArgVarname()
end

function gen.GetParamValueVarname(paramIndex)
	return string.format("%s[%i]", gen.GetParamArgVarname(), paramIndex)
end

function gen.GetExecuteFuncName()
	return "Execute"
end

function gen.GetSuiteFuncParam(suite)
	return "const " .. gen.GetSuiteClassname(suite.name) .. " &suite"
end

function gen.GetTestingFuncName()
	return "test_display"
end

function gen.GetCmdOptionDef()
	return "util::CommandLineOptions g_test_options;"
end

function gen.WritePreamble(hFile, suite_name)
	hFile:write([=[
	/* Here's some preamble text. */
	/* Here's some preamble text. */
	/* Here's some preamble text. */
	/******************************/
]=])
end

function gen.GetStandardIncludes()
	return {
		"<vector>",
		"<iostream>",
		"<fstream>",
		"<boost/container/vector.hpp>",
		"<boost/range/irange.hpp>",
		"<boost/range/iterator_range.hpp>",
		"<boost/foreach.hpp>",
	}
end

function gen.GetOpenGLIncludes(majorVersion, minorVersion, bCompatibility)
	local mainGLFuncName =
		string.format("<glload/gl_%i_%i%s.h>",
			majorVersion,
			minorVersion, 
			iif(bCompatibility, "_comp", ""))

	return {
		mainGLFuncName,
		"<glload/gll.hpp>",
		"<glutil/Shader.h>",
		[["../util/util.h"]],
	}
end

function gen.GetFreeglutIncludes()
	return {
		"<GL/freeglut.h>",
	}
end

function gen.GetParamDefStructDefinition()
	return[[
struct ParamDefinition
{
	int min;
	int max;
	int count;
	const int *values;
	
	boost::iterator_range<const int *> range() const {return boost::iterator_range<const int *>(values, values + count);}
};]]
end

function gen.GetParamValueStructDefinition()
	return[[
struct ParamValue
{
	int min;
	int max;
	int count;
	const int *values;
	int index;
	int value;
	
	boost::iterator_range<const int *> range() const {return boost::iterator_range<const int *>(values, values + count);}
	
	ParamValue(const ParamDefinition &def, int index)
		: min(def.min)
		, max(def.max)
		, count(def.count)
		, values(def.values)
		, index(index)
		, value(def.values[index])
		{}
};]]
end

--GPU timing.
gen.gpu_time =
{}

function gen.gpu_time.init()
	return [[
		GLuint test_gpu_time_query = util::CreateQuery();
]]
end

function gen.gpu_time.start()
	return [[
		glBeginQuery(GL_TIME_ELAPSED, test_gpu_time_query);
]]
end

function gen.gpu_time.stop()
	return [[
		glEndQuery(GL_TIME_ELAPSED);
]]
end

function gen.gpu_time.record()
	return [[
		{
			GLuint64 elapsedTime;
			glGetQueryObjectui64v(test_gpu_time_query, GL_QUERY_RESULT, &elapsedTime);

			datum.SetValue(util::DATUM_GPU_ELAPSED, double(elapsedTime) / 1000000.0);
		}
]]
end

function gen.gpu_time.final()
	return [[
		glDeleteQueries(1, &test_gpu_time_query);
]]
end

--GPU latency.
gen.gpu_latency =
{}

function gen.gpu_latency.init()
	return [[
		GLuint test_gpu_latency_query = util::CreateQuery();
]]
end

function gen.gpu_latency.stop()
	return [[
		glQueryCounter(test_gpu_latency_query, GL_TIMESTAMP);
		GLint64 test_issue_time;
		glGetInteger64v(GL_TIMESTAMP, &test_issue_time);
]]
end

function gen.gpu_latency.record()
	return [[
		{
			GLuint64 complete_time;
			glGetQueryObjectui64v(test_gpu_latency_query, GL_QUERY_RESULT, &complete_time);

			datum.SetValue(util::DATUM_GPU_LATENCY, double(complete_time - test_issue_time) / 1000000.0);
		}
]]
end

function gen.gpu_latency.final()
	return [[
		glDeleteQueries(1, &test_gpu_latency_query);
]]
end

return gen
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.