]> git.sesse.net Git - movit/blobdiff - test_util.cpp
Move the compute shader tests into effect_chain_test, as we will have hybrid tests...
[movit] / test_util.cpp
index 6214dbc1b16ef11ffd160fd1265230e9f13b77db..78122ced00d5f30190a5a9d7edabc97f2acd5260 100644 (file)
@@ -248,7 +248,7 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
                num_outputs = 1;
        }
 
-       GLuint fbo, texnum[4];
+       GLuint texnum[4];
 
        glGenTextures(num_outputs, texnum);
        check_error();
@@ -259,24 +259,12 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
                check_error();
        }
 
-       glGenFramebuffers(1, &fbo);
-       check_error();
-       glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-       check_error();
+       vector<EffectChain::DestinationTexture> textures;
        for (unsigned i = 0; i < num_outputs; ++i) {
-               glFramebufferTexture2D(
-                       GL_FRAMEBUFFER,
-                       GL_COLOR_ATTACHMENT0 + i,
-                       GL_TEXTURE_2D,
-                       texnum[i],
-                       0);
-               check_error();
+               textures.push_back(EffectChain::DestinationTexture{texnum[i], framebuffer_format});
        }
 
-       GLenum bufs[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
-       glDrawBuffers(num_outputs, bufs);
-
-       chain.render_to_fbo(fbo, width, height);
+       chain.render_to_texture(textures, width, height);
 
 #ifdef HAVE_BENCHMARK
        // If running benchmarks: Now we've warmed up everything, so let's run the
@@ -285,7 +273,7 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
                glFinish();
                size_t iters = benchmark_state->max_iterations;
                for (auto _ : *benchmark_state) {
-                       chain.render_to_fbo(fbo, width, height);
+                       chain.render_to_texture(textures, width, height);
                        if (--iters == 0) {
                                glFinish();
                        }
@@ -296,15 +284,14 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
 
        T *data[4] = { out_data, out_data2, out_data3, out_data4 };
 
-       glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-       check_error();
        for (unsigned i = 0; i < num_outputs; ++i) {
                T *ptr = data[i];
-               glReadBuffer(GL_COLOR_ATTACHMENT0 + i);
+               glBindTexture(GL_TEXTURE_2D, texnum[i]);
+               check_error();
                if (!epoxy_is_desktop_gl() && (format == GL_RED || format == GL_BLUE || format == GL_ALPHA)) {
                        // GLES will only read GL_RGBA.
                        T *temp = new T[width * height * 4];
-                       glReadPixels(0, 0, width, height, GL_RGBA, internal_format, temp);
+                       glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, type, temp);
                        check_error();
                        if (format == GL_ALPHA) {
                                for (unsigned i = 0; i < width * height; ++i) {
@@ -321,7 +308,7 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
                        }
                        delete[] temp;
                } else {
-                       glReadPixels(0, 0, width, height, format, internal_format, ptr);
+                       glGetTexImage(GL_TEXTURE_2D, 0, format, type, ptr);
                        check_error();
                }
 
@@ -332,8 +319,6 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T
                }
        }
 
-       glDeleteFramebuffers(1, &fbo);
-       check_error();
        glDeleteTextures(num_outputs, texnum);
        check_error();
 }