- GLenum type, internal_format;
- void *pixels;
- if (fallback_to_fp32) {
- type = GL_FLOAT;
- internal_format = GL_RG32F;
- pixels = bilinear_weights_fp32;
- } else {
- type = GL_HALF_FLOAT;
- internal_format = GL_RG16F;
- pixels = bilinear_weights_fp16;
- }
-
- if (int(src_bilinear_samples) == last_texture_width &&
- int(dst_samples) == last_texture_height &&
- internal_format == last_texture_internal_format) {
- // Texture dimensions and type are unchanged; it is more efficient
- // to just update it rather than making an entirely new texture.
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, src_bilinear_samples, dst_samples, GL_RG, type, pixels);
- } else {
- glTexImage2D(GL_TEXTURE_2D, 0, internal_format, src_bilinear_samples, dst_samples, 0, GL_RG, type, pixels);
- last_texture_width = src_bilinear_samples;
- last_texture_height = dst_samples;
- last_texture_internal_format = internal_format;
- }
- check_error();
-
- delete[] weights;
- delete[] bilinear_weights_fp16;
- delete[] bilinear_weights_fp32;