示例#1
0
bool end()
{
	saveProgram(ProgramName[program::VERT], VERT_PROGRAM_BINARY);
	saveProgram(ProgramName[program::FRAG], FRAG_PROGRAM_BINARY);

	// Delete objects
	glDeleteBuffers(buffer::MAX, BufferName);
	glDeleteVertexArrays(1, &VertexArrayName);
	glDeleteTextures(1, &Texture2DName);
	glDeleteProgram(ProgramName[program::VERT]);
	glDeleteProgram(ProgramName[program::FRAG]);
	glDeleteProgramPipelines(1, &PipelineName);

	return glf::checkError("end");
}
bool end()
{
	saveProgram(ProgramName[program::VERT], glf::DATA_DIRECTORY + VERT_PROGRAM_BINARY);
	saveProgram(ProgramName[program::GEOM], glf::DATA_DIRECTORY + GEOM_PROGRAM_BINARY);
	saveProgram(ProgramName[program::FRAG], glf::DATA_DIRECTORY + FRAG_PROGRAM_BINARY);

	// Delete objects
	glDeleteBuffers(buffer::MAX, BufferName);
	glDeleteVertexArrays(1, &VertexArrayName);
	glDeleteTextures(1, &Texture2DName);
	for(std::size_t i = 0; i < program::MAX; ++i)
		glDeleteProgram(ProgramName[i]);
	glDeleteProgramPipelines(1, &PipelineName);

	return glf::checkError("end");
}
示例#3
0
bool Tunefish4AudioProcessor::saveProgramAll()
{
    for(int i=0;i<TF_PLUG_NUM_PROGRAMS;i++)
    {
        if (!saveProgram(i))
            return false;
    }

    return true;
}
示例#4
0
bool tf3Synth::saveProgramAll()
{
	for(int i=0;i<kNumPrograms;i++)
	{
		if (!saveProgram(i))
			return false;
	}

	return true;
}
/*
	char const * retrieveBinaryCache(char const* Path)
	{
		return 0;
	}

	enum
	{
		PROGRAM_SEPARATE_BIT = (1 << 0),
		PROGRAM_CACHE_BIT = (1 << 1),
		PROGRAM_BYPASS_CACHE_BIT = (1 << 2)
	};

	bool hasProgramBinarySPIRVSupport()
	{
		GLint NumProgramBinaryFormats(0);
		glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &NumProgramBinaryFormats);

		std::vector<GLint> ProgramBinaryFormats(static_cast<std::size_t>(NumProgramBinaryFormats));
		glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, &ProgramBinaryFormats[0]);

		for(std::size_t FormatIndex = 0; FormatIndex < ProgramBinaryFormats.size(); ++FormatIndex)
		{
			if(ProgramBinaryFormats[FormatIndex] == GL_PROGRAM_BINARY_SPIR_V)
				return true;
		}

		return false;
	}

	bool isProgramBinarySPIRV(GLubyte * binary)
	{
		return *reinterpret_cast<GLuint*>(binary) == 0x07230203;
	}

	GLuint createProgram(char const* Path, GLbitfield Flags)
	{
		assert(HasProgramBinarySPIRVSupport());
		assert(Path);

		if(!(Flags & PROGRAM_BYPASS_CACHE_BIT))
			Path = retrieveBinaryCache(Path);

		GLenum Format = 0;
		GLint Size = 0;
		std::vector<glm::byte> Data;
		if(!loadBinary(Path, Format, Data, Size))
			return 0;

		assert((isProgramBinarySPIRV(&Data[0]) && Format == GL_PROGRAM_BINARY_SPIR_V) || Format != GL_PROGRAM_BINARY_SPIR_V);

		GLuint ProgramName = glCreateProgram();
		glProgramParameteri(ProgramName, GL_PROGRAM_SEPARABLE, Flags & PROGRAM_SEPARATE_BIT ? GL_TRUE : GL_FALSE);
		glProgramParameteri(ProgramName, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, Flags & PROGRAM_CACHE_BIT ? GL_TRUE : GL_FALSE);
		glProgramBinary(ProgramName, Format, &Data[0], Size);
		glLinkProgram(ProgramName);

		return ProgramName;
	}
*/
	bool initProgram()
	{
		bool Validated = true;
		GLint Success = 0;

		glGenProgramPipelines(1, &PipelineName);

		ProgramName[program::VERT] = glCreateProgram();
		glProgramParameteri(ProgramName[program::VERT], GL_PROGRAM_SEPARABLE, GL_TRUE);
		glProgramParameteri(ProgramName[program::VERT], GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);

		ProgramName[program::GEOM] = glCreateProgram();
		glProgramParameteri(ProgramName[program::GEOM], GL_PROGRAM_SEPARABLE, GL_TRUE);
		glProgramParameteri(ProgramName[program::GEOM], GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);

		ProgramName[program::FRAG] = glCreateProgram();
		glProgramParameteri(ProgramName[program::FRAG], GL_PROGRAM_SEPARABLE, GL_TRUE);
		glProgramParameteri(ProgramName[program::FRAG], GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);

		{
			GLenum Format = 0;
			GLint Size = 0;
			std::vector<glm::byte> Data;
			if(loadBinary(getDataDirectory() + VERT_PROGRAM_BINARY, Format, Data, Size))
			{
				glProgramBinary(ProgramName[program::VERT], Format, &Data[0], Size);
				glGetProgramiv(ProgramName[program::VERT], GL_LINK_STATUS, &Success);
				Validated = Validated && Success == GL_TRUE;
			}
		}

		{
			GLenum Format = 0;
			GLint Size = 0;
			std::vector<glm::byte> Data;
			if(loadBinary(getDataDirectory() + GEOM_PROGRAM_BINARY, Format, Data, Size))
			{
				glProgramBinary(ProgramName[program::GEOM], Format, &Data[0], Size);
				glGetProgramiv(ProgramName[program::GEOM], GL_LINK_STATUS, &Success);
				Validated = Validated && Success == GL_TRUE;
			}
		}

		{
			GLenum Format = 0;
			GLint Size = 0;
			std::vector<glm::byte> Data;
			if(loadBinary(getDataDirectory() + FRAG_PROGRAM_BINARY, Format, Data, Size))
			{
				glProgramBinary(ProgramName[program::FRAG], Format, &Data[0], Size);
				glGetProgramiv(ProgramName[program::FRAG], GL_LINK_STATUS, &Success);
				Validated = Validated && Success == GL_TRUE;
			}
		}

		compiler Compiler;

		if(Validated && !Success)
		{
			GLuint VertShaderName = Compiler.create(GL_VERTEX_SHADER, getDataDirectory() + VERT_SHADER_SOURCE);

			glAttachShader(ProgramName[program::VERT], VertShaderName);
			glLinkProgram(ProgramName[program::VERT]);
		}

		if(Validated && !Success)
		{
			GLuint GeomShaderName = Compiler.create(GL_GEOMETRY_SHADER, getDataDirectory() + GEOM_SHADER_SOURCE);

			glAttachShader(ProgramName[program::GEOM], GeomShaderName);
			glLinkProgram(ProgramName[program::GEOM]);
		}

		if(Validated && !Success)
		{
			GLuint FragShaderName = Compiler.create(GL_FRAGMENT_SHADER, getDataDirectory() + FRAG_SHADER_SOURCE);

			glAttachShader(ProgramName[program::FRAG], FragShaderName);
			glLinkProgram(ProgramName[program::FRAG]);
		}

		if(Validated)
		{
			glUseProgramStages(PipelineName, GL_VERTEX_SHADER_BIT, ProgramName[program::VERT]);
			glUseProgramStages(PipelineName, GL_GEOMETRY_SHADER_BIT, ProgramName[program::GEOM]);
			glUseProgramStages(PipelineName, GL_FRAGMENT_SHADER_BIT, ProgramName[program::FRAG]);
			Validated = Validated && this->checkError("initProgram - stage");
		}

		if(Validated)
		{
			Validated = Validated && Compiler.checkProgram(ProgramName[program::VERT]);
			Validated = Validated && Compiler.checkProgram(ProgramName[program::GEOM]);
			Validated = Validated && Compiler.checkProgram(ProgramName[program::FRAG]);
		}

		if(Validated)
		{
			UniformMVP = glGetUniformLocation(ProgramName[program::VERT], "MVP");
			UniformDiffuse = glGetUniformLocation(ProgramName[program::FRAG], "Diffuse");
		}

		saveProgram(ProgramName[program::VERT], getDataDirectory() + VERT_PROGRAM_BINARY);
		saveProgram(ProgramName[program::GEOM], getDataDirectory() + GEOM_PROGRAM_BINARY);
		saveProgram(ProgramName[program::FRAG], getDataDirectory() + FRAG_PROGRAM_BINARY);

		return Validated && this->checkError("initProgram");
	}
示例#6
0
bool Tunefish4AudioProcessor::saveProgram()
{
    return saveProgram(currentProgramIndex);
}
示例#7
0
bool tf3Synth::saveProgram()
{
	return saveProgram(curProgram);
}