| 76 | } |
| 77 | |
| 78 | ALResult 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 | |
| 117 | ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& renderContext ) |
| 118 | { |
no test coverage detected