Reworked C interfaces to share declaration with c++
assiduous
3 years ago
50 | 50 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override; |
51 | 51 | |
52 | 52 | /// Reads data from the stream |
53 | virtual void Read(IDataBlob* pData) override; | |
53 | virtual void ReadBlob(IDataBlob* pData) override; | |
54 | 54 | |
55 | 55 | /// Reads data from the stream |
56 | 56 | virtual bool Read(void* Data, size_t Size) override; |
50 | 50 | virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override; |
51 | 51 | |
52 | 52 | /// Reads data from the stream |
53 | virtual void Read(IDataBlob* pData) override; | |
53 | virtual void ReadBlob(IDataBlob* pData) override; | |
54 | 54 | |
55 | 55 | /// Reads data from the stream |
56 | 56 | virtual bool Read(void* Data, size_t Size) override; |
150 | 150 | return NumWeakReferences; |
151 | 151 | } |
152 | 152 | |
153 | inline virtual void GetObject(class IObject** ppObject) override final | |
153 | inline virtual void GetObject(struct IObject** ppObject) override final | |
154 | 154 | { |
155 | 155 | if (m_ObjectState != ObjectState::Alive) |
156 | 156 | return; // Early exit |
45 | 45 | return m_FileWrpr->Read(Data, Size); |
46 | 46 | } |
47 | 47 | |
48 | void BasicFileStream::Read(Diligent::IDataBlob* pData) | |
48 | void BasicFileStream::ReadBlob(Diligent::IDataBlob* pData) | |
49 | 49 | { |
50 | 50 | return m_FileWrpr->Read(pData); |
51 | 51 | } |
52 | 52 | return Size == BytesToRead; |
53 | 53 | } |
54 | 54 | |
55 | void MemoryFileStream::Read(IDataBlob* pData) | |
55 | void MemoryFileStream::ReadBlob(IDataBlob* pData) | |
56 | 56 | { |
57 | 57 | auto BytesLeft = m_DataBlob->GetSize() - m_CurrentOffset; |
58 | 58 | pData->Resize(BytesLeft); |
296 | 296 | if (pSourceStream == nullptr) |
297 | 297 | LOG_ERROR_AND_THROW("Failed to open shader source file"); |
298 | 298 | |
299 | pSourceStream->Read(pFileData); | |
299 | pSourceStream->ReadBlob(pFileData); | |
300 | 300 | ShaderSource = reinterpret_cast<char*>(pFileData->GetDataPtr()); |
301 | 301 | SourceLen = pFileData->GetSize(); |
302 | 302 | } |
393 | 393 | } |
394 | 394 | |
395 | 395 | RefCntAutoPtr<IDataBlob> pFileData(MakeNewRCObj<DataBlobImpl>()(0)); |
396 | pSourceStream->Read(pFileData); | |
396 | pSourceStream->ReadBlob(pFileData); | |
397 | 397 | auto* pNewInclude = |
398 | 398 | new IncludeResult{ |
399 | 399 | headerName, |
461 | 461 | if (pSourceStream == nullptr) |
462 | 462 | LOG_ERROR_AND_THROW("Failed to open shader source file"); |
463 | 463 | |
464 | pSourceStream->Read(pFileData); | |
464 | pSourceStream->ReadBlob(pFileData); | |
465 | 465 | SourceCode = reinterpret_cast<char*>(pFileData->GetDataPtr()); |
466 | 466 | SourceCodeLen = static_cast<int>(pFileData->GetSize()); |
467 | 467 | } |
34 | 34 | /// Creates default shader source stream factory |
35 | 35 | /// \param [in] SearchDirectories - Semicolon-seprated list of search directories. |
36 | 36 | /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. |
37 | void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, | |
38 | class IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory); | |
37 | void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, | |
38 | IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory); | |
39 | 39 | |
40 | 40 | DILIGENT_END_NAMESPACE // namespace Diligent |
97 | 97 | size_t MappedTextureSubresourceSize DEFAULT_INITIALIZER(0); |
98 | 98 | size_t TextureViewDescSize DEFAULT_INITIALIZER(0); |
99 | 99 | }; |
100 | typedef struct APIInfo APIInfo; | |
100 | 101 | |
101 | 102 | DILIGENT_END_NAMESPACE // namespace Diligent |
361 | 361 | } |
362 | 362 | #endif |
363 | 363 | }; |
364 | typedef struct RenderTargetBlendDesc RenderTargetBlendDesc; | |
364 | 365 | |
365 | 366 | |
366 | 367 | /// Blend state description |
378 | 379 | |
379 | 380 | /// An array of RenderTargetBlendDesc structures that describe the blend |
380 | 381 | /// states for render targets |
381 | struct RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS]; | |
382 | RenderTargetBlendDesc RenderTargets[DILIGENT_MAX_RENDER_TARGETS]; | |
382 | 383 | |
383 | 384 | #if DILIGENT_CPP_INTERFACE |
384 | 385 | // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code: |
423 | 424 | } |
424 | 425 | #endif |
425 | 426 | }; |
427 | typedef struct BlendStateDesc BlendStateDesc; | |
426 | 428 | |
427 | 429 | DILIGENT_END_NAMESPACE // namespace Diligent |
38 | 38 | |
39 | 39 | |
40 | 40 | // {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4} |
41 | static const struct INTERFACE_ID IID_Buffer = | |
41 | static const INTERFACE_ID IID_Buffer = | |
42 | 42 | {0xec47ead3, 0xa2c4, 0x44f2, {0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4}}; |
43 | 43 | |
44 | 44 | /// Describes the buffer access mode. |
147 | 147 | } |
148 | 148 | #endif |
149 | 149 | }; |
150 | typedef struct BufferDesc BufferDesc; | |
150 | 151 | |
151 | 152 | /// Describes the buffer initial data |
152 | 153 | struct BufferData |
169 | 170 | {} |
170 | 171 | #endif |
171 | 172 | }; |
172 | ||
173 | ||
173 | typedef struct BufferData BufferData; | |
174 | ||
175 | #if DILIGENT_C_INTERFACE | |
176 | # define THIS struct IBuffer* | |
177 | # define THIS_ struct IBuffer*, | |
178 | #endif | |
179 | ||
180 | ||
181 | /// Buffer interface | |
182 | ||
183 | /// Defines the methods to manipulate a buffer object | |
184 | DILIGENT_INTERFACE(IBuffer, IDeviceObject) | |
185 | { | |
174 | 186 | #if DILIGENT_CPP_INTERFACE |
175 | ||
176 | /// Buffer interface | |
177 | ||
178 | /// Defines the methods to manipulate a buffer object | |
179 | class IBuffer : public IDeviceObject | |
180 | { | |
181 | public: | |
182 | 187 | /// Returns the buffer description used to create the object |
183 | 188 | virtual const BufferDesc& GetDesc() const override = 0; |
189 | #endif | |
184 | 190 | |
185 | 191 | /// Creates a new buffer view |
186 | 192 | |
193 | 199 | /// until all views are released.\n |
194 | 200 | /// The function calls AddRef() for the created interface, so it must be released by |
195 | 201 | /// a call to Release() when it is no longer needed. |
196 | virtual void CreateView(const struct BufferViewDesc& ViewDesc, class IBufferView** ppView) = 0; | |
202 | VIRTUAL void METHOD(CreateView)(THIS_ | |
203 | const BufferViewDesc REF ViewDesc, | |
204 | IBufferView** ppView) PURE; | |
197 | 205 | |
198 | 206 | /// Returns the pointer to the default view. |
199 | 207 | |
205 | 213 | /// |
206 | 214 | /// \note The function does not increase the reference counter for the returned interface, so |
207 | 215 | /// Release() must *NOT* be called. |
208 | virtual IBufferView* GetDefaultView(BUFFER_VIEW_TYPE ViewType) = 0; | |
216 | VIRTUAL IBufferView* METHOD(GetDefaultView)(THIS_ | |
217 | BUFFER_VIEW_TYPE ViewType) PURE; | |
209 | 218 | |
210 | 219 | /// Returns native buffer handle specific to the underlying graphics API |
211 | 220 | |
212 | 221 | /// \return pointer to ID3D11Resource interface, for D3D11 implementation\n |
213 | 222 | /// pointer to ID3D12Resource interface, for D3D12 implementation\n |
214 | 223 | /// GL buffer handle, for GL implementation |
215 | virtual void* GetNativeHandle() = 0; | |
224 | VIRTUAL void* METHOD(GetNativeHandle)(THIS) PURE; | |
216 | 225 | |
217 | 226 | /// Sets the buffer usage state. |
218 | 227 | |
221 | 230 | /// This method should be used after the application finished |
222 | 231 | /// manually managing the buffer state and wants to hand over |
223 | 232 | /// state management back to the engine. |
224 | virtual void SetState(RESOURCE_STATE State) = 0; | |
233 | VIRTUAL void METHOD(SetState)(THIS_ | |
234 | RESOURCE_STATE State) PURE; | |
225 | 235 | |
226 | 236 | /// Returns the internal buffer state |
227 | virtual RESOURCE_STATE GetState() const = 0; | |
228 | }; | |
229 | ||
230 | #else | |
231 | ||
232 | struct IBuffer; | |
233 | ||
234 | struct IBufferMethods | |
235 | { | |
236 | void (*CreateView) (struct IBuffer*, const struct BufferViewDesc* ViewDesc, class IBufferView** ppView); | |
237 | class IBufferView* (*GetDefaultView) (struct IBuffer*, BUFFER_VIEW_TYPE ViewType); | |
238 | void* (*GetNativeHandle)(struct IBuffer*); | |
239 | void (*SetState) (struct IBuffer*,RESOURCE_STATE State); | |
240 | RESOURCE_STATE (*GetState) (struct IBuffer*); | |
241 | }; | |
237 | VIRTUAL RESOURCE_STATE METHOD(GetState)(THIS) CONST PURE; | |
238 | }; | |
239 | ||
240 | #if DILIGENT_C_INTERFACE | |
241 | ||
242 | #undef THIS | |
243 | #undef THIS_ | |
242 | 244 | |
243 | 245 | // clang-format on |
244 | 246 | |
249 | 251 | struct IBufferMethods Buffer; |
250 | 252 | }; |
251 | 253 | |
252 | struct IBuffer | |
254 | typedef struct IBuffer | |
253 | 255 | { |
254 | 256 | struct IBufferVtbl* pVtbl; |
255 | }; | |
257 | } IBuffer; | |
256 | 258 | |
257 | 259 | // clang-format off |
258 | 260 | |
259 | 261 | # define IBuffer_GetDesc(This) (const struct BufferDesc*)IDeviceObject_GetDesc(This) |
260 | 262 | |
261 | # define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((struct IBuffer*)(This), __VA_ARGS__) | |
262 | # define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((struct IBuffer*)(This), __VA_ARGS__) | |
263 | # define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((struct IBuffer*)(This)) | |
264 | # define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((struct IBuffer*)(This), __VA_ARGS__) | |
265 | # define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((struct IBuffer*)(This)) | |
263 | # define IBuffer_CreateView(This, ...) (This)->pVtbl->Buffer.CreateView ((IBuffer*)(This), __VA_ARGS__) | |
264 | # define IBuffer_GetDefaultView(This, ...) (This)->pVtbl->Buffer.GetDefaultView ((IBuffer*)(This), __VA_ARGS__) | |
265 | # define IBuffer_GetNativeHandle(This) (This)->pVtbl->Buffer.GetNativeHandle((IBuffer*)(This)) | |
266 | # define IBuffer_SetState(This, ...) (This)->pVtbl->Buffer.SetState ((IBuffer*)(This), __VA_ARGS__) | |
267 | # define IBuffer_GetState(This) (This)->pVtbl->Buffer.GetState ((IBuffer*)(This)) | |
266 | 268 | |
267 | 269 | // clang-format on |
268 | 270 |
81 | 81 | } |
82 | 82 | #endif |
83 | 83 | }; |
84 | typedef struct BufferFormat BufferFormat; | |
84 | 85 | |
85 | 86 | /// Buffer view description |
86 | 87 | struct BufferViewDesc DILIGENT_DERIVE(DeviceObjectAttribs) |
135 | 136 | } |
136 | 137 | #endif |
137 | 138 | }; |
139 | typedef struct BufferViewDesc BufferViewDesc; | |
138 | 140 | |
139 | 141 | |
140 | #if DILIGENT_CPP_INTERFACE | |
142 | ||
143 | #if DILIGENT_C_INTERFACE | |
144 | # define THIS struct IBufferView* | |
145 | # define THIS_ struct IBufferView*, | |
146 | #endif | |
141 | 147 | |
142 | 148 | /// Buffer view interface |
143 | 149 | |
145 | 151 | /// \remarks |
146 | 152 | /// Buffer view holds strong references to the buffer. The buffer |
147 | 153 | /// will not be destroyed until all views are released. |
148 | class IBufferView : public IDeviceObject | |
154 | DILIGENT_INTERFACE(IBufferView, IDeviceObject) | |
149 | 155 | { |
150 | public: | |
156 | #if DILIGENT_CPP_INTERFACE | |
151 | 157 | /// Returns the buffer view description used to create the object |
152 | 158 | virtual const BufferViewDesc& GetDesc() const override = 0; |
159 | #endif | |
153 | 160 | |
154 | 161 | /// Returns pointer to the referenced buffer object. |
155 | 162 | |
156 | 163 | /// The method does *NOT* call AddRef() on the returned interface, |
157 | 164 | /// so Release() must not be called. |
158 | virtual class IBuffer* GetBuffer() = 0; | |
165 | VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) PURE; | |
159 | 166 | }; |
160 | 167 | |
161 | #else | |
168 | #if DILIGENT_C_INTERFACE | |
162 | 169 | |
163 | class IBufferView; | |
164 | class IBuffer; | |
170 | # undef THIS | |
171 | # undef THIS_ | |
165 | 172 | |
166 | struct IBufferViewMethods | |
167 | { | |
168 | class IBuffer* (*GetBuffer)(struct IBufferView*); | |
169 | }; | |
173 | // clang-format on | |
170 | 174 | |
171 | 175 | struct IBufferViewVtbl |
172 | 176 | { |
175 | 179 | struct IBufferViewMethods BufferView; |
176 | 180 | }; |
177 | 181 | |
178 | struct IBufferView | |
182 | typedef struct IBufferView | |
179 | 183 | { |
180 | 184 | struct IBufferViewVtbl* pVtbl; |
181 | }; | |
185 | } IBufferView; | |
186 | ||
187 | // clang-format off | |
182 | 188 | |
183 | 189 | # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This) |
184 | 190 | |
185 | # define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((struct IBufferView*)(This)) | |
191 | # define IBufferView_GetBuffer(This) (This)->pVtbl->BufferView.GetBuffer((IBufferView*)(This)) | |
192 | ||
193 | // clang-format on | |
186 | 194 | |
187 | 195 | #endif |
188 | 196 |
64 | 64 | //struct ICommandListMethods CommandList; |
65 | 65 | }; |
66 | 66 | |
67 | struct ICommandList | |
67 | typedef struct ICommandList | |
68 | 68 | { |
69 | 69 | struct ICommandListVtbl* pVtbl; |
70 | }; | |
70 | } ICommandList; | |
71 | 71 | |
72 | 72 | #endif |
73 | 73 |
144 | 144 | } |
145 | 145 | #endif |
146 | 146 | }; |
147 | typedef struct StencilOpDesc StencilOpDesc; | |
147 | 148 | |
148 | 149 | /// Depth stencil state description |
149 | 150 | |
179 | 180 | Uint8 StencilWriteMask DEFAULT_INITIALIZER(0xFF); |
180 | 181 | |
181 | 182 | /// Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc. |
182 | struct StencilOpDesc FrontFace; | |
183 | StencilOpDesc FrontFace; | |
183 | 184 | |
184 | 185 | /// Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc. |
185 | struct StencilOpDesc BackFace; | |
186 | StencilOpDesc BackFace; | |
186 | 187 | |
187 | 188 | |
188 | 189 | #if DILIGENT_CPP_INTERFACE |
228 | 229 | } |
229 | 230 | #endif |
230 | 231 | }; |
232 | typedef struct DepthStencilStateDesc DepthStencilStateDesc; | |
231 | 233 | |
232 | 234 | DILIGENT_END_NAMESPACE |
59 | 59 | /// Indicates if device supports MIP load bias |
60 | 60 | Bool LODBiasSupported DEFAULT_INITIALIZER(False); |
61 | 61 | }; |
62 | typedef struct SamplerCaps SamplerCaps; | |
62 | 63 | |
63 | 64 | /// Texture capabilities |
64 | 65 | struct TextureCaps |
93 | 94 | /// Indicates if device supports cubemap arrays |
94 | 95 | Bool CubemapArraysSupported DEFAULT_INITIALIZER(False); |
95 | 96 | }; |
97 | typedef struct TextureCaps TextureCaps; | |
96 | 98 | |
97 | 99 | /// Describes supported device features |
98 | 100 | struct DeviceFeatures |
162 | 164 | /// Specifies whether all the extended UAV texture formats are available in shader code. |
163 | 165 | Bool TextureUAVExtendedFormats DEFAULT_INITIALIZER(False); |
164 | 166 | }; |
167 | typedef struct DeviceFeatures DeviceFeatures; | |
165 | 168 | |
166 | 169 | /// Device capabilities |
167 | 170 | struct DeviceCaps |
183 | 186 | ADAPTER_TYPE AdaterType DEFAULT_INITIALIZER(ADAPTER_TYPE_UNKNOWN); |
184 | 187 | |
185 | 188 | /// Texture sampling capabilities. See Diligent::SamplerCaps. |
186 | struct SamplerCaps SamCaps; | |
189 | SamplerCaps SamCaps; | |
187 | 190 | |
188 | 191 | /// Texture capabilities. See Diligent::TextureCaps. |
189 | struct TextureCaps TexCaps; | |
192 | TextureCaps TexCaps; | |
190 | 193 | |
191 | 194 | /// Device features. See Diligent::DeviceFeatures. |
192 | struct DeviceFeatures Features; | |
195 | DeviceFeatures Features; | |
193 | 196 | |
194 | 197 | #if DILIGENT_CPP_INTERFACE |
195 | 198 | bool IsGLDevice()const |
249 | 252 | } |
250 | 253 | #endif |
251 | 254 | }; |
255 | typedef struct DeviceCaps DeviceCaps; | |
252 | 256 | |
253 | 257 | DILIGENT_END_NAMESPACE // namespace Diligent |
55 | 55 | |
56 | 56 | |
57 | 57 | // {DC92711B-A1BE-4319-B2BD-C662D1CC19E4} |
58 | static const struct INTERFACE_ID IID_DeviceContext = | |
58 | static const INTERFACE_ID IID_DeviceContext = | |
59 | 59 | {0xdc92711b, 0xa1be, 0x4319, {0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4}}; |
60 | 60 | |
61 | 61 | /// Draw command flags |
209 | 209 | {} |
210 | 210 | #endif |
211 | 211 | }; |
212 | typedef struct DrawAttribs DrawAttribs; | |
212 | 213 | |
213 | 214 | |
214 | 215 | /// Defines the indexed draw command attributes. |
275 | 276 | {} |
276 | 277 | #endif |
277 | 278 | }; |
278 | ||
279 | typedef struct DrawIndexedAttribs DrawIndexedAttribs; | |
279 | 280 | |
280 | 281 | /// Defines the indirect draw command attributes. |
281 | 282 | |
313 | 314 | {} |
314 | 315 | #endif |
315 | 316 | }; |
316 | ||
317 | typedef struct DrawIndirectAttribs DrawIndirectAttribs; | |
317 | 318 | |
318 | 319 | /// Defines the indexed indirect draw command attributes. |
319 | 320 | |
358 | 359 | {} |
359 | 360 | #endif |
360 | 361 | }; |
361 | ||
362 | typedef struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs; | |
362 | 363 | |
363 | 364 | /// Defines which parts of the depth-stencil buffer to clear. |
364 | 365 | |
397 | 398 | {} |
398 | 399 | #endif |
399 | 400 | }; |
401 | typedef struct DispatchComputeAttribs DispatchComputeAttribs; | |
402 | ||
400 | 403 | |
401 | 404 | /// Describes dispatch command arguments. |
402 | 405 | |
421 | 424 | {} |
422 | 425 | #endif |
423 | 426 | }; |
427 | typedef struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs; | |
424 | 428 | |
425 | 429 | |
426 | 430 | /// Describes multi-sampled texture resolve command arguments. |
451 | 455 | /// either TEX_FORMAT_UNKNOWN, or match this format. |
452 | 456 | TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); |
453 | 457 | }; |
458 | typedef struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs; | |
459 | ||
454 | 460 | |
455 | 461 | /// Defines allowed flags for IDeviceContext::SetVertexBuffers() function. |
456 | 462 | DILIGENT_TYPED_ENUM(SET_VERTEX_BUFFERS_FLAGS, Uint8) |
507 | 513 | Viewport()noexcept{} |
508 | 514 | #endif |
509 | 515 | }; |
516 | typedef struct Viewport Viewport; | |
517 | ||
510 | 518 | |
511 | 519 | /// Describes the rectangle. |
512 | 520 | |
539 | 547 | } |
540 | 548 | #endif |
541 | 549 | }; |
550 | typedef struct Rect Rect; | |
542 | 551 | |
543 | 552 | |
544 | 553 | /// Defines copy texture command attributes. |
547 | 556 | struct CopyTextureAttribs |
548 | 557 | { |
549 | 558 | /// Source texture to copy data from. |
550 | class ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr); | |
559 | ITexture* pSrcTexture DEFAULT_INITIALIZER(nullptr); | |
551 | 560 | |
552 | 561 | /// Mip level of the source texture to copy data from. |
553 | 562 | Uint32 SrcMipLevel DEFAULT_INITIALIZER(0); |
556 | 565 | Uint32 SrcSlice DEFAULT_INITIALIZER(0); |
557 | 566 | |
558 | 567 | /// Source region to copy. Use nullptr to copy the entire subresource. |
559 | const struct Box* pSrcBox DEFAULT_INITIALIZER(nullptr); | |
568 | const Box* pSrcBox DEFAULT_INITIALIZER(nullptr); | |
560 | 569 | |
561 | 570 | /// Source texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE). |
562 | 571 | RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE); |
563 | 572 | |
564 | 573 | /// Destination texture. |
565 | class ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr); | |
574 | ITexture* pDstTexture DEFAULT_INITIALIZER(nullptr); | |
566 | 575 | |
567 | 576 | /// Destination mip level. |
568 | 577 | Uint32 DstMipLevel DEFAULT_INITIALIZER(0); |
597 | 606 | {} |
598 | 607 | #endif |
599 | 608 | }; |
600 | ||
601 | ||
602 | ||
603 | #if DILIGENT_CPP_INTERFACE | |
609 | typedef struct CopyTextureAttribs CopyTextureAttribs; | |
610 | ||
611 | ||
612 | #if DILIGENT_C_INTERFACE | |
613 | # define THIS struct IDeviceContext* | |
614 | # define THIS_ struct IDeviceContext*, | |
615 | #endif | |
604 | 616 | |
605 | 617 | /// Device context interface. |
606 | 618 | |
608 | 620 | /// the pipeline: buffers, states, samplers, shaders, etc. |
609 | 621 | /// The context also keeps strong reference to the device and |
610 | 622 | /// the swap chain. |
611 | class IDeviceContext : public IObject | |
612 | { | |
613 | public: | |
623 | DILIGENT_INTERFACE(IDeviceContext, IObject) | |
624 | { | |
614 | 625 | /// Sets the pipeline state. |
615 | 626 | |
616 | 627 | /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context. |
617 | virtual void SetPipelineState(IPipelineState* pPipelineState) = 0; | |
628 | VIRTUAL void METHOD(SetPipelineState)(THIS_ | |
629 | IPipelineState* pPipelineState) PURE; | |
618 | 630 | |
619 | 631 | |
620 | 632 | /// Transitions shader resources to the states required by Draw or Dispatch command. |
635 | 647 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
636 | 648 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
637 | 649 | /// of resource state management in Diligent Engine. |
638 | virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) = 0; | |
650 | VIRTUAL void METHOD(TransitionShaderResources)(THIS_ | |
651 | IPipelineState* pPipelineState, | |
652 | IShaderResourceBinding* pShaderResourceBinding) PURE; | |
639 | 653 | |
640 | 654 | /// Commits shader resources to the device context. |
641 | 655 | |
674 | 688 | /// If an application calls any method that changes the state of any resource after it has been committed, the |
675 | 689 | /// application is responsible for transitioning the resource back to correct state using one of the available methods |
676 | 690 | /// before issuing the next draw or dispatch command. |
677 | virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
691 | VIRTUAL void METHOD(CommitShaderResources)(THIS_ | |
692 | IShaderResourceBinding* pShaderResourceBinding, | |
693 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
678 | 694 | |
679 | 695 | /// Sets the stencil reference value. |
680 | 696 | |
681 | 697 | /// \param [in] StencilRef - Stencil reference value. |
682 | virtual void SetStencilRef(Uint32 StencilRef) = 0; | |
698 | VIRTUAL void METHOD(SetStencilRef)(THIS_ | |
699 | Uint32 StencilRef) PURE; | |
683 | 700 | |
684 | 701 | |
685 | 702 | /// \param [in] pBlendFactors - Array of four blend factors, one for each RGBA component. |
688 | 705 | /// Diligent::BLEND_FACTOR_INV_BLEND_FACTOR |
689 | 706 | /// blend factors. If nullptr is provided, |
690 | 707 | /// default blend factors array {1,1,1,1} will be used. |
691 | virtual void SetBlendFactors(const float* pBlendFactors = nullptr) = 0; | |
708 | VIRTUAL void METHOD(SetBlendFactors)(THIS_ | |
709 | const float* pBlendFactors DEFAULT_VALUE(nullptr)) PURE; | |
692 | 710 | |
693 | 711 | |
694 | 712 | /// Binds vertex buffers to the pipeline. |
721 | 739 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
722 | 740 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
723 | 741 | /// of resource state management in Diligent Engine. |
724 | virtual void SetVertexBuffers(Uint32 StartSlot, | |
725 | Uint32 NumBuffersSet, | |
726 | IBuffer** ppBuffers, | |
727 | Uint32* pOffsets, | |
728 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, | |
729 | SET_VERTEX_BUFFERS_FLAGS Flags) = 0; | |
742 | VIRTUAL void METHOD(SetVertexBuffers)(THIS_ | |
743 | Uint32 StartSlot, | |
744 | Uint32 NumBuffersSet, | |
745 | IBuffer** ppBuffers, | |
746 | Uint32* pOffsets, | |
747 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, | |
748 | SET_VERTEX_BUFFERS_FLAGS Flags) PURE; | |
730 | 749 | |
731 | 750 | |
732 | 751 | /// Invalidates the cached context state. |
733 | 752 | |
734 | 753 | /// This method should be called by an application to invalidate |
735 | 754 | /// internal cached states. |
736 | virtual void InvalidateState() = 0; | |
755 | VIRTUAL void METHOD(InvalidateState)(THIS) PURE; | |
737 | 756 | |
738 | 757 | |
739 | 758 | /// Binds an index buffer to the pipeline. |
757 | 776 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
758 | 777 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
759 | 778 | /// of resource state management in Diligent Engine. |
760 | virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
779 | VIRTUAL void METHOD(SetIndexBuffer)(THIS_ | |
780 | IBuffer* pIndexBuffer, | |
781 | Uint32 ByteOffset, | |
782 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
761 | 783 | |
762 | 784 | |
763 | 785 | /// Sets an array of viewports. |
778 | 800 | /// following call: |
779 | 801 | /// |
780 | 802 | /// pContext->SetViewports(1, nullptr, 0, 0); |
781 | virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) = 0; | |
803 | VIRTUAL void METHOD(SetViewports)(THIS_ | |
804 | Uint32 NumViewports, | |
805 | const Viewport* pViewports, | |
806 | Uint32 RTWidth, | |
807 | Uint32 RTHeight) PURE; | |
782 | 808 | |
783 | 809 | |
784 | 810 | /// Sets active scissor rects. |
795 | 821 | /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n |
796 | 822 | /// All scissor rects must be set atomically as one operation. Any rects not |
797 | 823 | /// defined by the call are disabled. |
798 | virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) = 0; | |
824 | VIRTUAL void METHOD(SetScissorRects)(THIS_ | |
825 | Uint32 NumRects, | |
826 | const Rect* pRects, | |
827 | Uint32 RTWidth, | |
828 | Uint32 RTHeight) PURE; | |
799 | 829 | |
800 | 830 | |
801 | 831 | /// Binds one or more render targets and the depth-stencil buffer to the context. It also |
825 | 855 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
826 | 856 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
827 | 857 | /// of resource state management in Diligent Engine. |
828 | virtual void SetRenderTargets(Uint32 NumRenderTargets, | |
829 | ITextureView* ppRenderTargets[], | |
830 | ITextureView* pDepthStencil, | |
831 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
858 | VIRTUAL void METHOD(SetRenderTargets)(THIS_ | |
859 | Uint32 NumRenderTargets, | |
860 | ITextureView* ppRenderTargets[], | |
861 | ITextureView* pDepthStencil, | |
862 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
832 | 863 | |
833 | 864 | |
834 | 865 | /// Executes a draw command. |
841 | 872 | /// |
842 | 873 | /// If the application intends to use the same resources in other threads simultaneously, it needs to |
843 | 874 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
844 | virtual void Draw(const DrawAttribs& Attribs) = 0; | |
875 | VIRTUAL void METHOD(Draw)(THIS_ | |
876 | const DrawAttribs REF Attribs) PURE; | |
845 | 877 | |
846 | 878 | |
847 | 879 | /// Executes an indexed draw command. |
854 | 886 | /// |
855 | 887 | /// If the application intends to use the same resources in other threads simultaneously, it needs to |
856 | 888 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
857 | virtual void DrawIndexed(const DrawIndexedAttribs& Attribs) = 0; | |
889 | VIRTUAL void METHOD(DrawIndexed)(THIS_ | |
890 | const DrawIndexedAttribs REF Attribs) PURE; | |
858 | 891 | |
859 | 892 | |
860 | 893 | /// Executes an indirect draw command. |
872 | 905 | /// |
873 | 906 | /// If the application intends to use the same resources in other threads simultaneously, it needs to |
874 | 907 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
875 | virtual void DrawIndirect(const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; | |
908 | VIRTUAL void METHOD(DrawIndirect)(THIS_ | |
909 | const DrawIndirectAttribs REF Attribs, | |
910 | IBuffer* pAttribsBuffer) PURE; | |
876 | 911 | |
877 | 912 | |
878 | 913 | /// Executes an indexed indirect draw command. |
890 | 925 | /// |
891 | 926 | /// If the application intends to use the same resources in other threads simultaneously, it needs to |
892 | 927 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
893 | virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; | |
928 | VIRTUAL void METHOD(DrawIndexedIndirect)(THIS_ | |
929 | const DrawIndexedIndirectAttribs REF Attribs, | |
930 | IBuffer* pAttribsBuffer) PURE; | |
894 | 931 | |
895 | 932 | |
896 | 933 | /// Executes a dispatch compute command. |
897 | 934 | |
898 | 935 | /// \param [in] Attribs - Dispatch command attributes, see Diligent::DispatchComputeAttribs for details. |
899 | virtual void DispatchCompute(const DispatchComputeAttribs& Attribs) = 0; | |
936 | VIRTUAL void METHOD(DispatchCompute)(THIS_ | |
937 | const DispatchComputeAttribs REF Attribs) PURE; | |
900 | 938 | |
901 | 939 | |
902 | 940 | /// Executes an indirect dispatch compute command. |
910 | 948 | /// |
911 | 949 | /// If the application intends to use the same resources in other threads simultaneously, it needs to |
912 | 950 | /// explicitly manage the states using IDeviceContext::TransitionResourceStates() method. |
913 | virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) = 0; | |
951 | VIRTUAL void METHOD(DispatchComputeIndirect)(THIS_ | |
952 | const DispatchComputeIndirectAttribs REF Attribs, | |
953 | IBuffer* pAttribsBuffer) PURE; | |
914 | 954 | |
915 | 955 | |
916 | 956 | /// Clears a depth-stencil view. |
934 | 974 | /// the state of resources used by the command. |
935 | 975 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
936 | 976 | /// of resource state management in Diligent Engine. |
937 | virtual void ClearDepthStencil(ITextureView* pView, | |
938 | CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, | |
939 | float fDepth, | |
940 | Uint8 Stencil, | |
941 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
977 | VIRTUAL void METHOD(ClearDepthStencil)(THIS_ | |
978 | ITextureView* pView, | |
979 | CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, | |
980 | float fDepth, | |
981 | Uint8 Stencil, | |
982 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
942 | 983 | |
943 | 984 | |
944 | 985 | /// Clears a render target view |
966 | 1007 | /// Diligent::RESOURCE_STATE_COPY_DEST state. Inside a render pass it must be in Diligent::RESOURCE_STATE_RENDER_TARGET |
967 | 1008 | /// state. When using Diligent::RESOURCE_STATE_TRANSITION_TRANSITION mode, the engine takes care of proper |
968 | 1009 | /// resource state transition, otherwise it is the responsibility of the application. |
969 | virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
1010 | VIRTUAL void METHOD(ClearRenderTarget)(THIS_ | |
1011 | ITextureView* pView, | |
1012 | const float* RGBA, | |
1013 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
970 | 1014 | |
971 | 1015 | |
972 | 1016 | /// Finishes recording commands and generates a command list. |
973 | 1017 | |
974 | 1018 | /// \param [out] ppCommandList - Memory location where pointer to the recorded command list will be written. |
975 | virtual void FinishCommandList(ICommandList **ppCommandList) = 0; | |
1019 | VIRTUAL void METHOD(FinishCommandList)(THIS_ | |
1020 | ICommandList** ppCommandList) PURE; | |
976 | 1021 | |
977 | 1022 | |
978 | 1023 | /// Executes recorded commands in a command list. |
979 | 1024 | |
980 | 1025 | /// \param [in] pCommandList - Pointer to the command list to executre. |
981 | 1026 | /// \remarks After command list is executed, it is no longer valid and should be released. |
982 | virtual void ExecuteCommandList(ICommandList* pCommandList) = 0; | |
1027 | VIRTUAL void METHOD(ExecuteCommandList)(THIS_ | |
1028 | ICommandList* pCommandList) PURE; | |
983 | 1029 | |
984 | 1030 | |
985 | 1031 | /// Tells the GPU to set a fence to a specified value after all previous work has completed. |
992 | 1038 | /// \param [in] pFence - The fence to signal |
993 | 1039 | /// \param [in] Value - The value to set the fence to. This value must be greater than the |
994 | 1040 | /// previously signaled value on the same fence. |
995 | virtual void SignalFence(IFence* pFence, Uint64 Value) = 0; | |
1041 | VIRTUAL void METHOD(SignalFence)(THIS_ | |
1042 | IFence* pFence, | |
1043 | Uint64 Value) PURE; | |
996 | 1044 | |
997 | 1045 | |
998 | 1046 | /// Waits until the specified fence reaches or exceeds the specified value, on the host. |
1014 | 1062 | /// may never return.\n |
1015 | 1063 | /// The fence can only be waited for from the same context it has |
1016 | 1064 | /// previously been signaled. |
1017 | virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) = 0; | |
1065 | VIRTUAL void METHOD(WaitForFence)(THIS_ | |
1066 | IFence* pFence, | |
1067 | Uint64 Value, | |
1068 | bool FlushContext) PURE; | |
1018 | 1069 | |
1019 | 1070 | |
1020 | 1071 | /// Submits all outstanding commands for execution to the GPU and waits until they are complete. |
1025 | 1076 | /// The methods implicitly flushes the context (see IDeviceContext::Flush()), so an |
1026 | 1077 | /// application must explicitly reset the PSO and bind all required shader resources after |
1027 | 1078 | /// idling the context.\n |
1028 | virtual void WaitForIdle() = 0; | |
1079 | VIRTUAL void METHOD(WaitForIdle)(THIS) PURE; | |
1029 | 1080 | |
1030 | 1081 | |
1031 | 1082 | /// Marks the beginning of a query. |
1046 | 1097 | /// SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE). |
1047 | 1098 | /// |
1048 | 1099 | /// \warning OpenGL and Vulkan do not support nested queries of the same type. |
1049 | virtual void BeginQuery(IQuery* pQuery) = 0; | |
1100 | VIRTUAL void METHOD(BeginQuery)(THIS_ | |
1101 | IQuery* pQuery) PURE; | |
1050 | 1102 | |
1051 | 1103 | |
1052 | 1104 | /// Marks the end of a query. |
1062 | 1114 | /// It is an error to explicitly flush the context while a query is active. |
1063 | 1115 | /// |
1064 | 1116 | /// All queries must be ended when IDeviceContext::FinishFrame() is called. |
1065 | virtual void EndQuery(IQuery* pQuery) = 0; | |
1117 | VIRTUAL void METHOD(EndQuery)(THIS_ | |
1118 | IQuery* pQuery) PURE; | |
1066 | 1119 | |
1067 | 1120 | |
1068 | 1121 | /// Submits all pending commands in the context for execution to the command queue. |
1074 | 1127 | /// restore viewports and scissor rects, etc.) except for the pipeline state and shader resource |
1075 | 1128 | /// bindings. An application must explicitly reset the PSO and bind all required shader |
1076 | 1129 | /// resources after flushing the context. |
1077 | virtual void Flush() = 0; | |
1130 | VIRTUAL void METHOD(Flush)(THIS) PURE; | |
1078 | 1131 | |
1079 | 1132 | |
1080 | 1133 | /// Updates the data in the buffer. |
1084 | 1137 | /// \param [in] Size - Size in bytes of the data region to update. |
1085 | 1138 | /// \param [in] pData - Pointer to the data to write to the buffer. |
1086 | 1139 | /// \param [in] StateTransitionMode - Buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE) |
1087 | virtual void UpdateBuffer(IBuffer* pBuffer, | |
1088 | Uint32 Offset, | |
1089 | Uint32 Size, | |
1090 | const void* pData, | |
1091 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) = 0; | |
1140 | VIRTUAL void METHOD(UpdateBuffer)(THIS_ | |
1141 | IBuffer* pBuffer, | |
1142 | Uint32 Offset, | |
1143 | Uint32 Size, | |
1144 | const void* pData, | |
1145 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE; | |
1092 | 1146 | |
1093 | 1147 | |
1094 | 1148 | /// Copies the data from one buffer to another. |
1101 | 1155 | /// of the destination region. |
1102 | 1156 | /// \param [in] Size - Size in bytes of data to copy. |
1103 | 1157 | /// \param [in] DstBufferTransitionMode - State transition mode of the destination buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE). |
1104 | virtual void CopyBuffer(IBuffer* pSrcBuffer, | |
1105 | Uint32 SrcOffset, | |
1106 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1107 | IBuffer* pDstBuffer, | |
1108 | Uint32 DstOffset, | |
1109 | Uint32 Size, | |
1110 | RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) = 0; | |
1158 | VIRTUAL void METHOD(CopyBuffer)(THIS_ | |
1159 | IBuffer* pSrcBuffer, | |
1160 | Uint32 SrcOffset, | |
1161 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1162 | IBuffer* pDstBuffer, | |
1163 | Uint32 DstOffset, | |
1164 | Uint32 Size, | |
1165 | RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) PURE; | |
1111 | 1166 | |
1112 | 1167 | |
1113 | 1168 | /// Maps the buffer. |
1116 | 1171 | /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE. |
1117 | 1172 | /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS. |
1118 | 1173 | /// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region. |
1119 | virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) = 0; | |
1174 | VIRTUAL void METHOD(MapBuffer)(THIS_ | |
1175 | IBuffer* pBuffer, | |
1176 | MAP_TYPE MapType, | |
1177 | MAP_FLAGS MapFlags, | |
1178 | PVoid REF pMappedData) PURE; | |
1120 | 1179 | |
1121 | 1180 | |
1122 | 1181 | /// Unmaps the previously mapped buffer. |
1124 | 1183 | /// \param [in] pBuffer - Pointer to the buffer to unmap. |
1125 | 1184 | /// \param [in] MapType - Type of the map operation. This parameter must match the type that was |
1126 | 1185 | /// provided to the Map() method. |
1127 | virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) = 0; | |
1186 | VIRTUAL void METHOD(UnmapBuffer)(THIS_ | |
1187 | IBuffer* pBuffer, | |
1188 | MAP_TYPE MapType) PURE; | |
1128 | 1189 | |
1129 | 1190 | |
1130 | 1191 | /// Updates the data in the texture. |
1138 | 1199 | /// parameter defines state transition mode of the source buffer. |
1139 | 1200 | /// If pSrcBuffer is null, this parameter is ignored. |
1140 | 1201 | /// \param [in] TextureTransitionMode - Texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE) |
1141 | virtual void UpdateTexture(ITexture* pTexture, | |
1142 | Uint32 MipLevel, | |
1143 | Uint32 Slice, | |
1144 | const Box& DstBox, | |
1145 | const TextureSubResData& SubresData, | |
1146 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1147 | RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) = 0; | |
1202 | VIRTUAL void METHOD(UpdateTexture)(THIS_ | |
1203 | ITexture* pTexture, | |
1204 | Uint32 MipLevel, | |
1205 | Uint32 Slice, | |
1206 | const Box REF DstBox, | |
1207 | const TextureSubResData REF SubresData, | |
1208 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1209 | RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) PURE; | |
1148 | 1210 | |
1149 | 1211 | |
1150 | 1212 | /// Copies data from one texture to another. |
1151 | 1213 | |
1152 | 1214 | /// \param [in] CopyAttribs - Structure describing copy command attributes, see Diligent::CopyTextureAttribs for details. |
1153 | virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) = 0; | |
1215 | VIRTUAL void METHOD(CopyTexture)(THIS_ | |
1216 | const CopyTextureAttribs REF CopyAttribs) PURE; | |
1154 | 1217 | |
1155 | 1218 | |
1156 | 1219 | /// Maps the texture subresource. |
1167 | 1230 | /// subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource. |
1168 | 1231 | /// In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping |
1169 | 1232 | /// with MAP_FLAG_DISCARD has exactly the same behavior. |
1170 | virtual void MapTextureSubresource(ITexture* pTexture, | |
1171 | Uint32 MipLevel, | |
1172 | Uint32 ArraySlice, | |
1173 | MAP_TYPE MapType, | |
1174 | MAP_FLAGS MapFlags, | |
1175 | const Box* pMapRegion, | |
1176 | MappedTextureSubresource& MappedData) = 0; | |
1233 | VIRTUAL void METHOD(MapTextureSubresource)(THIS_ | |
1234 | ITexture* pTexture, | |
1235 | Uint32 MipLevel, | |
1236 | Uint32 ArraySlice, | |
1237 | MAP_TYPE MapType, | |
1238 | MAP_FLAGS MapFlags, | |
1239 | const Box* pMapRegion, | |
1240 | MappedTextureSubresource REF MappedData) PURE; | |
1177 | 1241 | |
1178 | 1242 | |
1179 | 1243 | /// Unmaps the texture subresource. |
1180 | virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) = 0; | |
1244 | VIRTUAL void METHOD(UnmapTextureSubresource)(THIS_ | |
1245 | ITexture* pTexture, | |
1246 | Uint32 MipLevel, | |
1247 | Uint32 ArraySlice) PURE; | |
1181 | 1248 | |
1182 | 1249 | |
1183 | 1250 | /// Generates a mipmap chain. |
1185 | 1252 | /// \param [in] pTextureView - Texture view to generate mip maps for. |
1186 | 1253 | /// \remarks This function can only be called for a shader resource view. |
1187 | 1254 | /// The texture must be created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag. |
1188 | virtual void GenerateMips(ITextureView* pTextureView) = 0; | |
1255 | VIRTUAL void METHOD(GenerateMips)(THIS_ | |
1256 | ITextureView* pTextureView) PURE; | |
1189 | 1257 | |
1190 | 1258 | |
1191 | 1259 | /// Finishes the current frame and releases dynamic resources allocated by the context. |
1200 | 1268 | /// For deferred contexts, this method must be called after all command lists referencing dynamic resources |
1201 | 1269 | /// have been executed through immediate context.\n |
1202 | 1270 | /// The method does not Flush() the context. |
1203 | virtual void FinishFrame() = 0; | |
1271 | VIRTUAL void METHOD(FinishFrame)(THIS) PURE; | |
1204 | 1272 | |
1205 | 1273 | |
1206 | 1274 | /// Transitions resource states. |
1232 | 1300 | /// |
1233 | 1301 | /// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation |
1234 | 1302 | /// of resource state management in Diligent Engine. |
1235 | virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) = 0; | |
1303 | VIRTUAL void METHOD(TransitionResourceStates)(THIS_ | |
1304 | Uint32 BarrierCount, | |
1305 | StateTransitionDesc* pResourceBarriers) PURE; | |
1236 | 1306 | |
1237 | 1307 | |
1238 | 1308 | /// Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource. |
1240 | 1310 | /// \param [in] pSrcTexture - Source multi-sampled texture. |
1241 | 1311 | /// \param [in] pDstTexture - Destination non-multi-sampled texture. |
1242 | 1312 | /// \param [in] ResolveAttribs - Resolve command attributes, see Diligent::ResolveTextureSubresourceAttribs for details. |
1243 | virtual void ResolveTextureSubresource(ITexture* pSrcTexture, | |
1244 | ITexture* pDstTexture, | |
1245 | const ResolveTextureSubresourceAttribs& ResolveAttribs) = 0; | |
1246 | }; | |
1247 | ||
1248 | #else | |
1313 | VIRTUAL void METHOD(ResolveTextureSubresource)(THIS_ | |
1314 | ITexture* pSrcTexture, | |
1315 | ITexture* pDstTexture, | |
1316 | const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE; | |
1317 | }; | |
1318 | ||
1319 | #if DILIGENT_C_INTERFACE | |
1320 | ||
1321 | # undef THIS | |
1322 | # undef THIS_ | |
1249 | 1323 | |
1250 | 1324 | // clang-format on |
1251 | ||
1252 | struct IDeviceContext; | |
1253 | ||
1254 | struct IDeviceContextMethods | |
1255 | { | |
1256 | void (*SetPipelineState)(struct IDeviceContext*, class IPipelineState* pPipelineState); | |
1257 | void (*TransitionShaderResources)(struct IDeviceContext*, class IPipelineState* pPipelineState, class IShaderResourceBinding* pShaderResourceBinding); | |
1258 | void (*CommitShaderResources)(struct IDeviceContext*, class IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1259 | void (*SetStencilRef)(struct IDeviceContext*, Uint32 StencilRef); | |
1260 | void (*SetBlendFactors)(struct IDeviceContext*, const float* pBlendFactors); | |
1261 | void (*SetVertexBuffers)(struct IDeviceContext*, | |
1262 | Uint32 StartSlot, | |
1263 | Uint32 NumBuffersSet, | |
1264 | class IBuffer** ppBuffers, | |
1265 | Uint32* pOffsets, | |
1266 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, | |
1267 | SET_VERTEX_BUFFERS_FLAGS Flags); | |
1268 | void (*InvalidateState)(struct IDeviceContext*); | |
1269 | void (*SetIndexBuffer)(struct IDeviceContext*, | |
1270 | class IBuffer* pIndexBuffer, | |
1271 | Uint32 ByteOffset, | |
1272 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1273 | void (*SetViewports)(struct IDeviceContext*, | |
1274 | Uint32 NumViewports, | |
1275 | const struct Viewport* pViewports, | |
1276 | Uint32 RTWidth, | |
1277 | Uint32 RTHeight); | |
1278 | void (*SetScissorRects)(struct IDeviceContext*, | |
1279 | Uint32 NumRects, | |
1280 | const struct Rect* pRects, | |
1281 | Uint32 RTWidth, | |
1282 | Uint32 RTHeight); | |
1283 | void (*SetRenderTargets)(struct IDeviceContext*, | |
1284 | Uint32 NumRenderTargets, | |
1285 | class ITextureView* ppRenderTargets[], | |
1286 | class ITextureView* pDepthStencil, | |
1287 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1288 | void (*Draw)(struct IDeviceContext*, const struct DrawAttribs* Attribs); | |
1289 | void (*DrawIndexed)(struct IDeviceContext*, const struct DrawIndexedAttribs* Attribs); | |
1290 | void (*DrawIndirect)(struct IDeviceContext*, const struct DrawIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); | |
1291 | void (*DrawIndexedIndirect)(struct IDeviceContext*, const struct DrawIndexedIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); | |
1292 | void (*DispatchCompute)(struct IDeviceContext*, const struct DispatchComputeAttribs* Attribs); | |
1293 | void (*DispatchComputeIndirect)(struct IDeviceContext*, const struct DispatchComputeIndirectAttribs* Attribs, class IBuffer* pAttribsBuffer); | |
1294 | void (*ClearDepthStencil)(struct IDeviceContext*, | |
1295 | class ITextureView* pView, | |
1296 | CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, | |
1297 | float fDepth, | |
1298 | Uint8 Stencil, | |
1299 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1300 | void (*ClearRenderTarget)(struct IDeviceContext*, class ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1301 | void (*FinishCommandList)(struct IDeviceContext*, class ICommandList** ppCommandList); | |
1302 | void (*ExecuteCommandList)(struct IDeviceContext*, class ICommandList* pCommandList); | |
1303 | void (*SignalFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value); | |
1304 | void (*WaitForFence)(struct IDeviceContext*, class IFence* pFence, Uint64 Value, bool FlushContext); | |
1305 | void (*WaitForIdle)(struct IDeviceContext*); | |
1306 | void (*BeginQuery)(struct IDeviceContext*, class IQuery* pQuery); | |
1307 | void (*EndQuery)(struct IDeviceContext*, class IQuery* pQuery); | |
1308 | void (*Flush)(struct IDeviceContext*); | |
1309 | void (*UpdateBuffer)(struct IDeviceContext*, | |
1310 | class IBuffer* pBuffer, | |
1311 | Uint32 Offset, | |
1312 | Uint32 Size, | |
1313 | const void* pData, | |
1314 | RESOURCE_STATE_TRANSITION_MODE StateTransitionMode); | |
1315 | void (*CopyBuffer)(struct IDeviceContext*, | |
1316 | class IBuffer* pSrcBuffer, | |
1317 | Uint32 SrcOffset, | |
1318 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1319 | class IBuffer* pDstBuffer, | |
1320 | Uint32 DstOffset, | |
1321 | Uint32 Size, | |
1322 | RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode); | |
1323 | void (*MapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid* pMappedData); | |
1324 | void (*UnmapBuffer)(struct IDeviceContext*, class IBuffer* pBuffer, MAP_TYPE MapType); | |
1325 | void (*UpdateTexture)(struct IDeviceContext*, | |
1326 | class ITexture* pTexture, | |
1327 | Uint32 MipLevel, | |
1328 | Uint32 Slice, | |
1329 | const struct Box* DstBox, | |
1330 | const struct TextureSubResData* SubresData, | |
1331 | RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, | |
1332 | RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode); | |
1333 | void (*CopyTexture)(struct IDeviceContext*, const struct CopyTextureAttribs* CopyAttribs); | |
1334 | void (*MapTextureSubresource)(struct IDeviceContext*, | |
1335 | class ITexture* pTexture, | |
1336 | Uint32 MipLevel, | |
1337 | Uint32 ArraySlice, | |
1338 | MAP_TYPE MapType, | |
1339 | MAP_FLAGS MapFlags, | |
1340 | const struct Box* pMapRegion, | |
1341 | struct MappedTextureSubresource* MappedData); | |
1342 | void (*UnmapTextureSubresource)(struct IDeviceContext*, class ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice); | |
1343 | void (*GenerateMips)(struct IDeviceContext*, class ITextureView* pTextureView); | |
1344 | void (*FinishFrame)(struct IDeviceContext*); | |
1345 | void (*TransitionResourceStates)(struct IDeviceContext*, Uint32 BarrierCount, struct StateTransitionDesc* pResourceBarriers); | |
1346 | void (*ResolveTextureSubresource)(struct IDeviceContext*, | |
1347 | class ITexture* pSrcTexture, | |
1348 | class ITexture* pDstTexture, | |
1349 | const struct ResolveTextureSubresourceAttribs* ResolveAttribs); | |
1350 | }; | |
1351 | 1325 | |
1352 | 1326 | struct IDeviceContextVtbl |
1353 | 1327 | { |
1355 | 1329 | struct IDeviceContextMethods DeviceContext; |
1356 | 1330 | }; |
1357 | 1331 | |
1358 | struct IDeviceContext | |
1332 | typedef struct IDeviceContext | |
1359 | 1333 | { |
1360 | 1334 | struct IDeviceContextVtbl* pVtbl; |
1361 | }; | |
1335 | } IDeviceContext; | |
1362 | 1336 | |
1363 | 1337 | // clang-format off |
1364 | 1338 | |
1365 | # define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1366 | # define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1367 | # define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1368 | # define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1369 | # define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1370 | # define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1371 | # define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((struct IDeviceContext*)(This)) | |
1372 | # define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1373 | # define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1374 | # define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1375 | # define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1376 | # define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1377 | # define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1378 | # define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1379 | # define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1380 | # define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1381 | # define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1382 | # define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1383 | # define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1384 | # define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1385 | # define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1386 | # define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1387 | # define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1388 | # define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1389 | # define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1390 | # define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1391 | # define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1392 | # define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1393 | # define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1394 | # define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1395 | # define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1396 | # define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1397 | # define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1398 | # define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1399 | # define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1400 | # define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1401 | # define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((struct IDeviceContext*)(This)) | |
1402 | # define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1403 | # define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((struct IDeviceContext*)(This), __VA_ARGS__) | |
1339 | # define IDeviceContext_SetPipelineState(This, ...) (This)->pVtbl->DeviceContext.SetPipelineState ((IDeviceContext*)(This), __VA_ARGS__) | |
1340 | # define IDeviceContext_TransitionShaderResources(This, ...) (This)->pVtbl->DeviceContext.TransitionShaderResources ((IDeviceContext*)(This), __VA_ARGS__) | |
1341 | # define IDeviceContext_CommitShaderResources(This, ...) (This)->pVtbl->DeviceContext.CommitShaderResources ((IDeviceContext*)(This), __VA_ARGS__) | |
1342 | # define IDeviceContext_SetStencilRef(This, ...) (This)->pVtbl->DeviceContext.SetStencilRef ((IDeviceContext*)(This), __VA_ARGS__) | |
1343 | # define IDeviceContext_SetBlendFactors(This, ...) (This)->pVtbl->DeviceContext.SetBlendFactors ((IDeviceContext*)(This), __VA_ARGS__) | |
1344 | # define IDeviceContext_SetVertexBuffers(This, ...) (This)->pVtbl->DeviceContext.SetVertexBuffers ((IDeviceContext*)(This), __VA_ARGS__) | |
1345 | # define IDeviceContext_InvalidateState(This) (This)->pVtbl->DeviceContext.InvalidateState ((IDeviceContext*)(This)) | |
1346 | # define IDeviceContext_SetIndexBuffer(This, ...) (This)->pVtbl->DeviceContext.SetIndexBuffer ((IDeviceContext*)(This), __VA_ARGS__) | |
1347 | # define IDeviceContext_SetViewports(This, ...) (This)->pVtbl->DeviceContext.SetViewports ((IDeviceContext*)(This), __VA_ARGS__) | |
1348 | # define IDeviceContext_SetScissorRects(This, ...) (This)->pVtbl->DeviceContext.SetScissorRects ((IDeviceContext*)(This), __VA_ARGS__) | |
1349 | # define IDeviceContext_SetRenderTargets(This, ...) (This)->pVtbl->DeviceContext.SetRenderTargets ((IDeviceContext*)(This), __VA_ARGS__) | |
1350 | # define IDeviceContext_Draw(This, ...) (This)->pVtbl->DeviceContext.Draw ((IDeviceContext*)(This), __VA_ARGS__) | |
1351 | # define IDeviceContext_DrawIndexed(This, ...) (This)->pVtbl->DeviceContext.DrawIndexed ((IDeviceContext*)(This), __VA_ARGS__) | |
1352 | # define IDeviceContext_DrawIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndirect ((IDeviceContext*)(This), __VA_ARGS__) | |
1353 | # define IDeviceContext_DrawIndexedIndirect(This, ...) (This)->pVtbl->DeviceContext.DrawIndexedIndirect ((IDeviceContext*)(This), __VA_ARGS__) | |
1354 | # define IDeviceContext_DispatchCompute(This, ...) (This)->pVtbl->DeviceContext.DispatchCompute ((IDeviceContext*)(This), __VA_ARGS__) | |
1355 | # define IDeviceContext_DispatchComputeIndirect(This, ...) (This)->pVtbl->DeviceContext.DispatchComputeIndirect ((IDeviceContext*)(This), __VA_ARGS__) | |
1356 | # define IDeviceContext_ClearDepthStencil(This, ...) (This)->pVtbl->DeviceContext.ClearDepthStencil ((IDeviceContext*)(This), __VA_ARGS__) | |
1357 | # define IDeviceContext_ClearRenderTarget(This, ...) (This)->pVtbl->DeviceContext.ClearRenderTarget ((IDeviceContext*)(This), __VA_ARGS__) | |
1358 | # define IDeviceContext_FinishCommandList(This, ...) (This)->pVtbl->DeviceContext.FinishCommandList ((IDeviceContext*)(This), __VA_ARGS__) | |
1359 | # define IDeviceContext_ExecuteCommandList(This, ...) (This)->pVtbl->DeviceContext.ExecuteCommandList ((IDeviceContext*)(This), __VA_ARGS__) | |
1360 | # define IDeviceContext_SignalFence(This, ...) (This)->pVtbl->DeviceContext.SignalFence ((IDeviceContext*)(This), __VA_ARGS__) | |
1361 | # define IDeviceContext_WaitForFence(This, ...) (This)->pVtbl->DeviceContext.WaitForFence ((IDeviceContext*)(This), __VA_ARGS__) | |
1362 | # define IDeviceContext_WaitForIdle(This, ...) (This)->pVtbl->DeviceContext.WaitForIdle ((IDeviceContext*)(This), __VA_ARGS__) | |
1363 | # define IDeviceContext_BeginQuery(This, ...) (This)->pVtbl->DeviceContext.BeginQuery ((IDeviceContext*)(This), __VA_ARGS__) | |
1364 | # define IDeviceContext_EndQuery(This, ...) (This)->pVtbl->DeviceContext.EndQuery ((IDeviceContext*)(This), __VA_ARGS__) | |
1365 | # define IDeviceContext_Flush(This, ...) (This)->pVtbl->DeviceContext.Flush ((IDeviceContext*)(This), __VA_ARGS__) | |
1366 | # define IDeviceContext_UpdateBuffer(This, ...) (This)->pVtbl->DeviceContext.UpdateBuffer ((IDeviceContext*)(This), __VA_ARGS__) | |
1367 | # define IDeviceContext_CopyBuffer(This, ...) (This)->pVtbl->DeviceContext.CopyBuffer ((IDeviceContext*)(This), __VA_ARGS__) | |
1368 | # define IDeviceContext_MapBuffer(This, ...) (This)->pVtbl->DeviceContext.MapBuffer ((IDeviceContext*)(This), __VA_ARGS__) | |
1369 | # define IDeviceContext_UnmapBuffer(This, ...) (This)->pVtbl->DeviceContext.UnmapBuffer ((IDeviceContext*)(This), __VA_ARGS__) | |
1370 | # define IDeviceContext_UpdateTexture(This, ...) (This)->pVtbl->DeviceContext.UpdateTexture ((IDeviceContext*)(This), __VA_ARGS__) | |
1371 | # define IDeviceContext_CopyTexture(This, ...) (This)->pVtbl->DeviceContext.CopyTexture ((IDeviceContext*)(This), __VA_ARGS__) | |
1372 | # define IDeviceContext_MapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.MapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) | |
1373 | # define IDeviceContext_UnmapTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.UnmapTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) | |
1374 | # define IDeviceContext_GenerateMips(This, ...) (This)->pVtbl->DeviceContext.GenerateMips ((IDeviceContext*)(This), __VA_ARGS__) | |
1375 | # define IDeviceContext_FinishFrame(This) (This)->pVtbl->DeviceContext.FinishFrame ((IDeviceContext*)(This)) | |
1376 | # define IDeviceContext_TransitionResourceStates(This, ...) (This)->pVtbl->DeviceContext.TransitionResourceStates ((IDeviceContext*)(This), __VA_ARGS__) | |
1377 | # define IDeviceContext_ResolveTextureSubresource(This, ...) (This)->pVtbl->DeviceContext.ResolveTextureSubresource ((IDeviceContext*)(This), __VA_ARGS__) | |
1404 | 1378 | |
1405 | 1379 | // clang-format on |
1406 | 1380 |
36 | 36 | |
37 | 37 | |
38 | 38 | // {5B4CCA0B-5075-4230-9759-F48769EE5502} |
39 | static const struct INTERFACE_ID IID_DeviceObject = | |
39 | static const INTERFACE_ID IID_DeviceObject = | |
40 | 40 | {0x5b4cca0b, 0x5075, 0x4230, {0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2}}; |
41 | 41 | |
42 | #if DILIGENT_CPP_INTERFACE | |
42 | #if DILIGENT_C_INTERFACE | |
43 | # define THIS struct IDeviceObject* | |
44 | # define THIS_ struct IDeviceObject*, | |
45 | #endif | |
43 | 46 | |
44 | 47 | /// Base interface for all objects created by the render device Diligent::IRenderDevice |
45 | class IDeviceObject : public IObject | |
48 | DILIGENT_INTERFACE(IDeviceObject, IObject) | |
46 | 49 | { |
47 | public: | |
48 | 50 | /// Returns the object description |
49 | virtual const DeviceObjectAttribs& GetDesc() const = 0; | |
51 | VIRTUAL const DeviceObjectAttribs REF METHOD(GetDesc)(THIS) CONST PURE; | |
50 | 52 | |
51 | 53 | |
52 | 54 | /// Returns unique identifier assigned to an object |
65 | 67 | /// |
66 | 68 | /// Valid identifiers are always positive values. Zero and negative values can never be |
67 | 69 | /// assigned to an object and are always guaranteed to be invalid. |
68 | virtual Int32 GetUniqueID() const = 0; | |
70 | VIRTUAL Int32 METHOD(GetUniqueID)(THIS) CONST PURE; | |
69 | 71 | }; |
70 | 72 | |
71 | #else | |
73 | #if DILIGENT_C_INTERFACE | |
72 | 74 | |
73 | struct IDeviceObject; | |
75 | # undef THIS | |
76 | # undef THIS_ | |
74 | 77 | |
75 | 78 | // clang-format off |
76 | ||
77 | struct IDeviceObjectMethods | |
78 | { | |
79 | const struct DeviceObjectAttribs* (*GetDesc) (struct IDeviceObject*); | |
80 | Int32 (*GetUniqueID)(struct IDeviceObject*); | |
81 | }; | |
82 | ||
83 | // clang-format on | |
84 | 79 | |
85 | 80 | struct IDeviceObjectVtbl |
86 | 81 | { |
88 | 83 | struct IDeviceObjectMethods DeviceObject; |
89 | 84 | }; |
90 | 85 | |
91 | struct IDeviceObject | |
86 | typedef struct IDeviceObject | |
92 | 87 | { |
93 | 88 | struct IDeviceObjectVtbl* pVtbl; |
94 | }; | |
89 | }IDeviceObject; | |
95 | 90 | |
96 | 91 | // clang-format off |
97 | 92 | |
98 | # define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((struct IDeviceObject*)(This)) | |
99 | # define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((struct IDeviceObject*)(This)) | |
93 | # define IDeviceObject_GetDesc(This) (This)->pVtbl->DeviceObject.GetDesc ((IDeviceObject*)(This)) | |
94 | # define IDeviceObject_GetUniqueID(This) (This)->pVtbl->DeviceObject.GetUniqueID((IDeviceObject*)(This)) | |
100 | 95 | |
101 | 96 | // clang-format on |
102 | 97 |
34 | 34 | |
35 | 35 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
36 | 36 | |
37 | class IShaderSourceInputStreamFactory; | |
37 | struct IShaderSourceInputStreamFactory; | |
38 | 38 | |
39 | 39 | // {D932B052-4ED6-4729-A532-F31DEEC100F3} |
40 | static const struct INTERFACE_ID IID_EngineFactory = | |
40 | static const INTERFACE_ID IID_EngineFactory = | |
41 | 41 | {0xd932b052, 0x4ed6, 0x4729, {0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3}}; |
42 | 42 | |
43 | #if DILIGENT_CPP_INTERFACE | |
43 | #if DILIGENT_C_INTERFACE | |
44 | # define THIS struct IEngineFactory* | |
45 | # define THIS_ struct IEngineFactory*, | |
46 | #endif | |
47 | ||
48 | // clang-format off | |
44 | 49 | |
45 | 50 | /// Engine factory base interface |
46 | class IEngineFactory : public IObject | |
51 | DILIGENT_INTERFACE(IEngineFactory, IObject) | |
47 | 52 | { |
48 | public: | |
49 | 53 | /// Returns API info structure |
50 | virtual const APIInfo& GetAPIInfo() const = 0; | |
54 | VIRTUAL const APIInfo REF METHOD(GetAPIInfo)(THIS) CONST PURE; | |
51 | 55 | |
52 | 56 | /// Creates default shader source input stream factory |
53 | 57 | /// \param [in] SearchDirectories - Semicolon-seprated list of search directories. |
54 | 58 | /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. |
55 | virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, | |
56 | IShaderSourceInputStreamFactory** ppShaderSourceFactory) const = 0; | |
59 | VIRTUAL void METHOD(CreateDefaultShaderSourceStreamFactory)( | |
60 | THIS_ | |
61 | const Char* SearchDirectories, | |
62 | struct IShaderSourceInputStreamFactory** ppShaderSourceFactory) CONST PURE; | |
57 | 63 | |
58 | # if PLATFORM_ANDROID | |
64 | #if PLATFORM_ANDROID | |
59 | 65 | /// On Android platform, it is necessary to initialize the file system before |
60 | 66 | /// CreateDefaultShaderSourceStreamFactory() method can be called. |
61 | 67 | /// \param [in] Activity - Pointer to the activity. |
62 | 68 | /// \param [in] ActivityClassName - Activity class name. |
63 | virtual void InitAndroidFileSystem(void* Activity, const char* ActivityClassName) const = 0; | |
64 | # endif | |
69 | VIRTUAL void METHOD(InitAndroidFileSystem)(THIS_ | |
70 | void* Activity, | |
71 | const char* ActivityClassName) CONST PURE; | |
72 | #endif | |
65 | 73 | }; |
66 | 74 | |
67 | #else | |
75 | #if DILIGENT_C_INTERFACE | |
68 | 76 | |
69 | struct IEngineFactory; | |
70 | struct IShaderSourceInputStreamFactory; | |
71 | ||
72 | // clang-format off | |
73 | ||
74 | struct IEngineFactoryMethods | |
75 | { | |
76 | const struct APIInfo* (*GetAPIInfo) (struct IEngineFactory*); | |
77 | void (*CreateDefaultShaderSourceStreamFactory)(struct IEngineFactory*, | |
78 | const Char* SearchDirectories, | |
79 | struct IShaderSourceInputStreamFactory** ppShaderSourceFactory); | |
80 | ||
81 | # if PLATFORM_ANDROID | |
82 | void (*InitAndroidFileSystem) (struct IEngineFactory*, void* Activity, const char* ActivityClassName); | |
83 | # endif | |
84 | }; | |
77 | # undef THIS | |
78 | # undef THIS_ | |
85 | 79 | |
86 | 80 | // clang-format on |
87 | 81 | |
91 | 85 | struct IEngineFactoryMethods EngineFactory; |
92 | 86 | }; |
93 | 87 | |
94 | struct IEngineFactory | |
88 | typedef struct IEngineFactory | |
95 | 89 | { |
96 | 90 | struct IEngineFactoryVtbl* pVtbl; |
97 | }; | |
91 | } IEngineFactory; | |
98 | 92 | |
99 | 93 | // clang-format off |
100 | 94 | |
101 | # define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((struct IEngineFactory*)(This)) | |
102 | # define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((struct IEngineFactory*)(This), __VA_ARGS__) | |
103 | # define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((struct IEngineFactory*)(This), __VA_ARGS__) | |
95 | # define IEngineFactory_GetAPIInfo(This) (This)->pVtbl->EngineFactory.GetAPIInfo ((IEngineFactory*)(This)) | |
96 | # define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) (This)->pVtbl->EngineFactory.CreateDefaultShaderSourceStreamFactory((IEngineFactory*)(This), __VA_ARGS__) | |
97 | # define IEngineFactory_InitAndroidFileSystem(This, ...) (This)->pVtbl->EngineFactory.InitAndroidFileSystem ((IEngineFactory*)(This), __VA_ARGS__) | |
104 | 98 | |
105 | 99 | // clang-format on |
106 | 100 |
34 | 34 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
35 | 35 | |
36 | 36 | // {3B19184D-32AB-4701-84F4-9A0C03AE1672} |
37 | static const struct INTERFACE_ID IID_Fence = | |
37 | static const INTERFACE_ID IID_Fence = | |
38 | 38 | {0x3b19184d, 0x32ab, 0x4701, {0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72}}; |
39 | 39 | |
40 | 40 | // clang-format off |
41 | 41 | /// Fence description |
42 | 42 | struct FenceDesc DILIGENT_DERIVE(DeviceObjectAttribs) |
43 | 43 | }; |
44 | // clang-format on | |
44 | typedef struct FenceDesc FenceDesc; | |
45 | 45 | |
46 | // clang-format off | |
46 | 47 | |
47 | #if DILIGENT_CPP_INTERFACE | |
48 | #if DILIGENT_C_INTERFACE | |
49 | # define THIS struct IFence* | |
50 | # define THIS_ struct IFence*, | |
51 | #endif | |
48 | 52 | |
49 | 53 | /// Fence interface |
50 | 54 | |
52 | 56 | /// |
53 | 57 | /// \remarks When a fence that was previously signaled by IDeviceContext::SignalFence() is destroyed, |
54 | 58 | /// it may block the GPU until all prior commands have completed execution. |
55 | class IFence : public IDeviceObject | |
59 | DILIGENT_INTERFACE(IFence, IDeviceObject) | |
56 | 60 | { |
57 | public: | |
61 | #if DILIGENT_CPP_INTERFACE | |
58 | 62 | /// Returns the fence description used to create the object |
59 | 63 | virtual const FenceDesc& GetDesc() const override = 0; |
64 | #endif | |
60 | 65 | |
61 | 66 | /// Returns the last completed value signaled by the GPU |
62 | 67 | |
63 | 68 | /// \remarks This method is not thread safe (even if the fence object is protected by mutex) |
64 | 69 | /// and must only be called by the same thread that signals the fence via |
65 | 70 | /// IDeviceContext::SignalFence(). |
66 | virtual Uint64 GetCompletedValue() = 0; | |
71 | VIRTUAL Uint64 METHOD(GetCompletedValue)(THIS) PURE; | |
67 | 72 | |
68 | 73 | /// Resets the fence to the specified value. |
69 | virtual void Reset(Uint64 Value) = 0; | |
74 | VIRTUAL void METHOD(Reset)(THIS_ | |
75 | Uint64 Value) PURE; | |
70 | 76 | }; |
71 | 77 | |
72 | #else | |
73 | 78 | |
74 | struct IFence; | |
79 | #if DILIGENT_C_INTERFACE | |
75 | 80 | |
76 | // clang-format off | |
77 | ||
78 | struct IFenceMethods | |
79 | { | |
80 | Uint64 (*GetCompletedValue)(struct IFence*); | |
81 | void (*Reset) (struct IFence*, Uint64 Value); | |
82 | }; | |
81 | # undef THIS | |
82 | # undef THIS_ | |
83 | 83 | |
84 | 84 | // clang-format on |
85 | 85 | |
90 | 90 | struct IFenceMethods Fence; |
91 | 91 | }; |
92 | 92 | |
93 | struct IFence | |
93 | typedef struct IFence | |
94 | 94 | { |
95 | 95 | struct IFenceVtbl* pVtbl; |
96 | }; | |
96 | } IFence; | |
97 | 97 | |
98 | 98 | // clang-format off |
99 | 99 | |
100 | 100 | # define IFence_GetDesc(This) (const struct FenceDesc*)IDeviceObject_GetDesc(This) |
101 | 101 | |
102 | # define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((struct IFence*)(This)) | |
103 | # define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((struct IFence*)(This), __VA_ARGS__) | |
102 | # define IFence_GetCompletedValue(This) (This)->pVtbl->Fence.GetCompletedValue((IFence*)(This)) | |
103 | # define IFence_Reset(This, ...) (This)->pVtbl->Fence.Reset ((IFence*)(This), __VA_ARGS__) | |
104 | 104 | |
105 | 105 | // clang-format on |
106 | 106 |
39 | 39 | /// Graphics engine namespace |
40 | 40 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
41 | 41 | |
42 | class ITexture; | |
43 | class IBuffer; | |
42 | struct ITexture; | |
43 | struct IBuffer; | |
44 | 44 | |
45 | 45 | /// Value type |
46 | 46 | |
1089 | 1089 | {} |
1090 | 1090 | #endif |
1091 | 1091 | }; |
1092 | typedef struct DeviceObjectAttribs DeviceObjectAttribs; | |
1092 | 1093 | |
1093 | 1094 | /// Hardware adapter type |
1094 | 1095 | DILIGENT_TYPED_ENUM(ADAPTER_TYPE, Uint8) |
1130 | 1131 | /// Number of outputs this device has |
1131 | 1132 | Uint32 NumOutputs DEFAULT_INITIALIZER(0); |
1132 | 1133 | }; |
1134 | typedef struct AdapterAttribs AdapterAttribs; | |
1133 | 1135 | |
1134 | 1136 | |
1135 | 1137 | /// Flags indicating how an image is stretched to fit a given monitor's resolution. |
1196 | 1198 | /// The scaling mode. |
1197 | 1199 | enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED); |
1198 | 1200 | }; |
1201 | typedef struct DisplayModeAttribs DisplayModeAttribs; | |
1199 | 1202 | |
1200 | 1203 | /// Defines allowed swap chain usage flags |
1201 | 1204 | DILIGENT_TYPED_ENUM(SWAP_CHAIN_USAGE_FLAGS, Uint32) |
1269 | 1272 | {} |
1270 | 1273 | #endif |
1271 | 1274 | }; |
1275 | typedef struct SwapChainDesc SwapChainDesc; | |
1272 | 1276 | |
1273 | 1277 | /// Full screen mode description |
1274 | 1278 | /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh404531(v=vs.85).aspx">DXGI_SWAP_CHAIN_FULLSCREEN_DESC structure on MSDN</a>, |
1289 | 1293 | /// The scaling mode. |
1290 | 1294 | enum SCANLINE_ORDER ScanlineOrder DEFAULT_INITIALIZER(SCANLINE_ORDER_UNSPECIFIED); |
1291 | 1295 | }; |
1296 | typedef struct FullScreenModeDesc FullScreenModeDesc; | |
1292 | 1297 | |
1293 | 1298 | /// Engine creation attibutes |
1294 | 1299 | struct EngineCreateInfo |
1298 | 1303 | |
1299 | 1304 | /// Pointer to the raw memory allocator that will be used for all memory allocation/deallocation |
1300 | 1305 | /// operations in the engine |
1301 | class IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr); | |
1306 | struct IMemoryAllocator* pRawMemAllocator DEFAULT_INITIALIZER(nullptr); | |
1302 | 1307 | |
1303 | 1308 | /// Pointer to the user-specified debug message callback function |
1304 | 1309 | DebugMessageCallbackType DebugMessageCallback DEFAULT_INITIALIZER(nullptr); |
1310 | 1315 | /// starting at position 1. |
1311 | 1316 | Uint32 NumDeferredContexts DEFAULT_INITIALIZER(0); |
1312 | 1317 | }; |
1318 | typedef struct EngineCreateInfo EngineCreateInfo; | |
1313 | 1319 | |
1314 | 1320 | |
1315 | 1321 | /// Attributes of the OpenGL-based engine implementation |
1327 | 1333 | void* pDisplay DEFAULT_INITIALIZER(nullptr); |
1328 | 1334 | #endif |
1329 | 1335 | }; |
1336 | typedef struct EngineGLCreateInfo EngineGLCreateInfo; | |
1330 | 1337 | |
1331 | 1338 | |
1332 | 1339 | /// Debug flags that can be specified when creating Direct3D11-based engine implementation. |
1389 | 1396 | /// \sa CreateDeviceAndContextsD3D11Type, CreateSwapChainD3D11Type, LoadGraphicsEngineD3D11 |
1390 | 1397 | D3D11_DEBUG_FLAGS DebugFlags DEFAULT_INITIALIZER(D3D11_DEBUG_FLAG_NONE); |
1391 | 1398 | }; |
1399 | typedef struct EngineD3D11CreateInfo EngineD3D11CreateInfo; | |
1400 | ||
1392 | 1401 | |
1393 | 1402 | /// Attributes specific to D3D12 engine |
1394 | 1403 | struct EngineD3D12CreateInfo DILIGENT_DERIVE(EngineCreateInfo) |
1492 | 1501 | #endif |
1493 | 1502 | ; |
1494 | 1503 | }; |
1504 | typedef struct EngineD3D12CreateInfo EngineD3D12CreateInfo; | |
1505 | ||
1495 | 1506 | |
1496 | 1507 | /// Descriptor pool size |
1497 | 1508 | struct VulkanDescriptorPoolSize |
1533 | 1544 | } |
1534 | 1545 | #endif |
1535 | 1546 | }; |
1547 | typedef struct VulkanDescriptorPoolSize VulkanDescriptorPoolSize; | |
1548 | ||
1536 | 1549 | |
1537 | 1550 | /// Attributes specific to Vulkan engine |
1538 | 1551 | struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) |
1557 | 1570 | /// Size of the main descriptor pool that is used to allocate descriptor sets |
1558 | 1571 | /// for static and mutable variables. If allocation from the current pool fails, |
1559 | 1572 | /// the engine creates another one. |
1560 | struct VulkanDescriptorPoolSize MainDescriptorPoolSize | |
1573 | VulkanDescriptorPoolSize MainDescriptorPoolSize | |
1561 | 1574 | #if DILIGENT_CPP_INTERFACE |
1562 | 1575 | //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB |
1563 | 1576 | {8192, 1024, 8192, 8192, 1024, 4096, 4096, 1024, 1024} |
1569 | 1582 | /// The allocator requests pools from global dynamic descriptor pool manager, and then |
1570 | 1583 | /// performs lock-free suballocations from the pool. |
1571 | 1584 | |
1572 | struct VulkanDescriptorPoolSize DynamicDescriptorPoolSize | |
1585 | VulkanDescriptorPoolSize DynamicDescriptorPoolSize | |
1573 | 1586 | #if DILIGENT_CPP_INTERFACE |
1574 | 1587 | //Max SepSm CmbSm SmpImg StrImg UB SB UTxB StTxB |
1575 | 1588 | {2048, 256, 2048, 2048, 256, 1024, 1024, 256, 256} |
1619 | 1632 | #endif |
1620 | 1633 | ; |
1621 | 1634 | }; |
1635 | typedef struct EngineVkCreateInfo EngineVkCreateInfo; | |
1622 | 1636 | |
1623 | 1637 | |
1624 | 1638 | /// Attributes of the Metal-based engine implementation |
1625 | 1639 | struct EngineMtlCreateInfo DILIGENT_DERIVE(EngineCreateInfo) |
1626 | 1640 | |
1627 | 1641 | }; |
1642 | typedef struct EngineMtlCreateInfo EngineMtlCreateInfo; | |
1628 | 1643 | |
1629 | 1644 | |
1630 | 1645 | /// Box |
1661 | 1676 | Box() noexcept {} |
1662 | 1677 | #endif |
1663 | 1678 | }; |
1679 | typedef struct Box Box; | |
1664 | 1680 | |
1665 | 1681 | |
1666 | 1682 | /// Describes texture format component type |
1762 | 1778 | TextureFormatAttribs()noexcept {} |
1763 | 1779 | #endif |
1764 | 1780 | }; |
1781 | typedef struct TextureFormatAttribs TextureFormatAttribs; | |
1782 | ||
1765 | 1783 | |
1766 | 1784 | /// Basic texture format description |
1767 | 1785 | |
1771 | 1789 | /// Indicates if the format is supported by the device |
1772 | 1790 | bool Supported DEFAULT_INITIALIZER(false); |
1773 | 1791 | }; |
1792 | typedef struct TextureFormatInfo TextureFormatInfo; | |
1793 | ||
1774 | 1794 | |
1775 | 1795 | /// Extended texture format description |
1776 | 1796 | |
1802 | 1822 | /// If the format supports n samples, then (SampleCounts & n) != 0 |
1803 | 1823 | Uint32 SampleCounts DEFAULT_INITIALIZER(0); |
1804 | 1824 | }; |
1825 | typedef struct TextureFormatInfoExt TextureFormatInfoExt; | |
1826 | ||
1805 | 1827 | |
1806 | 1828 | /// Resource usage state |
1807 | 1829 | DILIGENT_TYPED_ENUM(RESOURCE_STATE, Uint32) |
1894 | 1916 | { |
1895 | 1917 | /// Texture to transition. |
1896 | 1918 | /// \note Exactly one of pTexture or pBuffer must be non-null. |
1897 | class ITexture* pTexture DEFAULT_INITIALIZER(nullptr); | |
1919 | struct ITexture* pTexture DEFAULT_INITIALIZER(nullptr); | |
1898 | 1920 | |
1899 | 1921 | /// Buffer to transition. |
1900 | 1922 | /// \note Exactly one of pTexture or pBuffer must be non-null. |
1901 | class IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr); | |
1923 | struct IBuffer* pBuffer DEFAULT_INITIALIZER(nullptr); | |
1902 | 1924 | |
1903 | 1925 | /// When transitioning a texture, first mip level of the subresource range to transition. |
1904 | 1926 | Uint32 FirstMipLevel DEFAULT_INITIALIZER(0); |
1985 | 2007 | {} |
1986 | 2008 | #endif |
1987 | 2009 | }; |
2010 | typedef struct StateTransitionDesc StateTransitionDesc; | |
1988 | 2011 | |
1989 | 2012 | DILIGENT_END_NAMESPACE // namespace Diligent |
173 | 173 | {} |
174 | 174 | #endif |
175 | 175 | }; |
176 | typedef struct LayoutElement LayoutElement; | |
177 | ||
176 | 178 | |
177 | 179 | /// Layout description |
178 | 180 | |
179 | 181 | /// This structure is used by IRenderDevice::CreatePipelineState(). |
180 | struct InputLayoutDesc | |
182 | struct InputLayoutDesc | |
181 | 183 | { |
182 | 184 | /// Array of layout elements |
183 | const struct LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr); | |
185 | const LayoutElement* LayoutElements DEFAULT_INITIALIZER(nullptr); | |
184 | 186 | /// Number of layout elements |
185 | Uint32 NumElements DEFAULT_INITIALIZER(0); | |
187 | Uint32 NumElements DEFAULT_INITIALIZER(0); | |
186 | 188 | |
187 | 189 | #if DILIGENT_CPP_INTERFACE |
188 | 190 | InputLayoutDesc()noexcept{} |
194 | 196 | {} |
195 | 197 | #endif |
196 | 198 | }; |
199 | typedef struct InputLayoutDesc InputLayoutDesc; | |
197 | 200 | |
198 | 201 | DILIGENT_END_NAMESPACE |
66 | 66 | {} |
67 | 67 | #endif |
68 | 68 | }; |
69 | typedef struct SampleDesc SampleDesc; | |
69 | 70 | |
70 | 71 | |
71 | 72 | /// Describes shader variable |
90 | 91 | {} |
91 | 92 | #endif |
92 | 93 | }; |
94 | typedef struct ShaderResourceVariableDesc ShaderResourceVariableDesc; | |
93 | 95 | |
94 | 96 | |
95 | 97 | /// Static sampler description |
117 | 119 | {} |
118 | 120 | #endif |
119 | 121 | }; |
120 | ||
122 | typedef struct StaticSamplerDesc StaticSamplerDesc; | |
121 | 123 | |
122 | 124 | /// Pipeline layout description |
123 | 125 | struct PipelineResourceLayoutDesc |
125 | 127 | /// Default shader resource variable type. This type will be used if shader |
126 | 128 | /// variable description is not found in the Variables array |
127 | 129 | /// or if Variables == nullptr |
128 | SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); | |
130 | SHADER_RESOURCE_VARIABLE_TYPE DefaultVariableType DEFAULT_INITIALIZER(SHADER_RESOURCE_VARIABLE_TYPE_STATIC); | |
129 | 131 | |
130 | 132 | /// Number of elements in Variables array |
131 | Uint32 NumVariables DEFAULT_INITIALIZER(0); | |
133 | Uint32 NumVariables DEFAULT_INITIALIZER(0); | |
132 | 134 | |
133 | 135 | /// Array of shader resource variable descriptions |
134 | const struct ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr); | |
136 | const ShaderResourceVariableDesc* Variables DEFAULT_INITIALIZER(nullptr); | |
135 | 137 | |
136 | 138 | /// Number of static samplers in StaticSamplers array |
137 | Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0); | |
139 | Uint32 NumStaticSamplers DEFAULT_INITIALIZER(0); | |
138 | 140 | |
139 | 141 | /// Array of static sampler descriptions |
140 | const struct StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr); | |
141 | }; | |
142 | const StaticSamplerDesc* StaticSamplers DEFAULT_INITIALIZER(nullptr); | |
143 | }; | |
144 | typedef struct PipelineResourceLayoutDesc PipelineResourceLayoutDesc; | |
142 | 145 | |
143 | 146 | |
144 | 147 | /// Graphics pipeline state description |
147 | 150 | struct GraphicsPipelineDesc |
148 | 151 | { |
149 | 152 | /// Vertex shader to be used with the pipeline |
150 | class IShader* pVS DEFAULT_INITIALIZER(nullptr); | |
153 | IShader* pVS DEFAULT_INITIALIZER(nullptr); | |
151 | 154 | |
152 | 155 | /// Pixel shader to be used with the pipeline |
153 | class IShader* pPS DEFAULT_INITIALIZER(nullptr); | |
156 | IShader* pPS DEFAULT_INITIALIZER(nullptr); | |
154 | 157 | |
155 | 158 | /// Domain shader to be used with the pipeline |
156 | class IShader* pDS DEFAULT_INITIALIZER(nullptr); | |
159 | IShader* pDS DEFAULT_INITIALIZER(nullptr); | |
157 | 160 | |
158 | 161 | /// Hull shader to be used with the pipeline |
159 | class IShader* pHS DEFAULT_INITIALIZER(nullptr); | |
162 | IShader* pHS DEFAULT_INITIALIZER(nullptr); | |
160 | 163 | |
161 | 164 | /// Geometry shader to be used with the pipeline |
162 | class IShader* pGS DEFAULT_INITIALIZER(nullptr); | |
165 | IShader* pGS DEFAULT_INITIALIZER(nullptr); | |
163 | 166 | |
164 | 167 | //D3D12_STREAM_OUTPUT_DESC StreamOutput; |
165 | 168 | |
166 | 169 | /// Blend state description |
167 | struct BlendStateDesc BlendDesc; | |
170 | BlendStateDesc BlendDesc; | |
168 | 171 | |
169 | 172 | /// 32-bit sample mask that determines which samples get updated |
170 | 173 | /// in all the active render targets. A sample mask is always applied; |
173 | 176 | Uint32 SampleMask DEFAULT_INITIALIZER(0xFFFFFFFF); |
174 | 177 | |
175 | 178 | /// Rasterizer state description |
176 | struct RasterizerStateDesc RasterizerDesc; | |
179 | RasterizerStateDesc RasterizerDesc; | |
177 | 180 | |
178 | 181 | /// Depth-stencil state description |
179 | struct DepthStencilStateDesc DepthStencilDesc; | |
182 | DepthStencilStateDesc DepthStencilDesc; | |
180 | 183 | |
181 | 184 | /// Input layout |
182 | struct InputLayoutDesc InputLayout; | |
185 | InputLayoutDesc InputLayout; | |
183 | 186 | //D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; |
184 | 187 | |
185 | 188 | /// Primitive topology type |
198 | 201 | TEXTURE_FORMAT DSVFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN); |
199 | 202 | |
200 | 203 | /// Multisampling parameters |
201 | struct SampleDesc SmplDesc; | |
204 | SampleDesc SmplDesc; | |
202 | 205 | |
203 | 206 | /// Node mask. |
204 | 207 | Uint32 NodeMask DEFAULT_INITIALIZER(0); |
206 | 209 | //D3D12_CACHED_PIPELINE_STATE CachedPSO; |
207 | 210 | //D3D12_PIPELINE_STATE_FLAGS Flags; |
208 | 211 | }; |
212 | typedef struct GraphicsPipelineDesc GraphicsPipelineDesc; | |
209 | 213 | |
210 | 214 | |
211 | 215 | /// Compute pipeline state description |
214 | 218 | struct ComputePipelineDesc |
215 | 219 | { |
216 | 220 | /// Compute shader to be used with the pipeline |
217 | class IShader* pCS DEFAULT_INITIALIZER(nullptr); | |
218 | }; | |
221 | IShader* pCS DEFAULT_INITIALIZER(nullptr); | |
222 | }; | |
223 | typedef struct ComputePipelineDesc ComputePipelineDesc; | |
224 | ||
219 | 225 | |
220 | 226 | /// Pipeline state description |
221 | 227 | struct PipelineStateDesc DILIGENT_DERIVE(DeviceObjectAttribs) |
233 | 239 | Uint64 CommandQueueMask DEFAULT_INITIALIZER(1); |
234 | 240 | |
235 | 241 | /// Pipeline layout description |
236 | struct PipelineResourceLayoutDesc ResourceLayout; | |
242 | PipelineResourceLayoutDesc ResourceLayout; | |
237 | 243 | |
238 | 244 | /// Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True |
239 | struct GraphicsPipelineDesc GraphicsPipeline; | |
245 | GraphicsPipelineDesc GraphicsPipeline; | |
240 | 246 | |
241 | 247 | /// Compute pipeline state description. This memeber is ignored if IsComputePipeline == False |
242 | struct ComputePipelineDesc ComputePipeline; | |
243 | }; | |
248 | ComputePipelineDesc ComputePipeline; | |
249 | }; | |
250 | typedef struct PipelineStateDesc PipelineStateDesc; | |
244 | 251 | |
245 | 252 | // {06084AE5-6A71-4FE8-84B9-395DD489A28C} |
246 | 253 | static const struct INTERFACE_ID IID_PipelineState = |
247 | 254 | {0x6084ae5, 0x6a71, 0x4fe8, {0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c}}; |
248 | 255 | |
256 | ||
257 | #if DILIGENT_C_INTERFACE | |
258 | # define THIS struct IPipelineState* | |
259 | # define THIS_ struct IPipelineState*, | |
260 | #endif | |
261 | ||
262 | // clang-format off | |
263 | ||
264 | /// Pipeline state interface | |
265 | DILIGENT_INTERFACE(IPipelineState, IDeviceObject) | |
266 | { | |
249 | 267 | #if DILIGENT_CPP_INTERFACE |
250 | ||
251 | /// Pipeline state interface | |
252 | class IPipelineState : public IDeviceObject | |
253 | { | |
254 | public: | |
255 | 268 | /// Returns the blend state description used to create the object |
256 | 269 | virtual const PipelineStateDesc& GetDesc()const override = 0; |
270 | #endif | |
257 | 271 | |
258 | 272 | |
259 | 273 | /// Binds resources for all shaders in the pipeline state |
262 | 276 | /// Any combination of Diligent::SHADER_TYPE may be used. |
263 | 277 | /// \param [in] pResourceMapping - Pointer to the resource mapping interface. |
264 | 278 | /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS. |
265 | virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) = 0; | |
279 | VIRTUAL void METHOD(BindStaticResources)(THIS_ | |
280 | Uint32 ShaderFlags, | |
281 | IResourceMapping* pResourceMapping, | |
282 | Uint32 Flags) PURE; | |
266 | 283 | |
267 | 284 | |
268 | 285 | /// Returns the number of static shader resource variables. |
270 | 287 | /// \param [in] ShaderType - Type of the shader. |
271 | 288 | /// \remark Only static variables (that can be accessed directly through the PSO) are counted. |
272 | 289 | /// Mutable and dynamic variables are accessed through Shader Resource Binding object. |
273 | virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const = 0; | |
290 | VIRTUAL Uint32 METHOD(GetStaticVariableCount)(THIS_ | |
291 | SHADER_TYPE ShaderType) CONST PURE; | |
274 | 292 | |
275 | 293 | |
276 | 294 | /// Returns static shader resource variable. If the variable is not found, |
281 | 299 | /// \param [in] Name - Name of the variable. |
282 | 300 | /// \remark The method does not increment the reference counter |
283 | 301 | /// of the returned interface. |
284 | virtual IShaderResourceVariable* GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) = 0; | |
302 | VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByName)(THIS_ | |
303 | SHADER_TYPE ShaderType, | |
304 | const Char* Name) PURE; | |
285 | 305 | |
286 | 306 | |
287 | 307 | /// Returns static shader resource variable by its index. |
294 | 314 | /// \remark Only static shader resource variables can be accessed through this method. |
295 | 315 | /// Mutable and dynamic variables are accessed through Shader Resource |
296 | 316 | /// Binding object |
297 | virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0; | |
317 | VIRTUAL IShaderResourceVariable* METHOD(GetStaticVariableByIndex)(THIS_ | |
318 | SHADER_TYPE ShaderType, | |
319 | Uint32 Index) PURE; | |
298 | 320 | |
299 | 321 | |
300 | 322 | /// Creates a shader resource binding object |
304 | 326 | /// \param [in] InitStaticResources - if set to true, the method will initialize static resources in |
305 | 327 | /// the created object, which has the exact same effect as calling |
306 | 328 | /// IShaderResourceBinding::InitializeStaticResources(). |
307 | virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources = false) = 0; | |
329 | VIRTUAL void METHOD(CreateShaderResourceBinding)(THIS_ | |
330 | IShaderResourceBinding** ppShaderResourceBinding, | |
331 | bool InitStaticResources DEFAULT_VALUE(false)) PURE; | |
308 | 332 | |
309 | 333 | |
310 | 334 | /// Checks if this pipeline state object is compatible with another PSO |
321 | 345 | /// to commit resources for the second pipeline, a runtime error will occur.\n |
322 | 346 | /// The function only checks compatibility of shader resource layouts. It does not take |
323 | 347 | /// into account vertex shader input layout, number of outputs, etc. |
324 | virtual bool IsCompatibleWith(const IPipelineState* pPSO)const = 0; | |
325 | }; | |
326 | ||
327 | #else | |
328 | ||
329 | struct IPipelineState; | |
330 | ||
331 | struct IPipelineStateMethods | |
332 | { | |
333 | void (*BindStaticResources) (struct IPipelineState*, Uint32 ShaderFlags, class IResourceMapping* pResourceMapping, Uint32 Flags); | |
334 | Uint32 (*GetStaticVariableCount) (struct IPipelineState*, SHADER_TYPE ShaderType); | |
335 | class IShaderResourceVariable* (*GetStaticVariableByName) (struct IPipelineState*, SHADER_TYPE ShaderType, const Char* Name); | |
336 | class IShaderResourceVariable* (*GetStaticVariableByIndex) (struct IPipelineState*, SHADER_TYPE ShaderType, Uint32 Index); | |
337 | void (*CreateShaderResourceBinding)(struct IPipelineState*, class IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources); | |
338 | bool (*IsCompatibleWith) (struct IPipelineState*, const class IPipelineState* pPSO); | |
339 | }; | |
348 | VIRTUAL bool METHOD(IsCompatibleWith)(THIS_ | |
349 | const struct IPipelineState* pPSO) CONST PURE; | |
350 | }; | |
351 | ||
352 | #if DILIGENT_C_INTERFACE | |
353 | ||
354 | # undef THIS | |
355 | # undef THIS_ | |
340 | 356 | |
341 | 357 | // clang-format on |
342 | 358 | |
347 | 363 | struct IPipelineStateMethods PipelineState; |
348 | 364 | }; |
349 | 365 | |
350 | struct IPipelineState | |
366 | typedef struct IPipelineState | |
351 | 367 | { |
352 | 368 | struct IPipelineStateVtbl* pVtbl; |
353 | }; | |
369 | } IPipelineState; | |
354 | 370 | |
355 | 371 | // clang-format off |
356 | 372 | |
357 | 373 | # define IPipelineState_GetDesc(This) (const struct PipelineStateDesc*)IDeviceObject_GetDesc(This) |
358 | 374 | |
359 | # define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((struct IPipelineState*)(This), __VA_ARGS__) | |
360 | # define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((struct IPipelineState*)(This), __VA_ARGS__) | |
361 | # define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((struct IPipelineState*)(This), __VA_ARGS__) | |
362 | # define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((struct IPipelineState*)(This), __VA_ARGS__) | |
363 | # define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((struct IPipelineState*)(This), __VA_ARGS__) | |
364 | # define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((struct IPipelineState*)(This), __VA_ARGS__) | |
375 | # define IPipelineState_BindStaticResources(This, ...) (This)->pVtbl->PipelineState.BindStaticResources ((IPipelineState*)(This), __VA_ARGS__) | |
376 | # define IPipelineState_GetStaticVariableCount(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableCount ((IPipelineState*)(This), __VA_ARGS__) | |
377 | # define IPipelineState_GetStaticVariableByName(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByName ((IPipelineState*)(This), __VA_ARGS__) | |
378 | # define IPipelineState_GetStaticVariableByIndex(This, ...) (This)->pVtbl->PipelineState.GetStaticVariableByIndex ((IPipelineState*)(This), __VA_ARGS__) | |
379 | # define IPipelineState_CreateShaderResourceBinding(This, ...) (This)->pVtbl->PipelineState.CreateShaderResourceBinding((IPipelineState*)(This), __VA_ARGS__) | |
380 | # define IPipelineState_IsCompatibleWith(This, ...) (This)->pVtbl->PipelineState.IsCompatibleWith ((IPipelineState*)(This), __VA_ARGS__) | |
365 | 381 | |
366 | 382 | // clang-format on |
367 | 383 |
35 | 35 | |
36 | 36 | |
37 | 37 | // {70F2A88A-F8BE-4901-8F05-2F72FA695BA0} |
38 | static const struct INTERFACE_ID IID_Query = | |
38 | static const INTERFACE_ID IID_Query = | |
39 | 39 | {0x70f2a88a, 0xf8be, 0x4901, {0x8f, 0x5, 0x2f, 0x72, 0xfa, 0x69, 0x5b, 0xa0}}; |
40 | 40 | |
41 | 41 | /// Query type. |
76 | 76 | /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery. |
77 | 77 | Uint64 NumSamples DEFAULT_INITIALIZER(0); |
78 | 78 | }; |
79 | typedef struct QueryDataOcclusion QueryDataOcclusion; | |
79 | 80 | |
80 | 81 | /// Binary occlusion query data. |
81 | 82 | /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_BINARY_OCCLUSION query type. |
88 | 89 | /// IDeviceContext::BeginQuery and IDeviceContext::EndQuery. |
89 | 90 | bool AnySamplePassed DEFAULT_INITIALIZER(0); |
90 | 91 | }; |
92 | typedef struct QueryDataBinaryOcclusion QueryDataBinaryOcclusion; | |
91 | 93 | |
92 | 94 | /// Timestamp query data. |
93 | 95 | /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_TIMESTAMP query type. |
103 | 105 | /// while getting the timestamp, this value will be 0. |
104 | 106 | Uint64 Frequency DEFAULT_INITIALIZER(0); |
105 | 107 | }; |
108 | typedef struct QueryDataTimestamp QueryDataTimestamp; | |
106 | 109 | |
107 | 110 | /// Pipeline statistics query data. |
108 | 111 | /// This structure is filled by IQuery::GetData() for Diligent::QUERY_TYPE_PIPELINE_STATISTICS query type. |
148 | 151 | /// Number of times a compute shader was invoked. |
149 | 152 | Uint64 CSInvocations DEFAULT_INITIALIZER(0); |
150 | 153 | }; |
151 | ||
154 | typedef struct QueryDataPipelineStatistics QueryDataPipelineStatistics; | |
152 | 155 | |
153 | 156 | // clang-format off |
154 | 157 | |
166 | 169 | {} |
167 | 170 | #endif |
168 | 171 | }; |
169 | ||
170 | // clang-format on | |
171 | ||
172 | typedef struct QueryDesc QueryDesc; | |
173 | ||
174 | #if DILIGENT_C_INTERFACE | |
175 | # define THIS struct IQuery* | |
176 | # define THIS_ struct IQuery*, | |
177 | #endif | |
178 | ||
179 | // clang-format off | |
180 | ||
181 | /// Query interface. | |
182 | ||
183 | /// Defines the methods to manipulate a Query object | |
184 | DILIGENT_INTERFACE(IQuery, IDeviceObject) | |
185 | { | |
172 | 186 | #if DILIGENT_CPP_INTERFACE |
173 | ||
174 | /// Query interface. | |
175 | ||
176 | /// Defines the methods to manipulate a Query object | |
177 | class IQuery : public IDeviceObject | |
178 | { | |
179 | public: | |
180 | 187 | /// Returns the Query description used to create the object. |
181 | 188 | virtual const QueryDesc& GetDesc() const override = 0; |
189 | #endif | |
182 | 190 | |
183 | 191 | /// Gets the query data. |
184 | 192 | |
200 | 208 | /// |
201 | 209 | /// If AutoInvalidate is set to true, and the data have been retrieved, an application |
202 | 210 | /// must not call GetData() until it begins and ends the query again. |
203 | virtual bool GetData(void* pData, Uint32 DataSize, bool AutoInvalidate = true) = 0; | |
211 | VIRTUAL bool METHOD(GetData)(THIS_ | |
212 | void* pData, | |
213 | Uint32 DataSize, | |
214 | bool AutoInvalidate DEFAULT_VALUE(true)) PURE; | |
204 | 215 | |
205 | 216 | /// Invalidates the query and releases associated resources. |
206 | virtual void Invalidate() = 0; | |
207 | }; | |
208 | ||
209 | #else | |
210 | ||
211 | struct IQuery; | |
212 | ||
213 | // clang-format off | |
214 | ||
215 | struct IQueryMethods | |
216 | { | |
217 | bool (*GetData) (struct IQuery*, void* pData, Uint32 DataSize, bool AutoInvalidate); | |
218 | void (*Invalidate)(struct IQuery*); | |
219 | }; | |
217 | VIRTUAL void METHOD(Invalidate)(THIS) PURE; | |
218 | }; | |
219 | ||
220 | #if DILIGENT_C_INTERFACE | |
221 | ||
222 | # undef THIS | |
223 | # undef THIS_ | |
220 | 224 | |
221 | 225 | // clang-format on |
222 | 226 | |
227 | 231 | struct IQueryMethods Query; |
228 | 232 | }; |
229 | 233 | |
230 | struct IQuery | |
234 | typedef struct IQuery | |
231 | 235 | { |
232 | 236 | struct IQueryVtbl* pVtbl; |
233 | }; | |
237 | } IQuery; | |
234 | 238 | |
235 | 239 | // clang-format off |
236 | 240 | |
237 | 241 | # define IQuery_GetDesc(This) (const struct QueryDesc*)IDeviceObject_GetDesc(This) |
238 | 242 | |
239 | # define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((struct IQuery*)(This), __VA_ARGS__) | |
240 | # define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((struct IQuery*)(This)) | |
243 | # define IQuery_GetData(This, ...) (This)->pVtbl->Query.GetData ((IQuery*)(This), __VA_ARGS__) | |
244 | # define IQuery_Invalidate(This) (This)->pVtbl->Query.Invalidate((IQuery*)(This)) | |
241 | 245 | |
242 | 246 | // clang-format on |
243 | 247 |
180 | 180 | } |
181 | 181 | #endif |
182 | 182 | }; |
183 | typedef struct RasterizerStateDesc RasterizerStateDesc; | |
183 | 184 | |
184 | 185 | DILIGENT_END_NAMESPACE |
53 | 53 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
54 | 54 | |
55 | 55 | // {F0E9B607-AE33-4B2B-B1AF-A8B2C3104022} |
56 | static const struct INTERFACE_ID IID_RenderDevice = | |
56 | static const INTERFACE_ID IID_RenderDevice = | |
57 | 57 | {0xf0e9b607, 0xae33, 0x4b2b, {0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22}}; |
58 | 58 | |
59 | #if DILIGENT_CPP_INTERFACE | |
59 | #if DILIGENT_C_INTERFACE | |
60 | # define THIS struct IRenderDevice* | |
61 | # define THIS_ struct IRenderDevice*, | |
62 | #endif | |
63 | ||
64 | // clang-format off | |
60 | 65 | |
61 | 66 | /// Render device interface |
62 | class IRenderDevice : public IObject | |
67 | DILIGENT_INTERFACE(IRenderDevice, IObject) | |
63 | 68 | { |
64 | public: | |
65 | 69 | /// Creates a new buffer object |
66 | 70 | |
67 | 71 | /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details. |
77 | 81 | /// Size of a uniform buffer (BIND_UNIFORM_BUFFER) must be multiple of 16.\n |
78 | 82 | /// Stride of a formatted buffer will be computed automatically from the format if |
79 | 83 | /// ElementByteStride member of buffer description is set to default value (0). |
80 | virtual void CreateBuffer(const BufferDesc& BuffDesc, | |
81 | const BufferData* pBuffData, | |
82 | IBuffer** ppBuffer) = 0; | |
84 | VIRTUAL void METHOD(CreateBuffer)(THIS_ | |
85 | const BufferDesc REF BuffDesc, | |
86 | const BufferData* pBuffData, | |
87 | IBuffer** ppBuffer) PURE; | |
83 | 88 | |
84 | 89 | /// Creates a new shader object |
85 | 90 | |
88 | 93 | /// shader interface will be stored. |
89 | 94 | /// The function calls AddRef(), so that the new object will contain |
90 | 95 | /// one reference. |
91 | virtual void CreateShader(const ShaderCreateInfo& ShaderCI, | |
92 | IShader** ppShader) = 0; | |
96 | VIRTUAL void METHOD(CreateShader)(THIS_ | |
97 | const ShaderCreateInfo REF ShaderCI, | |
98 | IShader** ppShader) PURE; | |
93 | 99 | |
94 | 100 | /// Creates a new texture object |
95 | 101 | |
113 | 119 | /// 15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.\n |
114 | 120 | /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n |
115 | 121 | /// 15x6x4, 7x3x2, 3x1x1, 1x1x1 |
116 | virtual void CreateTexture(const TextureDesc& TexDesc, | |
117 | const TextureData* pData, | |
118 | ITexture** ppTexture) = 0; | |
122 | VIRTUAL void METHOD(CreateTexture)(THIS_ | |
123 | const TextureDesc REF TexDesc, | |
124 | const TextureData* pData, | |
125 | ITexture** ppTexture) PURE; | |
119 | 126 | |
120 | 127 | /// Creates a new sampler object |
121 | 128 | |
127 | 134 | /// \remark If an application attempts to create a sampler interface with the same attributes |
128 | 135 | /// as an existing interface, the same interface will be returned. |
129 | 136 | /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time. |
130 | virtual void CreateSampler(const SamplerDesc& SamDesc, | |
131 | ISampler** ppSampler) = 0; | |
137 | VIRTUAL void METHOD(CreateSampler)(THIS_ | |
138 | const SamplerDesc REF SamDesc, | |
139 | ISampler** ppSampler) PURE; | |
132 | 140 | |
133 | 141 | /// Creates a new resource mapping |
134 | 142 | |
137 | 145 | /// resource mapping interface will be stored. |
138 | 146 | /// The function calls AddRef(), so that the new object will contain |
139 | 147 | /// one reference. |
140 | virtual void CreateResourceMapping(const ResourceMappingDesc& MappingDesc, | |
141 | IResourceMapping** ppMapping) = 0; | |
148 | VIRTUAL void METHOD(CreateResourceMapping)(THIS_ | |
149 | const ResourceMappingDesc REF MappingDesc, | |
150 | IResourceMapping** ppMapping) PURE; | |
142 | 151 | |
143 | 152 | /// Creates a new pipeline state object |
144 | 153 | |
147 | 156 | /// pipeline state interface will be stored. |
148 | 157 | /// The function calls AddRef(), so that the new object will contain |
149 | 158 | /// one reference. |
150 | virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, | |
151 | IPipelineState** ppPipelineState) = 0; | |
159 | VIRTUAL void METHOD(CreatePipelineState)(THIS_ | |
160 | const PipelineStateDesc REF PipelineDesc, | |
161 | IPipelineState** ppPipelineState) PURE; | |
152 | 162 | |
153 | 163 | |
154 | 164 | /// Creates a new fence object |
158 | 168 | /// fence interface will be stored. |
159 | 169 | /// The function calls AddRef(), so that the new object will contain |
160 | 170 | /// one reference. |
161 | virtual void CreateFence(const FenceDesc& Desc, | |
162 | IFence** ppFence) = 0; | |
171 | VIRTUAL void METHOD(CreateFence)(THIS_ | |
172 | const FenceDesc REF Desc, | |
173 | IFence** ppFence) PURE; | |
163 | 174 | |
164 | 175 | |
165 | 176 | /// Creates a new query object |
169 | 180 | /// query interface will be stored. |
170 | 181 | /// The function calls AddRef(), so that the new object will contain |
171 | 182 | /// one reference. |
172 | virtual void CreateQuery(const QueryDesc& Desc, | |
173 | IQuery** ppQuery) = 0; | |
183 | VIRTUAL void METHOD(CreateQuery)(THIS_ | |
184 | const QueryDesc REF Desc, | |
185 | IQuery** ppQuery) PURE; | |
174 | 186 | |
175 | 187 | |
176 | 188 | /// Gets the device capabilities, see Diligent::DeviceCaps for details |
177 | virtual const DeviceCaps& GetDeviceCaps() const = 0; | |
189 | VIRTUAL const DeviceCaps REF METHOD(GetDeviceCaps)(THIS) CONST PURE; | |
178 | 190 | |
179 | 191 | |
180 | 192 | /// Returns the basic texture format information. |
183 | 195 | /// \param [in] TexFormat - Texture format for which to provide the information |
184 | 196 | /// \return Const reference to the TextureFormatInfo structure containing the |
185 | 197 | /// texture format description. |
186 | virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat) = 0; | |
198 | VIRTUAL const TextureFormatInfo REF METHOD(GetTextureFormatInfo)(THIS_ | |
199 | TEXTURE_FORMAT TexFormat) PURE; | |
187 | 200 | |
188 | 201 | |
189 | 202 | /// Returns the extended texture format information. |
195 | 208 | /// \remark The first time this method is called for a particular format, it may be |
196 | 209 | /// considerably slower than GetTextureFormatInfo(). If you do not require |
197 | 210 | /// extended information, call GetTextureFormatInfo() instead. |
198 | virtual const TextureFormatInfoExt& GetTextureFormatInfoExt(TEXTURE_FORMAT TexFormat) = 0; | |
211 | VIRTUAL const TextureFormatInfoExt REF METHOD(GetTextureFormatInfoExt)(THIS_ | |
212 | TEXTURE_FORMAT TexFormat) PURE; | |
199 | 213 | |
200 | 214 | /// Purges device release queues and releases all stale resources. |
201 | 215 | /// This method is automatically called by ISwapChain::Present() of the primary swap chain. |
202 | 216 | /// \param [in] ForceRelease - Forces release of all objects. Use this option with |
203 | 217 | /// great care only if you are sure the resources are not |
204 | 218 | /// in use by the GPU (such as when the device has just been idled). |
205 | virtual void ReleaseStaleResources(bool ForceRelease = false) = 0; | |
219 | VIRTUAL void METHOD(ReleaseStaleResources)(THIS_ | |
220 | bool ForceRelease DEFAULT_VALUE(false)) PURE; | |
206 | 221 | |
207 | 222 | |
208 | 223 | /// Waits until all outstanding operations on the GPU are complete. |
213 | 228 | /// have been previously submitted for execution. An application should explicitly flush |
214 | 229 | /// the contexts using IDeviceContext::Flush() if it needs to make sure all recorded commands |
215 | 230 | /// are complete when the method returns. |
216 | virtual void IdleGPU() = 0; | |
231 | VIRTUAL void METHOD(IdleGPU)(THIS) PURE; | |
217 | 232 | |
218 | 233 | |
219 | 234 | /// Returns engine factory this device was created from. |
220 | 235 | /// \remark This method does not increment the reference counter of the returned interface, |
221 | 236 | /// so the application should not call Release(). |
222 | virtual IEngineFactory* GetEngineFactory() const = 0; | |
237 | VIRTUAL IEngineFactory* METHOD(GetEngineFactory)(THIS) CONST PURE; | |
223 | 238 | }; |
224 | 239 | |
225 | #else | |
226 | ||
227 | struct IRenderDevice; | |
228 | ||
229 | struct IRenderDeviceMethods | |
230 | { | |
231 | void (*CreateBuffer)(struct IRenderDevice*, | |
232 | const struct BufferDesc* BuffDesc, | |
233 | const struct BufferData* pBuffData, | |
234 | class IBuffer** ppBuffer); | |
235 | void (*CreateShader)(struct IRenderDevice*, | |
236 | const struct ShaderCreateInfo* ShaderCI, | |
237 | class IShader** ppShader); | |
238 | void (*CreateTexture)(struct IRenderDevice*, | |
239 | const struct TextureDesc* TexDesc, | |
240 | const struct TextureData* pData, | |
241 | class ITexture** ppTexture); | |
242 | void (*CreateSampler)(struct IRenderDevice*, | |
243 | const struct SamplerDesc* SamDesc, | |
244 | class ISampler** ppSampler); | |
245 | void (*CreateResourceMapping)(struct IRenderDevice*, | |
246 | const struct ResourceMappingDesc* MappingDesc, | |
247 | class IResourceMapping** ppMapping); | |
248 | void (*CreatePipelineState)(struct IRenderDevice*, | |
249 | const struct PipelineStateDesc* PipelineDesc, | |
250 | class IPipelineState** ppPipelineState); | |
251 | void (*CreateFence)(struct IRenderDevice*, | |
252 | const struct FenceDesc* Desc, | |
253 | class IFence** ppFence); | |
254 | void (*CreateQuery)(struct IRenderDevice*, | |
255 | const struct QueryDesc* Desc, | |
256 | class IQuery** ppQuery); | |
257 | const struct DeviceCaps* (*GetDeviceCaps)(struct IRenderDevice*); | |
258 | const struct TextureFormatInfo* (*GetTextureFormatInfo)(struct IRenderDevice*, | |
259 | TEXTURE_FORMAT TexFormat); | |
260 | const struct TextureFormatInfoExt* (*GetTextureFormatInfoExt)(struct IRenderDevice*, | |
261 | TEXTURE_FORMAT TexFormat); | |
262 | void (*ReleaseStaleResources)(struct IRenderDevice*, | |
263 | bool ForceRelease); | |
264 | void (*IdleGPU)(struct IRenderDevice*); | |
265 | class IEngineFactory* (*GetEngineFactory)(struct IRenderDevice*); | |
266 | }; | |
240 | ||
241 | #if DILIGENT_C_INTERFACE | |
242 | ||
243 | # undef THIS | |
244 | # undef THIS | |
245 | ||
246 | // clang-format on | |
267 | 247 | |
268 | 248 | struct IRenderDeviceVtbl |
269 | 249 | { |
271 | 251 | struct IRenderDeviceMethods RenderDevice; |
272 | 252 | }; |
273 | 253 | |
274 | struct IRenderDevice | |
254 | typedef struct IRenderDevice | |
275 | 255 | { |
276 | 256 | struct IRenderDeviceVtbl* pVtbl; |
277 | }; | |
257 | } IRenderDevice; | |
278 | 258 | |
279 | 259 | // clang-format off |
280 | 260 | |
281 | # define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((struct IRenderDevice*)(This), __VA_ARGS__) | |
282 | # define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((struct IRenderDevice*)(This), __VA_ARGS__) | |
283 | # define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((struct IRenderDevice*)(This), __VA_ARGS__) | |
284 | # define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((struct IRenderDevice*)(This), __VA_ARGS__) | |
285 | # define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((struct IRenderDevice*)(This), __VA_ARGS__) | |
286 | # define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((struct IRenderDevice*)(This), __VA_ARGS__) | |
287 | # define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((struct IRenderDevice*)(This), __VA_ARGS__) | |
288 | # define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((struct IRenderDevice*)(This), __VA_ARGS__) | |
289 | # define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((struct IRenderDevice*)(This)) | |
290 | # define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((struct IRenderDevice*)(This), __VA_ARGS__) | |
291 | # define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((struct IRenderDevice*)(This), __VA_ARGS__) | |
292 | # define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((struct IRenderDevice*)(This), __VA_ARGS__) | |
293 | # define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((struct IRenderDevice*)(This)) | |
294 | # define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((struct IRenderDevice*)(This)) | |
261 | # define IRenderDevice_CreateBuffer(This, ...) (This)->pVtbl->RenderDevice.CreateBuffer ((IRenderDevice*)(This), __VA_ARGS__) | |
262 | # define IRenderDevice_CreateShader(This, ...) (This)->pVtbl->RenderDevice.CreateShader ((IRenderDevice*)(This), __VA_ARGS__) | |
263 | # define IRenderDevice_CreateTexture(This, ...) (This)->pVtbl->RenderDevice.CreateTexture ((IRenderDevice*)(This), __VA_ARGS__) | |
264 | # define IRenderDevice_CreateSampler(This, ...) (This)->pVtbl->RenderDevice.CreateSampler ((IRenderDevice*)(This), __VA_ARGS__) | |
265 | # define IRenderDevice_CreateResourceMapping(This, ...) (This)->pVtbl->RenderDevice.CreateResourceMapping ((IRenderDevice*)(This), __VA_ARGS__) | |
266 | # define IRenderDevice_CreatePipelineState(This, ...) (This)->pVtbl->RenderDevice.CreatePipelineState ((IRenderDevice*)(This), __VA_ARGS__) | |
267 | # define IRenderDevice_CreateFence(This, ...) (This)->pVtbl->RenderDevice.CreateFence ((IRenderDevice*)(This), __VA_ARGS__) | |
268 | # define IRenderDevice_CreateQuery(This, ...) (This)->pVtbl->RenderDevice.CreateQuery ((IRenderDevice*)(This), __VA_ARGS__) | |
269 | # define IRenderDevice_GetDeviceCaps(This) (This)->pVtbl->RenderDevice.GetDeviceCaps ((IRenderDevice*)(This)) | |
270 | # define IRenderDevice_GetTextureFormatInfo(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfo ((IRenderDevice*)(This), __VA_ARGS__) | |
271 | # define IRenderDevice_GetTextureFormatInfoExt(This, ...) (This)->pVtbl->RenderDevice.GetTextureFormatInfoExt((IRenderDevice*)(This), __VA_ARGS__) | |
272 | # define IRenderDevice_ReleaseStaleResources(This, ...) (This)->pVtbl->RenderDevice.ReleaseStaleResources ((IRenderDevice*)(This), __VA_ARGS__) | |
273 | # define IRenderDevice_IdleGPU(This) (This)->pVtbl->RenderDevice.IdleGPU ((IRenderDevice*)(This)) | |
274 | # define IRenderDevice_GetEngineFactory(This) (This)->pVtbl->RenderDevice.GetEngineFactory ((IRenderDevice*)(This)) | |
295 | 275 | |
296 | 276 | // clang-format on |
297 | 277 |
34 | 34 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
35 | 35 | |
36 | 36 | // {6C1AC7A6-B429-4139-9433-9E54E93E384A} |
37 | static const struct INTERFACE_ID IID_ResourceMapping = | |
37 | static const INTERFACE_ID IID_ResourceMapping = | |
38 | 38 | {0x6c1ac7a6, 0xb429, 0x4139, {0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a}}; |
39 | 39 | |
40 | 40 | /// Describes the resourse mapping object entry |
43 | 43 | // clang-format off |
44 | 44 | |
45 | 45 | /// Object name |
46 | const Char* Name DEFAULT_INITIALIZER(nullptr); | |
46 | const Char* Name DEFAULT_INITIALIZER(nullptr); | |
47 | 47 | |
48 | 48 | /// Pointer to the object's interface |
49 | class IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr); | |
50 | ||
51 | Uint32 ArrayIndex DEFAULT_INITIALIZER(0); | |
49 | IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr); | |
50 | ||
51 | Uint32 ArrayIndex DEFAULT_INITIALIZER(0); | |
52 | 52 | |
53 | 53 | |
54 | 54 | #if DILIGENT_CPP_INTERFACE |
67 | 67 | // clang-format on |
68 | 68 | #endif |
69 | 69 | }; |
70 | typedef struct ResourceMappingEntry ResourceMappingEntry; | |
71 | ||
70 | 72 | |
71 | 73 | /// Resource mapping description |
72 | 74 | struct ResourceMappingDesc |
74 | 76 | /// Pointer to the array of resource mapping entries. |
75 | 77 | /// The last element in the array must be default value |
76 | 78 | /// created by ResourceMappingEntry::ResourceMappingEntry() |
77 | struct ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr); | |
79 | ResourceMappingEntry* pEntries DEFAULT_INITIALIZER(nullptr); | |
78 | 80 | |
79 | 81 | #if DILIGENT_CPP_INTERFACE |
80 | 82 | ResourceMappingDesc() noexcept |
85 | 87 | {} |
86 | 88 | #endif |
87 | 89 | }; |
88 | ||
89 | ||
90 | #if DILIGENT_CPP_INTERFACE | |
90 | typedef struct ResourceMappingDesc ResourceMappingDesc; | |
91 | ||
92 | ||
93 | #if DILIGENT_C_INTERFACE | |
94 | # define THIS struct IResourceMapping* | |
95 | # define THIS_ struct IResourceMapping*, | |
96 | #endif | |
97 | ||
98 | // clang-format off | |
91 | 99 | |
92 | 100 | /// Resouce mapping |
93 | 101 | |
94 | 102 | /// This interface provides mapping between literal names and resource pointers. |
95 | 103 | /// It is created by IRenderDevice::CreateResourceMapping(). |
96 | 104 | /// \remarks Resource mapping holds strong references to all objects it keeps. |
97 | class IResourceMapping : public IObject | |
98 | { | |
99 | public: | |
105 | DILIGENT_INTERFACE(IResourceMapping, IObject) | |
106 | { | |
100 | 107 | /// Adds a resource to the mapping. |
101 | 108 | |
102 | 109 | /// \param [in] Name - Resource name. |
107 | 114 | /// |
108 | 115 | /// \remarks Resource mapping increases the reference counter for referenced objects. So an |
109 | 116 | /// object will not be released as long as it is in the resource mapping. |
110 | virtual void AddResource(const Char* Name, IDeviceObject* pObject, bool bIsUnique) = 0; | |
117 | VIRTUAL void METHOD(AddResource)(THIS_ | |
118 | const Char* Name, | |
119 | IDeviceObject* pObject, | |
120 | bool bIsUnique) PURE; | |
111 | 121 | |
112 | 122 | |
113 | 123 | /// Adds resource array to the mapping. |
122 | 132 | /// |
123 | 133 | /// \remarks Resource mapping increases the reference counter for referenced objects. So an |
124 | 134 | /// object will not be released as long as it is in the resource mapping. |
125 | virtual void AddResourceArray(const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique) = 0; | |
135 | VIRTUAL void METHOD(AddResourceArray)(THIS_ | |
136 | const Char* Name, | |
137 | Uint32 StartIndex, | |
138 | IDeviceObject* const* ppObjects, | |
139 | Uint32 NumElements, | |
140 | bool bIsUnique) PURE; | |
126 | 141 | |
127 | 142 | |
128 | 143 | /// Removes a resource from the mapping using its literal name. |
129 | 144 | |
130 | 145 | /// \param [in] Name - Name of the resource to remove. |
131 | 146 | /// \param [in] ArrayIndex - For array resources, index in the array |
132 | virtual void RemoveResourceByName(const Char* Name, Uint32 ArrayIndex = 0) = 0; | |
147 | VIRTUAL void METHOD(RemoveResourceByName)(THIS_ | |
148 | const Char* Name, | |
149 | Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE; | |
133 | 150 | |
134 | 151 | /// Finds a resource in the mapping. |
135 | 152 | |
140 | 157 | /// If no object is found, nullptr will be written. |
141 | 158 | /// \remarks The method increases the reference counter |
142 | 159 | /// of the returned object, so Release() must be called. |
143 | virtual void GetResource(const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex = 0) = 0; | |
160 | VIRTUAL void METHOD(GetResource)(THIS_ | |
161 | const Char* Name, | |
162 | IDeviceObject** ppResource, | |
163 | Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE; | |
144 | 164 | |
145 | 165 | /// Returns the size of the resource mapping, i.e. the number of objects. |
146 | virtual size_t GetSize() = 0; | |
147 | }; | |
148 | ||
149 | #else | |
150 | ||
151 | struct IResourceMapping; | |
152 | ||
153 | // clang-format off | |
154 | ||
155 | struct IResourceMappingMethods | |
156 | { | |
157 | void (*AddResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject* pObject, bool bIsUnique); | |
158 | void (*AddResourceArray) (struct IResourceMapping*, const Char* Name, Uint32 StartIndex, class IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique); | |
159 | void (*RemoveResourceByName)(struct IResourceMapping*, const Char* Name, Uint32 ArrayIndex); | |
160 | void (*GetResource) (struct IResourceMapping*, const Char* Name, class IDeviceObject** ppResource, Uint32 ArrayIndex); | |
161 | size_t (*GetSize) (struct IResourceMapping*); | |
162 | }; | |
166 | VIRTUAL size_t METHOD(GetSize)(THIS) PURE; | |
167 | }; | |
168 | ||
169 | #if DILIGENT_C_INTERFACE | |
170 | ||
171 | # undef THIS | |
172 | # undef THIS_ | |
163 | 173 | |
164 | 174 | // clang-format on |
165 | 175 | |
169 | 179 | struct IResourceMappingMethods ResourceMapping; |
170 | 180 | }; |
171 | 181 | |
172 | struct IResourceMapping | |
182 | typedef struct IResourceMapping | |
173 | 183 | { |
174 | 184 | struct IResourceMappingVtbl* pVtbl; |
175 | }; | |
185 | } IResourceMapping; | |
176 | 186 | |
177 | 187 | // clang-format off |
178 | 188 | |
179 | # define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((struct IResourceMapping*)(This), __VA_ARGS__) | |
180 | # define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((struct IResourceMapping*)(This), __VA_ARGS__) | |
181 | # define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((struct IResourceMapping*)(This), __VA_ARGS__) | |
182 | # define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((struct IResourceMapping*)(This), __VA_ARGS__) | |
183 | # define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((struct IResourceMapping*)(This)) | |
189 | # define IResourceMapping_AddResource(This, ...) (This)->pVtbl->ResourceMapping.AddResource ((IResourceMapping*)(This), __VA_ARGS__) | |
190 | # define IResourceMapping_AddResourceArray(This, ...) (This)->pVtbl->ResourceMapping.AddResourceArray ((IResourceMapping*)(This), __VA_ARGS__) | |
191 | # define IResourceMapping_RemoveResourceByName(This, ...) (This)->pVtbl->ResourceMapping.RemoveResourceByName((IResourceMapping*)(This), __VA_ARGS__) | |
192 | # define IResourceMapping_GetResource(This, ...) (This)->pVtbl->ResourceMapping.GetResource ((IResourceMapping*)(This), __VA_ARGS__) | |
193 | # define IResourceMapping_GetSize(This) (This)->pVtbl->ResourceMapping.GetSize ((IResourceMapping*)(This)) | |
184 | 194 | |
185 | 195 | // clang-format on |
186 | 196 |
35 | 35 | |
36 | 36 | |
37 | 37 | // {595A59BF-FA81-4855-BC5E-C0E048745A95} |
38 | static const struct INTERFACE_ID IID_Sampler = | |
38 | static const INTERFACE_ID IID_Sampler = | |
39 | 39 | {0x595a59bf, 0xfa81, 0x4855, {0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95}}; |
40 | 40 | |
41 | 41 | |
168 | 168 | } |
169 | 169 | #endif |
170 | 170 | }; |
171 | typedef struct SamplerDesc SamplerDesc; | |
171 | 172 | |
172 | 173 | |
173 | 174 | #if DILIGENT_CPP_INTERFACE |
174 | 175 | |
175 | // clang-format on | |
176 | // clang-format off | |
176 | 177 | |
177 | 178 | /// Texture sampler interface. |
178 | 179 | |
179 | 180 | /// The interface holds the sampler state that can be used to perform texture filtering. |
180 | 181 | /// To create a sampler, call IRenderDevice::CreateSampler(). To use a sampler, |
181 | 182 | /// call ITextureView::SetSampler(). |
182 | class ISampler : public IDeviceObject | |
183 | DILIGENT_INTERFACE(ISampler, IDeviceObject) | |
183 | 184 | { |
184 | public: | |
185 | #if DILIGENT_CPP_INTERFACE | |
185 | 186 | /// Returns the sampler description used to create the object |
186 | 187 | virtual const SamplerDesc& GetDesc() const override = 0; |
188 | #endif | |
187 | 189 | }; |
188 | 190 | |
189 | #else | |
191 | #endif | |
192 | ||
193 | #if DILIGENT_C_INTERFACE | |
194 | ||
195 | // clang-format on | |
190 | 196 | |
191 | 197 | struct ISampler; |
192 | 198 | |
201 | 207 | //struct ISamplerMethods Sampler; |
202 | 208 | }; |
203 | 209 | |
204 | struct ISampler | |
210 | typedef struct ISampler | |
205 | 211 | { |
206 | 212 | struct ISamplerVtbl* pVtbl; |
207 | }; | |
213 | } ISampler; | |
208 | 214 | |
209 | 215 | # define ISampler_GetDesc(This) (const struct SamplerDesc*)IDeviceObject_GetDesc(This) |
210 | 216 |
35 | 35 | |
36 | 36 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
37 | 37 | |
38 | ||
39 | 38 | // {2989B45C-143D-4886-B89C-C3271C2DCC5D} |
40 | static const struct INTERFACE_ID IID_Shader = | |
39 | static const INTERFACE_ID IID_Shader = | |
41 | 40 | {0x2989b45c, 0x143d, 0x4886, {0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d}}; |
42 | 41 | |
43 | 42 | // clang-format off |
74 | 73 | /// Shader type. See Diligent::SHADER_TYPE. |
75 | 74 | SHADER_TYPE ShaderType DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN); |
76 | 75 | }; |
76 | typedef struct ShaderDesc ShaderDesc; | |
77 | 77 | |
78 | 78 | // clang-format on |
79 | 79 | |
80 | 80 | // {3EA98781-082F-4413-8C30-B9BA6D82DBB7} |
81 | static const struct INTERFACE_ID IID_IShaderSourceInputStreamFactory = | |
81 | static const INTERFACE_ID IID_IShaderSourceInputStreamFactory = | |
82 | 82 | {0x3ea98781, 0x82f, 0x4413, {0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7}}; |
83 | 83 | |
84 | 84 | |
85 | #if DILIGENT_CPP_INTERFACE | |
85 | // clang-format off | |
86 | ||
87 | #if DILIGENT_C_INTERFACE | |
88 | # define THIS struct IShaderSourceInputStreamFactory* | |
89 | # define THIS_ struct IShaderSourceInputStreamFactory*, | |
90 | #endif | |
86 | 91 | |
87 | 92 | /// Shader source stream factory interface |
88 | class IShaderSourceInputStreamFactory : public IObject | |
89 | { | |
90 | public: | |
91 | virtual void CreateInputStream(const Diligent::Char* Name, IFileStream** ppStream) = 0; | |
92 | }; | |
93 | ||
94 | #else | |
95 | ||
96 | #endif | |
93 | DILIGENT_INTERFACE(IShaderSourceInputStreamFactory, IObject) | |
94 | { | |
95 | VIRTUAL void METHOD(CreateInputStream)(THIS_ | |
96 | const Char* Name, | |
97 | IFileStream** ppStream) PURE; | |
98 | }; | |
99 | ||
100 | ||
101 | #if DILIGENT_C_INTERFACE | |
102 | ||
103 | # undef THIS | |
104 | # undef THIS_ | |
105 | ||
106 | // clang-format on | |
107 | ||
108 | struct IShaderSourceInputStreamFactoryVtbl | |
109 | { | |
110 | struct IObjectMethods Object; | |
111 | struct IShaderSourceInputStreamFactoryMethods ShaderSourceInputStreamFactory; | |
112 | }; | |
113 | ||
114 | typedef struct IShaderSourceInputStreamFactory | |
115 | { | |
116 | struct IShaderSourceInputStreamFactoryVtbl* pVtbl; | |
117 | } IShaderSourceInputStreamFactory; | |
118 | ||
119 | # define IShaderSourceInputStreamFactory_CreateInputStream(This, ...) (This)->pVtbl->ShaderSourceInputStreamFactory.CreateInputStream((IShaderSourceInputStreamFactory*)(This), __VA_ARGS__) | |
120 | ||
121 | #endif | |
122 | ||
97 | 123 | |
98 | 124 | struct ShaderMacro |
99 | 125 | { |
110 | 136 | {} |
111 | 137 | #endif |
112 | 138 | }; |
139 | typedef struct ShaderMacro ShaderMacro; | |
113 | 140 | |
114 | 141 | /// Shader version |
115 | 142 | struct ShaderVersion |
129 | 156 | {} |
130 | 157 | #endif |
131 | 158 | }; |
159 | typedef struct ShaderVersion ShaderVersion; | |
132 | 160 | |
133 | 161 | /// Shader creation attributes |
134 | 162 | struct ShaderCreateInfo |
142 | 170 | |
143 | 171 | /// The factory is used to load the shader source file if FilePath is not null. |
144 | 172 | /// It is also used to create additional input streams for shader include files |
145 | class IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr); | |
173 | IShaderSourceInputStreamFactory* pShaderSourceStreamFactory DEFAULT_INITIALIZER(nullptr); | |
146 | 174 | |
147 | 175 | /// HLSL->GLSL conversion stream |
148 | 176 | |
155 | 183 | /// the first time and will use it in all subsequent times. |
156 | 184 | /// For all subsequent conversions, FilePath member must be the same, or |
157 | 185 | /// new stream will be crated and warning message will be displayed. |
158 | class IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr); | |
186 | struct IHLSL2GLSLConversionStream** ppConversionStream DEFAULT_INITIALIZER(nullptr); | |
159 | 187 | |
160 | 188 | /// Shader source |
161 | 189 | |
186 | 214 | /// Shader macros |
187 | 215 | |
188 | 216 | /// This member is ignored if ByteCode is not null |
189 | const struct ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr); | |
217 | const ShaderMacro* Macros DEFAULT_INITIALIZER(nullptr); | |
190 | 218 | |
191 | 219 | /// If set to true, textures will be combined with texture samplers. |
192 | 220 | /// The CombinedSamplerSuffix member defines the suffix added to the texture variable |
204 | 232 | const Char* CombinedSamplerSuffix DEFAULT_INITIALIZER("_sampler"); |
205 | 233 | |
206 | 234 | /// Shader description. See Diligent::ShaderDesc. |
207 | struct ShaderDesc Desc; | |
235 | ShaderDesc Desc; | |
208 | 236 | |
209 | 237 | /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE. |
210 | 238 | SHADER_SOURCE_LANGUAGE SourceLanguage DEFAULT_INITIALIZER(SHADER_SOURCE_LANGUAGE_DEFAULT); |
215 | 243 | /// has no effect. |
216 | 244 | /// |
217 | 245 | /// \note When HLSL source is converted to GLSL, corresponding GLSL/GLESSL version will be used. |
218 | struct ShaderVersion HLSLVersion DEFAULT_INITIALIZER({}); | |
246 | ShaderVersion HLSLVersion DEFAULT_INITIALIZER({}); | |
219 | 247 | |
220 | 248 | /// GLSL version to use when creating the shader. When default value |
221 | 249 | /// is given (0, 0), the engine will attempt to use the highest GLSL version |
222 | 250 | /// supported by the device. |
223 | struct ShaderVersion GLSLVersion DEFAULT_INITIALIZER({}); | |
251 | ShaderVersion GLSLVersion DEFAULT_INITIALIZER({}); | |
224 | 252 | |
225 | 253 | /// GLES shading language version to use when creating the shader. When default value |
226 | 254 | /// is given (0, 0), the engine will attempt to use the highest GLESSL version |
227 | 255 | /// supported by the device. |
228 | struct ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({}); | |
256 | ShaderVersion GLESSLVersion DEFAULT_INITIALIZER({}); | |
229 | 257 | |
230 | 258 | |
231 | 259 | /// Memory address where pointer to the compiler messages data blob will be written |
233 | 261 | /// The buffer contains two null-terminated strings. The first one is the compiler |
234 | 262 | /// output message. The second one is the full shader source code including definitions added |
235 | 263 | /// by the engine. Data blob object must be released by the client. |
236 | class IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr); | |
237 | }; | |
264 | IDataBlob** ppCompilerOutput DEFAULT_INITIALIZER(nullptr); | |
265 | }; | |
266 | typedef struct ShaderCreateInfo ShaderCreateInfo; | |
238 | 267 | |
239 | 268 | /// Describes shader resource type |
240 | 269 | DILIGENT_TYPED_ENUM(SHADER_RESOURCE_TYPE, Uint8){ |
286 | 315 | Uint32 ArraySize DEFAULT_INITIALIZER(0); |
287 | 316 | // clang-format on |
288 | 317 | }; |
289 | ||
290 | ||
318 | typedef struct ShaderResourceDesc ShaderResourceDesc; | |
319 | ||
320 | ||
321 | #if DILIGENT_C_INTERFACE | |
322 | # define THIS struct IShader* | |
323 | # define THIS_ struct IShader*, | |
324 | #endif | |
325 | ||
326 | // clang-format off | |
327 | ||
328 | /// Shader interface | |
329 | DILIGENT_INTERFACE(IShader, IDeviceObject) | |
330 | { | |
291 | 331 | #if DILIGENT_CPP_INTERFACE |
292 | ||
293 | /// Shader interface | |
294 | class IShader : public IDeviceObject | |
295 | { | |
296 | public: | |
297 | 332 | /// Returns the shader description |
298 | 333 | virtual const ShaderDesc& GetDesc() const override = 0; |
334 | #endif | |
299 | 335 | |
300 | 336 | /// Returns the total number of shader resources |
301 | virtual Uint32 GetResourceCount() const = 0; | |
337 | VIRTUAL Uint32 METHOD(GetResourceCount)(THIS) CONST PURE; | |
302 | 338 | |
303 | 339 | /// Returns the pointer to the array of shader resources |
304 | virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const = 0; | |
305 | }; | |
306 | ||
307 | #else | |
308 | ||
309 | struct IShader; | |
310 | ||
311 | // clang-format off | |
312 | ||
313 | struct IShaderMethods | |
314 | { | |
315 | Uint32 (*GetResourceCount)(struct IShader*); | |
316 | void (*GetResourceDesc) (struct IShader*, Uint32 Index, struct ShaderResourceDesc* ResourceDesc); | |
317 | }; | |
340 | VIRTUAL void METHOD(GetResourceDesc)(THIS_ | |
341 | Uint32 Index, | |
342 | ShaderResourceDesc REF ResourceDesc) CONST PURE; | |
343 | }; | |
344 | ||
345 | #if DILIGENT_C_INTERFACE | |
346 | ||
347 | # undef THIS | |
348 | # undef THIS_ | |
318 | 349 | |
319 | 350 | // clang-format on |
320 | 351 | |
325 | 356 | struct IShaderMethods Shader; |
326 | 357 | }; |
327 | 358 | |
328 | struct IShader | |
359 | typedef struct IShader | |
329 | 360 | { |
330 | 361 | struct IShaderVtbl* pVtbl; |
331 | }; | |
362 | } IShader; | |
332 | 363 | |
333 | 364 | // clang-format off |
334 | 365 | |
335 | 366 | # define IShader_GetDesc(This) (const struct ShaderDesc*)IDeviceObject_GetDesc(This) |
336 | 367 | |
337 | # define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((struct IShader*)(This)) | |
338 | # define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((struct IShader*)(This), __VA_ARGS__) | |
368 | # define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((IShader*)(This)) | |
369 | # define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((IShader*)(This), __VA_ARGS__) | |
339 | 370 | |
340 | 371 | // clang-format on |
341 | 372 |
36 | 36 | |
37 | 37 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
38 | 38 | |
39 | class IPipelineState; | |
39 | struct IPipelineState; | |
40 | 40 | |
41 | 41 | // {061F8774-9A09-48E8-8411-B5BD20560104} |
42 | static const struct INTERFACE_ID IID_ShaderResourceBinding = | |
42 | static const INTERFACE_ID IID_ShaderResourceBinding = | |
43 | 43 | {0x61f8774, 0x9a09, 0x48e8, {0x84, 0x11, 0xb5, 0xbd, 0x20, 0x56, 0x1, 0x4}}; |
44 | 44 | |
45 | 45 | |
46 | #if DILIGENT_CPP_INTERFACE | |
46 | #if DILIGENT_C_INTERFACE | |
47 | # define THIS struct IShaderResourceBinding* | |
48 | # define THIS_ struct IShaderResourceBinding*, | |
49 | #endif | |
50 | ||
51 | // clang-format off | |
47 | 52 | |
48 | 53 | /// Shader resource binding interface |
49 | class IShaderResourceBinding : public IObject | |
54 | DILIGENT_INTERFACE(IShaderResourceBinding, IObject) | |
50 | 55 | { |
51 | public: | |
52 | 56 | /// Returns pointer to the referenced buffer object. |
53 | 57 | |
54 | 58 | /// The method calls AddRef() on the returned interface, |
55 | 59 | /// so Release() must be called to avoid memory leaks. |
56 | virtual IPipelineState* GetPipelineState() = 0; | |
60 | VIRTUAL struct IPipelineState* METHOD(GetPipelineState)(THIS) PURE; | |
57 | 61 | |
58 | 62 | /// Binds mutable and dynamice resources using the resource mapping |
59 | 63 | |
61 | 65 | /// Any combination of Diligent::SHADER_TYPE may be used. |
62 | 66 | /// \param [in] pResMapping - Shader resource mapping, where required resources will be looked up |
63 | 67 | /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS. |
64 | virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) = 0; | |
68 | VIRTUAL void METHOD(BindResources)(THIS_ | |
69 | Uint32 ShaderFlags, | |
70 | IResourceMapping* pResMapping, | |
71 | Uint32 Flags) PURE; | |
65 | 72 | |
66 | 73 | /// Returns variable |
67 | 74 | |
71 | 78 | /// |
72 | 79 | /// \note This operation may potentially be expensive. If the variable will be used often, it is |
73 | 80 | /// recommended to store and reuse the pointer as it never changes. |
74 | virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) = 0; | |
81 | VIRTUAL IShaderResourceVariable* METHOD(GetVariableByName)(THIS_ | |
82 | SHADER_TYPE ShaderType, | |
83 | const char* Name) PURE; | |
75 | 84 | |
76 | 85 | /// Returns the total variable count for the specific shader stage. |
77 | 86 | |
79 | 88 | /// \remark The method only counts mutable and dynamic variables that can be accessed through |
80 | 89 | /// the Shader Resource Binding object. Static variables are accessed through the Shader |
81 | 90 | /// object. |
82 | virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const = 0; | |
91 | VIRTUAL Uint32 METHOD(GetVariableCount)(THIS_ | |
92 | SHADER_TYPE ShaderType) CONST PURE; | |
83 | 93 | |
84 | 94 | /// Returns variable |
85 | 95 | |
93 | 103 | /// |
94 | 104 | /// \note This operation may potentially be expensive. If the variable will be used often, it is |
95 | 105 | /// recommended to store and reuse the pointer as it never changes. |
96 | virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) = 0; | |
106 | VIRTUAL IShaderResourceVariable* METHOD(GetVariableByIndex)(THIS_ | |
107 | SHADER_TYPE ShaderType, | |
108 | Uint32 Index) PURE; | |
97 | 109 | |
98 | 110 | |
99 | 111 | /// Initializes static resources |
111 | 123 | /// \note The method must be called exactly once. If static resources have |
112 | 124 | /// already been initialized and the method is called again, it will have |
113 | 125 | /// no effect and a warning messge will be displayed. |
114 | virtual void InitializeStaticResources(const IPipelineState* pPipelineState = nullptr) = 0; | |
126 | VIRTUAL void METHOD(InitializeStaticResources)(THIS_ | |
127 | const struct IPipelineState* pPipelineState DEFAULT_VALUE(nullptr)) PURE; | |
115 | 128 | }; |
116 | 129 | |
117 | #else | |
130 | #if DILIGENT_C_INTERFACE | |
118 | 131 | |
119 | class IPipelineState; | |
120 | struct IShaderResourceBinding; | |
121 | ||
122 | // clang-format off | |
123 | ||
124 | struct IShaderResourceBindingMethods | |
125 | { | |
126 | class IPipelineState* (*GetPipelineState) (struct IShaderResourceBinding*); | |
127 | void (*BindResources) (struct IShaderResourceBinding*, Uint32 ShaderFlags, class IResourceMapping* pResMapping, Uint32 Flags); | |
128 | class IShaderResourceVariable* (*GetVariableByName) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, const char* Name); | |
129 | Uint32 (*GetVariableCount) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType); | |
130 | class IShaderResourceVariable* (*GetVariableByIndex) (struct IShaderResourceBinding*, SHADER_TYPE ShaderType, Uint32 Index); | |
131 | void (*InitializeStaticResources)(struct IShaderResourceBinding*, const class IPipelineState* pPipelineState); | |
132 | }; | |
132 | # undef THIS | |
133 | # undef THIS_ | |
133 | 134 | |
134 | 135 | // clang-format on |
135 | 136 | |
139 | 140 | struct IShaderResourceBindingMethods ShaderResourceBinding; |
140 | 141 | }; |
141 | 142 | |
142 | struct IShaderResourceBinding | |
143 | typedef struct IShaderResourceBinding | |
143 | 144 | { |
144 | 145 | struct IShaderResourceBindingVtbl* pVtbl; |
145 | }; | |
146 | } IShaderResourceBinding; | |
146 | 147 | |
147 | 148 | // clang-format off |
148 | 149 | |
149 | # define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((struct IShaderResourceBinding*)(This)) | |
150 | # define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((struct IShaderResourceBinding*)(This), __VA_ARGS__) | |
151 | # define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((struct IShaderResourceBinding*)(This), __VA_ARGS__) | |
152 | # define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((struct IShaderResourceBinding*)(This), __VA_ARGS__) | |
153 | # define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((struct IShaderResourceBinding*)(This), __VA_ARGS__) | |
154 | # define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((struct IShaderResourceBinding*)(This), __VA_ARGS__) | |
150 | # define IShaderResourceBinding_GetPipelineState(This) (This)->pVtbl->ShaderResourceBinding.GetPipelineState ((IShaderResourceBinding*)(This)) | |
151 | # define IShaderResourceBinding_BindResources(This, ...) (This)->pVtbl->ShaderResourceBinding.BindResources ((IShaderResourceBinding*)(This), __VA_ARGS__) | |
152 | # define IShaderResourceBinding_GetVariableByName(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByName ((IShaderResourceBinding*)(This), __VA_ARGS__) | |
153 | # define IShaderResourceBinding_GetVariableCount(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableCount ((IShaderResourceBinding*)(This), __VA_ARGS__) | |
154 | # define IShaderResourceBinding_GetVariableByIndex(This, ...) (This)->pVtbl->ShaderResourceBinding.GetVariableByIndex ((IShaderResourceBinding*)(This), __VA_ARGS__) | |
155 | # define IShaderResourceBinding_InitializeStaticResources(This, ...) (This)->pVtbl->ShaderResourceBinding.InitializeStaticResources((IShaderResourceBinding*)(This), __VA_ARGS__) | |
155 | 156 | |
156 | 157 | // clang-format on |
157 | 158 |
38 | 38 | |
39 | 39 | |
40 | 40 | // {0D57DF3F-977D-4C8F-B64C-6675814BC80C} |
41 | static const struct INTERFACE_ID IID_ShaderResourceVariable = | |
41 | static const INTERFACE_ID IID_ShaderResourceVariable = | |
42 | 42 | {0xd57df3f, 0x977d, 0x4c8f, {0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc}}; |
43 | 43 | |
44 | 44 | // clang-format off |
103 | 103 | |
104 | 104 | // clang-format on |
105 | 105 | |
106 | #if DILIGENT_CPP_INTERFACE | |
106 | #if DILIGENT_C_INTERFACE | |
107 | # define THIS struct IShaderResourceVariable* | |
108 | # define THIS_ struct IShaderResourceVariable*, | |
109 | #endif | |
110 | ||
111 | // clang-format off | |
107 | 112 | |
108 | 113 | /// Shader resource variable |
109 | class IShaderResourceVariable : public IObject | |
114 | DILIGENT_INTERFACE(IShaderResourceVariable, IObject) | |
110 | 115 | { |
111 | public: | |
112 | 116 | /// Binds resource to the variable |
113 | 117 | |
114 | 118 | /// \remark The method performs run-time correctness checks. |
115 | 119 | /// For instance, shader resource view cannot |
116 | 120 | /// be assigned to a constant buffer variable. |
117 | virtual void Set(IDeviceObject* pObject) = 0; | |
121 | VIRTUAL void METHOD(Set)(THIS_ | |
122 | IDeviceObject* pObject) PURE; | |
118 | 123 | |
119 | 124 | /// Binds resource array to the variable |
120 | 125 | |
125 | 130 | /// \remark The method performs run-time correctness checks. |
126 | 131 | /// For instance, shader resource view cannot |
127 | 132 | /// be assigned to a constant buffer variable. |
128 | virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) = 0; | |
133 | VIRTUAL void METHOD(SetArray)(THIS_ | |
134 | IDeviceObject* const* ppObjects, | |
135 | Uint32 FirstElement, | |
136 | Uint32 NumElements) PURE; | |
129 | 137 | |
130 | 138 | /// Returns the shader resource variable type |
131 | virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const = 0; | |
139 | VIRTUAL SHADER_RESOURCE_VARIABLE_TYPE METHOD(GetType)(THIS) CONST PURE; | |
132 | 140 | |
133 | 141 | /// Returns shader resource description. See Diligent::ShaderResourceDesc. |
134 | virtual void GetResourceDesc(ShaderResourceDesc& ResourceDesc) const = 0; | |
142 | VIRTUAL void METHOD(GetResourceDesc)(THIS_ | |
143 | ShaderResourceDesc REF ResourceDesc) CONST PURE; | |
135 | 144 | |
136 | 145 | /// Returns the variable index that can be used to access the variable. |
137 | virtual Uint32 GetIndex() const = 0; | |
146 | VIRTUAL Uint32 METHOD(GetIndex)(THIS) CONST PURE; | |
138 | 147 | |
139 | 148 | /// Returns true if non-null resource is bound to this variable. |
140 | 149 | |
141 | 150 | /// \param [in] ArrayIndex - Resource array index. Must be 0 for |
142 | 151 | /// non-array variables. |
143 | virtual bool IsBound(Uint32 ArrayIndex) const = 0; | |
152 | VIRTUAL bool METHOD(IsBound)(THIS_ | |
153 | Uint32 ArrayIndex) CONST PURE; | |
144 | 154 | }; |
145 | 155 | |
146 | #else | |
147 | 156 | |
148 | struct IShaderResourceVariable; | |
157 | #if DILIGENT_C_INTERFACE | |
149 | 158 | |
150 | // clang-format off | |
151 | struct IShaderResourceVariableMethods | |
152 | { | |
153 | void (*Set) (struct IShaderResourceVariable*, class IDeviceObject* pObject); | |
154 | void (*SetArray) (struct IShaderResourceVariable*, class IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements); | |
155 | SHADER_RESOURCE_VARIABLE_TYPE (*GetType) (struct IShaderResourceVariable*); | |
156 | void (*GetResourceDesc)(struct IShaderResourceVariable*, struct ShaderResourceDesc* ResourceDesc); | |
157 | Uint32 (*GetIndex) (struct IShaderResourceVariable*); | |
158 | bool (*IsBound) (struct IShaderResourceVariable*, Uint32 ArrayIndex); | |
159 | }; | |
159 | # undef THIS | |
160 | # undef THIS_ | |
161 | ||
160 | 162 | // clang-format on |
161 | 163 | |
162 | 164 | struct IShaderResourceVariableVtbl |
165 | 167 | struct IShaderResourceVariableMethods ShaderResourceVariable; |
166 | 168 | }; |
167 | 169 | |
168 | struct IShaderResourceVariable | |
170 | typedef struct IShaderResourceVariable | |
169 | 171 | { |
170 | 172 | struct IShaderResourceVariableVtbl* pVtbl; |
171 | }; | |
173 | } IShaderResourceVariable; | |
172 | 174 | |
173 | 175 | // clang-format off |
174 | 176 | |
175 | # define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((struct IShaderResourceVariable*)(This), __VA_ARGS__) | |
176 | # define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((struct IShaderResourceVariable*)(This), __VA_ARGS__) | |
177 | # define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((struct IShaderResourceVariable*)(This)) | |
178 | # define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((struct IShaderResourceVariable*)(This), __VA_ARGS__) | |
179 | # define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((struct IShaderResourceVariable*)(This)) | |
180 | # define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((struct IShaderResourceVariable*)(This), __VA_ARGS__) | |
177 | # define IShaderResourceVariable_Set(This, ...) (This)->pVtbl->ShaderResourceVariable.Set ((IShaderResourceVariable*)(This), __VA_ARGS__) | |
178 | # define IShaderResourceVariable_SetArray(This, ...) (This)->pVtbl->ShaderResourceVariable.SetArray ((IShaderResourceVariable*)(This), __VA_ARGS__) | |
179 | # define IShaderResourceVariable_GetType(This) (This)->pVtbl->ShaderResourceVariable.GetType ((IShaderResourceVariable*)(This)) | |
180 | # define IShaderResourceVariable_GetResourceDesc(This, ...) (This)->pVtbl->ShaderResourceVariable.GetResourceDesc((IShaderResourceVariable*)(This), __VA_ARGS__) | |
181 | # define IShaderResourceVariable_GetIndex(This) (This)->pVtbl->ShaderResourceVariable.GetIndex ((IShaderResourceVariable*)(This)) | |
182 | # define IShaderResourceVariable_IsBound(This, ...) (This)->pVtbl->ShaderResourceVariable.IsBound ((IShaderResourceVariable*)(This), __VA_ARGS__) | |
181 | 183 | |
182 | 184 | // clang-format on |
183 | 185 |
37 | 37 | |
38 | 38 | |
39 | 39 | // {1C703B77-6607-4EEC-B1FE-15C82D3B4130} |
40 | static const struct INTERFACE_ID IID_SwapChain = | |
40 | static const INTERFACE_ID IID_SwapChain = | |
41 | 41 | {0x1c703b77, 0x6607, 0x4eec, {0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30}}; |
42 | 42 | |
43 | 43 | |
44 | #if DILIGENT_CPP_INTERFACE | |
44 | #if DILIGENT_C_INTERFACE | |
45 | # define THIS struct ISwapChain* | |
46 | # define THIS_ struct ISwapChain*, | |
47 | #endif | |
48 | ||
49 | // clang-format off | |
45 | 50 | |
46 | 51 | /// Swap chain interface |
47 | 52 | |
48 | 53 | /// The swap chain is created by a platform-dependent function |
49 | class ISwapChain : public IObject | |
54 | DILIGENT_INTERFACE(ISwapChain, IObject) | |
50 | 55 | { |
51 | public: | |
52 | 56 | /// Presents a rendered image to the user |
53 | virtual void Present(Uint32 SyncInterval = 1) = 0; | |
57 | VIRTUAL void METHOD(Present)(THIS_ | |
58 | Uint32 SyncInterval DEFAULT_VALUE(1)) PURE; | |
54 | 59 | |
55 | 60 | /// Returns the swap chain desctription |
56 | virtual const SwapChainDesc& GetDesc() const = 0; | |
61 | VIRTUAL const SwapChainDesc REF METHOD(GetDesc)(THIS) CONST PURE; | |
57 | 62 | |
58 | 63 | /// Changes the swap chain's back buffer size |
59 | 64 | |
62 | 67 | /// |
63 | 68 | /// \note When resizing non-primary swap chains, the engine unbinds the |
64 | 69 | /// swap chain buffers from the output. |
65 | virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) = 0; | |
70 | VIRTUAL void METHOD(Resize)(THIS_ | |
71 | Uint32 NewWidth, | |
72 | Uint32 NewHeight) PURE; | |
66 | 73 | |
67 | 74 | /// Sets fullscreen mode (only supported on Win32 platform) |
68 | virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) = 0; | |
75 | VIRTUAL void METHOD(SetFullscreenMode)(THIS_ const DisplayModeAttribs REF DisplayMode) PURE; | |
69 | 76 | |
70 | 77 | /// Sets windowed mode (only supported on Win32 platform) |
71 | virtual void SetWindowedMode() = 0; | |
78 | VIRTUAL void METHOD(SetWindowedMode)(THIS) PURE; | |
72 | 79 | |
73 | 80 | /// Returns render target view of the current back buffer in the swap chain |
74 | 81 | |
80 | 87 | /// |
81 | 88 | /// The method does *NOT* call AddRef() on the returned interface, |
82 | 89 | /// so Release() must not be called. |
83 | virtual ITextureView* GetCurrentBackBufferRTV() = 0; | |
90 | VIRTUAL ITextureView* METHOD(GetCurrentBackBufferRTV)(THIS) PURE; | |
84 | 91 | |
85 | 92 | /// Returns depth-stencil view of the depth buffer |
86 | 93 | |
87 | 94 | /// The method does *NOT* call AddRef() on the returned interface, |
88 | 95 | /// so Release() must not be called. |
89 | virtual ITextureView* GetDepthBufferDSV() = 0; | |
96 | VIRTUAL ITextureView* METHOD(GetDepthBufferDSV)(THIS) PURE; | |
90 | 97 | }; |
91 | 98 | |
92 | #else | |
93 | 99 | |
94 | struct ISwapChain; | |
100 | #if DILIGENT_C_INTERFACE | |
95 | 101 | |
96 | // clang-format off | |
97 | ||
98 | struct ISwapChainMethods | |
99 | { | |
100 | void (*Present) (struct ISwapChain*, Uint32 SyncInterval); | |
101 | const struct SwapChainDesc* (*GetDesc) (struct ISwapChain*); | |
102 | void (*Resize) (struct ISwapChain*, Uint32 NewWidth, Uint32 NewHeight); | |
103 | void (*SetFullscreenMode) (struct ISwapChain*, const struct DisplayModeAttribs* DisplayMode); | |
104 | void (*SetWindowedMode) (struct ISwapChain*); | |
105 | struct ITextureView* (*GetCurrentBackBufferRTV)(struct ISwapChain*); | |
106 | struct ITextureView* (*GetDepthBufferDSV) (struct ISwapChain*); | |
107 | }; | |
102 | # undef THIS | |
103 | # undef THIS_ | |
108 | 104 | |
109 | 105 | // clang-format on |
110 | 106 | |
114 | 110 | struct ISwapChainMethods SwapChain; |
115 | 111 | }; |
116 | 112 | |
117 | struct ISwapChain | |
113 | typedef struct ISwapChain | |
118 | 114 | { |
119 | 115 | struct ISwapChainVtbl* pVtbl; |
120 | }; | |
116 | } ISwapChain; | |
121 | 117 | |
122 | 118 | // clang-format off |
123 | 119 | |
124 | # define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((struct ISwapChain*)(This), __VA_ARGS__) | |
125 | # define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((struct ISwapChain*)(This)) | |
126 | # define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((struct ISwapChain*)(This), __VA_ARGS__) | |
127 | # define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((struct ISwapChain*)(This), __VA_ARGS__) | |
128 | # define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((struct ISwapChain*)(This)) | |
129 | # define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((struct ISwapChain*)(This)) | |
130 | # define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((struct ISwapChain*)(This)) | |
120 | # define ISwapChain_Present(This, ...) (This)->pVtbl->SwapChain.Present ((ISwapChain*)(This), __VA_ARGS__) | |
121 | # define ISwapChain_GetDesc(This) (This)->pVtbl->SwapChain.GetDesc ((ISwapChain*)(This)) | |
122 | # define ISwapChain_Resize(This, ...) (This)->pVtbl->SwapChain.Resize ((ISwapChain*)(This), __VA_ARGS__) | |
123 | # define ISwapChain_SetFullscreenMode(This, ...) (This)->pVtbl->SwapChain.SetFullscreenMode ((ISwapChain*)(This), __VA_ARGS__) | |
124 | # define ISwapChain_SetWindowedMode(This) (This)->pVtbl->SwapChain.SetWindowedMode ((ISwapChain*)(This)) | |
125 | # define ISwapChain_GetCurrentBackBufferRTV(This) (This)->pVtbl->SwapChain.GetCurrentBackBufferRTV((ISwapChain*)(This)) | |
126 | # define ISwapChain_GetDepthBufferDSV(This) (This)->pVtbl->SwapChain.GetDepthBufferDSV ((ISwapChain*)(This)) | |
131 | 127 | |
132 | 128 | // clang-format on |
133 | 129 |