//============================================================================== 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); }
//============================================================================== 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(); }
//============================================================================== 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); }
//============================================================================== 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); }
//============================================================================== void TexturePtr::generateMipmaps(CommandBufferPtr& commands) { ANKI_ASSERT(isCreated()); commands.get().pushBackNewCommand<GenMipmapsCommand>(*this); }
//============================================================================== void TexturePtr::bind(CommandBufferPtr& commands, U32 unit) { ANKI_ASSERT(isCreated()); commands.get().pushBackNewCommand<BindTextureCommand>(*this, unit); }
//============================================================================== void FramebufferPtr::bind(CommandBufferPtr& cmdb) { cmdb.get().pushBackNewCommand<BindFramebufferCommand>(*this); }
Error operator()(CommandBufferImpl*) { return m_commands.get().executeAllCommands(); }