Esempio n. 1
0
ProfilerBlock* Profiler::alloc_block( const char* name )
{
    ENGINE_ASSERT(numBlocks_ < TOTAL_BLOCK_NUM - 1, "profile blocks overflow.");
    ProfilerBlock* newBlock = blocks_ + (numBlocks_++);
    newBlock->name_ = name;
    return newBlock;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
LinearAllocator::~LinearAllocator()
{
    if (m_backing)
    {
        m_backing->deallocate(m_physical_start);
        ENGINE_ASSERT(m_offset == 0, "Memory leak of %ld bytes, maybe you forgot to call clear()?", m_offset);
    }
}
void CEglTest_TestStep_StressLoad::LoadGpuMemoryL()
    {
    const TInt KMaxSurfaceAllocs = 1000;
    CSurface **surfaces = new CSurface*[KMaxSurfaceAllocs];
    ENGINE_ASSERT(surfaces);
    TInt nSurfaces = 0;
    TInt err;
    while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuMemory]))     
        {
        ENGINE_ASSERT(nSurfaces < KMaxSurfaceAllocs);
        CSurface* s = CSurface::SurfaceFactoryL(ESurfTypePBuffer);
        if (s)
            {
            TRAP(err, s->CreateL(ELargeSurface));
            if (err == KErrNone)
                {
                surfaces[nSurfaces++] = s;
                TRAP(err, s->DrawContentL(TRgb(0x10, 0x20, 0xB0)));
                }
            else
                {
                delete s;
                s = NULL;
                }
            }
        if (!s)
            {
            User::After(100 * 1000);
            TInt nRelease = nSurfaces / 4;
            for(TInt i = 0; i < nRelease; i++)
                {
                delete surfaces[--nSurfaces];
                surfaces[nSurfaces] = NULL;
                }
            User::After(100 * 1000); // 100 ms. 
            }
        }
    while(nSurfaces)
        {
        delete surfaces[--nSurfaces];
        }
    delete [] surfaces;
    eglReleaseThread();
    }
Esempio n. 4
0
int data_compiler_main(bx::CommandLine* cmdline)
{
    delete_file(DC_RESULT);

    int err = kErrorSuccess;
    uint32_t timeMS = ::GetTickCount();

    LOG_INIT("DataCompilerLog.html", "Data Compiler");
    MemoryConfig cfg;
    memset(&cfg, 0, sizeof cfg);
    cfg.m_debugMemSize = SIZE_MB(2);
    g_memoryMgr.init(cfg);

#ifdef DC_DUMP_PROFILE
    g_profiler.init(TOTAL_BLOCK_NUM);
#endif

    register_engine_factories();

    g_config = new DC_Config;
    const char* inputChar = cmdline->findOption('i');
    if(!inputChar) inputChar = "intermediate";
    const char* outputFolderChar = cmdline->findOption('o');
    if(!outputFolderChar) outputFolderChar = "data";
    const char* threadChar = cmdline->findOption('t');
    if(threadChar) g_config->m_numThreads = atoi(threadChar);
    g_config->m_ignoreTextures = cmdline->hasArg("ignore_texture");
    g_config->m_slient = cmdline->hasArg("slient");
    g_config->m_bundled = cmdline->hasArg("bundle");
    g_config->m_forceRecompile = cmdline->hasArg('b');

    create_folder("data");
    g_config->m_database.load(DC_DATABASE);

    g_config->m_inputDir = inputChar;
    string_replace(g_config->m_inputDir, "\\", "/");
    add_trailing_slash(g_config->m_inputDir);
    g_config->m_topFolder = get_top_folder(g_config->m_inputDir);
    g_config->m_outputDir = input_to_output(g_config->m_inputDir);

    ENGINE_ASSERT(g_config->m_topFolder.length(), "top folder error.");
    string_replace(g_config->m_outputDir, "\\", "/");
    add_trailing_slash(g_config->m_outputDir);
    std::string secondFolder = remove_top_folder(g_config->m_outputDir);
    if(secondFolder.length()) g_config->m_packageName = get_top_folder(secondFolder);
    LOGI("input = %s, output = %s, top-folder = %s, package-name=%s",
        g_config->m_inputDir.c_str(),
        g_config->m_outputDir.c_str(),
        g_config->m_topFolder.c_str(),
        g_config->m_packageName.c_str());

    level_processing();
    resources_process();
    if(g_config->m_compilers.size() < 10) g_config->m_numThreads = 0;
    if(g_config->m_numThreads < 2)
    {
        for(size_t i=0; i<g_config->m_compilers.size(); ++i)
        {
            g_config->m_compilers[i]->go();
        }
    }
    else
    {
        const int maxThreads = 8;
        if(g_config->m_numThreads > maxThreads) g_config->m_numThreads = maxThreads;
        uint32_t totalNum = g_config->m_compilers.size();
        uint32_t numPerThread = totalNum / g_config->m_numThreads + 1;
        bx::Thread* threads[maxThreads];
        std::vector<BaseCompiler*> compilers[maxThreads];
        uint32_t currIndex = 0;

        for (int i=0; i<g_config->m_numThreads; ++i)
        {
            uint32_t elementNum = numPerThread;
            uint32_t numLeft = totalNum - currIndex;
            if(numLeft < elementNum) elementNum = numLeft;
            if(elementNum == 0) continue;
            std::vector<BaseCompiler*>& comArray = compilers[i];
            comArray.resize(elementNum);
            memcpy(&comArray[0], &g_config->m_compilers[currIndex], elementNum*sizeof(void*));
            currIndex += elementNum;
            if(i == 0) continue;
            threads[i] = new bx::Thread();
            threads[i]->init(thread_compile, &comArray);
        }
        //main thread with other threads.
        thread_compile(&compilers[0]);
        for (int i=1; i<g_config->m_numThreads; ++i)
        {
            delete threads[i];
        }
    }
    g_config->post_process();
    package_processing();

    timeMS = ::GetTickCount() - timeMS;
    if(!g_config->m_slient) g_config->m_error.show_error();
    g_config->m_database.save(DC_DATABASE);
    g_config->m_database.m_files.clear();
    SAFE_DELETE(g_config);

#ifdef DC_DUMP_PROFILE
    g_profiler.dump_to_file("data_compiler_profile.txt", true, true);
    g_profiler.shutdown();
#endif

    g_memoryMgr.shutdown();

    LOGD("******************************************************");
    LOGD("******************************************************");
    LOGD("* TOTAL TIME COST = %d[MS] *", timeMS);
    LOGD("******************************************************");
    LOGD("******************************************************");
    LOG_TERM();

	return err;
}
Esempio n. 5
0
 RenderDriverPtr GetRender() {
     ENGINE_ASSERT(this->_renderGL != NULL, "RenderGL3 is not initalized");
     return _renderGL;
 }