]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Fix compute shader outputs on NVIDIA.
[movit] / effect_chain.cpp
index 34a396aa607ab65db3e64f4f9f57a1273e45f021..fe07a3f909d0f3a3caaf1c41058329ce2f4f12bc 100644 (file)
@@ -1906,10 +1906,8 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height
                }
        }
 
-       for (map<Phase *, GLuint>::const_iterator texture_it = output_textures.begin();
-            texture_it != output_textures.end();
-            ++texture_it) {
-               resource_pool->release_2d_texture(texture_it->second);
+       for (const auto &phase_and_texnum : output_textures) {
+               resource_pool->release_2d_texture(phase_and_texnum.second);
        }
 
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -1926,8 +1924,8 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height
                // Get back the timer queries.
                for (unsigned phase_num = 0; phase_num < phases.size(); ++phase_num) {
                        Phase *phase = phases[phase_num];
-                       for (std::list<GLuint>::iterator timer_it = phase->timer_query_objects_running.begin();
-                            timer_it != phase->timer_query_objects_running.end(); ) {
+                       for (auto timer_it = phase->timer_query_objects_running.cbegin();
+                            timer_it != phase->timer_query_objects_running.cend(); ) {
                                GLint timer_query_object = *timer_it;
                                GLint available;
                                glGetQueryObjectiv(timer_query_object, GL_QUERY_RESULT_AVAILABLE, &available);
@@ -1995,6 +1993,16 @@ void EffectChain::execute_phase(Phase *phase, bool last_phase,
 
                GLuint tex_num = resource_pool->create_2d_texture(intermediate_format, phase->output_width, phase->output_height);
                output_textures->insert(make_pair(phase, tex_num));
+
+               // The output texture needs to have valid state to be written to by a compute shader.
+               if (phase->is_compute_shader) {
+                       glActiveTexture(GL_TEXTURE0);
+                       check_error();
+                       glBindTexture(GL_TEXTURE_2D, (*output_textures)[phase]);
+                       check_error();
+                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                       check_error();
+               }
        }
 
        // Set up RTT inputs for this phase.