Browse Source

Nothing important

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
07105502fd

+ 15 - 0
docs/todo

@@ -1,3 +1,18 @@
+
+=======
+Pending
+=======
+
+- For the main renderer dont use final stage. Just make PPS to write to the FB
+  Maybe though do that only when the rendering quality is 1.0 else you will have
+  more blending ops to do
+- Interleaved geometry
+- See if you can have 2 FAIs instead of 3 on SSAO and HDR
+
+====
+Done
+====
+
 - Put uniform buffers everywhere
 - Move to GLES3
 	- Remove all boost

+ 8 - 5
include/anki/gl/ShaderProgram.h

@@ -311,11 +311,12 @@ public:
 
 	ShaderProgram(const char* vertSource, const char* tcSource, 
 		const char* teSource, const char* geomSource, const char* fragSource,
-		const char* transformFeedbackVaryings[])
+		const char* transformFeedbackVaryings[],
+		const GLenum xfbBufferMode = GL_SEPARATE_ATTRIBS)
 	{
 		init();
 		create(vertSource, tcSource, teSource, geomSource, fragSource,
-			transformFeedbackVaryings);
+			transformFeedbackVaryings, xfbBufferMode);
 	}
 
 	~ShaderProgram()
@@ -352,11 +353,13 @@ public:
 	/// @param teSource Tessellation evaluation shader source. Can be nullptr
 	/// @param geomSource Geometry shader source. Can be nullptr
 	/// @param fragSource Fragment shader source. Can be nullptr
-	/// @param transformFeedbackVaryings An array of varyings names. Eg 
-	///                                  {"var0", "var1", nullptr} or {nullptr}
+	/// @param xfbVaryings An array of varyings names. Eg 
+	///                    {"var0", "var1", nullptr}. Can be nullptr
+	/// @param xfbBufferMode GL_SEPARATE_ATTRIBS or GL_INTERLEAVED_ATTRIBS
 	void create(const char* vertSource, const char* tcSource, 
 		const char* teSource, const char* geomSource, const char* fragSource,
-		const char* transformFeedbackVaryings[]);
+		const char* xfbVaryings[], 
+		const GLenum xfbBufferMode = GL_SEPARATE_ATTRIBS);
 
 	/// Bind the shader program
 	void bind() const

+ 15 - 1
include/anki/resource/ShaderProgramPrePreprocessor.h

@@ -22,12 +22,20 @@ namespace anki {
 /// - #pragma anki start <vertexShader | tcShader | teShader |
 ///                       geometryShader | fragmentShader>
 /// - #pragma anki include "<filename>"
-/// - #pragma anki transformFeedbackVarying <varName>
+/// - #pragma anki transformFeedbackVaryings <separate|interleaved>
+///   <varName> <varName>
 ///
 /// @note The order of the "#pragma anki start" is important
 class ShaderProgramPrePreprocessor
 {
 public:
+	enum XfbBufferMode
+	{
+		XFBBM_NONE,
+		XFBBM_INTERLEAVED,
+		XFBBM_SEPARATE
+	};
+
 	/// It loads a file and parses it
 	/// @param[in] filename The file to load
 	/// @exception Exception
@@ -51,6 +59,11 @@ public:
 	{
 		return shaderSources[type];
 	}
+
+	XfbBufferMode getXfbBufferMode() const
+	{
+		return xfbBufferMode;
+	}
 	/// @}
 
 protected:
@@ -70,6 +83,7 @@ protected:
 
 	/// Names and and ids for transform feedback varyings
 	StringList trffbVaryings;
+	XfbBufferMode xfbBufferMode = XFBBM_NONE;
 	Array<std::string, ST_NUM> shaderSources;
 
 	/// The parseFileForPragmas fills this

+ 10 - 8
src/gl/ShaderProgram.cpp

@@ -303,7 +303,7 @@ thread_local const ShaderProgram* ShaderProgram::current = nullptr;
 //==============================================================================
 void ShaderProgram::create(const char* vertSource, const char* tcSource, 
 	const char* teSource, const char* geomSource, const char* fragSource,
-	const char* transformFeedbackVaryings[])
+	const char* xfbVaryings[], const GLenum xfbBufferMode)
 {
 	ANKI_ASSERT(!isCreated());
 	U32 minor = GlStateCommonSingleton::get().getMinorVersion();
@@ -396,12 +396,14 @@ void ShaderProgram::create(const char* vertSource, const char* tcSource,
 		glAttachShader(glId, geomShaderGlId);
 	}
 
-	// 3) set the TRFFB varyings
-	ANKI_ASSERT(transformFeedbackVaryings != nullptr);
-	int count = 0;
-	while(transformFeedbackVaryings[count] != nullptr)
+	// 3) set the XFB varyings
+	U count = 0;
+	if(xfbVaryings)
 	{
-		++count;
+		while(xfbVaryings[count] != nullptr)
+		{
+			++count;
+		}
 	}
 
 	if(count)
@@ -409,8 +411,8 @@ void ShaderProgram::create(const char* vertSource, const char* tcSource,
 		glTransformFeedbackVaryings(
 			glId,
 			count, 
-			transformFeedbackVaryings,
-			GL_SEPARATE_ATTRIBS);
+			xfbVaryings,
+			xfbBufferMode);
 	}
 
 	// 4) link

+ 1 - 0
src/renderer/Pps.cpp

@@ -63,6 +63,7 @@ void Pps::init(const Renderer::Initializer& initializer)
 //==============================================================================
 void Pps::run()
 {
+	// First SSAO because it depends on MS where HDR depends on IS
 	if(ssao.getEnabled())
 	{
 		ssao.run();

+ 1 - 1
src/renderer/Tiler.cpp

@@ -173,12 +173,12 @@ void Tiler::updateTiles(Camera& cam, const Texture& depthMap)
 	//
 	// In the meantime update the 4 planes for all the tiles
 	//
+	fbo.bind(); // Flush prev FBO on Mali
 	update4Planes(cam);
 
 	//
 	// Issue the min/max draw call
 	//
-	fbo.bind();
 	prog->bind();
 	GlStateSingleton::get().setViewport(0, 0, TILES_X_COUNT, TILES_Y_COUNT);
 	prog->findUniformVariable("depthMap").set(depthMap);

+ 25 - 2
src/resource/ShaderProgramPrePreprocessor.cpp

@@ -12,14 +12,15 @@ namespace anki {
 
 // Keep the strings in that order so that the start pragmas will match to the
 // ShaderType enums
-static Array<const char*, 7> commands = {{
+static Array<const char*, 8> commands = {{
 	"#pragma anki start vertexShader",
 	"#pragma anki start teShader",
 	"#pragma anki start tcShader",
 	"#pragma anki start geometryShader",
 	"#pragma anki start fragmentShader",
 	"#pragma anki include",
-	"#pragma anki transformFeedbackVaryings"}};
+	"#pragma anki transformFeedbackVaryings separate",
+	"#pragma anki transformFeedbackVaryings interleaved"}};
 
 static_assert(ST_VERTEX == 0 && ST_FRAGMENT == 4, "See file");
 
@@ -58,6 +59,14 @@ void ShaderProgramPrePreprocessor::parseFileForPragmas(
 	for(const std::string& line : lines)
 	{
 		std::string::size_type npos;
+		Bool expectPragmaAnki = false;
+		Bool gotPragmaAnki = true;
+
+		if(line.find("#pragma anki") == 0)
+		{
+			expectPragmaAnki = true;
+		}
+
 		if(line.find(commands[ST_VERTEX]) == 0)
 		{
 			parseStartPragma(ST_VERTEX, line);
@@ -89,11 +98,25 @@ void ShaderProgramPrePreprocessor::parseFileForPragmas(
 		{
 			std::string slist = {line, npos, std::string::npos};
 			trffbVaryings = StringList::splitString(slist.c_str(), ' ');
+			xfbBufferMode = XFBBM_SEPARATE;
+		}
+		else if(line.find(commands[7]) == 0)
+		{
+			std::string slist = {line, npos, std::string::npos};
+			trffbVaryings = StringList::splitString(slist.c_str(), ' ');
+			xfbBufferMode = XFBBM_INTERLEAVED;
 		}
 		else
 		{
+			gotPragmaAnki = false;
 			sourceLines.push_back(line);
 		}
+
+		// Sanity check
+		if(expectPragmaAnki && !gotPragmaAnki)
+		{
+			throw ANKI_EXCEPTION("Malformed pragma anki: " + line);
+		}
 	}
 }
 

+ 18 - 3
src/resource/ShaderProgramResource.cpp

@@ -20,15 +20,29 @@ void ShaderProgramResource::load(const char* filename, const char* extraSrc)
 {
 	ShaderProgramPrePreprocessor pars(filename);
 
-	std::array<const char*, 128> trfVarsArr = {{nullptr}};
+	Array<const char*, 128> trfVarsArr = {{nullptr}};
+	GLenum xfbBufferMode = GL_NONE;
 	if(pars.getTranformFeedbackVaryings().size() > 0)
 	{
-		uint32_t i;
+		U32 i;
 		for(i = 0; i < pars.getTranformFeedbackVaryings().size(); i++)
 		{
 			trfVarsArr[i] = pars.getTranformFeedbackVaryings()[i].c_str();
 		}
 		trfVarsArr[i] = nullptr;
+
+		switch(pars.getXfbBufferMode())
+		{
+		case ShaderProgramPrePreprocessor::XFBBM_INTERLEAVED:
+			xfbBufferMode = GL_INTERLEAVED_ATTRIBS;
+			break;
+		case ShaderProgramPrePreprocessor::XFBBM_SEPARATE:
+			xfbBufferMode = GL_SEPARATE_ATTRIBS;
+			break;
+		default:
+			ANKI_ASSERT(0);
+			break;
+		}
 	}
 
 	std::string vertSrc = extraSrc + pars.getShaderSource(ST_VERTEX);
@@ -39,7 +53,8 @@ void ShaderProgramResource::load(const char* filename, const char* extraSrc)
 		nullptr,
 		nullptr,
 		fragSrc.c_str(),
-		&trfVarsArr[0]);
+		&trfVarsArr[0],
+		xfbBufferMode);
 }
 
 //==============================================================================