When I create a Pipeline State Object, I pass it a pipeline state descriptor that contains D3D12_SHADER_BYTECODE structures that have been derived from ID3DBlobs. Currently, those blobs are local to the function; I don't keep track of them beyond the call to CreateGraphicsPipelineState. Is the bytecode associated with that blob released at this point? I ask because I would like to create a system that caches the shaders used in the pipeline states. If you use the same vertex shader twice, it seems unnecessary to re-compile it every time. However, this is not going to be the common case, and I don't want to hold on to those blobs if doing so is going to keep data in RAM that I don't generally need.
[D3D12] Shader Blob and PSO
The bytecode owned by the blob is released at that point. D3D holds on to a copy of the bytecode.
Whelp, looks like I'll be adding a thread for PSO creation that recompiles when necessary. Thanks!
If you want to save memory, the real game changer is ID3D12PipelineLibrary.
You should always precompile your shader, then at runtime, there is two things, caching the cached blob from Pipeline creations for later run, it is a performance optimisation as you skip the bytecode to microcode compilation, and then the new interface, the library that allow sharing of inner parts of the pipelines. It is hard to measure the gains, but they can be substantial.
sharing of inner parts of the pipelines
Is that something I can manually direct it to do, or is that managed by the driver?
sharing of inner parts of the pipelines
Is that something I can manually direct it to do, or is that managed by the driver?
It is a Microsoft and driver layer collaboration. You don't know what can be shared, it is an implementation details. But it can definitely make a difference with thousands of PSO.
You should always precompile your shader^^This too. You can save a hell of a lot of work at runtime if you precompile all your blobs and save the bytecode to a file.