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

Function PyGetData

trinity/Tr2GpuBuffer_Blue.cpp:35–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33{
34
35PyObject* PyGetData( PyObject* self, PyObject* args )
36{
37 if( !PyArg_ParseTuple( args, "" ) )
38 {
39 return nullptr;
40 }
41
42 Tr2GpuBuffer* pThis = BluePythonCast<Tr2GpuBuffer*>( self );
43 if( !pThis )
44 {
45 return nullptr;
46 }
47 if( !pThis->IsValid() )
48 {
49 PyErr_SetString( PyExc_RuntimeError, "buffer is not valid" );
50 return nullptr;
51 }
52
53 auto buffer = pThis->GetGpuBuffer( 0 );
54
55 USE_MAIN_THREAD_RENDER_CONTEXT();
56
57 const void* data = nullptr;
58 auto hr = buffer->MapForReading( data, renderContext );
59 if( FAILED( hr ) )
60 {
61 PyErr_SetString( BeGetException( hr ), BeGetErrorMessage( hr ) );
62 return nullptr;
63 }
64 ON_BLOCK_EXIT( [&]() { buffer->UnmapForReading( renderContext ); } );
65
66 return PyVerCompat::ToPyBytes( static_cast<const char*>( data ), buffer->GetSize() );
67}
68}
69#endif
70

Callers

nothing calls this directly

Calls 7

ToPyBytesFunction · 0.85
BeGetErrorMessageFunction · 0.50
IsValidMethod · 0.45
GetGpuBufferMethod · 0.45
MapForReadingMethod · 0.45
UnmapForReadingMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected