3#define PL_GALDEVICE_LOCK_AND_CHECK() \
5 VerifyMultithreadedAccess()
14 return GetCurrentFramePlatform();
19 return GetSafeFramePlatform();
24 if (hTimestamp.IsInvalidated())
27 return GetTimestampResultPlatform(hTimestamp, out_result);
32 if (hOcclusion.IsInvalidated())
35 return GetOcclusionResultPlatform(hOcclusion, out_uiResult);
43 return GetFenceResultPlatform(hFence, timeout);
46template <
typename IdTableType,
typename ReturnType>
47PL_ALWAYS_INLINE ReturnType* plGALDevice::Get(
typename IdTableType::TypeOfId hHandle,
const IdTableType& IdTable)
const
49 PL_GALDEVICE_LOCK_AND_CHECK();
51 ReturnType* pObject =
nullptr;
52 IdTable.TryGetValue(hHandle, pObject);
58 return Get<SwapChainTable, plGALSwapChain>(hSwapChain, m_SwapChains);
63 return Get<ShaderTable, plGALShader>(hShader, m_Shaders);
68 return Get<TextureTable, plGALTexture>(hTexture, m_Textures);
73 return Get<BufferTable, plGALBuffer>(hBuffer, m_Buffers);
78 return Get<DepthStencilStateTable, plGALDepthStencilState>(hDepthStencilState, m_DepthStencilStates);
83 return Get<BlendStateTable, plGALBlendState>(hBlendState, m_BlendStates);
88 return Get<RasterizerStateTable, plGALRasterizerState>(hRasterizerState, m_RasterizerStates);
93 return Get<VertexDeclarationTable, plGALVertexDeclaration>(hVertexDeclaration, m_VertexDeclarations);
98 return Get<SamplerStateTable, plGALSamplerState>(hSamplerState, m_SamplerStates);
103 return Get<TextureResourceViewTable, plGALTextureResourceView>(hResourceView, m_TextureResourceViews);
108 return Get<BufferResourceViewTable, plGALBufferResourceView>(hResourceView, m_BufferResourceViews);
113 return Get<RenderTargetViewTable, plGALRenderTargetView>(hRenderTargetView, m_RenderTargetViews);
118 return Get<TextureUnorderedAccessViewTable, plGALTextureUnorderedAccessView>(hUnorderedAccessView, m_TextureUnorderedAccessViews);
123 return Get<BufferUnorderedAccessViewTable, plGALBufferUnorderedAccessView>(hUnorderedAccessView, m_BufferUnorderedAccessViews);
127PL_ALWAYS_INLINE
void plGALDevice::SetDefaultDevice(
plGALDevice* pDefaultDevice)
129 s_pDefaultDevice = pDefaultDevice;
133PL_ALWAYS_INLINE
plGALDevice* plGALDevice::GetDefaultDevice()
135 PL_ASSERT_DEBUG(s_pDefaultDevice !=
nullptr,
"Default device not set.");
136 return s_pDefaultDevice;
140PL_ALWAYS_INLINE
bool plGALDevice::HasDefaultDevice()
142 return s_pDefaultDevice !=
nullptr;
145template <
typename HandleType>
146PL_FORCE_INLINE
void plGALDevice::AddDeadObject(plUInt32 uiType, HandleType handle)
148 auto& deadObject = m_DeadObjects.ExpandAndGetRef();
149 deadObject.m_uiType = uiType;
150 deadObject.m_uiHandle = handle.GetInternalID().m_Data;
153template <
typename HandleType>
154void plGALDevice::ReviveDeadObject(plUInt32 uiType, HandleType handle)
156 plUInt32 uiHandle = handle.GetInternalID().m_Data;
158 for (plUInt32 i = 0; i < m_DeadObjects.GetCount(); ++i)
160 const auto& deadObject = m_DeadObjects[i];
162 if (deadObject.m_uiType == uiType && deadObject.m_uiHandle == uiHandle)
164 m_DeadObjects.RemoveAtAndCopy(i);
172#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
174 "This device does not support multi-threaded resource creation, therefore this function can only be executed on the main thread.");
Base class for all memory allocators.
Definition Allocator.h:23
Definition RendererFoundationDLL.h:467
Definition RendererFoundationDLL.h:418
Definition RendererFoundationDLL.h:432
Definition ResourceView.h:30
Definition RendererFoundationDLL.h:446
Definition UnorderedAccesView.h:28
Definition RendererFoundationDLL.h:460
The plRenderDevice class is the primary interface for interactions with rendering APIs It contains a ...
Definition Device.h:19
void VerifyMultithreadedAccess() const
Asserts that either this device supports multi-threaded resource creation, or that this function is e...
Definition Device_inl.h:170
plAllocator * GetAllocator()
Internal: Returns the allocator used by the device.
Definition Device_inl.h:178
plUInt64 GetSafeFrame() const
The latest frame that has been fully executed on the GPU. Whenever you execute any work that requires...
Definition Device_inl.h:17
plEnum< plGALAsyncResult > GetFenceResult(plGALFenceHandle hFence, plTime timeout=plTime::MakeZero())
Definition Device_inl.h:38
plEnum< plGALAsyncResult > GetOcclusionQueryResult(plGALOcclusionHandle hOcclusion, plUInt64 &out_uiResult)
Definition Device_inl.h:30
plUInt64 GetCurrentFrame() const
The current rendering frame. This is a monotonically increasing number which changes +1 every time En...
Definition Device_inl.h:12
plEnum< plGALAsyncResult > GetTimestampResult(plGALTimestampHandle hTimestamp, plTime &out_result)
Queries the result of a timestamp. Should be called every frame until plGALAsyncResult::Ready is retu...
Definition Device_inl.h:22
Definition RendererFoundationDLL.h:474
Definition RendererFoundationDLL.h:453
Definition RenderTargetView.h:8
Definition RendererFoundationDLL.h:481
Definition RendererFoundationDLL.h:404
Definition RendererFoundationDLL.h:397
Definition SwapChain.h:11
Definition RendererFoundationDLL.h:411
Definition RendererFoundationDLL.h:425
Definition ResourceView.h:11
Definition RendererFoundationDLL.h:439
Definition UnorderedAccesView.h:11
Definition RendererFoundationDLL.h:488
Definition VertexDeclaration.h:8
static bool IsMainThread()
Helper function to check if the current thread is the main thread (e.g. the thread which initialized ...
Definition ThreadUtils_Posix.h:47
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
@ Ready
The async operation has finished and the result is ready.
Definition RendererFoundationDLL.h:350
@ Expired
The async operation is too old and the result was thrown away. Pending results should be queried ever...
Definition RendererFoundationDLL.h:352
bool m_bMultithreadedResourceCreation
whether creating resources is allowed on other threads than the main thread
Definition DeviceCapabilities.h:51
Definition Descriptors.h:39
A generic id class that holds an id combined of an instance index and a generation counter.
Definition Id.h:52
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12