Skip to content

Commit

Permalink
Merge branch 'master' into fix-include-alt-base-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent authored Nov 22, 2023
2 parents e0585e5 + 39458ea commit 4e38d04
Show file tree
Hide file tree
Showing 14 changed files with 513 additions and 154 deletions.
1 change: 1 addition & 0 deletions BuildTools/.NET/dotnet-build-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def dotnet_run_native_tests(config, settings, arch, gapi):

def dotnet_run_managed_tests(config, arch, gapi):
os.environ["DILIGENT_GAPI"] = gapi
os.environ["DOTNET_ROLL_FORWARD"] = "Major"
subprocess.run(f"dotnet test -c {config} -p:Platform={arch} {project_paths['dotnet-tests']}", check=True)


Expand Down
363 changes: 241 additions & 122 deletions Graphics/GraphicsEngine/include/DeviceContextBase.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Graphics/GraphicsEngine/interface/APIInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/// \file
/// Diligent API information

#define DILIGENT_API_VERSION 254001
#define DILIGENT_API_VERSION 254002

#include "../../../Primitives/interface/BasicTypes.h"

Expand Down
162 changes: 162 additions & 0 deletions Graphics/GraphicsEngine/interface/DeviceContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,160 @@ struct StateTransitionDesc
};
typedef struct StateTransitionDesc StateTransitionDesc;

/// Device context command counters.
struct DeviceContextCommandCounters
{
/// The total number of SetPipelineState calls.
Uint32 SetPipelineState DEFAULT_INITIALIZER(0);

/// The total number of CommitShaderResources calls.
Uint32 CommitShaderResources DEFAULT_INITIALIZER(0);

/// The total number of SetVertexBuffers calls.
Uint32 SetVertexBuffers DEFAULT_INITIALIZER(0);

/// The total number of SetIndexBuffer calls.
Uint32 SetIndexBuffer DEFAULT_INITIALIZER(0);

/// The total number of SetRenderTargets calls.
Uint32 SetRenderTargets DEFAULT_INITIALIZER(0);

/// The total number of SetBlendFactors calls.
Uint32 SetBlendFactors DEFAULT_INITIALIZER(0);

/// The total number of SetStencilRef calls.
Uint32 SetStencilRef DEFAULT_INITIALIZER(0);

/// The total number of SetViewports calls.
Uint32 SetViewports DEFAULT_INITIALIZER(0);

/// The total number of SetScissorRects calls.
Uint32 SetScissorRects DEFAULT_INITIALIZER(0);

/// The total number of ClearRenderTarget calls.
Uint32 ClearRenderTarget DEFAULT_INITIALIZER(0);

/// The total number of ClearDepthStencil calls.
Uint32 ClearDepthStencil DEFAULT_INITIALIZER(0);

/// The total number of Draw calls.
Uint32 Draw DEFAULT_INITIALIZER(0);

/// The total number of DrawIndexed calls.
Uint32 DrawIndexed DEFAULT_INITIALIZER(0);

/// The total number of indirect DrawIndirect calls.
Uint32 DrawIndirect DEFAULT_INITIALIZER(0);

/// The total number of indexed indirect DrawIndexedIndirect calls.
Uint32 DrawIndexedIndirect DEFAULT_INITIALIZER(0);

/// The total number of DispatchCompute calls.
Uint32 DispatchCompute DEFAULT_INITIALIZER(0);

/// The total number of DispatchComputeIndirect calls.
Uint32 DispatchComputeIndirect DEFAULT_INITIALIZER(0);

/// The total number of DispatchTile calls.
Uint32 DispatchTile DEFAULT_INITIALIZER(0);

/// The total number of DrawMesh calls.
Uint32 DrawMesh DEFAULT_INITIALIZER(0);

/// The total number of DrawMeshIndirect calls.
Uint32 DrawMeshIndirect DEFAULT_INITIALIZER(0);

/// The total number of BuildBLAS calls.
Uint32 BuildBLAS DEFAULT_INITIALIZER(0);

/// The total number of BuildTLAS calls.
Uint32 BuildTLAS DEFAULT_INITIALIZER(0);

/// The total number of CopyBLAS calls.
Uint32 CopyBLAS DEFAULT_INITIALIZER(0);

/// The total number of CopyTLAS calls.
Uint32 CopyTLAS DEFAULT_INITIALIZER(0);

/// The total number of WriteBLASCompactedSize calls.
Uint32 WriteBLASCompactedSize DEFAULT_INITIALIZER(0);

/// The total number of WriteTLASCompactedSize calls.
Uint32 WriteTLASCompactedSize DEFAULT_INITIALIZER(0);

/// The total number of TraceRays calls.
Uint32 TraceRays DEFAULT_INITIALIZER(0);

/// The total number of TraceRaysIndirect calls.
Uint32 TraceRaysIndirect DEFAULT_INITIALIZER(0);

/// The total number of UpdateSBT calls.
Uint32 UpdateSBT DEFAULT_INITIALIZER(0);

/// The total number of UpdateBuffer calls.
Uint32 UpdateBuffer DEFAULT_INITIALIZER(0);

/// The total number of CopyBuffer calls.
Uint32 CopyBuffer DEFAULT_INITIALIZER(0);

/// The total number of MapBuffer calls.
Uint32 MapBuffer DEFAULT_INITIALIZER(0);

/// The total number of UpdateTexture calls.
Uint32 UpdateTexture DEFAULT_INITIALIZER(0);

/// The total number of CopyTexture calls.
Uint32 CopyTexture DEFAULT_INITIALIZER(0);

/// The total number of MapTextureSubresource calls.
Uint32 MapTextureSubresource DEFAULT_INITIALIZER(0);

/// The total number of BeginQuery calls.
Uint32 BeginQuery DEFAULT_INITIALIZER(0);

/// The total number of GenerateMips calls.
Uint32 GenerateMips DEFAULT_INITIALIZER(0);

/// The total number of ResolveTextureSubresource calls.
Uint32 ResolveTextureSubresource DEFAULT_INITIALIZER(0);

/// The total number of BindSparseResourceMemory calls.
Uint32 BindSparseResourceMemory DEFAULT_INITIALIZER(0);
};
typedef struct DeviceContextCommandCounters DeviceContextCommandCounters;

/// Device context statistics.
struct DeviceContextStats
{
/// The total number of primitives rendered, for each primitive topology.
Uint32 PrimitiveCounts[PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES] DEFAULT_INITIALIZER({});

/// Command counters, see Diligent::DeviceContextCommandCounters.
DeviceContextCommandCounters CommandCounters DEFAULT_INITIALIZER({});

#if DILIGENT_CPP_INTERFACE
constexpr Uint32 GetTotalTriangleCount() const noexcept
{
return PrimitiveCounts[PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] +
PrimitiveCounts[PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] +
PrimitiveCounts[PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ];
}

constexpr Uint32 GetTotalLineCount() const noexcept
{
return PrimitiveCounts[PRIMITIVE_TOPOLOGY_LINE_LIST] +
PrimitiveCounts[PRIMITIVE_TOPOLOGY_LINE_STRIP] +
PrimitiveCounts[PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ];
}

constexpr Uint32 GetTotalPointCount() const noexcept
{
return PrimitiveCounts[PRIMITIVE_TOPOLOGY_POINT_LIST];
}
#endif
};
typedef struct DeviceContextStats DeviceContextStats;


#define DILIGENT_INTERFACE_NAME IDeviceContext
#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
Expand Down Expand Up @@ -3243,6 +3397,12 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject)
/// internal queue supports COMMAND_QUEUE_TYPE_SPARSE_BINDING.
VIRTUAL void METHOD(BindSparseResourceMemory)(THIS_
const BindSparseResourceMemoryAttribs REF Attribs) PURE;

/// Clears the device context statistics.
VIRTUAL void METHOD(ClearStats)(THIS) PURE;

/// Returns the device context statistics, see Diligent::DeviceContextStats.
VIRTUAL const DeviceContextStats REF METHOD(GetStats)(THIS) CONST PURE;
};
DILIGENT_END_INTERFACE

Expand Down Expand Up @@ -3320,6 +3480,8 @@ DILIGENT_END_INTERFACE
# define IDeviceContext_UnlockCommandQueue(This) CALL_IFACE_METHOD(DeviceContext, UnlockCommandQueue, This)
# define IDeviceContext_SetShadingRate(This, ...) CALL_IFACE_METHOD(DeviceContext, SetShadingRate, This, __VA_ARGS__)
# define IDeviceContext_BindSparseResourceMemory(This, ...) CALL_IFACE_METHOD(DeviceContext, BindSparseResourceMemory, This, __VA_ARGS__)
# define IDeviceContext_ClearStats(This) CALL_IFACE_METHOD(DeviceContext, ClearStats, This)
# define IDeviceContext_GetStats(This) CALL_IFACE_METHOD(DeviceContext, GetStats, This)

// clang-format on

Expand Down
12 changes: 6 additions & 6 deletions Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void DeviceContextD3D11Impl::PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE

void DeviceContextD3D11Impl::Draw(const DrawAttribs& Attribs)
{
DvpVerifyDrawArguments(Attribs);
TDeviceContextBase::Draw(Attribs, 0);

PrepareForDraw(Attribs.Flags);

Expand All @@ -674,7 +674,7 @@ void DeviceContextD3D11Impl::Draw(const DrawAttribs& Attribs)

void DeviceContextD3D11Impl::DrawIndexed(const DrawIndexedAttribs& Attribs)
{
DvpVerifyDrawIndexedArguments(Attribs);
TDeviceContextBase::DrawIndexed(Attribs, 0);

PrepareForIndexedDraw(Attribs.Flags, Attribs.IndexType);

Expand All @@ -689,7 +689,7 @@ void DeviceContextD3D11Impl::DrawIndexed(const DrawIndexedAttribs& Attribs)

void DeviceContextD3D11Impl::DrawIndirect(const DrawIndirectAttribs& Attribs)
{
DvpVerifyDrawIndirectArguments(Attribs);
TDeviceContextBase::DrawIndirect(Attribs, 0);
DEV_CHECK_ERR(Attribs.pCounterBuffer == nullptr, "Direct3D11 does not support indirect counter buffer");

PrepareForDraw(Attribs.Flags);
Expand Down Expand Up @@ -726,7 +726,7 @@ void DeviceContextD3D11Impl::DrawIndirect(const DrawIndirectAttribs& Attribs)

void DeviceContextD3D11Impl::DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs)
{
DvpVerifyDrawIndexedIndirectArguments(Attribs);
TDeviceContextBase::DrawIndexedIndirect(Attribs, 0);
DEV_CHECK_ERR(Attribs.pCounterBuffer == nullptr, "Direct3D11 does not support indirect counter buffer");

PrepareForIndexedDraw(Attribs.Flags, Attribs.IndexType);
Expand Down Expand Up @@ -772,7 +772,7 @@ void DeviceContextD3D11Impl::DrawMeshIndirect(const DrawMeshIndirectAttribs& Att

void DeviceContextD3D11Impl::DispatchCompute(const DispatchComputeAttribs& Attribs)
{
DvpVerifyDispatchArguments(Attribs);
TDeviceContextBase::DispatchCompute(Attribs, 0);

if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask())
{
Expand Down Expand Up @@ -802,7 +802,7 @@ void DeviceContextD3D11Impl::DispatchCompute(const DispatchComputeAttribs& Attri

void DeviceContextD3D11Impl::DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs)
{
DvpVerifyDispatchIndirectArguments(Attribs);
TDeviceContextBase::DispatchComputeIndirect(Attribs, 0);

if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask())
{
Expand Down
16 changes: 8 additions & 8 deletions Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ void DeviceContextD3D12Impl::PrepareForIndexedDraw(GraphicsContext& GraphCtx, DR

void DeviceContextD3D12Impl::Draw(const DrawAttribs& Attribs)
{
DvpVerifyDrawArguments(Attribs);
TDeviceContextBase::Draw(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForDraw(GraphCtx, Attribs.Flags);
Expand All @@ -680,7 +680,7 @@ void DeviceContextD3D12Impl::Draw(const DrawAttribs& Attribs)

void DeviceContextD3D12Impl::DrawIndexed(const DrawIndexedAttribs& Attribs)
{
DvpVerifyDrawIndexedArguments(Attribs);
TDeviceContextBase::DrawIndexed(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForIndexedDraw(GraphCtx, Attribs.Flags, Attribs.IndexType);
Expand Down Expand Up @@ -715,7 +715,7 @@ void DeviceContextD3D12Impl::PrepareIndirectAttribsBuffer(CommandContext&

void DeviceContextD3D12Impl::DrawIndirect(const DrawIndirectAttribs& Attribs)
{
DvpVerifyDrawIndirectArguments(Attribs);
TDeviceContextBase::DrawIndirect(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForDraw(GraphCtx, Attribs.Flags);
Expand Down Expand Up @@ -751,7 +751,7 @@ void DeviceContextD3D12Impl::DrawIndirect(const DrawIndirectAttribs& Attribs)

void DeviceContextD3D12Impl::DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs)
{
DvpVerifyDrawIndexedIndirectArguments(Attribs);
TDeviceContextBase::DrawIndexedIndirect(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForIndexedDraw(GraphCtx, Attribs.Flags, Attribs.IndexType);
Expand Down Expand Up @@ -788,7 +788,7 @@ void DeviceContextD3D12Impl::DrawIndexedIndirect(const DrawIndexedIndirectAttrib

void DeviceContextD3D12Impl::DrawMesh(const DrawMeshAttribs& Attribs)
{
DvpVerifyDrawMeshArguments(Attribs);
TDeviceContextBase::DrawMesh(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext6();
PrepareForDraw(GraphCtx, Attribs.Flags);
Expand All @@ -802,7 +802,7 @@ void DeviceContextD3D12Impl::DrawMesh(const DrawMeshAttribs& Attribs)

void DeviceContextD3D12Impl::DrawMeshIndirect(const DrawMeshIndirectAttribs& Attribs)
{
DvpVerifyDrawMeshIndirectArguments(Attribs);
TDeviceContextBase::DrawMeshIndirect(Attribs, 0);

auto& GraphCtx = GetCmdContext().AsGraphicsContext();
PrepareForDraw(GraphCtx, Attribs.Flags);
Expand Down Expand Up @@ -859,7 +859,7 @@ void DeviceContextD3D12Impl::PrepareForDispatchRays(GraphicsContext& GraphCtx)

void DeviceContextD3D12Impl::DispatchCompute(const DispatchComputeAttribs& Attribs)
{
DvpVerifyDispatchArguments(Attribs);
TDeviceContextBase::DispatchCompute(Attribs, 0);

auto& ComputeCtx = GetCmdContext().AsComputeContext();
PrepareForDispatchCompute(ComputeCtx);
Expand All @@ -872,7 +872,7 @@ void DeviceContextD3D12Impl::DispatchCompute(const DispatchComputeAttribs& Attri

void DeviceContextD3D12Impl::DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs)
{
DvpVerifyDispatchIndirectArguments(Attribs);
TDeviceContextBase::DispatchComputeIndirect(Attribs, 0);

auto& ComputeCtx = GetCmdContext().AsComputeContext();
PrepareForDispatchCompute(ComputeCtx);
Expand Down
12 changes: 6 additions & 6 deletions Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void DeviceContextGLImpl::PostDraw()

void DeviceContextGLImpl::Draw(const DrawAttribs& Attribs)
{
DvpVerifyDrawArguments(Attribs);
TDeviceContextBase::Draw(Attribs, 0);

GLenum GlTopology;
PrepareForDraw(Attribs.Flags, false, GlTopology);
Expand All @@ -863,7 +863,7 @@ void DeviceContextGLImpl::Draw(const DrawAttribs& Attribs)

void DeviceContextGLImpl::DrawIndexed(const DrawIndexedAttribs& Attribs)
{
DvpVerifyDrawIndexedArguments(Attribs);
TDeviceContextBase::DrawIndexed(Attribs, 0);

GLenum GlTopology;
PrepareForDraw(Attribs.Flags, true, GlTopology);
Expand Down Expand Up @@ -948,7 +948,7 @@ void DeviceContextGLImpl::PrepareForIndirectDrawCount(IBuffer* pCountBuffer)

void DeviceContextGLImpl::DrawIndirect(const DrawIndirectAttribs& Attribs)
{
DvpVerifyDrawIndirectArguments(Attribs);
TDeviceContextBase::DrawIndirect(Attribs, 0);

GLenum GlTopology;
PrepareForDraw(Attribs.Flags, true, GlTopology);
Expand Down Expand Up @@ -1022,7 +1022,7 @@ void DeviceContextGLImpl::DrawIndirect(const DrawIndirectAttribs& Attribs)

void DeviceContextGLImpl::DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs)
{
DvpVerifyDrawIndexedIndirectArguments(Attribs);
TDeviceContextBase::DrawIndexedIndirect(Attribs, 0);

GLenum GlTopology;
PrepareForDraw(Attribs.Flags, true, GlTopology);
Expand Down Expand Up @@ -1114,7 +1114,7 @@ void DeviceContextGLImpl::DrawMeshIndirect(const DrawMeshIndirectAttribs& Attrib

void DeviceContextGLImpl::DispatchCompute(const DispatchComputeAttribs& Attribs)
{
DvpVerifyDispatchArguments(Attribs);
TDeviceContextBase::DispatchCompute(Attribs, 0);

#if GL_ARB_compute_shader
// The program might have changed since the last SetPipelineState call if a shader was
Expand Down Expand Up @@ -1144,7 +1144,7 @@ void DeviceContextGLImpl::DispatchCompute(const DispatchComputeAttribs& Attribs)

void DeviceContextGLImpl::DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs)
{
DvpVerifyDispatchIndirectArguments(Attribs);
TDeviceContextBase::DispatchComputeIndirect(Attribs, 0);

#if GL_ARB_compute_shader
// The program might have changed since the last SetPipelineState call if a shader was
Expand Down
Loading

0 comments on commit 4e38d04

Please sign in to comment.