is there good way to get the bytecode of a shader if all you have is a ID3D11PixelShader object? in d3d9 this is simple, IDirect3DPixelShader9 has a function called GetFunction that returns the compiled bytecode of the shader. is there a d3d11 equivalent?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
get compiled pixel shader bytecode from ID3D11PixelShader object
In D3D11 you create the pixel shader with the byte code, and the pixel shader object is purely a handle to use to set the compiled version on the context to render with.
D3DCompile allows you to create a shader blob in code: https://docs.microsoft.com/en-us/windows/win32/api/d3dcompiler/nf-d3dcompiler-d3dcompile
FXC.exe will allow you to compile shaders on the commandline or in Visual Studio if you tell your project that certain files need to use that extension to compile with. This can create output files that are compiled shaders that you can then feed to the CreateXXXShaderFunctions in D3D11.
No, there's no equivalent of that D3D9 function. You would need to somehow manually associate the bytecode with the ID3D11PixelShader* pointer to be able do that.