Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Hardware/Video/OpenGL/Shaders/glShaderProgram.cpp

Diff revisions: vs.
  @@ -72,13 +72,15 @@
72 72 validateInternal();
73 73 // We dump the shader binary only if it wasn't loaded from one
74 74 if (!_loadedFromBinary && GFX_DEVICE.getGPUVendor() == GPU_VENDOR_NVIDIA) {
75 - STUBBED("GLSL binary dump/load is only enabled for nVidia GPUS. Catalyst 14.x destroys uniforms on shader dump, for whatever reason. - Ionut")
75 + STUBBED("GLSL binary dump/load is only enabled for nVidia GPUS. "
76 + "Catalyst 14.x destroys uniforms on shader dump, for whatever reason. - Ionut")
76 77 // Get the size of the binary code
77 78 GLint binaryLength = 0;
78 79 glGetProgramiv(_shaderProgramId, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
79 80 // allocate a big enough buffer to hold it
80 81 void* binary = (void*)malloc(binaryLength);
81 - DIVIDE_ASSERT(binary != NULL, "glShaderProgram error: could not allocate memory for the program binary!");
82 + DIVIDE_ASSERT(binary != NULL,
83 + "glShaderProgram error: could not allocate memory for the program binary!");
82 84 // and fill the buffer with the binary code
83 85 glGetProgramBinary(_shaderProgramId, binaryLength, NULL, &_binaryFormat, binary);
84 86 // dump the buffer to file
  @@ -117,7 +119,7 @@
117 119 if (length > 1) {
118 120 // Delete our OK string, and start on a new line
119 121 validationBuffer = "\n -- ";
120 - // This little trick avoids a "New/Delete" set of calls and still gives us a linear array of char's
122 + // This little trick avoids a "NEW/DELETE" set of calls and still gives us a linear array of char's
121 123 vectorImpl<char> shaderProgramLog(length);
122 124 glGetProgramInfoLog(_shaderProgramIDTemp, length, NULL, &shaderProgramLog[0]);
123 125 // Append the program's log to the output message
  @@ -125,7 +127,10 @@
125 127 // To avoid overflowing the output buffers (both CEGUI and Console), limit the maximum output size
126 128 if (validationBuffer.size() > 4096 * 16) {
127 129 // On some systems, the program's disassembly is printed, and that can get quite large
128 - validationBuffer.resize(static_cast<stringAlg::stringSize>(4096 * 16 - strlen(Locale::get("GLSL_LINK_PROGRAM_LOG")) - 10));
130 + validationBuffer.resize(static_cast<stringAlg::stringSize>(4096 *
131 + 16 -
132 + strlen(Locale::get("GLSL_LINK_PROGRAM_LOG")) -
133 + 10));
129 134 // Use the simple "truncate and inform user" system (a.k.a. add dots and delete the rest)
130 135 validationBuffer.append(" ... ");
131 136 }
  @@ -136,7 +141,8 @@
136 141
137 142 /// Remove a shader stage from this program
138 143 void glShaderProgram::detachShader(Shader* const shader) {
139 - DIVIDE_ASSERT(_threadedLoadComplete, "glShaderProgram error: tried to detach a shader from a program that didn't finish loading!");
144 + DIVIDE_ASSERT(_threadedLoadComplete,
145 + "glShaderProgram error: tried to detach a shader from a program that didn't finish loading!");
140 146 glDetachShader(_shaderProgramId, shader->getShaderId());
141 147 shader->removeParentProgram(this);
142 148 }
  @@ -373,7 +379,8 @@
373 379 stringAlg::stringSize propPositionVertex = name.find_first_of(",");
374 380 // Get the position of the first "." symbol
375 381 stringAlg::stringSize propPosition = name.find_first_of(".");
376 - // If we have effect properties, we extract them from the name (starting from the first "." symbol to the first "," symbol)
382 + // If we have effect properties, we extract them from the name
383 + // (starting from the first "." symbol to the first "," symbol)
377 384 if (propPosition != stringImpl::npos) {
378 385 shaderProperties = "." + name.substr(propPosition + 1, propPositionVertex - propPosition - 1);
379 386 }
  @@ -407,7 +414,9 @@
407 414 // If this is the first time this shader is loaded ...
408 415 if (!_shaderStage[type]){
409 416 // Use GLSW to read the appropriate part of the effect file based on the specified stage and properties
410 - const char* sourceCode = glswGetShader(shaderCompileName[type].c_str(), lineCountOffset[type], _refreshStage[type]);
417 + const char* sourceCode = glswGetShader(shaderCompileName[type].c_str(),
418 + lineCountOffset[type],
419 + _refreshStage[type]);
411 420 // GLSW may fail for various reasons (not a valid effect stage, invalid name, etc)
412 421 if (sourceCode) {
413 422 // If reading was successful, grab the entire code in a string
  @@ -416,7 +425,10 @@
416 425 Util::replaceStringInPlace(codeString, "//__CUSTOM_DEFINES__", shaderSourceHeader);
417 426 Util::replaceStringInPlace(codeString, "//__CUSTOM_UNIFORMS__", shaderSourceUniforms[type]);
418 427 // Load our shader from the final string and save it in the manager in case a new Shader Program needs it
419 - _shaderStage[type] = ShaderManager::getInstance().loadShader(shaderCompileName[type], codeString, type, _refreshStage[type]);
428 + _shaderStage[type] = ShaderManager::getInstance().loadShader(shaderCompileName[type],
429 + codeString,
430 + type,
431 + _refreshStage[type]);
420 432 }
421 433 }
422 434 // Show a message, in debug, if we don't have a shader for this stage
  @@ -432,7 +444,8 @@
432 444 }
433 445
434 446 // try to link the program in a separate thread
435 - return GFX_DEVICE.loadInContext(_threadedLoading && !_loadedFromBinary ? GFX_RENDERING_CONTEXT/*GFX_LOADING_CONTEXT*/ : GFX_RENDERING_CONTEXT,
447 + return GFX_DEVICE.loadInContext(/*_threadedLoading && !_loadedFromBinary ? GFX_LOADING_CONTEXT : */
448 + GFX_RENDERING_CONTEXT,
436 449 DELEGATE_BIND(&glShaderProgram::threadedLoad, this, name));
437 450 }
438 451
  @@ -453,7 +466,8 @@
453 466 return -1;
454 467 }
455 468
456 - DIVIDE_ASSERT(_threadedLoadComplete, "glShaderProgram error: tried to query a shader program before threaded load completed!");
469 + DIVIDE_ASSERT(_threadedLoadComplete,
470 + "glShaderProgram error: tried to query a shader program before threaded load completed!");
457 471
458 472 // Check the cache for the location
459 473 ShaderVarMap::const_iterator it = _shaderVars.find(name);
  @@ -462,7 +476,8 @@
462 476 }
463 477
464 478 // Cache miss. Query OpenGL for the location
465 - GLint location = uniform ? glGetUniformLocation(_shaderProgramId, name.c_str()) : glGetAttribLocation(_shaderProgramId, name.c_str());
479 + GLint location = uniform ? glGetUniformLocation(_shaderProgramId, name.c_str()) :
480 + glGetAttribLocation(_shaderProgramId, name.c_str());
466 481
467 482 // Save it for later reference
468 483 hashAlg::emplace(_shaderVars, name, location);