Explorar el Código

Remove shader variables

[email protected] hace 11 años
padre
commit
73c7fff9db

+ 0 - 172
include/anki/gl/GlCommon.h

@@ -32,10 +32,6 @@
 
 
 namespace anki {
 namespace anki {
 
 
-// Forward
-class GlShader;
-class GlProgramBlock;
-
 /// @addtogroup opengl_private
 /// @addtogroup opengl_private
 /// @{
 /// @{
 
 
@@ -158,174 +154,6 @@ void writeShaderBlockMemory(
 	U32 elementsCount,
 	U32 elementsCount,
 	void* buffBegin,
 	void* buffBegin,
 	const void* buffEnd);
 	const void* buffEnd);
-
-/// Shader program variable. The type is attribute or uniform
-class GlProgramVariable
-{
-	friend class GlShader;
-
-public:
-	/// Shader program variable type
-	enum class Type: U8
-	{
-		INPUT, ///< Attribute on vertex
-		UNIFORM,
-		BUFFER
-	};
-
-	/// @name Accessors
-	/// @{
-	Type getType() const
-	{
-		return m_type;
-	}
-
-	CString getName() const
-	{
-		return CString(&m_name[0]);
-	}
-
-	GLenum getDataType() const
-	{
-		ANKI_ASSERT(m_dataType != GL_NONE);
-		return m_dataType;
-	}
-
-	PtrSize getArraySize() const
-	{
-		ANKI_ASSERT(m_arrSize != 0);
-		return m_arrSize;
-	}
-
-	GLint getLocation() const
-	{
-		ANKI_ASSERT(m_loc != -1);
-		return m_loc;
-	}
-
-	U32 getTextureUnit() const
-	{
-		ANKI_ASSERT(m_texUnit >= 0);
-		return (U32)m_texUnit;
-	}
-
-	/// @return The block or nullptr if it doesn't belong to a block
-	const GlProgramBlock* getBlock() const;
-	/// @}
-
-	/// @name Block setters
-	/// Write a client memory that represents the interface block
-	/// @{
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const F32 arr[], U32 size) const;
-
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const Vec2 arr[], U32 size) const;
-
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const Vec3 arr[], U32 size) const;
-
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const Vec4 arr[], U32 size) const;
-
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const Mat3 arr[], U32 size) const;
-
-	void writeClientMemory(void* buffBase, U32 buffSize,
-		const Mat4 arr[], U32 size) const;
-	/// @}
-
-private:
-	Type m_type; ///< It's type
-	GlShader* m_prog = nullptr;
-	char* m_name; ///< The name inside the shader program
-
-	GLenum m_dataType = GL_NONE; ///< GL_FLOAT or GL_FLOAT_VEC2 etc.
-	U8 m_arrSize = 0; ///< Its 1 if it is a single or >1 if it is an array
-
-	I32 m_loc = -1; ///< For uniforms and attributes
-
-	/// @name For variables in interface blocks
-	/// @{
-
-	/// Stride between the each array element if the variable is array
-	I32 m_arrStride = -1;
-
-	I32 m_offset = -1; ///< Offset inside the block
-
-	/// Identifying the stride between columns of a column-major matrix or rows 
-	/// of a row-major matrix
-	I32 m_matrixStride = -1;
-
-	I16 m_blockIdx = -1; ///< Interface block
-	/// @}
-
-	I32 m_texUnit = -1; ///< Explicit unit for samplers
-
-	/// Do common checks
-	template<typename T>
-	void writeClientMemorySanityChecks(void* buffBase, U32 buffSize,
-		const T arr[], U32 size) const;
-
-	/// Do the actual command of setClientMemory
-	template<typename T>
-	void writeClientMemoryInternal(
-		void* buff, U32 buffSize, const T arr[], U32 size) const;
-
-	/// Do the actual command of setClientMemory for matrices
-	template<typename Mat, typename Vec>
-	void writeClientMemoryInternalMatrix(void* buff, U32 buffSize,
-		const Mat arr[], U32 size) const;
-};
-
-/// Interface shader block
-class GlProgramBlock
-{
-	friend class GlShader;
-
-public:
-	static const U32 MAX_VARIABLES_PER_BLOCK = 16;
-
-	/// Interface shader block type
-	enum class Type: U8
-	{
-		UNIFORM,
-		SHADER_STORAGE
-	};
-
-	/// @name Accessors
-	/// @{
-	Type getType() const
-	{
-		return m_type;
-	}
-
-	PtrSize getSize() const
-	{
-		return m_size;
-	}
-
-	CString getName() const
-	{
-		return CString(&m_name[0]);
-	}
-
-	U32 getBinding() const
-	{
-		return m_bindingPoint;
-	}
-	/// @}
-
-private:
-	Type m_type;
-	char* m_name = nullptr;
-	/// Keep the indices as U16 to save memory
-	Array<U16, MAX_VARIABLES_PER_BLOCK> m_variableIdx; 
-	U32 m_size = 0; ///< In bytes
-	U32 m_bindingPoint = MAX_U32;
-	U8 m_variablesCount = 0;
-};
-
 /// @}
 /// @}
 
 
 /// @addtogroup opengl_other
 /// @addtogroup opengl_other

+ 0 - 28
include/anki/gl/GlShader.h

@@ -51,29 +51,8 @@ public:
 		return m_type;
 		return m_type;
 	}
 	}
 
 
-	const DArray<GlProgramVariable>& getVariables() const
-	{
-		ANKI_ASSERT(isCreated());
-		return m_variables;
-	}
-
-	const DArray<GlProgramBlock>& getBlocks() const
-	{
-		ANKI_ASSERT(isCreated());
-		return m_blocks;
-	}
-
-	const GlProgramVariable* tryFindVariable(const CString& name) const;
-	const GlProgramBlock* tryFindBlock(const CString& name) const;
-
 private:
 private:
 	GLenum m_type;
 	GLenum m_type;
-	GlAllocator<U8> m_alloc;
-	DArray<GlProgramVariable> m_variables;
-	DArray<GlProgramBlock> m_blocks;
-
-	/// Keep all the names of blocks and variables in a single place
-	DArray<char> m_names;
 
 
 	void destroy();
 	void destroy();
 
 
@@ -81,13 +60,6 @@ private:
 	ANKI_USE_RESULT Error initBlocksOfType(GLenum programInterface, 
 	ANKI_USE_RESULT Error initBlocksOfType(GLenum programInterface, 
 		U count, U index, char*& namesPtr, U& namesLen);
 		U count, U index, char*& namesPtr, U& namesLen);
 
 
-	/// Query the program for variables
-	ANKI_USE_RESULT Error initVariablesOfType(
-		GLenum programInterface, U count, U index, U blkIndex,
-		char*& namesPtr, U& namesLen);
-
-	ANKI_USE_RESULT Error populateVariablesAndBlock(GlAllocator<U8>& alloc);
-
 	ANKI_USE_RESULT Error handleError(GlAllocator<U8>& alloc, String& src);
 	ANKI_USE_RESULT Error handleError(GlAllocator<U8>& alloc, String& src);
 };
 };
 
 

+ 0 - 10
include/anki/gl/GlShaderHandle.h

@@ -35,16 +35,6 @@ public:
 	/// They will sync client with server.
 	/// They will sync client with server.
 	/// @{
 	/// @{
 	GLenum getType() const;
 	GLenum getType() const;
-
-	const GlProgramVariable* getVariablesBegin() const;
-	const GlProgramVariable* getVariablesEnd() const;
-
-	const GlProgramBlock* getBlocksBegin() const;
-	const GlProgramBlock* getBlocksEnd() const;
-
-	const GlProgramVariable* tryFindVariable(const CString& name) const;
-
-	const GlProgramBlock* tryFindBlock(const CString& name) const;
 	/// @}
 	/// @}
 };
 };
 
 

+ 5 - 0
include/anki/resource/MaterialProgramCreator.h

@@ -138,6 +138,11 @@ public:
 		return m_tessellation;
 		return m_tessellation;
 	}
 	}
 
 
+	U32 getUniformBlockSize() const
+	{
+		return m_blockSize;
+	}
+
 private:
 private:
 	TempResourceAllocator<char> m_alloc; 
 	TempResourceAllocator<char> m_alloc; 
 	Array<MPStringList, 5> m_source; ///< Shader program final source
 	Array<MPStringList, 5> m_source; ///< Shader program final source

+ 1 - 648
src/gl/GlShader.cpp

@@ -15,259 +15,6 @@
 
 
 namespace anki {
 namespace anki {
 
 
-//==============================================================================
-// GlProgramVariable                                                           =
-//==============================================================================
-
-//==============================================================================
-namespace {
-
-#if ANKI_ASSERTIONS
-
-// Template functions that return the GL type using an AnKi type
-template<typename T>
-static Bool checkType(GLenum glDataType);
-
-template<>
-Bool checkType<F32>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT;
-}
-
-template<>
-Bool checkType<Vec2>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT_VEC2;
-}
-
-template<>
-Bool checkType<Vec3>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT_VEC3;
-}
-
-template<>
-Bool checkType<Vec4>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT_VEC4;
-}
-
-template<>
-Bool checkType<Mat3>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT_MAT3;
-}
-
-template<>
-Bool checkType<Mat4>(GLenum glDataType)
-{
-	return glDataType == GL_FLOAT_MAT4;
-}
-
-#endif
-
-static Bool isSampler(GLenum type)
-{
-	Bool is = 
-		type == GL_SAMPLER_2D 
-		|| type == GL_SAMPLER_2D_SHADOW
-		|| type == GL_UNSIGNED_INT_SAMPLER_2D
-		|| type == GL_SAMPLER_2D_ARRAY_SHADOW
-		|| type == GL_SAMPLER_2D_ARRAY
-		|| type == GL_SAMPLER_CUBE
-#if ANKI_GL == ANKI_GL_DESKTOP
-		|| type == GL_SAMPLER_2D_MULTISAMPLE
-#endif
-		;
-
-	return is;
-}
-
-} // end anonymous namespace
-
-//==============================================================================
-const GlProgramBlock* GlProgramVariable::getBlock() const
-{
-	ANKI_ASSERT(m_prog);
-	if(m_blockIdx != -1)
-	{
-		ANKI_ASSERT((PtrSize)m_blockIdx < m_prog->m_blocks.getSize());
-	}
-
-	return (m_blockIdx != -1) ? &m_prog->m_blocks[m_blockIdx] : nullptr;
-}
-
-//==============================================================================
-template<typename T>
-void GlProgramVariable::writeClientMemorySanityChecks(
-	void* buffBase, U32 buffSize,
-	const T arr[], U32 size) const
-{
-	// Check pointers
-	ANKI_ASSERT(buffBase != nullptr && arr != nullptr);
-
-	// Check T
-	ANKI_ASSERT(checkType<T>(m_dataType));
-	
-	// Check array size
-	ANKI_ASSERT(size <= m_arrSize && size > 0);
-	
-	// Check if var in block
-	ANKI_ASSERT(m_blockIdx != -1);
-	ANKI_ASSERT(m_offset != -1 && m_arrStride != -1);
-
-	// Check if there is space
-	ANKI_ASSERT(getBlock()->getSize() <= buffSize);
-
-	// arrStride should not be zero if array
-	ANKI_ASSERT(!(size > 1 && m_arrStride == 0));
-}
-
-//==============================================================================
-template<typename T>
-void GlProgramVariable::writeClientMemoryInternal(
-	void* buffBase, U32 buffSize, const T arr[], U32 size) const
-{
-	writeClientMemorySanityChecks<T>(buffBase, buffSize, arr, size);
-	
-	U8* buff = (U8*)buffBase + m_offset;
-	for(U32 i = 0; i < size; i++)
-	{
-		ANKI_ASSERT((U8*)buff + sizeof(T) <= (U8*)buffBase + buffSize);
-
-		T* ptr = (T*)buff;
-		*ptr = arr[i];
-		buff += m_arrStride;
-	}
-}
-
-//==============================================================================
-template<typename T, typename Vec>
-void GlProgramVariable::writeClientMemoryInternalMatrix(
-	void* buffBase, U32 buffSize, const T arr[], U32 size) const
-{
-	writeClientMemorySanityChecks<T>(buffBase, buffSize, arr, size);
-	ANKI_ASSERT(m_matrixStride != -1 && m_matrixStride >= (I32)sizeof(Vec));
-
-	U8* buff = (U8*)buffBase + m_offset;
-	for(U32 i = 0; i < size; i++)
-	{
-		U8* subbuff = buff;
-		T matrix = arr[i];
-		matrix.transpose();
-		for(U j = 0; j < sizeof(T) / sizeof(Vec); j++)
-		{
-			ANKI_ASSERT(subbuff + sizeof(Vec) <= (U8*)buffBase + buffSize);
-
-			Vec* ptr = (Vec*)subbuff;
-			*ptr = matrix.getRow(j);
-			subbuff += m_matrixStride;
-		}
-		buff += m_arrStride;
-	}
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const F32 arr[], U32 size) const
-{
-	writeClientMemoryInternal(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const Vec2 arr[], U32 size) const
-{
-	writeClientMemoryInternal(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const Vec3 arr[], U32 size) const
-{
-	writeClientMemoryInternal(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const Vec4 arr[], U32 size) const
-{
-	writeClientMemoryInternal(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const Mat3 arr[], U32 size) const
-{
-	writeClientMemoryInternalMatrix<Mat3, Vec3>(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-void GlProgramVariable::writeClientMemory(void* buff, U32 buffSize,
-	const Mat4 arr[], U32 size) const
-{
-	writeClientMemoryInternalMatrix<Mat4, Vec4>(buff, buffSize, arr, size);
-}
-
-//==============================================================================
-// GlShader                                                                    =
-//==============================================================================
-
-/// Check if the variable name is worth beeng processed.
-///
-/// In case of uniform arrays some implementations (nVidia) on 
-/// GL_ACTIVE_UNIFORMS they return the number of uniforms that are inside that 
-/// uniform array in addition to the first element (it will count for example 
-/// the float_arr[9]). But other implementations don't (Mali T6xx). Also in 
-/// some cases with big arrays (IS shader) this will overpopulate the uniforms 
-/// vector and hash map. So, to solve this if the uniform name has something 
-/// like this "[N]" where N != 0 then ignore the uniform and put it as array
-static Bool sanitizeSymbolName(char* name)
-{
-	ANKI_ASSERT(name && strlen(name) > 1);
-
-	// Kick everything that starts with "gl" or "_"
-	if(name[0] == '_')
-	{
-		return false;
-	}
-
-	if(strlen(name) > 2 && name[0] == 'g' && name[1] == 'l')
-	{
-		return false;
-	}
-
-	// Search for arrays
-	char* c = strchr(name, '[');
-
-	if(c != nullptr)
-	{
-		// Found bracket
-
-		if(strstr(name, "[0]") == nullptr)
-		{
-			// Found something "[N]" where N != 0
-			return false;
-		}
-		else
-		{
-			// Found "[0]"
-
-			if(strlen(c) != 3)
-			{
-				// It's something like "bla[0].xxxxxxx" so _forget_ it
-				return false;
-			}
-
-			*c = '\0'; // Cut the bracket part
-		}
-	}
-
-	return true;
-}
-
-const U SYMBOL_MAX_NAME_LENGTH = 256;
-
 //==============================================================================
 //==============================================================================
 Error GlShader::create(GLenum type, const CString& source, 
 Error GlShader::create(GLenum type, const CString& source, 
 	GlAllocator<U8>& alloc, const CString& cacheDir)
 	GlAllocator<U8>& alloc, const CString& cacheDir)
@@ -278,7 +25,6 @@ Error GlShader::create(GLenum type, const CString& source,
 	Error err = ErrorCode::NONE;
 	Error err = ErrorCode::NONE;
 
 
 	m_type = type;
 	m_type = type;
-	m_alloc = alloc;
 
 
 	// 1) Append some things in the source string
 	// 1) Append some things in the source string
 	//
 	//
@@ -291,6 +37,7 @@ Error GlShader::create(GLenum type, const CString& source,
 	}
 	}
 
 
 	String fullSrc;
 	String fullSrc;
+	String::ScopeDestroyer fullSrcd(&fullSrc, alloc); 
 #if ANKI_GL == ANKI_GL_DESKTOP
 #if ANKI_GL == ANKI_GL_DESKTOP
 	err = fullSrc.sprintf(alloc, "#version %d core\n%s\n", version, &source[0]); 
 	err = fullSrc.sprintf(alloc, "#version %d core\n%s\n", version, &source[0]); 
 #else
 #else
@@ -371,15 +118,6 @@ Error GlShader::create(GLenum type, const CString& source,
 		}
 		}
 	}
 	}
 
 
-	// 3) Populate with vars and blocks
-	//
-	if(!err)
-	{
-		err = populateVariablesAndBlock(alloc);
-	}
-
-	fullSrc.destroy(alloc);
-
 	return err;
 	return err;
 }
 }
 
 
@@ -437,150 +175,6 @@ Error GlShader::handleError(GlAllocator<U8>& alloc, String& src)
 	return err;
 	return err;
 }
 }
 
 
-//==============================================================================
-Error GlShader::populateVariablesAndBlock(GlAllocator<U8>& alloc)
-{
-	Error err = ErrorCode::NONE;
-
-	static Array<GLenum, 5> interfaces = {{
-		GL_UNIFORM_BLOCK, GL_SHADER_STORAGE_BLOCK, 
-		GL_UNIFORM, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT}};
-
-	// First get the count of active resources and name length
-	Array<GLint, interfaces.size()> count; // Count of symbol after
-	                                       // kicking some symbols
-	Array<GLint, interfaces.size()> countReal; // Count of symbols as GL
-	                                           // reported them
-	U namesLen = 0;
-
-	for(U i = 0; i < interfaces.size(); i++)
-	{
-		GLint cnt;
-		glGetProgramInterfaceiv(
-			m_glName, interfaces[i], GL_ACTIVE_RESOURCES, &cnt);
-
-		count[i] = 0;
-		countReal[i] = cnt;
-		for(U c = 0; c < (U)cnt; c++)
-		{
-			GLint len = 0;
-			Array<char, SYMBOL_MAX_NAME_LENGTH> name;
-
-			// Get and check the name
-			glGetProgramResourceName(m_glName, interfaces[i], c, 
-				name.size(), &len, &name[0]);
-
-			ANKI_ASSERT((U)len < name.size());
-			ANKI_ASSERT((U)len == strlen(&name[0]));
-
-			if(!sanitizeSymbolName(&name[0]))
-			{
-				continue;
-			}
-
-			// Recalc length after trimming
-			len = std::strlen(&name[0]);
-
-			namesLen += (U)len + 1;
-			++count[i];
-		}
-	}
-
-	err = m_names.create(alloc, namesLen);
-	char* namesPtr = nullptr;
-
-	if(!err)
-	{
-		namesPtr = &m_names[0];
-	}
-
-	// Populate the blocks
-	if(!err && (count[0] + count[1] > 0))
-	{
-		err = m_blocks.create(alloc, count[0] + count[1]);
-
-		if(!err)
-		{
-			err = initBlocksOfType(GL_UNIFORM_BLOCK,
-				countReal[0], 0, namesPtr, namesLen);
-		}
-
-		if(!err)
-		{
-			err = initBlocksOfType(GL_SHADER_STORAGE_BLOCK,
-				countReal[1], count[0], namesPtr, namesLen);
-		}
-	}
-
-	// Populate the variables
-	if(!err && (count[2] + count[3] + count[4] > 0))
-	{
-		err = m_variables.create(alloc, count[2] + count[3] + count[4]);
-
-		if(!err)
-		{
-			err = initVariablesOfType(GL_UNIFORM,
-				countReal[2], 0, 0, namesPtr, namesLen);
-		}
-
-		if(!err)
-		{
-			err = initVariablesOfType(GL_BUFFER_VARIABLE,
-				countReal[3], count[2], count[0], namesPtr, namesLen);
-		}
-
-		if(!err)
-		{
-			err = initVariablesOfType(GL_PROGRAM_INPUT,
-				countReal[4], count[2] + count[3], 0, namesPtr, namesLen);
-		}
-
-		// Sanity checks
-		if(!err)
-		{
-			// Iterate all samples and make sure they have set the unit 
-			// explicitly
-			std::unordered_map<
-				U, 
-				U, 
-				std::hash<U>,
-				std::equal_to<U>,
-				HeapAllocator<std::pair<U, U>>> 
-				unitToCount(10, std::hash<U>(), std::equal_to<U>(), alloc);
-
-			for(const GlProgramVariable& var : m_variables)
-			{
-				if(isSampler(var.m_dataType))
-				{
-					if(unitToCount.find(var.m_texUnit) == unitToCount.end())
-					{
-						// Doesn't exit
-						unitToCount[var.m_texUnit] = 1;
-					}	
-					else
-					{
-						unitToCount[var.m_texUnit] = 
-							unitToCount[var.m_texUnit] + 1;
-					}
-				}
-			}
-
-			for(auto pair : unitToCount)
-			{
-				if(pair.second != 1)
-				{
-					ANKI_LOGW("It is advised to explicitly set the unit "
-						"for samplers");
-				}
-			}
-		} // end sanity checks
-	}
-
-	ANKI_ASSERT(namesLen == 0);
-
-	return err;
-}
-
 //==============================================================================
 //==============================================================================
 void GlShader::destroy()
 void GlShader::destroy()
 {
 {
@@ -589,247 +183,6 @@ void GlShader::destroy()
 		glDeleteProgram(m_glName);
 		glDeleteProgram(m_glName);
 		m_glName = 0;
 		m_glName = 0;
 	}
 	}
-
-	m_variables.destroy(m_alloc);
-	m_blocks.destroy(m_alloc);
-	m_names.destroy(m_alloc);
-}
-
-//==============================================================================
-Error GlShader::initVariablesOfType(
-	GLenum interface, U activeCount, U indexOffset, U blkIndexOffset,
-	char*& namesPtr, U& namesLen)
-{
-	Error err = ErrorCode::NONE;
-	U index = indexOffset;
-
-	for(U i = 0; i < activeCount; i++)
-	{
-		// Get name
-		Array<char, SYMBOL_MAX_NAME_LENGTH> name;
-		GLint len;
-		glGetProgramResourceName(
-			m_glName, interface, i, name.size(), &len, &name[0]);
-
-		if(!sanitizeSymbolName(&name[0]))
-		{
-			continue;
-		}
-
-		len = strlen(&name[0]);
-		strcpy(namesPtr, &name[0]);
-
-		// Get the properties
-		Array<GLenum, 7> prop = {{GL_LOCATION, GL_TYPE, GL_ARRAY_SIZE, 
-			GL_ARRAY_STRIDE, GL_OFFSET, GL_MATRIX_STRIDE, GL_BLOCK_INDEX}};
-		Array<GLint, 7> out = {{-1, GL_NONE, -1, -1, -1, -1, -1}};
-
-		U fromIdx = 0, toIdx = 0;
-		GlProgramVariable::Type akType = GlProgramVariable::Type::UNIFORM;
-		switch(interface)
-		{
-		case GL_UNIFORM:
-			fromIdx = 0;
-			toIdx = prop.getSize() - 1;
-			akType = GlProgramVariable::Type::UNIFORM;
-			break;
-		case GL_BUFFER_VARIABLE:
-			fromIdx = 1;
-			toIdx = prop.getSize() - 1;
-			akType = GlProgramVariable::Type::BUFFER;
-			break;
-		case GL_PROGRAM_INPUT:
-			fromIdx = 0;
-			toIdx = 2;
-			akType = GlProgramVariable::Type::INPUT;
-			break;
-		default:
-			ANKI_ASSERT(0);
-		};
-
-		GLsizei outCount = 0;
-		GLsizei count = toIdx - fromIdx + 1;
-		glGetProgramResourceiv(m_glName, interface, i, 
-			count, &prop[fromIdx], 
-			count, &outCount, &out[fromIdx]);
-
-		if(count != outCount)
-		{
-			ANKI_LOGE("glGetProgramResourceiv() didn't got all the params");
-			err = ErrorCode::FUNCTION_FAILED;
-			break;
-		}
-
-		// Create and populate the variable
-		ANKI_ASSERT(index < m_variables.getSize());
-		GlProgramVariable& var = m_variables[index++];
-
-		var.m_type = akType;
-		var.m_prog = this;
-		var.m_name = namesPtr;
-		var.m_dataType = out[1];
-		ANKI_ASSERT(var.m_dataType != GL_NONE);
-
-		var.m_arrSize = out[2];
-
-		if(var.m_arrSize == 0)
-		{
-			var.m_arrSize = 1;
-		}
-
-		if(interface == GL_UNIFORM || interface == GL_PROGRAM_INPUT)
-		{
-			var.m_loc = out[0];
-		}
-
-		if(interface == GL_UNIFORM || interface == GL_BUFFER_VARIABLE)
-		{
-			var.m_arrStride = out[3];
-			var.m_offset = out[4];
-			var.m_matrixStride = out[5];
-		}
-
-		// Block index
-		if(out[6] >= 0)
-		{
-			ANKI_ASSERT(interface != GL_PROGRAM_INPUT);
-
-			U blkIdx = blkIndexOffset + out[6];
-			ANKI_ASSERT(blkIdx < m_blocks.getSize());
-
-			// Connect block with variable
-			ANKI_ASSERT(m_blocks[blkIdx].m_variablesCount < 255);
-			
-			m_blocks[blkIdx].m_variableIdx[
-				m_blocks[blkIdx].m_variablesCount++];
-
-			var.m_blockIdx = blkIdx;
-		}
-
-		// Sampler unit
-		if(isSampler(var.m_dataType))
-		{
-			GLint unit = -1;
-			glGetUniformiv(m_glName, var.m_loc, &unit);
-			ANKI_ASSERT(unit > -1);
-			var.m_texUnit = unit;
-		}
-
-		// Advance
-		namesPtr += len + 1;
-		namesLen -= len + 1;
-	}
-
-	return err;
-}
-
-//==============================================================================
-Error GlShader::initBlocksOfType(
-	GLenum interface, U activeCount, U indexOffset, 
-	char*& namesPtr, U& namesLen)
-{
-	Error err = ErrorCode::NONE;
-	U index = indexOffset;
-
-	for(U i = 0; i < activeCount; i++)
-	{
-		// Get name
-		Array<char, SYMBOL_MAX_NAME_LENGTH> name;
-		GLint len;
-		glGetProgramResourceName(
-			m_glName, interface, i, name.size(), &len, &name[0]);
-
-		if(!sanitizeSymbolName(&name[0]))
-		{
-			continue;
-		}
-
-		len = strlen(&name[0]);
-		strcpy(namesPtr, &name[0]);
-
-		// Get the properties
-		Array<GLenum, 2> prop = {{GL_BUFFER_BINDING, GL_BUFFER_DATA_SIZE}};
-		Array<GLint, 2> out = {{-1, -1}};
-
-		GLsizei outCount = 0;
-		glGetProgramResourceiv(m_glName, interface, i, 
-			prop.getSize(), &prop[0], 
-			out.getSize(), &outCount, &out[0]);
-
-		if(prop.getSize() != (U)outCount)
-		{
-			ANKI_LOGE("glGetProgramResourceiv() didn't got all the params");
-			err = ErrorCode::FUNCTION_FAILED;
-			break;
-		}
-
-		GlProgramBlock::Type akType = GlProgramBlock::Type::UNIFORM;
-		switch(interface)
-		{
-		case GL_UNIFORM_BLOCK:
-			akType = GlProgramBlock::Type::UNIFORM;
-			break;
-		case GL_SHADER_STORAGE_BLOCK:
-			akType = GlProgramBlock::Type::SHADER_STORAGE;
-			break;
-		default:
-			ANKI_ASSERT(0);
-		}
-
-		// Create and populate the block
-		GlProgramBlock& block = m_blocks[index++];
-
-		block.m_type = akType;
-		block.m_name = namesPtr;
-		block.m_size = out[1];
-		ANKI_ASSERT(out[1] > 0);
-		block.m_bindingPoint = out[0];
-		ANKI_ASSERT(out[0] >= 0);
-
-		// Advance
-		namesPtr += len + 1;
-		namesLen -= len + 1;
-	}
-
-	return err;
-}
-
-//==============================================================================
-const GlProgramVariable* GlShader::tryFindVariable(const CString& name) const
-{
-	ANKI_ASSERT(isCreated());
-
-	const GlProgramVariable* out = nullptr;
-
-	auto it = m_variables.begin(); 
-	for(; it != m_variables.end(); it++)
-	{
-		if(it->getName() == name)
-		{
-			out = &(*it);
-		}
-	}
-
-	return out;
-}
-
-//==============================================================================
-const GlProgramBlock* GlShader::tryFindBlock(const CString& name) const
-{
-	ANKI_ASSERT(isCreated());
-
-	const GlProgramBlock* out = nullptr;
-	
-	auto it = m_blocks.begin();
-	for(; it != m_blocks.end(); it++)
-	{
-		if(it->getName() == name)
-		{
-			out = &(*it);
-		}
-	}
-
-	return out;
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 0 - 41
src/gl/GlShaderHandle.cpp

@@ -81,46 +81,5 @@ GLenum GlShaderHandle::getType() const
 	return (serializeOnGetter()) ? GL_NONE : _get().getType();
 	return (serializeOnGetter()) ? GL_NONE : _get().getType();
 }
 }
 
 
-//==============================================================================
-const GlProgramVariable* GlShaderHandle::getVariablesBegin() const
-{
-	Error err = serializeOnGetter();
-	const GlProgramVariable* out = nullptr;
-
-	if(!err && _get().getVariables().getSize() != 0)
-	{
-		out = _get().getVariables().begin();
-	}
-
-	return out;
-}
-
-//==============================================================================
-const GlProgramVariable* GlShaderHandle::getVariablesEnd() const
-{
-	Error err = serializeOnGetter();
-	const GlProgramVariable* out = nullptr;
-
-	if(!err && _get().getVariables().getSize() != 0)
-	{
-		out = _get().getVariables().end();
-	}
-
-	return out;
-}
-
-//==============================================================================
-const GlProgramVariable* 
-	GlShaderHandle::tryFindVariable(const CString& name) const
-{
-	return (serializeOnGetter()) ? nullptr : _get().tryFindVariable(name);
-}
-
-//==============================================================================
-const GlProgramBlock* GlShaderHandle::tryFindBlock(const CString& name) const
-{
-	return (serializeOnGetter()) ? nullptr : _get().tryFindBlock(name);
-}
-
 } // end namespace anki
 } // end namespace anki
 
 

+ 0 - 6
src/renderer/Lf.cpp

@@ -125,12 +125,6 @@ Error Lf::initInternal(const ConfigSet& config)
 
 
 	PtrSize blockSize = 
 	PtrSize blockSize = 
 		sizeof(Flare) * m_maxFlaresPerLight * m_maxLightsWithFlares;
 		sizeof(Flare) * m_maxFlaresPerLight * m_maxLightsWithFlares;
-	if(m_realVert->getGlProgram().tryFindBlock("bFlares")->getSize() 
-		!= blockSize)
-	{
-		ANKI_LOGE("Incorrect block size");
-		return ErrorCode::FUNCTION_FAILED;
-	}
 
 
 	// Init buffer
 	// Init buffer
 	err = m_flareDataBuff.create(
 	err = m_flareDataBuff.create(

+ 1 - 9
src/resource/Material.cpp

@@ -572,15 +572,7 @@ Error Material::parseMaterialTag(const XmlElement& materialEl,
 
 
 	// Get uniform block size
 	// Get uniform block size
 	ANKI_ASSERT(m_progs.getSize() > 0);
 	ANKI_ASSERT(m_progs.getSize() > 0);
-
-	auto blk = m_progs[0]->getGlProgram().tryFindBlock("bDefaultBlock");
-	if(blk == nullptr)
-	{
-		ANKI_LOGE("bDefaultBlock not found");
-		return ErrorCode::USER_DATA;
-	}
-
-	m_shaderBlockSize = blk->getSize();
+	m_shaderBlockSize = loader.getUniformBlockSize();
 
 
 	return err;
 	return err;
 }
 }

+ 0 - 10
src/resource/Model.cpp

@@ -58,16 +58,6 @@ Error ModelPatchBase::createVertexDesc(
 	U count = 0;
 	U count = 0;
 	for(const Attrib& attrib : attribs)
 	for(const Attrib& attrib : attribs)
 	{
 	{
-		const GlProgramVariable* attr = 
-			prog.tryFindVariable(attrib.m_name);
-
-		if(attr == nullptr)
-		{
-			continue;
-		}
-
-		ANKI_ASSERT(attr->getType() == GlProgramVariable::Type::INPUT);
-
 		mesh.getBufferInfo(attrib.m_location, vbo, size, type,
 		mesh.getBufferInfo(attrib.m_location, vbo, size, type,
 			stride, offset);
 			stride, offset);