+ // And now the output.
+ if (phase->is_compute_shader) {
+ // This is currently the only place where we use image units,
+ // so we can always use 0.
+ phase->outbuf_image_unit = 0;
+ glBindImageTexture(phase->outbuf_image_unit, (*output_textures)[phase], 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA16F);
+ check_error();
+ phase->inv_output_size.x = 1.0f / phase->output_width;
+ phase->inv_output_size.y = 1.0f / phase->output_height;
+ phase->output_texcoord_adjust.x = 0.5f / phase->output_width;
+ phase->output_texcoord_adjust.y = 0.5f / phase->output_height;
+ } else {
+ // (Already set up for us if it is the last phase.)
+ if (!last_phase) {
+ fbo = resource_pool->create_fbo((*output_textures)[phase]);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ glViewport(0, 0, phase->output_width, phase->output_height);
+ }
+ }
+