+ // Whether this effect expects mipmaps or not.
+ enum MipmapRequirements {
+ // If chosen, you will be sampling with bilinear filtering,
+ // ie. the closest mipmap will be chosen, and then there will be
+ // bilinear interpolation inside it (GL_LINEAR_MIPMAP_NEAREST).
+ NEEDS_MIPMAPS,
+
+ // Whether the effect doesn't really care whether input textures
+ // are with or without mipmaps. You could get the same effect
+ // as NEEDS_MIPMAPS or CANNOT_ACCEPT_MIPMAPS; normally, you won't
+ // get them, but if a different effect in the same phase needs mipmaps,
+ // you will also get them.
+ DOES_NOT_NEED_MIPMAPS,
+
+ // The opposite of NEEDS_MIPMAPS; you will always be sampling from
+ // the most detailed mip level (GL_LINEAR). Effects with NEEDS_MIPMAPS
+ // and CANNOT_ACCEPT_MIPMAPS can not coexist within the same phase;
+ // such phases will be split.
+ //
+ // This is the only choice that makes sense for a compute shader,
+ // given that it doesn't have screen-space derivatives and thus
+ // always will sample the most detailed mip level.
+ CANNOT_ACCEPT_MIPMAPS,
+ };
+ virtual MipmapRequirements needs_mipmaps() const {
+ if (is_compute_shader()) {
+ return CANNOT_ACCEPT_MIPMAPS;
+ } else {
+ return DOES_NOT_NEED_MIPMAPS;
+ }
+ }
+
+ // Whether there is a direct correspondence between input and output
+ // texels. Specifically, the effect must not:
+ //
+ // 1. Try to sample in the border (ie., outside the 0.0 to 1.0 area).
+ // 2. Try to sample between texels.
+ // 3. Sample with an x- or y-derivative different from -1 or 1.
+ // (This also means needs_mipmaps() and one_to_one_sampling()
+ // together would make no sense.)
+ //
+ // The most common case for this would be an effect that has an exact
+ // 1:1-correspondence between input and output texels, e.g. SaturationEffect.
+ // However, more creative things, like mirroring/flipping or padding,
+ // would also be allowed.
+ //
+ // The primary gain from setting this is that you can sample directly
+ // from an effect that changes output size (see changes_output_size() below),
+ // without going through a bounce texture. It won't work for effects that
+ // set sets_virtual_output_size(), though.
+ //
+ // Does not make a lot of sense together with needs_texture_bounce().
+ // Cannot be set for compute shaders.
+ virtual bool one_to_one_sampling() const { return strong_one_to_one_sampling(); }
+
+ // Similar in use to one_to_one_sampling(), but even stricter:
+ // The effect must not use texture coordinate in any way beyond
+ // giving it unmodified to its (single) input. This allows it to
+ // also be used after a compute shader, in the same phase.
+ //
+ // An effect that it strong one-to-one must also be one-to-one.
+ virtual bool strong_one_to_one_sampling() const { return false; }