// All destination textures must be exactly of size <width> x <height>,
// and must either come from the same ResourcePool the effect uses, or outlive
// the EffectChain (otherwise, we could be allocating FBOs that end up being
// All destination textures must be exactly of size <width> x <height>,
// and must either come from the same ResourcePool the effect uses, or outlive
// the EffectChain (otherwise, we could be allocating FBOs that end up being
- // stale). width and height can not be zero.
+ // stale). Textures must also have valid state; in particular, they must either
+ // be mipmap complete or have a non-mipmapped minification mode.
+ //
+ // width and height can not be zero.
struct DestinationTexture {
GLuint texnum;
GLenum format;
struct DestinationTexture {
GLuint texnum;
GLenum format;
+ glActiveTexture(GL_TEXTURE0);
+ check_error();
+
vector<EffectChain::DestinationTexture> textures;
for (unsigned i = 0; i < num_outputs; ++i) {
GLuint texnum = chain.get_resource_pool()->create_2d_texture(framebuffer_format, width, height);
textures.push_back(EffectChain::DestinationTexture{texnum, framebuffer_format});
vector<EffectChain::DestinationTexture> textures;
for (unsigned i = 0; i < num_outputs; ++i) {
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);
}
chain.render_to_texture(textures, width, height);