Because attempting to compile the new voxel texture shader causes my system

(Ubuntu LTS, Intel graphics) to hang, change it to compile lazily when
activated.
This commit is contained in:
Andrzej Kapolka 2014-07-07 11:22:17 -07:00
parent b7b46b0a3b
commit 21ba9bf410
2 changed files with 20 additions and 12 deletions

View file

@ -499,17 +499,7 @@ void VoxelSystem::initVoxelMemory() {
_memoryUsageRAM += (sizeof(GLubyte) * vertexPointsPerVoxel * _maxVoxels);
// create our simple fragment shader if we're the first system to init
if (!_perlinModulateProgram.isLinked()) {
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath()
+ "shaders/perlin_modulate.vert");
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath()
+ "shaders/perlin_modulate.frag");
_perlinModulateProgram.link();
_perlinModulateProgram.bind();
_perlinModulateProgram.setUniformValue("permutationNormalTexture", 0);
_perlinModulateProgram.release();
if (!_shadowMapProgram.isLinked()) {
_shadowMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/shadow_map.vert");
_shadowMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
@ -1509,7 +1499,7 @@ void VoxelSystem::applyScaleAndBindProgram(bool texture) {
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getShadowDepthTextureID());
} else if (texture) {
_perlinModulateProgram.bind();
bindPerlinModulateProgram();
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPermutationNormalTextureID());
}
@ -2159,6 +2149,22 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() {
return (_initialMemoryUsageGPU - currentFreeMemory);
}
void VoxelSystem::bindPerlinModulateProgram() {
if (!_perlinModulateProgram.isLinked()) {
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/perlin_modulate.vert");
_perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment,
Application::resourcesPath() + "shaders/perlin_modulate.frag");
_perlinModulateProgram.link();
_perlinModulateProgram.bind();
_perlinModulateProgram.setUniformValue("permutationNormalTexture", 0);
} else {
_perlinModulateProgram.bind();
}
}
// Swizzle value of bit pairs of the value of index
unsigned short VoxelSystem::_sSwizzledOcclusionBits[64] = {
0x0000, // 00000000

View file

@ -236,6 +236,8 @@ private:
static ProgramObject _cascadedShadowMapProgram;
static int _shadowDistancesLocation;
static void bindPerlinModulateProgram();
int _hookID;
std::vector<glBufferIndex> _freeIndexes;
QMutex _freeIndexLock;