git.s-ol.nu forks/DiligentCore / 75d892e
c inteface: implemented core object VTBLs assiduous 3 years ago
22 changed file(s) with 578 addition(s) and 97 deletion(s). Raw diff Collapse all Expand all
4343 class RefCountersImpl final : public IReferenceCounters
4444 {
4545 public:
46 inline virtual CounterValueType AddStrongRef() override final
46 inline virtual ReferenceCounterValueType AddStrongRef() override final
4747 {
4848 VERIFY(m_ObjectState == ObjectState::Alive, "Attempting to increment strong reference counter for a destroyed or not itialized object!");
4949 VERIFY(m_ObjectWrapperBuffer[0] != 0 && m_ObjectWrapperBuffer[1] != 0, "Object wrapper is not initialized");
5151 }
5252
5353 template <class TPreObjectDestroy>
54 inline CounterValueType ReleaseStrongRef(TPreObjectDestroy PreObjectDestroy)
54 inline ReferenceCounterValueType ReleaseStrongRef(TPreObjectDestroy PreObjectDestroy)
5555 {
5656 VERIFY(m_ObjectState == ObjectState::Alive, "Attempting to decrement strong reference counter for an object that is not alive");
5757 VERIFY(m_ObjectWrapperBuffer[0] != 0 && m_ObjectWrapperBuffer[1] != 0, "Object wrapper is not initialized");
6868 return RefCount;
6969 }
7070
71 inline virtual CounterValueType ReleaseStrongRef() override final
71 inline virtual ReferenceCounterValueType ReleaseStrongRef() override final
7272 {
7373 return ReleaseStrongRef([]() {});
7474 }
7575
76 inline virtual CounterValueType AddWeakRef() override final
76 inline virtual ReferenceCounterValueType AddWeakRef() override final
7777 {
7878 return Atomics::AtomicIncrement(m_lNumWeakReferences);
7979 }
8080
81 inline virtual CounterValueType ReleaseWeakRef() override final
81 inline virtual ReferenceCounterValueType ReleaseWeakRef() override final
8282 {
8383 // The method must be serialized!
8484 ThreadingTools::LockHelper Lock(m_LockFlag);
201201 Atomics::AtomicDecrement(m_lNumStrongReferences);
202202 }
203203
204 inline virtual CounterValueType GetNumStrongRefs() const override final
204 inline virtual ReferenceCounterValueType GetNumStrongRefs() const override final
205205 {
206206 return m_lNumStrongReferences;
207207 }
208208
209 inline virtual CounterValueType GetNumWeakRefs() const override final
209 inline virtual ReferenceCounterValueType GetNumWeakRefs() const override final
210210 {
211211 return m_lNumWeakReferences;
212212 }
488488 class RefCountedObject : public Base
489489 {
490490 public:
491 using CounterValueType = IReferenceCounters::CounterValueType;
492
493491 template <typename... BaseCtorArgTypes>
494492 RefCountedObject(IReferenceCounters* pRefCounters, BaseCtorArgTypes&&... BaseCtorArgs) noexcept :
495493 // clang-format off
532530 return m_pRefCounters;
533531 }
534532
535 inline virtual CounterValueType AddRef() override final
533 inline virtual ReferenceCounterValueType AddRef() override final
536534 {
537535 VERIFY_EXPR(m_pRefCounters != nullptr);
538536 // Since type of m_pRefCounters is RefCountersImpl,
540538 return m_pRefCounters->AddStrongRef();
541539 }
542540
543 inline virtual CounterValueType Release() override
541 inline virtual ReferenceCounterValueType Release() override
544542 {
545543 VERIFY_EXPR(m_pRefCounters != nullptr);
546544 // Since type of m_pRefCounters is RefCountersImpl,
549547 }
550548
551549 template <class TPreObjectDestroy>
552 inline CounterValueType Release(TPreObjectDestroy PreObjectDestroy)
550 inline ReferenceCounterValueType Release(TPreObjectDestroy PreObjectDestroy)
553551 {
554552 VERIFY_EXPR(m_pRefCounters != nullptr);
555553 return m_pRefCounters->ReleaseStrongRef(PreObjectDestroy);
4747 class EngineFactoryBase : public BaseInterface
4848 {
4949 public:
50 using CounterValueType = IReferenceCounters::CounterValueType;
51
5250 EngineFactoryBase(const INTERFACE_ID& FactoryIID) noexcept :
5351 // clang-format off
5452 m_FactoryIID {FactoryIID},
7068 }
7169 }
7270
73 virtual CounterValueType AddRef() override final
71 virtual ReferenceCounterValueType AddRef() override final
7472 {
7573 return m_RefCounters.AddStrongRef();
7674 }
7775
78 virtual CounterValueType Release() override final
76 virtual ReferenceCounterValueType Release() override final
7977 {
8078 return m_RefCounters.ReleaseStrongRef();
8179 }
107105 m_lNumWeakReferences = 0;
108106 }
109107
110 using IReferenceCounters::CounterValueType;
111 virtual CounterValueType AddStrongRef() override final
108 virtual ReferenceCounterValueType AddStrongRef() override final
112109 {
113110 return Atomics::AtomicIncrement(m_lNumStrongReferences);
114111 }
115112
116 virtual CounterValueType ReleaseStrongRef() override final
113 virtual ReferenceCounterValueType ReleaseStrongRef() override final
117114 {
118115 return Atomics::AtomicDecrement(m_lNumStrongReferences);
119116 }
120117
121 virtual CounterValueType AddWeakRef() override final
118 virtual ReferenceCounterValueType AddWeakRef() override final
122119 {
123120 return Atomics::AtomicIncrement(m_lNumWeakReferences);
124121 }
125122
126 virtual CounterValueType ReleaseWeakRef() override final
123 virtual ReferenceCounterValueType ReleaseWeakRef() override final
127124 {
128125 return Atomics::AtomicDecrement(m_lNumWeakReferences);
129126 }
134131 m_Factory.QueryInterface(IID_Unknown, ppObject);
135132 }
136133
137 virtual CounterValueType GetNumStrongRefs() const override final
134 virtual ReferenceCounterValueType GetNumStrongRefs() const override final
138135 {
139136 return m_lNumStrongReferences;
140137 }
141138
142 virtual CounterValueType GetNumWeakRefs() const override final
139 virtual ReferenceCounterValueType GetNumWeakRefs() const override final
143140 {
144141 return m_lNumWeakReferences;
145142 }
312312
313313 // It is important to have final implementation of Release() method to avoid
314314 // virtual calls
315 inline virtual IReferenceCounters::CounterValueType Release() override final
315 inline virtual ReferenceCounterValueType Release() override final
316316 {
317317 return TObjectBase::Release();
318318 }
3232 /// Defines Diligent::IBuffer interface and related data structures
3333
3434 #include "DeviceObject.h"
35 #include "BufferView.h"
3536
3637 DILIGENT_BEGIN_NAMESPACE(Diligent)
3738
178179 class IBuffer : public IDeviceObject
179180 {
180181 public:
181 /// Queries the specific interface, see IObject::QueryInterface() for details
182 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
183
184182 /// Returns the buffer description used to create the object
185183 virtual const BufferDesc& GetDesc() const override = 0;
186184
231229
232230 #else
233231
232 struct IBuffer;
233
234 struct IBufferVtbl
235 {
236 void (*CreateView)(const struct BufferViewDesc* ViewDesc, class IBufferView** ppView);
237 class IBufferView* (*GetDefaultView)(BUFFER_VIEW_TYPE ViewType);
238 void* (*GetNativeHandle)();
239 void (*SetState)(RESOURCE_STATE State);
240 RESOURCE_STATE (*GetState)();
241 };
242
243 struct IBuffer
244 {
245 struct IObjectVtbl* pObjectVtbl;
246 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
247 struct IBufferVtbl* pBufferVtbl;
248 };
249
250 # define IBuffer_GetDesc(This) (const struct BufferDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
251
252 # define IBuffer_CreateView(This, ...) (This)->pBufferVtbl->CreateView(This, __VA_ARGS__)
253 # define IBuffer_GetDefaultView(This, ...) (This)->pBufferVtbl->GetDefaultView(This, __VA_ARGS__)
254 # define IBuffer_GetNativeHandle(This) (This)->pBufferVtbl->(This)
255 # define IBuffer_SetState(This) (This)->pBufferVtbl->SetState(This, __VA_ARGS__)
256 # define IBuffer_GetState(This) (This)->pBufferVtbl->GetState(This, __VA_ARGS__)
257
234258 #endif
235259
236260 DILIGENT_END_NAMESPACE // namespace Diligent
3131 /// \file
3232 /// Definition of the Diligent::IBufferView interface and related data structures
3333
34 #include "Buffer.h"
34 #include "DeviceObject.h"
3535
3636 DILIGENT_BEGIN_NAMESPACE(Diligent)
3737
148148 class IBufferView : public IDeviceObject
149149 {
150150 public:
151 /// Queries the specific interface, see IObject::QueryInterface() for details
152 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
153
154151 /// Returns the buffer view description used to create the object
155152 virtual const BufferViewDesc& GetDesc() const override = 0;
156153
158155
159156 /// The method does *NOT* call AddRef() on the returned interface,
160157 /// so Release() must not be called.
161 virtual IBuffer* GetBuffer() = 0;
158 virtual class IBuffer* GetBuffer() = 0;
162159 };
163160
164161 #else
165162
163 class IBufferView;
164 class IBuffer;
165
166 struct IBufferViewVtbl
167 {
168 class IBuffer* (*GetBuffer)();
169 };
170
171 struct IBufferView
172 {
173 struct IObjectVtbl* pObjectVtbl;
174 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
175 struct IBufferViewVtbl* pBufferVtbl;
176 };
177
178 # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
179
180 # define IBufferView_GetBuffer(This) (This)->pBufferVtbl->GetBuffer(This)
181
166182 #endif
167183
168184 DILIGENT_END_NAMESPACE // namespace Diligent
5050
5151 #else
5252
53 struct ICommandList;
54
55 // C requires that a struct or union has at least one member
56 //struct ICommandListVtbl
57 //{
58 //};
59
60 struct ICommandList
61 {
62 struct IObjectVtbl* pObjectVtbl;
63 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
64 //struct ICommandListVtbl* pCommandListVtbl;
65 };
66
5367 #endif
5468
5569 DILIGENT_END_NAMESPACE // namespace Diligent
559559 const struct Box* pSrcBox DEFAULT_INITIALIZER(nullptr);
560560
561561 /// Source texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
562 enum RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
562 RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
563563
564564 /// Destination texture.
565565 class ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr);
611611 class IDeviceContext : public IObject
612612 {
613613 public:
614 /// Queries the specific interface, see IObject::QueryInterface() for details.
615 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
616
617614 /// Sets the pipeline state.
618615
619616 /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context.
12501247
12511248 #else
12521249
1253
1250 // clang-format on
1251
1252 struct IDeviceContext;
1253
1254 struct IDeviceContextVtbl
1255 {
1256 void (*SetPipelineState)(class IPipelineState* pPipelineState);
1257 void (*TransitionShaderResources)(class IPipelineState* pPipelineState, class IShaderResourceBinding* pShaderResourceBinding);
1258 void (*CommitShaderResources)(class IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1259 void (*SetStencilRef)(Uint32 StencilRef);
1260 void (*SetBlendFactors)(const float* pBlendFactors);
1261 void (*SetVertexBuffers)(Uint32 StartSlot,
1262 Uint32 NumBuffersSet,
1263 class IBuffer** ppBuffers,
1264 Uint32* pOffsets,
1265 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
1266 SET_VERTEX_BUFFERS_FLAGS Flags);
1267 void (*InvalidateState)();
1268 void (*SetIndexBuffer)(class IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1269 void (*SetViewports)(Uint32 NumViewports, const struct Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight);
1270 void (*SetScissorRects)(Uint32 NumRects, const struct Rect* pRects, Uint32 RTWidth, Uint32 RTHeight);
1271 void (*SetRenderTargets)(Uint32 NumRenderTargets,
1272 class ITextureView* ppRenderTargets[],
1273 class ITextureView* pDepthStencil,
1274 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1275 void (*Draw)(const struct DrawAttribs* Attribs);
1276 void (*DrawIndexed)(const struct DrawIndexedAttribs* Attribs);
1277 void (*DrawIndirect)(const struct DrawIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1278 void (*DrawIndexedIndirect)(const struct DrawIndexedIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1279 void (*DispatchCompute)(const struct DispatchComputeAttribs* Attribs);
1280 void (*DispatchComputeIndirect)(const struct DispatchComputeIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer);
1281 void (*ClearDepthStencil)(class ITextureView* pView,
1282 CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
1283 float fDepth,
1284 Uint8 Stencil,
1285 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1286 void (*ClearRenderTarget)(class ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1287 void (*FinishCommandList)(class ICommandList** ppCommandList);
1288 void (*ExecuteCommandList)(class ICommandList* pCommandList);
1289 void (*SignalFence)(class IFence* pFence, Uint64 Value);
1290 void (*WaitForFence)(class IFence* pFence, Uint64 Value, bool FlushContext);
1291 void (*WaitForIdle)();
1292 void (*BeginQuery)(class IQuery* pQuery);
1293 void (*EndQuery)(class IQuery* pQuery);
1294 void (*Flush)();
1295 void (*UpdateBuffer)(class IBuffer* pBuffer,
1296 Uint32 Offset,
1297 Uint32 Size,
1298 const void* pData,
1299 RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
1300 void (*CopyBuffer)(class IBuffer* pSrcBuffer,
1301 Uint32 SrcOffset,
1302 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1303 class IBuffer* pDstBuffer,
1304 Uint32 DstOffset,
1305 Uint32 Size,
1306 RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode);
1307 void (*MapBuffer)(class IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid* pMappedData);
1308 void (*UnmapBuffer)(class IBuffer* pBuffer, MAP_TYPE MapType);
1309 void (*UpdateTexture)(class ITexture* pTexture,
1310 Uint32 MipLevel,
1311 Uint32 Slice,
1312 const struct Box* DstBox,
1313 const struct TextureSubResData* SubresData,
1314 RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1315 RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode);
1316 void (*CopyTexture)(const struct CopyTextureAttribs* CopyAttribs);
1317 void (*MapTextureSubresource)(class ITexture* pTexture,
1318 Uint32 MipLevel,
1319 Uint32 ArraySlice,
1320 MAP_TYPE MapType,
1321 MAP_FLAGS MapFlags,
1322 const struct Box* pMapRegion,
1323 struct MappedTextureSubresource* MappedData);
1324 void (*UnmapTextureSubresource)(class ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice);
1325 void (*GenerateMips)(class ITextureView* pTextureView);
1326 void (*FinishFrame)();
1327 void (*TransitionResourceStates)(Uint32 BarrierCount, struct StateTransitionDesc* pResourceBarriers);
1328 void (*ResolveTextureSubresource)(class ITexture* pSrcTexture,
1329 class ITexture* pDstTexture,
1330 const struct ResolveTextureSubresourceAttribs* ResolveAttribs);
1331 };
1332
1333 struct IDeviceContext
1334 {
1335 struct IObjectVtbl* pObjectVtbl;
1336 struct IDeviceContextVtbl* pDeviceContextVtbl;
1337 };
1338
1339 # define IDeviceContext_SetPipelineState(This, ...) (This)->pDeviceContextVtbl->SetPipelineState(This, __VA_ARGS__)
1340 # define IDeviceContext_TransitionShaderResources(This, ...) (This)->pDeviceContextVtbl->TransitionShaderResources(This, __VA_ARGS__)
1341 # define IDeviceContext_CommitShaderResources(This, ...) (This)->pDeviceContextVtbl - CommitShaderResources(This, __VA_ARGS__)
1342 # define IDeviceContext_SetStencilRef(This, ...) (This)->pDeviceContextVtbl->SetStencilRef(This, __VA_ARGS__)
1343 # define IDeviceContext_SetBlendFactors(This, ...) (This)->pDeviceContextVtbl->SetBlendFactors(This, __VA_ARGS__)
1344 # define IDeviceContext_SetVertexBuffers(This, ...) (This)->pDeviceContextVtbl->SetVertexBuffers(This, __VA_ARGS__)
1345 # define IDeviceContext_InvalidateState(This) (This)->pDeviceContextVtbl->InvalidateState(This)
1346 # define IDeviceContext_SetIndexBuffer(This, ...) (This)->pDeviceContextVtbl->SetIndexBuffer(This, __VA_ARGS__)
1347 # define IDeviceContext_SetViewports(This, ...) (This)->pDeviceContextVtbl->SetViewports(This, __VA_ARGS__)
1348 # define IDeviceContext_SetScissorRects(This, ...) (This)->pDeviceContextVtbl->SetScissorRects(This, __VA_ARGS__)
1349 # define IDeviceContext_SetRenderTargets(This, ...) (This)->pDeviceContextVtbl->SetRenderTargets(This, __VA_ARGS__)
1350 # define IDeviceContext_Draw(This, ...) (This)->pDeviceContextVtbl->Draw(This, __VA_ARGS__)
1351 # define IDeviceContext_DrawIndexed(This, ...) (This)->pDeviceContextVtbl->DrawIndexed(This, __VA_ARGS__)
1352 # define IDeviceContext_DrawIndirect(This, ...) (This)->pDeviceContextVtbl->DrawIndirect(This, __VA_ARGS__)
1353 # define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pDeviceContextVtbl->DrawIndexedIndirect(This, __VA_ARGS__)
1354 # define IDeviceContext_DispatchCompute(This, ...) (This)->pDeviceContextVtbl->DispatchCompute(This, __VA_ARGS__)
1355 # define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pDeviceContextVtbl->DispatchComputeIndirect(This, __VA_ARGS__)
1356 # define IDeviceContext_ClearDepthStencil(This, ...) (This)->pDeviceContextVtbl->ClearDepthStencil(This, __VA_ARGS__)
1357 # define IDeviceContext_ClearRenderTarget(This, ...) (This)->pDeviceContextVtbl->ClearRenderTarget(This, __VA_ARGS__)
1358 # define IDeviceContext_FinishCommandList(This, ...) (This)->pDeviceContextVtbl->FinishCommandList(This, __VA_ARGS__)
1359 # define IDeviceContext_ExecuteCommandList(This, ...) (This)->pDeviceContextVtbl->ExecuteCommandList(This, __VA_ARGS__)
1360 # define IDeviceContext_SignalFence(This, ...) (This)->pDeviceContextVtbl->SignalFence(This, __VA_ARGS__)
1361 # define IDeviceContext_WaitForFence(This, ...) (This)->pDeviceContextVtbl->WaitForFence(This, __VA_ARGS__)
1362 # define IDeviceContext_WaitForIdle(This, ...) (This)->pDeviceContextVtbl->WaitForIdle(This, __VA_ARGS__)
1363 # define IDeviceContext_BeginQuery(This, ...) (This)->pDeviceContextVtbl->BeginQuery(This, __VA_ARGS__)
1364 # define IDeviceContext_EndQuery(This, ...) (This)->pDeviceContextVtbl->EndQuery(This, __VA_ARGS__)
1365 # define IDeviceContext_Flush(This, ...) (This)->pDeviceContextVtbl->Flush(This, __VA_ARGS__)
1366 # define IDeviceContext_UpdateBuffer(This, ...) (This)->pDeviceContextVtbl->UpdateBuffer(This, __VA_ARGS__)
1367 # define IDeviceContext_CopyBuffer(This, ...) (This)->pDeviceContextVtbl->CopyBuffer(This, __VA_ARGS__)
1368 # define IDeviceContext_MapBuffer(This, ...) (This)->pDeviceContextVtbl->MapBuffer(This, __VA_ARGS__)
1369 # define IDeviceContext_UnmapBuffer(This, ...) (This)->pDeviceContextVtbl->UnmapBuffer(This, __VA_ARGS__)
1370 # define IDeviceContext_UpdateTexture(This, ...) (This)->pDeviceContextVtbl->UpdateTexture(This, __VA_ARGS__)
1371 # define IDeviceContext_CopyTexture(This, ...) (This)->pDeviceContextVtbl->CopyTexture(This, __VA_ARGS__)
1372 # define IDeviceContext_MapTextureSubresource(This, ...) (This)->pDeviceContextVtbl->MapTextureSubresource(This, __VA_ARGS__)
1373 # define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pDeviceContextVtbl->UnmapTextureSubresource(This, __VA_ARGS__)
1374 # define IDeviceContext_GenerateMips(This, ...) (This)->pDeviceContextVtbl->GenerateMips(This, __VA_ARGS__)
1375 # define IDeviceContext_FinishFrame(This) (This)->pDeviceContextVtbl->FinishFrame(This)
1376 # define IDeviceContext_TransitionResourceStates(This, ...) (This)->pDeviceContextVtbl->TransitionResourceStates(This, __VA_ARGS__)
1377 # define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pDeviceContextVtbl->ResolveTextureSubresource(This, __VA_ARGS__)
12541378
12551379 #endif
12561380
4545 class IDeviceObject : public IObject
4646 {
4747 public:
48 /// Queries the specific interface, see IObject::QueryInterface() for details
49 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
50
51
5248 /// Returns the object description
5349 virtual const DeviceObjectAttribs& GetDesc() const = 0;
5450
7470
7571 #else
7672
73 struct IDeviceObject;
74
75 struct IDeviceObjectVtbl
76 {
77 const struct DeviceObjectAttribs* (*GetDesc)();
78 Int32 (*GetUniqueID)();
79 };
80
81 struct IDeviceObject
82 {
83 struct IObjectVtbl* pObjectVtbl;
84 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
85 };
86
87 # define IDeviceObject_GetDesc(This) (This)->pDeviceObjectVtbl->GetDesc(This)
88 # define IDeviceObject_GetUniqueID(This) (This)->pDeviceObjectVtbl->GetUniqueID(This)
89
7790 #endif
7891
7992 DILIGENT_END_NAMESPACE // namespace Diligent
5555 class IFence : public IDeviceObject
5656 {
5757 public:
58 /// Queries the specific interface, see IObject::QueryInterface() for details
59 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
60
6158 /// Returns the fence description used to create the object
6259 virtual const FenceDesc& GetDesc() const override = 0;
6360
7471
7572 #else
7673
74 struct IFence;
75
76 struct IFenceVtbl
77 {
78 Uint64 (*GetCompletedValue)();
79 void (*Reset)(Uint64 Value);
80 };
81
82 struct IFence
83 {
84 struct IObjectVtbl* pObjectVtbl;
85 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
86 struct IFenceVtbl* pFenceVtbl;
87 };
88
89 # define IFence_GetDesc(This) (const struct FenceDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
90
91 # define IFence_GetCompletedValue(This) (This)->pFenceVtbl->GetCompletedValue(This)
92 # define IFence_Reset(This, ...) (This)->pFenceVtbl->Reset(This, __VA_ARGS__)
93
7794 #endif
7895
7996 DILIGENT_END_NAMESPACE // namespace Diligent
252252 class IPipelineState : public IDeviceObject
253253 {
254254 public:
255 /// Queries the specific interface, see IObject::QueryInterface() for details
256 virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override = 0;
257
258
259255 /// Returns the blend state description used to create the object
260256 virtual const PipelineStateDesc& GetDesc()const override = 0;
261257
330326
331327 #else
332328
329 struct IPipelineState;
330
331 struct IPipelineStateVtbl
332 {
333 void (*BindStaticResources)(Uint32 ShaderFlags, class IResourceMapping* pResourceMapping, Uint32 Flags);
334 Uint32 (*GetStaticVariableCount)(SHADER_TYPE ShaderType);
335 class IShaderResourceVariable* (*GetStaticVariableByName)(SHADER_TYPE ShaderType, const Char* Name);
336 class IShaderResourceVariable* (*GetStaticVariableByIndex)(SHADER_TYPE ShaderType, Uint32 Index);
337 void (*CreateShaderResourceBinding)(class IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources);
338 bool (*IsCompatibleWith)(const class IPipelineState* pPSO);
339 };
340
341 // clang-format on
342
343 struct IPipelineState
344 {
345 struct IObjectVtbl* pObjectVtbl;
346 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
347 struct IPipelineState* pPipelineStateVtbl;
348 };
349
350 # define IPipelineState_GetDesc(This) (const struct PipelineStateDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
351
352 # define IPipelineState_BindStaticResources(This, ...) (This)->pPipelineStateVtbl->BindStaticResources(This, __VA_ARGS__)
353 # define IPipelineState_GetStaticVariableCount(This, ...) (This)->pPipelineStateVtbl->GetStaticVariableCount(This, __VA_ARGS__)
354 # define IPipelineState_GetStaticVariableByName(This, ...) (This)->pPipelineStateVtbl->GetStaticVariableByName(This, __VA_ARGS__)
355 # define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pPipelineStateVtbl->GetStaticVariableByIndex(This, __VA_ARGS__)
356 # define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pPipelineStateVtbl->CreateShaderResourceBinding(This, __VA_ARGS__)
357 # define IPipelineState_IsCompatibleWith(This, ...) (This)->pPipelineStateVtbl->IsCompatibleWith(This, __VA_ARGS__)
358
359
333360 #endif
334361
335362 DILIGENT_END_NAMESPACE
177177 class IQuery : public IDeviceObject
178178 {
179179 public:
180 /// Queries the specific interface, see IObject::QueryInterface() for details.
181 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
182
183180 /// Returns the Query description used to create the object.
184181 virtual const QueryDesc& GetDesc() const override = 0;
185182
211208
212209 #else
213210
211 struct IQuery;
212
213 struct IQueryVtbl
214 {
215 bool (*GetData)(void* pData, Uint32 DataSize, bool AutoInvalidate);
216 void (*Invalidate)();
217 };
218
219 struct IQuery
220 {
221 struct IObjectVtbl* pObjectVtbl;
222 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
223 struct IQuery* pQueryVtbl;
224 };
225
226 # define IQuery_GetDesc(This) (const struct QueryDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
227
228 # define IQuery_GetData(This, ...) (This)->pQueryVtbl->GetData(This, __VA_ARGS__)
229 # define IQuery_Invalidate(This) (This)->pQueryVtbl->Invalidate(This)
230
214231 #endif
215232
216233 DILIGENT_END_NAMESPACE // namespace Diligent
6262 class IRenderDevice : public IObject
6363 {
6464 public:
65 /// Queries the specific interface, see IObject::QueryInterface() for details
66 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
67
6865 /// Creates a new buffer object
6966
7067 /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details.
227224
228225 #else
229226
230
227 struct IRenderDevice;
228
229 struct IRenderDeviceVtbl
230 {
231 void (*CreateBuffer)(const struct BufferDesc* BuffDesc,
232 const struct BufferData* pBuffData,
233 class IBuffer** ppBuffer);
234 void (*CreateShader)(const struct ShaderCreateInfo* ShaderCI,
235 class IShader** ppShader);
236 void (*CreateTexture)(const struct TextureDesc* TexDesc,
237 const struct TextureData* pData,
238 class ITexture** ppTexture);
239 void (*CreateSampler)(const struct SamplerDesc* SamDesc,
240 class ISampler** ppSampler);
241 void (*CreateResourceMapping)(const struct ResourceMappingDesc* MappingDesc,
242 class IResourceMapping** ppMapping);
243 void (*CreatePipelineState)(const struct PipelineStateDesc* PipelineDesc,
244 class IPipelineState** ppPipelineState);
245 void (*CreateFence)(const struct FenceDesc* Desc,
246 class IFence** ppFence);
247 void (*CreateQuery)(const struct QueryDesc* Desc,
248 class IQuery** ppQuery);
249 const struct DeviceCaps* (*GetDeviceCaps)();
250 const struct TextureFormatInfo* (*GetTextureFormatInfo)(TEXTURE_FORMAT TexFormat);
251 const struct TextureFormatInfoExt* (*GetTextureFormatInfoExt)(TEXTURE_FORMAT TexFormat);
252 void (*ReleaseStaleResources)(bool ForceRelease);
253 void (*IdleGPU)();
254 class IEngineFactory* (*GetEngineFactory)();
255 };
256
257 struct IRenderDevice
258 {
259 struct IObjectVtbl* pObjectVtbl;
260 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
261 struct IRenderDevice* pRenderDeviceVtbl;
262 };
263
264 # define IRenderDevice_CreateBuffer(This, ...) (This)->pRenderDeviceVtbl->CreateBuffer(This, __VA_ARGS__)
265 # define IRenderDevice_CreateShader(This, ...) (This)->pRenderDeviceVtbl->CreateShader(This, __VA_ARGS__)
266 # define IRenderDevice_CreateTexture(This, ...) (This)->pRenderDeviceVtbl->CreateTexture(This, __VA_ARGS__)
267 # define IRenderDevice_CreateSampler(This, ...) (This)->pRenderDeviceVtbl->CreateSampler(This, __VA_ARGS__)
268 # define IRenderDevice_CreateResourceMapping(This, ...) (This)->pRenderDeviceVtbl->CreateResourceMapping(This, __VA_ARGS__)
269 # define IRenderDevice_CreatePipelineState(This, ...) (This)->pRenderDeviceVtbl->CreatePipelineState(This, __VA_ARGS__)
270 # define IRenderDevice_CreateFence(This, ...) (This)->pRenderDeviceVtbl->CreateFence(This, __VA_ARGS__)
271 # define IRenderDevice_CreateQuery(This, ...) (This)->pRenderDeviceVtbl->CreateQuery(This, __VA_ARGS__)
272 # define IRenderDevice_GetDeviceCaps(This) (This)->pRenderDeviceVtbl->GetDeviceCaps(This)
273 # define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pRenderDeviceVtbl->GetTextureFormatInfo(This, __VA_ARGS__)
274 # define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pRenderDeviceVtbl->GetTextureFormatInfoExt(This, __VA_ARGS__)
275 # define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pRenderDeviceVtbl->ReleaseStaleResources(This, __VA_ARGS__)
276 # define IRenderDevice_IdleGPU(This) (This)->pRenderDeviceVtbl->IdleGPU(This)
277 # define IRenderDevice_GetEngineFactory(This) (This)->pRenderDeviceVtbl->GetEngineFactory(This)
231278
232279 #endif
233280
9797 class IResourceMapping : public IObject
9898 {
9999 public:
100 /// Queries the specific interface, see IObject::QueryInterface() for details
101 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
102
103100 /// Adds a resource to the mapping.
104101
105102 /// \param [in] Name - Resource name.
151148
152149 #else
153150
151 struct IResourceMapping;
152
153 struct IResourceMappingVtbl
154 {
155 void (*AddResource)(const Char* Name, class IDeviceObject* pObject, bool bIsUnique);
156 void (*AddResourceArray)(const Char* Name, Uint32 StartIndex, class IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique);
157 void (*RemoveResourceByName)(const Char* Name, Uint32 ArrayIndex);
158 void (*GetResource)(const Char* Name, class IDeviceObject** ppResource, Uint32 ArrayIndex);
159 size_t (*GetSize)();
160 };
161
162 struct IResourceMapping
163 {
164 struct IObjectVtbl* pObjectVtbl;
165 struct IResourceMapping* pResourceMappingVtbl;
166 };
167
168 # define IResourceMapping_AddResource(This, ...) (This)->pResourceMappingVtbl->AddResource(This, __VA_ARGS__)
169 # define IResourceMapping_AddResourceArray(This, ...) (This)->pResourceMappingVtbl->AddResourceArray(This, __VA_ARGS__)
170 # define IResourceMapping_RemoveResourceByName(This, ...) (This)->pResourceMappingVtbl->RemoveResourceByName(This, __VA_ARGS__)
171 # define IResourceMapping_GetResource(This, ...) (This)->pResourceMappingVtbl->GetResource(This, __VA_ARGS__)
172 # define IResourceMapping_GetSize(This) (This)->pResourceMappingVtbl->GetSize(This)
173
154174 #endif
155175
156176 DILIGENT_END_NAMESPACE // namespace Diligent
2929 /// \file
3030 /// Definition of the Diligent::ISampler interface and related data structures
3131
32 #include <cfloat>
3332 #include "DeviceObject.h"
3433
3534 DILIGENT_BEGIN_NAMESPACE(Diligent)
183182 class ISampler : public IDeviceObject
184183 {
185184 public:
186 /// Queries the specific interface, see IObject::QueryInterface() for details
187 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
188
189185 /// Returns the sampler description used to create the object
190186 virtual const SamplerDesc& GetDesc() const override = 0;
191187 };
192188
193189 #else
194190
195
191 struct ISampler;
192
193 //struct ISamplerVtbl
194 //{
195 //};
196
197 struct ISampler
198 {
199 struct IObjectVtbl* pObjectVtbl;
200 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
201 //struct ISampler* pSamplerVtbl;
202 };
203
204 # define ISampler_GetDesc(This) (const struct SamplerDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
196205
197206 #endif
198207
294294 class IShader : public IDeviceObject
295295 {
296296 public:
297 /// Queries the specific interface, see IObject::QueryInterface() for details
298 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
299
300297 /// Returns the shader description
301298 virtual const ShaderDesc& GetDesc() const override = 0;
302299
309306
310307 #else
311308
309 struct IShader;
310
311 struct IShaderVtbl
312 {
313 Uint32 (*GetResourceCount)();
314 struct ShaderResourceDesc (*GetResource)(Uint32 Index);
315 };
316
317 struct IShader
318 {
319 struct IObjectVtbl* pObjectVtbl;
320 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
321 struct IShader* pShaderVtbl;
322 };
323
324 # define IShader_GetDesc(This) (const struct ShaderDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
325
326 # define ITexture_GetResourceCount(This) (This)->pShaderVtbl->GetResourceCount(This)
327 # define ITexture_GetResource(This, ...) (This)->pShaderVtbl->GetResource(This, __VA_ARGS__)
328
312329 #endif
313330
314331 DILIGENT_END_NAMESPACE // namespace Diligent
4949 class IShaderResourceBinding : public IObject
5050 {
5151 public:
52 /// Queries the specific interface, see IObject::QueryInterface() for details
53 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
54
5552 /// Returns pointer to the referenced buffer object.
5653
5754 /// The method calls AddRef() on the returned interface,
119116
120117 #else
121118
119 class IPipelineState;
120 struct IShaderResourceBinding;
121
122 // clang-format off
123 struct IShaderResourceBindingVtbl
124 {
125 class IPipelineState* (*GetPipelineState)();
126 void (*BindResources)(Uint32 ShaderFlags, class IResourceMapping* pResMapping, Uint32 Flags);
127 class IShaderResourceVariable* (*GetVariableByName)(SHADER_TYPE ShaderType, const char* Name);
128 Uint32 (*GetVariableCount)(SHADER_TYPE ShaderType);
129 class IShaderResourceVariable* (*GetVariableByIndex)(SHADER_TYPE ShaderType, Uint32 Index);
130 void (*InitializeStaticResources)(const class IPipelineState* pPipelineState);
131 };
132 // clang-format on
133
134 struct IShaderResourceBinding
135 {
136 struct IObjectVtbl* pObjectVtbl;
137 struct IShaderResourceBinding* pShaderResourceBindingVtbl;
138 };
139
140 # define IShaderResourceBinding_GetPipelineState(This) (This)->pShaderResourceBindingVtbl->GetPipelineState(This)
141 # define IShaderResourceBinding_BindResources(This, ...) (This)->pShaderResourceBindingVtbl->BindResources(This, __VA_ARGS__)
142 # define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pShaderResourceBindingVtbl->GetVariableByName(This, __VA_ARGS__)
143 # define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pShaderResourceBindingVtbl->GetVariableCount(This, __VA_ARGS__)
144 # define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pShaderResourceBindingVtbl->GetVariableByIndex(This, __VA_ARGS__)
145 # define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pShaderResourceBindingVtbl->InitializeStaticResources(This, __VA_ARGS__)
146
122147 #endif
123148
124149 DILIGENT_END_NAMESPACE // namespace Diligent
145145
146146 #else
147147
148 struct IShaderResourceVariable;
149
150 // clang-format off
151 struct IShaderResourceVariableVtbl
152 {
153 void (*Set)(class IDeviceObject* pObject);
154 void (*SetArray)(class IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements);
155 SHADER_RESOURCE_VARIABLE_TYPE(*GetType)();
156 struct ShaderResourceDesc (*GetResourceDesc)();
157 Uint32 (*GetIndex)();
158 bool (*IsBound)(Uint32 ArrayIndex);
159 };
160 // clang-format on
161
162
163 struct IShaderResourceVariable
164 {
165 struct IObjectVtbl* pObjectVtbl;
166 struct IShaderResourceVariable* pShaderResourceVariableVtbl;
167 };
168
169 # define IShaderResourceVariable_Set(This, ...) (This)->pShaderResourceVariableVtbl->Set(This, __VA_ARGS__)
170 # define IShaderResourceVariable_SetArray(This, ...) (This)->pShaderResourceVariableVtbl->SetArray(This, __VA_ARGS__)
171 # define IShaderResourceVariable_GetType(This) (This)->pShaderResourceVariableVtbl->GetType(This)
172 # define IShaderResourceVariable_GetResourceDesc(This) (This)->pShaderResourceVariableVtbl->GetResourceDesc(This)
173 # define IShaderResourceVariable_GetIndex(This) (This)->pShaderResourceVariableVtbl->GetIndex(This)
174 # define IShaderResourceVariable_IsBound(This, ...) (This)->pShaderResourceVariableVtbl->IsBound(This, __VA_ARGS__)
175
148176 #endif
149177
150178 DILIGENT_END_NAMESPACE // namespace Diligent
9191
9292 #else
9393
94 struct ISwapChain;
95
96 struct ISwapChainVtbl
97 {
98 void (*Present)(Uint32 SyncInterval);
99 const struct SwapChainDesc* (*GetDesc)();
100 void (*Resize)(Uint32 NewWidth, Uint32 NewHeight);
101 void (*SetFullscreenMode)(const struct DisplayModeAttribs* DisplayMode);
102 void (*SetWindowedMode)();
103 struct ITextureView* (*GetCurrentBackBufferRTV)();
104 struct ITextureView* (*GetDepthBufferDSV)();
105 };
106
107 // clang-format on
108
109 struct ISwapChain
110 {
111 struct IObjectVtbl* pObjectVtbl;
112 struct ISwapChain* pSwapChainVtbl;
113 };
114
94115 #endif
95116
96117 DILIGENT_END_NAMESPACE // namespace Diligent
3232 /// Definition of the Diligent::ITexture interface and related data structures
3333
3434 #include "DeviceObject.h"
35 #include "TextureView.h"
3536
3637 DILIGENT_BEGIN_NAMESPACE(Diligent)
3738
6364 struct OptimizedClearValue
6465 {
6566 /// Format
66 enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
67 TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
6768
6869 /// Render target clear value
69 Float32 Color[4] DEFAULT_INITIALIZER({});
70 Float32 Color[4] DEFAULT_INITIALIZER({});
7071
7172 /// Depth stencil clear value
7273 struct DepthStencilClearValue DepthStencil;
8990 struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs)
9091
9192 /// Texture type. See Diligent::RESOURCE_DIMENSION for details.
92 enum RESOURCE_DIMENSION Type DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED);
93 RESOURCE_DIMENSION Type DEFAULT_INITIALIZER(RESOURCE_DIM_UNDEFINED);
9394
9495 /// Texture width, in pixels.
9596 Uint32 Width DEFAULT_INITIALIZER(0);
107108 };
108109
109110 /// Texture format, see Diligent::TEXTURE_FORMAT.
110 enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
111 TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
111112
112113 /// Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level.
113114 /// Specify 0 to create full mipmap chain.
114 Uint32 MipLevels DEFAULT_INITIALIZER(1);
115 Uint32 MipLevels DEFAULT_INITIALIZER(1);
115116
116117 /// Number of samples.\n
117118 /// Only 2D textures or 2D texture arrays can be multisampled.
118 Uint32 SampleCount DEFAULT_INITIALIZER(1);
119 Uint32 SampleCount DEFAULT_INITIALIZER(1);
119120
120121 /// Texture usage. See Diligent::USAGE for details.
121 enum USAGE Usage DEFAULT_INITIALIZER(USAGE_DEFAULT);
122 USAGE Usage DEFAULT_INITIALIZER(USAGE_DEFAULT);
122123
123124 /// Bind flags, see Diligent::BIND_FLAGS for details. \n
124125 /// The following bind flags are allowed:
125126 /// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_RENDER_TARGET, Diligent::BIND_DEPTH_STENCIL,
126127 /// Diligent::and BIND_UNORDERED_ACCESS. \n
127128 /// Multisampled textures cannot have Diligent::BIND_UNORDERED_ACCESS flag set
128 enum BIND_FLAGS BindFlags DEFAULT_INITIALIZER(BIND_NONE);
129 BIND_FLAGS BindFlags DEFAULT_INITIALIZER(BIND_NONE);
129130
130131 /// CPU access flags or 0 if no CPU access is allowed,
131132 /// see Diligent::CPU_ACCESS_FLAGS for details.
132 enum CPU_ACCESS_FLAGS CPUAccessFlags DEFAULT_INITIALIZER(CPU_ACCESS_NONE);
133 CPU_ACCESS_FLAGS CPUAccessFlags DEFAULT_INITIALIZER(CPU_ACCESS_NONE);
133134
134135 /// Miscellaneous flags, see Diligent::MISC_TEXTURE_FLAGS for details.
135 enum MISC_TEXTURE_FLAGS MiscFlags DEFAULT_INITIALIZER(MISC_TEXTURE_FLAG_NONE);
136 MISC_TEXTURE_FLAGS MiscFlags DEFAULT_INITIALIZER(MISC_TEXTURE_FLAG_NONE);
136137
137138 /// Optimized clear value
138139 struct OptimizedClearValue ClearValue;
307308 class ITexture : public IDeviceObject
308309 {
309310 public:
310 /// Queries the specific interface, see IObject::QueryInterface() for details
311 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0;
312
313311 /// Returns the texture description used to create the object
314312 virtual const TextureDesc& GetDesc()const override = 0;
315313
366364
367365 #else
368366
367 struct ITexture;
368 struct ITextureView;
369
370 struct ITextureVtbl
371 {
372 void (*CreateView)(const struct TextureViewDesc* ViewDesc, class ITextureView** ppView);
373 class ITextureView* (*GetDefaultView)(enum TEXTURE_VIEW_TYPE ViewType);
374 void* (*GetNativeHandle)();
375 void (*SetState)(RESOURCE_STATE State);
376 RESOURCE_STATE (*GetState)();
377 };
378
379 // clang-format on
380
381 struct ITexture
382 {
383 struct IObjectVtbl* pObjectVtbl;
384 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
385 struct ITexture* pTextureVtbl;
386 };
387
388 # define ITexture_GetDesc(This) (const struct TextureDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
389
390 # define ITexture_CreateView(This, ...) (This)->pTextureVtbl->SetSampler(This, __VA_ARGS__)
391 # define ITexture_GetDefaultView(This, ...) (This)->pTextureVtbl->GetDefaultView(This, __VA_ARGS__)
392 # define ITexture_GetNativeHandle(This) (This)->pTextureVtbl->GetNativeHandle(This)
393 # define ITexture_SetState(This, ...) (This)->pTextureVtbl->SetState(This, __VA_ARGS__)
394 # define ITexture_GetState(This) (This)->pTextureVtbl->GetState(This, __VA_ARGS__)
395
369396 #endif
370397
371398 DILIGENT_END_NAMESPACE // namespace Diligent
195195 class ITextureView : public IDeviceObject
196196 {
197197 public:
198 /// Queries the specific interface, see IObject::QueryInterface() for details
199 virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0;
200
201198 /// Returns the texture view description used to create the object
202199 virtual const TextureViewDesc& GetDesc() const override = 0;
203200
223220
224221 #else
225222
223 struct ITextureView;
224 struct ISampler;
225
226 struct ITextureViewVtbl
227 {
228 void (*SetSampler)(class ISampler* pSampler);
229 class ISampler* (*GetSampler)();
230 class ITexture* (*GetTexture)();
231 };
232
233 // clang-format on
234
235 struct ITextureView
236 {
237 struct IObjectVtbl* pObjectVtbl;
238 struct IDeviceObjectVtbl* pDeviceObjectVtbl;
239 struct ITextureView* pTextureViewVtbl;
240 };
241
242 # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)(This)->pDeviceObjectVtbl->GetDesc(This)
243
244 # define ITextureView_SetSampler(This) (This)->pTextureViewVtbl->SetSampler(This)
245 # define ITextureView_GetSampler(This) (This)->pTextureViewVtbl->GetSampler(This)
246 # define ITextureView_GetTexture(This) (This)->pTextureViewVtbl->GetTexture(This)
247
226248 #endif
227249
228250 DILIGENT_END_NAMESPACE
4040 class IObject
4141 {
4242 public:
43 using CounterValueType = IReferenceCounters::CounterValueType;
44
4543 /// Queries the specific interface.
4644
4745 /// \param [in] IID - Unique identifier of the requested interface.
5957 /// \return The number of strong references after incrementing the counter.
6058 /// \note In a multithreaded environment, the returned number may not be reliable
6159 /// as other threads may simultaneously change the actual value of the counter.
62 virtual CounterValueType AddRef() = 0;
60 virtual ReferenceCounterValueType AddRef() = 0;
6361
6462
6563 /// Decrements the number of strong references by 1 and destroys the object when the
7270 /// as other threads may simultaneously change the actual value of the counter.
7371 /// The only reliable value is 0 as the object is destroyed when the last
7472 /// strong reference is released.
75 virtual CounterValueType Release() = 0;
73 virtual ReferenceCounterValueType Release() = 0;
7674
7775
7876 /// Returns the pointer to IReferenceCounters interface of the associated
8381
8482 #else
8583
84 struct IObject;
85
86 struct IObjectVtbl
87 {
88 void (*QueryInterface)(const struct INTERFACE_ID* IID, struct IObject** ppInterface);
89 ReferenceCounterValueType (*AddRef)();
90 ReferenceCounterValueType (*Release)();
91 class IReferenceCounters* (*GetReferenceCounters)();
92 };
93
94 struct IObject
95 {
96 struct IObjectVtbl* pObjectVtbl;
97 struct IObjectVtbl* pDeviceObjectVtbl;
98 };
99
100 # define IObject_QueryInterface(This, ...) (This)->pDeviceObjectVtbl->QueryInterface(This, __VA_ARGS__)
101 # define IObject_AddRef(This, ...) (This)->pDeviceObjectVtbl->AddRef(This, __VA_ARGS__)
102 # define IObject_Release(This) (This)->pDeviceObjectVtbl->Release()
103
86104 #endif
87105
88106 DILIGENT_END_NAMESPACE // namespace Diligent
3333
3434 DILIGENT_BEGIN_NAMESPACE(Diligent)
3535
36 typedef long ReferenceCounterValueType;
37
3638 #if DILIGENT_CPP_INTERFACE
3739
3840 /// Base interface for a reference counter object that stores the number of strong and
4143 class IReferenceCounters
4244 {
4345 public:
44 using CounterValueType = long;
45
4646 /// Increments the number of strong references by 1.
4747
4848 /// \return The number of strong references after incrementing the counter.
4949 /// \remark The method is thread-safe and does not require explicit synchronization.
5050 /// \note In a multithreaded environment, the returned number may not be reliable
5151 /// as other threads may simultaneously change the actual value of the counter.
52 virtual CounterValueType AddStrongRef() = 0;
52 virtual ReferenceCounterValueType AddStrongRef() = 0;
5353
5454
5555 /// Decrements the number of strong references by 1 and destroys the referenced object
6565 /// as other threads may simultaneously change the actual value of the counter.
6666 /// The only reliable value is 0 as the object is destroyed when the last
6767 /// strong reference is released.
68 virtual CounterValueType ReleaseStrongRef() = 0;
68 virtual ReferenceCounterValueType ReleaseStrongRef() = 0;
6969
7070
7171 /// Increments the number of weak references by 1.
7474 /// \remark The method is thread-safe and does not require explicit synchronization.
7575 /// \note In a multithreaded environment, the returned number may not be reliable
7676 /// as other threads may simultaneously change the actual value of the counter.
77 virtual CounterValueType AddWeakRef() = 0;
77 virtual ReferenceCounterValueType AddWeakRef() = 0;
7878
7979
8080 /// Decrements the number of weak references by 1. If there are no more strong and weak
8484 /// \remark The method is thread-safe and does not require explicit synchronization.
8585 /// \note In a multithreaded environment, the returned number may not be reliable
8686 /// as other threads may simultaneously change the actual value of the counter.
87 virtual CounterValueType ReleaseWeakRef() = 0;
87 virtual ReferenceCounterValueType ReleaseWeakRef() = 0;
8888
8989
9090 /// Gets the pointer to the IUnknown interface of the referenced object.
106106 /// as other threads may simultaneously change the actual value of the counter.
107107 /// The only reliable value is 0 as the object is destroyed when the last
108108 /// strong reference is released.
109 virtual CounterValueType GetNumStrongRefs() const = 0;
109 virtual ReferenceCounterValueType GetNumStrongRefs() const = 0;
110110
111111
112112 /// Returns the number of outstanding weak references.
114114 /// \return The number of weak references.
115115 /// \note In a multithreaded environment, the returned number may not be reliable
116116 /// as other threads may simultaneously change the actual value of the counter.
117 virtual CounterValueType GetNumWeakRefs() const = 0;
117 virtual ReferenceCounterValueType GetNumWeakRefs() const = 0;
118118 };
119119
120120 #else