* Utility function to unnormalized a coordinate given a particular sampler. * * name - the name of the coordinate, used for verbose debugging only * coord - the coordinate requiring unnormalization * offset - an addressing offset to be added to the coordinate * extent - the max value for this coordinate (e.g. width for x) */
| 1986 | * extent - the max value for this coordinate (e.g. width for x) |
| 1987 | */ |
| 1988 | static float unnormalize_coordinate(const char *name, float coord, float offset, |
| 1989 | float extent, |
| 1990 | cl_addressing_mode addressing_mode, |
| 1991 | int verbose) |
| 1992 | { |
| 1993 | float ret = 0.0f; |
| 1994 | |
| 1995 | switch (addressing_mode) |
| 1996 | { |
| 1997 | case CL_ADDRESS_REPEAT: |
| 1998 | ret = RepeatNormalizedAddressFn(coord, static_cast<size_t>(extent)); |
| 1999 | |
| 2000 | if (verbose) |
| 2001 | { |
| 2002 | log_info("\tRepeat filter denormalizes %s (%f) to %f\n", name, |
| 2003 | coord, ret); |
| 2004 | } |
| 2005 | |
| 2006 | if (offset != 0.0) |
| 2007 | { |
| 2008 | // Add in the offset, and handle wrapping. |
| 2009 | ret += offset; |
| 2010 | if (ret > extent) ret -= extent; |
| 2011 | if (ret < 0.0) ret += extent; |
| 2012 | } |
| 2013 | |
| 2014 | if (verbose && offset != 0.0f) |
| 2015 | { |
| 2016 | log_info("\tAddress offset of %f added to get %f\n", offset, |
| 2017 | ret); |
| 2018 | } |
| 2019 | break; |
| 2020 | |
| 2021 | case CL_ADDRESS_MIRRORED_REPEAT: |
| 2022 | ret = MirroredRepeatNormalizedAddressFn( |
| 2023 | coord, static_cast<size_t>(extent)); |
| 2024 | |
| 2025 | if (verbose) |
| 2026 | { |
| 2027 | log_info( |
| 2028 | "\tMirrored repeat filter denormalizes %s (%f) to %f\n", |
| 2029 | name, coord, ret); |
| 2030 | } |
| 2031 | |
| 2032 | if (offset != 0.0) |
| 2033 | { |
| 2034 | float temp = ret + offset; |
| 2035 | if (temp > extent) temp = extent - (temp - extent); |
| 2036 | ret = fabsf(temp); |
| 2037 | } |
| 2038 | |
| 2039 | if (verbose && offset != 0.0f) |
| 2040 | { |
| 2041 | log_info("\tAddress offset of %f added to get %f\n", offset, |
| 2042 | ret); |
| 2043 | } |
| 2044 | break; |
| 2045 |
no test coverage detected