From 10cd33e0e314cc02ac9779130b8cf9cc38867b4b Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 27 Jan 2020 11:01:19 -0800 Subject: Reworked C interfaces to share declaration with c++ --- .../include/DefaultShaderSourceStreamFactory.h | 4 +- Graphics/GraphicsEngine/interface/APIInfo.h | 1 + Graphics/GraphicsEngine/interface/BlendState.h | 4 +- Graphics/GraphicsEngine/interface/Buffer.h | 56 +-- Graphics/GraphicsEngine/interface/BufferView.h | 36 +- Graphics/GraphicsEngine/interface/CommandList.h | 4 +- .../GraphicsEngine/interface/DepthStencilState.h | 6 +- Graphics/GraphicsEngine/interface/DeviceCaps.h | 10 +- Graphics/GraphicsEngine/interface/DeviceContext.h | 430 ++++++++++----------- Graphics/GraphicsEngine/interface/DeviceObject.h | 35 +- Graphics/GraphicsEngine/interface/EngineFactory.h | 60 ++- Graphics/GraphicsEngine/interface/Fence.h | 40 +- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 37 +- Graphics/GraphicsEngine/interface/InputLayout.h | 9 +- Graphics/GraphicsEngine/interface/PipelineState.h | 114 +++--- Graphics/GraphicsEngine/interface/Query.h | 48 +-- .../GraphicsEngine/interface/RasterizerState.h | 1 + Graphics/GraphicsEngine/interface/RenderDevice.h | 148 +++---- .../GraphicsEngine/interface/ResourceMapping.h | 76 ++-- Graphics/GraphicsEngine/interface/Sampler.h | 20 +- Graphics/GraphicsEngine/interface/Shader.h | 101 +++-- .../interface/ShaderResourceBinding.h | 69 ++-- .../interface/ShaderResourceVariable.h | 62 +-- Graphics/GraphicsEngine/interface/SwapChain.h | 64 ++- Graphics/GraphicsEngine/interface/Texture.h | 72 ++-- Graphics/GraphicsEngine/interface/TextureView.h | 46 +-- 26 files changed, 804 insertions(+), 749 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h index 7b3b1e47..eb441c97 100644 --- a/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h +++ b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) /// Creates default shader source stream factory /// \param [in] SearchDirectories - Semicolon-seprated list of search directories. /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. -void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, - class IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory); +void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, + IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory); DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 0b6cebd8..8a2b89d3 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -98,5 +98,6 @@ struct APIInfo size_t MappedTextureSubresourceSize DEFAULT_INITIALIZER(0); size_t TextureViewDescSize DEFAULT_INITIALIZER(0); }; +typedef struct APIInfo APIInfo; DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h index 4499c2cc..d1595411 100644 --- a/Graphics/GraphicsEngine/interface/BlendState.h +++ b/Graphics/GraphicsEngine/interface/BlendState.h @@ -362,6 +362,7 @@ struct RenderTargetBlendDesc } #endif }; +typedef struct RenderTargetBlendDesc RenderTargetBlendDesc; /// Blend state description @@ -379,7 +380,7 @@ struct BlendStateDesc /// An array of RenderTargetBlendDesc structures that describe the blend /// states for render targets - struct RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS]; + RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS]; #if DILIGENT_CPP_INTERFACE // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code: @@ -424,5 +425,6 @@ struct BlendStateDesc } #endif }; +typedef struct BlendStateDesc BlendStateDesc; DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h index 8c13d652..1a1f79d1 100644 --- a/Graphics/GraphicsEngine/interface/Buffer.h +++ b/Graphics/GraphicsEngine/interface/Buffer.h @@ -39,7 +39,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4} -static const struct INTERFACE_ID IID_Buffer = +static const INTERFACE_ID IID_Buffer = {0xec47ead3, 0xa2c4, 0x44f2, {0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4}}; /// Describes the buffer access mode. @@ -148,6 +148,7 @@ struct BufferDesc DILIGENT_DERIVE(DeviceObjectAttribs) } #endif }; +typedef struct BufferDesc BufferDesc; /// Describes the buffer initial data struct BufferData @@ -170,18 +171,23 @@ struct BufferData {} #endif }; +typedef struct BufferData BufferData; +#if DILIGENT_C_INTERFACE +# define THIS struct IBuffer* +# define THIS_ struct IBuffer*, +#endif -#if DILIGENT_CPP_INTERFACE /// Buffer interface /// Defines the methods to manipulate a buffer object -class IBuffer : public IDeviceObject +DILIGENT_INTERFACE(IBuffer, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the buffer description used to create the object virtual const BufferDesc& GetDesc() const override = 0; +#endif /// Creates a new buffer view @@ -194,7 +200,9 @@ public: /// until all views are released.\n /// The function calls AddRef() for the created interface, so it must be released by /// a call to Release() when it is no longer needed. - virtual void CreateView(const struct BufferViewDesc& ViewDesc, class IBufferView** ppView) = 0; + VIRTUAL void METHOD(CreateView)(THIS_ + const BufferViewDesc REF ViewDesc, + IBufferView** ppView) PURE; /// Returns the pointer to the default view. @@ -206,14 +214,15 @@ public: /// /// \note The function does not increase the reference counter for the returned interface, so /// Release() must *NOT* be called. - virtual IBufferView* GetDefaultView(BUFFER_VIEW_TYPE ViewType) = 0; + VIRTUAL IBufferView* METHOD(GetDefaultView)(THIS_ + BUFFER_VIEW_TYPE ViewType) PURE; /// Returns native buffer handle specific to the underlying graphics API /// \return pointer to ID3D11Resource interface, for D3D11 implementation\n /// pointer to ID3D12Resource interface, for D3D12 implementation\n /// GL buffer handle, for GL implementation - virtual void* GetNativeHandle() = 0; + VIRTUAL void* METHOD(GetNativeHandle)(THIS) PURE; /// Sets the buffer usage state. @@ -222,24 +231,17 @@ public: /// This method should be used after the application finished /// manually managing the buffer state and wants to hand over /// state management back to the engine. - virtual void SetState(RESOURCE_STATE State) = 0; + VIRTUAL void METHOD(SetState)(THIS_ + RESOURCE_STATE State) PURE; /// Returns the internal buffer state - virtual RESOURCE_STATE GetState() const = 0; + VIRTUAL RESOURCE_STATE METHOD(GetState)(THIS) CONST PURE; }; -#else +#if DILIGENT_C_INTERFACE -struct IBuffer; - -struct IBufferMethods -{ - void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView); - class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType); - void* (*GetNativeHandle)(struct IBuffer*); - void (*SetState) (struct IBuffer*,RESOURCE_STATE State); - RESOURCE_STATE (*GetState) (struct IBuffer*); -}; +#undef THIS +#undef THIS_ // clang-format on @@ -250,20 +252,20 @@ struct IBufferVtbl struct IBufferMethods Buffer; }; -struct IBuffer +typedef struct IBuffer { struct IBufferVtbl* pVtbl; -}; +} IBuffer; // clang-format off # define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This) -# define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((struct IBuffer*)(This), __VA_ARGS__) -# define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__) -# define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((struct IBuffer*)(This)) -# define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((struct IBuffer*)(This), __VA_ARGS__) -# define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((struct IBuffer*)(This)) +# define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((IBuffer*)(This)) +# define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((IBuffer*)(This), __VA_ARGS__) +# define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((IBuffer*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h index 6daf555f..fbdb6636 100644 --- a/Graphics/GraphicsEngine/interface/BufferView.h +++ b/Graphics/GraphicsEngine/interface/BufferView.h @@ -82,6 +82,7 @@ struct BufferFormat } #endif }; +typedef struct BufferFormat BufferFormat; /// Buffer view description struct BufferViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) @@ -136,9 +137,14 @@ struct BufferViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) } #endif }; +typedef struct BufferViewDesc BufferViewDesc; -#if DILIGENT_CPP_INTERFACE + +#if DILIGENT_C_INTERFACE +# define THIS struct IBufferView* +# define THIS_ struct IBufferView*, +#endif /// Buffer view interface @@ -146,28 +152,26 @@ struct BufferViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// \remarks /// Buffer view holds strong references to the buffer. The buffer /// will not be destroyed until all views are released. -class IBufferView : public IDeviceObject +DILIGENT_INTERFACE(IBufferView, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the buffer view description used to create the object virtual const BufferViewDesc& GetDesc() const override = 0; +#endif /// Returns pointer to the referenced buffer object. /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual class IBuffer* GetBuffer() = 0; + VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) PURE; }; -#else +#if DILIGENT_C_INTERFACE -class IBufferView; -class IBuffer; +# undef THIS +# undef THIS_ -struct IBufferViewMethods -{ - class IBuffer* (*GetBuffer)(struct IBufferView*); -}; +// clang-format on struct IBufferViewVtbl { @@ -176,14 +180,18 @@ struct IBufferViewVtbl struct IBufferViewMethods BufferView; }; -struct IBufferView +typedef struct IBufferView { struct IBufferViewVtbl* pVtbl; -}; +} IBufferView; + +// clang-format off # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This) -# define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((struct IBufferView*)(This)) +# define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((IBufferView*)(This)) + +// clang-format on #endif diff --git a/Graphics/GraphicsEngine/interface/CommandList.h b/Graphics/GraphicsEngine/interface/CommandList.h index 521797a6..12eba2c1 100644 --- a/Graphics/GraphicsEngine/interface/CommandList.h +++ b/Graphics/GraphicsEngine/interface/CommandList.h @@ -65,10 +65,10 @@ struct ICommandListVtbl //struct ICommandListMethods CommandList; }; -struct ICommandList +typedef struct ICommandList { struct ICommandListVtbl* pVtbl; -}; +} ICommandList; #endif diff --git a/Graphics/GraphicsEngine/interface/DepthStencilState.h b/Graphics/GraphicsEngine/interface/DepthStencilState.h index 39c4111d..0a65e9cd 100644 --- a/Graphics/GraphicsEngine/interface/DepthStencilState.h +++ b/Graphics/GraphicsEngine/interface/DepthStencilState.h @@ -145,6 +145,7 @@ struct StencilOpDesc } #endif }; +typedef struct StencilOpDesc StencilOpDesc; /// Depth stencil state description @@ -180,10 +181,10 @@ struct DepthStencilStateDesc Uint8 StencilWriteMask DEFAULT_INITIALIZER(0xFF); /// Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc. - struct StencilOpDesc FrontFace; + StencilOpDesc FrontFace; /// Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc. - struct StencilOpDesc BackFace; + StencilOpDesc BackFace; #if DILIGENT_CPP_INTERFACE @@ -229,5 +230,6 @@ struct DepthStencilStateDesc } #endif }; +typedef struct DepthStencilStateDesc DepthStencilStateDesc; DILIGENT_END_NAMESPACE diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h index e43a343c..1f0dc257 100644 --- a/Graphics/GraphicsEngine/interface/DeviceCaps.h +++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h @@ -60,6 +60,7 @@ struct SamplerCaps /// Indicates if device supports MIP load bias Bool LODBiasSupported DEFAULT_INITIALIZER(False); }; +typedef struct SamplerCaps SamplerCaps; /// Texture capabilities struct TextureCaps @@ -94,6 +95,7 @@ struct TextureCaps /// Indicates if device supports cubemap arrays Bool CubemapArraysSupported DEFAULT_INITIALIZER(False); }; +typedef struct TextureCaps TextureCaps; /// Describes supported device features struct DeviceFeatures @@ -163,6 +165,7 @@ struct DeviceFeatures /// Specifies whether all the extended UAV texture formats are available in shader code. Bool TextureUAVExtendedFormats DEFAULT_INITIALIZER(False); }; +typedef struct DeviceFeatures DeviceFeatures; /// Device capabilities struct DeviceCaps @@ -184,13 +187,13 @@ struct DeviceCaps ADAPTER_TYPE AdaterType DEFAULT_INITIALIZER(ADAPTER_TYPE_UNKNOWN); /// Texture sampling capabilities. See Diligent::SamplerCaps. - struct SamplerCaps SamCaps; + SamplerCaps SamCaps; /// Texture capabilities. See Diligent::TextureCaps. - struct TextureCaps TexCaps; + TextureCaps TexCaps; /// Device features. See Diligent::DeviceFeatures. - struct DeviceFeatures Features; + DeviceFeatures Features; #if DILIGENT_CPP_INTERFACE bool IsGLDevice()const @@ -250,5 +253,6 @@ struct DeviceCaps } #endif }; +typedef struct DeviceCaps DeviceCaps; DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index a1c44a13..8484be67 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -56,7 +56,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {DC92711B-A1BE-4319-B2BD-C662D1CC19E4} -static const struct INTERFACE_ID IID_DeviceContext = +static const INTERFACE_ID IID_DeviceContext = {0xdc92711b, 0xa1be, 0x4319, {0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4}}; /// Draw command flags @@ -210,6 +210,7 @@ struct DrawAttribs {} #endif }; +typedef struct DrawAttribs DrawAttribs; /// Defines the indexed draw command attributes. @@ -276,7 +277,7 @@ struct DrawIndexedAttribs {} #endif }; - +typedef struct DrawIndexedAttribs DrawIndexedAttribs; /// Defines the indirect draw command attributes. @@ -314,7 +315,7 @@ struct DrawIndirectAttribs {} #endif }; - +typedef struct DrawIndirectAttribs DrawIndirectAttribs; /// Defines the indexed indirect draw command attributes. @@ -359,7 +360,7 @@ struct DrawIndexedIndirectAttribs {} #endif }; - +typedef struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs; /// Defines which parts of the depth-stencil buffer to clear. @@ -398,6 +399,8 @@ struct DispatchComputeAttribs {} #endif }; +typedef struct DispatchComputeAttribs DispatchComputeAttribs; + /// Describes dispatch command arguments. @@ -422,6 +425,7 @@ struct DispatchComputeIndirectAttribs {} #endif }; +typedef struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs; /// Describes multi-sampled texture resolve command arguments. @@ -452,6 +456,8 @@ struct ResolveTextureSubresourceAttribs /// either TEX_FORMAT_UNKNOWN, or match this format. TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); }; +typedef struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs; + /// Defines allowed flags for IDeviceContext::SetVertexBuffers() function. DILIGENT_TYPED_ENUM(SET_VERTEX_BUFFERS_FLAGS, Uint8) @@ -508,6 +514,8 @@ struct Viewport Viewport()noexcept{} #endif }; +typedef struct Viewport Viewport; + /// Describes the rectangle. @@ -540,6 +548,7 @@ struct Rect } #endif }; +typedef struct Rect Rect; /// Defines copy texture command attributes. @@ -548,7 +557,7 @@ struct Rect struct CopyTextureAttribs { /// Source texture to copy data from. - class ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr); + ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr); /// Mip level of the source texture to copy data from. Uint32 SrcMipLevel DEFAULT_INITIALIZER(0); @@ -557,13 +566,13 @@ struct CopyTextureAttribs Uint32 SrcSlice DEFAULT_INITIALIZER(0); /// Source region to copy. Use nullptr to copy the entire subresource. - const struct Box* pSrcBox DEFAULT_INITIALIZER(nullptr); + const Box* pSrcBox DEFAULT_INITIALIZER(nullptr); /// Source texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); /// Destination texture. - class ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr); + ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr); /// Destination mip level. Uint32 DstMipLevel DEFAULT_INITIALIZER(0); @@ -598,10 +607,13 @@ struct CopyTextureAttribs {} #endif }; +typedef struct CopyTextureAttribs CopyTextureAttribs; - -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IDeviceContext* +# define THIS_ struct IDeviceContext*, +#endif /// Device context interface. @@ -609,13 +621,13 @@ struct CopyTextureAttribs /// the pipeline: buffers, states, samplers, shaders, etc. /// The context also keeps strong reference to the device and /// the swap chain. -class IDeviceContext : public IObject +DILIGENT_INTERFACE(IDeviceContext, IObject) { -public: /// Sets the pipeline state. /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context. - virtual void SetPipelineState(IPipelineState* pPipelineState) = 0; + VIRTUAL void METHOD(SetPipelineState)(THIS_ + IPipelineState* pPipelineState) PURE; /// Transitions shader resources to the states required by Draw or Dispatch command. @@ -636,7 +648,9 @@ public: /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) = 0; + VIRTUAL void METHOD(TransitionShaderResources)(THIS_ + IPipelineState* pPipelineState, + IShaderResourceBinding* pShaderResourceBinding) PURE; /// Commits shader resources to the device context. @@ -675,12 +689,15 @@ public: /// If an application calls any method that changes the state of any resource after it has been committed, the /// application is responsible for transitioning the resource back to correct state using one of the available methods /// before issuing the next draw or dispatch command. - virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(CommitShaderResources)(THIS_ + IShaderResourceBinding* pShaderResourceBinding, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Sets the stencil reference value. /// \param [in] StencilRef - Stencil reference value. - virtual void SetStencilRef(Uint32 StencilRef) = 0; + VIRTUAL void METHOD(SetStencilRef)(THIS_ + Uint32 StencilRef) PURE; /// \param [in] pBlendFactors - Array of four blend factors, one for each RGBA component. @@ -689,7 +706,8 @@ public: /// Diligent::BLEND_FACTOR_INV_BLEND_FACTOR /// blend factors. If nullptr is provided, /// default blend factors array {1,1,1,1} will be used. - virtual void SetBlendFactors(const float* pBlendFactors = nullptr) = 0; + VIRTUAL void METHOD(SetBlendFactors)(THIS_ + const float* pBlendFactors DEFAULT_VALUE(nullptr)) PURE; /// Binds vertex buffers to the pipeline. @@ -722,19 +740,20 @@ public: /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void SetVertexBuffers(Uint32 StartSlot, - Uint32 NumBuffersSet, - IBuffer** ppBuffers, - Uint32* pOffsets, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, - SET_VERTEX_BUFFERS_FLAGS Flags) = 0; + VIRTUAL void METHOD(SetVertexBuffers)(THIS_ + Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, + SET_VERTEX_BUFFERS_FLAGS Flags) PURE; /// Invalidates the cached context state. /// This method should be called by an application to invalidate /// internal cached states. - virtual void InvalidateState() = 0; + VIRTUAL void METHOD(InvalidateState)(THIS) PURE; /// Binds an index buffer to the pipeline. @@ -758,7 +777,10 @@ public: /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(SetIndexBuffer)(THIS_ + IBuffer* pIndexBuffer, + Uint32 ByteOffset, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Sets an array of viewports. @@ -779,7 +801,11 @@ public: /// following call: /// /// pContext->SetViewports(1, nullptr, 0, 0); - virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) = 0; + VIRTUAL void METHOD(SetViewports)(THIS_ + Uint32 NumViewports, + const Viewport* pViewports, + Uint32 RTWidth, + Uint32 RTHeight) PURE; /// Sets active scissor rects. @@ -796,7 +822,11 @@ public: /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n /// All scissor rects must be set atomically as one operation. Any rects not /// defined by the call are disabled. - virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) = 0; + VIRTUAL void METHOD(SetScissorRects)(THIS_ + Uint32 NumRects, + const Rect* pRects, + Uint32 RTWidth, + Uint32 RTHeight) PURE; /// Binds one or more render targets and the depth-stencil buffer to the context. It also @@ -826,10 +856,11 @@ public: /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void SetRenderTargets(Uint32 NumRenderTargets, - ITextureView* ppRenderTargets[], - ITextureView* pDepthStencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(SetRenderTargets)(THIS_ + Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Executes a draw command. @@ -842,7 +873,8 @@ public: /// /// If the application intends to use the same resources in other threads simultaneously, it needs to /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. - virtual void Draw(const DrawAttribs& Attribs) = 0; + VIRTUAL void METHOD(Draw)(THIS_ + const DrawAttribs REF Attribs) PURE; /// Executes an indexed draw command. @@ -855,7 +887,8 @@ public: /// /// If the application intends to use the same resources in other threads simultaneously, it needs to /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. - virtual void DrawIndexed(const DrawIndexedAttribs& Attribs) = 0; + VIRTUAL void METHOD(DrawIndexed)(THIS_ + const DrawIndexedAttribs REF Attribs) PURE; /// Executes an indirect draw command. @@ -873,7 +906,9 @@ public: /// /// If the application intends to use the same resources in other threads simultaneously, it needs to /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. - virtual void DrawIndirect(const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; + VIRTUAL void METHOD(DrawIndirect)(THIS_ + const DrawIndirectAttribs REF Attribs, + IBuffer* pAttribsBuffer) PURE; /// Executes an indexed indirect draw command. @@ -891,13 +926,16 @@ public: /// /// If the application intends to use the same resources in other threads simultaneously, it needs to /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. - virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; + VIRTUAL void METHOD(DrawIndexedIndirect)(THIS_ + const DrawIndexedIndirectAttribs REF Attribs, + IBuffer* pAttribsBuffer) PURE; /// Executes a dispatch compute command. /// \param [in] Attribs - Dispatch command attributes, see Diligent::DispatchComputeAttribs for details. - virtual void DispatchCompute(const DispatchComputeAttribs& Attribs) = 0; + VIRTUAL void METHOD(DispatchCompute)(THIS_ + const DispatchComputeAttribs REF Attribs) PURE; /// Executes an indirect dispatch compute command. @@ -911,7 +949,9 @@ public: /// /// If the application intends to use the same resources in other threads simultaneously, it needs to /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. - virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; + VIRTUAL void METHOD(DispatchComputeIndirect)(THIS_ + const DispatchComputeIndirectAttribs REF Attribs, + IBuffer* pAttribsBuffer) PURE; /// Clears a depth-stencil view. @@ -935,11 +975,12 @@ public: /// the state of resources used by the command. /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void ClearDepthStencil(ITextureView* pView, - CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, - float fDepth, - Uint8 Stencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(ClearDepthStencil)(THIS_ + ITextureView* pView, + CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, + float fDepth, + Uint8 Stencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Clears a render target view @@ -967,20 +1008,25 @@ public: /// Diligent::RESOURCE_STATE_COPY_DEST state. Inside a render pass it must be in Diligent::RESOURCE_STATE_RENDER_TARGET /// state. When using Diligent::RESOURCE_STATE_TRANSITION_TRANSITION mode, the engine takes care of proper /// resource state transition, otherwise it is the responsibility of the application. - virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(ClearRenderTarget)(THIS_ + ITextureView* pView, + const float* RGBA, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Finishes recording commands and generates a command list. /// \param [out] ppCommandList - Memory location where pointer to the recorded command list will be written. - virtual void FinishCommandList(ICommandList **ppCommandList) = 0; + VIRTUAL void METHOD(FinishCommandList)(THIS_ + ICommandList** ppCommandList) PURE; /// Executes recorded commands in a command list. /// \param [in] pCommandList - Pointer to the command list to executre. /// \remarks After command list is executed, it is no longer valid and should be released. - virtual void ExecuteCommandList(ICommandList* pCommandList) = 0; + VIRTUAL void METHOD(ExecuteCommandList)(THIS_ + ICommandList* pCommandList) PURE; /// Tells the GPU to set a fence to a specified value after all previous work has completed. @@ -993,7 +1039,9 @@ public: /// \param [in] pFence - The fence to signal /// \param [in] Value - The value to set the fence to. This value must be greater than the /// previously signaled value on the same fence. - virtual void SignalFence(IFence* pFence, Uint64 Value) = 0; + VIRTUAL void METHOD(SignalFence)(THIS_ + IFence* pFence, + Uint64 Value) PURE; /// Waits until the specified fence reaches or exceeds the specified value, on the host. @@ -1015,7 +1063,10 @@ public: /// may never return.\n /// The fence can only be waited for from the same context it has /// previously been signaled. - virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) = 0; + VIRTUAL void METHOD(WaitForFence)(THIS_ + IFence* pFence, + Uint64 Value, + bool FlushContext) PURE; /// Submits all outstanding commands for execution to the GPU and waits until they are complete. @@ -1026,7 +1077,7 @@ public: /// The methods implicitly flushes the context (see IDeviceContext::Flush()), so an /// application must explicitly reset the PSO and bind all required shader resources after /// idling the context.\n - virtual void WaitForIdle() = 0; + VIRTUAL void METHOD(WaitForIdle)(THIS) PURE; /// Marks the beginning of a query. @@ -1047,7 +1098,8 @@ public: /// SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE). /// /// \warning OpenGL and Vulkan do not support nested queries of the same type. - virtual void BeginQuery(IQuery* pQuery) = 0; + VIRTUAL void METHOD(BeginQuery)(THIS_ + IQuery* pQuery) PURE; /// Marks the end of a query. @@ -1063,7 +1115,8 @@ public: /// It is an error to explicitly flush the context while a query is active. /// /// All queries must be ended when IDeviceContext::FinishFrame() is called. - virtual void EndQuery(IQuery* pQuery) = 0; + VIRTUAL void METHOD(EndQuery)(THIS_ + IQuery* pQuery) PURE; /// Submits all pending commands in the context for execution to the command queue. @@ -1075,7 +1128,7 @@ public: /// restore viewports and scissor rects, etc.) except for the pipeline state and shader resource /// bindings. An application must explicitly reset the PSO and bind all required shader /// resources after flushing the context. - virtual void Flush() = 0; + VIRTUAL void METHOD(Flush)(THIS) PURE; /// Updates the data in the buffer. @@ -1085,11 +1138,12 @@ public: /// \param [in] Size - Size in bytes of the data region to update. /// \param [in] pData - Pointer to the data to write to the buffer. /// \param [in] StateTransitionMode - Buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE) - virtual void UpdateBuffer(IBuffer* pBuffer, - Uint32 Offset, - Uint32 Size, - const void* pData, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; + VIRTUAL void METHOD(UpdateBuffer)(THIS_ + IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const void* pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; /// Copies the data from one buffer to another. @@ -1102,13 +1156,14 @@ public: /// of the destination region. /// \param [in] Size - Size in bytes of data to copy. /// \param [in] DstBufferTransitionMode - State transition mode of the destination buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE). - virtual void CopyBuffer(IBuffer* pSrcBuffer, - Uint32 SrcOffset, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - IBuffer* pDstBuffer, - Uint32 DstOffset, - Uint32 Size, - RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) = 0; + VIRTUAL void METHOD(CopyBuffer)(THIS_ + IBuffer* pSrcBuffer, + Uint32 SrcOffset, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + IBuffer* pDstBuffer, + Uint32 DstOffset, + Uint32 Size, + RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) PURE; /// Maps the buffer. @@ -1117,7 +1172,11 @@ public: /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE. /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS. /// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region. - virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) = 0; + VIRTUAL void METHOD(MapBuffer)(THIS_ + IBuffer* pBuffer, + MAP_TYPE MapType, + MAP_FLAGS MapFlags, + PVoid REF pMappedData) PURE; /// Unmaps the previously mapped buffer. @@ -1125,7 +1184,9 @@ public: /// \param [in] pBuffer - Pointer to the buffer to unmap. /// \param [in] MapType - Type of the map operation. This parameter must match the type that was /// provided to the Map() method. - virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) = 0; + VIRTUAL void METHOD(UnmapBuffer)(THIS_ + IBuffer* pBuffer, + MAP_TYPE MapType) PURE; /// Updates the data in the texture. @@ -1139,19 +1200,21 @@ public: /// parameter defines state transition mode of the source buffer. /// If pSrcBuffer is null, this parameter is ignored. /// \param [in] TextureTransitionMode - Texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE) - virtual void UpdateTexture(ITexture* pTexture, - Uint32 MipLevel, - Uint32 Slice, - const Box& DstBox, - const TextureSubResData& SubresData, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) = 0; + VIRTUAL void METHOD(UpdateTexture)(THIS_ + ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box REF DstBox, + const TextureSubResData REF SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) PURE; /// Copies data from one texture to another. /// \param [in] CopyAttribs - Structure describing copy command attributes, see Diligent::CopyTextureAttribs for details. - virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) = 0; + VIRTUAL void METHOD(CopyTexture)(THIS_ + const CopyTextureAttribs REF CopyAttribs) PURE; /// Maps the texture subresource. @@ -1168,17 +1231,21 @@ public: /// subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource. /// In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping /// with MAP_FLAG_DISCARD has exactly the same behavior. - virtual void MapTextureSubresource(ITexture* pTexture, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - MAP_FLAGS MapFlags, - const Box* pMapRegion, - MappedTextureSubresource& MappedData) = 0; + VIRTUAL void METHOD(MapTextureSubresource)(THIS_ + ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + MAP_FLAGS MapFlags, + const Box* pMapRegion, + MappedTextureSubresource REF MappedData) PURE; /// Unmaps the texture subresource. - virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) = 0; + VIRTUAL void METHOD(UnmapTextureSubresource)(THIS_ + ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice) PURE; /// Generates a mipmap chain. @@ -1186,7 +1253,8 @@ public: /// \param [in] pTextureView - Texture view to generate mip maps for. /// \remarks This function can only be called for a shader resource view. /// The texture must be created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag. - virtual void GenerateMips(ITextureView* pTextureView) = 0; + VIRTUAL void METHOD(GenerateMips)(THIS_ + ITextureView* pTextureView) PURE; /// Finishes the current frame and releases dynamic resources allocated by the context. @@ -1201,7 +1269,7 @@ public: /// For deferred contexts, this method must be called after all command lists referencing dynamic resources /// have been executed through immediate context.\n /// The method does not Flush() the context. - virtual void FinishFrame() = 0; + VIRTUAL void METHOD(FinishFrame)(THIS) PURE; /// Transitions resource states. @@ -1233,7 +1301,9 @@ public: /// /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation /// of resource state management in Diligent Engine. - virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) = 0; + VIRTUAL void METHOD(TransitionResourceStates)(THIS_ + Uint32 BarrierCount, + StateTransitionDesc* pResourceBarriers) PURE; /// Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource. @@ -1241,114 +1311,18 @@ public: /// \param [in] pSrcTexture - Source multi-sampled texture. /// \param [in] pDstTexture - Destination non-multi-sampled texture. /// \param [in] ResolveAttribs - Resolve command attributes, see Diligent::ResolveTextureSubresourceAttribs for details. - virtual void ResolveTextureSubresource(ITexture* pSrcTexture, - ITexture* pDstTexture, - const ResolveTextureSubresourceAttribs& ResolveAttribs) = 0; + VIRTUAL void METHOD(ResolveTextureSubresource)(THIS_ + ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE; }; -#else - -// clang-format on +#if DILIGENT_C_INTERFACE -struct IDeviceContext; +# undef THIS +# undef THIS_ -struct IDeviceContextMethods -{ - void (*SetPipelineState)(struct IDeviceContext*, class IPipelineState* pPipelineState); - void (*TransitionShaderResources)(struct IDeviceContext*, class IPipelineState* pPipelineState, class IShaderResourceBinding* pShaderResourceBinding); - void (*CommitShaderResources)(struct IDeviceContext*, class IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*SetStencilRef)(struct IDeviceContext*, Uint32 StencilRef); - void (*SetBlendFactors)(struct IDeviceContext*, const float* pBlendFactors); - void (*SetVertexBuffers)(struct IDeviceContext*, - Uint32 StartSlot, - Uint32 NumBuffersSet, - class IBuffer** ppBuffers, - Uint32* pOffsets, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, - SET_VERTEX_BUFFERS_FLAGS Flags); - void (*InvalidateState)(struct IDeviceContext*); - void (*SetIndexBuffer)(struct IDeviceContext*, - class IBuffer* pIndexBuffer, - Uint32 ByteOffset, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*SetViewports)(struct IDeviceContext*, - Uint32 NumViewports, - const struct Viewport* pViewports, - Uint32 RTWidth, - Uint32 RTHeight); - void (*SetScissorRects)(struct IDeviceContext*, - Uint32 NumRects, - const struct Rect* pRects, - Uint32 RTWidth, - Uint32 RTHeight); - void (*SetRenderTargets)(struct IDeviceContext*, - Uint32 NumRenderTargets, - class ITextureView* ppRenderTargets[], - class ITextureView* pDepthStencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*Draw)(struct IDeviceContext*, const struct DrawAttribs* Attribs); - void (*DrawIndexed)(struct IDeviceContext*, const struct DrawIndexedAttribs* Attribs); - void (*DrawIndirect)(struct IDeviceContext*, const struct DrawIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); - void (*DrawIndexedIndirect)(struct IDeviceContext*, const struct DrawIndexedIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); - void (*DispatchCompute)(struct IDeviceContext*, const struct DispatchComputeAttribs* Attribs); - void (*DispatchComputeIndirect)(struct IDeviceContext*, const struct DispatchComputeIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); - void (*ClearDepthStencil)(struct IDeviceContext*, - class ITextureView* pView, - CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, - float fDepth, - Uint8 Stencil, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*ClearRenderTarget)(struct IDeviceContext*, class ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*FinishCommandList)(struct IDeviceContext*, class ICommandList** ppCommandList); - void (*ExecuteCommandList)(struct IDeviceContext*, class ICommandList* pCommandList); - void (*SignalFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value); - void (*WaitForFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value, bool FlushContext); - void (*WaitForIdle)(struct IDeviceContext*); - void (*BeginQuery)(struct IDeviceContext*, class IQuery* pQuery); - void (*EndQuery)(struct IDeviceContext*, class IQuery* pQuery); - void (*Flush)(struct IDeviceContext*); - void (*UpdateBuffer)(struct IDeviceContext*, - class IBuffer* pBuffer, - Uint32 Offset, - Uint32 Size, - const void* pData, - RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); - void (*CopyBuffer)(struct IDeviceContext*, - class IBuffer* pSrcBuffer, - Uint32 SrcOffset, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - class IBuffer* pDstBuffer, - Uint32 DstOffset, - Uint32 Size, - RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode); - void (*MapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid* pMappedData); - void (*UnmapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType); - void (*UpdateTexture)(struct IDeviceContext*, - class ITexture* pTexture, - Uint32 MipLevel, - Uint32 Slice, - const struct Box* DstBox, - const struct TextureSubResData* SubresData, - RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, - RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode); - void (*CopyTexture)(struct IDeviceContext*, const struct CopyTextureAttribs* CopyAttribs); - void (*MapTextureSubresource)(struct IDeviceContext*, - class ITexture* pTexture, - Uint32 MipLevel, - Uint32 ArraySlice, - MAP_TYPE MapType, - MAP_FLAGS MapFlags, - const struct Box* pMapRegion, - struct MappedTextureSubresource* MappedData); - void (*UnmapTextureSubresource)(struct IDeviceContext*, class ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice); - void (*GenerateMips)(struct IDeviceContext*, class ITextureView* pTextureView); - void (*FinishFrame)(struct IDeviceContext*); - void (*TransitionResourceStates)(struct IDeviceContext*, Uint32 BarrierCount, struct StateTransitionDesc* pResourceBarriers); - void (*ResolveTextureSubresource)(struct IDeviceContext*, - class ITexture* pSrcTexture, - class ITexture* pDstTexture, - const struct ResolveTextureSubresourceAttribs* ResolveAttribs); -}; +// clang-format on struct IDeviceContextVtbl { @@ -1356,52 +1330,52 @@ struct IDeviceContextVtbl struct IDeviceContextMethods DeviceContext; }; -struct IDeviceContext +typedef struct IDeviceContext { struct IDeviceContextVtbl* pVtbl; -}; +} IDeviceContext; // clang-format off -# define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((struct IDeviceContext*)(This)) -# define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((struct IDeviceContext*)(This)) -# define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((struct IDeviceContext*)(This), __VA_ARGS__) -# define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((IDeviceContext*)(This)) +# define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((IDeviceContext*)(This)) +# define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((IDeviceContext*)(This), __VA_ARGS__) +# define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/DeviceObject.h b/Graphics/GraphicsEngine/interface/DeviceObject.h index 98c90c07..3feba088 100644 --- a/Graphics/GraphicsEngine/interface/DeviceObject.h +++ b/Graphics/GraphicsEngine/interface/DeviceObject.h @@ -37,17 +37,19 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {5B4CCA0B-5075-4230-9759-F48769EE5502} -static const struct INTERFACE_ID IID_DeviceObject = +static const INTERFACE_ID IID_DeviceObject = {0x5b4cca0b, 0x5075, 0x4230, {0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2}}; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IDeviceObject* +# define THIS_ struct IDeviceObject*, +#endif /// Base interface for all objects created by the render device Diligent::IRenderDevice -class IDeviceObject : public IObject +DILIGENT_INTERFACE(IDeviceObject, IObject) { -public: /// Returns the object description - virtual const DeviceObjectAttribs& GetDesc() const = 0; + VIRTUAL const DeviceObjectAttribs REF METHOD(GetDesc)(THIS) CONST PURE; /// Returns unique identifier assigned to an object @@ -66,38 +68,31 @@ public: /// /// Valid identifiers are always positive values. Zero and negative values can never be /// assigned to an object and are always guaranteed to be invalid. - virtual Int32 GetUniqueID() const = 0; + VIRTUAL Int32 METHOD(GetUniqueID)(THIS) CONST PURE; }; -#else +#if DILIGENT_C_INTERFACE -struct IDeviceObject; +# undef THIS +# undef THIS_ // clang-format off -struct IDeviceObjectMethods -{ - const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*); - Int32 (*GetUniqueID)(struct IDeviceObject*); -}; - -// clang-format on - struct IDeviceObjectVtbl { struct IObjectMethods Object; struct IDeviceObjectMethods DeviceObject; }; -struct IDeviceObject +typedef struct IDeviceObject { struct IDeviceObjectVtbl* pVtbl; -}; +}IDeviceObject; // clang-format off -# define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((struct IDeviceObject*)(This)) -# define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((struct IDeviceObject*)(This)) +# define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((IDeviceObject*)(This)) +# define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((IDeviceObject*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/EngineFactory.h b/Graphics/GraphicsEngine/interface/EngineFactory.h index eab3d9e8..829e9ccd 100644 --- a/Graphics/GraphicsEngine/interface/EngineFactory.h +++ b/Graphics/GraphicsEngine/interface/EngineFactory.h @@ -35,54 +35,48 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) -class IShaderSourceInputStreamFactory; +struct IShaderSourceInputStreamFactory; // {D932B052-4ED6-4729-A532-F31DEEC100F3} -static const struct INTERFACE_ID IID_EngineFactory = +static const INTERFACE_ID IID_EngineFactory = {0xd932b052, 0x4ed6, 0x4729, {0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3}}; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IEngineFactory* +# define THIS_ struct IEngineFactory*, +#endif + +// clang-format off /// Engine factory base interface -class IEngineFactory : public IObject +DILIGENT_INTERFACE(IEngineFactory, IObject) { -public: /// Returns API info structure - virtual const APIInfo& GetAPIInfo() const = 0; + VIRTUAL const APIInfo REF METHOD(GetAPIInfo)(THIS) CONST PURE; /// Creates default shader source input stream factory /// \param [in] SearchDirectories - Semicolon-seprated list of search directories. /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. - virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, - IShaderSourceInputStreamFactory** ppShaderSourceFactory) const = 0; + VIRTUAL void METHOD(CreateDefaultShaderSourceStreamFactory)( + THIS_ + const Char* SearchDirectories, + struct IShaderSourceInputStreamFactory** ppShaderSourceFactory) CONST PURE; -# if PLATFORM_ANDROID +#if PLATFORM_ANDROID /// On Android platform, it is necessary to initialize the file system before /// CreateDefaultShaderSourceStreamFactory() method can be called. /// \param [in] Activity - Pointer to the activity. /// \param [in] ActivityClassName - Activity class name. - virtual void InitAndroidFileSystem(void* Activity, const char* ActivityClassName) const = 0; -# endif + VIRTUAL void METHOD(InitAndroidFileSystem)(THIS_ + void* Activity, + const char* ActivityClassName) CONST PURE; +#endif }; -#else - -struct IEngineFactory; -struct IShaderSourceInputStreamFactory; - -// clang-format off +#if DILIGENT_C_INTERFACE -struct IEngineFactoryMethods -{ - const struct APIInfo* (*GetAPIInfo) (struct IEngineFactory*); - void (*CreateDefaultShaderSourceStreamFactory)(struct IEngineFactory*, - const Char* SearchDirectories, - struct IShaderSourceInputStreamFactory** ppShaderSourceFactory); - -# if PLATFORM_ANDROID - void (*InitAndroidFileSystem) (struct IEngineFactory*, void* Activity, const char* ActivityClassName); -# endif -}; +# undef THIS +# undef THIS_ // clang-format on @@ -92,16 +86,16 @@ struct IEngineFactoryVtbl struct IEngineFactoryMethods EngineFactory; }; -struct IEngineFactory +typedef struct IEngineFactory { struct IEngineFactoryVtbl* pVtbl; -}; +} IEngineFactory; // clang-format off -# define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((struct IEngineFactory*)(This)) -# define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((struct IEngineFactory*)(This), __VA_ARGS__) -# define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((struct IEngineFactory*)(This), __VA_ARGS__) +# define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((IEngineFactory*)(This)) +# define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((IEngineFactory*)(This), __VA_ARGS__) +# define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((IEngineFactory*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/Fence.h b/Graphics/GraphicsEngine/interface/Fence.h index fd21bf03..b1fe06c1 100644 --- a/Graphics/GraphicsEngine/interface/Fence.h +++ b/Graphics/GraphicsEngine/interface/Fence.h @@ -35,17 +35,21 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {3B19184D-32AB-4701-84F4-9A0C03AE1672} -static const struct INTERFACE_ID IID_Fence = +static const INTERFACE_ID IID_Fence = {0x3b19184d, 0x32ab, 0x4701, {0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72}}; // clang-format off /// Fence description struct FenceDesc DILIGENT_DERIVE(DeviceObjectAttribs) }; -// clang-format on +typedef struct FenceDesc FenceDesc; +// clang-format off -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IFence* +# define THIS_ struct IFence*, +#endif /// Fence interface @@ -53,34 +57,30 @@ struct FenceDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// /// \remarks When a fence that was previously signaled by IDeviceContext::SignalFence() is destroyed, /// it may block the GPU until all prior commands have completed execution. -class IFence : public IDeviceObject +DILIGENT_INTERFACE(IFence, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the fence description used to create the object virtual const FenceDesc& GetDesc() const override = 0; +#endif /// Returns the last completed value signaled by the GPU /// \remarks This method is not thread safe (even if the fence object is protected by mutex) /// and must only be called by the same thread that signals the fence via /// IDeviceContext::SignalFence(). - virtual Uint64 GetCompletedValue() = 0; + VIRTUAL Uint64 METHOD(GetCompletedValue)(THIS) PURE; /// Resets the fence to the specified value. - virtual void Reset(Uint64 Value) = 0; + VIRTUAL void METHOD(Reset)(THIS_ + Uint64 Value) PURE; }; -#else -struct IFence; +#if DILIGENT_C_INTERFACE -// clang-format off - -struct IFenceMethods -{ - Uint64 (*GetCompletedValue)(struct IFence*); - void (*Reset) (struct IFence*, Uint64 Value); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -91,17 +91,17 @@ struct IFenceVtbl struct IFenceMethods Fence; }; -struct IFence +typedef struct IFence { struct IFenceVtbl* pVtbl; -}; +} IFence; // clang-format off # define IFence_GetDesc(This) (const struct FenceDesc*)IDeviceObject_GetDesc(This) -# define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((struct IFence*)(This)) -# define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((struct IFence*)(This), __VA_ARGS__) +# define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((IFence*)(This)) +# define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((IFence*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index d4e3e858..913d5e61 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -40,8 +40,8 @@ /// Graphics engine namespace DILIGENT_BEGIN_NAMESPACE(Diligent) -class ITexture; -class IBuffer; +struct ITexture; +struct IBuffer; /// Value type @@ -1090,6 +1090,7 @@ struct DeviceObjectAttribs {} #endif }; +typedef struct DeviceObjectAttribs DeviceObjectAttribs; /// Hardware adapter type DILIGENT_TYPED_ENUM(ADAPTER_TYPE, Uint8) @@ -1131,6 +1132,7 @@ struct AdapterAttribs /// Number of outputs this device has Uint32 NumOutputs DEFAULT_INITIALIZER(0); }; +typedef struct AdapterAttribs AdapterAttribs; /// Flags indicating how an image is stretched to fit a given monitor's resolution. @@ -1197,6 +1199,7 @@ struct DisplayModeAttribs /// The scaling mode. enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED); }; +typedef struct DisplayModeAttribs DisplayModeAttribs; /// Defines allowed swap chain usage flags DILIGENT_TYPED_ENUM(SWAP_CHAIN_USAGE_FLAGS, Uint32) @@ -1270,6 +1273,7 @@ struct SwapChainDesc {} #endif }; +typedef struct SwapChainDesc SwapChainDesc; /// Full screen mode description /// \sa DXGI_SWAP_CHAIN_FULLSCREEN_DESC structure on MSDN, @@ -1290,6 +1294,7 @@ struct FullScreenModeDesc /// The scaling mode. enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED); }; +typedef struct FullScreenModeDesc FullScreenModeDesc; /// Engine creation attibutes struct EngineCreateInfo @@ -1299,7 +1304,7 @@ struct EngineCreateInfo /// Pointer to the raw memory allocator that will be used for all memory allocation/deallocation /// operations in the engine - class IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr); + struct IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr); /// Pointer to the user-specified debug message callback function DebugMessageCallbackType DebugMessageCallback DEFAULT_INITIALIZER(nullptr); @@ -1311,6 +1316,7 @@ struct EngineCreateInfo /// starting at position 1. Uint32 NumDeferredContexts DEFAULT_INITIALIZER(0); }; +typedef struct EngineCreateInfo EngineCreateInfo; /// Attributes of the OpenGL-based engine implementation @@ -1328,6 +1334,7 @@ struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo) void* pDisplay DEFAULT_INITIALIZER(nullptr); #endif }; +typedef struct EngineGLCreateInfo EngineGLCreateInfo; /// Debug flags that can be specified when creating Direct3D11-based engine implementation. @@ -1390,6 +1397,8 @@ struct EngineD3D11CreateInfo DILIGENT_DERIVE(EngineCreateInfo) /// \sa CreateDeviceAndContextsD3D11Type, CreateSwapChainD3D11Type, LoadGraphicsEngineD3D11 D3D11_DEBUG_FLAGS DebugFlags DEFAULT_INITIALIZER(D3D11_DEBUG_FLAG_NONE); }; +typedef struct EngineD3D11CreateInfo EngineD3D11CreateInfo; + /// Attributes specific to D3D12 engine struct EngineD3D12CreateInfo DILIGENT_DERIVE(EngineCreateInfo) @@ -1493,6 +1502,8 @@ struct EngineD3D12CreateInfo DILIGENT_DERIVE(EngineCreateInfo) #endif ; }; +typedef struct EngineD3D12CreateInfo EngineD3D12CreateInfo; + /// Descriptor pool size struct VulkanDescriptorPoolSize @@ -1534,6 +1545,8 @@ struct VulkanDescriptorPoolSize } #endif }; +typedef struct VulkanDescriptorPoolSize VulkanDescriptorPoolSize; + /// Attributes specific to Vulkan engine struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) @@ -1558,7 +1571,7 @@ struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) /// Size of the main descriptor pool that is used to allocate descriptor sets /// for static and mutable variables. If allocation from the current pool fails, /// the engine creates another one. - struct VulkanDescriptorPoolSize MainDescriptorPoolSize + VulkanDescriptorPoolSize MainDescriptorPoolSize #if DILIGENT_CPP_INTERFACE //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB {8192, 1024, 8192, 8192, 1024, 4096, 4096, 1024, 1024} @@ -1570,7 +1583,7 @@ struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) /// The allocator requests pools from global dynamic descriptor pool manager, and then /// performs lock-free suballocations from the pool. - struct VulkanDescriptorPoolSize DynamicDescriptorPoolSize + VulkanDescriptorPoolSize DynamicDescriptorPoolSize #if DILIGENT_CPP_INTERFACE //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB {2048, 256, 2048, 2048, 256, 1024, 1024, 256, 256} @@ -1620,12 +1633,14 @@ struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) #endif ; }; +typedef struct EngineVkCreateInfo EngineVkCreateInfo; /// Attributes of the Metal-based engine implementation struct EngineMtlCreateInfo DILIGENT_DERIVE(EngineCreateInfo) }; +typedef struct EngineMtlCreateInfo EngineMtlCreateInfo; /// Box @@ -1662,6 +1677,7 @@ struct Box Box() noexcept {} #endif }; +typedef struct Box Box; /// Describes texture format component type @@ -1763,6 +1779,8 @@ struct TextureFormatAttribs TextureFormatAttribs()noexcept {} #endif }; +typedef struct TextureFormatAttribs TextureFormatAttribs; + /// Basic texture format description @@ -1772,6 +1790,8 @@ struct TextureFormatInfo DILIGENT_DERIVE(TextureFormatAttribs) /// Indicates if the format is supported by the device bool Supported DEFAULT_INITIALIZER(false); }; +typedef struct TextureFormatInfo TextureFormatInfo; + /// Extended texture format description @@ -1803,6 +1823,8 @@ struct TextureFormatInfoExt DILIGENT_DERIVE(TextureFormatInfo) /// If the format supports n samples, then (SampleCounts & n) != 0 Uint32 SampleCounts DEFAULT_INITIALIZER(0); }; +typedef struct TextureFormatInfoExt TextureFormatInfoExt; + /// Resource usage state DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32) @@ -1895,11 +1917,11 @@ struct StateTransitionDesc { /// Texture to transition. /// \note Exactly one of pTexture or pBuffer must be non-null. - class ITexture* pTexture DEFAULT_INITIALIZER(nullptr); + struct ITexture* pTexture DEFAULT_INITIALIZER(nullptr); /// Buffer to transition. /// \note Exactly one of pTexture or pBuffer must be non-null. - class IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr); + struct IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr); /// When transitioning a texture, first mip level of the subresource range to transition. Uint32 FirstMipLevel DEFAULT_INITIALIZER(0); @@ -1986,5 +2008,6 @@ struct StateTransitionDesc {} #endif }; +typedef struct StateTransitionDesc StateTransitionDesc; DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/InputLayout.h b/Graphics/GraphicsEngine/interface/InputLayout.h index fde6abec..19904974 100644 --- a/Graphics/GraphicsEngine/interface/InputLayout.h +++ b/Graphics/GraphicsEngine/interface/InputLayout.h @@ -174,16 +174,18 @@ struct LayoutElement {} #endif }; +typedef struct LayoutElement LayoutElement; + /// Layout description /// This structure is used by IRenderDevice::CreatePipelineState(). -struct InputLayoutDesc +struct InputLayoutDesc { /// Array of layout elements - const struct LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr); + const LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr); /// Number of layout elements - Uint32 NumElements DEFAULT_INITIALIZER(0); + Uint32 NumElements DEFAULT_INITIALIZER(0); #if DILIGENT_CPP_INTERFACE InputLayoutDesc()noexcept{} @@ -195,5 +197,6 @@ struct InputLayoutDesc {} #endif }; +typedef struct InputLayoutDesc InputLayoutDesc; DILIGENT_END_NAMESPACE diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 9740e6d8..95f42972 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -67,6 +67,7 @@ struct SampleDesc {} #endif }; +typedef struct SampleDesc SampleDesc; /// Describes shader variable @@ -91,6 +92,7 @@ struct ShaderResourceVariableDesc {} #endif }; +typedef struct ShaderResourceVariableDesc ShaderResourceVariableDesc; /// Static sampler description @@ -118,7 +120,7 @@ struct StaticSamplerDesc {} #endif }; - +typedef struct StaticSamplerDesc StaticSamplerDesc; /// Pipeline layout description struct PipelineResourceLayoutDesc @@ -126,20 +128,21 @@ struct PipelineResourceLayoutDesc /// Default shader resource variable type. This type will be used if shader /// variable description is not found in the Variables array /// or if Variables == nullptr - SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); + SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); /// Number of elements in Variables array - Uint32 NumVariables DEFAULT_INITIALIZER(0); + Uint32 NumVariables DEFAULT_INITIALIZER(0); /// Array of shader resource variable descriptions - const struct ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr); + const ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr); /// Number of static samplers in StaticSamplers array - Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0); + Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0); /// Array of static sampler descriptions - const struct StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr); + const StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr); }; +typedef struct PipelineResourceLayoutDesc PipelineResourceLayoutDesc; /// Graphics pipeline state description @@ -148,24 +151,24 @@ struct PipelineResourceLayoutDesc struct GraphicsPipelineDesc { /// Vertex shader to be used with the pipeline - class IShader* pVS DEFAULT_INITIALIZER(nullptr); + IShader* pVS DEFAULT_INITIALIZER(nullptr); /// Pixel shader to be used with the pipeline - class IShader* pPS DEFAULT_INITIALIZER(nullptr); + IShader* pPS DEFAULT_INITIALIZER(nullptr); /// Domain shader to be used with the pipeline - class IShader* pDS DEFAULT_INITIALIZER(nullptr); + IShader* pDS DEFAULT_INITIALIZER(nullptr); /// Hull shader to be used with the pipeline - class IShader* pHS DEFAULT_INITIALIZER(nullptr); + IShader* pHS DEFAULT_INITIALIZER(nullptr); /// Geometry shader to be used with the pipeline - class IShader* pGS DEFAULT_INITIALIZER(nullptr); + IShader* pGS DEFAULT_INITIALIZER(nullptr); //D3D12_STREAM_OUTPUT_DESC StreamOutput; /// Blend state description - struct BlendStateDesc BlendDesc; + BlendStateDesc BlendDesc; /// 32-bit sample mask that determines which samples get updated /// in all the active render targets. A sample mask is always applied; @@ -174,13 +177,13 @@ struct GraphicsPipelineDesc Uint32 SampleMask DEFAULT_INITIALIZER(0xFFFFFFFF); /// Rasterizer state description - struct RasterizerStateDesc RasterizerDesc; + RasterizerStateDesc RasterizerDesc; /// Depth-stencil state description - struct DepthStencilStateDesc DepthStencilDesc; + DepthStencilStateDesc DepthStencilDesc; /// Input layout - struct InputLayoutDesc InputLayout; + InputLayoutDesc InputLayout; //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; /// Primitive topology type @@ -199,7 +202,7 @@ struct GraphicsPipelineDesc TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); /// Multisampling parameters - struct SampleDesc SmplDesc; + SampleDesc SmplDesc; /// Node mask. Uint32 NodeMask DEFAULT_INITIALIZER(0); @@ -207,6 +210,7 @@ struct GraphicsPipelineDesc //D3D12_CACHED_PIPELINE_STATE CachedPSO; //D3D12_PIPELINE_STATE_FLAGS Flags; }; +typedef struct GraphicsPipelineDesc GraphicsPipelineDesc; /// Compute pipeline state description @@ -215,8 +219,10 @@ struct GraphicsPipelineDesc struct ComputePipelineDesc { /// Compute shader to be used with the pipeline - class IShader* pCS DEFAULT_INITIALIZER(nullptr); + IShader* pCS DEFAULT_INITIALIZER(nullptr); }; +typedef struct ComputePipelineDesc ComputePipelineDesc; + /// Pipeline state description struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) @@ -234,27 +240,35 @@ struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) Uint64 CommandQueueMask DEFAULT_INITIALIZER(1); /// Pipeline layout description - struct PipelineResourceLayoutDesc ResourceLayout; + PipelineResourceLayoutDesc ResourceLayout; /// Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True - struct GraphicsPipelineDesc GraphicsPipeline; + GraphicsPipelineDesc GraphicsPipeline; /// Compute pipeline state description. This memeber is ignored if IsComputePipeline == False - struct ComputePipelineDesc ComputePipeline; + ComputePipelineDesc ComputePipeline; }; +typedef struct PipelineStateDesc PipelineStateDesc; // {06084AE5-6A71-4FE8-84B9-395DD489A28C} static const struct INTERFACE_ID IID_PipelineState = {0x6084ae5, 0x6a71, 0x4fe8, {0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c}}; -#if DILIGENT_CPP_INTERFACE + +#if DILIGENT_C_INTERFACE +# define THIS struct IPipelineState* +# define THIS_ struct IPipelineState*, +#endif + +// clang-format off /// Pipeline state interface -class IPipelineState : public IDeviceObject +DILIGENT_INTERFACE(IPipelineState, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the blend state description used to create the object virtual const PipelineStateDesc& GetDesc()const override = 0; +#endif /// Binds resources for all shaders in the pipeline state @@ -263,7 +277,10 @@ public: /// Any combination of Diligent::SHADER_TYPE may be used. /// \param [in] pResourceMapping - Pointer to the resource mapping interface. /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS. - virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) = 0; + VIRTUAL void METHOD(BindStaticResources)(THIS_ + Uint32 ShaderFlags, + IResourceMapping* pResourceMapping, + Uint32 Flags) PURE; /// Returns the number of static shader resource variables. @@ -271,7 +288,8 @@ public: /// \param [in] ShaderType - Type of the shader. /// \remark Only static variables (that can be accessed directly through the PSO) are counted. /// Mutable and dynamic variables are accessed through Shader Resource Binding object. - virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const = 0; + VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_ + SHADER_TYPE ShaderType) CONST PURE; /// Returns static shader resource variable. If the variable is not found, @@ -282,7 +300,9 @@ public: /// \param [in] Name - Name of the variable. /// \remark The method does not increment the reference counter /// of the returned interface. - virtual IShaderResourceVariable* GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) = 0; + VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByName)(THIS_ + SHADER_TYPE ShaderType, + const Char* Name) PURE; /// Returns static shader resource variable by its index. @@ -295,7 +315,9 @@ public: /// \remark Only static shader resource variables can be accessed through this method. /// Mutable and dynamic variables are accessed through Shader Resource /// Binding object - virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0; + VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByIndex)(THIS_ + SHADER_TYPE ShaderType, + Uint32 Index) PURE; /// Creates a shader resource binding object @@ -305,7 +327,9 @@ public: /// \param [in] InitStaticResources - if set to true, the method will initialize static resources in /// the created object, which has the exact same effect as calling /// IShaderResourceBinding::InitializeStaticResources(). - virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources = false) = 0; + VIRTUAL void METHOD(CreateShaderResourceBinding)(THIS_ + IShaderResourceBinding** ppShaderResourceBinding, + bool InitStaticResources DEFAULT_VALUE(false)) PURE; /// Checks if this pipeline state object is compatible with another PSO @@ -322,22 +346,14 @@ public: /// to commit resources for the second pipeline, a runtime error will occur.\n /// The function only checks compatibility of shader resource layouts. It does not take /// into account vertex shader input layout, number of outputs, etc. - virtual bool IsCompatibleWith(const IPipelineState* pPSO)const = 0; + VIRTUAL bool METHOD(IsCompatibleWith)(THIS_ + const struct IPipelineState* pPSO) CONST PURE; }; -#else - -struct IPipelineState; +#if DILIGENT_C_INTERFACE -struct IPipelineStateMethods -{ - void (*BindStaticResources) (struct IPipelineState*, Uint32 ShaderFlags, class IResourceMapping* pResourceMapping, Uint32 Flags); - Uint32 (*GetStaticVariableCount) (struct IPipelineState*, SHADER_TYPE ShaderType); - class IShaderResourceVariable* (*GetStaticVariableByName) (struct IPipelineState*, SHADER_TYPE ShaderType, const Char* Name); - class IShaderResourceVariable* (*GetStaticVariableByIndex) (struct IPipelineState*, SHADER_TYPE ShaderType, Uint32 Index); - void (*CreateShaderResourceBinding)(struct IPipelineState*, class IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources); - bool (*IsCompatibleWith) (struct IPipelineState*, const class IPipelineState* pPSO); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -348,21 +364,21 @@ struct IPipelineStateVtbl struct IPipelineStateMethods PipelineState; }; -struct IPipelineState +typedef struct IPipelineState { struct IPipelineStateVtbl* pVtbl; -}; +} IPipelineState; // clang-format off # define IPipelineState_GetDesc(This) (const struct PipelineStateDesc*)IDeviceObject_GetDesc(This) -# define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((struct IPipelineState*)(This), __VA_ARGS__) -# define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((struct IPipelineState*)(This), __VA_ARGS__) -# define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((struct IPipelineState*)(This), __VA_ARGS__) -# define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((struct IPipelineState*)(This), __VA_ARGS__) -# define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((struct IPipelineState*)(This), __VA_ARGS__) -# define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((struct IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((IPipelineState*)(This), __VA_ARGS__) +# define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((IPipelineState*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/Query.h b/Graphics/GraphicsEngine/interface/Query.h index b87b109d..61834232 100644 --- a/Graphics/GraphicsEngine/interface/Query.h +++ b/Graphics/GraphicsEngine/interface/Query.h @@ -36,7 +36,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {70F2A88A-F8BE-4901-8F05-2F72FA695BA0} -static const struct INTERFACE_ID IID_Query = +static const INTERFACE_ID IID_Query = {0x70f2a88a, 0xf8be, 0x4901, {0x8f, 0x5, 0x2f, 0x72, 0xfa, 0x69, 0x5b, 0xa0}}; /// Query type. @@ -77,6 +77,7 @@ struct QueryDataOcclusion /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery. Uint64 NumSamples DEFAULT_INITIALIZER(0); }; +typedef struct QueryDataOcclusion QueryDataOcclusion; /// Binary occlusion query data. /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_BINARY_OCCLUSION query type. @@ -89,6 +90,7 @@ struct QueryDataBinaryOcclusion /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery. bool AnySamplePassed DEFAULT_INITIALIZER(0); }; +typedef struct QueryDataBinaryOcclusion QueryDataBinaryOcclusion; /// Timestamp query data. /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_TIMESTAMP query type. @@ -104,6 +106,7 @@ struct QueryDataTimestamp /// while getting the timestamp, this value will be 0. Uint64 Frequency DEFAULT_INITIALIZER(0); }; +typedef struct QueryDataTimestamp QueryDataTimestamp; /// Pipeline statistics query data. /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_PIPELINE_STATISTICS query type. @@ -149,7 +152,7 @@ struct QueryDataPipelineStatistics /// Number of times a compute shader was invoked. Uint64 CSInvocations DEFAULT_INITIALIZER(0); }; - +typedef struct QueryDataPipelineStatistics QueryDataPipelineStatistics; // clang-format off @@ -167,19 +170,24 @@ struct QueryDesc DILIGENT_DERIVE(DeviceObjectAttribs) {} #endif }; +typedef struct QueryDesc QueryDesc; -// clang-format on +#if DILIGENT_C_INTERFACE +# define THIS struct IQuery* +# define THIS_ struct IQuery*, +#endif -#if DILIGENT_CPP_INTERFACE +// clang-format off /// Query interface. /// Defines the methods to manipulate a Query object -class IQuery : public IDeviceObject +DILIGENT_INTERFACE(IQuery, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the Query description used to create the object. virtual const QueryDesc& GetDesc() const override = 0; +#endif /// Gets the query data. @@ -201,23 +209,19 @@ public: /// /// If AutoInvalidate is set to true, and the data have been retrieved, an application /// must not call GetData() until it begins and ends the query again. - virtual bool GetData(void* pData, Uint32 DataSize, bool AutoInvalidate = true) = 0; + VIRTUAL bool METHOD(GetData)(THIS_ + void* pData, + Uint32 DataSize, + bool AutoInvalidate DEFAULT_VALUE(true)) PURE; /// Invalidates the query and releases associated resources. - virtual void Invalidate() = 0; + VIRTUAL void METHOD(Invalidate)(THIS) PURE; }; -#else +#if DILIGENT_C_INTERFACE -struct IQuery; - -// clang-format off - -struct IQueryMethods -{ - bool (*GetData) (struct IQuery*, void* pData, Uint32 DataSize, bool AutoInvalidate); - void (*Invalidate)(struct IQuery*); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -228,17 +232,17 @@ struct IQueryVtbl struct IQueryMethods Query; }; -struct IQuery +typedef struct IQuery { struct IQueryVtbl* pVtbl; -}; +} IQuery; // clang-format off # define IQuery_GetDesc(This) (const struct QueryDesc*)IDeviceObject_GetDesc(This) -# define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((struct IQuery*)(This), __VA_ARGS__) -# define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((struct IQuery*)(This)) +# define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((IQuery*)(This), __VA_ARGS__) +# define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((IQuery*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/RasterizerState.h b/Graphics/GraphicsEngine/interface/RasterizerState.h index 08a74933..9a2f926c 100644 --- a/Graphics/GraphicsEngine/interface/RasterizerState.h +++ b/Graphics/GraphicsEngine/interface/RasterizerState.h @@ -181,5 +181,6 @@ struct RasterizerStateDesc } #endif }; +typedef struct RasterizerStateDesc RasterizerStateDesc; DILIGENT_END_NAMESPACE diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index 82414dc5..93d70a83 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -54,15 +54,19 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {F0E9B607-AE33-4B2B-B1AF-A8B2C3104022} -static const struct INTERFACE_ID IID_RenderDevice = +static const INTERFACE_ID IID_RenderDevice = {0xf0e9b607, 0xae33, 0x4b2b, {0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22}}; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IRenderDevice* +# define THIS_ struct IRenderDevice*, +#endif + +// clang-format off /// Render device interface -class IRenderDevice : public IObject +DILIGENT_INTERFACE(IRenderDevice, IObject) { -public: /// Creates a new buffer object /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details. @@ -78,9 +82,10 @@ public: /// Size of a uniform buffer (BIND_UNIFORM_BUFFER) must be multiple of 16.\n /// Stride of a formatted buffer will be computed automatically from the format if /// ElementByteStride member of buffer description is set to default value (0). - virtual void CreateBuffer(const BufferDesc& BuffDesc, - const BufferData* pBuffData, - IBuffer** ppBuffer) = 0; + VIRTUAL void METHOD(CreateBuffer)(THIS_ + const BufferDesc REF BuffDesc, + const BufferData* pBuffData, + IBuffer** ppBuffer) PURE; /// Creates a new shader object @@ -89,8 +94,9 @@ public: /// shader interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreateShader(const ShaderCreateInfo& ShaderCI, - IShader** ppShader) = 0; + VIRTUAL void METHOD(CreateShader)(THIS_ + const ShaderCreateInfo REF ShaderCI, + IShader** ppShader) PURE; /// Creates a new texture object @@ -114,9 +120,10 @@ public: /// 15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.\n /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n /// 15x6x4, 7x3x2, 3x1x1, 1x1x1 - virtual void CreateTexture(const TextureDesc& TexDesc, - const TextureData* pData, - ITexture** ppTexture) = 0; + VIRTUAL void METHOD(CreateTexture)(THIS_ + const TextureDesc REF TexDesc, + const TextureData* pData, + ITexture** ppTexture) PURE; /// Creates a new sampler object @@ -128,8 +135,9 @@ public: /// \remark If an application attempts to create a sampler interface with the same attributes /// as an existing interface, the same interface will be returned. /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time. - virtual void CreateSampler(const SamplerDesc& SamDesc, - ISampler** ppSampler) = 0; + VIRTUAL void METHOD(CreateSampler)(THIS_ + const SamplerDesc REF SamDesc, + ISampler** ppSampler) PURE; /// Creates a new resource mapping @@ -138,8 +146,9 @@ public: /// resource mapping interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreateResourceMapping(const ResourceMappingDesc& MappingDesc, - IResourceMapping** ppMapping) = 0; + VIRTUAL void METHOD(CreateResourceMapping)(THIS_ + const ResourceMappingDesc REF MappingDesc, + IResourceMapping** ppMapping) PURE; /// Creates a new pipeline state object @@ -148,8 +157,9 @@ public: /// pipeline state interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, - IPipelineState** ppPipelineState) = 0; + VIRTUAL void METHOD(CreatePipelineState)(THIS_ + const PipelineStateDesc REF PipelineDesc, + IPipelineState** ppPipelineState) PURE; /// Creates a new fence object @@ -159,8 +169,9 @@ public: /// fence interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreateFence(const FenceDesc& Desc, - IFence** ppFence) = 0; + VIRTUAL void METHOD(CreateFence)(THIS_ + const FenceDesc REF Desc, + IFence** ppFence) PURE; /// Creates a new query object @@ -170,12 +181,13 @@ public: /// query interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreateQuery(const QueryDesc& Desc, - IQuery** ppQuery) = 0; + VIRTUAL void METHOD(CreateQuery)(THIS_ + const QueryDesc REF Desc, + IQuery** ppQuery) PURE; /// Gets the device capabilities, see Diligent::DeviceCaps for details - virtual const DeviceCaps& GetDeviceCaps() const = 0; + VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE; /// Returns the basic texture format information. @@ -184,7 +196,8 @@ public: /// \param [in] TexFormat - Texture format for which to provide the information /// \return Const reference to the TextureFormatInfo structure containing the /// texture format description. - virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat) = 0; + VIRTUAL const TextureFormatInfo REF METHOD(GetTextureFormatInfo)(THIS_ + TEXTURE_FORMAT TexFormat) PURE; /// Returns the extended texture format information. @@ -196,14 +209,16 @@ public: /// \remark The first time this method is called for a particular format, it may be /// considerably slower than GetTextureFormatInfo(). If you do not require /// extended information, call GetTextureFormatInfo() instead. - virtual const TextureFormatInfoExt& GetTextureFormatInfoExt(TEXTURE_FORMAT TexFormat) = 0; + VIRTUAL const TextureFormatInfoExt REF METHOD(GetTextureFormatInfoExt)(THIS_ + TEXTURE_FORMAT TexFormat) PURE; /// Purges device release queues and releases all stale resources. /// This method is automatically called by ISwapChain::Present() of the primary swap chain. /// \param [in] ForceRelease - Forces release of all objects. Use this option with /// great care only if you are sure the resources are not /// in use by the GPU (such as when the device has just been idled). - virtual void ReleaseStaleResources(bool ForceRelease = false) = 0; + VIRTUAL void METHOD(ReleaseStaleResources)(THIS_ + bool ForceRelease DEFAULT_VALUE(false)) PURE; /// Waits until all outstanding operations on the GPU are complete. @@ -214,57 +229,22 @@ public: /// have been previously submitted for execution. An application should explicitly flush /// the contexts using IDeviceContext::Flush() if it needs to make sure all recorded commands /// are complete when the method returns. - virtual void IdleGPU() = 0; + VIRTUAL void METHOD(IdleGPU)(THIS) PURE; /// Returns engine factory this device was created from. /// \remark This method does not increment the reference counter of the returned interface, /// so the application should not call Release(). - virtual IEngineFactory* GetEngineFactory() const = 0; + VIRTUAL IEngineFactory* METHOD(GetEngineFactory)(THIS) CONST PURE; }; -#else -struct IRenderDevice; +#if DILIGENT_C_INTERFACE -struct IRenderDeviceMethods -{ - void (*CreateBuffer)(struct IRenderDevice*, - const struct BufferDesc* BuffDesc, - const struct BufferData* pBuffData, - class IBuffer** ppBuffer); - void (*CreateShader)(struct IRenderDevice*, - const struct ShaderCreateInfo* ShaderCI, - class IShader** ppShader); - void (*CreateTexture)(struct IRenderDevice*, - const struct TextureDesc* TexDesc, - const struct TextureData* pData, - class ITexture** ppTexture); - void (*CreateSampler)(struct IRenderDevice*, - const struct SamplerDesc* SamDesc, - class ISampler** ppSampler); - void (*CreateResourceMapping)(struct IRenderDevice*, - const struct ResourceMappingDesc* MappingDesc, - class IResourceMapping** ppMapping); - void (*CreatePipelineState)(struct IRenderDevice*, - const struct PipelineStateDesc* PipelineDesc, - class IPipelineState** ppPipelineState); - void (*CreateFence)(struct IRenderDevice*, - const struct FenceDesc* Desc, - class IFence** ppFence); - void (*CreateQuery)(struct IRenderDevice*, - const struct QueryDesc* Desc, - class IQuery** ppQuery); - const struct DeviceCaps* (*GetDeviceCaps)(struct IRenderDevice*); - const struct TextureFormatInfo* (*GetTextureFormatInfo)(struct IRenderDevice*, - TEXTURE_FORMAT TexFormat); - const struct TextureFormatInfoExt* (*GetTextureFormatInfoExt)(struct IRenderDevice*, - TEXTURE_FORMAT TexFormat); - void (*ReleaseStaleResources)(struct IRenderDevice*, - bool ForceRelease); - void (*IdleGPU)(struct IRenderDevice*); - class IEngineFactory* (*GetEngineFactory)(struct IRenderDevice*); -}; +# undef THIS +# undef THIS + +// clang-format on struct IRenderDeviceVtbl { @@ -272,27 +252,27 @@ struct IRenderDeviceVtbl struct IRenderDeviceMethods RenderDevice; }; -struct IRenderDevice +typedef struct IRenderDevice { struct IRenderDeviceVtbl* pVtbl; -}; +} IRenderDevice; // clang-format off -# define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((struct IRenderDevice*)(This)) -# define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((struct IRenderDevice*)(This), __VA_ARGS__) -# define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((struct IRenderDevice*)(This)) -# define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((struct IRenderDevice*)(This)) +# define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((IRenderDevice*)(This)) +# define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((IRenderDevice*)(This), __VA_ARGS__) +# define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((IRenderDevice*)(This)) +# define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((IRenderDevice*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/ResourceMapping.h b/Graphics/GraphicsEngine/interface/ResourceMapping.h index 4fb2db14..5de0e935 100644 --- a/Graphics/GraphicsEngine/interface/ResourceMapping.h +++ b/Graphics/GraphicsEngine/interface/ResourceMapping.h @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {6C1AC7A6-B429-4139-9433-9E54E93E384A} -static const struct INTERFACE_ID IID_ResourceMapping = +static const INTERFACE_ID IID_ResourceMapping = {0x6c1ac7a6, 0xb429, 0x4139, {0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a}}; /// Describes the resourse mapping object entry @@ -44,12 +44,12 @@ struct ResourceMappingEntry // clang-format off /// Object name - const Char* Name DEFAULT_INITIALIZER(nullptr); + const Char* Name DEFAULT_INITIALIZER(nullptr); /// Pointer to the object's interface - class IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr); + IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr); - Uint32 ArrayIndex DEFAULT_INITIALIZER(0); + Uint32 ArrayIndex DEFAULT_INITIALIZER(0); #if DILIGENT_CPP_INTERFACE @@ -68,6 +68,8 @@ struct ResourceMappingEntry // clang-format on #endif }; +typedef struct ResourceMappingEntry ResourceMappingEntry; + /// Resource mapping description struct ResourceMappingDesc @@ -75,7 +77,7 @@ struct ResourceMappingDesc /// Pointer to the array of resource mapping entries. /// The last element in the array must be default value /// created by ResourceMappingEntry::ResourceMappingEntry() - struct ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr); + ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE ResourceMappingDesc() noexcept @@ -86,18 +88,23 @@ struct ResourceMappingDesc {} #endif }; +typedef struct ResourceMappingDesc ResourceMappingDesc; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IResourceMapping* +# define THIS_ struct IResourceMapping*, +#endif + +// clang-format off /// Resouce mapping /// This interface provides mapping between literal names and resource pointers. /// It is created by IRenderDevice::CreateResourceMapping(). /// \remarks Resource mapping holds strong references to all objects it keeps. -class IResourceMapping : public IObject +DILIGENT_INTERFACE(IResourceMapping, IObject) { -public: /// Adds a resource to the mapping. /// \param [in] Name - Resource name. @@ -108,7 +115,10 @@ public: /// /// \remarks Resource mapping increases the reference counter for referenced objects. So an /// object will not be released as long as it is in the resource mapping. - virtual void AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique) = 0; + VIRTUAL void METHOD(AddResource)(THIS_ + const Char* Name, + IDeviceObject* pObject, + bool bIsUnique) PURE; /// Adds resource array to the mapping. @@ -123,14 +133,21 @@ public: /// /// \remarks Resource mapping increases the reference counter for referenced objects. So an /// object will not be released as long as it is in the resource mapping. - virtual void AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) = 0; + VIRTUAL void METHOD(AddResourceArray)(THIS_ + const Char* Name, + Uint32 StartIndex, + IDeviceObject* const* ppObjects, + Uint32 NumElements, + bool bIsUnique) PURE; /// Removes a resource from the mapping using its literal name. /// \param [in] Name - Name of the resource to remove. /// \param [in] ArrayIndex - For array resources, index in the array - virtual void RemoveResourceByName(const Char* Name, Uint32 ArrayIndex = 0) = 0; + VIRTUAL void METHOD(RemoveResourceByName)(THIS_ + const Char* Name, + Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE; /// Finds a resource in the mapping. @@ -141,26 +158,19 @@ public: /// If no object is found, nullptr will be written. /// \remarks The method increases the reference counter /// of the returned object, so Release() must be called. - virtual void GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex = 0) = 0; + VIRTUAL void METHOD(GetResource)(THIS_ + const Char* Name, + IDeviceObject** ppResource, + Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE; /// Returns the size of the resource mapping, i.e. the number of objects. - virtual size_t GetSize() = 0; + VIRTUAL size_t METHOD(GetSize)(THIS) PURE; }; -#else +#if DILIGENT_C_INTERFACE -struct IResourceMapping; - -// clang-format off - -struct IResourceMappingMethods -{ - void (*AddResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject* pObject, bool bIsUnique); - void (*AddResourceArray) (struct IResourceMapping*, const Char* Name, Uint32 StartIndex, class IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique); - void (*RemoveResourceByName)(struct IResourceMapping*, const Char* Name, Uint32 ArrayIndex); - void (*GetResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject** ppResource, Uint32 ArrayIndex); - size_t (*GetSize) (struct IResourceMapping*); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -170,18 +180,18 @@ struct IResourceMappingVtbl struct IResourceMappingMethods ResourceMapping; }; -struct IResourceMapping +typedef struct IResourceMapping { struct IResourceMappingVtbl* pVtbl; -}; +} IResourceMapping; // clang-format off -# define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((struct IResourceMapping*)(This), __VA_ARGS__) -# define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((struct IResourceMapping*)(This), __VA_ARGS__) -# define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((struct IResourceMapping*)(This), __VA_ARGS__) -# define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((struct IResourceMapping*)(This), __VA_ARGS__) -# define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((struct IResourceMapping*)(This)) +# define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((IResourceMapping*)(This), __VA_ARGS__) +# define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((IResourceMapping*)(This), __VA_ARGS__) +# define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((IResourceMapping*)(This), __VA_ARGS__) +# define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((IResourceMapping*)(This), __VA_ARGS__) +# define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((IResourceMapping*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/Sampler.h b/Graphics/GraphicsEngine/interface/Sampler.h index 9493106e..97d4b99c 100644 --- a/Graphics/GraphicsEngine/interface/Sampler.h +++ b/Graphics/GraphicsEngine/interface/Sampler.h @@ -36,7 +36,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {595A59BF-FA81-4855-BC5E-C0E048745A95} -static const struct INTERFACE_ID IID_Sampler = +static const INTERFACE_ID IID_Sampler = {0x595a59bf, 0xfa81, 0x4855, {0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95}}; @@ -169,25 +169,31 @@ struct SamplerDesc DILIGENT_DERIVE(DeviceObjectAttribs) } #endif }; +typedef struct SamplerDesc SamplerDesc; #if DILIGENT_CPP_INTERFACE -// clang-format on +// clang-format off /// Texture sampler interface. /// The interface holds the sampler state that can be used to perform texture filtering. /// To create a sampler, call IRenderDevice::CreateSampler(). To use a sampler, /// call ITextureView::SetSampler(). -class ISampler : public IDeviceObject +DILIGENT_INTERFACE(ISampler, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the sampler description used to create the object virtual const SamplerDesc& GetDesc() const override = 0; +#endif }; -#else +#endif + +#if DILIGENT_C_INTERFACE + +// clang-format on struct ISampler; @@ -202,10 +208,10 @@ struct ISamplerVtbl //struct ISamplerMethods Sampler; }; -struct ISampler +typedef struct ISampler { struct ISamplerVtbl* pVtbl; -}; +} ISampler; # define ISampler_GetDesc(This) (const struct SamplerDesc*)IDeviceObject_GetDesc(This) diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index e472852f..971302af 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -36,9 +36,8 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) - // {2989B45C-143D-4886-B89C-C3271C2DCC5D} -static const struct INTERFACE_ID IID_Shader = +static const INTERFACE_ID IID_Shader = {0x2989b45c, 0x143d, 0x4886, {0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d}}; // clang-format off @@ -75,27 +74,54 @@ struct ShaderDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// Shader type. See Diligent::SHADER_TYPE. SHADER_TYPE ShaderType DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); }; +typedef struct ShaderDesc ShaderDesc; // clang-format on // {3EA98781-082F-4413-8C30-B9BA6D82DBB7} -static const struct INTERFACE_ID IID_IShaderSourceInputStreamFactory = +static const INTERFACE_ID IID_IShaderSourceInputStreamFactory = {0x3ea98781, 0x82f, 0x4413, {0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7}}; -#if DILIGENT_CPP_INTERFACE +// clang-format off + +#if DILIGENT_C_INTERFACE +# define THIS struct IShaderSourceInputStreamFactory* +# define THIS_ struct IShaderSourceInputStreamFactory*, +#endif /// Shader source stream factory interface -class IShaderSourceInputStreamFactory : public IObject +DILIGENT_INTERFACE(IShaderSourceInputStreamFactory, IObject) +{ + VIRTUAL void METHOD(CreateInputStream)(THIS_ + const Char* Name, + IFileStream** ppStream) PURE; +}; + + +#if DILIGENT_C_INTERFACE + +# undef THIS +# undef THIS_ + +// clang-format on + +struct IShaderSourceInputStreamFactoryVtbl { -public: - virtual void CreateInputStream(const Diligent::Char* Name, IFileStream** ppStream) = 0; + struct IObjectMethods Object; + struct IShaderSourceInputStreamFactoryMethods ShaderSourceInputStreamFactory; }; -#else +typedef struct IShaderSourceInputStreamFactory +{ + struct IShaderSourceInputStreamFactoryVtbl* pVtbl; +} IShaderSourceInputStreamFactory; + +# define IShaderSourceInputStreamFactory_CreateInputStream(This, ...) (This)->pVtbl->ShaderSourceInputStreamFactory.CreateInputStream((IShaderSourceInputStreamFactory*)(This), __VA_ARGS__) #endif + struct ShaderMacro { const Char* Name DEFAULT_INITIALIZER(nullptr); @@ -111,6 +137,7 @@ struct ShaderMacro {} #endif }; +typedef struct ShaderMacro ShaderMacro; /// Shader version struct ShaderVersion @@ -130,6 +157,7 @@ struct ShaderVersion {} #endif }; +typedef struct ShaderVersion ShaderVersion; /// Shader creation attributes struct ShaderCreateInfo @@ -143,7 +171,7 @@ struct ShaderCreateInfo /// The factory is used to load the shader source file if FilePath is not null. /// It is also used to create additional input streams for shader include files - class IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr); + IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr); /// HLSL->GLSL conversion stream @@ -156,7 +184,7 @@ struct ShaderCreateInfo /// the first time and will use it in all subsequent times. /// For all subsequent conversions, FilePath member must be the same, or /// new stream will be crated and warning message will be displayed. - class IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr); + struct IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr); /// Shader source @@ -187,7 +215,7 @@ struct ShaderCreateInfo /// Shader macros /// This member is ignored if ByteCode is not null - const struct ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr); + const ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr); /// If set to true, textures will be combined with texture samplers. /// The CombinedSamplerSuffix member defines the suffix added to the texture variable @@ -205,7 +233,7 @@ struct ShaderCreateInfo const Char* CombinedSamplerSuffix DEFAULT_INITIALIZER("_sampler"); /// Shader description. See Diligent::ShaderDesc. - struct ShaderDesc Desc; + ShaderDesc Desc; /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE. SHADER_SOURCE_LANGUAGE SourceLanguage DEFAULT_INITIALIZER(SHADER_SOURCE_LANGUAGE_DEFAULT); @@ -216,17 +244,17 @@ struct ShaderCreateInfo /// has no effect. /// /// \note When HLSL source is converted to GLSL, corresponding GLSL/GLESSL version will be used. - struct ShaderVersion HLSLVersion DEFAULT_INITIALIZER({}); + ShaderVersion HLSLVersion DEFAULT_INITIALIZER({}); /// GLSL version to use when creating the shader. When default value /// is given (0, 0), the engine will attempt to use the highest GLSL version /// supported by the device. - struct ShaderVersion GLSLVersion DEFAULT_INITIALIZER({}); + ShaderVersion GLSLVersion DEFAULT_INITIALIZER({}); /// GLES shading language version to use when creating the shader. When default value /// is given (0, 0), the engine will attempt to use the highest GLESSL version /// supported by the device. - struct ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({}); + ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({}); /// Memory address where pointer to the compiler messages data blob will be written @@ -234,8 +262,9 @@ struct ShaderCreateInfo /// The buffer contains two null-terminated strings. The first one is the compiler /// output message. The second one is the full shader source code including definitions added /// by the engine. Data blob object must be released by the client. - class IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr); + IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr); }; +typedef struct ShaderCreateInfo ShaderCreateInfo; /// Describes shader resource type DILIGENT_TYPED_ENUM(SHADER_RESOURCE_TYPE, Uint8){ @@ -287,35 +316,37 @@ struct ShaderResourceDesc Uint32 ArraySize DEFAULT_INITIALIZER(0); // clang-format on }; +typedef struct ShaderResourceDesc ShaderResourceDesc; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IShader* +# define THIS_ struct IShader*, +#endif + +// clang-format off /// Shader interface -class IShader : public IDeviceObject +DILIGENT_INTERFACE(IShader, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the shader description virtual const ShaderDesc& GetDesc() const override = 0; +#endif /// Returns the total number of shader resources - virtual Uint32 GetResourceCount() const = 0; + VIRTUAL Uint32 METHOD(GetResourceCount)(THIS) CONST PURE; /// Returns the pointer to the array of shader resources - virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const = 0; + VIRTUAL void METHOD(GetResourceDesc)(THIS_ + Uint32 Index, + ShaderResourceDesc REF ResourceDesc) CONST PURE; }; -#else - -struct IShader; +#if DILIGENT_C_INTERFACE -// clang-format off - -struct IShaderMethods -{ - Uint32 (*GetResourceCount)(struct IShader*); - void (*GetResourceDesc) (struct IShader*, Uint32 Index, struct ShaderResourceDesc* ResourceDesc); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -326,17 +357,17 @@ struct IShaderVtbl struct IShaderMethods Shader; }; -struct IShader +typedef struct IShader { struct IShaderVtbl* pVtbl; -}; +} IShader; // clang-format off # define IShader_GetDesc(This) (const struct ShaderDesc*)IDeviceObject_GetDesc(This) -# define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((struct IShader*)(This)) -# define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((struct IShader*)(This), __VA_ARGS__) +# define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((IShader*)(This)) +# define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((IShader*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h index 931855d1..d18c8060 100644 --- a/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h +++ b/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h @@ -37,24 +37,28 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) -class IPipelineState; +struct IPipelineState; // {061F8774-9A09-48E8-8411-B5BD20560104} -static const struct INTERFACE_ID IID_ShaderResourceBinding = +static const INTERFACE_ID IID_ShaderResourceBinding = {0x61f8774, 0x9a09, 0x48e8, {0x84, 0x11, 0xb5, 0xbd, 0x20, 0x56, 0x1, 0x4}}; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IShaderResourceBinding* +# define THIS_ struct IShaderResourceBinding*, +#endif + +// clang-format off /// Shader resource binding interface -class IShaderResourceBinding : public IObject +DILIGENT_INTERFACE(IShaderResourceBinding, IObject) { -public: /// Returns pointer to the referenced buffer object. /// The method calls AddRef() on the returned interface, /// so Release() must be called to avoid memory leaks. - virtual IPipelineState* GetPipelineState() = 0; + VIRTUAL struct IPipelineState* METHOD(GetPipelineState)(THIS) PURE; /// Binds mutable and dynamice resources using the resource mapping @@ -62,7 +66,10 @@ public: /// Any combination of Diligent::SHADER_TYPE may be used. /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS. - virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) = 0; + VIRTUAL void METHOD(BindResources)(THIS_ + Uint32 ShaderFlags, + IResourceMapping* pResMapping, + Uint32 Flags) PURE; /// Returns variable @@ -72,7 +79,9 @@ public: /// /// \note This operation may potentially be expensive. If the variable will be used often, it is /// recommended to store and reuse the pointer as it never changes. - virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) = 0; + VIRTUAL IShaderResourceVariable* METHOD(GetVariableByName)(THIS_ + SHADER_TYPE ShaderType, + const char* Name) PURE; /// Returns the total variable count for the specific shader stage. @@ -80,7 +89,8 @@ public: /// \remark The method only counts mutable and dynamic variables that can be accessed through /// the Shader Resource Binding object. Static variables are accessed through the Shader /// object. - virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const = 0; + VIRTUAL Uint32 METHOD(GetVariableCount)(THIS_ + SHADER_TYPE ShaderType) CONST PURE; /// Returns variable @@ -94,7 +104,9 @@ public: /// /// \note This operation may potentially be expensive. If the variable will be used often, it is /// recommended to store and reuse the pointer as it never changes. - virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0; + VIRTUAL IShaderResourceVariable* METHOD(GetVariableByIndex)(THIS_ + SHADER_TYPE ShaderType, + Uint32 Index) PURE; /// Initializes static resources @@ -112,25 +124,14 @@ public: /// \note The method must be called exactly once. If static resources have /// already been initialized and the method is called again, it will have /// no effect and a warning messge will be displayed. - virtual void InitializeStaticResources(const IPipelineState* pPipelineState = nullptr) = 0; + VIRTUAL void METHOD(InitializeStaticResources)(THIS_ + const struct IPipelineState* pPipelineState DEFAULT_VALUE(nullptr)) PURE; }; -#else +#if DILIGENT_C_INTERFACE -class IPipelineState; -struct IShaderResourceBinding; - -// clang-format off - -struct IShaderResourceBindingMethods -{ - class IPipelineState* (*GetPipelineState) (struct IShaderResourceBinding*); - void (*BindResources) (struct IShaderResourceBinding*, Uint32 ShaderFlags, class IResourceMapping* pResMapping, Uint32 Flags); - class IShaderResourceVariable* (*GetVariableByName) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, const char* Name); - Uint32 (*GetVariableCount) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType); - class IShaderResourceVariable* (*GetVariableByIndex) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, Uint32 Index); - void (*InitializeStaticResources)(struct IShaderResourceBinding*, const class IPipelineState* pPipelineState); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -140,19 +141,19 @@ struct IShaderResourceBindingVtbl struct IShaderResourceBindingMethods ShaderResourceBinding; }; -struct IShaderResourceBinding +typedef struct IShaderResourceBinding { struct IShaderResourceBindingVtbl* pVtbl; -}; +} IShaderResourceBinding; // clang-format off -# define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((struct IShaderResourceBinding*)(This)) -# define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((struct IShaderResourceBinding*)(This), __VA_ARGS__) -# define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((struct IShaderResourceBinding*)(This), __VA_ARGS__) -# define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((struct IShaderResourceBinding*)(This), __VA_ARGS__) -# define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((struct IShaderResourceBinding*)(This), __VA_ARGS__) -# define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((struct IShaderResourceBinding*)(This), __VA_ARGS__) +# define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((IShaderResourceBinding*)(This)) +# define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((IShaderResourceBinding*)(This), __VA_ARGS__) +# define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((IShaderResourceBinding*)(This), __VA_ARGS__) +# define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((IShaderResourceBinding*)(This), __VA_ARGS__) +# define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((IShaderResourceBinding*)(This), __VA_ARGS__) +# define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((IShaderResourceBinding*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h index 44c0d058..6001f99b 100644 --- a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h +++ b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h @@ -39,7 +39,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {0D57DF3F-977D-4C8F-B64C-6675814BC80C} -static const struct INTERFACE_ID IID_ShaderResourceVariable = +static const INTERFACE_ID IID_ShaderResourceVariable = {0xd57df3f, 0x977d, 0x4c8f, {0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc}}; // clang-format off @@ -104,18 +104,23 @@ DILIGENT_TYPED_ENUM(BIND_SHADER_RESOURCES_FLAGS, Uint32) // clang-format on -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct IShaderResourceVariable* +# define THIS_ struct IShaderResourceVariable*, +#endif + +// clang-format off /// Shader resource variable -class IShaderResourceVariable : public IObject +DILIGENT_INTERFACE(IShaderResourceVariable, IObject) { -public: /// Binds resource to the variable /// \remark The method performs run-time correctness checks. /// For instance, shader resource view cannot /// be assigned to a constant buffer variable. - virtual void Set(IDeviceObject* pObject) = 0; + VIRTUAL void METHOD(Set)(THIS_ + IDeviceObject* pObject) PURE; /// Binds resource array to the variable @@ -126,38 +131,35 @@ public: /// \remark The method performs run-time correctness checks. /// For instance, shader resource view cannot /// be assigned to a constant buffer variable. - virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) = 0; + VIRTUAL void METHOD(SetArray)(THIS_ + IDeviceObject* const* ppObjects, + Uint32 FirstElement, + Uint32 NumElements) PURE; /// Returns the shader resource variable type - virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const = 0; + VIRTUAL SHADER_RESOURCE_VARIABLE_TYPE METHOD(GetType)(THIS) CONST PURE; /// Returns shader resource description. See Diligent::ShaderResourceDesc. - virtual void GetResourceDesc(ShaderResourceDesc& ResourceDesc) const = 0; + VIRTUAL void METHOD(GetResourceDesc)(THIS_ + ShaderResourceDesc REF ResourceDesc) CONST PURE; /// Returns the variable index that can be used to access the variable. - virtual Uint32 GetIndex() const = 0; + VIRTUAL Uint32 METHOD(GetIndex)(THIS) CONST PURE; /// Returns true if non-null resource is bound to this variable. /// \param [in] ArrayIndex - Resource array index. Must be 0 for /// non-array variables. - virtual bool IsBound(Uint32 ArrayIndex) const = 0; + VIRTUAL bool METHOD(IsBound)(THIS_ + Uint32 ArrayIndex) CONST PURE; }; -#else -struct IShaderResourceVariable; +#if DILIGENT_C_INTERFACE + +# undef THIS +# undef THIS_ -// clang-format off -struct IShaderResourceVariableMethods -{ - void (*Set) (struct IShaderResourceVariable*, class IDeviceObject* pObject); - void (*SetArray) (struct IShaderResourceVariable*, class IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements); - SHADER_RESOURCE_VARIABLE_TYPE (*GetType) (struct IShaderResourceVariable*); - void (*GetResourceDesc)(struct IShaderResourceVariable*, struct ShaderResourceDesc* ResourceDesc); - Uint32 (*GetIndex) (struct IShaderResourceVariable*); - bool (*IsBound) (struct IShaderResourceVariable*, Uint32 ArrayIndex); -}; // clang-format on struct IShaderResourceVariableVtbl @@ -166,19 +168,19 @@ struct IShaderResourceVariableVtbl struct IShaderResourceVariableMethods ShaderResourceVariable; }; -struct IShaderResourceVariable +typedef struct IShaderResourceVariable { struct IShaderResourceVariableVtbl* pVtbl; -}; +} IShaderResourceVariable; // clang-format off -# define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((struct IShaderResourceVariable*)(This), __VA_ARGS__) -# define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((struct IShaderResourceVariable*)(This), __VA_ARGS__) -# define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((struct IShaderResourceVariable*)(This)) -# define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((struct IShaderResourceVariable*)(This), __VA_ARGS__) -# define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((struct IShaderResourceVariable*)(This)) -# define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((struct IShaderResourceVariable*)(This), __VA_ARGS__) +# define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((IShaderResourceVariable*)(This), __VA_ARGS__) +# define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((IShaderResourceVariable*)(This), __VA_ARGS__) +# define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((IShaderResourceVariable*)(This)) +# define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((IShaderResourceVariable*)(This), __VA_ARGS__) +# define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((IShaderResourceVariable*)(This)) +# define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((IShaderResourceVariable*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/SwapChain.h b/Graphics/GraphicsEngine/interface/SwapChain.h index 60bdb22f..b1d435e6 100644 --- a/Graphics/GraphicsEngine/interface/SwapChain.h +++ b/Graphics/GraphicsEngine/interface/SwapChain.h @@ -38,23 +38,28 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {1C703B77-6607-4EEC-B1FE-15C82D3B4130} -static const struct INTERFACE_ID IID_SwapChain = +static const INTERFACE_ID IID_SwapChain = {0x1c703b77, 0x6607, 0x4eec, {0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30}}; -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct ISwapChain* +# define THIS_ struct ISwapChain*, +#endif + +// clang-format off /// Swap chain interface /// The swap chain is created by a platform-dependent function -class ISwapChain : public IObject +DILIGENT_INTERFACE(ISwapChain, IObject) { -public: /// Presents a rendered image to the user - virtual void Present(Uint32 SyncInterval = 1) = 0; + VIRTUAL void METHOD(Present)(THIS_ + Uint32 SyncInterval DEFAULT_VALUE(1)) PURE; /// Returns the swap chain desctription - virtual const SwapChainDesc& GetDesc() const = 0; + VIRTUAL const SwapChainDesc REF METHOD(GetDesc)(THIS) CONST PURE; /// Changes the swap chain's back buffer size @@ -63,13 +68,15 @@ public: /// /// \note When resizing non-primary swap chains, the engine unbinds the /// swap chain buffers from the output. - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) = 0; + VIRTUAL void METHOD(Resize)(THIS_ + Uint32 NewWidth, + Uint32 NewHeight) PURE; /// Sets fullscreen mode (only supported on Win32 platform) - virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) = 0; + VIRTUAL void METHOD(SetFullscreenMode)(THIS_ const DisplayModeAttribs REF DisplayMode) PURE; /// Sets windowed mode (only supported on Win32 platform) - virtual void SetWindowedMode() = 0; + VIRTUAL void METHOD(SetWindowedMode)(THIS) PURE; /// Returns render target view of the current back buffer in the swap chain @@ -81,31 +88,20 @@ public: /// /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual ITextureView* GetCurrentBackBufferRTV() = 0; + VIRTUAL ITextureView* METHOD(GetCurrentBackBufferRTV)(THIS) PURE; /// Returns depth-stencil view of the depth buffer /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual ITextureView* GetDepthBufferDSV() = 0; + VIRTUAL ITextureView* METHOD(GetDepthBufferDSV)(THIS) PURE; }; -#else - -struct ISwapChain; -// clang-format off +#if DILIGENT_C_INTERFACE -struct ISwapChainMethods -{ - void (*Present) (struct ISwapChain*, Uint32 SyncInterval); - const struct SwapChainDesc* (*GetDesc) (struct ISwapChain*); - void (*Resize) (struct ISwapChain*, Uint32 NewWidth, Uint32 NewHeight); - void (*SetFullscreenMode) (struct ISwapChain*, const struct DisplayModeAttribs* DisplayMode); - void (*SetWindowedMode) (struct ISwapChain*); - struct ITextureView* (*GetCurrentBackBufferRTV)(struct ISwapChain*); - struct ITextureView* (*GetDepthBufferDSV) (struct ISwapChain*); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -115,20 +111,20 @@ struct ISwapChainVtbl struct ISwapChainMethods SwapChain; }; -struct ISwapChain +typedef struct ISwapChain { struct ISwapChainVtbl* pVtbl; -}; +} ISwapChain; // clang-format off -# define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((struct ISwapChain*)(This), __VA_ARGS__) -# define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((struct ISwapChain*)(This)) -# define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((struct ISwapChain*)(This), __VA_ARGS__) -# define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((struct ISwapChain*)(This), __VA_ARGS__) -# define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((struct ISwapChain*)(This)) -# define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((struct ISwapChain*)(This)) -# define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((struct ISwapChain*)(This)) +# define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((ISwapChain*)(This), __VA_ARGS__) +# define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((ISwapChain*)(This)) +# define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((ISwapChain*)(This), __VA_ARGS__) +# define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((ISwapChain*)(This), __VA_ARGS__) +# define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((ISwapChain*)(This)) +# define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((ISwapChain*)(This)) +# define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((ISwapChain*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h index 598210fd..e5bd316c 100644 --- a/Graphics/GraphicsEngine/interface/Texture.h +++ b/Graphics/GraphicsEngine/interface/Texture.h @@ -39,7 +39,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {A64B0E60-1B5E-4CFD-B880-663A1ADCBE98} -static const struct INTERFACE_ID IID_Texture = +static const INTERFACE_ID IID_Texture = {0xa64b0e60, 0x1b5e, 0x4cfd,{0xb8, 0x80, 0x66, 0x3a, 0x1a, 0xdc, 0xbe, 0x98}}; /// Defines optimized depth-stencil clear value. @@ -60,6 +60,7 @@ struct DepthStencilClearValue {} #endif }; +typedef struct DepthStencilClearValue DepthStencilClearValue; /// Defines optimized clear value. struct OptimizedClearValue @@ -71,7 +72,7 @@ struct OptimizedClearValue Float32 Color[4] DEFAULT_INITIALIZER({}); /// Depth stencil clear value - struct DepthStencilClearValue DepthStencil; + DepthStencilClearValue DepthStencil; #if DILIGENT_CPP_INTERFACE bool operator == (const OptimizedClearValue& rhs)const @@ -86,6 +87,7 @@ struct OptimizedClearValue } #endif }; +typedef struct OptimizedClearValue OptimizedClearValue; /// Texture description struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs) @@ -137,7 +139,7 @@ struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs) MISC_TEXTURE_FLAGS MiscFlags DEFAULT_INITIALIZER(MISC_TEXTURE_FLAG_NONE); /// Optimized clear value - struct OptimizedClearValue ClearValue; + OptimizedClearValue ClearValue; /// Defines which command queues this texture can be used with Uint64 CommandQueueMask DEFAULT_INITIALIZER(1); @@ -203,6 +205,7 @@ struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs) } #endif }; +typedef struct TextureDesc TextureDesc; /// Describes data for one subresource struct TextureSubResData @@ -213,7 +216,7 @@ struct TextureSubResData /// Pointer to the GPU buffer that contains subresource data. /// If provided, pData must be null - class IBuffer* pSrcBuffer DEFAULT_INITIALIZER(nullptr); + struct IBuffer* pSrcBuffer DEFAULT_INITIALIZER(nullptr); /// When updating data from the buffer (pSrcBuffer is not null), /// offset from the beginning of the buffer to the data start @@ -258,13 +261,14 @@ struct TextureSubResData {} #endif }; +typedef struct TextureSubResData TextureSubResData; /// Describes the initial data to store in the texture struct TextureData { /// Pointer to the array of the TextureSubResData elements containing /// information about each subresource. - struct TextureSubResData* pSubResources DEFAULT_INITIALIZER(nullptr); + TextureSubResData* pSubResources DEFAULT_INITIALIZER(nullptr); /// Number of elements in pSubResources array. /// NumSubresources must exactly match the number @@ -282,6 +286,7 @@ struct TextureData {} #endif }; +typedef struct TextureData TextureData; struct MappedTextureSubresource { @@ -301,17 +306,21 @@ struct MappedTextureSubresource {} #endif }; +typedef struct MappedTextureSubresource MappedTextureSubresource; - -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct ITexture* +# define THIS_ struct ITexture*, +#endif /// Texture inteface -class ITexture : public IDeviceObject +DILIGENT_INTERFACE(ITexture, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the texture description used to create the object virtual const TextureDesc& GetDesc()const override = 0; - +#endif + /// Creates a new texture view /// \param [in] ViewDesc - View description. See Diligent::TextureViewDesc for details. @@ -331,7 +340,9 @@ public: /// until all views are released.\n /// The function calls AddRef() for the created interface, so it must be released by /// a call to Release() when it is no longer needed. - virtual void CreateView(const struct TextureViewDesc& ViewDesc, class ITextureView** ppView) = 0; + VIRTUAL void METHOD(CreateView)(THIS_ + const TextureViewDesc REF ViewDesc, + ITextureView** ppView) PURE; /// Returns the pointer to the default view. @@ -340,7 +351,8 @@ public: /// /// \note The function does not increase the reference counter for the returned interface, so /// Release() must *NOT* be called. - virtual ITextureView* GetDefaultView(TEXTURE_VIEW_TYPE ViewType) = 0; + VIRTUAL ITextureView* METHOD(GetDefaultView)(THIS_ + TEXTURE_VIEW_TYPE ViewType) PURE; /// Returns native texture handle specific to the underlying graphics API @@ -348,7 +360,7 @@ public: /// \return pointer to ID3D11Resource interface, for D3D11 implementation\n /// pointer to ID3D12Resource interface, for D3D12 implementation\n /// GL buffer handle, for GL implementation - virtual void* GetNativeHandle() = 0; + VIRTUAL void* METHOD(GetNativeHandle)(THIS) PURE; /// Sets the usage state for all texture subresources. @@ -357,25 +369,17 @@ public: /// This method should be used after the application finished /// manually managing the texture state and wants to hand over /// state management back to the engine. - virtual void SetState(RESOURCE_STATE State) = 0; + VIRTUAL void METHOD(SetState)(THIS_ + RESOURCE_STATE State) PURE; /// Returns the internal texture state - virtual RESOURCE_STATE GetState() const = 0; + VIRTUAL RESOURCE_STATE METHOD(GetState)(THIS) CONST PURE; }; -#else +#if DILIGENT_C_INTERFACE -struct ITexture; -struct ITextureView; - -struct ITextureMethods -{ - void (*CreateView) (struct ITexture*, const struct TextureViewDesc* ViewDesc, class ITextureView** ppView); - class ITextureView* (*GetDefaultView) (struct ITexture*, TEXTURE_VIEW_TYPE ViewType); - void* (*GetNativeHandle)(struct ITexture*); - void (*SetState) (struct ITexture*, RESOURCE_STATE State); - RESOURCE_STATE (*GetState) (struct ITexture*); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -386,20 +390,20 @@ struct ITextureVtbl struct ITextureMethods Texture; }; -struct ITexture +typedef struct ITexture { struct ITextureVtbl* pVtbl; -}; +} ITexture; // clang-format off # define ITexture_GetDesc(This) (const struct TextureDesc*)IDeviceObject_GetDesc(This) -# define ITexture_CreateView(This, ...) (This)->pVtbl->Texture.CreateView ((struct ITexture*)(This), __VA_ARGS__) -# define ITexture_GetDefaultView(This, ...) (This)->pVtbl->Texture.GetDefaultView ((struct ITexture*)(This), __VA_ARGS__) -# define ITexture_GetNativeHandle(This) (This)->pVtbl->Texture.GetNativeHandle((struct ITexture*)(This)) -# define ITexture_SetState(This, ...) (This)->pVtbl->Texture.SetState ((struct ITexture*)(This), __VA_ARGS__) -# define ITexture_GetState(This) (This)->pVtbl->Texture.GetState ((struct ITexture*)(This)) +# define ITexture_CreateView(This, ...) (This)->pVtbl->Texture.CreateView ((ITexture*)(This), __VA_ARGS__) +# define ITexture_GetDefaultView(This, ...) (This)->pVtbl->Texture.GetDefaultView ((ITexture*)(This), __VA_ARGS__) +# define ITexture_GetNativeHandle(This) (This)->pVtbl->Texture.GetNativeHandle((ITexture*)(This)) +# define ITexture_SetState(This, ...) (This)->pVtbl->Texture.SetState ((ITexture*)(This), __VA_ARGS__) +# define ITexture_GetState(This) (This)->pVtbl->Texture.GetState ((ITexture*)(This)) // clang-format on diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h index e79a23a8..4182d85d 100644 --- a/Graphics/GraphicsEngine/interface/TextureView.h +++ b/Graphics/GraphicsEngine/interface/TextureView.h @@ -37,10 +37,10 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) - +struct ISampler; // {5B2EA04E-8128-45E4-AA4D-6DC7E70DC424} -static const struct INTERFACE_ID IID_TextureView = +static const INTERFACE_ID IID_TextureView = {0x5b2ea04e, 0x8128, 0x45e4,{0xaa, 0x4d, 0x6d, 0xc7, 0xe7, 0xd, 0xc4, 0x24}}; // clang-format off @@ -180,10 +180,14 @@ struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) #endif }; +typedef struct TextureViewDesc TextureViewDesc; // clang-format on -#if DILIGENT_CPP_INTERFACE +#if DILIGENT_C_INTERFACE +# define THIS struct ITextureView* +# define THIS_ struct ITextureView*, +#endif /// Texture view interface @@ -193,45 +197,37 @@ struct TextureViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) /// will not be destroyed until all views are released. /// The texture view will also keep a strong reference to the texture sampler, /// if any is set. -class ITextureView : public IDeviceObject +DILIGENT_INTERFACE(ITextureView, IDeviceObject) { -public: +#if DILIGENT_CPP_INTERFACE /// Returns the texture view description used to create the object virtual const TextureViewDesc& GetDesc() const override = 0; +#endif /// Sets the texture sampler to use for filtering operations /// when accessing a texture from shaders. Only /// shader resource views can be assigned a sampler. /// The view will keep strong reference to the sampler. - virtual void SetSampler(class ISampler* pSampler) = 0; + VIRTUAL void METHOD(SetSampler)(THIS_ struct ISampler * pSampler) PURE; /// Returns the pointer to the sampler object set by the ITextureView::SetSampler(). /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual ISampler* GetSampler() = 0; + VIRTUAL struct ISampler* METHOD(GetSampler)(THIS) PURE; /// Returns the pointer to the referenced texture object. /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual class ITexture* GetTexture() = 0; + VIRTUAL struct ITexture* METHOD(GetTexture)(THIS) PURE; }; -#else - -struct ITextureView; -struct ISampler; +#if DILIGENT_C_INTERFACE -// clang-format off - -struct ITextureViewMethods -{ - void (*SetSampler)(struct ITextureView*, class ISampler* pSampler); - class ISampler* (*GetSampler)(struct ITextureView*); - class ITexture* (*GetTexture)(struct ITextureView*); -}; +# undef THIS +# undef THIS_ // clang-format on @@ -242,18 +238,18 @@ struct ITextureViewVtbl struct ITextureViewMethods TextureView; }; -struct ITextureView +typedef struct ITextureView { struct ITextureViewVtbl* pVtbl; -}; +} ITextureView; # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)IDeviceObject_GetDesc(This) // clang-format off -# define ITextureView_SetSampler(This, ...) (This)->pVtbl->TextureView.SetSampler((struct ITextureView*)(This), __VA_ARGS__) -# define ITextureView_GetSampler(This) (This)->pVtbl->TextureView.GetSampler((struct ITextureView*)(This)) -# define ITextureView_GetTexture(This) (This)->pVtbl->TextureView.GetTexture((struct ITextureView*)(This)) +# define ITextureView_SetSampler(This, ...) (This)->pVtbl->TextureView.SetSampler((ITextureView*)(This), __VA_ARGS__) +# define ITextureView_GetSampler(This) (This)->pVtbl->TextureView.GetSampler((ITextureView*)(This)) +# define ITextureView_GetTexture(This) (This)->pVtbl->TextureView.GetTexture((ITextureView*)(This)) // clang-format on -- cgit v1.2.3