mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 15:09:19 +02:00
move python timestamp check (avoid needless gl context switch)
This commit is contained in:
@@ -79,26 +79,18 @@ void python_screen_viewer::threadfunc()
|
|||||||
auto start_time = std::chrono::high_resolution_clock::now();
|
auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
for (auto &window : m_windows) {
|
for (auto &window : m_windows) {
|
||||||
glfwMakeContextCurrent(window->window);
|
|
||||||
gl::program::unbind();
|
|
||||||
gl::buffer::unbind();
|
|
||||||
|
|
||||||
window->shader->bind();
|
unsigned char *image = nullptr;
|
||||||
window->ubo->bind_uniform();
|
|
||||||
|
|
||||||
m_ubs.projection = glm::mat4(glm::mat3(glm::translate(glm::scale(glm::mat3(), 1.0f / window->scale), window->offset)));
|
|
||||||
window->ubo->update(m_ubs);
|
|
||||||
|
|
||||||
if (!Global.python_sharectx) {
|
|
||||||
unsigned char *image;
|
|
||||||
int format, components, width, height;
|
int format, components, width, height;
|
||||||
|
|
||||||
{
|
if (!Global.python_sharectx) {
|
||||||
std::lock_guard<std::mutex> guard(m_rt->mutex);
|
std::lock_guard<std::mutex> guard(m_rt->mutex);
|
||||||
|
|
||||||
if (window->timestamp == m_rt->timestamp)
|
if (window->timestamp == m_rt->timestamp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
window->timestamp = m_rt->timestamp;
|
||||||
|
|
||||||
if (!m_rt->image)
|
if (!m_rt->image)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -111,10 +103,19 @@ void python_screen_viewer::threadfunc()
|
|||||||
|
|
||||||
image = new unsigned char[size];
|
image = new unsigned char[size];
|
||||||
memcpy(image, m_rt->image, size);
|
memcpy(image, m_rt->image, size);
|
||||||
|
|
||||||
window->timestamp = m_rt->timestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(window->window);
|
||||||
|
gl::program::unbind();
|
||||||
|
gl::buffer::unbind();
|
||||||
|
|
||||||
|
window->shader->bind();
|
||||||
|
window->ubo->bind_uniform();
|
||||||
|
|
||||||
|
m_ubs.projection = glm::mat4(glm::mat3(glm::translate(glm::scale(glm::mat3(), 1.0f / window->scale), window->offset)));
|
||||||
|
window->ubo->update(m_ubs);
|
||||||
|
|
||||||
|
if (image) {
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D, 0,
|
GL_TEXTURE_2D, 0,
|
||||||
format,
|
format,
|
||||||
|
|||||||
Reference in New Issue
Block a user