Lines Matching full:sampler
1542 static inline int wrap (Sampler::WrapMode mode, int c, int size)
1546 case tcu::Sampler::CLAMP_TO_BORDER:
1549 case tcu::Sampler::CLAMP_TO_EDGE:
1552 case tcu::Sampler::REPEAT_GL:
1555 case tcu::Sampler::REPEAT_CL:
1558 case tcu::Sampler::MIRRORED_ONCE:
1562 case tcu::Sampler::MIRRORED_REPEAT_GL:
1565 case tcu::Sampler::MIRRORED_REPEAT_CL:
1575 static inline float unnormalize (Sampler::WrapMode mode, float c, int size)
1579 case tcu::Sampler::CLAMP_TO_EDGE:
1580 case tcu::Sampler::CLAMP_TO_BORDER:
1581 case tcu::Sampler::REPEAT_GL:
1582 case tcu::Sampler::MIRRORED_REPEAT_GL:
1583 case tcu::Sampler::MIRRORED_ONCE: // Fall-through (ordinary case).
1586 case tcu::Sampler::REPEAT_CL:
1589 case tcu::Sampler::MIRRORED_REPEAT_CL:
1635 static inline Vec4 lookupBorder (const tcu::TextureFormat& format, const tcu::Sampler& sampler)
1648 return sampleTextureBorder<float>(format, sampler);
1650 return sampleTextureBorder<deInt32>(format, sampler).cast<float>();
1652 return sampleTextureBorder<deUint32>(format, sampler).cast<float>();
1660 static inline float execCompare (const tcu::Vec4& color, Sampler::CompareMode compare, int chanNdx, float ref_, bool isFixedPoint)
1669 case Sampler::COMPAREMODE_LESS: res = ref < cmp; break;
1670 case Sampler::COMPAREMODE_LESS_OR_EQUAL: res = ref <= cmp; break;
1671 case Sampler::COMPAREMODE_GREATER: res = ref > cmp; break;
1672 case Sampler::COMPAREMODE_GREATER_OR_EQUAL: res = ref >= cmp; break;
1673 case Sampler::COMPAREMODE_EQUAL: res = ref == cmp; break;
1674 case Sampler::COMPAREMODE_NOT_EQUAL: res = ref != cmp; break;
1675 case Sampler::COMPAREMODE_ALWAYS: res = true; break;
1676 case Sampler::COMPAREMODE_NEVER: res = false; break;
1684 static Vec4 sampleNearest1D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, const IVec2& offset)
1691 if (sampler.wrapS == Sampler::CLAMP_TO_BORDER && !deInBounds32(x, 0, width))
1692 return lookupBorder(access.getFormat(), sampler);
1694 int i = wrap(sampler.wrapS, x, width);
1699 static Vec4 sampleNearest2D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, float v, const IVec3& offset)
1708 if ((sampler.wrapS == Sampler::CLAMP_TO_BORDER && !deInBounds32(x, 0, width)) ||
1709 (sampler.wrapT == Sampler::CLAMP_TO_BORDER && !deInBounds32(y, 0, height)))
1710 return lookupBorder(access.getFormat(), sampler);
1712 int i = wrap(sampler.wrapS, x, width);
1713 int j = wrap(sampler.wrapT, y, height);
1718 static Vec4 sampleNearest3D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, float v, float w, const IVec3& offset)
1729 if ((sampler.wrapS == Sampler::CLAMP_TO_BORDER && !deInBounds32(x, 0, width)) ||
1730 (sampler.wrapT == Sampler::CLAMP_TO_BORDER && !deInBounds32(y, 0, height)) ||
1731 (sampler.wrapR == Sampler::CLAMP_TO_BORDER && !deInBounds32(z, 0, depth)))
1732 return lookupBorder(access.getFormat(), sampler);
1734 int i = wrap(sampler.wrapS, x, width);
1735 int j = wrap(sampler.wrapT, y, height);
1736 int k = wrap(sampler.wrapR, z, depth);
1741 static Vec4 sampleLinear1D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, const IVec2& offset)
1748 int i0 = wrap(sampler.wrapS, x0, w);
1749 int i1 = wrap(sampler.wrapS, x1, w);
1753 bool i0UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i0, 0, w);
1754 bool i1UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i1, 0, w);
1757 Vec4 p0 = i0UseBorder ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, offset.y(), 0);
1758 Vec4 p1 = i1UseBorder ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, offset.y(), 0);
1764 static Vec4 sampleLinear2D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, float v, const IVec3& offset)
1774 int i0 = wrap(sampler.wrapS, x0, w);
1775 int i1 = wrap(sampler.wrapS, x1, w);
1776 int j0 = wrap(sampler.wrapT, y0, h);
1777 int j1 = wrap(sampler.wrapT, y1, h);
1782 bool i0UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i0, 0, w);
1783 bool i1UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i1, 0, w);
1784 bool j0UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j0, 0, h);
1785 bool j1UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j1, 0, h);
1788 Vec4 p00 = (i0UseBorder || j0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j0, offset.z());
1789 Vec4 p10 = (i1UseBorder || j0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j0, offset.z());
1790 Vec4 p01 = (i0UseBorder || j1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j1, offset.z());
1791 sampler) : lookup(access, i1, j1, offset.z());
1800 static float sampleLinear1DCompare (const ConstPixelBufferAccess& access, const Sampler& sampler, float ref, float u, const IVec2& offset, bool isFixedPointDepthFormat)
1807 int i0 = wrap(sampler.wrapS, x0, w);
1808 int i1 = wrap(sampler.wrapS, x1, w);
1812 bool i0UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i0, 0, w);
1813 bool i1UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i1, 0, w);
1816 Vec4 p0Clr = i0UseBorder ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, offset.y(), 0);
1817 Vec4 p1Clr = i1UseBorder ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, offset.y(), 0);
1820 float p0 = execCompare(p0Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1821 float p1 = execCompare(p1Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1827 static float sampleLinear2DCompare (const ConstPixelBufferAccess& access, const Sampler& sampler, float ref, float u, float v, const IVec3& offset, bool isFixedPointDepthFormat)
1837 int i0 = wrap(sampler.wrapS, x0, w);
1838 int i1 = wrap(sampler.wrapS, x1, w);
1839 int j0 = wrap(sampler.wrapT, y0, h);
1840 int j1 = wrap(sampler.wrapT, y1, h);
1845 bool i0UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i0, 0, w);
1846 bool i1UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i1, 0, w);
1847 bool j0UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j0, 0, h);
1848 bool j1UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j1, 0, h);
1851 Vec4 p00Clr = (i0UseBorder || j0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j0, offset.z());
1852 Vec4 p10Clr = (i1UseBorder || j0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j0, offset.z());
1853 Vec4 p01Clr = (i0UseBorder || j1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j1, offset.z());
1854 Vec4 p11Clr = (i1UseBorder || j1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j1, offset.z());
1857 float p00 = execCompare(p00Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1858 float p10 = execCompare(p10Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1859 float p01 = execCompare(p01Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1860 float p11 = execCompare(p11Clr, sampler.compare, sampler.compareChannel, ref, isFixedPointDepthFormat);
1869 static Vec4 sampleLinear3D (const ConstPixelBufferAccess& access, const Sampler& sampler, float u, float v, float w, const IVec3& offset)
1882 int i0 = wrap(sampler.wrapS, x0, width);
1883 int i1 = wrap(sampler.wrapS, x1, width);
1884 int j0 = wrap(sampler.wrapT, y0, height);
1885 int j1 = wrap(sampler.wrapT, y1, height);
1886 int k0 = wrap(sampler.wrapR, z0, depth);
1887 int k1 = wrap(sampler.wrapR, z1, depth);
1893 bool i0UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i0, 0, width);
1894 bool i1UseBorder = sampler.wrapS == Sampler::CLAMP_TO_BORDER && !de::inBounds(i1, 0, width);
1895 bool j0UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j0, 0, height);
1896 bool j1UseBorder = sampler.wrapT == Sampler::CLAMP_TO_BORDER && !de::inBounds(j1, 0, height);
1897 bool k0UseBorder = sampler.wrapR == Sampler::CLAMP_TO_BORDER && !de::inBounds(k0, 0, depth);
1898 bool k1UseBorder = sampler.wrapR == Sampler::CLAMP_TO_BORDER && !de::inBounds(k1, 0, depth);
1901 Vec4 p000 = (i0UseBorder || j0UseBorder || k0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j0, k0);
1902 Vec4 p100 = (i1UseBorder || j0UseBorder || k0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j0, k0);
1903 Vec4 p010 = (i0UseBorder || j1UseBorder || k0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j1, k0);
1904 Vec4 p110 = (i1UseBorder || j1UseBorder || k0UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j1, k0);
1905 Vec4 p001 = (i0UseBorder || j0UseBorder || k1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j0, k1);
1906 Vec4 p101 = (i1UseBorder || j0UseBorder || k1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j0, k1);
1907 Vec4 p011 = (i0UseBorder || j1UseBorder || k1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i0, j1, k1);
1908 Vec4 p111 = (i1UseBorder || j1UseBorder || k1UseBorder) ? lookupBorder(access.getFormat(), sampler) : lookup(access, i1, j1, k1);
1921 Vec4 ConstPixelBufferAccess::sample1D (const Sampler& sampler, Sampler::FilterMode filter, float s, int level) const
1926 return sample1DOffset(sampler, filter, s, tcu::IVec2(0, level));
1929 Vec4 ConstPixelBufferAccess::sample2D (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, int depth) const
1934 return sample2DOffset(sampler, filter, s, t, tcu::IVec3(0, 0, depth));
1937 Vec4 ConstPixelBufferAccess::sample3D (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r) const
1939 return sample3DOffset(sampler, filter, s, t, r, tcu::IVec3(0, 0, 0));
1942 Vec4 ConstPixelBufferAccess::sample1DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, const IVec2& offset) const
1951 if (sampler.normalizedCoords)
1952 u = unnormalize(sampler.wrapS, s, m_size.x());
1956 case Sampler::NEAREST: return sampleNearest1D (*this, sampler, u, offset);
1957 case Sampler::LINEAR: return sampleLinear1D (*this, sampler, u, offset);
1964 Vec4 ConstPixelBufferAccess::sample2DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, const IVec3& offset) const
1974 if (sampler.normalizedCoords)
1976 u = unnormalize(sampler.wrapS, s, m_size.x());
1977 v = unnormalize(sampler.wrapT, t, m_size.y());
1982 case Sampler::NEAREST: return sampleNearest2D (*this, sampler, u, v, offset);
1983 case Sampler::LINEAR: return sampleLinear2D (*this, sampler, u, v, offset);
1990 Vec4 ConstPixelBufferAccess::sample3DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r, const IVec3& offset) const
1997 if (sampler.normalizedCoords)
1999 u = unnormalize(sampler.wrapS, s, m_size.x());
2000 v = unnormalize(sampler.wrapT, t, m_size.y());
2001 w = unnormalize(sampler.wrapR, r, m_size.z());
2006 case Sampler::NEAREST: return sampleNearest3D (*this, sampler, u, v, w, offset);
2007 case Sampler::LINEAR: return sampleLinear3D (*this, sampler, u, v, w, offset);
2014 float ConstPixelBufferAccess::sample1DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, const IVec2& offset) const
2026 if (sampler.normalizedCoords)
2027 u = unnormalize(sampler.wrapS, s, m_size.x());
2031 case Sampler::NEAREST: return execCompare(sampleNearest1D(*this, sampler, u, offset), sampler.compare, sampler.compareChannel, ref, isFixedPointDepth);
2032 case Sampler::LINEAR: return sampleLinear1DCompare(*this, sampler, ref, u, offset, isFixedPointDepth);
2039 float ConstPixelBufferAccess::sample2DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, float t, const IVec3& offset) const
2052 if (sampler.normalizedCoords)
2054 u = unnormalize(sampler.wrapS, s, m_size.x());
2055 v = unnormalize(sampler.wrapT, t, m_size.y());
2060 case Sampler::NEAREST: return execCompare(sampleNearest2D(*this, sampler, u, v, offset), sampler.compare, sampler.compareChannel, ref, isFixedPointDepth);
2061 case Sampler::LINEAR: return sampleLinear2DCompare(*this, sampler, ref, u, v, offset, isFixedPointDepth);
2106 Vec4 sampleLevelArray1D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, int depth, float lod)
2108 return sampleLevelArray1DOffset(levels, numLevels, sampler, s, lod, IVec2(0, depth)); // y-offset in 1D textures is layer selector
2111 Vec4 sampleLevelArray2D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, int depth, float lod)
2113 return sampleLevelArray2DOffset(levels, numLevels, sampler, s, t, lod, IVec3(0, 0, depth)); // z-offset in 2D textures is layer selector
2116 Vec4 sampleLevelArray3D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod)
2118 return sampleLevelArray3DOffset(levels, numLevels, sampler, s, t, r, lod, IVec3(0, 0, 0));
2121 Vec4 sampleLevelArray1DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float lod, const IVec2& offset)
2123 bool magnified = lod <= sampler.lodThreshold;
2124 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2128 case Sampler::NEAREST: return levels[0].sample1DOffset(sampler, filterMode, s, offset);
2129 case Sampler::LINEAR: return levels[0].sample1DOffset(sampler, filterMode, s, offset);
2131 case Sampler::NEAREST_MIPMAP_NEAREST:
2132 case Sampler::LINEAR_MIPMAP_NEAREST:
2136 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2138 return levels[level].sample1DOffset(sampler, levelFilter, s, offset);
2141 case Sampler::NEAREST_MIPMAP_LINEAR:
2142 case Sampler::LINEAR_MIPMAP_LINEAR:
2147 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2149 tcu::Vec4 t0 = levels[level0].sample1DOffset(sampler, levelFilter, s, offset);
2150 tcu::Vec4 t1 = levels[level1].sample1DOffset(sampler, levelFilter, s, offset);
2161 Vec4 sampleLevelArray2DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float lod, const IVec3& offset)
2163 bool magnified = lod <= sampler.lodThreshold;
2164 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2168 case Sampler::NEAREST: return levels[0].sample2DOffset(sampler, filterMode, s, t, offset);
2169 case Sampler::LINEAR: return levels[0].sample2DOffset(sampler, filterMode, s, t, offset);
2171 case Sampler::NEAREST_MIPMAP_NEAREST:
2172 case Sampler::LINEAR_MIPMAP_NEAREST:
2176 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2178 return levels[level].sample2DOffset(sampler, levelFilter, s, t, offset);
2181 case Sampler::NEAREST_MIPMAP_LINEAR:
2182 case Sampler::LINEAR_MIPMAP_LINEAR:
2187 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2189 tcu::Vec4 t0 = levels[level0].sample2DOffset(sampler, levelFilter, s, t, offset);
2190 tcu::Vec4 t1 = levels[level1].sample2DOffset(sampler, levelFilter, s, t, offset);
2201 Vec4 sampleLevelArray3DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset)
2203 bool magnified = lod <= sampler.lodThreshold;
2204 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2208 case Sampler::NEAREST: return levels[0].sample3DOffset(sampler, filterMode, s, t, r, offset);
2209 case Sampler::LINEAR: return levels[0].sample3DOffset(sampler, filterMode, s, t, r, offset);
2211 case Sampler::NEAREST_MIPMAP_NEAREST:
2212 case Sampler::LINEAR_MIPMAP_NEAREST:
2216 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2218 return levels[level].sample3DOffset(sampler, levelFilter, s, t, r, offset);
2221 case Sampler::NEAREST_MIPMAP_LINEAR:
2222 case Sampler::LINEAR_MIPMAP_LINEAR:
2227 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2229 tcu::Vec4 t0 = levels[level0].sample3DOffset(sampler, levelFilter, s, t, r, offset);
2230 tcu::Vec4 t1 = levels[level1].sample3DOffset(sampler, levelFilter, s, t, r, offset);
2241 float sampleLevelArray1DCompare (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float lod, const IVec2& offset)
2243 bool magnified = lod <= sampler.lodThreshold;
2244 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2248 case Sampler::NEAREST: return levels[0].sample1DCompare(sampler, filterMode, ref, s, offset);
2249 case Sampler::LINEAR: return levels[0].sample1DCompare(sampler, filterMode, ref, s, offset);
2251 case Sampler::NEAREST_MIPMAP_NEAREST:
2252 case Sampler::LINEAR_MIPMAP_NEAREST:
2256 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2258 return levels[level].sample1DCompare(sampler, levelFilter, ref, s, offset);
2261 case Sampler::NEAREST_MIPMAP_LINEAR:
2262 case Sampler::LINEAR_MIPMAP_LINEAR:
2267 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2269 float t0 = levels[level0].sample1DCompare(sampler, levelFilter, ref, s, offset);
2270 float t1 = levels[level1].sample1DCompare(sampler, levelFilter, ref, s, offset);
2281 float sampleLevelArray2DCompare (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float t, float lod, const IVec3& offset)
2283 bool magnified = lod <= sampler.lodThreshold;
2284 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2288 case Sampler::NEAREST: return levels[0].sample2DCompare(sampler, filterMode, ref, s, t, offset);
2289 case Sampler::LINEAR: return levels[0].sample2DCompare(sampler, filterMode, ref, s, t, offset);
2291 case Sampler::NEAREST_MIPMAP_NEAREST:
2292 case Sampler::LINEAR_MIPMAP_NEAREST:
2296 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2298 return levels[level].sample2DCompare(sampler, levelFilter, ref, s, t, offset);
2301 case Sampler::NEAREST_MIPMAP_LINEAR:
2302 case Sampler::LINEAR_MIPMAP_LINEAR:
2307 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2309 float t0 = levels[level0].sample2DCompare(sampler, levelFilter, ref, s, t, offset);
2310 float t1 = levels[level1].sample2DCompare(sampler, levelFilter, ref, s, t, offset);
2321 static Vec4 fetchGatherArray2DOffsets (const ConstPixelBufferAccess& src, const Sampler& sampler, float s, float t, int depth, int componentNdx, const IVec2 (&offsets)[4])
2327 const float u = unnormalize(sampler.wrapS, s, w);
2328 const float v = unnormalize(sampler.wrapT, t, h);
2336 const int sampleX = wrap(sampler.wrapS, x0 + offsets[i].x(), w);
2337 const int sampleY = wrap(sampler.wrapT, y0 + offsets[i].y(), h);
2343 pixel = lookupBorder(src.getFormat(), sampler);
2351 Vec4 gatherArray2DOffsets (const ConstPixelBufferAccess& src, const Sampler& sampler, float s, float t, int depth, int componentNdx, const IVec2 (&offsets)[4])
2353 DE_ASSERT(sampler.compare == Sampler::COMPAREMODE_NONE);
2356 return fetchGatherArray2DOffsets(src, sampler, s, t, depth, componentNdx, offsets);
2359 Vec4 gatherArray2DOffsetsCompare (const ConstPixelBufferAccess& src, const Sampler& sampler, float ref, float s, float t, int depth, const IVec2 (&offsets)[4])
2361 DE_ASSERT(sampler.compare != Sampler::COMPAREMODE_NONE);
2363 DE_ASSERT(sampler.compareChannel == 0);
2366 const Vec4 gathered = fetchGatherArray2DOffsets(src, sampler, s, t, depth, 0 /* component 0: depth */, offsets);
2370 result[i] = execCompare(gathered, sampler.compare, i, ref, isFixedPoint);
2375 static Vec4 sampleCubeSeamlessNearest (const ConstPixelBufferAccess& faceAccess, const Sampler& sampler, float s, float t, int depth)
2377 Sampler clampingSampler = sampler;
2378 clampingSampler.wrapS = Sampler::CLAMP_TO_EDGE;
2379 clampingSampler.wrapT = Sampler::CLAMP_TO_EDGE;
2380 return faceAccess.sample2D(clampingSampler, Sampler::NEAREST, s, t, depth);
2476 IVec2 coords(wrap(Sampler::CLAMP_TO_BORDER, origCoords.s, size),
2477 wrap(Sampler::CLAMP_TO_BORDER, origCoords.t, size));
2576 static Vec4 sampleCubeSeamlessLinear (const ConstPixelBufferAccess (&faceAccesses)[CUBEFACE_LAST], CubeFace baseFace, const Sampler& sampler, float s, float t, int depth)
2585 if (sampler.normalizedCoords)
2587 u = unnormalize(sampler.wrapS, s, size);
2588 v = unnormalize(sampler.wrapT, t, size);
2607 static Vec4 sampleLevelArrayCubeSeamless (const ConstPixelBufferAccess* const (&faces)[CUBEFACE_LAST], int numLevels, CubeFace face, const Sampler& sampler, float s, float t, int depth, float lod)
2609 bool magnified = lod <= sampler.lodThreshold;
2610 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2614 case Sampler::NEAREST:
2615 return sampleCubeSeamlessNearest(faces[face][0], sampler, s, t, depth);
2617 case Sampler::LINEAR:
2623 return sampleCubeSeamlessLinear(faceAccesses, face, sampler, s, t, depth);
2626 case Sampler::NEAREST_MIPMAP_NEAREST:
2627 case Sampler::LINEAR_MIPMAP_NEAREST:
2631 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2633 if (levelFilter == Sampler::NEAREST)
2634 return sampleCubeSeamlessNearest(faces[face][level], sampler, s, t, depth);
2637 DE_ASSERT(levelFilter == Sampler::LINEAR);
2643 return sampleCubeSeamlessLinear(faceAccesses, face, sampler, s, t, depth);
2647 case Sampler::NEAREST_MIPMAP_LINEAR:
2648 case Sampler::LINEAR_MIPMAP_LINEAR:
2653 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2658 if (levelFilter == Sampler::NEAREST)
2660 t0 = sampleCubeSeamlessNearest(faces[face][level0], sampler, s, t, depth);
2661 t1 = sampleCubeSeamlessNearest(faces[face][level1], sampler, s, t, depth);
2665 DE_ASSERT(levelFilter == Sampler::LINEAR);
2675 t0 = sampleCubeSeamlessLinear(faceAccesses0, face, sampler, s, t, depth);
2676 t1 = sampleCubeSeamlessLinear(faceAccesses1, face, sampler, s, t, depth);
2688 static float sampleCubeSeamlessNearestCompare (const ConstPixelBufferAccess& faceAccess, const Sampler& sampler, float ref, float s, float t, int depth = 0)
2690 Sampler clampingSampler = sampler;
2691 clampingSampler.wrapS = Sampler::CLAMP_TO_EDGE;
2692 clampingSampler.wrapT = Sampler::CLAMP_TO_EDGE;
2693 return faceAccess.sample2DCompare(clampingSampler, Sampler::NEAREST, ref, s, t, IVec3(0, 0, depth));
2696 static float sampleCubeSeamlessLinearCompare (const ConstPixelBufferAccess (&faceAccesses)[CUBEFACE_LAST], CubeFace baseFace, const Sampler& sampler, float ref, float s, float t)
2705 if (sampler.normalizedCoords)
2707 u = unnormalize(sampler.wrapS, s, size);
2708 v = unnormalize(sampler.wrapT, t, size);
2736 sampleRes[i] = execCompare(faceAccesses[coords.face].getPixel(coords.s, coords.t), sampler.compare, sampler.compareChannel, ref, isFixedPointDepth);
2777 static float sampleLevelArrayCubeSeamlessCompare (const ConstPixelBufferAccess* const (&faces)[CUBEFACE_LAST], int numLevels, CubeFace face, const Sampler& sampler, float ref, float s, float t, float lod)
2779 bool magnified = lod <= sampler.lodThreshold;
2780 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2784 case Sampler::NEAREST:
2785 return sampleCubeSeamlessNearestCompare(faces[face][0], sampler, ref, s, t);
2787 case Sampler::LINEAR:
2793 return sampleCubeSeamlessLinearCompare(faceAccesses, face, sampler, ref, s, t);
2796 case Sampler::NEAREST_MIPMAP_NEAREST:
2797 case Sampler::LINEAR_MIPMAP_NEAREST:
2801 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2803 if (levelFilter == Sampler::NEAREST)
2804 return sampleCubeSeamlessNearestCompare(faces[face][level], sampler, ref, s, t);
2807 DE_ASSERT(levelFilter == Sampler::LINEAR);
2813 return sampleCubeSeamlessLinearCompare(faceAccesses, face, sampler, ref, s, t);
2817 case Sampler::NEAREST_MIPMAP_LINEAR:
2818 case Sampler::LINEAR_MIPMAP_LINEAR:
2823 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2828 if (levelFilter == Sampler::NEAREST)
2830 t0 = sampleCubeSeamlessNearestCompare(faces[face][level0], sampler, ref, s, t);
2831 t1 = sampleCubeSeamlessNearestCompare(faces[face][level1], sampler, ref, s, t);
2835 DE_ASSERT(levelFilter == Sampler::LINEAR);
2845 t0 = sampleCubeSeamlessLinearCompare(faceAccesses0, face, sampler, ref, s, t);
2846 t1 = sampleCubeSeamlessLinearCompare(faceAccesses1, face, sampler, ref, s, t);
2868 static Vec4 sampleCubeArraySeamless (const ConstPixelBufferAccess* const levels, int numLevels, int slice, CubeFace face, const Sampler& sampler, float s, float t, float lod)
2871 const bool magnified = lod <= sampler.lodThreshold;
2872 const Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2876 case Sampler::NEAREST:
2877 return sampleCubeSeamlessNearest(levels[0], sampler, s, t, faceDepth);
2879 case Sampler::LINEAR:
2885 return sampleCubeSeamlessLinear(faceAccesses, face, sampler, s, t, 0);
2888 case Sampler::NEAREST_MIPMAP_NEAREST:
2889 case Sampler::LINEAR_MIPMAP_NEAREST:
2893 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2895 if (levelFilter == Sampler::NEAREST)
2896 return sampleCubeSeamlessNearest(levels[level], sampler, s, t, faceDepth);
2899 DE_ASSERT(levelFilter == Sampler::LINEAR);
2905 return sampleCubeSeamlessLinear(faceAccesses, face, sampler, s, t, 0);
2909 case Sampler::NEAREST_MIPMAP_LINEAR:
2910 case Sampler::LINEAR_MIPMAP_LINEAR:
2915 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
2920 if (levelFilter == Sampler::NEAREST)
2922 t0 = sampleCubeSeamlessNearest(levels[level0], sampler, s, t, faceDepth);
2923 t1 = sampleCubeSeamlessNearest(levels[level1], sampler, s, t, faceDepth);
2927 DE_ASSERT(levelFilter == Sampler::LINEAR);
2937 t0 = sampleCubeSeamlessLinear(faceAccesses0, face, sampler, s, t, 0);
2938 t1 = sampleCubeSeamlessLinear(faceAccesses1, face, sampler, s, t, 0);
2950 static float sampleCubeArraySeamlessCompare (const ConstPixelBufferAccess* const levels, int numLevels, int slice, CubeFace face, const Sampler& sampler, float ref, float s, float t, float lod)
2953 const bool magnified = lod <= sampler.lodThreshold;
2954 Sampler::FilterMode filterMode = magnified ? sampler.magFilter : sampler.minFilter;
2958 case Sampler::NEAREST:
2959 return sampleCubeSeamlessNearestCompare(levels[0], sampler, ref, s, t, faceDepth);
2961 case Sampler::LINEAR:
2967 return sampleCubeSeamlessLinearCompare(faceAccesses, face, sampler, ref, s, t);
2970 case Sampler::NEAREST_MIPMAP_NEAREST:
2971 case Sampler::LINEAR_MIPMAP_NEAREST:
2975 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_NEAREST) ? Sampler::LINEAR : Sampler::NEAREST;
2977 if (levelFilter == Sampler::NEAREST)
2978 return sampleCubeSeamlessNearestCompare(levels[level], sampler, ref, s, t, faceDepth);
2981 DE_ASSERT(levelFilter == Sampler::LINEAR);
2987 return sampleCubeSeamlessLinearCompare(faceAccesses, face, sampler, ref, s, t);
2991 case Sampler::NEAREST_MIPMAP_LINEAR:
2992 case Sampler::LINEAR_MIPMAP_LINEAR:
2997 Sampler::FilterMode levelFilter = (filterMode == Sampler::LINEAR_MIPMAP_LINEAR) ? Sampler::LINEAR : Sampler::NEAREST;
3002 if (levelFilter == Sampler::NEAREST)
3004 t0 = sampleCubeSeamlessNearestCompare(levels[level0], sampler, ref, s, t, faceDepth);
3005 t1 = sampleCubeSeamlessNearestCompare(levels[level1], sampler, ref, s, t, faceDepth);
3009 DE_ASSERT(levelFilter == Sampler::LINEAR);
3019 t0 = sampleCubeSeamlessLinearCompare(faceAccesses0, face, sampler, ref, s, t);
3020 t1 = sampleCubeSeamlessLinearCompare(faceAccesses1, face, sampler, ref, s, t);
3229 tcu::Vec4 TextureCubeView::sample (const Sampler& sampler, float s, float t, float r, float lod) const
3231 DE_ASSERT(sampler.compare == Sampler::COMPAREMODE_NONE);
3235 if (sampler.seamlessCubeMap)
3236 return sampleLevelArrayCubeSeamless(m_levels, m_numLevels, coords.face, sampler, coords.s, coords.t, 0 /* depth */, lod);
3238 return sampleLevelArray2D(m_levels[coords.face], m_numLevels, sampler, coords.s, coords.t, 0 /* depth */, lod);
3241 float TextureCubeView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
3243 DE_ASSERT(sampler.compare != Sampler::COMPAREMODE_NONE);
3247 if (sampler.seamlessCubeMap)
3248 return sampleLevelArrayCubeSeamlessCompare(m_levels, m_numLevels, coords.face, sampler, ref, coords.s, coords.t, lod);
3250 return sampleLevelArray2DCompare(m_levels[coords.face], m_numLevels, sampler, ref, coords.s, coords.t, lod, IVec3(0, 0, 0));
3253 Vec4 TextureCubeView::gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const
3255 DE_ASSERT(sampler.compare == Sampler::COMPAREMODE_NONE);
3267 if (sampler.normalizedCoords)
3269 u = unnormalize(sampler.wrapS, coords.s, size);
3270 v = unnormalize(sampler.wrapT, coords.t, size);
3284 Vec4 TextureCubeView::gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const
3286 DE_ASSERT(sampler.compare != Sampler::COMPAREMODE_NONE);
3288 DE_ASSERT(sampler.compareChannel == 0);
3290 Sampler noCompareSampler = sampler;
3291 noCompareSampler.compare = Sampler::COMPAREMODE_NONE;
3297 result[i] = execCompare(gathered, sampler.compare, i, ref, isFixedPoint);
3424 Vec4 Texture1DArrayView::sample (const Sampler& sampler, float s, float t, float lod) const
3426 return sampleLevelArray1D(m_levels, m_numLevels, sampler, s, selectLayer(t), lod);
3429 Vec4 Texture1DArrayView::sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const
3431 return sampleLevelArray1DOffset(m_levels, m_numLevels, sampler, s, lod, IVec2(offset, selectLayer(t)));
3434 float Texture1DArrayView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
3436 return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(0, selectLayer(t)));
3439 float Texture1DArrayView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const
3441 return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(offset, selectLayer(t)));
3458 Vec4 Texture2DArrayView::sample (const Sampler& sampler, float s, float t, float r, float lod) const
3460 return sampleLevelArray2D(m_levels, m_numLevels, sampler, s, t, selectLayer(r), lod);
3463 float Texture2DArrayView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
3465 return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(0, 0, selectLayer(r)));
3468 Vec4 Texture2DArrayView::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const
3470 return sampleLevelArray2DOffset(m_levels, m_numLevels, sampler, s, t, lod, IVec3(offset.x(), offset.y(), selectLayer(r)));
3473 float Texture2DArrayView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const
3475 return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(offset.x(), offset.y(), selectLayer(r)));
3478 Vec4 Texture2DArrayView::gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const
3480 return gatherArray2DOffsets(m_levels[0], sampler, s, t, selectLayer(r), componentNdx, offsets);
3483 Vec4 Texture2DArrayView::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const
3485 return gatherArray2DOffsetsCompare(m_levels[0], sampler, ref, s, t, selectLayer(r), offsets);
3656 tcu::Vec4 TextureCubeArrayView::sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const
3662 DE_ASSERT(sampler.compare == Sampler::COMPAREMODE_NONE);
3664 if (sampler.seamlessCubeMap)
3665 return sampleCubeArraySeamless(m_levels, m_numLevels, layer, coords.face, sampler, coords.s, coords.t, lod);
3667 return sampleLevelArray2D(m_levels, m_numLevels, sampler, coords.s, coords.t, faceDepth, lod);
3670 float TextureCubeArrayView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const
3676 DE_ASSERT(sampler.compare != Sampler::COMPAREMODE_NONE);
3678 if (sampler.seamlessCubeMap)
3679 return sampleCubeArraySeamlessCompare(m_levels, m_numLevels, layer, coords.face, sampler, ref, coords.s, coords.t, lod);
3681 return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, coords.s, coords.t, lod, IVec3(0, 0, faceDepth));