shader-slang / slang

Making it easier to work with shaders
MIT License
1.99k stars 169 forks source link

No valid method to create `Slang::ComPtr<IModule>` from `loadModule` #4630

Open LouChiSoft opened 2 months ago

LouChiSoft commented 2 months ago

Following the instructions on using the compilation API instead of slangc and there is a section about generating diagnostic data:

Slang::ComPtr<IBlob> diagnostics;
Slang::ComPtr<IModule> module = session->loadModule("MyShaders", diagnostics.writeRef());

I tried this and as far as I can see there is no version of loadModule that returns a Slang::ComPtr<ISession> nor is there a constructor that takes an ISession* to create the one from. Not sure if it's the documentation that needs updating or there is a bit of missing code.

Version: Built from source. GitHash = 1a0bbb53c116e6e5f89ed577803341e6aa1bce82 Default build.

swoods-nv commented 1 month ago

The current behavior is not ideal, in that loadModule returns a raw pointer whose lifetime is bound to be the same as ISession. We should fix this in the long term, but in the meantime at a minimum we should document this and document the intent to change it.

swoods-nv commented 1 month ago

(Assigning to myself because it's related to #4420 in the documentation bit)