Comments (16)
Yes that's correct.
from silk.net.
Awesome stuff @jcyuan. I had hoped that this is what the LambdaNativeContext is essentially doing, but it looks like for some reason it's not rolling over to the default context.
The null thing is a big oops, feel free to use unsafe accessors to rectify that:
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_extensions")]
extern static ref ConcurrentDictionary<nint, HashSet<string>>? Exts(WGL wgl);
Exts(wgl) = new();
from silk.net.
NV_DX_interop2 does not add any new functions therefore it does not have a class generated. For more info see the specification: https://registry.khronos.org/OpenGL/extensions/NV/WGL_NV_DX_interop2.txt
from silk.net.
NV_DX_interop2 does not add any new functions therefore it does not have a class generated. For more info see the specification: https://registry.khronos.org/OpenGL/extensions/NV/WGL_NV_DX_interop2.txt
thanks for reply, yeah i know that, actually it was the usage confused me, so how can i use NV_DX_interop2 with Silk.WGL? i assume that the Overloads will be auto used for those changes in NV_DX_interop2?
from silk.net.
Yes that's correct.
Hi sir, sorry for bothering again,
i just found 2 problems:
1, this method is not implemented in WGL.cs:
so, if (wgl.TryGetExtension<NVDXInterop>(out var ext))
will fail.
2, NV_DX_interop
does not exist in the extension string list. but i can still use wglGetProcAddress("wglDXOpenDeviceNV")
to use those methods, not sure why, it's strange to me...
if i try to use the ext with a 'normal' way just like other extensions:
by this test code:
var wgl = WGL.GetApi();
var ext = new NVDXInterop(wgl.Context);
ext.DxopenDevice(out IntPtr device);
ext.DxcloseDevice(device);
it will fail....
and if i just use it by using DllImport even it does not exist in the extension string list:
it just works....
from silk.net.
oops
from silk.net.
This will now be fixed as part of #2115 (the next update), and the fix is contained in commit dfb4225. If you would like to work around this in your own code, feel free to use this commit as inspiration.
from silk.net.
This will now be fixed as part of #2115 (the next update), and the fix is contained in commit dfb4225. If you would like to work around this in your own code, feel free to use this commit as inspiration.
πthanks so much.
from silk.net.
hi @Perksey
i had applied your changes into my logic (as the official release is not ready yet),
i found that i can create NVDXInterop extension in my 'primary' context, once i try to create with any context created later (shared with the primary context), the creating will fail.
ex info: i manage all the created DCs in a single thread.
maybe i should wait for new official release?
from silk.net.
2.21 should have fixed this.
from silk.net.
so fast! thanks so much @Perksey
but just had a try and it didn't work, here is the code:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[SupportedOSPlatform("windows")]
private INativeContext CreateNativeContext()
{
return WGL.CreateDefaultContext(["Opengl32"]);
}
// ------
var nativeContext = CreateNativeContext();
using (MakeCurrent())
{
_gl = GL.GetApi(nativeContext);
_wgl= WGL.GetApi(); // new WGL(nativeContext) not work too.
}
// test
var test = _wgl.TryGetExtension(out NVDXInterop ext);
from silk.net.
Please ensure that you're using WGL.GetApi. Please note that the snippet you gave is using GL.GetApi incorrectly - this will only work for OpenGL 1.1 - you need to use a native context that uses wgl.GetProcAddress for the others.
I'm not sure why this isn't working, I'll reopen this issue until a community member can investigate further.
from silk.net.
thanks for your suggestion,
i have changed my code like this:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static IntPtr GetProcAddress(string proc)
{
var p = NativeMethods.wglGetProcAddress(proc);
return p != IntPtr.Zero ? p : NativeMethods.GetProcAddress(OpenGl32Handle, proc);
}
using (MakeCurrent())
{
_gl = GL.GetApi(GetProcAddress);
_wgl = WGL.GetApi(); // way auto create `MultiNativeContext`
}
i think for _gl
it's fine now, but for _wgl
, still the same exception.
from silk.net.
update:
i tried to create WGL with new WGL(new LamdaNativeContext(GetProcAddress));
(the GetProcAddress is the same one the _gl
uses.
now it has exception, the _extensions
is null:
so i think
private static IntPtr GetProcAddress(string proc)
{
var p = NativeMethods.wglGetProcAddress(proc);
return p != IntPtr.Zero ? p : NativeMethods.GetProcAddress(OpenGl32Handle, proc);
}
this should be the right way. @Perksey
from silk.net.
update:
still failed, even the getProcAddress
works for NVDXInterop
extension to get those APIs, but those API call only works with the primary context, not sure why...
works fine now, i have manually written a binding for NVDXInterop
because it only has a few APIs, and it works with all context now.
hope Silk could fix these problems soon, and thanks so much for official team for your efforts. β€
from silk.net.
This is a way I tried, I hope it can help you.
Use TryGetProcAddress instead of GetProcAddress in the GetProcAddress function of MultiNativeContext.
public nint GetProcAddress(string proc, int? slot = null)
{
INativeContext[] contexts = Contexts;
for (int i = 0; i < contexts.Length; i++)
{
if (contexts[i]?.TryGetProcAddress(proc, out IntPtr intPtr, slot) ?? false)
{
return intPtr;
}
}
return 0;
}
Initialize and assign _extensions in WGL.
This can effectively solve the extension problem of WGL.
from silk.net.
Related Issues (20)
- Silk.NET.Core.Loader.DefaultPathResolver does not check the directory of its own assembly HOT 1
- Build DXVK native package for `linux-arm`, `linux-arm64`, and `win-arm64`
- Silk.NET is awesome, but no CUDA? HOT 1
- GetUniformLocation() returns -1 on Nvidia HOT 9
- SDL2 gone on publish HOT 5
- Add MeshOptimizer Bindings HOT 1
- Error when trying to use TextureStorage3D on Android HOT 5
- Changed behavior when setting GLFW StandardCursor
- MAUI project on Android using OpenXR HOT 1
- SDL API not loading on M-series Mac HOT 34
- Native symbol not found (Symbol: vkCreateSwapchainKHR) HOT 2
- WebGPU bindings are broken in 2.21.0 HOT 4
- [ID3DInclude] Custom include handler for D3D.Compile2() HOT 1
- Silk.NET.Vulkan work on iOS? HOT 1
- Interactive Silk.NET Windowing in Polyglot Notebooks HOT 1
- Can't build for iOS HOT 5
- Android Bluetooth permission question HOT 2
- ImGui is broken for OpenGL HOT 1
- Add iOS and Android platform for Silk.NET.WebGPU.Native.WGPU
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silk.net.