c inteface: implemented core object VTBLs
assiduous
3 years ago
43 | 43 | class RefCountersImpl final : public IReferenceCounters |
44 | 44 | { |
45 | 45 | public: |
46 | inline virtual CounterValueType AddStrongRef() override final | |
46 | inline virtual ReferenceCounterValueType AddStrongRef() override final | |
47 | 47 | { |
48 | 48 | VERIFY(m_ObjectState == ObjectState::Alive, "Attempting to increment strong reference counter for a destroyed or not itialized object!"); |
49 | 49 | VERIFY(m_ObjectWrapperBuffer[0] != 0 && m_ObjectWrapperBuffer[1] != 0, "Object wrapper is not initialized"); |
51 | 51 | } |
52 | 52 | |
53 | 53 | template <class TPreObjectDestroy> |
54 | inline CounterValueType ReleaseStrongRef(TPreObjectDestroy PreObjectDestroy) | |
54 | inline ReferenceCounterValueType ReleaseStrongRef(TPreObjectDestroy PreObjectDestroy) | |
55 | 55 | { |
56 | 56 | VERIFY(m_ObjectState == ObjectState::Alive, "Attempting to decrement strong reference counter for an object that is not alive"); |
57 | 57 | VERIFY(m_ObjectWrapperBuffer[0] != 0 && m_ObjectWrapperBuffer[1] != 0, "Object wrapper is not initialized"); |
68 | 68 | return RefCount; |
69 | 69 | } |
70 | 70 | |
71 | inline virtual CounterValueType ReleaseStrongRef() override final | |
71 | inline virtual ReferenceCounterValueType ReleaseStrongRef() override final | |
72 | 72 | { |
73 | 73 | return ReleaseStrongRef([]() {}); |
74 | 74 | } |
75 | 75 | |
76 | inline virtual CounterValueType AddWeakRef() override final | |
76 | inline virtual ReferenceCounterValueType AddWeakRef() override final | |
77 | 77 | { |
78 | 78 | return Atomics::AtomicIncrement(m_lNumWeakReferences); |
79 | 79 | } |
80 | 80 | |
81 | inline virtual CounterValueType ReleaseWeakRef() override final | |
81 | inline virtual ReferenceCounterValueType ReleaseWeakRef() override final | |
82 | 82 | { |
83 | 83 | // The method must be serialized! |
84 | 84 | ThreadingTools::LockHelper Lock(m_LockFlag); |
201 | 201 | Atomics::AtomicDecrement(m_lNumStrongReferences); |
202 | 202 | } |
203 | 203 | |
204 | inline virtual CounterValueType GetNumStrongRefs() const override final | |
204 | inline virtual ReferenceCounterValueType GetNumStrongRefs() const override final | |
205 | 205 | { |
206 | 206 | return m_lNumStrongReferences; |
207 | 207 | } |
208 | 208 | |
209 | inline virtual CounterValueType GetNumWeakRefs() const override final | |
209 | inline virtual ReferenceCounterValueType GetNumWeakRefs() const override final | |
210 | 210 | { |
211 | 211 | return m_lNumWeakReferences; |
212 | 212 | } |
488 | 488 | class RefCountedObject : public Base |
489 | 489 | { |
490 | 490 | public: |
491 | using CounterValueType = IReferenceCounters::CounterValueType; | |
492 | ||
493 | 491 | template <typename... BaseCtorArgTypes> |
494 | 492 | RefCountedObject(IReferenceCounters* pRefCounters, BaseCtorArgTypes&&... BaseCtorArgs) noexcept : |
495 | 493 | // clang-format off |
532 | 530 | return m_pRefCounters; |
533 | 531 | } |
534 | 532 | |
535 | inline virtual CounterValueType AddRef() override final | |
533 | inline virtual ReferenceCounterValueType AddRef() override final | |
536 | 534 | { |
537 | 535 | VERIFY_EXPR(m_pRefCounters != nullptr); |
538 | 536 | // Since type of m_pRefCounters is RefCountersImpl, |
540 | 538 | return m_pRefCounters->AddStrongRef(); |
541 | 539 | } |
542 | 540 | |
543 | inline virtual CounterValueType Release() override | |
541 | inline virtual ReferenceCounterValueType Release() override | |
544 | 542 | { |
545 | 543 | VERIFY_EXPR(m_pRefCounters != nullptr); |
546 | 544 | // Since type of m_pRefCounters is RefCountersImpl, |
549 | 547 | } |
550 | 548 | |
551 | 549 | template <class TPreObjectDestroy> |
552 | inline CounterValueType Release(TPreObjectDestroy PreObjectDestroy) | |
550 | inline ReferenceCounterValueType Release(TPreObjectDestroy PreObjectDestroy) | |
553 | 551 | { |
554 | 552 | VERIFY_EXPR(m_pRefCounters != nullptr); |
555 | 553 | return m_pRefCounters->ReleaseStrongRef(PreObjectDestroy); |
47 | 47 | class EngineFactoryBase : public BaseInterface |
48 | 48 | { |
49 | 49 | public: |
50 | using CounterValueType = IReferenceCounters::CounterValueType; | |
51 | ||
52 | 50 | EngineFactoryBase(const INTERFACE_ID& FactoryIID) noexcept : |
53 | 51 | // clang-format off |
54 | 52 | m_FactoryIID {FactoryIID}, |
70 | 68 | } |
71 | 69 | } |
72 | 70 | |
73 | virtual CounterValueType AddRef() override final | |
71 | virtual ReferenceCounterValueType AddRef() override final | |
74 | 72 | { |
75 | 73 | return m_RefCounters.AddStrongRef(); |
76 | 74 | } |
77 | 75 | |
78 | virtual CounterValueType Release() override final | |
76 | virtual ReferenceCounterValueType Release() override final | |
79 | 77 | { |
80 | 78 | return m_RefCounters.ReleaseStrongRef(); |
81 | 79 | } |
107 | 105 | m_lNumWeakReferences = 0; |
108 | 106 | } |
109 | 107 | |
110 | using IReferenceCounters::CounterValueType; | |
111 | virtual CounterValueType AddStrongRef() override final | |
108 | virtual ReferenceCounterValueType AddStrongRef() override final | |
112 | 109 | { |
113 | 110 | return Atomics::AtomicIncrement(m_lNumStrongReferences); |
114 | 111 | } |
115 | 112 | |
116 | virtual CounterValueType ReleaseStrongRef() override final | |
113 | virtual ReferenceCounterValueType ReleaseStrongRef() override final | |
117 | 114 | { |
118 | 115 | return Atomics::AtomicDecrement(m_lNumStrongReferences); |
119 | 116 | } |
120 | 117 | |
121 | virtual CounterValueType AddWeakRef() override final | |
118 | virtual ReferenceCounterValueType AddWeakRef() override final | |
122 | 119 | { |
123 | 120 | return Atomics::AtomicIncrement(m_lNumWeakReferences); |
124 | 121 | } |
125 | 122 | |
126 | virtual CounterValueType ReleaseWeakRef() override final | |
123 | virtual ReferenceCounterValueType ReleaseWeakRef() override final | |
127 | 124 | { |
128 | 125 | return Atomics::AtomicDecrement(m_lNumWeakReferences); |
129 | 126 | } |
134 | 131 | m_Factory.QueryInterface(IID_Unknown, ppObject); |
135 | 132 | } |
136 | 133 | |
137 | virtual CounterValueType GetNumStrongRefs() const override final | |
134 | virtual ReferenceCounterValueType GetNumStrongRefs() const override final | |
138 | 135 | { |
139 | 136 | return m_lNumStrongReferences; |
140 | 137 | } |
141 | 138 | |
142 | virtual CounterValueType GetNumWeakRefs() const override final | |
139 | virtual ReferenceCounterValueType GetNumWeakRefs() const override final | |
143 | 140 | { |
144 | 141 | return m_lNumWeakReferences; |
145 | 142 | } |
312 | 312 | |
313 | 313 | // It is important to have final implementation of Release() method to avoid |
314 | 314 | // virtual calls |
315 | inline virtual IReferenceCounters::CounterValueType Release() override final | |
315 | inline virtual ReferenceCounterValueType Release() override final | |
316 | 316 | { |
317 | 317 | return TObjectBase::Release(); |
318 | 318 | } |
32 | 32 | /// Defines Diligent::IBuffer interface and related data structures |
33 | 33 | |
34 | 34 | #include "DeviceObject.h" |
35 | #include "BufferView.h" | |
35 | 36 | |
36 | 37 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
37 | 38 | |
178 | 179 | class IBuffer : public IDeviceObject |
179 | 180 | { |
180 | 181 | public: |
181 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
182 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
183 | ||
184 | 182 | /// Returns the buffer description used to create the object |
185 | 183 | virtual const BufferDesc& GetDesc() const override = 0; |
186 | 184 | |
231 | 229 | |
232 | 230 | #else |
233 | 231 | |
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 | ||
234 | 258 | #endif |
235 | 259 | |
236 | 260 | DILIGENT_END_NAMESPACE // namespace Diligent |
31 | 31 | /// \file |
32 | 32 | /// Definition of the Diligent::IBufferView interface and related data structures |
33 | 33 | |
34 | #include "Buffer.h" | |
34 | #include "DeviceObject.h" | |
35 | 35 | |
36 | 36 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
37 | 37 | |
148 | 148 | class IBufferView : public IDeviceObject |
149 | 149 | { |
150 | 150 | public: |
151 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
152 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
153 | ||
154 | 151 | /// Returns the buffer view description used to create the object |
155 | 152 | virtual const BufferViewDesc& GetDesc() const override = 0; |
156 | 153 | |
158 | 155 | |
159 | 156 | /// The method does *NOT* call AddRef() on the returned interface, |
160 | 157 | /// so Release() must not be called. |
161 | virtual IBuffer* GetBuffer() = 0; | |
158 | virtual class IBuffer* GetBuffer() = 0; | |
162 | 159 | }; |
163 | 160 | |
164 | 161 | #else |
165 | 162 | |
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 | ||
166 | 182 | #endif |
167 | 183 | |
168 | 184 | DILIGENT_END_NAMESPACE // namespace Diligent |
50 | 50 | |
51 | 51 | #else |
52 | 52 | |
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 | ||
53 | 67 | #endif |
54 | 68 | |
55 | 69 | DILIGENT_END_NAMESPACE // namespace Diligent |
559 | 559 | const struct Box* pSrcBox DEFAULT_INITIALIZER(nullptr); |
560 | 560 | |
561 | 561 | /// 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); | |
563 | 563 | |
564 | 564 | /// Destination texture. |
565 | 565 | class ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr); |
611 | 611 | class IDeviceContext : public IObject |
612 | 612 | { |
613 | 613 | public: |
614 | /// Queries the specific interface, see IObject::QueryInterface() for details. | |
615 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0; | |
616 | ||
617 | 614 | /// Sets the pipeline state. |
618 | 615 | |
619 | 616 | /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context. |
1250 | 1247 | |
1251 | 1248 | #else |
1252 | 1249 | |
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__) | |
1254 | 1378 | |
1255 | 1379 | #endif |
1256 | 1380 |
45 | 45 | class IDeviceObject : public IObject |
46 | 46 | { |
47 | 47 | 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 | ||
52 | 48 | /// Returns the object description |
53 | 49 | virtual const DeviceObjectAttribs& GetDesc() const = 0; |
54 | 50 | |
74 | 70 | |
75 | 71 | #else |
76 | 72 | |
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 | ||
77 | 90 | #endif |
78 | 91 | |
79 | 92 | DILIGENT_END_NAMESPACE // namespace Diligent |
55 | 55 | class IFence : public IDeviceObject |
56 | 56 | { |
57 | 57 | public: |
58 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
59 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
60 | ||
61 | 58 | /// Returns the fence description used to create the object |
62 | 59 | virtual const FenceDesc& GetDesc() const override = 0; |
63 | 60 | |
74 | 71 | |
75 | 72 | #else |
76 | 73 | |
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 | ||
77 | 94 | #endif |
78 | 95 | |
79 | 96 | DILIGENT_END_NAMESPACE // namespace Diligent |
252 | 252 | class IPipelineState : public IDeviceObject |
253 | 253 | { |
254 | 254 | 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 | ||
259 | 255 | /// Returns the blend state description used to create the object |
260 | 256 | virtual const PipelineStateDesc& GetDesc()const override = 0; |
261 | 257 | |
330 | 326 | |
331 | 327 | #else |
332 | 328 | |
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 | ||
333 | 360 | #endif |
334 | 361 | |
335 | 362 | DILIGENT_END_NAMESPACE |
177 | 177 | class IQuery : public IDeviceObject |
178 | 178 | { |
179 | 179 | public: |
180 | /// Queries the specific interface, see IObject::QueryInterface() for details. | |
181 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
182 | ||
183 | 180 | /// Returns the Query description used to create the object. |
184 | 181 | virtual const QueryDesc& GetDesc() const override = 0; |
185 | 182 | |
211 | 208 | |
212 | 209 | #else |
213 | 210 | |
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 | ||
214 | 231 | #endif |
215 | 232 | |
216 | 233 | DILIGENT_END_NAMESPACE // namespace Diligent |
62 | 62 | class IRenderDevice : public IObject |
63 | 63 | { |
64 | 64 | public: |
65 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
66 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
67 | ||
68 | 65 | /// Creates a new buffer object |
69 | 66 | |
70 | 67 | /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details. |
227 | 224 | |
228 | 225 | #else |
229 | 226 | |
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) | |
231 | 278 | |
232 | 279 | #endif |
233 | 280 |
97 | 97 | class IResourceMapping : public IObject |
98 | 98 | { |
99 | 99 | public: |
100 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
101 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
102 | ||
103 | 100 | /// Adds a resource to the mapping. |
104 | 101 | |
105 | 102 | /// \param [in] Name - Resource name. |
151 | 148 | |
152 | 149 | #else |
153 | 150 | |
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 | ||
154 | 174 | #endif |
155 | 175 | |
156 | 176 | DILIGENT_END_NAMESPACE // namespace Diligent |
29 | 29 | /// \file |
30 | 30 | /// Definition of the Diligent::ISampler interface and related data structures |
31 | 31 | |
32 | #include <cfloat> | |
33 | 32 | #include "DeviceObject.h" |
34 | 33 | |
35 | 34 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
183 | 182 | class ISampler : public IDeviceObject |
184 | 183 | { |
185 | 184 | public: |
186 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
187 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
188 | ||
189 | 185 | /// Returns the sampler description used to create the object |
190 | 186 | virtual const SamplerDesc& GetDesc() const override = 0; |
191 | 187 | }; |
192 | 188 | |
193 | 189 | #else |
194 | 190 | |
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) | |
196 | 205 | |
197 | 206 | #endif |
198 | 207 |
294 | 294 | class IShader : public IDeviceObject |
295 | 295 | { |
296 | 296 | public: |
297 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
298 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
299 | ||
300 | 297 | /// Returns the shader description |
301 | 298 | virtual const ShaderDesc& GetDesc() const override = 0; |
302 | 299 | |
309 | 306 | |
310 | 307 | #else |
311 | 308 | |
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 | ||
312 | 329 | #endif |
313 | 330 | |
314 | 331 | DILIGENT_END_NAMESPACE // namespace Diligent |
49 | 49 | class IShaderResourceBinding : public IObject |
50 | 50 | { |
51 | 51 | public: |
52 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
53 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
54 | ||
55 | 52 | /// Returns pointer to the referenced buffer object. |
56 | 53 | |
57 | 54 | /// The method calls AddRef() on the returned interface, |
119 | 116 | |
120 | 117 | #else |
121 | 118 | |
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 | ||
122 | 147 | #endif |
123 | 148 | |
124 | 149 | DILIGENT_END_NAMESPACE // namespace Diligent |
145 | 145 | |
146 | 146 | #else |
147 | 147 | |
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 | ||
148 | 176 | #endif |
149 | 177 | |
150 | 178 | DILIGENT_END_NAMESPACE // namespace Diligent |
91 | 91 | |
92 | 92 | #else |
93 | 93 | |
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 | ||
94 | 115 | #endif |
95 | 116 | |
96 | 117 | DILIGENT_END_NAMESPACE // namespace Diligent |
32 | 32 | /// Definition of the Diligent::ITexture interface and related data structures |
33 | 33 | |
34 | 34 | #include "DeviceObject.h" |
35 | #include "TextureView.h" | |
35 | 36 | |
36 | 37 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
37 | 38 | |
63 | 64 | struct OptimizedClearValue |
64 | 65 | { |
65 | 66 | /// Format |
66 | enum TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
67 | TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); | |
67 | 68 | |
68 | 69 | /// Render target clear value |
69 | Float32 Color[4] DEFAULT_INITIALIZER({}); | |
70 | Float32 Color[4] DEFAULT_INITIALIZER({}); | |
70 | 71 | |
71 | 72 | /// Depth stencil clear value |
72 | 73 | struct DepthStencilClearValue DepthStencil; |
89 | 90 | struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs) |
90 | 91 | |
91 | 92 | /// 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); | |
93 | 94 | |
94 | 95 | /// Texture width, in pixels. |
95 | 96 | Uint32 Width DEFAULT_INITIALIZER(0); |
107 | 108 | }; |
108 | 109 | |
109 | 110 | /// 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); | |
111 | 112 | |
112 | 113 | /// Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level. |
113 | 114 | /// Specify 0 to create full mipmap chain. |
114 | Uint32 MipLevels DEFAULT_INITIALIZER(1); | |
115 | Uint32 MipLevels DEFAULT_INITIALIZER(1); | |
115 | 116 | |
116 | 117 | /// Number of samples.\n |
117 | 118 | /// Only 2D textures or 2D texture arrays can be multisampled. |
118 | Uint32 SampleCount DEFAULT_INITIALIZER(1); | |
119 | Uint32 SampleCount DEFAULT_INITIALIZER(1); | |
119 | 120 | |
120 | 121 | /// Texture usage. See Diligent::USAGE for details. |
121 | enum USAGE Usage DEFAULT_INITIALIZER(USAGE_DEFAULT); | |
122 | USAGE Usage DEFAULT_INITIALIZER(USAGE_DEFAULT); | |
122 | 123 | |
123 | 124 | /// Bind flags, see Diligent::BIND_FLAGS for details. \n |
124 | 125 | /// The following bind flags are allowed: |
125 | 126 | /// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_RENDER_TARGET, Diligent::BIND_DEPTH_STENCIL, |
126 | 127 | /// Diligent::and BIND_UNORDERED_ACCESS. \n |
127 | 128 | /// 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); | |
129 | 130 | |
130 | 131 | /// CPU access flags or 0 if no CPU access is allowed, |
131 | 132 | /// 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); | |
133 | 134 | |
134 | 135 | /// 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); | |
136 | 137 | |
137 | 138 | /// Optimized clear value |
138 | 139 | struct OptimizedClearValue ClearValue; |
307 | 308 | class ITexture : public IDeviceObject |
308 | 309 | { |
309 | 310 | public: |
310 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
311 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override = 0; | |
312 | ||
313 | 311 | /// Returns the texture description used to create the object |
314 | 312 | virtual const TextureDesc& GetDesc()const override = 0; |
315 | 313 | |
366 | 364 | |
367 | 365 | #else |
368 | 366 | |
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 | ||
369 | 396 | #endif |
370 | 397 | |
371 | 398 | DILIGENT_END_NAMESPACE // namespace Diligent |
195 | 195 | class ITextureView : public IDeviceObject |
196 | 196 | { |
197 | 197 | public: |
198 | /// Queries the specific interface, see IObject::QueryInterface() for details | |
199 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override = 0; | |
200 | ||
201 | 198 | /// Returns the texture view description used to create the object |
202 | 199 | virtual const TextureViewDesc& GetDesc() const override = 0; |
203 | 200 | |
223 | 220 | |
224 | 221 | #else |
225 | 222 | |
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 | ||
226 | 248 | #endif |
227 | 249 | |
228 | 250 | DILIGENT_END_NAMESPACE |
40 | 40 | class IObject |
41 | 41 | { |
42 | 42 | public: |
43 | using CounterValueType = IReferenceCounters::CounterValueType; | |
44 | ||
45 | 43 | /// Queries the specific interface. |
46 | 44 | |
47 | 45 | /// \param [in] IID - Unique identifier of the requested interface. |
59 | 57 | /// \return The number of strong references after incrementing the counter. |
60 | 58 | /// \note In a multithreaded environment, the returned number may not be reliable |
61 | 59 | /// as other threads may simultaneously change the actual value of the counter. |
62 | virtual CounterValueType AddRef() = 0; | |
60 | virtual ReferenceCounterValueType AddRef() = 0; | |
63 | 61 | |
64 | 62 | |
65 | 63 | /// Decrements the number of strong references by 1 and destroys the object when the |
72 | 70 | /// as other threads may simultaneously change the actual value of the counter. |
73 | 71 | /// The only reliable value is 0 as the object is destroyed when the last |
74 | 72 | /// strong reference is released. |
75 | virtual CounterValueType Release() = 0; | |
73 | virtual ReferenceCounterValueType Release() = 0; | |
76 | 74 | |
77 | 75 | |
78 | 76 | /// Returns the pointer to IReferenceCounters interface of the associated |
83 | 81 | |
84 | 82 | #else |
85 | 83 | |
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 | ||
86 | 104 | #endif |
87 | 105 | |
88 | 106 | DILIGENT_END_NAMESPACE // namespace Diligent |
33 | 33 | |
34 | 34 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
35 | 35 | |
36 | typedef long ReferenceCounterValueType; | |
37 | ||
36 | 38 | #if DILIGENT_CPP_INTERFACE |
37 | 39 | |
38 | 40 | /// Base interface for a reference counter object that stores the number of strong and |
41 | 43 | class IReferenceCounters |
42 | 44 | { |
43 | 45 | public: |
44 | using CounterValueType = long; | |
45 | ||
46 | 46 | /// Increments the number of strong references by 1. |
47 | 47 | |
48 | 48 | /// \return The number of strong references after incrementing the counter. |
49 | 49 | /// \remark The method is thread-safe and does not require explicit synchronization. |
50 | 50 | /// \note In a multithreaded environment, the returned number may not be reliable |
51 | 51 | /// as other threads may simultaneously change the actual value of the counter. |
52 | virtual CounterValueType AddStrongRef() = 0; | |
52 | virtual ReferenceCounterValueType AddStrongRef() = 0; | |
53 | 53 | |
54 | 54 | |
55 | 55 | /// Decrements the number of strong references by 1 and destroys the referenced object |
65 | 65 | /// as other threads may simultaneously change the actual value of the counter. |
66 | 66 | /// The only reliable value is 0 as the object is destroyed when the last |
67 | 67 | /// strong reference is released. |
68 | virtual CounterValueType ReleaseStrongRef() = 0; | |
68 | virtual ReferenceCounterValueType ReleaseStrongRef() = 0; | |
69 | 69 | |
70 | 70 | |
71 | 71 | /// Increments the number of weak references by 1. |
74 | 74 | /// \remark The method is thread-safe and does not require explicit synchronization. |
75 | 75 | /// \note In a multithreaded environment, the returned number may not be reliable |
76 | 76 | /// as other threads may simultaneously change the actual value of the counter. |
77 | virtual CounterValueType AddWeakRef() = 0; | |
77 | virtual ReferenceCounterValueType AddWeakRef() = 0; | |
78 | 78 | |
79 | 79 | |
80 | 80 | /// Decrements the number of weak references by 1. If there are no more strong and weak |
84 | 84 | /// \remark The method is thread-safe and does not require explicit synchronization. |
85 | 85 | /// \note In a multithreaded environment, the returned number may not be reliable |
86 | 86 | /// as other threads may simultaneously change the actual value of the counter. |
87 | virtual CounterValueType ReleaseWeakRef() = 0; | |
87 | virtual ReferenceCounterValueType ReleaseWeakRef() = 0; | |
88 | 88 | |
89 | 89 | |
90 | 90 | /// Gets the pointer to the IUnknown interface of the referenced object. |
106 | 106 | /// as other threads may simultaneously change the actual value of the counter. |
107 | 107 | /// The only reliable value is 0 as the object is destroyed when the last |
108 | 108 | /// strong reference is released. |
109 | virtual CounterValueType GetNumStrongRefs() const = 0; | |
109 | virtual ReferenceCounterValueType GetNumStrongRefs() const = 0; | |
110 | 110 | |
111 | 111 | |
112 | 112 | /// Returns the number of outstanding weak references. |
114 | 114 | /// \return The number of weak references. |
115 | 115 | /// \note In a multithreaded environment, the returned number may not be reliable |
116 | 116 | /// as other threads may simultaneously change the actual value of the counter. |
117 | virtual CounterValueType GetNumWeakRefs() const = 0; | |
117 | virtual ReferenceCounterValueType GetNumWeakRefs() const = 0; | |
118 | 118 | }; |
119 | 119 | |
120 | 120 | #else |