本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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()
}
示例14: generateMipmaps
//==============================================================================
void TexturePtr::generateMipmaps(CommandBufferPtr& commands)
{
ANKI_ASSERT(isCreated());
commands.get().pushBackNewCommand<GenMipmapsCommand>(*this);
}
示例15: bind
//==============================================================================
void TexturePtr::bind(CommandBufferPtr& commands, U32 unit)
{
ANKI_ASSERT(isCreated());
commands.get().pushBackNewCommand<BindTextureCommand>(*this, unit);
}