MCPcopy Create free account
hub / github.com/carbonengine/trinity / Lock

Method Lock

trinityal/dx11/Tr2ConstantBufferALDx11.cpp:78–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& renderContext )
79{
80 if( m_usage == Tr2ConstantUsageAL::ONE_SHOT )
81 {
82 if( !m_bufferMirror )
83 {
84 *data = 0;
85 return E_FAIL;
86 }
87 *data = m_bufferMirror.get();
88 return S_OK;
89 }
90
91 if( !m_buffer )
92 {
93 *data = 0;
94 return E_FAIL;
95 }
96 D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 };
97 HRESULT hr = renderContext.m_context->Map( m_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ms );
98 if( FAILED( hr ) )
99 {
100 *data = nullptr;
101 return hr;
102 }
103 if( !ms.pData )
104 {
105 *data = nullptr;
106 return E_FAIL;
107 }
108#ifdef TRINITY_AL_GUARD_LOCKS
109 m_lockGuard.Lock( m_size, ms.pData );
110 *data = m_lockGuard.GetMemory();
111#else
112 *data = ms.pData;
113#endif
114 return hr;
115}
116
117ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& renderContext )
118{

Callers 3

MapForWritingMethod · 0.45
SetConstantsMethod · 0.45
MapForWritingMethod · 0.45

Calls 3

getMethod · 0.80
GetMemoryMethod · 0.80
MapMethod · 0.45

Tested by

no test coverage detected