git.s-ol.nu forks/DiligentCore / 10cd33e
Reworked C interfaces to share declaration with c++ assiduous 3 years ago
66 changed file(s) with 1087 addition(s) and 952 deletion(s). Raw diff Collapse all Expand all
5050 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override;
5151
5252 /// Reads data from the stream
53 virtual void Read(IDataBlob* pData) override;
53 virtual void ReadBlob(IDataBlob* pData) override;
5454
5555 /// Reads data from the stream
5656 virtual bool Read(void* Data, size_t Size) override;
5050 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override;
5151
5252 /// Reads data from the stream
53 virtual void Read(IDataBlob* pData) override;
53 virtual void ReadBlob(IDataBlob* pData) override;
5454
5555 /// Reads data from the stream
5656 virtual bool Read(void* Data, size_t Size) override;
150150 return NumWeakReferences;
151151 }
152152
153 inline virtual void GetObject(class IObject** ppObject) override final
153 inline virtual void GetObject(struct IObject** ppObject) override final
154154 {
155155 if (m_ObjectState != ObjectState::Alive)
156156 return; // Early exit
4545 return m_FileWrpr->Read(Data, Size);
4646 }
4747
48 void BasicFileStream::Read(Diligent::IDataBlob* pData)
48 void BasicFileStream::ReadBlob(Diligent::IDataBlob* pData)
4949 {
5050 return m_FileWrpr->Read(pData);
5151 }
5252 return Size == BytesToRead;
5353 }
5454
55 void MemoryFileStream::Read(IDataBlob* pData)
55 void MemoryFileStream::ReadBlob(IDataBlob* pData)
5656 {
5757 auto BytesLeft = m_DataBlob->GetSize() - m_CurrentOffset;
5858 pData->Resize(BytesLeft);
296296 if (pSourceStream == nullptr)
297297 LOG_ERROR_AND_THROW("Failed to open shader source file");
298298
299 pSourceStream->Read(pFileData);
299 pSourceStream->ReadBlob(pFileData);
300300 ShaderSource = reinterpret_cast<char*>(pFileData->GetDataPtr());
301301 SourceLen = pFileData->GetSize();
302302 }
393393 }
394394
395395 RefCntAutoPtr<IDataBlob> pFileData(MakeNewRCObj<DataBlobImpl>()(0));
396 pSourceStream->Read(pFileData);
396 pSourceStream->ReadBlob(pFileData);
397397 auto* pNewInclude =
398398 new IncludeResult{
399399 headerName,
461461 if (pSourceStream == nullptr)
462462 LOG_ERROR_AND_THROW("Failed to open shader source file");
463463
464 pSourceStream->Read(pFileData);
464 pSourceStream->ReadBlob(pFileData);
465465 SourceCode = reinterpret_cast<char*>(pFileData->GetDataPtr());
466466 SourceCodeLen = static_cast<int>(pFileData->GetSize());
467467 }
3434 /// Creates default shader source stream factory
3535 /// \param [in] SearchDirectories - Semicolon-seprated list of search directories.
3636 /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written.
37 void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
38 class IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory);
37 void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
38 IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory);
3939
4040 DILIGENT_END_NAMESPACE // namespace Diligent
9797 size_t MappedTextureSubresourceSize DEFAULT_INITIALIZER(0);
9898 size_t TextureViewDescSize DEFAULT_INITIALIZER(0);
9999 };
100 typedef struct APIInfo APIInfo;
100101
101102 DILIGENT_END_NAMESPACE // namespace Diligent
361361 }
362362 #endif
363363 };
364 typedef struct RenderTargetBlendDesc RenderTargetBlendDesc;
364365
365366
366367 /// Blend state description
378379
379380 /// An array of RenderTargetBlendDesc structures that describe the blend
380381 /// states for render targets
381 struct RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS];
382 RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS];
382383
383384 #if DILIGENT_CPP_INTERFACE
384385 // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
423424 }
424425 #endif
425426 };
427 typedef struct BlendStateDesc BlendStateDesc;
426428
427429 DILIGENT_END_NAMESPACE // namespace Diligent
3838
3939
4040 // {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4}
41 static const struct INTERFACE_ID IID_Buffer =
41 static const INTERFACE_ID IID_Buffer =
4242 {0xec47ead3, 0xa2c4, 0x44f2, {0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4}};
4343
4444 /// Describes the buffer access mode.
147147 }
148148 #endif
149149 };
150 typedef struct BufferDesc BufferDesc;
150151
151152 /// Describes the buffer initial data
152153 struct BufferData
169170 {}
170171 #endif
171172 };
172
173
173 typedef struct BufferData BufferData;
174
175 #if DILIGENT_C_INTERFACE
176 # define THIS struct IBuffer*
177 # define THIS_ struct IBuffer*,
178 #endif
179
180
181 /// Buffer interface
182
183 /// Defines the methods to manipulate a buffer object
184 DILIGENT_INTERFACE(IBuffer, IDeviceObject)
185 {
174186 #if DILIGENT_CPP_INTERFACE
175
176 /// Buffer interface
177
178 /// Defines the methods to manipulate a buffer object
179 class IBuffer : public IDeviceObject
180 {
181 public:
182187 /// Returns the buffer description used to create the object
183188 virtual const BufferDesc& GetDesc() const override = 0;
189 #endif
184190
185191 /// Creates a new buffer view
186192
193199 /// until all views are released.\n
194200 /// The function calls AddRef() for the created interface, so it must be released by
195201 /// a call to Release() when it is no longer needed.
196 virtual void CreateView(const struct BufferViewDesc& ViewDesc, class IBufferView** ppView) = 0;
202 VIRTUAL void METHOD(CreateView)(THIS_
203 const BufferViewDesc REF ViewDesc,
204 IBufferView** ppView) PURE;
197205
198206 /// Returns the pointer to the default view.
199207
205213 ///
206214 /// \note The function does not increase the reference counter for the returned interface, so
207215 /// Release() must *NOT* be called.
208 virtual IBufferView* GetDefaultView(BUFFER_VIEW_TYPE ViewType) = 0;
216 VIRTUAL IBufferView* METHOD(GetDefaultView)(THIS_
217 BUFFER_VIEW_TYPE ViewType) PURE;
209218
210219 /// Returns native buffer handle specific to the underlying graphics API
211220
212221 /// \return pointer to ID3D11Resource interface, for D3D11 implementation\n
213222 /// pointer to ID3D12Resource interface, for D3D12 implementation\n
214223 /// GL buffer handle, for GL implementation
215 virtual void* GetNativeHandle() = 0;
224 VIRTUAL void* METHOD(GetNativeHandle)(THIS) PURE;
216225
217226 /// Sets the buffer usage state.
218227
221230 /// This method should be used after the application finished
222231 /// manually managing the buffer state and wants to hand over
223232 /// state management back to the engine.
224 virtual void SetState(RESOURCE_STATE State) = 0;
233 VIRTUAL void METHOD(SetState)(THIS_
234 RESOURCE_STATE State) PURE;
225235
226236 /// Returns the internal buffer state
227 virtual RESOURCE_STATE GetState() const = 0;
228 };
229
230 #else
231
232 struct IBuffer;
233
234 struct IBufferMethods
235 {
236 void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView);
237 class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType);
238 void* (*GetNativeHandle)(struct IBuffer*);
239 void (*SetState) (struct IBuffer*,RESOURCE_STATE State);
240 RESOURCE_STATE (*GetState) (struct IBuffer*);
241 };
237 VIRTUAL RESOURCE_STATE METHOD(GetState)(THIS) CONST PURE;
238 };
239
240 #if DILIGENT_C_INTERFACE
241
242 #undef THIS
243 #undef THIS_
242244
243245 // clang-format on
244246
249251 struct IBufferMethods Buffer;
250252 };
251253
252 struct IBuffer
254 typedef struct IBuffer
253255 {
254256 struct IBufferVtbl* pVtbl;
255 };
257 } IBuffer;
256258
257259 // clang-format off
258260
259261 # define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This)
260262
261 # define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((struct IBuffer*)(This), __VA_ARGS__)
262 # define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__)
263 # define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((struct IBuffer*)(This))
264 # define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((struct IBuffer*)(This), __VA_ARGS__)
265 # define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((struct IBuffer*)(This))
263 # define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((IBuffer*)(This), __VA_ARGS__)
264 # define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((IBuffer*)(This), __VA_ARGS__)
265 # define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((IBuffer*)(This))
266 # define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((IBuffer*)(This), __VA_ARGS__)
267 # define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((IBuffer*)(This))
266268
267269 // clang-format on
268270
8181 }
8282 #endif
8383 };
84 typedef struct BufferFormat BufferFormat;
8485
8586 /// Buffer view description
8687 struct BufferViewDesc DILIGENT_DERIVE(DeviceObjectAttribs)
135136 }
136137 #endif
137138 };
139 typedef struct BufferViewDesc BufferViewDesc;
138140
139141
140 #if DILIGENT_CPP_INTERFACE
142
143 #if DILIGENT_C_INTERFACE
144 # define THIS struct IBufferView*
145 # define THIS_ struct IBufferView*,
146 #endif
141147
142148 /// Buffer view interface
143149
145151 /// \remarks
146152 /// Buffer view holds strong references to the buffer. The buffer
147153 /// will not be destroyed until all views are released.
148 class IBufferView : public IDeviceObject
154 DILIGENT_INTERFACE(IBufferView, IDeviceObject)
149155 {
150 public:
156 #if DILIGENT_CPP_INTERFACE
151157 /// Returns the buffer view description used to create the object
152158 virtual const BufferViewDesc& GetDesc() const override = 0;
159 #endif
153160
154161 /// Returns pointer to the referenced buffer object.
155162
156163 /// The method does *NOT* call AddRef() on the returned interface,
157164 /// so Release() must not be called.
158 virtual class IBuffer* GetBuffer() = 0;
165 VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) PURE;
159166 };
160167
161 #else
168 #if DILIGENT_C_INTERFACE
162169
163 class IBufferView;
164 class IBuffer;
170 # undef THIS
171 # undef THIS_
165172
166 struct IBufferViewMethods
167 {
168 class IBuffer* (*GetBuffer)(struct IBufferView*);
169 };
173 // clang-format on
170174
171175 struct IBufferViewVtbl
172176 {
175179 struct IBufferViewMethods BufferView;
176180 };
177181
178 struct IBufferView
182 typedef struct IBufferView
179183 {
180184 struct IBufferViewVtbl* pVtbl;
181 };
185 } IBufferView;
186
187 // clang-format off
182188
183189 # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This)
184190
185 # define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((struct IBufferView*)(This))
191 # define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((IBufferView*)(This))
192
193 // clang-format on
186194
187195 #endif
188196
6464 //struct ICommandListMethods CommandList;
6565 };
6666
67 struct ICommandList
67 typedef struct ICommandList
6868 {
6969 struct ICommandListVtbl* pVtbl;
70 };
70 } ICommandList;
7171
7272 #endif
7373
144144 }
145145 #endif
146146 };
147 typedef struct StencilOpDesc StencilOpDesc;
147148
148149 /// Depth stencil state description
149150
179180 Uint8 StencilWriteMask DEFAULT_INITIALIZER(0xFF);
180181
181182 /// Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc.
182 struct StencilOpDesc FrontFace;
183 StencilOpDesc FrontFace;
183184
184185 /// Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc.
185 struct StencilOpDesc BackFace;
186 StencilOpDesc BackFace;
186187
187188
188189 #if DILIGENT_CPP_INTERFACE
228229 }
229230 #endif
230231 };
232 typedef struct DepthStencilStateDesc DepthStencilStateDesc;
231233
232234 DILIGENT_END_NAMESPACE
5959 /// Indicates if device supports MIP load bias
6060 Bool LODBiasSupported DEFAULT_INITIALIZER(False);
6161 };
62 typedef struct SamplerCaps SamplerCaps;
6263
6364 /// Texture capabilities
6465 struct TextureCaps
9394 /// Indicates if device supports cubemap arrays
9495 Bool CubemapArraysSupported DEFAULT_INITIALIZER(False);
9596 };
97 typedef struct TextureCaps TextureCaps;
9698
9799 /// Describes supported device features
98100 struct DeviceFeatures
162164 /// Specifies whether all the extended UAV texture formats are available in shader code.
163165 Bool TextureUAVExtendedFormats DEFAULT_INITIALIZER(False);
164166 };
167 typedef struct DeviceFeatures DeviceFeatures;
165168
166169 /// Device capabilities
167170 struct DeviceCaps
183186 ADAPTER_TYPE AdaterType DEFAULT_INITIALIZER(ADAPTER_TYPE_UNKNOWN);
184187
185188 /// Texture sampling capabilities. See Diligent::SamplerCaps.
186 struct SamplerCaps SamCaps;
189 SamplerCaps SamCaps;
187190
188191 /// Texture capabilities. See Diligent::TextureCaps.
189 struct TextureCaps TexCaps;
192 TextureCaps TexCaps;
190193
191194 /// Device features. See Diligent::DeviceFeatures.
192 struct DeviceFeatures Features;
195 DeviceFeatures Features;
193196
194197 #if DILIGENT_CPP_INTERFACE
195198 bool IsGLDevice()const
249252 }
250253 #endif
251254 };
255 typedef struct DeviceCaps DeviceCaps;
252256
253257 DILIGENT_END_NAMESPACE // namespace Diligent
5555
5656
5757 // {DC92711B-A1BE-4319-B2BD-C662D1CC19E4}
58 static const struct INTERFACE_ID IID_DeviceContext =
58 static const INTERFACE_ID IID_DeviceContext =
5959 {0xdc92711b, 0xa1be, 0x4319, {0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4}};
6060
6161 /// Draw command flags
209209 {}
210210 #endif
211211 };
212 typedef struct DrawAttribs DrawAttribs;
212213
213214
214215 /// Defines the indexed draw command attributes.
275276 {}
276277 #endif
277278 };
278
279 typedef struct DrawIndexedAttribs DrawIndexedAttribs;
279280
280281 /// Defines the indirect draw command attributes.
281282
313314 {}
314315 #endif
315316 };
316
317 typedef struct DrawIndirectAttribs DrawIndirectAttribs;
317318
318319 /// Defines the indexed indirect draw command attributes.
319320
358359 {}
359360 #endif
360361 };
361
362 typedef struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs;
362363
363364 /// Defines which parts of the depth-stencil buffer to clear.
364365
397398 {}
398399 #endif
399400 };
401 typedef struct DispatchComputeAttribs DispatchComputeAttribs;
402
400403
401404 /// Describes dispatch command arguments.
402405
421424 {}
422425 #endif
423426 };
427 typedef struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs;
424428
425429
426430 /// Describes multi-sampled texture resolve command arguments.
451455 /// either TEX_FORMAT_UNKNOWN, or match this format.
452456 TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
453457 };
458 typedef struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs;
459
454460
455461 /// Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
456462 DILIGENT_TYPED_ENUM(SET_VERTEX_BUFFERS_FLAGS, Uint8)
507513 Viewport()noexcept{}
508514 #endif
509515 };
516 typedef struct Viewport Viewport;
517
510518
511519 /// Describes the rectangle.
512520
539547 }
540548 #endif
541549 };
550 typedef struct Rect Rect;
542551
543552
544553 /// Defines copy texture command attributes.
547556 struct CopyTextureAttribs
548557 {
549558 /// Source texture to copy data from.
550 class ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr);
559 ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr);
551560
552561 /// Mip level of the source texture to copy data from.
553562 Uint32 SrcMipLevel DEFAULT_INITIALIZER(0);
556565 Uint32 SrcSlice DEFAULT_INITIALIZER(0);
557566
558567 /// Source region to copy. Use nullptr to copy the entire subresource.
559 const struct Box* pSrcBox DEFAULT_INITIALIZER(nullptr);
568 const Box* pSrcBox DEFAULT_INITIALIZER(nullptr);
560569
561570 /// Source texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
562571 RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
563572
564573 /// Destination texture.
565 class ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr);
574 ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr);
566575
567576 /// Destination mip level.
568577 Uint32 DstMipLevel DEFAULT_INITIALIZER(0);
597606 {}
598607 #endif
599608 };
600
601
602
603 #if DILIGENT_CPP_INTERFACE
609 typedef struct CopyTextureAttribs CopyTextureAttribs;
610
611
612 #if DILIGENT_C_INTERFACE
613 # define THIS struct IDeviceContext*
614 # define THIS_ struct IDeviceContext*,
615 #endif
604616
605617 /// Device context interface.
606618
608620 /// the pipeline: buffers, states, samplers, shaders, etc.
609621 /// The context also keeps strong reference to the device and
610622 /// the swap chain.
611 class IDeviceContext : public IObject
612 {
613 public:
623 DILIGENT_INTERFACE(IDeviceContext, IObject)
624 {
614625 /// Sets the pipeline state.
615626
616627 /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context.
617 virtual void SetPipelineState(IPipelineState* pPipelineState) = 0;
628 VIRTUAL void METHOD(SetPipelineState)(THIS_
629 IPipelineState* pPipelineState) PURE;
618630
619631
620632 /// Transitions shader resources to the states required by Draw or Dispatch command.
635647 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
636648 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
637649 /// of resource state management in Diligent Engine.
638 virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) = 0;
650 VIRTUAL void METHOD(TransitionShaderResources)(THIS_
651 IPipelineState* pPipelineState,
652 IShaderResourceBinding* pShaderResourceBinding) PURE;
639653
640654 /// Commits shader resources to the device context.
641655
674688 /// If an application calls any method that changes the state of any resource after it has been committed, the
675689 /// application is responsible for transitioning the resource back to correct state using one of the available methods
676690 /// before issuing the next draw or dispatch command.
677 virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
691 VIRTUAL void METHOD(CommitShaderResources)(THIS_
692 IShaderResourceBinding* pShaderResourceBinding,
693 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
678694
679695 /// Sets the stencil reference value.
680696
681697 /// \param [in] StencilRef - Stencil reference value.
682 virtual void SetStencilRef(Uint32 StencilRef) = 0;
698 VIRTUAL void METHOD(SetStencilRef)(THIS_
699 Uint32 StencilRef) PURE;
683700
684701
685702 /// \param [in] pBlendFactors - Array of four blend factors, one for each RGBA component.
688705 /// Diligent::BLEND_FACTOR_INV_BLEND_FACTOR
689706 /// blend factors. If nullptr is provided,
690707 /// default blend factors array {1,1,1,1} will be used.
691 virtual void SetBlendFactors(const float* pBlendFactors = nullptr) = 0;
708 VIRTUAL void METHOD(SetBlendFactors)(THIS_
709 const float* pBlendFactors DEFAULT_VALUE(nullptr)) PURE;
692710
693711
694712 /// Binds vertex buffers to the pipeline.
721739 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
722740 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
723741 /// of resource state management in Diligent Engine.
724 virtual void SetVertexBuffers(Uint32 StartSlot,
725 Uint32 NumBuffersSet,
726 IBuffer** ppBuffers,
727 Uint32* pOffsets,
728 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
729 SET_VERTEX_BUFFERS_FLAGS Flags) = 0;
742 VIRTUAL void METHOD(SetVertexBuffers)(THIS_
743 Uint32 StartSlot,
744 Uint32 NumBuffersSet,
745 IBuffer** ppBuffers,
746 Uint32* pOffsets,
747 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
748 SET_VERTEX_BUFFERS_FLAGS Flags) PURE;
730749
731750
732751 /// Invalidates the cached context state.
733752
734753 /// This method should be called by an application to invalidate
735754 /// internal cached states.
736 virtual void InvalidateState() = 0;
755 VIRTUAL void METHOD(InvalidateState)(THIS) PURE;
737756
738757
739758 /// Binds an index buffer to the pipeline.
757776 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
758777 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
759778 /// of resource state management in Diligent Engine.
760 virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
779 VIRTUAL void METHOD(SetIndexBuffer)(THIS_
780 IBuffer* pIndexBuffer,
781 Uint32 ByteOffset,
782 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
761783
762784
763785 /// Sets an array of viewports.
778800 /// following call:
779801 ///
780802 /// pContext->SetViewports(1, nullptr, 0, 0);
781 virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) = 0;
803 VIRTUAL void METHOD(SetViewports)(THIS_
804 Uint32 NumViewports,
805 const Viewport* pViewports,
806 Uint32 RTWidth,
807 Uint32 RTHeight) PURE;
782808
783809
784810 /// Sets active scissor rects.
795821 /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n
796822 /// All scissor rects must be set atomically as one operation. Any rects not
797823 /// defined by the call are disabled.
798 virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) = 0;
824 VIRTUAL void METHOD(SetScissorRects)(THIS_
825 Uint32 NumRects,
826 const Rect* pRects,
827 Uint32 RTWidth,
828 Uint32 RTHeight) PURE;
799829
800830
801831 /// Binds one or more render targets and the depth-stencil buffer to the context. It also
825855 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
826856 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
827857 /// of resource state management in Diligent Engine.
828 virtual void SetRenderTargets(Uint32 NumRenderTargets,
829 ITextureView* ppRenderTargets[],
830 ITextureView* pDepthStencil,
831 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
858 VIRTUAL void METHOD(SetRenderTargets)(THIS_
859 Uint32 NumRenderTargets,
860 ITextureView* ppRenderTargets[],
861 ITextureView* pDepthStencil,
862 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
832863
833864
834865 /// Executes a draw command.
841872 ///
842873 /// If the application intends to use the same resources in other threads simultaneously, it needs to
843874 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
844 virtual void Draw(const DrawAttribs& Attribs) = 0;
875 VIRTUAL void METHOD(Draw)(THIS_
876 const DrawAttribs REF Attribs) PURE;
845877
846878
847879 /// Executes an indexed draw command.
854886 ///
855887 /// If the application intends to use the same resources in other threads simultaneously, it needs to
856888 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
857 virtual void DrawIndexed(const DrawIndexedAttribs& Attribs) = 0;
889 VIRTUAL void METHOD(DrawIndexed)(THIS_
890 const DrawIndexedAttribs REF Attribs) PURE;
858891
859892
860893 /// Executes an indirect draw command.
872905 ///
873906 /// If the application intends to use the same resources in other threads simultaneously, it needs to
874907 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
875 virtual void DrawIndirect(const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0;
908 VIRTUAL void METHOD(DrawIndirect)(THIS_
909 const DrawIndirectAttribs REF Attribs,
910 IBuffer* pAttribsBuffer) PURE;
876911
877912
878913 /// Executes an indexed indirect draw command.
890925 ///
891926 /// If the application intends to use the same resources in other threads simultaneously, it needs to
892927 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
893 virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0;
928 VIRTUAL void METHOD(DrawIndexedIndirect)(THIS_
929 const DrawIndexedIndirectAttribs REF Attribs,
930 IBuffer* pAttribsBuffer) PURE;
894931
895932
896933 /// Executes a dispatch compute command.
897934
898935 /// \param [in] Attribs - Dispatch command attributes, see Diligent::DispatchComputeAttribs for details.
899 virtual void DispatchCompute(const DispatchComputeAttribs& Attribs) = 0;
936 VIRTUAL void METHOD(DispatchCompute)(THIS_
937 const DispatchComputeAttribs REF Attribs) PURE;
900938
901939
902940 /// Executes an indirect dispatch compute command.
910948 ///
911949 /// If the application intends to use the same resources in other threads simultaneously, it needs to
912950 /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
913 virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0;
951 VIRTUAL void METHOD(DispatchComputeIndirect)(THIS_
952 const DispatchComputeIndirectAttribs REF Attribs,
953 IBuffer* pAttribsBuffer) PURE;
914954
915955
916956 /// Clears a depth-stencil view.
934974 /// the state of resources used by the command.
935975 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
936976 /// of resource state management in Diligent Engine.
937 virtual void ClearDepthStencil(ITextureView* pView,
938 CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
939 float fDepth,
940 Uint8 Stencil,
941 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
977 VIRTUAL void METHOD(ClearDepthStencil)(THIS_
978 ITextureView* pView,
979 CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
980 float fDepth,
981 Uint8 Stencil,
982 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
942983
943984
944985 /// Clears a render target view
9661007 /// Diligent::RESOURCE_STATE_COPY_DEST state. Inside a render pass it must be in Diligent::RESOURCE_STATE_RENDER_TARGET
9671008 /// state. When using Diligent::RESOURCE_STATE_TRANSITION_TRANSITION mode, the engine takes care of proper
9681009 /// resource state transition, otherwise it is the responsibility of the application.
969 virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
1010 VIRTUAL void METHOD(ClearRenderTarget)(THIS_
1011 ITextureView* pView,
1012 const float* RGBA,
1013 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
9701014
9711015
9721016 /// Finishes recording commands and generates a command list.
9731017
9741018 /// \param [out] ppCommandList - Memory location where pointer to the recorded command list will be written.
975 virtual void FinishCommandList(ICommandList **ppCommandList) = 0;
1019 VIRTUAL void METHOD(FinishCommandList)(THIS_
1020 ICommandList** ppCommandList) PURE;
9761021
9771022
9781023 /// Executes recorded commands in a command list.
9791024
9801025 /// \param [in] pCommandList - Pointer to the command list to executre.
9811026 /// \remarks After command list is executed, it is no longer valid and should be released.
982 virtual void ExecuteCommandList(ICommandList* pCommandList) = 0;
1027 VIRTUAL void METHOD(ExecuteCommandList)(THIS_
1028 ICommandList* pCommandList) PURE;
9831029
9841030
9851031 /// Tells the GPU to set a fence to a specified value after all previous work has completed.
9921038 /// \param [in] pFence - The fence to signal
9931039 /// \param [in] Value - The value to set the fence to. This value must be greater than the
9941040 /// previously signaled value on the same fence.
995 virtual void SignalFence(IFence* pFence, Uint64 Value) = 0;
1041 VIRTUAL void METHOD(SignalFence)(THIS_
1042 IFence* pFence,
1043 Uint64 Value) PURE;
9961044
9971045
9981046 /// Waits until the specified fence reaches or exceeds the specified value, on the host.
10141062 /// may never return.\n
10151063 /// The fence can only be waited for from the same context it has
10161064 /// previously been signaled.
1017 virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) = 0;
1065 VIRTUAL void METHOD(WaitForFence)(THIS_
1066 IFence* pFence,
1067 Uint64 Value,
1068 bool FlushContext) PURE;
10181069
10191070
10201071 /// Submits all outstanding commands for execution to the GPU and waits until they are complete.
10251076 /// The methods implicitly flushes the context (see IDeviceContext::Flush()), so an
10261077 /// application must explicitly reset the PSO and bind all required shader resources after
10271078 /// idling the context.\n
1028 virtual void WaitForIdle() = 0;
1079 VIRTUAL void METHOD(WaitForIdle)(THIS) PURE;
10291080
10301081
10311082 /// Marks the beginning of a query.
10461097 /// SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE).
10471098 ///
10481099 /// \warning OpenGL and Vulkan do not support nested queries of the same type.
1049 virtual void BeginQuery(IQuery* pQuery) = 0;
1100 VIRTUAL void METHOD(BeginQuery)(THIS_
1101 IQuery* pQuery) PURE;
10501102
10511103
10521104 /// Marks the end of a query.
10621114 /// It is an error to explicitly flush the context while a query is active.
10631115 ///
10641116 /// All queries must be ended when IDeviceContext::FinishFrame() is called.
1065 virtual void EndQuery(IQuery* pQuery) = 0;
1117 VIRTUAL void METHOD(EndQuery)(THIS_
1118 IQuery* pQuery) PURE;
10661119
10671120
10681121 /// Submits all pending commands in the context for execution to the command queue.
10741127 /// restore viewports and scissor rects, etc.) except for the pipeline state and shader resource
10751128 /// bindings. An application must explicitly reset the PSO and bind all required shader
10761129 /// resources after flushing the context.
1077 virtual void Flush() = 0;
1130 VIRTUAL void METHOD(Flush)(THIS) PURE;
10781131
10791132
10801133 /// Updates the data in the buffer.
10841137 /// \param [in] Size - Size in bytes of the data region to update.
10851138 /// \param [in] pData - Pointer to the data to write to the buffer.
10861139 /// \param [in] StateTransitionMode - Buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
1087 virtual void UpdateBuffer(IBuffer* pBuffer,
1088 Uint32 Offset,
1089 Uint32 Size,
1090 const void* pData,
1091 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0;
1140 VIRTUAL void METHOD(UpdateBuffer)(THIS_
1141 IBuffer* pBuffer,
1142 Uint32 Offset,
1143 Uint32 Size,
1144 const void* pData,
1145 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;
10921146
10931147
10941148 /// Copies the data from one buffer to another.
11011155 /// of the destination region.
11021156 /// \param [in] Size - Size in bytes of data to copy.
11031157 /// \param [in] DstBufferTransitionMode - State transition mode of the destination buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
1104 virtual void CopyBuffer(IBuffer* pSrcBuffer,
1105 Uint32 SrcOffset,
1106 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1107 IBuffer* pDstBuffer,
1108 Uint32 DstOffset,
1109 Uint32 Size,
1110 RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) = 0;
1158 VIRTUAL void METHOD(CopyBuffer)(THIS_
1159 IBuffer* pSrcBuffer,
1160 Uint32 SrcOffset,
1161 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1162 IBuffer* pDstBuffer,
1163 Uint32 DstOffset,
1164 Uint32 Size,
1165 RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) PURE;
11111166
11121167
11131168 /// Maps the buffer.
11161171 /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE.
11171172 /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS.
11181173 /// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region.
1119 virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) = 0;
1174 VIRTUAL void METHOD(MapBuffer)(THIS_
1175 IBuffer* pBuffer,
1176 MAP_TYPE MapType,
1177 MAP_FLAGS MapFlags,
1178 PVoid REF pMappedData) PURE;
11201179
11211180
11221181 /// Unmaps the previously mapped buffer.
11241183 /// \param [in] pBuffer - Pointer to the buffer to unmap.
11251184 /// \param [in] MapType - Type of the map operation. This parameter must match the type that was
11261185 /// provided to the Map() method.
1127 virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) = 0;
1186 VIRTUAL void METHOD(UnmapBuffer)(THIS_
1187 IBuffer* pBuffer,
1188 MAP_TYPE MapType) PURE;
11281189
11291190
11301191 /// Updates the data in the texture.
11381199 /// parameter defines state transition mode of the source buffer.
11391200 /// If pSrcBuffer is null, this parameter is ignored.
11401201 /// \param [in] TextureTransitionMode - Texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
1141 virtual void UpdateTexture(ITexture* pTexture,
1142 Uint32 MipLevel,
1143 Uint32 Slice,
1144 const Box& DstBox,
1145 const TextureSubResData& SubresData,
1146 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1147 RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) = 0;
1202 VIRTUAL void METHOD(UpdateTexture)(THIS_
1203 ITexture* pTexture,
1204 Uint32 MipLevel,
1205 Uint32 Slice,
1206 const Box REF DstBox,
1207 const TextureSubResData REF SubresData,
1208 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1209 RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) PURE;
11481210
11491211
11501212 /// Copies data from one texture to another.
11511213
11521214 /// \param [in] CopyAttribs - Structure describing copy command attributes, see Diligent::CopyTextureAttribs for details.
1153 virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) = 0;
1215 VIRTUAL void METHOD(CopyTexture)(THIS_
1216 const CopyTextureAttribs REF CopyAttribs) PURE;
11541217
11551218
11561219 /// Maps the texture subresource.
11671230 /// subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource.
11681231 /// In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping
11691232 /// with MAP_FLAG_DISCARD has exactly the same behavior.
1170 virtual void MapTextureSubresource(ITexture* pTexture,
1171 Uint32 MipLevel,
1172 Uint32 ArraySlice,
1173 MAP_TYPE MapType,
1174 MAP_FLAGS MapFlags,
1175 const Box* pMapRegion,
1176 MappedTextureSubresource& MappedData) = 0;
1233 VIRTUAL void METHOD(MapTextureSubresource)(THIS_
1234 ITexture* pTexture,
1235 Uint32 MipLevel,
1236 Uint32 ArraySlice,
1237 MAP_TYPE MapType,
1238 MAP_FLAGS MapFlags,
1239 const Box* pMapRegion,
1240 MappedTextureSubresource REF MappedData) PURE;
11771241
11781242
11791243 /// Unmaps the texture subresource.
1180 virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) = 0;
1244 VIRTUAL void METHOD(UnmapTextureSubresource)(THIS_
1245 ITexture* pTexture,
1246 Uint32 MipLevel,
1247 Uint32 ArraySlice) PURE;
11811248
11821249
11831250 /// Generates a mipmap chain.
11851252 /// \param [in] pTextureView - Texture view to generate mip maps for.
11861253 /// \remarks This function can only be called for a shader resource view.
11871254 /// The texture must be created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag.
1188 virtual void GenerateMips(ITextureView* pTextureView) = 0;
1255 VIRTUAL void METHOD(GenerateMips)(THIS_
1256 ITextureView* pTextureView) PURE;
11891257
11901258
11911259 /// Finishes the current frame and releases dynamic resources allocated by the context.
12001268 /// For deferred contexts, this method must be called after all command lists referencing dynamic resources
12011269 /// have been executed through immediate context.\n
12021270 /// The method does not Flush() the context.
1203 virtual void FinishFrame() = 0;
1271 VIRTUAL void METHOD(FinishFrame)(THIS) PURE;
12041272
12051273
12061274 /// Transitions resource states.
12321300 ///
12331301 /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
12341302 /// of resource state management in Diligent Engine.
1235 virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) = 0;
1303 VIRTUAL void METHOD(TransitionResourceStates)(THIS_
1304 Uint32 BarrierCount,
1305 StateTransitionDesc* pResourceBarriers) PURE;
12361306
12371307
12381308 /// Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource.
12401310 /// \param [in] pSrcTexture - Source multi-sampled texture.
12411311 /// \param [in] pDstTexture - Destination non-multi-sampled texture.
12421312 /// \param [in] ResolveAttribs - Resolve command attributes, see Diligent::ResolveTextureSubresourceAttribs for details.
1243 virtual void ResolveTextureSubresource(ITexture* pSrcTexture,
1244 ITexture* pDstTexture,
1245 const ResolveTextureSubresourceAttribs& ResolveAttribs) = 0;
1246 };
1247
1248 #else
1313 VIRTUAL void METHOD(ResolveTextureSubresource)(THIS_
1314 ITexture* pSrcTexture,
1315 ITexture* pDstTexture,
1316 const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE;
1317 };
1318
1319 #if DILIGENT_C_INTERFACE
1320
1321 # undef THIS
1322 # undef THIS_
12491323
12501324 // clang-format on
1251
1252 struct IDeviceContext;
1253
1254 struct IDeviceContextMethods
1255 {
1256 void (*SetPipelineState)(struct IDeviceContext*, class IPipelineState* pPipelineState);
1257 void (*TransitionShaderResources)(struct IDeviceContext*, class IPipelineState* pPipelineState, class IShaderResourceBinding* pShaderResourceBinding);
1258 void (*CommitShaderResources)(struct IDeviceContext*, class IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1259 void (*SetStencilRef)(struct IDeviceContext*, Uint32 StencilRef);
1260 void (*SetBlendFactors)(struct IDeviceContext*, const float* pBlendFactors);
1261 void (*SetVertexBuffers)(struct IDeviceContext*,
1262 Uint32 StartSlot,
1263 Uint32 NumBuffersSet,
1264 class IBuffer** ppBuffers,
1265 Uint32* pOffsets,
1266 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
1267 SET_VERTEX_BUFFERS_FLAGS Flags);
1268 void (*InvalidateState)(struct IDeviceContext*);
1269 void (*SetIndexBuffer)(struct IDeviceContext*,
1270 class IBuffer* pIndexBuffer,
1271 Uint32 ByteOffset,
1272 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1273 void (*SetViewports)(struct IDeviceContext*,
1274 Uint32 NumViewports,
1275 const struct Viewport* pViewports,
1276 Uint32 RTWidth,
1277 Uint32 RTHeight);
1278 void (*SetScissorRects)(struct IDeviceContext*,
1279 Uint32 NumRects,
1280 const struct Rect* pRects,
1281 Uint32 RTWidth,
1282 Uint32 RTHeight);
1283 void (*SetRenderTargets)(struct IDeviceContext*,
1284 Uint32 NumRenderTargets,
1285 class ITextureView* ppRenderTargets[],
1286 class ITextureView* pDepthStencil,
1287 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1288 void (*Draw)(struct IDeviceContext*, const struct DrawAttribs* Attribs);
1289 void (*DrawIndexed)(struct IDeviceContext*, const struct DrawIndexedAttribs* Attribs);
1290 void (*DrawIndirect)(struct IDeviceContext*, const struct DrawIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1291 void (*DrawIndexedIndirect)(struct IDeviceContext*, const struct DrawIndexedIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1292 void (*DispatchCompute)(struct IDeviceContext*, const struct DispatchComputeAttribs* Attribs);
1293 void (*DispatchComputeIndirect)(struct IDeviceContext*, const struct DispatchComputeIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1294 void (*ClearDepthStencil)(struct IDeviceContext*,
1295 class ITextureView* pView,
1296 CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
1297 float fDepth,
1298 Uint8 Stencil,
1299 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1300 void (*ClearRenderTarget)(struct IDeviceContext*, class ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1301 void (*FinishCommandList)(struct IDeviceContext*, class ICommandList** ppCommandList);
1302 void (*ExecuteCommandList)(struct IDeviceContext*, class ICommandList* pCommandList);
1303 void (*SignalFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value);
1304 void (*WaitForFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value, bool FlushContext);
1305 void (*WaitForIdle)(struct IDeviceContext*);
1306 void (*BeginQuery)(struct IDeviceContext*, class IQuery* pQuery);
1307 void (*EndQuery)(struct IDeviceContext*, class IQuery* pQuery);
1308 void (*Flush)(struct IDeviceContext*);
1309 void (*UpdateBuffer)(struct IDeviceContext*,
1310 class IBuffer* pBuffer,
1311 Uint32 Offset,
1312 Uint32 Size,
1313 const void* pData,
1314 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1315 void (*CopyBuffer)(struct IDeviceContext*,
1316 class IBuffer* pSrcBuffer,
1317 Uint32 SrcOffset,
1318 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1319 class IBuffer* pDstBuffer,
1320 Uint32 DstOffset,
1321 Uint32 Size,
1322 RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode);
1323 void (*MapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid* pMappedData);
1324 void (*UnmapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType);
1325 void (*UpdateTexture)(struct IDeviceContext*,
1326 class ITexture* pTexture,
1327 Uint32 MipLevel,
1328 Uint32 Slice,
1329 const struct Box* DstBox,
1330 const struct TextureSubResData* SubresData,
1331 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1332 RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode);
1333 void (*CopyTexture)(struct IDeviceContext*, const struct CopyTextureAttribs* CopyAttribs);
1334 void (*MapTextureSubresource)(struct IDeviceContext*,
1335 class ITexture* pTexture,
1336 Uint32 MipLevel,
1337 Uint32 ArraySlice,
1338 MAP_TYPE MapType,
1339 MAP_FLAGS MapFlags,
1340 const struct Box* pMapRegion,
1341 struct MappedTextureSubresource* MappedData);
1342 void (*UnmapTextureSubresource)(struct IDeviceContext*, class ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice);
1343 void (*GenerateMips)(struct IDeviceContext*, class ITextureView* pTextureView);
1344 void (*FinishFrame)(struct IDeviceContext*);
1345 void (*TransitionResourceStates)(struct IDeviceContext*, Uint32 BarrierCount, struct StateTransitionDesc* pResourceBarriers);
1346 void (*ResolveTextureSubresource)(struct IDeviceContext*,
1347 class ITexture* pSrcTexture,
1348 class ITexture* pDstTexture,
1349 const struct ResolveTextureSubresourceAttribs* ResolveAttribs);
1350 };
13511325
13521326 struct IDeviceContextVtbl
13531327 {
13551329 struct IDeviceContextMethods DeviceContext;
13561330 };
13571331
1358 struct IDeviceContext
1332 typedef struct IDeviceContext
13591333 {
13601334 struct IDeviceContextVtbl* pVtbl;
1361 };
1335 } IDeviceContext;
13621336
13631337 // clang-format off
13641338
1365 # define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((struct IDeviceContext*)(This), __VA_ARGS__)
1366 # define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__)
1367 # define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__)
1368 # define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((struct IDeviceContext*)(This), __VA_ARGS__)
1369 # define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((struct IDeviceContext*)(This), __VA_ARGS__)
1370 # define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((struct IDeviceContext*)(This), __VA_ARGS__)
1371 # define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((struct IDeviceContext*)(This))
1372 # define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((struct IDeviceContext*)(This), __VA_ARGS__)
1373 # define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((struct IDeviceContext*)(This), __VA_ARGS__)
1374 # define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((struct IDeviceContext*)(This), __VA_ARGS__)
1375 # define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((struct IDeviceContext*)(This), __VA_ARGS__)
1376 # define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((struct IDeviceContext*)(This), __VA_ARGS__)
1377 # define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((struct IDeviceContext*)(This), __VA_ARGS__)
1378 # define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((struct IDeviceContext*)(This), __VA_ARGS__)
1379 # define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((struct IDeviceContext*)(This), __VA_ARGS__)
1380 # define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((struct IDeviceContext*)(This), __VA_ARGS__)
1381 # define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((struct IDeviceContext*)(This), __VA_ARGS__)
1382 # define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((struct IDeviceContext*)(This), __VA_ARGS__)
1383 # define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((struct IDeviceContext*)(This), __VA_ARGS__)
1384 # define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((struct IDeviceContext*)(This), __VA_ARGS__)
1385 # define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((struct IDeviceContext*)(This), __VA_ARGS__)
1386 # define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((struct IDeviceContext*)(This), __VA_ARGS__)
1387 # define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((struct IDeviceContext*)(This), __VA_ARGS__)
1388 # define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((struct IDeviceContext*)(This), __VA_ARGS__)
1389 # define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((struct IDeviceContext*)(This), __VA_ARGS__)
1390 # define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((struct IDeviceContext*)(This), __VA_ARGS__)
1391 # define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((struct IDeviceContext*)(This), __VA_ARGS__)
1392 # define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((struct IDeviceContext*)(This), __VA_ARGS__)
1393 # define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((struct IDeviceContext*)(This), __VA_ARGS__)
1394 # define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__)
1395 # define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__)
1396 # define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((struct IDeviceContext*)(This), __VA_ARGS__)
1397 # define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((struct IDeviceContext*)(This), __VA_ARGS__)
1398 # define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__)
1399 # define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__)
1400 # define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((struct IDeviceContext*)(This), __VA_ARGS__)
1401 # define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((struct IDeviceContext*)(This))
1402 # define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((struct IDeviceContext*)(This), __VA_ARGS__)
1403 # define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__)
1339 # define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((IDeviceContext*)(This), __VA_ARGS__)
1340 # define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((IDeviceContext*)(This), __VA_ARGS__)
1341 # define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((IDeviceContext*)(This), __VA_ARGS__)
1342 # define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((IDeviceContext*)(This), __VA_ARGS__)
1343 # define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((IDeviceContext*)(This), __VA_ARGS__)
1344 # define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((IDeviceContext*)(This), __VA_ARGS__)
1345 # define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((IDeviceContext*)(This))
1346 # define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((IDeviceContext*)(This), __VA_ARGS__)
1347 # define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((IDeviceContext*)(This), __VA_ARGS__)
1348 # define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((IDeviceContext*)(This), __VA_ARGS__)
1349 # define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((IDeviceContext*)(This), __VA_ARGS__)
1350 # define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((IDeviceContext*)(This), __VA_ARGS__)
1351 # define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((IDeviceContext*)(This), __VA_ARGS__)
1352 # define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((IDeviceContext*)(This), __VA_ARGS__)
1353 # define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((IDeviceContext*)(This), __VA_ARGS__)
1354 # define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((IDeviceContext*)(This), __VA_ARGS__)
1355 # define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((IDeviceContext*)(This), __VA_ARGS__)
1356 # define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((IDeviceContext*)(This), __VA_ARGS__)
1357 # define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((IDeviceContext*)(This), __VA_ARGS__)
1358 # define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((IDeviceContext*)(This), __VA_ARGS__)
1359 # define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((IDeviceContext*)(This), __VA_ARGS__)
1360 # define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((IDeviceContext*)(This), __VA_ARGS__)
1361 # define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((IDeviceContext*)(This), __VA_ARGS__)
1362 # define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((IDeviceContext*)(This), __VA_ARGS__)
1363 # define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((IDeviceContext*)(This), __VA_ARGS__)
1364 # define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((IDeviceContext*)(This), __VA_ARGS__)
1365 # define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((IDeviceContext*)(This), __VA_ARGS__)
1366 # define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((IDeviceContext*)(This), __VA_ARGS__)
1367 # define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((IDeviceContext*)(This), __VA_ARGS__)
1368 # define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((IDeviceContext*)(This), __VA_ARGS__)
1369 # define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((IDeviceContext*)(This), __VA_ARGS__)
1370 # define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((IDeviceContext*)(This), __VA_ARGS__)
1371 # define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((IDeviceContext*)(This), __VA_ARGS__)
1372 # define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__)
1373 # define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__)
1374 # define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((IDeviceContext*)(This), __VA_ARGS__)
1375 # define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((IDeviceContext*)(This))
1376 # define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((IDeviceContext*)(This), __VA_ARGS__)
1377 # define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__)
14041378
14051379 // clang-format on
14061380
3636
3737
3838 // {5B4CCA0B-5075-4230-9759-F48769EE5502}
39 static const struct INTERFACE_ID IID_DeviceObject =
39 static const INTERFACE_ID IID_DeviceObject =
4040 {0x5b4cca0b, 0x5075, 0x4230, {0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2}};
4141
42 #if DILIGENT_CPP_INTERFACE
42 #if DILIGENT_C_INTERFACE
43 # define THIS struct IDeviceObject*
44 # define THIS_ struct IDeviceObject*,
45 #endif
4346
4447 /// Base interface for all objects created by the render device Diligent::IRenderDevice
45 class IDeviceObject : public IObject
48 DILIGENT_INTERFACE(IDeviceObject, IObject)
4649 {
47 public:
4850 /// Returns the object description
49 virtual const DeviceObjectAttribs& GetDesc() const = 0;
51 VIRTUAL const DeviceObjectAttribs REF METHOD(GetDesc)(THIS) CONST PURE;
5052
5153
5254 /// Returns unique identifier assigned to an object
6567 ///
6668 /// Valid identifiers are always positive values. Zero and negative values can never be
6769 /// assigned to an object and are always guaranteed to be invalid.
68 virtual Int32 GetUniqueID() const = 0;
70 VIRTUAL Int32 METHOD(GetUniqueID)(THIS) CONST PURE;
6971 };
7072
71 #else
73 #if DILIGENT_C_INTERFACE
7274
73 struct IDeviceObject;
75 # undef THIS
76 # undef THIS_
7477
7578 // clang-format off
76
77 struct IDeviceObjectMethods
78 {
79 const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*);
80 Int32 (*GetUniqueID)(struct IDeviceObject*);
81 };
82
83 // clang-format on
8479
8580 struct IDeviceObjectVtbl
8681 {
8883 struct IDeviceObjectMethods DeviceObject;
8984 };
9085
91 struct IDeviceObject
86 typedef struct IDeviceObject
9287 {
9388 struct IDeviceObjectVtbl* pVtbl;
94 };
89 }IDeviceObject;
9590
9691 // clang-format off
9792
98 # define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((struct IDeviceObject*)(This))
99 # define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((struct IDeviceObject*)(This))
93 # define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((IDeviceObject*)(This))
94 # define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((IDeviceObject*)(This))
10095
10196 // clang-format on
10297
3434
3535 DILIGENT_BEGIN_NAMESPACE(Diligent)
3636
37 class IShaderSourceInputStreamFactory;
37 struct IShaderSourceInputStreamFactory;
3838
3939 // {D932B052-4ED6-4729-A532-F31DEEC100F3}
40 static const struct INTERFACE_ID IID_EngineFactory =
40 static const INTERFACE_ID IID_EngineFactory =
4141 {0xd932b052, 0x4ed6, 0x4729, {0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3}};
4242
43 #if DILIGENT_CPP_INTERFACE
43 #if DILIGENT_C_INTERFACE
44 # define THIS struct IEngineFactory*
45 # define THIS_ struct IEngineFactory*,
46 #endif
47
48 // clang-format off
4449
4550 /// Engine factory base interface
46 class IEngineFactory : public IObject
51 DILIGENT_INTERFACE(IEngineFactory, IObject)
4752 {
48 public:
4953 /// Returns API info structure
50 virtual const APIInfo& GetAPIInfo() const = 0;
54 VIRTUAL const APIInfo REF METHOD(GetAPIInfo)(THIS) CONST PURE;
5155
5256 /// Creates default shader source input stream factory
5357 /// \param [in] SearchDirectories - Semicolon-seprated list of search directories.
5458 /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written.
55 virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
56 IShaderSourceInputStreamFactory** ppShaderSourceFactory) const = 0;
59 VIRTUAL void METHOD(CreateDefaultShaderSourceStreamFactory)(
60 THIS_
61 const Char* SearchDirectories,
62 struct IShaderSourceInputStreamFactory** ppShaderSourceFactory) CONST PURE;
5763
58 # if PLATFORM_ANDROID
64 #if PLATFORM_ANDROID
5965 /// On Android platform, it is necessary to initialize the file system before
6066 /// CreateDefaultShaderSourceStreamFactory() method can be called.
6167 /// \param [in] Activity - Pointer to the activity.
6268 /// \param [in] ActivityClassName - Activity class name.
63 virtual void InitAndroidFileSystem(void* Activity, const char* ActivityClassName) const = 0;
64 # endif
69 VIRTUAL void METHOD(InitAndroidFileSystem)(THIS_
70 void* Activity,
71 const char* ActivityClassName) CONST PURE;
72 #endif
6573 };
6674
67 #else
75 #if DILIGENT_C_INTERFACE
6876
69 struct IEngineFactory;
70 struct IShaderSourceInputStreamFactory;
71
72 // clang-format off
73
74 struct IEngineFactoryMethods
75 {
76 const struct APIInfo* (*GetAPIInfo) (struct IEngineFactory*);
77 void (*CreateDefaultShaderSourceStreamFactory)(struct IEngineFactory*,
78 const Char* SearchDirectories,
79 struct IShaderSourceInputStreamFactory** ppShaderSourceFactory);
80
81 # if PLATFORM_ANDROID
82 void (*InitAndroidFileSystem) (struct IEngineFactory*, void* Activity, const char* ActivityClassName);
83 # endif
84 };
77 # undef THIS
78 # undef THIS_
8579
8680 // clang-format on
8781
9185 struct IEngineFactoryMethods EngineFactory;
9286 };
9387
94 struct IEngineFactory
88 typedef struct IEngineFactory
9589 {
9690 struct IEngineFactoryVtbl* pVtbl;
97 };
91 } IEngineFactory;
9892
9993 // clang-format off
10094
101 # define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((struct IEngineFactory*)(This))
102 # define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((struct IEngineFactory*)(This), __VA_ARGS__)
103 # define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((struct IEngineFactory*)(This), __VA_ARGS__)
95 # define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((IEngineFactory*)(This))
96 # define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((IEngineFactory*)(This), __VA_ARGS__)
97 # define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((IEngineFactory*)(This), __VA_ARGS__)
10498
10599 // clang-format on
106100
3434 DILIGENT_BEGIN_NAMESPACE(Diligent)
3535
3636 // {3B19184D-32AB-4701-84F4-9A0C03AE1672}
37 static const struct INTERFACE_ID IID_Fence =
37 static const INTERFACE_ID IID_Fence =
3838 {0x3b19184d, 0x32ab, 0x4701, {0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72}};
3939
4040 // clang-format off
4141 /// Fence description
4242 struct FenceDesc DILIGENT_DERIVE(DeviceObjectAttribs)
4343 };
44 // clang-format on
44 typedef struct FenceDesc FenceDesc;
4545
46 // clang-format off
4647
47 #if DILIGENT_CPP_INTERFACE
48 #if DILIGENT_C_INTERFACE
49 # define THIS struct IFence*
50 # define THIS_ struct IFence*,
51 #endif
4852
4953 /// Fence interface
5054
5256 ///
5357 /// \remarks When a fence that was previously signaled by IDeviceContext::SignalFence() is destroyed,
5458 /// it may block the GPU until all prior commands have completed execution.
55 class IFence : public IDeviceObject
59 DILIGENT_INTERFACE(IFence, IDeviceObject)
5660 {
57 public:
61 #if DILIGENT_CPP_INTERFACE
5862 /// Returns the fence description used to create the object
5963 virtual const FenceDesc& GetDesc() const override = 0;
64 #endif
6065
6166 /// Returns the last completed value signaled by the GPU
6267
6368 /// \remarks This method is not thread safe (even if the fence object is protected by mutex)
6469 /// and must only be called by the same thread that signals the fence via
6570 /// IDeviceContext::SignalFence().
66 virtual Uint64 GetCompletedValue() = 0;
71 VIRTUAL Uint64 METHOD(GetCompletedValue)(THIS) PURE;
6772
6873 /// Resets the fence to the specified value.
69 virtual void Reset(Uint64 Value) = 0;
74 VIRTUAL void METHOD(Reset)(THIS_
75 Uint64 Value) PURE;
7076 };
7177
72 #else
7378
74 struct IFence;
79 #if DILIGENT_C_INTERFACE
7580
76 // clang-format off
77
78 struct IFenceMethods
79 {
80 Uint64 (*GetCompletedValue)(struct IFence*);
81 void (*Reset) (struct IFence*, Uint64 Value);
82 };
81 # undef THIS
82 # undef THIS_
8383
8484 // clang-format on
8585
9090 struct IFenceMethods Fence;
9191 };
9292
93 struct IFence
93 typedef struct IFence
9494 {
9595 struct IFenceVtbl* pVtbl;
96 };
96 } IFence;
9797
9898 // clang-format off
9999
100100 # define IFence_GetDesc(This) (const struct FenceDesc*)IDeviceObject_GetDesc(This)
101101
102 # define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((struct IFence*)(This))
103 # define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((struct IFence*)(This), __VA_ARGS__)
102 # define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((IFence*)(This))
103 # define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((IFence*)(This), __VA_ARGS__)
104104
105105 // clang-format on
106106
3939 /// Graphics engine namespace
4040 DILIGENT_BEGIN_NAMESPACE(Diligent)
4141
42 class ITexture;
43 class IBuffer;
42 struct ITexture;
43 struct IBuffer;
4444
4545 /// Value type
4646
10891089 {}
10901090 #endif
10911091 };
1092 typedef struct DeviceObjectAttribs DeviceObjectAttribs;
10921093
10931094 /// Hardware adapter type
10941095 DILIGENT_TYPED_ENUM(ADAPTER_TYPE, Uint8)
11301131 /// Number of outputs this device has
11311132 Uint32 NumOutputs DEFAULT_INITIALIZER(0);
11321133 };
1134 typedef struct AdapterAttribs AdapterAttribs;
11331135
11341136
11351137 /// Flags indicating how an image is stretched to fit a given monitor's resolution.
11961198 /// The scaling mode.
11971199 enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED);
11981200 };
1201 typedef struct DisplayModeAttribs DisplayModeAttribs;
11991202
12001203 /// Defines allowed swap chain usage flags
12011204 DILIGENT_TYPED_ENUM(SWAP_CHAIN_USAGE_FLAGS, Uint32)
12691272 {}
12701273 #endif
12711274 };
1275 typedef struct SwapChainDesc SwapChainDesc;
12721276
12731277 /// Full screen mode description
12741278 /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh404531(v=vs.85).aspx">DXGI_SWAP_CHAIN_FULLSCREEN_DESC structure on MSDN</a>,
12891293 /// The scaling mode.
12901294 enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED);
12911295 };
1296 typedef struct FullScreenModeDesc FullScreenModeDesc;
12921297
12931298 /// Engine creation attibutes
12941299 struct EngineCreateInfo
12981303
12991304 /// Pointer to the raw memory allocator that will be used for all memory allocation/deallocation
13001305 /// operations in the engine
1301 class IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr);
1306 struct IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr);
13021307
13031308 /// Pointer to the user-specified debug message callback function
13041309 DebugMessageCallbackType DebugMessageCallback DEFAULT_INITIALIZER(nullptr);
13101315 /// starting at position 1.
13111316 Uint32 NumDeferredContexts DEFAULT_INITIALIZER(0);
13121317 };
1318 typedef struct EngineCreateInfo EngineCreateInfo;
13131319
13141320
13151321 /// Attributes of the OpenGL-based engine implementation
13271333 void* pDisplay DEFAULT_INITIALIZER(nullptr);
13281334 #endif
13291335 };
1336 typedef struct EngineGLCreateInfo EngineGLCreateInfo;
13301337
13311338
13321339 /// Debug flags that can be specified when creating Direct3D11-based engine implementation.
13891396 /// \sa CreateDeviceAndContextsD3D11Type, CreateSwapChainD3D11Type, LoadGraphicsEngineD3D11
13901397 D3D11_DEBUG_FLAGS DebugFlags DEFAULT_INITIALIZER(D3D11_DEBUG_FLAG_NONE);
13911398 };
1399 typedef struct EngineD3D11CreateInfo EngineD3D11CreateInfo;
1400
13921401
13931402 /// Attributes specific to D3D12 engine
13941403 struct EngineD3D12CreateInfo DILIGENT_DERIVE(EngineCreateInfo)
14921501 #endif
14931502 ;
14941503 };
1504 typedef struct EngineD3D12CreateInfo EngineD3D12CreateInfo;
1505
14951506
14961507 /// Descriptor pool size
14971508 struct VulkanDescriptorPoolSize
15331544 }
15341545 #endif
15351546 };
1547 typedef struct VulkanDescriptorPoolSize VulkanDescriptorPoolSize;
1548
15361549
15371550 /// Attributes specific to Vulkan engine
15381551 struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
15571570 /// Size of the main descriptor pool that is used to allocate descriptor sets
15581571 /// for static and mutable variables. If allocation from the current pool fails,
15591572 /// the engine creates another one.
1560 struct VulkanDescriptorPoolSize MainDescriptorPoolSize
1573 VulkanDescriptorPoolSize MainDescriptorPoolSize
15611574 #if DILIGENT_CPP_INTERFACE
15621575 //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB
15631576 {8192, 1024, 8192, 8192, 1024, 4096, 4096, 1024, 1024}
15691582 /// The allocator requests pools from global dynamic descriptor pool manager, and then
15701583 /// performs lock-free suballocations from the pool.
15711584
1572 struct VulkanDescriptorPoolSize DynamicDescriptorPoolSize
1585 VulkanDescriptorPoolSize DynamicDescriptorPoolSize
15731586 #if DILIGENT_CPP_INTERFACE
15741587 //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB
15751588 {2048, 256, 2048, 2048, 256, 1024, 1024, 256, 256}
16191632 #endif
16201633 ;
16211634 };
1635 typedef struct EngineVkCreateInfo EngineVkCreateInfo;
16221636
16231637
16241638 /// Attributes of the Metal-based engine implementation
16251639 struct EngineMtlCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
16261640
16271641 };
1642 typedef struct EngineMtlCreateInfo EngineMtlCreateInfo;
16281643
16291644
16301645 /// Box
16611676 Box() noexcept {}
16621677 #endif
16631678 };
1679 typedef struct Box Box;
16641680
16651681
16661682 /// Describes texture format component type
17621778 TextureFormatAttribs()noexcept {}
17631779 #endif
17641780 };
1781 typedef struct TextureFormatAttribs TextureFormatAttribs;
1782
17651783
17661784 /// Basic texture format description
17671785
17711789 /// Indicates if the format is supported by the device
17721790 bool Supported DEFAULT_INITIALIZER(false);
17731791 };
1792 typedef struct TextureFormatInfo TextureFormatInfo;
1793
17741794
17751795 /// Extended texture format description
17761796
18021822 /// If the format supports n samples, then (SampleCounts & n) != 0
18031823 Uint32 SampleCounts DEFAULT_INITIALIZER(0);
18041824 };
1825 typedef struct TextureFormatInfoExt TextureFormatInfoExt;
1826
18051827
18061828 /// Resource usage state
18071829 DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32)
18941916 {
18951917 /// Texture to transition.
18961918 /// \note Exactly one of pTexture or pBuffer must be non-null.
1897 class ITexture* pTexture DEFAULT_INITIALIZER(nullptr);
1919 struct ITexture* pTexture DEFAULT_INITIALIZER(nullptr);
18981920
18991921 /// Buffer to transition.
19001922 /// \note Exactly one of pTexture or pBuffer must be non-null.
1901 class IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr);
1923 struct IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr);
19021924
19031925 /// When transitioning a texture, first mip level of the subresource range to transition.
19041926 Uint32 FirstMipLevel DEFAULT_INITIALIZER(0);
19852007 {}
19862008 #endif
19872009 };
2010 typedef struct StateTransitionDesc StateTransitionDesc;
19882011
19892012 DILIGENT_END_NAMESPACE // namespace Diligent
173173 {}
174174 #endif
175175 };
176 typedef struct LayoutElement LayoutElement;
177
176178
177179 /// Layout description
178180
179181 /// This structure is used by IRenderDevice::CreatePipelineState().
180 struct InputLayoutDesc
182 struct InputLayoutDesc
181183 {
182184 /// Array of layout elements
183 const struct LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr);
185 const LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr);
184186 /// Number of layout elements
185 Uint32 NumElements DEFAULT_INITIALIZER(0);
187 Uint32 NumElements DEFAULT_INITIALIZER(0);
186188
187189 #if DILIGENT_CPP_INTERFACE
188190 InputLayoutDesc()noexcept{}
194196 {}
195197 #endif
196198 };
199 typedef struct InputLayoutDesc InputLayoutDesc;
197200
198201 DILIGENT_END_NAMESPACE
6666 {}
6767 #endif
6868 };
69 typedef struct SampleDesc SampleDesc;
6970
7071
7172 /// Describes shader variable
9091 {}
9192 #endif
9293 };
94 typedef struct ShaderResourceVariableDesc ShaderResourceVariableDesc;
9395
9496
9597 /// Static sampler description
117119 {}
118120 #endif
119121 };
120
122 typedef struct StaticSamplerDesc StaticSamplerDesc;
121123
122124 /// Pipeline layout description
123125 struct PipelineResourceLayoutDesc
125127 /// Default shader resource variable type. This type will be used if shader
126128 /// variable description is not found in the Variables array
127129 /// or if Variables == nullptr
128 SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
130 SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
129131
130132 /// Number of elements in Variables array
131 Uint32 NumVariables DEFAULT_INITIALIZER(0);
133 Uint32 NumVariables DEFAULT_INITIALIZER(0);
132134
133135 /// Array of shader resource variable descriptions
134 const struct ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr);
136 const ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr);
135137
136138 /// Number of static samplers in StaticSamplers array
137 Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0);
139 Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0);
138140
139141 /// Array of static sampler descriptions
140 const struct StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr);
141 };
142 const StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr);
143 };
144 typedef struct PipelineResourceLayoutDesc PipelineResourceLayoutDesc;
142145
143146
144147 /// Graphics pipeline state description
147150 struct GraphicsPipelineDesc
148151 {
149152 /// Vertex shader to be used with the pipeline
150 class IShader* pVS DEFAULT_INITIALIZER(nullptr);
153 IShader* pVS DEFAULT_INITIALIZER(nullptr);
151154
152155 /// Pixel shader to be used with the pipeline
153 class IShader* pPS DEFAULT_INITIALIZER(nullptr);
156 IShader* pPS DEFAULT_INITIALIZER(nullptr);
154157
155158 /// Domain shader to be used with the pipeline
156 class IShader* pDS DEFAULT_INITIALIZER(nullptr);
159 IShader* pDS DEFAULT_INITIALIZER(nullptr);
157160
158161 /// Hull shader to be used with the pipeline
159 class IShader* pHS DEFAULT_INITIALIZER(nullptr);
162 IShader* pHS DEFAULT_INITIALIZER(nullptr);
160163
161164 /// Geometry shader to be used with the pipeline
162 class IShader* pGS DEFAULT_INITIALIZER(nullptr);
165 IShader* pGS DEFAULT_INITIALIZER(nullptr);
163166
164167 //D3D12_STREAM_OUTPUT_DESC StreamOutput;
165168
166169 /// Blend state description
167 struct BlendStateDesc BlendDesc;
170 BlendStateDesc BlendDesc;
168171
169172 /// 32-bit sample mask that determines which samples get updated
170173 /// in all the active render targets. A sample mask is always applied;
173176 Uint32 SampleMask DEFAULT_INITIALIZER(0xFFFFFFFF);
174177
175178 /// Rasterizer state description
176 struct RasterizerStateDesc RasterizerDesc;
179 RasterizerStateDesc RasterizerDesc;
177180
178181 /// Depth-stencil state description
179 struct DepthStencilStateDesc DepthStencilDesc;
182 DepthStencilStateDesc DepthStencilDesc;
180183
181184 /// Input layout
182 struct InputLayoutDesc InputLayout;
185 InputLayoutDesc InputLayout;
183186 //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue;
184187
185188 /// Primitive topology type
198201 TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
199202
200203 /// Multisampling parameters
201 struct SampleDesc SmplDesc;
204 SampleDesc SmplDesc;
202205
203206 /// Node mask.
204207 Uint32 NodeMask DEFAULT_INITIALIZER(0);
206209 //D3D12_CACHED_PIPELINE_STATE CachedPSO;
207210 //D3D12_PIPELINE_STATE_FLAGS Flags;
208211 };
212 typedef struct GraphicsPipelineDesc GraphicsPipelineDesc;
209213
210214
211215 /// Compute pipeline state description
214218 struct ComputePipelineDesc
215219 {
216220 /// Compute shader to be used with the pipeline
217 class IShader* pCS DEFAULT_INITIALIZER(nullptr);
218 };
221 IShader* pCS DEFAULT_INITIALIZER(nullptr);
222 };
223 typedef struct ComputePipelineDesc ComputePipelineDesc;
224
219225
220226 /// Pipeline state description
221227 struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs)
233239 Uint64 CommandQueueMask DEFAULT_INITIALIZER(1);
234240
235241 /// Pipeline layout description
236 struct PipelineResourceLayoutDesc ResourceLayout;
242 PipelineResourceLayoutDesc ResourceLayout;
237243
238244 /// Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True
239 struct GraphicsPipelineDesc GraphicsPipeline;
245 GraphicsPipelineDesc GraphicsPipeline;
240246
241247 /// Compute pipeline state description. This memeber is ignored if IsComputePipeline == False
242 struct ComputePipelineDesc ComputePipeline;
243 };
248 ComputePipelineDesc ComputePipeline;
249 };
250 typedef struct PipelineStateDesc PipelineStateDesc;
244251
245252 // {06084AE5-6A71-4FE8-84B9-395DD489A28C}
246253 static const struct INTERFACE_ID IID_PipelineState =
247254 {0x6084ae5, 0x6a71, 0x4fe8, {0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c}};
248255
256
257 #if DILIGENT_C_INTERFACE
258 # define THIS struct IPipelineState*
259 # define THIS_ struct IPipelineState*,
260 #endif
261
262 // clang-format off
263
264 /// Pipeline state interface
265 DILIGENT_INTERFACE(IPipelineState, IDeviceObject)
266 {
249267 #if DILIGENT_CPP_INTERFACE
250
251 /// Pipeline state interface
252 class IPipelineState : public IDeviceObject
253 {
254 public:
255268 /// Returns the blend state description used to create the object
256269 virtual const PipelineStateDesc& GetDesc()const override = 0;
270 #endif
257271
258272
259273 /// Binds resources for all shaders in the pipeline state
262276 /// Any combination of Diligent::SHADER_TYPE may be used.
263277 /// \param [in] pResourceMapping - Pointer to the resource mapping interface.
264278 /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS.
265 virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) = 0;
279 VIRTUAL void METHOD(BindStaticResources)(THIS_
280 Uint32 ShaderFlags,
281 IResourceMapping* pResourceMapping,
282 Uint32 Flags) PURE;
266283
267284
268285 /// Returns the number of static shader resource variables.
270287 /// \param [in] ShaderType - Type of the shader.
271288 /// \remark Only static variables (that can be accessed directly through the PSO) are counted.
272289 /// Mutable and dynamic variables are accessed through Shader Resource Binding object.
273 virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const = 0;
290 VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_
291 SHADER_TYPE ShaderType) CONST PURE;
274292
275293
276294 /// Returns static shader resource variable. If the variable is not found,
281299 /// \param [in] Name - Name of the variable.
282300 /// \remark The method does not increment the reference counter
283301 /// of the returned interface.
284 virtual IShaderResourceVariable* GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) = 0;
302 VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByName)(THIS_
303 SHADER_TYPE ShaderType,
304 const Char* Name) PURE;
285305
286306
287307 /// Returns static shader resource variable by its index.
294314 /// \remark Only static shader resource variables can be accessed through this method.
295315 /// Mutable and dynamic variables are accessed through Shader Resource
296316 /// Binding object
297 virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0;
317 VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByIndex)(THIS_
318 SHADER_TYPE ShaderType,
319 Uint32 Index) PURE;
298320
299321
300322 /// Creates a shader resource binding object
304326 /// \param [in] InitStaticResources - if set to true, the method will initialize static resources in
305327 /// the created object, which has the exact same effect as calling
306328 /// IShaderResourceBinding::InitializeStaticResources().
307 virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources = false) = 0;
329 VIRTUAL void METHOD(CreateShaderResourceBinding)(THIS_
330 IShaderResourceBinding** ppShaderResourceBinding,
331 bool InitStaticResources DEFAULT_VALUE(false)) PURE;
308332
309333
310334 /// Checks if this pipeline state object is compatible with another PSO
321345 /// to commit resources for the second pipeline, a runtime error will occur.\n
322346 /// The function only checks compatibility of shader resource layouts. It does not take
323347 /// into account vertex shader input layout, number of outputs, etc.
324 virtual bool IsCompatibleWith(const IPipelineState* pPSO)const = 0;
325 };
326
327 #else
328
329 struct IPipelineState;
330
331 struct IPipelineStateMethods
332 {
333 void (*BindStaticResources) (struct IPipelineState*, Uint32 ShaderFlags, class IResourceMapping* pResourceMapping, Uint32 Flags);
334 Uint32 (*GetStaticVariableCount) (struct IPipelineState*, SHADER_TYPE ShaderType);
335 class IShaderResourceVariable* (*GetStaticVariableByName) (struct IPipelineState*, SHADER_TYPE ShaderType, const Char* Name);
336 class IShaderResourceVariable* (*GetStaticVariableByIndex) (struct IPipelineState*, SHADER_TYPE ShaderType, Uint32 Index);
337 void (*CreateShaderResourceBinding)(struct IPipelineState*, class IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources);
338 bool (*IsCompatibleWith) (struct IPipelineState*, const class IPipelineState* pPSO);
339 };
348 VIRTUAL bool METHOD(IsCompatibleWith)(THIS_
349 const struct IPipelineState* pPSO) CONST PURE;
350 };
351
352 #if DILIGENT_C_INTERFACE
353
354 # undef THIS
355 # undef THIS_
340356
341357 // clang-format on
342358
347363 struct IPipelineStateMethods PipelineState;
348364 };
349365
350 struct IPipelineState
366 typedef struct IPipelineState
351367 {
352368 struct IPipelineStateVtbl* pVtbl;
353 };
369 } IPipelineState;
354370
355371 // clang-format off
356372
357373 # define IPipelineState_GetDesc(This) (const struct PipelineStateDesc*)IDeviceObject_GetDesc(This)
358374
359 # define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((struct IPipelineState*)(This), __VA_ARGS__)
360 # define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((struct IPipelineState*)(This), __VA_ARGS__)
361 # define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((struct IPipelineState*)(This), __VA_ARGS__)
362 # define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((struct IPipelineState*)(This), __VA_ARGS__)
363 # define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((struct IPipelineState*)(This), __VA_ARGS__)
364 # define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((struct IPipelineState*)(This), __VA_ARGS__)
375 # define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((IPipelineState*)(This), __VA_ARGS__)
376 # define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((IPipelineState*)(This), __VA_ARGS__)
377 # define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((IPipelineState*)(This), __VA_ARGS__)
378 # define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((IPipelineState*)(This), __VA_ARGS__)
379 # define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((IPipelineState*)(This), __VA_ARGS__)
380 # define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((IPipelineState*)(This), __VA_ARGS__)
365381
366382 // clang-format on
367383
3535
3636
3737 // {70F2A88A-F8BE-4901-8F05-2F72FA695BA0}
38 static const struct INTERFACE_ID IID_Query =
38 static const INTERFACE_ID IID_Query =
3939 {0x70f2a88a, 0xf8be, 0x4901, {0x8f, 0x5, 0x2f, 0x72, 0xfa, 0x69, 0x5b, 0xa0}};
4040
4141 /// Query type.
7676 /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery.
7777 Uint64 NumSamples DEFAULT_INITIALIZER(0);
7878 };
79 typedef struct QueryDataOcclusion QueryDataOcclusion;
7980
8081 /// Binary occlusion query data.
8182 /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_BINARY_OCCLUSION query type.
8889 /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery.
8990 bool AnySamplePassed DEFAULT_INITIALIZER(0);
9091 };
92 typedef struct QueryDataBinaryOcclusion QueryDataBinaryOcclusion;
9193
9294 /// Timestamp query data.
9395 /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_TIMESTAMP query type.
103105 /// while getting the timestamp, this value will be 0.
104106 Uint64 Frequency DEFAULT_INITIALIZER(0);
105107 };
108 typedef struct QueryDataTimestamp QueryDataTimestamp;
106109
107110 /// Pipeline statistics query data.
108111 /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_PIPELINE_STATISTICS query type.
148151 /// Number of times a compute shader was invoked.
149152 Uint64 CSInvocations DEFAULT_INITIALIZER(0);
150153 };
151
154 typedef struct QueryDataPipelineStatistics QueryDataPipelineStatistics;
152155
153156 // clang-format off
154157
166169 {}
167170 #endif
168171 };
169
170 // clang-format on
171
172 typedef struct QueryDesc QueryDesc;
173
174 #if DILIGENT_C_INTERFACE
175 # define THIS struct IQuery*
176 # define THIS_ struct IQuery*,
177 #endif
178
179 // clang-format off
180
181 /// Query interface.
182
183 /// Defines the methods to manipulate a Query object
184 DILIGENT_INTERFACE(IQuery, IDeviceObject)
185 {
172186 #if DILIGENT_CPP_INTERFACE
173
174 /// Query interface.
175
176 /// Defines the methods to manipulate a Query object
177 class IQuery : public IDeviceObject
178 {
179 public:
180187 /// Returns the Query description used to create the object.
181188 virtual const QueryDesc& GetDesc() const override = 0;
189 #endif
182190
183191 /// Gets the query data.
184192
200208 ///
201209 /// If AutoInvalidate is set to true, and the data have been retrieved, an application
202210 /// must not call GetData() until it begins and ends the query again.
203 virtual bool GetData(void* pData, Uint32 DataSize, bool AutoInvalidate = true) = 0;
211 VIRTUAL bool METHOD(GetData)(THIS_
212 void* pData,
213 Uint32 DataSize,
214 bool AutoInvalidate DEFAULT_VALUE(true)) PURE;
204215
205216 /// Invalidates the query and releases associated resources.
206 virtual void Invalidate() = 0;
207 };
208
209 #else
210
211 struct IQuery;
212
213 // clang-format off
214
215 struct IQueryMethods
216 {
217 bool (*GetData) (struct IQuery*, void* pData, Uint32 DataSize, bool AutoInvalidate);
218 void (*Invalidate)(struct IQuery*);
219 };
217 VIRTUAL void METHOD(Invalidate)(THIS) PURE;
218 };
219
220 #if DILIGENT_C_INTERFACE
221
222 # undef THIS
223 # undef THIS_
220224
221225 // clang-format on
222226
227231 struct IQueryMethods Query;
228232 };
229233
230 struct IQuery
234 typedef struct IQuery
231235 {
232236 struct IQueryVtbl* pVtbl;
233 };
237 } IQuery;
234238
235239 // clang-format off
236240
237241 # define IQuery_GetDesc(This) (const struct QueryDesc*)IDeviceObject_GetDesc(This)
238242
239 # define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((struct IQuery*)(This), __VA_ARGS__)
240 # define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((struct IQuery*)(This))
243 # define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((IQuery*)(This), __VA_ARGS__)
244 # define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((IQuery*)(This))
241245
242246 // clang-format on
243247
180180 }
181181 #endif
182182 };
183 typedef struct RasterizerStateDesc RasterizerStateDesc;
183184
184185 DILIGENT_END_NAMESPACE
5353 DILIGENT_BEGIN_NAMESPACE(Diligent)
5454
5555 // {F0E9B607-AE33-4B2B-B1AF-A8B2C3104022}
56 static const struct INTERFACE_ID IID_RenderDevice =
56 static const INTERFACE_ID IID_RenderDevice =
5757 {0xf0e9b607, 0xae33, 0x4b2b, {0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22}};
5858
59 #if DILIGENT_CPP_INTERFACE
59 #if DILIGENT_C_INTERFACE
60 # define THIS struct IRenderDevice*
61 # define THIS_ struct IRenderDevice*,
62 #endif
63
64 // clang-format off
6065
6166 /// Render device interface
62 class IRenderDevice : public IObject
67 DILIGENT_INTERFACE(IRenderDevice, IObject)
6368 {
64 public:
6569 /// Creates a new buffer object
6670
6771 /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details.
7781 /// Size of a uniform buffer (BIND_UNIFORM_BUFFER) must be multiple of 16.\n
7882 /// Stride of a formatted buffer will be computed automatically from the format if
7983 /// ElementByteStride member of buffer description is set to default value (0).
80 virtual void CreateBuffer(const BufferDesc& BuffDesc,
81 const BufferData* pBuffData,
82 IBuffer** ppBuffer) = 0;
84 VIRTUAL void METHOD(CreateBuffer)(THIS_
85 const BufferDesc REF BuffDesc,
86 const BufferData* pBuffData,
87 IBuffer** ppBuffer) PURE;
8388
8489 /// Creates a new shader object
8590
8893 /// shader interface will be stored.
8994 /// The function calls AddRef(), so that the new object will contain
9095 /// one reference.
91 virtual void CreateShader(const ShaderCreateInfo& ShaderCI,
92 IShader** ppShader) = 0;
96 VIRTUAL void METHOD(CreateShader)(THIS_
97 const ShaderCreateInfo REF ShaderCI,
98 IShader** ppShader) PURE;
9399
94100 /// Creates a new texture object
95101
113119 /// 15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.\n
114120 /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n
115121 /// 15x6x4, 7x3x2, 3x1x1, 1x1x1
116 virtual void CreateTexture(const TextureDesc& TexDesc,
117 const TextureData* pData,
118 ITexture** ppTexture) = 0;
122 VIRTUAL void METHOD(CreateTexture)(THIS_
123 const TextureDesc REF TexDesc,
124 const TextureData* pData,
125 ITexture** ppTexture) PURE;
119126
120127 /// Creates a new sampler object
121128
127134 /// \remark If an application attempts to create a sampler interface with the same attributes
128135 /// as an existing interface, the same interface will be returned.
129136 /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time.
130 virtual void CreateSampler(const SamplerDesc& SamDesc,
131 ISampler** ppSampler) = 0;
137 VIRTUAL void METHOD(CreateSampler)(THIS_
138 const SamplerDesc REF SamDesc,
139 ISampler** ppSampler) PURE;
132140
133141 /// Creates a new resource mapping
134142
137145 /// resource mapping interface will be stored.
138146 /// The function calls AddRef(), so that the new object will contain
139147 /// one reference.
140 virtual void CreateResourceMapping(const ResourceMappingDesc& MappingDesc,
141 IResourceMapping** ppMapping) = 0;
148 VIRTUAL void METHOD(CreateResourceMapping)(THIS_
149 const ResourceMappingDesc REF MappingDesc,
150 IResourceMapping** ppMapping) PURE;
142151
143152 /// Creates a new pipeline state object
144153
147156 /// pipeline state interface will be stored.
148157 /// The function calls AddRef(), so that the new object will contain
149158 /// one reference.
150 virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc,
151 IPipelineState** ppPipelineState) = 0;
159 VIRTUAL void METHOD(CreatePipelineState)(THIS_
160 const PipelineStateDesc REF PipelineDesc,
161 IPipelineState** ppPipelineState) PURE;
152162
153163
154164 /// Creates a new fence object
158168 /// fence interface will be stored.
159169 /// The function calls AddRef(), so that the new object will contain
160170 /// one reference.
161 virtual void CreateFence(const FenceDesc& Desc,
162 IFence** ppFence) = 0;
171 VIRTUAL void METHOD(CreateFence)(THIS_
172 const FenceDesc REF Desc,
173 IFence** ppFence) PURE;
163174
164175
165176 /// Creates a new query object
169180 /// query interface will be stored.
170181 /// The function calls AddRef(), so that the new object will contain
171182 /// one reference.
172 virtual void CreateQuery(const QueryDesc& Desc,
173 IQuery** ppQuery) = 0;
183 VIRTUAL void METHOD(CreateQuery)(THIS_
184 const QueryDesc REF Desc,
185 IQuery** ppQuery) PURE;
174186
175187
176188 /// Gets the device capabilities, see Diligent::DeviceCaps for details
177 virtual const DeviceCaps& GetDeviceCaps() const = 0;
189 VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE;
178190
179191
180192 /// Returns the basic texture format information.
183195 /// \param [in] TexFormat - Texture format for which to provide the information
184196 /// \return Const reference to the TextureFormatInfo structure containing the
185197 /// texture format description.
186 virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat) = 0;
198 VIRTUAL const TextureFormatInfo REF METHOD(GetTextureFormatInfo)(THIS_
199 TEXTURE_FORMAT TexFormat) PURE;
187200
188201
189202 /// Returns the extended texture format information.
195208 /// \remark The first time this method is called for a particular format, it may be
196209 /// considerably slower than GetTextureFormatInfo(). If you do not require
197210 /// extended information, call GetTextureFormatInfo() instead.
198 virtual const TextureFormatInfoExt& GetTextureFormatInfoExt(TEXTURE_FORMAT TexFormat) = 0;
211 VIRTUAL const TextureFormatInfoExt REF METHOD(GetTextureFormatInfoExt)(THIS_
212 TEXTURE_FORMAT TexFormat) PURE;
199213
200214 /// Purges device release queues and releases all stale resources.
201215 /// This method is automatically called by ISwapChain::Present() of the primary swap chain.
202216 /// \param [in] ForceRelease - Forces release of all objects. Use this option with
203217 /// great care only if you are sure the resources are not
204218 /// in use by the GPU (such as when the device has just been idled).
205 virtual void ReleaseStaleResources(bool ForceRelease = false) = 0;
219 VIRTUAL void METHOD(ReleaseStaleResources)(THIS_
220 bool ForceRelease DEFAULT_VALUE(false)) PURE;
206221
207222
208223 /// Waits until all outstanding operations on the GPU are complete.
213228 /// have been previously submitted for execution. An application should explicitly flush
214229 /// the contexts using IDeviceContext::Flush() if it needs to make sure all recorded commands
215230 /// are complete when the method returns.
216 virtual void IdleGPU() = 0;
231 VIRTUAL void METHOD(IdleGPU)(THIS) PURE;
217232
218233
219234 /// Returns engine factory this device was created from.
220235 /// \remark This method does not increment the reference counter of the returned interface,
221236 /// so the application should not call Release().
222 virtual IEngineFactory* GetEngineFactory() const = 0;
237 VIRTUAL IEngineFactory* METHOD(GetEngineFactory)(THIS) CONST PURE;
223238 };
224239
225 #else
226
227 struct IRenderDevice;
228
229 struct IRenderDeviceMethods
230 {
231 void (*CreateBuffer)(struct IRenderDevice*,
232 const struct BufferDesc* BuffDesc,
233 const struct BufferData* pBuffData,
234 class IBuffer** ppBuffer);
235 void (*CreateShader)(struct IRenderDevice*,
236 const struct ShaderCreateInfo* ShaderCI,
237 class IShader** ppShader);
238 void (*CreateTexture)(struct IRenderDevice*,
239 const struct TextureDesc* TexDesc,
240 const struct TextureData* pData,
241 class ITexture** ppTexture);
242 void (*CreateSampler)(struct IRenderDevice*,
243 const struct SamplerDesc* SamDesc,
244 class ISampler** ppSampler);
245 void (*CreateResourceMapping)(struct IRenderDevice*,
246 const struct ResourceMappingDesc* MappingDesc,
247 class IResourceMapping** ppMapping);
248 void (*CreatePipelineState)(struct IRenderDevice*,
249 const struct PipelineStateDesc* PipelineDesc,
250 class IPipelineState** ppPipelineState);
251 void (*CreateFence)(struct IRenderDevice*,
252 const struct FenceDesc* Desc,
253 class IFence** ppFence);
254 void (*CreateQuery)(struct IRenderDevice*,
255 const struct QueryDesc* Desc,
256 class IQuery** ppQuery);
257 const struct DeviceCaps* (*GetDeviceCaps)(struct IRenderDevice*);
258 const struct TextureFormatInfo* (*GetTextureFormatInfo)(struct IRenderDevice*,
259 TEXTURE_FORMAT TexFormat);
260 const struct TextureFormatInfoExt* (*GetTextureFormatInfoExt)(struct IRenderDevice*,
261 TEXTURE_FORMAT TexFormat);
262 void (*ReleaseStaleResources)(struct IRenderDevice*,
263 bool ForceRelease);
264 void (*IdleGPU)(struct IRenderDevice*);
265 class IEngineFactory* (*GetEngineFactory)(struct IRenderDevice*);
266 };
240
241 #if DILIGENT_C_INTERFACE
242
243 # undef THIS
244 # undef THIS
245
246 // clang-format on
267247
268248 struct IRenderDeviceVtbl
269249 {
271251 struct IRenderDeviceMethods RenderDevice;
272252 };
273253
274 struct IRenderDevice
254 typedef struct IRenderDevice
275255 {
276256 struct IRenderDeviceVtbl* pVtbl;
277 };
257 } IRenderDevice;
278258
279259 // clang-format off
280260
281 # define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((struct IRenderDevice*)(This), __VA_ARGS__)
282 # define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((struct IRenderDevice*)(This), __VA_ARGS__)
283 # define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((struct IRenderDevice*)(This), __VA_ARGS__)
284 # define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((struct IRenderDevice*)(This), __VA_ARGS__)
285 # define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((struct IRenderDevice*)(This), __VA_ARGS__)
286 # define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((struct IRenderDevice*)(This), __VA_ARGS__)
287 # define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((struct IRenderDevice*)(This), __VA_ARGS__)
288 # define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((struct IRenderDevice*)(This), __VA_ARGS__)
289 # define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((struct IRenderDevice*)(This))
290 # define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((struct IRenderDevice*)(This), __VA_ARGS__)
291 # define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((struct IRenderDevice*)(This), __VA_ARGS__)
292 # define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((struct IRenderDevice*)(This), __VA_ARGS__)
293 # define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((struct IRenderDevice*)(This))
294 # define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((struct IRenderDevice*)(This))
261 # define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((IRenderDevice*)(This), __VA_ARGS__)
262 # define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((IRenderDevice*)(This), __VA_ARGS__)
263 # define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((IRenderDevice*)(This), __VA_ARGS__)
264 # define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((IRenderDevice*)(This), __VA_ARGS__)
265 # define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((IRenderDevice*)(This), __VA_ARGS__)
266 # define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((IRenderDevice*)(This), __VA_ARGS__)
267 # define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((IRenderDevice*)(This), __VA_ARGS__)
268 # define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((IRenderDevice*)(This), __VA_ARGS__)
269 # define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((IRenderDevice*)(This))
270 # define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((IRenderDevice*)(This), __VA_ARGS__)
271 # define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((IRenderDevice*)(This), __VA_ARGS__)
272 # define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((IRenderDevice*)(This), __VA_ARGS__)
273 # define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((IRenderDevice*)(This))
274 # define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((IRenderDevice*)(This))
295275
296276 // clang-format on
297277
3434 DILIGENT_BEGIN_NAMESPACE(Diligent)
3535
3636 // {6C1AC7A6-B429-4139-9433-9E54E93E384A}
37 static const struct INTERFACE_ID IID_ResourceMapping =
37 static const INTERFACE_ID IID_ResourceMapping =
3838 {0x6c1ac7a6, 0xb429, 0x4139, {0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a}};
3939
4040 /// Describes the resourse mapping object entry
4343 // clang-format off
4444
4545 /// Object name
46 const Char* Name DEFAULT_INITIALIZER(nullptr);
46 const Char* Name DEFAULT_INITIALIZER(nullptr);
4747
4848 /// Pointer to the object's interface
49 class IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr);
50
51 Uint32 ArrayIndex DEFAULT_INITIALIZER(0);
49 IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr);
50
51 Uint32 ArrayIndex DEFAULT_INITIALIZER(0);
5252
5353
5454 #if DILIGENT_CPP_INTERFACE
6767 // clang-format on
6868 #endif
6969 };
70 typedef struct ResourceMappingEntry ResourceMappingEntry;
71
7072
7173 /// Resource mapping description
7274 struct ResourceMappingDesc
7476 /// Pointer to the array of resource mapping entries.
7577 /// The last element in the array must be default value
7678 /// created by ResourceMappingEntry::ResourceMappingEntry()
77 struct ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr);
79 ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr);
7880
7981 #if DILIGENT_CPP_INTERFACE
8082 ResourceMappingDesc() noexcept
8587 {}
8688 #endif
8789 };
88
89
90 #if DILIGENT_CPP_INTERFACE
90 typedef struct ResourceMappingDesc ResourceMappingDesc;
91
92
93 #if DILIGENT_C_INTERFACE
94 # define THIS struct IResourceMapping*
95 # define THIS_ struct IResourceMapping*,
96 #endif
97
98 // clang-format off
9199
92100 /// Resouce mapping
93101
94102 /// This interface provides mapping between literal names and resource pointers.
95103 /// It is created by IRenderDevice::CreateResourceMapping().
96104 /// \remarks Resource mapping holds strong references to all objects it keeps.
97 class IResourceMapping : public IObject
98 {
99 public:
105 DILIGENT_INTERFACE(IResourceMapping, IObject)
106 {
100107 /// Adds a resource to the mapping.
101108
102109 /// \param [in] Name - Resource name.
107114 ///
108115 /// \remarks Resource mapping increases the reference counter for referenced objects. So an
109116 /// object will not be released as long as it is in the resource mapping.
110 virtual void AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique) = 0;
117 VIRTUAL void METHOD(AddResource)(THIS_
118 const Char* Name,
119 IDeviceObject* pObject,
120 bool bIsUnique) PURE;
111121
112122
113123 /// Adds resource array to the mapping.
122132 ///
123133 /// \remarks Resource mapping increases the reference counter for referenced objects. So an
124134 /// object will not be released as long as it is in the resource mapping.
125 virtual void AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) = 0;
135 VIRTUAL void METHOD(AddResourceArray)(THIS_
136 const Char* Name,
137 Uint32 StartIndex,
138 IDeviceObject* const* ppObjects,
139 Uint32 NumElements,
140 bool bIsUnique) PURE;
126141
127142
128143 /// Removes a resource from the mapping using its literal name.
129144
130145 /// \param [in] Name - Name of the resource to remove.
131146 /// \param [in] ArrayIndex - For array resources, index in the array
132 virtual void RemoveResourceByName(const Char* Name, Uint32 ArrayIndex = 0) = 0;
147 VIRTUAL void METHOD(RemoveResourceByName)(THIS_
148 const Char* Name,
149 Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE;
133150
134151 /// Finds a resource in the mapping.
135152
140157 /// If no object is found, nullptr will be written.
141158 /// \remarks The method increases the reference counter
142159 /// of the returned object, so Release() must be called.
143 virtual void GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex = 0) = 0;
160 VIRTUAL void METHOD(GetResource)(THIS_
161 const Char* Name,
162 IDeviceObject** ppResource,
163 Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE;
144164
145165 /// Returns the size of the resource mapping, i.e. the number of objects.
146 virtual size_t GetSize() = 0;
147 };
148
149 #else
150
151 struct IResourceMapping;
152
153 // clang-format off
154
155 struct IResourceMappingMethods
156 {
157 void (*AddResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject* pObject, bool bIsUnique);
158 void (*AddResourceArray) (struct IResourceMapping*, const Char* Name, Uint32 StartIndex, class IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique);
159 void (*RemoveResourceByName)(struct IResourceMapping*, const Char* Name, Uint32 ArrayIndex);
160 void (*GetResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject** ppResource, Uint32 ArrayIndex);
161 size_t (*GetSize) (struct IResourceMapping*);
162 };
166 VIRTUAL size_t METHOD(GetSize)(THIS) PURE;
167 };
168
169 #if DILIGENT_C_INTERFACE
170
171 # undef THIS
172 # undef THIS_
163173
164174 // clang-format on
165175
169179 struct IResourceMappingMethods ResourceMapping;
170180 };
171181
172 struct IResourceMapping
182 typedef struct IResourceMapping
173183 {
174184 struct IResourceMappingVtbl* pVtbl;
175 };
185 } IResourceMapping;
176186
177187 // clang-format off
178188
179 # define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((struct IResourceMapping*)(This), __VA_ARGS__)
180 # define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((struct IResourceMapping*)(This), __VA_ARGS__)
181 # define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((struct IResourceMapping*)(This), __VA_ARGS__)
182 # define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((struct IResourceMapping*)(This), __VA_ARGS__)
183 # define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((struct IResourceMapping*)(This))
189 # define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((IResourceMapping*)(This), __VA_ARGS__)
190 # define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((IResourceMapping*)(This), __VA_ARGS__)
191 # define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((IResourceMapping*)(This), __VA_ARGS__)
192 # define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((IResourceMapping*)(This), __VA_ARGS__)
193 # define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((IResourceMapping*)(This))
184194
185195 // clang-format on
186196
3535
3636
3737 // {595A59BF-FA81-4855-BC5E-C0E048745A95}
38 static const struct INTERFACE_ID IID_Sampler =
38 static const INTERFACE_ID IID_Sampler =
3939 {0x595a59bf, 0xfa81, 0x4855, {0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95}};
4040
4141
168168 }
169169 #endif
170170 };
171 typedef struct SamplerDesc SamplerDesc;
171172
172173
173174 #if DILIGENT_CPP_INTERFACE
174175
175 // clang-format on
176 // clang-format off
176177
177178 /// Texture sampler interface.
178179
179180 /// The interface holds the sampler state that can be used to perform texture filtering.
180181 /// To create a sampler, call IRenderDevice::CreateSampler(). To use a sampler,
181182 /// call ITextureView::SetSampler().
182 class ISampler : public IDeviceObject
183 DILIGENT_INTERFACE(ISampler, IDeviceObject)
183184 {
184 public:
185 #if DILIGENT_CPP_INTERFACE
185186 /// Returns the sampler description used to create the object
186187 virtual const SamplerDesc& GetDesc() const override = 0;
188 #endif
187189 };
188190
189 #else
191 #endif
192
193 #if DILIGENT_C_INTERFACE
194
195 // clang-format on
190196
191197 struct ISampler;
192198
201207 //struct ISamplerMethods Sampler;
202208 };
203209
204 struct ISampler
210 typedef struct ISampler
205211 {
206212 struct ISamplerVtbl* pVtbl;
207 };
213 } ISampler;
208214
209215 # define ISampler_GetDesc(This) (const struct SamplerDesc*)IDeviceObject_GetDesc(This)
210216
3535
3636 DILIGENT_BEGIN_NAMESPACE(Diligent)
3737
38
3938 // {2989B45C-143D-4886-B89C-C3271C2DCC5D}
40 static const struct INTERFACE_ID IID_Shader =
39 static const INTERFACE_ID IID_Shader =
4140 {0x2989b45c, 0x143d, 0x4886, {0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d}};
4241
4342 // clang-format off
7473 /// Shader type. See Diligent::SHADER_TYPE.
7574 SHADER_TYPE ShaderType DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
7675 };
76 typedef struct ShaderDesc ShaderDesc;
7777
7878 // clang-format on
7979
8080 // {3EA98781-082F-4413-8C30-B9BA6D82DBB7}
81 static const struct INTERFACE_ID IID_IShaderSourceInputStreamFactory =
81 static const INTERFACE_ID IID_IShaderSourceInputStreamFactory =
8282 {0x3ea98781, 0x82f, 0x4413, {0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7}};
8383
8484
85 #if DILIGENT_CPP_INTERFACE
85 // clang-format off
86
87 #if DILIGENT_C_INTERFACE
88 # define THIS struct IShaderSourceInputStreamFactory*
89 # define THIS_ struct IShaderSourceInputStreamFactory*,
90 #endif
8691
8792 /// Shader source stream factory interface
88 class IShaderSourceInputStreamFactory : public IObject
89 {
90 public:
91 virtual void CreateInputStream(const Diligent::Char* Name, IFileStream** ppStream) = 0;
92 };
93
94 #else
95
96 #endif
93 DILIGENT_INTERFACE(IShaderSourceInputStreamFactory, IObject)
94 {
95 VIRTUAL void METHOD(CreateInputStream)(THIS_
96 const Char* Name,
97 IFileStream** ppStream) PURE;
98 };
99
100
101 #if DILIGENT_C_INTERFACE
102
103 # undef THIS
104 # undef THIS_
105
106 // clang-format on
107
108 struct IShaderSourceInputStreamFactoryVtbl
109 {
110 struct IObjectMethods Object;
111 struct IShaderSourceInputStreamFactoryMethods ShaderSourceInputStreamFactory;
112 };
113
114 typedef struct IShaderSourceInputStreamFactory
115 {
116 struct IShaderSourceInputStreamFactoryVtbl* pVtbl;
117 } IShaderSourceInputStreamFactory;
118
119 # define IShaderSourceInputStreamFactory_CreateInputStream(This, ...) (This)->pVtbl->ShaderSourceInputStreamFactory.CreateInputStream((IShaderSourceInputStreamFactory*)(This), __VA_ARGS__)
120
121 #endif
122
97123
98124 struct ShaderMacro
99125 {
110136 {}
111137 #endif
112138 };
139 typedef struct ShaderMacro ShaderMacro;
113140
114141 /// Shader version
115142 struct ShaderVersion
129156 {}
130157 #endif
131158 };
159 typedef struct ShaderVersion ShaderVersion;
132160
133161 /// Shader creation attributes
134162 struct ShaderCreateInfo
142170
143171 /// The factory is used to load the shader source file if FilePath is not null.
144172 /// It is also used to create additional input streams for shader include files
145 class IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr);
173 IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr);
146174
147175 /// HLSL->GLSL conversion stream
148176
155183 /// the first time and will use it in all subsequent times.
156184 /// For all subsequent conversions, FilePath member must be the same, or
157185 /// new stream will be crated and warning message will be displayed.
158 class IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr);
186 struct IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr);
159187
160188 /// Shader source
161189
186214 /// Shader macros
187215
188216 /// This member is ignored if ByteCode is not null
189 const struct ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr);
217 const ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr);
190218
191219 /// If set to true, textures will be combined with texture samplers.
192220 /// The CombinedSamplerSuffix member defines the suffix added to the texture variable
204232 const Char* CombinedSamplerSuffix DEFAULT_INITIALIZER("_sampler");
205233
206234 /// Shader description. See Diligent::ShaderDesc.
207 struct ShaderDesc Desc;
235 ShaderDesc Desc;
208236
209237 /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE.
210238 SHADER_SOURCE_LANGUAGE SourceLanguage DEFAULT_INITIALIZER(SHADER_SOURCE_LANGUAGE_DEFAULT);
215243 /// has no effect.
216244 ///
217245 /// \note When HLSL source is converted to GLSL, corresponding GLSL/GLESSL version will be used.
218 struct ShaderVersion HLSLVersion DEFAULT_INITIALIZER({});
246 ShaderVersion HLSLVersion DEFAULT_INITIALIZER({});
219247
220248 /// GLSL version to use when creating the shader. When default value
221249 /// is given (0, 0), the engine will attempt to use the highest GLSL version
222250 /// supported by the device.
223 struct ShaderVersion GLSLVersion DEFAULT_INITIALIZER({});
251 ShaderVersion GLSLVersion DEFAULT_INITIALIZER({});
224252
225253 /// GLES shading language version to use when creating the shader. When default value
226254 /// is given (0, 0), the engine will attempt to use the highest GLESSL version
227255 /// supported by the device.
228 struct ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({});
256 ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({});
229257
230258
231259 /// Memory address where pointer to the compiler messages data blob will be written
233261 /// The buffer contains two null-terminated strings. The first one is the compiler
234262 /// output message. The second one is the full shader source code including definitions added
235263 /// by the engine. Data blob object must be released by the client.
236 class IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr);
237 };
264 IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr);
265 };
266 typedef struct ShaderCreateInfo ShaderCreateInfo;
238267
239268 /// Describes shader resource type
240269 DILIGENT_TYPED_ENUM(SHADER_RESOURCE_TYPE, Uint8){
286315 Uint32 ArraySize DEFAULT_INITIALIZER(0);
287316 // clang-format on
288317 };
289
290
318 typedef struct ShaderResourceDesc ShaderResourceDesc;
319
320
321 #if DILIGENT_C_INTERFACE
322 # define THIS struct IShader*
323 # define THIS_ struct IShader*,
324 #endif
325
326 // clang-format off
327
328 /// Shader interface
329 DILIGENT_INTERFACE(IShader, IDeviceObject)
330 {
291331 #if DILIGENT_CPP_INTERFACE
292
293 /// Shader interface
294 class IShader : public IDeviceObject
295 {
296 public:
297332 /// Returns the shader description
298333 virtual const ShaderDesc& GetDesc() const override = 0;
334 #endif
299335
300336 /// Returns the total number of shader resources
301 virtual Uint32 GetResourceCount() const = 0;
337 VIRTUAL Uint32 METHOD(GetResourceCount)(THIS) CONST PURE;
302338
303339 /// Returns the pointer to the array of shader resources
304 virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const = 0;
305 };
306
307 #else
308
309 struct IShader;
310
311 // clang-format off
312
313 struct IShaderMethods
314 {
315 Uint32 (*GetResourceCount)(struct IShader*);
316 void (*GetResourceDesc) (struct IShader*, Uint32 Index, struct ShaderResourceDesc* ResourceDesc);
317 };
340 VIRTUAL void METHOD(GetResourceDesc)(THIS_
341 Uint32 Index,
342 ShaderResourceDesc REF ResourceDesc) CONST PURE;
343 };
344
345 #if DILIGENT_C_INTERFACE
346
347 # undef THIS
348 # undef THIS_
318349
319350 // clang-format on
320351
325356 struct IShaderMethods Shader;
326357 };
327358
328 struct IShader
359 typedef struct IShader
329360 {
330361 struct IShaderVtbl* pVtbl;
331 };
362 } IShader;
332363
333364 // clang-format off
334365
335366 # define IShader_GetDesc(This) (const struct ShaderDesc*)IDeviceObject_GetDesc(This)
336367
337 # define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((struct IShader*)(This))
338 # define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((struct IShader*)(This), __VA_ARGS__)
368 # define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((IShader*)(This))
369 # define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((IShader*)(This), __VA_ARGS__)
339370
340371 // clang-format on
341372
3636
3737 DILIGENT_BEGIN_NAMESPACE(Diligent)
3838
39 class IPipelineState;
39 struct IPipelineState;
4040
4141 // {061F8774-9A09-48E8-8411-B5BD20560104}
42 static const struct INTERFACE_ID IID_ShaderResourceBinding =
42 static const INTERFACE_ID IID_ShaderResourceBinding =
4343 {0x61f8774, 0x9a09, 0x48e8, {0x84, 0x11, 0xb5, 0xbd, 0x20, 0x56, 0x1, 0x4}};
4444
4545
46 #if DILIGENT_CPP_INTERFACE
46 #if DILIGENT_C_INTERFACE
47 # define THIS struct IShaderResourceBinding*
48 # define THIS_ struct IShaderResourceBinding*,
49 #endif
50
51 // clang-format off
4752
4853 /// Shader resource binding interface
49 class IShaderResourceBinding : public IObject
54 DILIGENT_INTERFACE(IShaderResourceBinding, IObject)
5055 {
51 public:
5256 /// Returns pointer to the referenced buffer object.
5357
5458 /// The method calls AddRef() on the returned interface,
5559 /// so Release() must be called to avoid memory leaks.
56 virtual IPipelineState* GetPipelineState() = 0;
60 VIRTUAL struct IPipelineState* METHOD(GetPipelineState)(THIS) PURE;
5761
5862 /// Binds mutable and dynamice resources using the resource mapping
5963
6165 /// Any combination of Diligent::SHADER_TYPE may be used.
6266 /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up
6367 /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS.
64 virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) = 0;
68 VIRTUAL void METHOD(BindResources)(THIS_
69 Uint32 ShaderFlags,
70 IResourceMapping* pResMapping,
71 Uint32 Flags) PURE;
6572
6673 /// Returns variable
6774
7178 ///
7279 /// \note This operation may potentially be expensive. If the variable will be used often, it is
7380 /// recommended to store and reuse the pointer as it never changes.
74 virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) = 0;
81 VIRTUAL IShaderResourceVariable* METHOD(GetVariableByName)(THIS_
82 SHADER_TYPE ShaderType,
83 const char* Name) PURE;
7584
7685 /// Returns the total variable count for the specific shader stage.
7786
7988 /// \remark The method only counts mutable and dynamic variables that can be accessed through
8089 /// the Shader Resource Binding object. Static variables are accessed through the Shader
8190 /// object.
82 virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const = 0;
91 VIRTUAL Uint32 METHOD(GetVariableCount)(THIS_
92 SHADER_TYPE ShaderType) CONST PURE;
8393
8494 /// Returns variable
8595
93103 ///
94104 /// \note This operation may potentially be expensive. If the variable will be used often, it is
95105 /// recommended to store and reuse the pointer as it never changes.
96 virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0;
106 VIRTUAL IShaderResourceVariable* METHOD(GetVariableByIndex)(THIS_
107 SHADER_TYPE ShaderType,
108 Uint32 Index) PURE;
97109
98110
99111 /// Initializes static resources
111123 /// \note The method must be called exactly once. If static resources have
112124 /// already been initialized and the method is called again, it will have
113125 /// no effect and a warning messge will be displayed.
114 virtual void InitializeStaticResources(const IPipelineState* pPipelineState = nullptr) = 0;
126 VIRTUAL void METHOD(InitializeStaticResources)(THIS_
127 const struct IPipelineState* pPipelineState DEFAULT_VALUE(nullptr)) PURE;
115128 };
116129
117 #else
130 #if DILIGENT_C_INTERFACE
118131
119 class IPipelineState;
120 struct IShaderResourceBinding;
121
122 // clang-format off
123
124 struct IShaderResourceBindingMethods
125 {
126 class IPipelineState* (*GetPipelineState) (struct IShaderResourceBinding*);
127 void (*BindResources) (struct IShaderResourceBinding*, Uint32 ShaderFlags, class IResourceMapping* pResMapping, Uint32 Flags);
128 class IShaderResourceVariable* (*GetVariableByName) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, const char* Name);
129 Uint32 (*GetVariableCount) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType);
130 class IShaderResourceVariable* (*GetVariableByIndex) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, Uint32 Index);
131 void (*InitializeStaticResources)(struct IShaderResourceBinding*, const class IPipelineState* pPipelineState);
132 };
132 # undef THIS
133 # undef THIS_
133134
134135 // clang-format on
135136
139140 struct IShaderResourceBindingMethods ShaderResourceBinding;
140141 };
141142
142 struct IShaderResourceBinding
143 typedef struct IShaderResourceBinding
143144 {
144145 struct IShaderResourceBindingVtbl* pVtbl;
145 };
146 } IShaderResourceBinding;
146147
147148 // clang-format off
148149
149 # define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((struct IShaderResourceBinding*)(This))
150 # define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((struct IShaderResourceBinding*)(This), __VA_ARGS__)
151 # define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((struct IShaderResourceBinding*)(This), __VA_ARGS__)
152 # define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((struct IShaderResourceBinding*)(This), __VA_ARGS__)
153 # define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((struct IShaderResourceBinding*)(This), __VA_ARGS__)
154 # define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((struct IShaderResourceBinding*)(This), __VA_ARGS__)
150 # define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((IShaderResourceBinding*)(This))
151 # define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((IShaderResourceBinding*)(This), __VA_ARGS__)
152 # define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((IShaderResourceBinding*)(This), __VA_ARGS__)
153 # define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((IShaderResourceBinding*)(This), __VA_ARGS__)
154 # define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((IShaderResourceBinding*)(This), __VA_ARGS__)
155 # define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((IShaderResourceBinding*)(This), __VA_ARGS__)
155156
156157 // clang-format on
157158
3838
3939
4040 // {0D57DF3F-977D-4C8F-B64C-6675814BC80C}
41 static const struct INTERFACE_ID IID_ShaderResourceVariable =
41 static const INTERFACE_ID IID_ShaderResourceVariable =
4242 {0xd57df3f, 0x977d, 0x4c8f, {0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc}};
4343
4444 // clang-format off
103103
104104 // clang-format on
105105
106 #if DILIGENT_CPP_INTERFACE
106 #if DILIGENT_C_INTERFACE
107 # define THIS struct IShaderResourceVariable*
108 # define THIS_ struct IShaderResourceVariable*,
109 #endif
110
111 // clang-format off
107112
108113 /// Shader resource variable
109 class IShaderResourceVariable : public IObject
114 DILIGENT_INTERFACE(IShaderResourceVariable, IObject)
110115 {
111 public:
112116 /// Binds resource to the variable
113117
114118 /// \remark The method performs run-time correctness checks.
115119 /// For instance, shader resource view cannot
116120 /// be assigned to a constant buffer variable.
117 virtual void Set(IDeviceObject* pObject) = 0;
121 VIRTUAL void METHOD(Set)(THIS_
122 IDeviceObject* pObject) PURE;
118123
119124 /// Binds resource array to the variable
120125
125130 /// \remark The method performs run-time correctness checks.
126131 /// For instance, shader resource view cannot
127132 /// be assigned to a constant buffer variable.
128 virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) = 0;
133 VIRTUAL void METHOD(SetArray)(THIS_
134 IDeviceObject* const* ppObjects,
135 Uint32 FirstElement,
136 Uint32 NumElements) PURE;
129137
130138 /// Returns the shader resource variable type
131 virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const = 0;
139 VIRTUAL SHADER_RESOURCE_VARIABLE_TYPE METHOD(GetType)(THIS) CONST PURE;
132140
133141 /// Returns shader resource description. See Diligent::ShaderResourceDesc.
134 virtual void GetResourceDesc(ShaderResourceDesc& ResourceDesc) const = 0;
142 VIRTUAL void METHOD(GetResourceDesc)(THIS_
143 ShaderResourceDesc REF ResourceDesc) CONST PURE;
135144
136145 /// Returns the variable index that can be used to access the variable.
137 virtual Uint32 GetIndex() const = 0;
146 VIRTUAL Uint32 METHOD(GetIndex)(THIS) CONST PURE;
138147
139148 /// Returns true if non-null resource is bound to this variable.
140149
141150 /// \param [in] ArrayIndex - Resource array index. Must be 0 for
142151 /// non-array variables.
143 virtual bool IsBound(Uint32 ArrayIndex) const = 0;
152 VIRTUAL bool METHOD(IsBound)(THIS_
153 Uint32 ArrayIndex) CONST PURE;
144154 };
145155
146 #else
147156
148 struct IShaderResourceVariable;
157 #if DILIGENT_C_INTERFACE
149158
150 // clang-format off
151 struct IShaderResourceVariableMethods
152 {
153 void (*Set) (struct IShaderResourceVariable*, class IDeviceObject* pObject);
154 void (*SetArray) (struct IShaderResourceVariable*, class IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements);
155 SHADER_RESOURCE_VARIABLE_TYPE (*GetType) (struct IShaderResourceVariable*);
156 void (*GetResourceDesc)(struct IShaderResourceVariable*, struct ShaderResourceDesc* ResourceDesc);
157 Uint32 (*GetIndex) (struct IShaderResourceVariable*);
158 bool (*IsBound) (struct IShaderResourceVariable*, Uint32 ArrayIndex);
159 };
159 # undef THIS
160 # undef THIS_
161
160162 // clang-format on
161163
162164 struct IShaderResourceVariableVtbl
165167 struct IShaderResourceVariableMethods ShaderResourceVariable;
166168 };
167169
168 struct IShaderResourceVariable
170 typedef struct IShaderResourceVariable
169171 {
170172 struct IShaderResourceVariableVtbl* pVtbl;
171 };
173 } IShaderResourceVariable;
172174
173175 // clang-format off
174176
175 # define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((struct IShaderResourceVariable*)(This), __VA_ARGS__)
176 # define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((struct IShaderResourceVariable*)(This), __VA_ARGS__)
177 # define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((struct IShaderResourceVariable*)(This))
178 # define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((struct IShaderResourceVariable*)(This), __VA_ARGS__)
179 # define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((struct IShaderResourceVariable*)(This))
180 # define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((struct IShaderResourceVariable*)(This), __VA_ARGS__)
177 # define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((IShaderResourceVariable*)(This), __VA_ARGS__)
178 # define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((IShaderResourceVariable*)(This), __VA_ARGS__)
179 # define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((IShaderResourceVariable*)(This))
180 # define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((IShaderResourceVariable*)(This), __VA_ARGS__)
181 # define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((IShaderResourceVariable*)(This))
182 # define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((IShaderResourceVariable*)(This), __VA_ARGS__)
181183
182184 // clang-format on
183185
3737
3838
3939 // {1C703B77-6607-4EEC-B1FE-15C82D3B4130}
40 static const struct INTERFACE_ID IID_SwapChain =
40 static const INTERFACE_ID IID_SwapChain =
4141 {0x1c703b77, 0x6607, 0x4eec, {0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30}};
4242
4343
44 #if DILIGENT_CPP_INTERFACE
44 #if DILIGENT_C_INTERFACE
45 # define THIS struct ISwapChain*
46 # define THIS_ struct ISwapChain*,
47 #endif
48
49 // clang-format off
4550
4651 /// Swap chain interface
4752
4853 /// The swap chain is created by a platform-dependent function
49 class ISwapChain : public IObject
54 DILIGENT_INTERFACE(ISwapChain, IObject)
5055 {
51 public:
5256 /// Presents a rendered image to the user
53 virtual void Present(Uint32 SyncInterval = 1) = 0;
57 VIRTUAL void METHOD(Present)(THIS_
58 Uint32 SyncInterval DEFAULT_VALUE(1)) PURE;
5459
5560 /// Returns the swap chain desctription
56 virtual const SwapChainDesc& GetDesc() const = 0;
61 VIRTUAL const SwapChainDesc REF METHOD(GetDesc)(THIS) CONST PURE;
5762
5863 /// Changes the swap chain's back buffer size
5964
6267 ///
6368 /// \note When resizing non-primary swap chains, the engine unbinds the
6469 /// swap chain buffers from the output.
65 virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) = 0;
70 VIRTUAL void METHOD(Resize)(THIS_
71 Uint32 NewWidth,
72 Uint32 NewHeight) PURE;
6673
6774 /// Sets fullscreen mode (only supported on Win32 platform)
68 virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) = 0;
75 VIRTUAL void METHOD(SetFullscreenMode)(THIS_ const DisplayModeAttribs REF DisplayMode) PURE;
6976
7077 /// Sets windowed mode (only supported on Win32 platform)
71 virtual void SetWindowedMode() = 0;
78 VIRTUAL void METHOD(SetWindowedMode)(THIS) PURE;
7279
7380 /// Returns render target view of the current back buffer in the swap chain
7481
8087 ///
8188 /// The method does *NOT* call AddRef() on the returned interface,
8289 /// so Release() must not be called.
83 virtual ITextureView* GetCurrentBackBufferRTV() = 0;
90 VIRTUAL ITextureView* METHOD(GetCurrentBackBufferRTV)(THIS) PURE;
8491
8592 /// Returns depth-stencil view of the depth buffer
8693
8794 /// The method does *NOT* call AddRef() on the returned interface,
8895 /// so Release() must not be called.
89 virtual ITextureView* GetDepthBufferDSV() = 0;
96 VIRTUAL ITextureView* METHOD(GetDepthBufferDSV)(THIS) PURE;
9097 };
9198
92 #else
9399
94 struct ISwapChain;
100 #if DILIGENT_C_INTERFACE
95101
96 // clang-format off
97
98 struct ISwapChainMethods
99 {
100 void (*Present) (struct ISwapChain*, Uint32 SyncInterval);
101 const struct SwapChainDesc* (*GetDesc) (struct ISwapChain*);
102 void (*Resize) (struct ISwapChain*, Uint32 NewWidth, Uint32 NewHeight);
103 void (*SetFullscreenMode) (struct ISwapChain*, const struct DisplayModeAttribs* DisplayMode);
104 void (*SetWindowedMode) (struct ISwapChain*);
105 struct ITextureView* (*GetCurrentBackBufferRTV)(struct ISwapChain*);
106 struct ITextureView* (*GetDepthBufferDSV) (struct ISwapChain*);
107 };
102 # undef THIS
103 # undef THIS_
108104
109105 // clang-format on
110106
114110 struct ISwapChainMethods SwapChain;
115111 };
116112
117 struct ISwapChain
113 typedef struct ISwapChain
118114 {
119115 struct ISwapChainVtbl* pVtbl;
120 };
116 } ISwapChain;
121117
122118 // clang-format off
123119
124 # define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((struct ISwapChain*)(This), __VA_ARGS__)
125 # define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((struct ISwapChain*)(This))
126 # define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((struct ISwapChain*)(This), __VA_ARGS__)
127 # define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((struct ISwapChain*)(This), __VA_ARGS__)
128 # define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((struct ISwapChain*)(This))
129 # define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((struct ISwapChain*)(This))
130 # define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((struct ISwapChain*)(This))
120 # define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((ISwapChain*)(This), __VA_ARGS__)
121 # define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((ISwapChain*)(This))
122 # define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((ISwapChain*)(This), __VA_ARGS__)
123 # define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((ISwapChain*)(This), __VA_ARGS__)
124 # define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((ISwapChain*)(This))
125 # define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((ISwapChain*)(This))
126 # define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((ISwapChain*)(This))
131127
132128 // clang-format on
133129