51 plUInt32 m_uiFailedDrawcalls;
56 void BeginRendering(
const plGALRenderingSetup& renderingSetup,
const plRectFloat& viewport,
const char* szName =
"",
bool bStereoRendering =
false);
59 void BeginCompute(
const char* szName =
"");
63 template <
int ScopeType>
71 if constexpr (ScopeType == 0)
72 m_RenderContext.EndRendering();
74 m_RenderContext.EndCompute();
76 if (m_pCommandsScope !=
nullptr)
78 plGALDevice::GetDefaultDevice()->
EndCommands(m_pCommandsScope);
89 : m_RenderContext(renderContext)
90 , m_pCommandsScope(pCommandsScope)
92 m_pGALCommandEncoder = renderContext.GetCommandEncoder();
103 viewContext.m_pRenderContext->BeginRendering(renderingSetup, viewContext.m_pViewData->m_ViewPortRect, szName, bStereoRendering);
107 PL_ALWAYS_INLINE
static RenderingScope BeginCommandsAndRenderingScope(
const plRenderViewContext& viewContext,
const plGALRenderingSetup& renderingSetup,
const char* szName,
bool bStereoRendering =
false)
110 viewContext.m_pRenderContext->BeginRendering(renderingSetup, viewContext.m_pViewData->m_ViewPortRect,
"", bStereoRendering);
111 return RenderingScope(*viewContext.m_pRenderContext, pCommandEncoder);
114 using ComputeScope = CommandEncoderScope<1>;
115 PL_ALWAYS_INLINE
static ComputeScope BeginComputeScope(
const plRenderViewContext& viewContext,
const char* szName =
"")
117 viewContext.m_pRenderContext->BeginCompute(szName);
118 return ComputeScope(*viewContext.m_pRenderContext,
nullptr);
121 PL_ALWAYS_INLINE
static ComputeScope BeginCommandsAndComputeScope(
const plRenderViewContext& viewContext,
const char* szName)
125 viewContext.m_pRenderContext->BeginCompute();
126 return ComputeScope(*viewContext.m_pRenderContext, pCommandEncoder);
131 PL_ASSERT_DEBUG(m_pGALCommandEncoder !=
nullptr,
"Outside of BeginCommands / EndCommands scope of the device");
132 return m_pGALCommandEncoder;
136 void SetShaderPermutationVariable(
const char* szName,
const plTempHashedString& sValue);
170 template <
typename T>
184 PL_ALWAYS_INLINE
void BindNullMeshBuffer(plGALPrimitiveTopology::Enum topology, plUInt32 uiPrimitiveCount)
189 plResult DrawMeshBuffer(plUInt32 uiPrimitiveCount = 0xFFFFFFFF, plUInt32 uiFirstPrimitive = 0, plUInt32 uiInstanceCount = 1);
191 plResult Dispatch(plUInt32 uiThreadGroupCountX, plUInt32 uiThreadGroupCountY = 1, plUInt32 uiThreadGroupCountZ = 1);
194 plResult ApplyContextStates(
bool bForce =
false);
195 void ResetContextState();
197 plGlobalConstants& WriteGlobalConstants();
198 const plGlobalConstants& ReadGlobalConstants()
const;
205 void SetDefaultTextureFilter(plTextureFilterSetting::Enum filter);
215 plTextureFilterSetting::Enum GetSpecificTextureFilter(plTextureFilterSetting::Enum configuration)
const;
218 void SetAllowAsyncShaderLoading(
bool bAllow);
221 bool GetAllowAsyncShaderLoading();
227 template <
typename T>
230 return CreateConstantBufferStorage(
sizeof(T));
233 template <
typename T>
245 return CreateConstantBufferStorage(uiSizeInBytes, pStorage);
251 template <
typename T>
255 bool bResult = TryGetConstantBufferStorage(hStorage, pStorage);
262 template <
typename T>
266 if (TryGetConstantBufferStorage(hStorage, pStorage))
268 return &(pStorage->GetDataForWriting());
278 PL_MAKE_SUBSYSTEM_STARTUP_FRIEND(RendererCore, RendererContext);
281 static void RegisterImmutableSamplers();
282 static void OnEngineStartup();
283 static void OnEngineShutdown();
287 Statistics m_Statistics;
303 plGALPrimitiveTopology::Enum m_Topology;
304 plUInt32 m_uiMeshBufferPrimitiveCount;
306 bool m_bAllowAsyncShaderLoading;
307 bool m_bStereoRendering =
false;
320 struct BoundConstantBuffer
322 PL_DECLARE_POD_TYPE();
324 BoundConstantBuffer() =
default;
326 : m_hConstantBuffer(hConstantBuffer)
330 : m_hConstantBufferStorage(hConstantBufferStorage)
343 struct ShaderVertexDecl
346 plUInt32 m_uiVertexDeclarationHash;
348 PL_FORCE_INLINE
bool operator<(
const ShaderVertexDecl& rhs)
const
350 if (m_hShader < rhs.m_hShader)
352 if (rhs.m_hShader < m_hShader)
354 return m_uiVertexDeclarationHash < rhs.m_uiVertexDeclarationHash;
357 PL_FORCE_INLINE
bool operator==(
const ShaderVertexDecl& rhs)
const
359 return (m_hShader == rhs.m_hShader && m_uiVertexDeclarationHash == rhs.m_uiVertexDeclarationHash);
367 static plMutex s_ConstantBufferStorageMutex;
373 plEventSubscriptionID m_GALdeviceEventsId = 0;
374 bool m_bRendering =
false;
375 bool m_bCompute =
false;
378 void UploadConstants();
384 void ApplyConstantBufferBindings(
const plGALShader* pShader);
385 void ApplyTextureBindings(
const plGALShader* pShader);
387 void ApplySamplerBindings(
const plGALShader* pShader);
388 void ApplyBufferBindings(
const plGALShader* pShader);
Definition RendererFoundationDLL.h:425
Definition RenderContext.h:30
PL_ALWAYS_INLINE void SetPushConstants(const plTempHashedString &sSlotName, const T &constants)
Definition RenderContext.h:171
plTextureFilterSetting::Enum GetDefaultTextureFilter() const
Returns the texture filter mode that is used by default for textures.
Definition RenderContext.h:208
Definition RenderContext.h:47
Definition Declarations.h:51