| 33 | { |
| 34 | |
| 35 | PyObject* 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 |
nothing calls this directly
no test coverage detected