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

Method GetData

trinity/Tr2DirectInstanceData.cpp:168–204  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Allocates memory for instance data (if passed instance count is different from previous one) and returns it. Arguments: count - Number of instances Return value: Instance data buffer --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

166// Instance data buffer
167// --------------------------------------------------------------------------------------
168void* Tr2DirectInstanceData::GetData( unsigned count )
169{
170 if( count != m_count )
171 {
172 m_count = count;
173 }
174
175 if( !m_stride || !m_count )
176 {
177 return nullptr;
178 }
179
180 USE_MAIN_THREAD_RENDER_CONTEXT();
181
182 if( !m_vertexBuffer.IsValid() || m_vertexBuffer.GetDesc().count < m_count )
183 {
184 m_vertexBuffer = Tr2BufferAL();
185 auto hr = m_vertexBuffer.Create(
186 m_stride,
187 m_count,
188 Tr2GpuUsage::VERTEX_BUFFER,
189 Tr2CpuUsage::WRITE_OFTEN,
190 nullptr,
191 renderContext );
192 if( FAILED( hr ) )
193 {
194 return nullptr;
195 }
196 }
197 uint8_t* data = nullptr;
198 if( FAILED( m_vertexBuffer.MapForWriting( data, renderContext ) ) )
199 {
200 return nullptr;
201 }
202
203 return data;
204}
205
206// --------------------------------------------------------------------------------------
207// Description:

Callers 5

PySetDataFunction · 0.45
PyGetItemFunction · 0.45
PySetItemFunction · 0.45
PyGetItemElementFunction · 0.45
PySetItemElementFunction · 0.45

Calls 4

Tr2BufferALClass · 0.50
IsValidMethod · 0.45
CreateMethod · 0.45
MapForWritingMethod · 0.45

Tested by

no test coverage detected