コード例 #1
0
//==============================================================================
Error GlPipelineHandle::commonConstructor(
	GlCommandBufferHandle& commands,
	const GlShaderHandle* progsBegin, const GlShaderHandle* progsEnd)
{
	class Command: public GlCommand
	{
	public:
		GlPipelineHandle m_ppline;
		Array<GlShaderHandle, 6> m_progs;
		U8 m_progsCount;

		Command(GlPipelineHandle& ppline, 
			const GlShaderHandle* progsBegin, const GlShaderHandle* progsEnd)
		:	m_ppline(ppline)
		{
			m_progsCount = 0;
			const GlShaderHandle* prog = progsBegin;
			do
			{
				m_progs[m_progsCount++] = *prog;
			} while(++prog != progsEnd);
		}

		Error operator()(GlCommandBuffer* cmdb)
		{
			Error err = m_ppline._get().create(
				&m_progs[0], &m_progs[0] + m_progsCount,
				cmdb->getGlobalAllocator());

			GlHandleState oldState = m_ppline._setState(
				err ? GlHandleState::ERROR : GlHandleState::CREATED);
			ANKI_ASSERT(oldState == GlHandleState::TO_BE_CREATED);
			(void)oldState;

			return err;
		}
	};

	using Alloc = GlAllocator<GlPipeline>;
	using DeleteCommand = GlDeleteObjectCommand<GlPipeline, Alloc>;
	using Deleter = 
		GlHandleDeferredDeleter<GlPipeline, Alloc, DeleteCommand>;

	Error err = _createAdvanced(
		&commands._get().getQueue().getDevice(),
		commands._get().getGlobalAllocator(), 
		Deleter());

	if(!err)
	{
		_setState(GlHandleState::TO_BE_CREATED);

		commands._pushBackNewCommand<Command>(*this, progsBegin, progsEnd);
	}

	return err;
}
コード例 #2
0
//==============================================================================
Error GlCommandBufferHandle::create(GlDevice* gl, 
	GlCommandBufferInitHints hints)
{
	ANKI_ASSERT(!isCreated());
	ANKI_ASSERT(gl);

	using Alloc = GlAllocator<GlCommandBuffer>;
	Alloc alloc = gl->_getAllocator();

	Error err = _createAdvanced(
		gl,
		alloc, 
		GlHandleDefaultDeleter<GlCommandBuffer, Alloc>());

	if(!err)
	{
		err = _get().create(&gl->_getQueue(), hints);
	}

	return err;
}