X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=d2ed9f8196069c7c0c539e002d6320f9d3620894;hp=78122ced00d5f30190a5a9d7edabc97f2acd5260;hb=094bfbb35f1af70ef07890ac7735006cdc195cca;hpb=7366e74b75fa1ac3267709c12417179819b86acb diff --git a/test_util.cpp b/test_util.cpp index 78122ce..d2ed9f8 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -248,20 +248,19 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T num_outputs = 1; } - GLuint texnum[4]; - - glGenTextures(num_outputs, texnum); + glActiveTexture(GL_TEXTURE0); check_error(); - for (unsigned i = 0; i < num_outputs; ++i) { - glBindTexture(GL_TEXTURE_2D, texnum[i]); - check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, framebuffer_format, width, height, 0, GL_RGBA, type, nullptr); - check_error(); - } vector textures; for (unsigned i = 0; i < num_outputs; ++i) { - textures.push_back(EffectChain::DestinationTexture{texnum[i], framebuffer_format}); + GLuint texnum = chain.get_resource_pool()->create_2d_texture(framebuffer_format, width, height); + textures.push_back(EffectChain::DestinationTexture{texnum, framebuffer_format}); + + // The output texture needs to have valid state to be written to by a compute shader. + glBindTexture(GL_TEXTURE_2D, texnum); + check_error(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + check_error(); } chain.render_to_texture(textures, width, height); @@ -286,7 +285,7 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T for (unsigned i = 0; i < num_outputs; ++i) { T *ptr = data[i]; - glBindTexture(GL_TEXTURE_2D, texnum[i]); + glBindTexture(GL_TEXTURE_2D, textures[i].texnum); check_error(); if (!epoxy_is_desktop_gl() && (format == GL_RED || format == GL_BLUE || format == GL_ALPHA)) { // GLES will only read GL_RGBA. @@ -319,8 +318,9 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T } } - glDeleteTextures(num_outputs, texnum); - check_error(); + for (unsigned i = 0; i < num_outputs; ++i) { + chain.get_resource_pool()->release_2d_texture(textures[i].texnum); + } } void EffectChainTester::add_output(const ImageFormat &format, OutputAlphaFormat alpha_format)