mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge branch 'milek-dev' into gfx-work
This commit is contained in:
21
PyInt.cpp
21
PyInt.cpp
@@ -30,13 +30,8 @@ void render_task::run() {
|
||||
// upload texture data
|
||||
if( ( outputwidth != nullptr )
|
||||
&& ( outputheight != nullptr ) ) {
|
||||
const opengl_material &material = GfxRenderer.Material(m_target);
|
||||
if (material.textures[0] != null_handle)
|
||||
{
|
||||
GLuint id = GfxRenderer.Texture(material.textures[0]).id;
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
|
||||
::glBindTexture( GL_TEXTURE_2D, GfxRenderer.Texture( m_target ).id );
|
||||
// setup texture parameters
|
||||
::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
|
||||
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
@@ -49,7 +44,7 @@ void render_task::run() {
|
||||
// build texture
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0,
|
||||
GL_SRGB8_ALPHA8,
|
||||
GL_SRGB8,
|
||||
PyInt_AsLong( outputwidth ), PyInt_AsLong( outputheight ), 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<GLubyte const *>( PyString_AsString( output ) ) );
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
@@ -166,6 +161,18 @@ auto python_taskqueue::insert( task_request const &Task ) -> bool {
|
||||
// acquire a lock on the task queue and add a new task
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_tasks.mutex );
|
||||
|
||||
// if task for this target already exists, don't add another
|
||||
for (render_task *task : m_tasks.data)
|
||||
if (task->get_target() == Task.target)
|
||||
{
|
||||
PyEval_AcquireLock();
|
||||
Py_DECREF(Task.input);
|
||||
PyEval_ReleaseLock();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_tasks.data.emplace_back( new render_task( renderer, Task.input, Task.target ) );
|
||||
}
|
||||
// potentially wake a worker to handle the new task
|
||||
|
||||
Reference in New Issue
Block a user