A bit of a weird dispose
pattern - Concerns on leaky resources?
#52
-
I have been getting an (unrelated) issue with glsl include sub-includes sometimes seemingly (probably?) accessing freed file data. So, when I am debugging that, I noticed in here, if the I have also seen this appears in many other places, with (I think) native resources being conditionally freed behind that bool flag. So I am really not sure if this is a bug or if I am missing something? Code: Vortice.Vulkan/src/Vortice.ShaderCompiler/Result.cs Lines 37 to 57 in 984b679 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Can you try to follow the IDisposable pattern using keyword and see if it causes issue? Take look here: |
Beta Was this translation helpful? Give feedback.
-
Update, can confirm that the latest (ShaderCompiler v1.8.0) did fix above mentioned issues! Btw, it might be a good idea to add comments on Side-note:My current guess on why the shaderc is reading corrupted data on Vortice.Vulkan/src/Vortice.ShaderCompiler/Includer.cs Lines 75 to 76 in f75763a In above, it is passing down the utf-16 c#-style string Now, how, or even if, those mismatches lead to the memory corruption, I have no idea. This really is just a guess. It prob was causing problems. But is that the specific problem I was encountering? Who knows. I can confirm however that the new reworked code indeed does this properly, and that the issues on corrupted memory no longer (seems to) happen. Thanks @amerkoleci a lot! |
Beta Was this translation helpful? Give feedback.
Update, can confirm that the latest (ShaderCompiler v1.8.0) did fix above mentioned issues!
Btw, it might be a good idea to add comments on
Compiler
class that it REQUIRES explicit call toDispose()
.Side-note:
My current guess on why the shaderc is reading corrupted data on
#include
is that the old version of passing included file strings into native environment seems to pass incorrect 'length' param compared to the raw utf-8 c-string it passes:Vortice.Vulkan/src/Vortice.ShaderCompiler/Includer.cs
Lines 75 to 76 in f75763a
In above, it is passing down the utf-16 c#-sty…