コード例 #1
0
ファイル: HLSL2GLSL.cpp プロジェクト: Irina4ik/hlsl2glslfork
static bool InitProcess()
{
	if (s_ThreadInitialized != OS_INVALID_TLS_INDEX)
		return true;
	
	s_ThreadInitialized = OS_AllocTLSIndex();
	if (s_ThreadInitialized == OS_INVALID_TLS_INDEX)
	{
		assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
		return false;
	}
	
	if (!InitializePoolIndex())
	{
		assert(0 && "InitProcess(): Failed to initalize global pool");
		return false;
	}
	
	if (!InitializeParseContextIndex())
	{
		assert(0 && "InitProcess(): Failed to initalize parse context");
		return false;
	}
	
	InitThread();
	return true;
}
コード例 #2
0
bool InitProcess()
{
    if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
		//
		// Function is re-entrant.
		//
        return true;
	}

    ThreadInitializeIndex = OS_AllocTLSIndex();

    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
        assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
        return false;
	}


    if (!InitializePoolIndex()) {
        assert(0 && "InitProcess(): Failed to initalize global pool");
        return false;
	}

    if (!InitializeParseContextIndex()) {
        assert(0 && "InitProcess(): Failed to initalize parse context");
        return false;
	}

	InitThread();
    return true;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: CRivlaldo/hlsl2glslfork
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	switch (fdwReason)
	{
		case DLL_PROCESS_ATTACH:

            if (!InitProcess())
                return FALSE;
            break;
		case DLL_THREAD_ATTACH:

            if (!InitThread())
                return FALSE;
            break;

		case DLL_THREAD_DETACH:

			if (!DetachThread())
				return FALSE;
			break;

		case DLL_PROCESS_DETACH:

			DetachProcess();
			break;

		default:
			assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
			return FALSE;
	}

	return TRUE;
}
コード例 #4
0
int main (int argc, char * argv[])
{

    srand(time(NULL));
    srand((unsigned int)time((time_t *)NULL));

    printf("Instructions:\n"
            "Hold down the left mouse button to rotate image: \n"
            "\n"
            "Hold 'm' while holding down the right mouse to move the end\n"
            "Hold 't' while holding down the right mouse to rotate the tangent \n"
            "\n"
            "Press 'Esc' to quit\n"
    );

    InitGLUT(argc, argv);
    InitLights();
    InitStuff ();



    InitThread(argc, argv);


    glutMainLoop ();
}
コード例 #5
0
ファイル: InitializeDll.cpp プロジェクト: casseveritt/glslang
bool InitProcess()
{
    glslang::GetGlobalLock();

    if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
		//
		// Function is re-entrant.
		//

        glslang::ReleaseGlobalLock();
        return true;
	}

    ThreadInitializeIndex = OS_AllocTLSIndex();

    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
        assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");

        glslang::ReleaseGlobalLock();
        return false;
	}

    if (! InitializePoolIndex()) {
        assert(0 && "InitProcess(): Failed to initalize global pool");

        glslang::ReleaseGlobalLock();
        return false;
	}

	InitThread();

    glslang::ReleaseGlobalLock();
    return true;
}
コード例 #6
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Do an actual link on the given compile objects.
//
// Return:  The return value of is really boolean, indicating
// success or failure.
//
int ShLink(
    const ShHandle linkHandle,
    const ShHandle compHandles[],
    const int numHandles,
    ShHandle uniformMapHandle,
    short int** uniformsAccessed,
    int* numUniformsAccessed)

{
    if (!InitThread())
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
    TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
    if (linker == 0)
        return 0;

    int returnValue;
    GlobalPoolAllocator.push();
    returnValue = ShLinkExt(linkHandle, compHandles, numHandles);
    GlobalPoolAllocator.pop();

    if (returnValue)
        return 1;

    return 0;
}
コード例 #7
0
ファイル: HLSL2GLSL.cpp プロジェクト: Irina4ik/hlsl2glslfork
ShHandle C_DECL Hlsl2Glsl_ConstructCompiler( const EShLanguage language )
{
   if (!InitThread())
      return 0;

   HlslCrossCompiler* compiler = new HlslCrossCompiler(language);
   return compiler;
}
コード例 #8
0
ファイル: dllmain.c プロジェクト: mutoso-mirrors/reactos
INT WINAPI
DllMain(
   IN PVOID hInstanceDll,
   IN ULONG dwReason,
   IN PVOID reserved)
{
   switch (dwReason)
   {
      case DLL_PROCESS_ATTACH:
         User32Instance = hInstanceDll;
         if (!RegisterClientPFN())
         {
             return FALSE;
         }

         if (!Init())
            return FALSE;
         if (!InitThread())
         {
            Cleanup();
            return FALSE;
         }

         /* Initialize message spying */
        if (!SPY_Init()) return FALSE;

         break;

      case DLL_THREAD_ATTACH:
         if (!InitThread())
            return FALSE;
         break;

      case DLL_THREAD_DETACH:
         CleanupThread();
         break;

      case DLL_PROCESS_DETACH:
         if (hImmInstance) FreeLibrary(hImmInstance);
         CleanupThread();
         Cleanup();
         break;
   }

   return TRUE;
}
コード例 #9
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions)
{
    if (!InitThread())
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions));
    
    return reinterpret_cast<void*>(base);
}
コード例 #10
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions)
{
    if (!InitThread())
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions));

    return reinterpret_cast<void*>(base);
}
コード例 #11
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
ShHandle ShConstructUniformMap()
{
    if (!InitThread())
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap());

    return reinterpret_cast<void*>(base);
}
コード例 #12
0
ファイル: CTeachingBox.cpp プロジェクト: 6VV/TeachingBox
void CTeachingBox::Init()
{
	InitLayout();
	InitSignalSlots();
	InitThread();
	SlotChangeToScreenSetting();
	SlotOnButtonModelClicked();

	CTcpManager::GetInstance();	/*初始化net,用于在程序启动时建立连接*/
}
コード例 #13
0
ファイル: Simulation.cpp プロジェクト: mormegil-cz/fel-cvut
CProcess::CProcess(bool createThread)
{
    terminated = false;
    event = NULL;                // zatim nema zaznam o udalosti
    char x[20];
    itoa((long int) this, x, 16);
    SetName(string("Process ")+ x);   // nastavi name v CLinkage
    if (createThread) InitThread();      // vola CreateThread, ktera vytvori vlakno 
                                      // ve stavu SUSPENDED
}
コード例 #14
0
ファイル: HLSL2GLSL.cpp プロジェクト: Irina4ik/hlsl2glslfork
const char* C_DECL Hlsl2Glsl_GetInfoLog( const ShHandle handle )
{
   if (!InitThread())
      return 0;
   if (handle == 0)
      return 0;
   HlslCrossCompiler* base = static_cast<HlslCrossCompiler*>(handle);
   TInfoSink* infoSink = &(base->getInfoSink());
   infoSink->info << infoSink->debug.c_str();
   return infoSink->info.c_str();
}
コード例 #15
0
int InterruptTask::Init(char *name, int priority, int intNum){
	mTaskName = name;

	mIntNum = intNum;

	if(InitThread(&mIntThreadId, priority, IntThread, (void *)(this))==-1){
		printf("%s:InitThread:IntThread failed\n", mTaskName);
		exit(1);
	}

	return 1;
}
コード例 #16
0
ファイル: ShaderLang.cpp プロジェクト: awangk/glslang
//
// Turn the shader strings into a parse tree in the TIntermediate.
//
// Returns true for success.
//
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
                    bool forwardCompatible, EShMessages messages)
{
    if (! InitThread())
        return false;
    
    pool = new TPoolAllocator();
    SetThreadPoolAllocator(*pool);
    if (! preamble)
        preamble = "";

    return CompileDeferred(compiler, strings, numStrings, nullptr, preamble, EShOptNone, builtInResources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, *intermediate);
}
コード例 #17
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Return the index for OpenGL to use for knowing where a uniform lives.
//
// Return:  The return value of is really boolean, indicating
// success or failure.
//
int ShGetUniformLocation(const ShHandle handle, const char* name)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return -1;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    TUniformMap* uniformMap= base->getAsUniformMap();
    if (uniformMap == 0)
        return -1;

    return uniformMap->getLocation(name);
}
コード例 #18
0
ファイル: ShaderLang.cpp プロジェクト: achellies/WinCEWebKit
//
// Return any object code.
//
const char* ShGetObjectCode(const ShHandle handle)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(handle);
    TInfoSink* infoSink;

    if (base->getAsCompiler())
        infoSink = &(base->getAsCompiler()->getInfoSink());

    return infoSink->obj.c_str();
}
コード例 #19
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Return the resulting binary code from the link process.  Structure
// is machine dependent.
//
const void* ShGetExecutable(const ShHandle handle)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    
    TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
    if (linker == 0)
        return 0;

    return linker->getObjectCode();
}
コード例 #20
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Let the linker know where the predefined attributes have to live.
//
int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    TLinker* linker = static_cast<TLinker*>(base->getAsLinker());

    if (linker == 0)
        return 0;

    linker->setFixedAttributeBindings(table);
    return 1;
}
コード例 #21
0
ファイル: ShaderLang.cpp プロジェクト: achellies/WinCEWebKit
//
// Return any compiler log of messages for the application.
//
const char* ShGetInfoLog(const ShHandle handle)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(handle);
    TInfoSink* infoSink = 0;

    if (base->getAsCompiler())
        infoSink = &(base->getAsCompiler()->getInfoSink());

    infoSink->info << infoSink->debug.c_str();
    return infoSink->info.c_str();
}
コード例 #22
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Some attribute locations are off-limits to the linker...
//
int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
    if (linker == 0)
        return 0;

    linker->setExcludedAttributes(attributes, count);

    return 1;
}
コード例 #23
0
ファイル: ShaderLang.cpp プロジェクト: achellies/WinCEWebKit
//
// Driver calls these to create and destroy compiler objects.
//
ShHandle ShConstructCompiler(EShLanguage language, EShSpec spec, const TBuiltInResource* resources)
{
    if (!InitThread())
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, spec));
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;

    // Generate built-in symbol table.
    if (!GenerateBuiltInSymbolTable(language, spec, *resources, compiler->getInfoSink(), compiler->getSymbolTable())) {
        ShDestruct(base);
        return 0;
    }

    return reinterpret_cast<void*>(base);
}
コード例 #24
0
//
// Do an actual compile on the given strings.  The result is left 
// in the given compile object.
//
// Return:  The return value of ShCompile is really boolean, indicating
// success or failure.
//
int ShCompile(
    const ShHandle handle,
    const char* const shaderStrings[],
    const int numStrings,
    int compileOptions)
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;

    bool success = compiler->compile(shaderStrings, numStrings, compileOptions);
    return success ? 1 : 0;
}
コード例 #25
0
//
// Driver calls these to create and destroy compiler objects.
//
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
                             ShShaderOutput output,
                             const ShBuiltInResources* resources)
{
    if (!InitThread())
        return 0;

    TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;

    // Generate built-in symbol table.
    if (!compiler->Init(*resources)) {
        ShDestruct(base);
        return 0;
    }

    return reinterpret_cast<void*>(base);
}
コード例 #26
0
int clsThread::Run()
{
	if (!InitThread()) return -1;

	_pulse pulse;
	for (m_nCount = 0; ; m_nCount ++) {

		m_bReady = TRUE;
		ReceivePulse(&pulse);
		m_bReady = FALSE;				//begin working

		if (pulse.code == PULSECODE_EXIT) break;

		if (!EveryRun()) break;

		SetEvent();
	}

	ExitThread();
	SetEvent();
	return 1;
}
コード例 #27
0
ファイル: IConcurrentPool.cpp プロジェクト: zrma/SSSS
	void IConcurrentPool::Init()
	{
		mWork = std::make_shared<boost::asio::io_service::work>( mDispatcher );

		const auto f = [ = ]()
		{
			LThreadId = GetCurrentThreadId();

			LThreadCallHistory = std::make_shared<ThreadCallHistory>( LThreadId );
			InterlockedPushEntrySList( &GThreadCallHistory, reinterpret_cast<PSLIST_ENTRY>(LThreadCallHistory.get()) );

			LThreadCallElapsedRecord = std::make_shared<ThreadCallElapsedRecord>( LThreadId );
			InterlockedPushEntrySList( &GThreadCallElapsedRecord, reinterpret_cast<PSLIST_ENTRY>(LThreadCallElapsedRecord.get()) );

			InitThread();
			Run();
		};

		for( std::size_t i = 0; i < mPoolSize; ++i )
		{
			mGroup.create_thread( f );
		}
	}
コード例 #28
0
ファイル: test_planner.cpp プロジェクト: alexlee-gk/surgical
int main (int argc, char * argv[])
{

  //srand(time(NULL));
  //srand((unsigned int)time((time_t *)NULL));
  
  printf("Instructions:\n"
      "Hold down the left mouse button to rotate image: \n"
      "\n"
      "Hold 'm' while holding down the right mouse to move the end\n"
      "Hold 't' while holding down the right mouse to rotate the tangent \n"
      "\n"
      "Press 'Esc' to quit\n"
      );
  InitGLUT(argc, argv);
  InitLights();
  InitStuff ();
  InitThread(argc, argv);

  signal(SIGINT, &interruptHandler);
  cout << "Running with CPU Threads = " << NUM_CPU_THREADS << endl; 
  glutMainLoop ();
}
コード例 #29
0
ファイル: XSPThread.cpp プロジェクト: dx01259/libxsp
CXSPThread::CXSPThread()
{
	sem_init(&this->m_sem, 0, 0);
	InitThread(NULL, NULL);
}
コード例 #30
0
ファイル: ShaderLang.cpp プロジェクト: Aetherdyne/glintercept
//
// Do an actual compile on the given strings.  The result is left 
// in the given compile object.
//
// Return:  The return value of ShCompile is really boolean, indicating
// success or failure.
//
int ShCompile(
    const ShHandle handle,
    const char* const shaderStrings[],
    const int numStrings,
    const EShOptimizationLevel optLevel,
    const TBuiltInResource* resources,
    int debugOptions
    )
{
    if (!InitThread())
        return 0;

    if (handle == 0)
        return 0;

    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
    TCompiler* compiler = base->getAsCompiler();
    if (compiler == 0)
        return 0;
    
    GlobalPoolAllocator.push();
    compiler->infoSink.info.erase();
    compiler->infoSink.debug.erase();

    if (numStrings == 0)
        return 1;

    TIntermediate intermediate(compiler->infoSink);
    TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
    
    GenerateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());

    TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
    parseContext.initializeExtensionBehavior();

    GlobalParseContext = &parseContext;
    
    setInitialState();

    InitPreprocessor();    
    //
    // Parse the application's shaders.  All the following symbol table
    // work will be throw-away, so push a new allocation scope that can
    // be thrown away, then push a scope for the current shader's globals.
    //
    bool success = true;
    
    symbolTable.push();
    if (!symbolTable.atGlobalLevel())
        parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");

    if (parseContext.insertBuiltInArrayAtGlobalLevel())
        success = false;

    int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext);
    if (ret)
        success = false;

    if (success && parseContext.treeRoot) {
        if (optLevel == EShOptNoGeneration)
            parseContext.infoSink.info.message(EPrefixNone, "No errors.  No code generation or linking was requested.");
        else {
            success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);

            if (success) {

                if (debugOptions & EDebugOpIntermediate)
                    intermediate.outputTree(parseContext.treeRoot);

                //
                // Call the machine dependent compiler
                //
                if (! compiler->compile(parseContext.treeRoot))
                    success = false;
            }
        }
    } else if (!success) {
        parseContext.infoSink.info.prefix(EPrefixError);
        parseContext.infoSink.info << parseContext.numErrors << " compilation errors.  No code generated.\n\n";
        success = false;
        if (debugOptions & EDebugOpIntermediate)
            intermediate.outputTree(parseContext.treeRoot);
    }

    intermediate.remove(parseContext.treeRoot);

    //
    // Ensure symbol table is returned to the built-in level,
    // throwing away all but the built-ins.
    //
    while (! symbolTable.atSharedBuiltInLevel())
        symbolTable.pop();

    FinalizePreprocessor();
    //
    // Throw away all the temporary memory used by the compilation process.
    //
    GlobalPoolAllocator.pop();

    return success ? 1 : 0;
}