当前位置: 首页>>代码示例>>C++>>正文


C++ CommandBufferPtr类代码示例

本文整理汇总了C++中CommandBufferPtr的典型用法代码示例。如果您正苦于以下问题:C++ CommandBufferPtr类的具体用法?C++ CommandBufferPtr怎么用?C++ CommandBufferPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandBufferPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create

//==============================================================================
void TexturePtr::create(
	CommandBufferPtr& commands, const Initializer& initS)
{
	ANKI_ASSERT(!isCreated());
	Initializer init(initS);

	// Copy data to temp buffers
	if(init.m_copyDataBeforeReturn)
	{
		for(U layer = 0; layer < MAX_TEXTURE_LAYERS; ++layer)
		{
			for(U level = 0; level < MAX_MIPMAPS; ++level)
			{
				SurfaceData& surf = init.m_data[level][layer];
				if(surf.m_ptr)
				{
					void* newData = commands.get().getInternalAllocator().
						allocate(surf.m_size);

					memcpy(newData, surf.m_ptr, surf.m_size);
					surf.m_ptr = newData;
				}
			}
		}
	}

	Base::create(commands.get().getManager());
	get().setStateAtomically(GlObject::State::TO_BE_CREATED);

	// Fire the command
	commands.get().pushBackNewCommand<CreateTextureCommand>(
		*this, init, init.m_copyDataBeforeReturn);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:34,代码来源:TexturePtr.cpp

示例2: getManager

void Sampler::init(const SamplerInitInfo& init)
{
	m_impl.reset(getAllocator().newInstance<SamplerImpl>(&getManager()));

	CommandBufferPtr cmdb = getManager().newInstance<CommandBuffer>(CommandBufferInitInfo());

	cmdb->m_impl->pushBackNewCommand<CreateSamplerCommand>(this, init);
	cmdb->flush();
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3: run

void Tiler::run(CommandBufferPtr& cmd)
{
	// Issue the min/max job
	U pboIdx = m_r->getFrameCount() % m_outBuffers.getSize();

	cmd->bindPipeline(m_ppline);
	cmd->bindResourceGroup(m_rcGroups[pboIdx], 0, nullptr);

	cmd->dispatchCompute(m_r->getTileCountXY().x(), m_r->getTileCountXY().y(), 1);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例4: init

void Texture::init(const TextureInitInfo& init)
{
	m_impl.reset(getAllocator().newInstance<TextureImpl>(&getManager()));

	CommandBufferPtr cmdb =
		getManager().newInstance<CommandBuffer>(CommandBufferInitInfo());

	cmdb->getImplementation().pushBackNewCommand<CreateTextureCommand>(
		this, init);
	cmdb->flush();
}
开发者ID:galek,项目名称:anki-3d-engine-1,代码行数:11,代码来源:Texture.cpp

示例5: init

void OcclusionQuery::init(OcclusionQueryResultBit condRenderingBit)
{
	m_impl.reset(getAllocator().newInstance<OcclusionQueryImpl>(&getManager()));

	CommandBufferPtr cmdb =
		getManager().newInstance<CommandBuffer>(CommandBufferInitInfo());

	cmdb->getImplementation().pushBackNewCommand<CreateOqCommand>(
		this, condRenderingBit);
	cmdb->flush();
}
开发者ID:kingofoz,项目名称:anki-3d-engine,代码行数:11,代码来源:OcclusionQuery.cpp

示例6: create

//==============================================================================
void FramebufferPtr::create(GrManager* manager, Initializer& init)
{
	CommandBufferPtr cmdb;
	cmdb.create(manager);

	Base::create(cmdb.get().getManager());

	get().setStateAtomically(GlObject::State::TO_BE_CREATED);

	cmdb.get().pushBackNewCommand<CreateFramebufferCommand>(*this, init);
	cmdb.flush();
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:13,代码来源:FramebufferPtr.cpp

示例7: flushCommandBuffer

//==============================================================================
void RenderingThread::flushCommandBuffer(CommandBufferPtr cmdb)
{
	cmdb->getImplementation().makeImmutable();

	{
		LockGuard<Mutex> lock(m_mtx);

		// Set commands
		U64 diff = m_tail - m_head;

		if(diff < m_queue.getSize())
		{
			U64 idx = m_tail % m_queue.getSize();

			m_queue[idx] = cmdb;
			++m_tail;
		}
		else
		{
			ANKI_LOGW("Rendering queue too small");
		}

		m_condVar.notifyOne(); // Wake the thread
	}
}
开发者ID:galek,项目名称:anki-3d-engine-1,代码行数:26,代码来源:RenderingThread.cpp

示例8: ANKI_TRACE_START_EVENT

Error MainRenderer::render(SceneGraph& scene)
{
	ANKI_TRACE_START_EVENT(RENDER);

	// First thing, reset the temp mem pool
	m_frameAlloc.getMemoryPool().reset();

	GrManager& gl = m_r->getGrManager();
	CommandBufferInitInfo cinf;
	cinf.m_hints = m_cbInitHints;
	CommandBufferPtr cmdb = gl.newInstance<CommandBuffer>(cinf);

	// Set some of the dynamic state
	cmdb->setPolygonOffset(0.0, 0.0);

	// Run renderer
	RenderingContext ctx(m_frameAlloc);

	if(m_rDrawToDefaultFb)
	{
		ctx.m_outFb = m_defaultFb;
		ctx.m_outFbWidth = m_width;
		ctx.m_outFbHeight = m_height;
	}

	ctx.m_commandBuffer = cmdb;
	ctx.m_frustumComponent = &scene.getActiveCamera().getComponent<FrustumComponent>();
	ANKI_CHECK(m_r->render(ctx));

	// Blit renderer's result to default FB if needed
	if(!m_rDrawToDefaultFb)
	{
		cmdb->beginRenderPass(m_defaultFb);
		cmdb->setViewport(0, 0, m_width, m_height);

		cmdb->bindPipeline(m_blitPpline);
		cmdb->bindResourceGroup(m_rcGroup, 0, nullptr);

		m_r->drawQuad(cmdb);
		cmdb->endRenderPass();
	}

	// Flush the command buffer
	cmdb->flush();

	// Set the hints
	m_cbInitHints = cmdb->computeInitHints();

	ANKI_TRACE_STOP_EVENT(RENDER);

	return ErrorCode::NONE;
}
开发者ID:,项目名称:,代码行数:52,代码来源:

示例9: prepare

//==============================================================================
void RenderingThread::threadLoop()
{
	prepare();

	while(1)
	{
		CommandBufferPtr cmd;

		// Wait for something
		{
			LockGuard<Mutex> lock(m_mtx);
			while(m_tail == m_head)
			{
				m_condVar.wait(m_mtx);
			}

			// Check signals
			if(m_renderingThreadSignal == 1)
			{
				// Requested to stop
				break;
			}

			U64 idx = m_head % m_queue.getSize();
			// Pop a command
			cmd = m_queue[idx];
			m_queue[idx] = CommandBufferPtr(); // Insert empty cmd buffer

			++m_head;
		}

		ANKI_TRACE_START_EVENT(GL_THREAD);
		Error err = cmd->getImplementation().executeAllCommands();
		ANKI_TRACE_STOP_EVENT(GL_THREAD);

		if(err)
		{
			ANKI_LOGE("Error in rendering thread. Aborting");
			abort();
		}
	}

	finish();
}
开发者ID:galek,项目名称:anki-3d-engine-1,代码行数:45,代码来源:RenderingThread.cpp

示例10: blit

//==============================================================================
void FramebufferPtr::blit(CommandBufferPtr& cmdb,
	const FramebufferPtr& b,
	const Array<U32, 4>& sourceRect,
	const Array<U32, 4>& destRect,
	GLbitfield attachmentMask,
	Bool linear)
{
	cmdb.get().pushBackNewCommand<BlitFramebufferCommand>(
		*this, b, sourceRect, destRect, attachmentMask, linear);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:11,代码来源:FramebufferPtr.cpp

示例11: buildCommandBuffers

//==============================================================================
Error Fs::buildCommandBuffers(
	RenderingContext& ctx, U threadId, U threadCount) const
{
	// Get some stuff
	VisibilityTestResults& vis =
		ctx.m_frustumComponent->getVisibilityTestResults();

	U problemSize = vis.getCount(VisibilityGroupType::RENDERABLES_FS);
	PtrSize start, end;
	ThreadPoolTask::choseStartEnd(
		threadId, threadCount, problemSize, start, end);

	if(start == end)
	{
		// Early exit
		return ErrorCode::NONE;
	}

	// Create the command buffer and set some state
	CommandBufferInitInfo cinf;
	cinf.m_secondLevel = true;
	cinf.m_framebuffer = m_fb;
	CommandBufferPtr cmdb =
		m_r->getGrManager().newInstance<CommandBuffer>(cinf);
	ctx.m_fs.m_commandBuffers[threadId] = cmdb;

	cmdb->setViewport(0, 0, m_width, m_height);
	cmdb->setPolygonOffset(0.0, 0.0);
	cmdb->bindResourceGroup(m_globalResources, 1, &ctx.m_is.m_dynBufferInfo);

	// Start drawing
	Error err = m_r->getSceneDrawer().drawRange(Pass::MS_FS,
		*ctx.m_frustumComponent,
		cmdb,
		vis.getBegin(VisibilityGroupType::RENDERABLES_FS) + start,
		vis.getBegin(VisibilityGroupType::RENDERABLES_FS) + end);

	return err;
}
开发者ID:galek,项目名称:anki-3d-engine-1,代码行数:40,代码来源:Fs.cpp

示例12: Command

//==============================================================================
void CommandBufferPtr::pushBackOtherCommandBuffer(
	CommandBufferPtr& commands)
{
	class Command: public GlCommand
	{
	public:
		CommandBufferPtr m_commands;

		Command(CommandBufferPtr& commands)
		:	m_commands(commands)
		{}

		Error operator()(CommandBufferImpl*)
		{
			return m_commands.get().executeAllCommands();
		}
	};

	commands.get().makeImmutable();
	get().pushBackNewCommand<Command>(commands);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:22,代码来源:CommandBufferPtr.cpp

示例13: ANKI_TEST

ANKI_TEST(Gr, SimpleDrawcall)
{
	COMMON_BEGIN()

	PipelinePtr ppline = createSimplePpline(VERT_SRC, FRAG_SRC, *gr);
	FramebufferPtr fb = createDefaultFb(*gr);

	U iterations = 100;
	while(iterations--)
	{
		HighRezTimer timer;
		timer.start();

		gr->beginFrame();

		CommandBufferInitInfo cinit;
		CommandBufferPtr cmdb = gr->newInstance<CommandBuffer>(cinit);

		cmdb->setViewport(0, 0, WIDTH, HEIGHT);
		cmdb->setPolygonOffset(0.0, 0.0);
		cmdb->bindPipeline(ppline);
		cmdb->beginRenderPass(fb);
		cmdb->drawArrays(3);
		cmdb->endRenderPass();
		cmdb->flush();

		gr->swapBuffers();

		timer.stop();
		const F32 TICK = 1.0 / 30.0;
		if(timer.getElapsedTime() < TICK)
		{
			HighRezTimer::sleep(TICK - timer.getElapsedTime());
		}
	}

	COMMON_END()
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例14: generateMipmaps

//==============================================================================
void TexturePtr::generateMipmaps(CommandBufferPtr& commands)
{
	ANKI_ASSERT(isCreated());
	commands.get().pushBackNewCommand<GenMipmapsCommand>(*this);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:6,代码来源:TexturePtr.cpp

示例15: bind

//==============================================================================
void TexturePtr::bind(CommandBufferPtr& commands, U32 unit)
{
	ANKI_ASSERT(isCreated());
	commands.get().pushBackNewCommand<BindTextureCommand>(*this, unit);
}
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:6,代码来源:TexturePtr.cpp


注:本文中的CommandBufferPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。