16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-20 11:29:18 +02:00

basic texture generation support, python multithreading fixes

This commit is contained in:
tmj-fstate
2018-10-21 01:29:27 +02:00
parent b51d5c3d2b
commit b36ed8db6c
11 changed files with 298 additions and 130 deletions

14
PyInt.h
View File

@@ -29,7 +29,7 @@ class render_task {
public:
// constructors
render_task( PyObject *Renderer, PyObject *Input, texture_handle Target ) :
render_task( PyObject *Renderer, PyObject *Input, GLuint Target ) :
m_renderer( Renderer ), m_input( Input ), m_target( Target )
{}
// methods
@@ -41,9 +41,11 @@ private:
// members
PyObject *m_renderer {nullptr};
PyObject *m_input { nullptr };
texture_handle m_target { null_handle };
GLuint m_target { 0 };
};
class python_taskqueue {
public:
@@ -52,7 +54,7 @@ public:
std::string const &renderer;
PyObject *input;
texture_handle target;
GLuint target;
};
// constructors
python_taskqueue() = default;
@@ -65,11 +67,15 @@ public:
auto insert( task_request const &Task ) -> bool;
// executes python script stored in specified file. returns true on success
auto run_file( std::string const &File, std::string const &Path = "" ) -> bool;
// acquires the python gil and sets the main thread as current
void acquire_lock();
// releases the python gil and swaps the main thread out
void release_lock();
private:
// types
static int const WORKERCOUNT { 1 };
using worker_array = std::array<std::unique_ptr<std::thread>, WORKERCOUNT >;
using worker_array = std::array<std::thread, WORKERCOUNT >;
using rendertask_sequence = threading::lockable< std::deque<render_task *> >;
// methods
auto fetch_renderer( std::string const Renderer ) -> PyObject *;