Hi,
I am trying to reduce the load time of my game.
Right now, I compile all the shader at runtime, when the game is started, which takes quite some time.
I use D3DX10CompileFromMemory to compile my shaders.
I am thinking about writing the content of the blob returned by this function on disk, the first time the shader is being compiled, and re-use it next time the game is started.
This is very straightforward.
However, what I also would like to achieve, is to automatically detect any change in the shader source, and re-compile the shader if any change occured.
So, my initial idea was to save two files, the source code version used for compilation, and the resulting compiled shader blob.
At runtime, I would load the shader source file, and compare it with the source version used for compilation. If there is no difference, i can use the pre-compiled blob, otherwise I compile the shader again.
However, this approach gets a bit more complicated when considering "#include" directives, along with the usage of a "ID3D10Include" object.
The only way I see would be to manually resolve all the #include" directives, in order to get a "#include"-free HLSL source code I could use to compare the current version with the pre-compiled cache version.
Is there any other option I haven't seen ? How do you guys handle this problem ?
I am trying to reduce the load time of my game.
Right now, I compile all the shader at runtime, when the game is started, which takes quite some time.
I use D3DX10CompileFromMemory to compile my shaders.
I am thinking about writing the content of the blob returned by this function on disk, the first time the shader is being compiled, and re-use it next time the game is started.
This is very straightforward.
However, what I also would like to achieve, is to automatically detect any change in the shader source, and re-compile the shader if any change occured.
So, my initial idea was to save two files, the source code version used for compilation, and the resulting compiled shader blob.
At runtime, I would load the shader source file, and compare it with the source version used for compilation. If there is no difference, i can use the pre-compiled blob, otherwise I compile the shader again.
However, this approach gets a bit more complicated when considering "#include" directives, along with the usage of a "ID3D10Include" object.
The only way I see would be to manually resolve all the #include" directives, in order to get a "#include"-free HLSL source code I could use to compare the current version with the pre-compiled cache version.
Is there any other option I haven't seen ? How do you guys handle this problem ?