Skip to content

Commit 0261077

Browse files
Add void* getNativeHandle() to everything except OpenGL logical devices, queues and swapchains
1 parent fafa8e7 commit 0261077

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+224
-162
lines changed

src/nbl/video/CEGL.h renamed to include/nbl/video/CEGL.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __NBL_C_EGL_H_INCLUDED__
2-
#define __NBL_C_EGL_H_INCLUDED__
1+
#ifndef _NBL_C_EGL_H_INCLUDED_
2+
#define _NBL_C_EGL_H_INCLUDED_
33

44
//#include "nbl/video/CWaylandCaller.h"
55
#include "nbl/video/CEGLCaller.h"

src/nbl/video/CEGLCaller.h renamed to include/nbl/video/CEGLCaller.h

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __NBL_C_EGL_CALLER_H_INCLUDED__
2-
#define __NBL_C_EGL_CALLER_H_INCLUDED__
1+
#ifndef _NBL_C_EGL_CALLER_H_INCLUDED_
2+
#define _NBL_C_EGL_CALLER_H_INCLUDED_
33

44
#include "EGL/egl.h"
55
#include "nbl/system/DynamicFunctionCaller.h"
@@ -59,7 +59,6 @@ namespace nbl::video::egl
5959
eglWaitSync,\
6060
eglGetPlatformDependentHandles
6161

62-
#define NBL_IMPL_GET_FUNC_PTR(FUNC_NAME) reinterpret_cast<void*>(&::FUNC_NAME)
6362
class CEGLLoader : public system::FuncPtrLoader
6463
{
6564
system::DefaultFuncPtrLoader m_libEGL;
@@ -84,56 +83,18 @@ class CEGLLoader : public system::FuncPtrLoader
8483
{
8584
if (m_libEGL.isLibraryLoaded())
8685
return m_libEGL.loadFuncPtr(funcname);
86+
87+
#define NBL_IMPL_GET_FUNC_PTR(FUNC_NAME) reinterpret_cast<void*>(&::FUNC_NAME)
8788
#define LOAD_DYNLIB_FUNCPTR(FUNC_NAME) if (strcmp(funcname, #FUNC_NAME )==0) \
8889
return NBL_IMPL_GET_FUNC_PTR(FUNC_NAME);
8990
NBL_FOREACH(LOAD_DYNLIB_FUNCPTR,NBL_EGL_FUNC_LIST)
9091
#undef LOAD_DYNLIB_FUNCPTR
92+
#undef NBL_IMPL_GET_FUNC_PTR
9193
return nullptr;
9294
}
9395
};
9496
NBL_SYSTEM_DECLARE_DYNAMIC_FUNCTION_CALLER_CLASS(CEGLCaller,CEGLLoader,NBL_EGL_FUNC_LIST);
9597

96-
/*
97-
class CEGLCaller final : public core::Uncopyable
98-
{
99-
100-
101-
102-
103-
public:
104-
#define NBL_IMPL_INIT_EGL_FUNCPTR(FUNC_NAME) ,p ## FUNC_NAME ( NBL_IMPL_GET_FUNC_PTR(FUNC_NAME) )
105-
#define NBL_IMPL_INIT_EGL_FUNC_PTRS(...)\
106-
NBL_FOREACH(NBL_IMPL_INIT_EGL_FUNCPTR,__VA_ARGS__)
107-
CEGLCaller() : core::Uncopyable()
108-
NBL_IMPL_INIT_EGL_FUNC_PTRS(NBL_EGL_FUNC_LIST)
109-
{
110-
}
111-
#undef NBL_IMPL_INIT_EGL_FUNC_PTRS
112-
#undef NBL_IMPL_INIT_EGL_FUNCPTR
113-
#undef NBL_IMPL_GET_FUNC_PTR
114-
CEGLCaller(CEGLCaller&& other)
115-
{
116-
operator=(std::move(other));
117-
}
118-
119-
CEGLCaller& operator=(CEGLCaller&& other)
120-
{
121-
#define NBL_IMPL_SWAP_EGL_FUNC_PTRS(...)\
122-
NBL_FOREACH(NBL_SYSTEM_IMPL_SWAP_DYNLIB_FUNCPTR,__VA_ARGS__);
123-
NBL_IMPL_SWAP_EGL_FUNC_PTRS(NBL_EGL_FUNC_LIST);
124-
#undef NBL_IMPL_SWAP_EGL_FUNC_PTRS
125-
126-
return *this;
127-
}
128-
129-
#define NBL_IMPL_DECLARE_EGL_FUNC_PTRS(...)\
130-
NBL_FOREACH(NBL_SYSTEM_DECLARE_DYNLIB_FUNCPTR,__VA_ARGS__);
131-
NBL_IMPL_DECLARE_EGL_FUNC_PTRS(NBL_EGL_FUNC_LIST)
132-
#undef NBL_IMPL_DECLARE_EGL_FUNC_PTRS
133-
134-
};
135-
*/
136-
13798
#undef NBL_EGL_FUNC_LIST
13899
}
139100

include/nbl/video/COpenGL_Connection.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#ifndef __NBL_C_OPENGL__CONNECTION_H_INCLUDED__
2-
#define __NBL_C_OPENGL__CONNECTION_H_INCLUDED__
1+
#ifndef _NBL_C_OPENGL__CONNECTION_H_INCLUDED_
2+
#define _NBL_C_OPENGL__CONNECTION_H_INCLUDED_
33

44
#include "nbl/system/ISystem.h"
55

66
#include "nbl/video/IAPIConnection.h"
77
#include "nbl/video/debug/COpenGLDebugCallback.h"
8+
#include "nbl/video/CEGL.h"
89

910
namespace nbl::video
1011
{
@@ -13,6 +14,13 @@ template<E_API_TYPE API_TYPE>
1314
class COpenGL_Connection final : public IAPIConnection
1415
{
1516
public:
17+
//
18+
struct SStuff
19+
{
20+
// to load function pointers, make EGL context current and use `egl->call.peglGetProcAddress("glFuncname")`
21+
};
22+
23+
//
1624
static core::smart_refctd_ptr<COpenGL_Connection<API_TYPE>> create(core::smart_refctd_ptr<system::ISystem>&& sys, uint32_t appVer, const char* appName, COpenGLDebugCallback&& dbgCb);
1725

1826
E_API_TYPE getAPIType() const override
@@ -22,6 +30,8 @@ class COpenGL_Connection final : public IAPIConnection
2230

2331
IDebugCallback* getDebugCallback() const override;
2432

33+
const egl::CEGL& getInternalObject() const;
34+
2535
private:
2636
COpenGL_Connection() : IAPIConnection()
2737
{}

include/nbl/video/CThreadSafeGPUQueueAdapter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class CThreadSafeGPUQueueAdapter : public IGPUQueue
5555
{
5656
return originalQueue;
5757
}
58+
59+
virtual const void* getNativeHandle() const
60+
{
61+
return originalQueue->getNativeHandle();
62+
}
5863
};
5964

6065
}

include/nbl/video/IAPIConnection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class IPhysicalDevice;
1515
class IAPIConnection : public core::IReferenceCounted
1616
{
1717
public:
18+
// TODO: are these "instance features" ?
1819
enum E_FEATURE
1920
{
2021
EF_SURFACE = 0,
@@ -30,6 +31,7 @@ class IAPIConnection : public core::IReferenceCounted
3031
static core::SRange<const E_FEATURE> getDependentFeatures(const E_FEATURE feature);
3132

3233
protected:
34+
// TODO: move to IAPIConnection.cpp
3335
inline IAPIConnection() : m_physicalDevices(), m_rdoc_api(nullptr)
3436
{
3537
#ifdef _NBL_PLATFORM_WINDOWS_

include/nbl/video/IGPUBuffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class IGPUBuffer : public asset::IBuffer, public IDriverMemoryBacked, public IBa
4141
inline uint64_t getSize() const override {return cachedMemoryReqs.vulkanReqs.size;}
4242

4343
inline const SCachedCreationParams& getCachedCreationParams() const {return m_cachedCreationParams;}
44+
45+
// OpenGL: const GLuint* handle of a Buffer
46+
// Vulkan: const VkBuffer*
47+
virtual const void* getNativeHandle() const = 0;
4448

4549
protected:
4650
IGPUBuffer(

include/nbl/video/IGPUBufferView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class IGPUBufferView : public asset::IBufferView<IGPUBuffer>, public IBackendObj
2424
asset::IBufferView<IGPUBuffer>(std::move(_buffer), _format, _offset, _size), IBackendObject(std::move(dev))
2525
{}
2626

27+
// OpenGL: const GLuint* handle of GL_TEXTURE_BUFFER
28+
// Vulkan: const VkBufferView*
29+
virtual const void* getNativeHandle() const = 0;
30+
2731
protected:
2832
virtual ~IGPUBufferView() = default;
2933
};

include/nbl/video/IGPUCommandBuffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ class IGPUCommandBuffer :
174174
return m_cachedInheritanceInfo;
175175
}
176176

177+
// OpenGL: nullptr, because commandbuffer doesn't exist in GL (we might expose the linked list command storage in the future)
178+
// Vulkan: const VkCommandBuffer*
179+
virtual const void* getNativeHandle() const = 0;
180+
177181
protected:
178182
friend class IGPUQueue;
179183

include/nbl/video/IGPUCommandPool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class IGPUCommandPool : public core::IReferenceCounted, public IBackendObject
2727
core::bitflag<E_CREATE_FLAGS> getCreationFlags() const { return m_flags; }
2828
uint32_t getQueueFamilyIndex() const { return m_familyIx; }
2929

30+
// OpenGL: nullptr, because commandpool doesn't exist in GL (we might expose the internal allocator in the future)
31+
// Vulkan: const VkCommandPool*
32+
virtual const void* getNativeHandle() const = 0;
33+
3034
protected:
3135
virtual ~IGPUCommandPool() = default;
3236

include/nbl/video/IGPUFence.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class IGPUFence : public core::IReferenceCounted, public IBackendObject
3030
{
3131
}
3232

33+
// OpenGL: core::smart_refctd_ptr<COpenGLSync>*
34+
// Vulkan: const VkFence*
35+
virtual void* getNativeHandle() = 0;
36+
3337
protected:
3438
virtual ~IGPUFence() = default;
3539
};

0 commit comments

Comments
 (0)