]> git.sesse.net Git - nageru/commitdiff
Use the new Movit VAO functionality.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Jul 2017 23:12:59 +0000 (01:12 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Jul 2017 23:12:59 +0000 (01:12 +0200)
See the Movit changelog for full rationale, but basically it works
around a crash bug in NVIDIA's drivers.

README
chroma_subsampler.cpp
chroma_subsampler.h

diff --git a/README b/README
index c89a3e8228ce854ac8d1338d533acca6bd9a095c..01adb4e5be2562137cebd02eb18889567333f96a 100644 (file)
--- a/README
+++ b/README
@@ -42,7 +42,7 @@ Nageru is in beta stage. It currently needs:
    but also for stability. You need at least version 0.7.0.
 
  - Movit, my GPU-based video filter library (https://movit.sesse.net).
-   You will need at least version 1.5.1.
+   You will need at least version 1.5.2.
 
  - Qt 5.5 or newer for the GUI.
 
@@ -79,9 +79,9 @@ with:
     libasound2-dev libx264-dev libbmusb-dev protobuf-compiler \
     libprotobuf-dev libpci-dev
 
-Exceptions as of May 2017:
+Exceptions as of July 2017:
 
-  - You will need Movit from experimental; stretch only has 1.4.0.
+  - You will need Movit from git; stretch only has 1.4.0.
 
   - You will need bmusb from experimental; stretch only has 0.5.4.
 
index 0b214132efbe7e2ee873fab8cf5c27e7df34783f..80e24670a0a5f8acbcbfe24cfcbcff524aa027fc 100644 (file)
@@ -273,10 +273,7 @@ ChromaSubsampler::~ChromaSubsampler()
 
 void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex, GLuint dst2_tex)
 {
-       GLuint vao;
-       glGenVertexArrays(1, &vao);
-       check_error();
-
+       GLuint vao = resource_pool->create_vec2_vao({ cbcr_position_attribute_index, cbcr_texcoord_attribute_index }, vbo);
        glBindVertexArray(vao);
        check_error();
 
@@ -311,38 +308,24 @@ void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigne
        check_error();
        glUniform1i(cbcr_texture_sampler_uniform, 0);
 
-       glBindBuffer(GL_ARRAY_BUFFER, vbo);
-       check_error();
-
-       for (GLint attr_index : { cbcr_position_attribute_index, cbcr_texcoord_attribute_index }) {
-               glEnableVertexAttribArray(attr_index);
-               check_error();
-               glVertexAttribPointer(attr_index, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
-               check_error();
-       }
-
        glDrawArrays(GL_TRIANGLES, 0, 3);
        check_error();
 
-       for (GLint attr_index : { cbcr_position_attribute_index, cbcr_texcoord_attribute_index }) {
-               glDisableVertexAttribArray(attr_index);
-               check_error();
-       }
-
        glUseProgram(0);
        check_error();
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        check_error();
+       glBindVertexArray(0);
+       check_error();
 
        resource_pool->release_fbo(fbo);
-       glDeleteVertexArrays(1, &vao);
-       check_error();
+       resource_pool->release_vec2_vao(vao);
 }
 
 void ChromaSubsampler::create_uyvy(GLuint y_tex, GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex)
 {
-       GLuint vao;
-       glGenVertexArrays(1, &vao);
+       GLuint vao = resource_pool->create_vec2_vao({ cbcr_position_attribute_index, cbcr_texcoord_attribute_index }, vbo);
+       glBindVertexArray(vao);
        check_error();
 
        glBindVertexArray(vao);
@@ -395,32 +378,20 @@ void ChromaSubsampler::create_uyvy(GLuint y_tex, GLuint cbcr_tex, unsigned width
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        check_error();
 
-       for (GLint attr_index : { uyvy_position_attribute_index, uyvy_texcoord_attribute_index }) {
-               if (attr_index == -1) continue;
-               glEnableVertexAttribArray(attr_index);
-               check_error();
-               glVertexAttribPointer(attr_index, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
-               check_error();
-       }
-
        glDrawArrays(GL_TRIANGLES, 0, 3);
        check_error();
 
-       for (GLint attr_index : { uyvy_position_attribute_index, uyvy_texcoord_attribute_index }) {
-               if (attr_index == -1) continue;
-               glDisableVertexAttribArray(attr_index);
-               check_error();
-       }
-
        glActiveTexture(GL_TEXTURE0);
        check_error();
        glUseProgram(0);
        check_error();
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
        check_error();
+       glBindVertexArray(0);
+       check_error();
 
        resource_pool->release_fbo(fbo);
-       glDeleteVertexArrays(1, &vao);
+       resource_pool->release_vec2_vao(vao);
 }
 
 void ChromaSubsampler::create_v210(GLuint y_tex, GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex)
index 6466285960eea21434eccc0455eb0ed40f483a81..8e9ff4e0116c0ad31b9d317e92fd6121eb4bfc1a 100644 (file)
@@ -42,12 +42,12 @@ private:
 
        GLuint cbcr_program_num;  // Owned by <resource_pool>.
        GLuint cbcr_texture_sampler_uniform;
-       GLuint cbcr_position_attribute_index, cbcr_texcoord_attribute_index;
+       GLint cbcr_position_attribute_index, cbcr_texcoord_attribute_index;
        GLuint cbcr_chroma_offset_0_location, cbcr_chroma_offset_1_location;
 
        GLuint uyvy_program_num;  // Owned by <resource_pool>.
        GLuint uyvy_y_texture_sampler_uniform, uyvy_cbcr_texture_sampler_uniform;
-       GLuint uyvy_position_attribute_index, uyvy_texcoord_attribute_index;
+       GLint uyvy_position_attribute_index, uyvy_texcoord_attribute_index;
        GLuint uyvy_luma_offset_0_location, uyvy_luma_offset_1_location;
        GLuint uyvy_chroma_offset_0_location, uyvy_chroma_offset_1_location;