Game Development Community

dev|Pro Game Development Curriculum

Enable CSF generation

by thanasimos · 03/12/2014 (3:29 pm) · 7 comments

I dont know why it was disabled but loading precompiled shaders instead of re-compiling them improves a lot loading times especially on "heavy" missions. Enabling compiled shaders may be useful in shipping builds.



  1. At source/gfx/D3D9/gfxD3D9Shader.cpp

  2. Around line 951 change
    if ( !_saveCompiledOutput(filePath, code, bufferLayoutF, bufferLayoutI) && smLogErrors )
    to
    if (!_saveCompiledOutput(filePath, code, bufferLayoutF, bufferLayoutI,samplerDescriptions) && smLogErrors)

  3. Define TORQUE_ENABLE_CSF_GENERATION in your torqueConfig.h
  4. #define TORQUE_ENABLE_CSF_GENERATION
  5. Recompile and run your game. The generated .csf files should exist in shaders/procedural directory.

  6. Add
    $shaders::forceLoadCSF = true;
    in your default.cs or main.cs


About the author

Recent Blogs


#1
03/12/2014 (4:05 pm)
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/9993c8d4678e15b0_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
MaterialList::initMatInstances - failed to initialize material instance for 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/a0bd591c52ed17a4_V.hlsl'.
Failed to initialize material 'debri_debris'
MaterialList::initMatInstances - failed to initialize material instance for 'debri_debris'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/87b5194bea8332b_V.hlsl'.
Failed to initialize material 'w_swarmgun'
MaterialList::initMatInstances - failed to initialize material instance for 'w_swarmgun'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/59bd5b16c3ddaa5b_V.hlsl'.
Failed to initialize material 'LaserRedMat'
MaterialList::initMatInstances - failed to initialize material instance for 'LaserRedMat'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
Warning: shape art/shapes/weapons/Turret/Turret_Legs.DAE collision detail 1 (Collision-1) bounds exceed that of shape.
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/a70d2393bdd03807_V.hlsl'.
Failed to initialize material 'Turret_Base'
MaterialList::initMatInstances - failed to initialize material instance for 'Turret_Base'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/5a0843ed59463d17_V.hlsl'.
Failed to initialize material 'Turret_Lazer_Base'
MaterialList::initMatInstances - failed to initialize material instance for 'Turret_Lazer_Base'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/ef2f8e3c60f2b78c_V.hlsl'.
Failed to initialize material 'Turret_MuzzleFlash_Base'
MaterialList::initMatInstances - failed to initialize material instance for 'Turret_MuzzleFlash_Base'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
Warning: shape art/shapes/weapons/Turret/Turret_Legs.DAE collision detail 1 (Collision-1) bounds exceed that of shape.
Warning: shape art/shapes/weapons/Turret/Turret_Legs.DAE collision detail 1 (Collision-1) bounds exceed that of shape.
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/a70d2393bdd03807_V.hlsl'.
Failed to initialize material 'Turret_Base'
MaterialList::initMatInstances - failed to initialize material instance for 'Turret_Base'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/a70d2393bdd03807_V.hlsl'.
Failed to initialize material 'Turret_Base'
MaterialList::initMatInstances - failed to initialize material instance for 'Turret_Base'
GFXD3D9Shader::init - Unable to load precompiled vertex shader for 'shadergen:/b12a767dec12097c_V.hlsl'.
Failed to initialize material 'WarningMaterial'

getting tons of these errors and game crashs???
#2
03/12/2014 (5:09 pm)
ok got it!! had to run the game first with $shaders::forceLoadCSF = false; than I set it to true to use the precompiled shaders... works great thank you......
#3
03/13/2014 (8:13 am)
This is great! Having worked quite a bit with shaders lately, I know how long the compilation of some shaders actually takes (several seconds for shaders with a for-loop).
#4
03/14/2014 (6:13 am)
Just a stupid question, isn't there a problem when a user changes the gfx card? I thought that the shaders had to be recompiled then.

On second thought, there may be a work-around twhen this is the case. Just check if the procedural shaders map is empty then run with forceLoadCSF = false, else set it to true.
#5
03/16/2014 (6:52 am)
It needs a button for the end user. So he can choose between load precompiled and generate shaders, if he start the game. Maybe a clean shader button also.
#6
03/29/2014 (2:07 am)
This would be a great candidate for a pull request if we can work out the usability issues! For example, if forceLoadCSF is false but there are no shaders, it should be treated as if it's true. Maybe that needs to happen wherever the warning is occurring from.
#7
09/01/2014 (1:48 am)
Quote:I dont know why it was disabled...

I know now. If you have shaders that use a
defines = "...";
in the ShaderData (like the UnderWaterShader) to distinguish between two forms of the same shader (UnderWaterShader and WaterShader both use the same pixel and vertex shader with the UNDERWATER defines makes the difference), then the compiled shader goes wrong. If you want to use the csf's then you have to create two shaders in the mentioned case.

Furthermore I have solved the problem when no shaders are present.