コード例 #1
0
const std::vector<U8>* CudaCompiler::compileCubin(bool enablePrints)
{
  staticInit();

  // Cached in memory => done.
  U64 memHash = getMemHash();
  std::vector<U8>* pCubin = s_cubinCache[memHash];
  if (pCubin) {
    return pCubin;
  }
  
  // Compile CUBIN file.
  std::string cubinFile = compileCubinFile(enablePrints);
  if (std::string::npos == cubinFile.length()) {
    fprintf( stderr, "%s Error : cubinfile null.\n", __FUNCTION__);
    return NULL;
  }

  // Load CUBIN.  
  File in( cubinFile, File::Read);
  S32 size = (S32)in.getSize();
  
  std::vector<U8>* cubin = new std::vector<U8>(size + 1);  
  in.read( &(*cubin)[0], size);
  (*cubin)[size] = '\0';
  
  // Add to memory cache.
  s_cubinCache[memHash] = cubin;
  
  return cubin;
}
コード例 #2
0
NETRootInfo::NETRootInfo(Display* display, unsigned long prop, int screen)
    : display(display),
      root(RootWindow(display,screen))
{
    assert(prop==WMMoveResize); (void)prop;
    static const bool _ = (staticInit(),true); (void)_;
}
コード例 #3
0
ファイル: effect.cpp プロジェクト: CombustibleLemonade/LinFX
// TODO
void Effect::draw(){
	if (defaultFramebuffer == -1){
		staticInit();
		init();
	}

	glDisable(GL_LIGHTING);
	glEnable(GL_TEXTURE_2D);

	glPushMatrix();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	screen.draw();

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	glEnable(GL_LIGHTING);
	glDisable(GL_TEXTURE_2D);
}
コード例 #4
0
ファイル: ai.cpp プロジェクト: bysreg/komo
Ai::Ai(std::string ai_profile)
{    
    QString ai_profiles_path = KStandardDirs::locate("appdata", "ai_profiles.lua");

    staticInit();
    lua_getglobal(L, "createProfile");
    lua_pushstring(L, ai_profiles_path.toAscii());
    lua_pushstring(L, ai_profile.c_str());
    if(lua_pcall(L, 2, 1, 0))
        bail(L, "lua_pcall() failed");          /* Error out if Lua file has an error */

    profile_ref = luaL_ref(L, LUA_REGISTRYINDEX); // pop the resulting profile object and store its reference
}
コード例 #5
0
S64 CudaModule::getMemoryUsed(void)
{
  staticInit();

  if (!s_available) {
    return 0;
  }

  size_t free = 0;
  size_t total = 0;
  cuMemGetInfo(&free, &total);
  return total - free;
}
コード例 #6
0
int CudaModule::getDeviceAttribute(CUdevice_attribute attrib)
{
  staticInit();

  if (!s_available) {
    return 0;
  }

  int value;
  checkError( "cuDeviceGetAttribute", 
              cuDeviceGetAttribute(&value, attrib, s_device));
  
  return value;
}
コード例 #7
0
int CudaModule::getComputeCapability(void)
{
  staticInit();
  
  if (!s_available) {
    return 0;
  }

  int major, minor;
  checkError( "cuDeviceComputeCapability", 
              cuDeviceComputeCapability(&major, &minor, s_device));
              
  return major * 10 + minor;
}
コード例 #8
0
std::string CudaCompiler::compileCubinFile(bool enablePrints)
{
  bool bSucceed = true;
  
  staticInit();
    
  /// Check that the source file exists.
  if (!fileExists(m_sourceFile)) {
    fprintf( stderr, "%s : source file does not exist.\n", __FUNCTION__);
    return "";
  }
  
  /// Cache directory does not exist => create it.
  createCacheDir();

  /// Preprocess.
  writeDefineFile();
  std::string cubinFile, finalOpts;
  bSucceed = runPreprocessor(cubinFile, finalOpts);
  
  if (!bSucceed) { 
    fprintf( stderr, "%s : preprocessor failed.\n", __FUNCTION__);
    return ""; 
  }

  /// CUBIN exists => done.
  if (fileExists(cubinFile)) 
  {
#ifndef NDEBUG
    //fprintf( stderr, "CudaCompiler: '%s' already compiled.\n", m_sourceFile.c_str());
#endif
    return cubinFile;
  }
  
  /// Compile.
  if (enablePrints) {
    printf("CudaCompiler: Compiling '%s'...", m_sourceFile.c_str());
  }

  bSucceed = runCompiler( cubinFile, finalOpts);

  if (enablePrints) {
    printf((!bSucceed) ? " Failed.\n" : " Done.\n");
  }
  
  return (bSucceed) ? cubinFile : "";
}
コード例 #9
0
AbstractGreyscaleLampPattern::AbstractGreyscaleLampPattern(int startPosition)
: cycleCount(0), cycleStart(startPosition)
{
	staticInit();
}
コード例 #10
0
AbstractGreyscaleLampPattern::AbstractGreyscaleLampPattern()
: cycleCount(0), cycleStart(0)
{
	staticInit();
}
コード例 #11
0
ファイル: GLContext.hpp プロジェクト: jtyot/morse-pc
 static GLContext&   getDefault      (void)              { staticInit(); FW_ASSERT(s_default); return *s_default; }
コード例 #12
0
ファイル: simpletui.cpp プロジェクト: hephaisto/simpletui
Simpletui::Simpletui()
{
	if(!(instance_count++))
		staticInit();
}
コード例 #13
0
CudaModule::CudaModule(const std::string& cubinFile)
{
  staticInit();
  checkError("cuModuleLoad", cuModuleLoad(&m_module, cubinFile.c_str()));
}
コード例 #14
0
ファイル: Shader.cpp プロジェクト: 4nakin/Aquaria_clean
void Shader::load(const std::string &file, const std::string &fragFile)
{
	staticInit();
	loaded = false;

#ifdef BBGE_BUILD_SHADERS
	if(!_useShaders)
		return;

	debugLog("Shader::load("+file+", "+fragFile+")");

	g_location_texture	= 0;
	g_location_mode		= 0;
	g_location_value	= 0;

	try
	{

		debugLog("Shader::load 1");
		this->vertFile = file;
		this->fragFile = fragFile;
		//
		// If the required extension is present, get the addresses of its 
		// functions that we wish to use...
		//

		const char *vertexShaderStrings[1];
		const char *fragmentShaderStrings[1];
		GLint bVertCompiled;
		GLint bFragCompiled;
		GLint bLinked;
		char str[4096];

		//
		// Create the vertex shader...
		//

		debugLog("Shader::load 2");

		g_vertexShader = glCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );

		unsigned char *vertexShaderAssembly = readShaderFile( file.c_str() );
		vertexShaderStrings[0] = (char*)vertexShaderAssembly;
		glShaderSourceARB( g_vertexShader, 1, vertexShaderStrings, NULL );
		glCompileShaderARB( g_vertexShader);
		delete[] vertexShaderAssembly;

		glGetObjectParameterivARB( g_vertexShader, GL_OBJECT_COMPILE_STATUS_ARB, 
								&bVertCompiled );
		if( bVertCompiled  == false )
		//if (true)
		{
			glGetInfoLogARB(g_vertexShader, sizeof(str), NULL, str);
			std::ostringstream os;
			os << "Vertex Shader Compile Error: " << str;
			debugLog(os.str());
			return;
		}

		//
		// Create the fragment shader...
		//

		debugLog("Shader::load 3");

		g_fragmentShader = glCreateShaderObjectARB( GL_FRAGMENT_SHADER_ARB );

		unsigned char *fragmentShaderAssembly = readShaderFile( fragFile.c_str() );
		fragmentShaderStrings[0] = (char*)fragmentShaderAssembly;
		glShaderSourceARB( g_fragmentShader, 1, fragmentShaderStrings, NULL );
		glCompileShaderARB( g_fragmentShader );
		delete[] fragmentShaderAssembly;

		glGetObjectParameterivARB( g_fragmentShader, GL_OBJECT_COMPILE_STATUS_ARB, 
								&bFragCompiled );
		if( bFragCompiled == false )
		{
			glGetInfoLogARB( g_fragmentShader, sizeof(str), NULL, str );
			std::ostringstream os;
			os << "Fragment Shader Compile Error: " << str;
			debugLog(os.str());
			return;
		}

		debugLog("Shader::load 4");

		//
		// Create a program object and attach the two compiled shaders...
		//
		

		g_programObj = glCreateProgramObjectARB();

		if (!g_programObj || !g_vertexShader || !g_fragmentShader)
		{
			debugLog("programObj / vertexShader / fragmentShader problem");
			return;
		}

		glAttachObjectARB( g_programObj, g_vertexShader );
		glAttachObjectARB( g_programObj, g_fragmentShader );

		//
		// Link the program object and print out the info log...
		//

		glLinkProgramARB( g_programObj );
		glGetObjectParameterivARB( g_programObj, GL_OBJECT_LINK_STATUS_ARB, &bLinked );

		debugLog("Shader::load 5");

		if( bLinked == false )
		{
			glGetInfoLogARB( g_programObj, sizeof(str), NULL, str );
			std::ostringstream os;
			os << "Shader Linking Error: " << str;
			debugLog(os.str());
			return;
		}

		//
		// Locate some parameters by name so we can set them later...
		//

		debugLog("Shader::load 6");

		g_location_texture = glGetUniformLocationARB( g_programObj, "tex" );
		g_location_mode = glGetUniformLocationARB( g_programObj, "mode" );
		g_location_value = glGetUniformLocationARB( g_programObj, "value" );

		debugLog("Shader::load 7");

		loaded = true;
	}
	catch(...)
	{
		debugLog("caught exception in shader::load");
		loaded = false;
	}
#endif
	debugLog("End Shader::load()");
}
コード例 #15
0
ファイル: Timer.hpp プロジェクト: AllioNicholas/CG_AS3
F32 Timer::ticksToSecs(S64 ticks)
{
    if (s_ticksToSecsCoef == -1.0)
        staticInit();
    return (F32)((F64)ticks * s_ticksToSecsCoef);
}