Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngine/include/DeviceContextBase.h Source File

Diligent Engine API Reference

DeviceContextBase.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include "DeviceContext.h"
30 #include "DeviceObjectBase.h"
31 #include "Defines.h"
32 #include "ResourceMapping.h"
33 #include "Sampler.h"
34 #include "ObjectBase.h"
35 #include "DebugUtilities.h"
36 #include "SwapChain.h"
37 #include "ValidatedCast.h"
38 #include "GraphicsAccessories.h"
39
40 #ifdef _DEBUG
41 # define DEBUG_CHECKS
42 #endif
43
44 namespace Diligent
45 {
46
48 struct VertexStreamInfo
49 {
51 RefCntAutoPtr<IBuffer> pBuffer;
52 Uint32 Stride;
53 Uint32 Offset;
54 VertexStreamInfo() :
55 Stride( 0 ),
56 Offset( 0 )
57 {}
58 };
59
61
67 template<typename BaseInterface>
68 class DeviceContextBase : public ObjectBase<BaseInterface>
69 {
70 public:
71
72 typedef ObjectBase<BaseInterface> TObjectBase;
73
77 DeviceContextBase(IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice, bool bIsDeferred) :
78 TObjectBase(pRefCounters),
79 m_pDevice(pRenderDevice),
80 m_bIsDeferred(bIsDeferred)
81 {
82 }
83
84 ~DeviceContextBase()
85 {
86 }
87
88 IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceContext, TObjectBase )
89
90
91 inline virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override = 0;
93
94 inline virtual void InvalidateState()override = 0;
95
97 inline virtual void SetPipelineState(IPipelineState *pPipelineState)override = 0;
98
100 inline bool CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags, int);
101
103 inline virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )override = 0;
104
106 inline void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight );
107
109 inline void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight );
110
113 inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy = 0 );
114
116 virtual void SetSwapChain( ISwapChain *pSwapChain )override final { m_pSwapChain = pSwapChain; }
117
119 ISwapChain *GetSwapChain() { return m_pSwapChain; }
120
122 inline bool IsDefaultFBBound(){ return m_IsDefaultFramebufferBound; }
123
125 inline void GetPipelineState(IPipelineState **ppPSO, float* BlendFactors, Uint32 &StencilRef);
126
128 inline void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV);
129
131 inline void GetViewports( Uint32 &NumViewports, Viewport *pViewports );
132
134 IRenderDevice *GetDevice(){return m_pDevice;}
135
136 protected:
137 inline bool SetBlendFactors(const float *BlendFactors, int Dummy);
138
139 inline bool SetStencilRef(Uint32 StencilRef, int Dummy);
140
142 inline void GetRenderTargetSize( Uint32 &RTWidth, Uint32 &RTHeight );
143
145 inline void ClearStateCache();
146
148 RefCntAutoPtr<IRenderDevice> m_pDevice;
149
152 RefCntAutoPtr<ISwapChain> m_pSwapChain;
153
155 VertexStreamInfo m_VertexStreams[MaxBufferSlots];
156
158 Uint32 m_NumVertexStreams = 0;
159
161 RefCntAutoPtr<IPipelineState> m_pPipelineState;
162
164 RefCntAutoPtr<IBuffer> m_pIndexBuffer;
165
167 Uint32 m_IndexDataStartOffset = 0;
168
170 Uint32 m_StencilRef = 0;
171
173 Float32 m_BlendFactors[4] = { -1, -1, -1, -1 };
174
176 Viewport m_Viewports[MaxRenderTargets];
178 Uint32 m_NumViewports = 0;
179
181 Rect m_ScissorRects[MaxRenderTargets];
183 Uint32 m_NumScissorRects = 0;
184
186 RefCntAutoPtr<ITextureView> m_pBoundRenderTargets[MaxRenderTargets];
188 Uint32 m_NumBoundRenderTargets = 0;
191 bool m_IsDefaultFramebufferBound = false;
192
194 RefCntAutoPtr<ITextureView> m_pBoundDepthStencil;
195
196 const bool m_bIsDeferred = false;
197 };
198
199
200 template<typename BaseInterface>
201 inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )
202 {
203 if( StartSlot >= MaxBufferSlots )
204 {
205 LOG_ERROR_MESSAGE( "Start vertex buffer slot ", StartSlot, " is out of allowed range [0, ", MaxBufferSlots-1, "]." );
206 return;
207 }
208
209 if( StartSlot + NumBuffersSet > MaxBufferSlots )
210 {
211 LOG_ERROR_MESSAGE( "The range of vertex buffer slots being set [", StartSlot, ", ", StartSlot + NumBuffersSet - 1, "] is out of allowed range [0, ", MaxBufferSlots - 1, "]." );
212 NumBuffersSet = MaxBufferSlots - StartSlot;
213 }
214
215 if( Flags & SET_VERTEX_BUFFERS_FLAG_RESET )
216 {
217 for(Uint32 s=0; s < m_NumVertexStreams; ++s)
218 m_VertexStreams[s] = VertexStreamInfo();
219 m_NumVertexStreams = 0;
220 }
221 m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet );
222
223 for( Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff )
224 {
225 auto &CurrStream = m_VertexStreams[StartSlot + Buff];
226 CurrStream.pBuffer = RefCntAutoPtr<IBuffer>( ppBuffers ? ppBuffers[Buff] : nullptr );
227 CurrStream.Stride = pStrides ? pStrides[Buff] : 0;
228 CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
229 #ifdef DEBUG_CHECKS
230 if( CurrStream.pBuffer )
231 {
232 const auto &BuffDesc = CurrStream.pBuffer->GetDesc();
233 if( !(BuffDesc.BindFlags & BIND_VERTEX_BUFFER) )
234 {
235 LOG_ERROR_MESSAGE( "Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\" being bound as vertex buffer to slot ", Buff," was not created with BIND_VERTEX_BUFFER flag" );
236 }
237 }
238 #endif
239 }
240 // Remove null buffers from the end of the array
241 while(m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams-1].pBuffer)
242 m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo();
243 }
244
245 template<typename BaseInterface>
246 inline void DeviceContextBase<BaseInterface> :: SetPipelineState(IPipelineState *pPipelineState)
247 {
248 m_pPipelineState = pPipelineState;
249 }
250
251 template<typename BaseInterface>
252 inline bool DeviceContextBase<BaseInterface> :: CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags, int)
253 {
254 #ifdef _DEBUG
255 if (!m_pPipelineState)
256 {
257 LOG_ERROR_MESSAGE("No pipeline state is bound to the pipeline");
258 return false;
259 }
260
261 if (pShaderResourceBinding)
262 {
263 auto *pPSO = pShaderResourceBinding->GetPipelineState();
264 if (pPSO != m_pPipelineState)
265 {
266 LOG_ERROR_MESSAGE("Shader resource binding object does not match currently bound pipeline state");
267 return false;
268 }
269 }
270 #endif
271 return true;
272 }
273
274 template<typename BaseInterface>
275 inline void DeviceContextBase<BaseInterface> :: InvalidateState()
276 {
277 DeviceContextBase<BaseInterface> :: ClearStateCache();
278 m_IsDefaultFramebufferBound = false;
279 }
280
281 template<typename BaseInterface>
282 inline void DeviceContextBase<BaseInterface> :: SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )
283 {
284 m_pIndexBuffer = pIndexBuffer;
285 m_IndexDataStartOffset = ByteOffset;
286 #ifdef DEBUG_CHECKS
287 const auto &BuffDesc = m_pIndexBuffer->GetDesc();
288 if( !(BuffDesc.BindFlags & BIND_INDEX_BUFFER) )
289 {
290 LOG_ERROR_MESSAGE( "Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\" being bound as index buffer was not created with BIND_INDEX_BUFFER flag" );
291 }
292 #endif
293 }
294
295
296 template<typename BaseInterface>
297 inline void DeviceContextBase<BaseInterface> :: GetPipelineState(IPipelineState **ppPSO, float* BlendFactors, Uint32 &StencilRef)
298 {
299 VERIFY( ppPSO != nullptr, "Null pointer provided null" );
300 VERIFY( *ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state" );
301 if(m_pPipelineState)
302 {
303 m_pPipelineState->QueryInterface( IID_PipelineState, reinterpret_cast<IObject**>( ppPSO ) );
304 }
305 else
306 {
307 *ppPSO = nullptr;
308 }
309
310 for( Uint32 f = 0; f < 4; ++f )
311 BlendFactors[f] = m_BlendFactors[f];
312 StencilRef = m_StencilRef;
313 };
314
315 template<typename BaseInterface>
316 inline bool DeviceContextBase<BaseInterface> ::SetBlendFactors(const float *BlendFactors, int)
317 {
318 bool FactorsDiffer = false;
319 for( Uint32 f = 0; f < 4; ++f )
320 {
321 if( m_BlendFactors[f] != BlendFactors[f] )
322 FactorsDiffer = true;
323 m_BlendFactors[f] = BlendFactors[f];
324 }
325 return FactorsDiffer;
326 }
327
328 template<typename BaseInterface>
329 inline bool DeviceContextBase<BaseInterface> :: SetStencilRef(Uint32 StencilRef, int)
330 {
331 if (m_StencilRef != StencilRef)
332 {
333 m_StencilRef = StencilRef;
334 return true;
335 }
336 return false;
337 }
338
339 template<typename BaseInterface>
340 inline void DeviceContextBase<BaseInterface> :: GetRenderTargetSize( Uint32 &RTWidth, Uint32 &RTHeight )
341 {
342 RTWidth = 0;
343 RTHeight = 0;
344 // First, try to find non-null render target
345 for( Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt )
346 {
347 if( auto *pRTView = m_pBoundRenderTargets[rt].RawPtr() )
348 {
349 // Use render target size as viewport size
350 auto *pTex = pRTView->GetTexture();
351 auto MipLevel = pRTView->GetDesc().MostDetailedMip;
352 const auto &TexDesc = pTex->GetDesc();
353 RTWidth = TexDesc.Width >> MipLevel;
354 RTHeight = TexDesc.Height >> MipLevel;
355 VERIFY( RTWidth > 0 && RTHeight > 0, "RT dimension is zero" );
356 break;
357 }
358 }
359
360 // If render target was not found, check depth stencil
361 if( RTWidth == 0 || RTHeight == 0 )
362 {
363 auto *pDSView = m_pBoundDepthStencil.RawPtr();
364 if( pDSView != nullptr )
365 {
366 // Use depth stencil size
367 auto *pTex = pDSView->GetTexture();
368 const auto &TexDesc = pTex->GetDesc();
369 RTWidth = TexDesc.Width;
370 RTHeight = TexDesc.Height;
371 }
372 }
373
374 // Finally, if no render targets and depth stencil are bound,
375 // use default RT size
376 if( RTWidth == 0 || RTHeight == 0 )
377 {
378 if (m_pSwapChain)
379 {
380 const auto &SwapChainDesc = m_pSwapChain->GetDesc();
381 RTWidth = SwapChainDesc.Width;
382 RTHeight = SwapChainDesc.Height;
383 }
384 else
385 {
386 LOG_ERROR("Failed to determine default render target size: swap chain is not initialized in the device context");
387 }
388 }
389 }
390
391 template<typename BaseInterface>
392 inline void DeviceContextBase<BaseInterface> :: SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight )
393 {
394 if( RTWidth == 0 || RTHeight == 0 )
395 {
396 GetRenderTargetSize( RTWidth, RTHeight );
397 }
398
399 VERIFY(NumViewports < MaxRenderTargets, "Num viewports (", NumViewports, ") exceeds the limit (", MaxRenderTargets, ")");
400 m_NumViewports = std::min(MaxRenderTargets, NumViewports);
401
402 Viewport DefaultVP( 0, 0, static_cast<float>(RTWidth), static_cast<float>(RTHeight) );
403 // If no viewports are specified, use default viewport
404 if( m_NumViewports == 1 && pViewports == nullptr )
405 {
406 pViewports = &DefaultVP;
407 }
408
409 for( Uint32 vp = 0; vp < m_NumViewports; ++vp )
410 {
411 m_Viewports[vp] = pViewports[vp];
412 VERIFY( m_Viewports[vp].Width >= 0, "Incorrect viewport width (", m_Viewports[vp].Width, ")" );
413 VERIFY( m_Viewports[vp].Height >= 0 , "Incorrect viewport height (", m_Viewports[vp].Height, ")" );
414 VERIFY( m_Viewports[vp].MaxDepth >= m_Viewports[vp].MinDepth, "Incorrect viewport depth range [", m_Viewports[vp].MinDepth, ", ", m_Viewports[vp].MaxDepth, "]" );
415 }
416 }
417
418 template<typename BaseInterface>
419 inline void DeviceContextBase<BaseInterface> :: GetViewports( Uint32 &NumViewports, Viewport *pViewports )
420 {
421 NumViewports = m_NumViewports;
422 if( pViewports )
423 {
424 for( Uint32 vp = 0; vp < m_NumViewports; ++vp )
425 pViewports[vp] = m_Viewports[vp];
426 }
427 }
428
429 template<typename BaseInterface>
430 inline void DeviceContextBase<BaseInterface> :: SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight )
431 {
432 if( RTWidth == 0 || RTHeight == 0 )
433 {
434 GetRenderTargetSize( RTWidth, RTHeight );
435 }
436
437 VERIFY(NumRects < MaxRenderTargets, "Num scissor rects (", NumRects, ") exceeds the limit (", MaxRenderTargets, ")");
438 m_NumScissorRects = std::min(MaxRenderTargets, NumRects);
439
440 for( Uint32 sr = 0; sr < m_NumScissorRects; ++sr )
441 {
442 m_ScissorRects[sr] = pRects[sr];
443 VERIFY( m_ScissorRects[sr].left <= m_ScissorRects[sr].right, "Incorrect horizontal bounds for a scissor rect [", m_ScissorRects[sr].left, ", ", m_ScissorRects[sr].right, ")" );
444 VERIFY( m_ScissorRects[sr].top <= m_ScissorRects[sr].bottom, "Incorrect vertical bounds for a scissor rect [", m_ScissorRects[sr].top, ", ", m_ScissorRects[sr].bottom, ")" );
445 }
446 }
447
448 template<typename BaseInterface>
449 inline bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy )
450 {
451 bool bBindRenderTargets = false;
452 if( NumRenderTargets != m_NumBoundRenderTargets )
453 {
454 bBindRenderTargets = true;
455 for(Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt )
456 m_pBoundRenderTargets[rt].Release();
457
458 m_NumBoundRenderTargets = NumRenderTargets;
459 }
460
461 for( Uint32 rt = 0; rt < NumRenderTargets; ++rt )
462 {
463 auto *pRTView = ppRenderTargets[rt];
464 #ifdef _DEBUG
465 if( pRTView )
466 {
467 const auto &ViewDesc = pRTView->GetDesc();
468 VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET, "Texture view object named \"", ViewDesc.Name ? ViewDesc.Name : "", "\" has incorrect view type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), "). Render target view is expected" );
469 }
470 #endif
471 // Here both views a certainly live object, since we store
472 // strong references to all bound render targets. So we
473 // can safely compare pointers.
474 if( m_pBoundRenderTargets[rt] != pRTView )
475 {
476 m_pBoundRenderTargets[rt] = pRTView;
477 bBindRenderTargets = true;
478 }
479 }
480
481 #ifdef _DEBUG
482 if( pDepthStencil )
483 {
484 const auto &ViewDesc = pDepthStencil->GetDesc();
485 VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Texture view object named \"", ViewDesc.Name ? ViewDesc.Name : "", "\" has incorrect view type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), "). Depth stencil view is expected" );
486 }
487 #endif
488
489 if( m_pBoundDepthStencil != pDepthStencil)
490 {
491 m_pBoundDepthStencil = pDepthStencil;
492 bBindRenderTargets = true;
493 }
494
495 if (NumRenderTargets == 0 && pDepthStencil == nullptr)
496 {
497 if (!m_IsDefaultFramebufferBound)
498 {
499 m_IsDefaultFramebufferBound = true;
500 bBindRenderTargets = true;
501 }
502 }
503 else
504 m_IsDefaultFramebufferBound = false;
505
506 return bBindRenderTargets;
507 }
508
509 template<typename BaseInterface>
510 inline void DeviceContextBase<BaseInterface> :: GetRenderTargets( Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV )
511 {
512 NumRenderTargets = m_NumBoundRenderTargets;
513
514 if( ppRTVs )
515 {
516 for( Uint32 rt = 0; rt < NumRenderTargets; ++rt )
517 {
518 VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
519 auto pBoundRTV = m_pBoundRenderTargets[rt];
520 if( pBoundRTV )
521 pBoundRTV->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppRTVs + rt) );
522 else
523 ppRTVs[rt] = nullptr;
524 }
525 for( Uint32 rt = NumRenderTargets; rt < MaxRenderTargets; ++rt )
526 {
527 VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
528 ppRTVs[rt] = nullptr;
529 }
530 }
531
532 if( ppDSV )
533 {
534 VERIFY( *ppDSV == nullptr, "Non-null DSV pointer found" );
535 if( m_pBoundDepthStencil )
536 m_pBoundDepthStencil->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppDSV) );
537 else
538 *ppDSV = nullptr;
539 }
540 }
541
542 template<typename BaseInterface>
543 inline void DeviceContextBase<BaseInterface> :: ClearStateCache()
544 {
545 for(Uint32 stream=0; stream < m_NumVertexStreams; ++stream)
546 m_VertexStreams[stream] = VertexStreamInfo();
547 #ifdef _DEBUG
548 for(Uint32 stream=m_NumVertexStreams; stream < _countof(m_VertexStreams); ++stream)
549 {
550 VERIFY(m_VertexStreams[stream].pBuffer == nullptr, "Unexpected non-null buffer");
551 VERIFY(m_VertexStreams[stream].Offset == 0, "Unexpected non-zero offset");
552 VERIFY(m_VertexStreams[stream].Stride == 0, "Unexpected non-zero stride");
553 }
554 #endif
555 m_NumVertexStreams = 0;
556
557 m_pPipelineState.Release();
558
559 m_pIndexBuffer.Release();
560 m_IndexDataStartOffset = 0;
561
562 m_StencilRef = 0;
563
564 for( int i = 0; i < 4; ++i )
565 m_BlendFactors[i] = -1;
566
567 for(Uint32 vp=0; vp < m_NumViewports; ++vp)
568 m_Viewports[vp] = Viewport();
569 m_NumViewports = 0;
570
571 for(Uint32 sr=0; sr < m_NumScissorRects; ++sr)
572 m_ScissorRects[sr] = Rect();
573 m_NumScissorRects = 0;
574
575 // Vector of strong references to bound render targets
576 for(Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt )
577 m_pBoundRenderTargets[rt].Release();
578 #ifdef _DEBUG
579 for (Uint32 rt = m_NumBoundRenderTargets; rt < _countof(m_pBoundRenderTargets); ++rt)
580 {
581 VERIFY(m_pBoundRenderTargets[rt] == nullptr, "Non-null render target found");
582 }
583 #endif
584 m_NumBoundRenderTargets = 0;
585
586 m_pBoundDepthStencil.Release();
587 }
588
589 }
Diligent::DeviceContextBase::SetRenderTargets
bool SetRenderTargets(Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy=0)
Caches the render target and depth stencil views. Returns true if any view is different from the cach...
Definition: DeviceContextBase.h:449
Diligent::DeviceContextBase::m_NumViewports
Uint32 m_NumViewports
Number of current viewports.
Definition: DeviceContextBase.h:178
Diligent::MaxBufferSlots
static constexpr Uint32 MaxBufferSlots
Maximum number of input buffer slots. D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32...
Definition: Constants.h:33
Diligent::SwapChainDesc
Swap chain description.
Definition: GraphicsTypes.h:912
Diligent::DeviceContextBase::GetRenderTargetSize
void GetRenderTargetSize(Uint32 &RTWidth, Uint32 &RTHeight)
Returns the size of the currently bound render target.
Definition: DeviceContextBase.h:340
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:55
Diligent::DeviceContextBase::m_NumVertexStreams
Uint32 m_NumVertexStreams
Number of bound vertex streams.
Definition: DeviceContextBase.h:158
Diligent::ObjectBase
Template class implementing base functionality for an object.
Definition: ObjectBase.h:62
Diligent::DeviceContextBase::CommitShaderResources
bool CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags, int)
Base implementation of IDeviceContext::CommitShaderResources(); validates parameters.
Definition: DeviceContextBase.h:252
Diligent::DeviceContextBase::DeviceContextBase
DeviceContextBase(IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice, bool bIsDeferred)
Definition: DeviceContextBase.h:77
Diligent::DeviceContextBase::GetRenderTargets
void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV)
Returns currently bound render targets.
Definition: DeviceContextBase.h:510
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::VertexStreamInfo::Offset
Uint32 Offset
Offset in bytes.
Definition: DeviceContextBase.h:53
Diligent::DeviceContextBase
Base implementation of the device context.
Definition: DeviceContextBase.h:68
Diligent::DeviceContextBase::m_NumScissorRects
Uint32 m_NumScissorRects
Number of current scissor rects.
Definition: DeviceContextBase.h:183
Diligent::DeviceContextBase::SetViewports
void SetViewports(Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the viewports.
Definition: DeviceContextBase.h:392
Diligent::DeviceContextBase::IsDefaultFBBound
bool IsDefaultFBBound()
Returns true if currently bound frame buffer is the default frame buffer.
Definition: DeviceContextBase.h:122
Diligent::MaxRenderTargets
static constexpr Uint32 MaxRenderTargets
Maximum number of simultaneous render targets.
Definition: Constants.h:36
Diligent::BIND_INDEX_BUFFER
A buffer can be bound as an index buffer.
Definition: GraphicsTypes.h:65
Diligent::Viewport
Describes the viewport.
Definition: DeviceContext.h:376
Diligent::DeviceContextBase::SetSwapChain
virtual void SetSwapChain(ISwapChain *pSwapChain) override final
Sets the strong pointer to the swap chain.
Definition: DeviceContextBase.h:116
Diligent::IShaderResourceBinding
Shader resource binding interface.
Definition: ShaderResourceBinding.h:40
Diligent::DeviceContextBase::GetDevice
IRenderDevice * GetDevice()
Returns the render device.
Definition: DeviceContextBase.h:134
Diligent::VertexStreamInfo
Describes input vertex stream.
Definition: DeviceContextBase.h:48
Diligent::BIND_VERTEX_BUFFER
A buffer can be bound as a vertex buffer.
Definition: GraphicsTypes.h:64
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:200
Diligent::DeviceContextBase::m_StencilRef
Uint32 m_StencilRef
Current stencil reference value.
Definition: DeviceContextBase.h:170
Diligent::DeviceContextBase::m_pBoundDepthStencil
RefCntAutoPtr< ITextureView > m_pBoundDepthStencil
Strong references to the bound depth stencil view.
Definition: DeviceContextBase.h:194
Diligent::ISwapChain
Swap chain interface.
Definition: SwapChain.h:41
Diligent::DeviceContextBase::m_ScissorRects
Rect m_ScissorRects[MaxRenderTargets]
Current scissor rects.
Definition: DeviceContextBase.h:181
Diligent::TEXTURE_VIEW_DEPTH_STENCIL
A texture view will define a depth stencil view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:205
Diligent::DeviceContextBase::m_VertexStreams
VertexStreamInfo m_VertexStreams[MaxBufferSlots]
Vertex streams. Every stream holds strong reference to the buffer.
Definition: DeviceContextBase.h:155
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:163
Diligent::DeviceContextBase::m_pPipelineState
RefCntAutoPtr< IPipelineState > m_pPipelineState
Strong reference to the bound pipeline state object.
Definition: DeviceContextBase.h:161
Diligent::DeviceContextBase::m_IndexDataStartOffset
Uint32 m_IndexDataStartOffset
Offset from the beginning of the index buffer to the start of the index data, in bytes.
Definition: DeviceContextBase.h:167
Diligent::DeviceContextBase::GetSwapChain
ISwapChain * GetSwapChain()
Returns the swap chain.
Definition: DeviceContextBase.h:119
Diligent::DeviceContextBase::ClearStateCache
void ClearStateCache()
Clears all cached resources.
Definition: DeviceContextBase.h:543
Diligent::ITextureView::GetDesc
virtual const TextureViewDesc & GetDesc() const =0
Returns the texture view description used to create the object.
Diligent::DeviceContextBase::SetScissorRects
void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the scissor rects.
Definition: DeviceContextBase.h:430
Diligent::IPipelineState
Definition: PipelineState.h:209
Diligent::DeviceContextBase::m_pBoundRenderTargets
RefCntAutoPtr< ITextureView > m_pBoundRenderTargets[MaxRenderTargets]
Vector of strong references to the bound render targets.
Definition: DeviceContextBase.h:186
Diligent::DeviceContextBase::GetPipelineState
void GetPipelineState(IPipelineState **ppPSO, float *BlendFactors, Uint32 &StencilRef)
Returns currently bound pipeline state and blend factors.
Definition: DeviceContextBase.h:297
Diligent::DeviceContextBase::m_IsDefaultFramebufferBound
bool m_IsDefaultFramebufferBound
Flag indicating if default render target & depth-stencil buffer are currently bound.
Definition: DeviceContextBase.h:191
Diligent::DeviceContextBase::GetViewports
void GetViewports(Uint32 &NumViewports, Viewport *pViewports)
Returns currently set viewports.
Definition: DeviceContextBase.h:419
Diligent::VertexStreamInfo::Stride
Uint32 Stride
Stride in bytes.
Definition: DeviceContextBase.h:52
Diligent::DeviceContextBase::m_Viewports
Viewport m_Viewports[MaxRenderTargets]
Current viewports.
Definition: DeviceContextBase.h:176
Diligent::Rect
Describes the rectangle.
Definition: DeviceContext.h:420
Diligent::RefCntAutoPtr
Template class that implements reference counting.
Definition: RefCntAutoPtr.h:71
Diligent::VertexStreamInfo::pBuffer
RefCntAutoPtr< IBuffer > pBuffer
Strong reference to the buffer object.
Definition: DeviceContextBase.h:51
Diligent::DeviceContextBase::SetPipelineState
virtual void SetPipelineState(IPipelineState *pPipelineState) override=0
Base implementation of IDeviceContext::SetPipelineState(); caches references to the pipeline state ob...
Definition: DeviceContextBase.h:246
Diligent::DeviceContextBase::m_pDevice
RefCntAutoPtr< IRenderDevice > m_pDevice
Strong reference to the device.
Definition: DeviceContextBase.h:148
Diligent::SET_VERTEX_BUFFERS_FLAG_RESET
Reset the vertex buffers to only the buffers specified in this call. All buffers previously bound to ...
Definition: DeviceContext.h:359
Diligent::DeviceContextBase::m_pIndexBuffer
RefCntAutoPtr< IBuffer > m_pIndexBuffer
Strong reference to the bound index buffer.
Definition: DeviceContextBase.h:164
Diligent::DeviceContextBase::m_NumBoundRenderTargets
Uint32 m_NumBoundRenderTargets
Number of bound render targets.
Definition: DeviceContextBase.h:188
Diligent::DeviceContextBase::m_BlendFactors
Float32 m_BlendFactors[4]
Curent blend factors.
Definition: DeviceContextBase.h:173
Diligent::DeviceContextBase::SetVertexBuffers
virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags) override=0
Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and caches references...
Definition: DeviceContextBase.h:201
Diligent::DeviceContextBase::m_pSwapChain
RefCntAutoPtr< ISwapChain > m_pSwapChain
Strong reference to the swap chain. Swap chain holds weak reference to the immediate context...
Definition: DeviceContextBase.h:152
Diligent::SwapChainDesc::Height
Uint32 Height
The swap chain height. Default value is 0.
Definition: GraphicsTypes.h:918
Diligent::SwapChainDesc::Width
Uint32 Width
The swap chain width. Default value is 0.
Definition: GraphicsTypes.h:915
Diligent::DeviceContextBase::SetIndexBuffer
virtual void SetIndexBuffer(IBuffer *pIndexBuffer, Uint32 ByteOffset) override=0
Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buf...
Definition: DeviceContextBase.h:282
Diligent::IShaderResourceBinding::GetPipelineState
virtual class IPipelineState * GetPipelineState()=0
Returns pointer to the referenced buffer object.
Diligent::TEXTURE_VIEW_RENDER_TARGET
A texture view will define a render target view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:201
Diligent::IBuffer::GetDesc
virtual const BufferDesc & GetDesc() const =0
Returns the buffer description used to create the object.