Lines Matching refs:access

229 		// It is never allowed to access combined depth-stencil format with getPixel().
231 // access must be used.
240 // A few packed color formats have access type restrictions
250 * \brief Get access to subregion of pixel buffer
251 * \param access Parent access object
258 * \return Access object that targets given subregion of parent access object
260 ConstPixelBufferAccess getSubregion (const ConstPixelBufferAccess& access, int x, int y, int z, int width, int height, int depth)
262 DE_ASSERT(de::inBounds(x, 0, access.getWidth()));
263 DE_ASSERT(de::inRange(x+width, x+1, access.getWidth()));
265 DE_ASSERT(de::inBounds(y, 0, access.getHeight()));
266 DE_ASSERT(de::inRange(y+height, y+1, access.getHeight()));
268 DE_ASSERT(de::inBounds(z, 0, access.getDepth()));
270 DE_ASSERT(de::inRange(z + depth, z + 1, access.getDepth()));
272 return ConstPixelBufferAccess(access.getFormat(), tcu::IVec3(width, height, depth), access.getPitch(),
273 (const deUint8*)access.getDataPtr() + access.getPixelPitch()*x + access.getRowPitch()*y + access.getSlicePitch()*z);
277 * \brief Get access to subregion of pixel buffer
278 * \param access Parent access object
285 * \return Access object that targets given subregion of parent access object
287 PixelBufferAccess getSubregion (const PixelBufferAccess& access, int x, int y, int z, int width, int height, int depth)
289 DE_ASSERT(de::inBounds(x, 0, access.getWidth()));
290 DE_ASSERT(de::inRange(x+width, x+1, access.getWidth()));
292 DE_ASSERT(de::inBounds(y, 0, access.getHeight()));
293 DE_ASSERT(de::inRange(y+height, y+1, access.getHeight()));
295 DE_ASSERT(de::inBounds(z, 0, access.getDepth()));
297 DE_ASSERT(de::inRange(z + depth, z + 1, access.getDepth()));
299 return PixelBufferAccess(access.getFormat(), tcu::IVec3(width, height, depth), access.getPitch(),
300 (deUint8*)access.getDataPtr() + access.getPixelPitch()*x + access.getRowPitch()*y + access.getSlicePitch()*z);
304 * \brief Get access to subregion of pixel buffer
305 * \param access Parent access object
310 * \return Access object that targets given subregion of parent access object
312 PixelBufferAccess getSubregion (const PixelBufferAccess& access, int x, int y, int width, int height)
314 return getSubregion(access, x, y, 0, width, height, 1);
318 * \brief Get access to subregion of pixel buffer
319 * \param access Parent access object
324 * \return Access object that targets given subregion of parent access object
326 ConstPixelBufferAccess getSubregion (const ConstPixelBufferAccess& access, int x, int y, int width, int height)
328 return getSubregion(access, x, y, 0, width, height, 1);
333 * \param access Access object
334 * \return Modified access object where Y coordinates are reversed
336 PixelBufferAccess flipYAccess (const PixelBufferAccess& access)
338 const int rowPitch = access.getRowPitch();
339 const int offsetToLast = rowPitch*(access.getHeight()-1);
340 const tcu::IVec3 pitch (access.getPixelPitch(), -rowPitch, access.getSlicePitch());
342 return PixelBufferAccess(access.getFormat(), access.getSize(), pitch, (deUint8*)access.getDataPtr() + offsetToLast);
347 * \param access Access object
348 * \return Modified access object where Y coordinates are reversed
350 ConstPixelBufferAccess flipYAccess (const ConstPixelBufferAccess& access)
352 const int rowPitch = access.getRowPitch();
353 const int offsetToLast = rowPitch*(access.getHeight()-1);
354 const tcu::IVec3 pitch (access.getPixelPitch(), -rowPitch, access.getSlicePitch());
356 return ConstPixelBufferAccess(access.getFormat(), access.getSize(), pitch, (deUint8*)access.getDataPtr() + offsetToLast);
754 void clear (const PixelBufferAccess& access, const Vec4& color)
756 const int pixelSize = access.getFormat().getPixelSize();
757 const int pixelPitch = access.getPixelPitch();
760 if (access.getWidth()*access.getHeight()*access.getDepth() >= CLEAR_OPTIMIZE_THRESHOLD &&
770 PixelBufferAccess(access.getFormat(), 1, 1, 1, 0, 0, &pixel.u8[0]).setPixel(color, 0, 0);
772 for (int z = 0; z < access.getDepth(); z++)
773 for (int y = 0; y < access.getHeight(); y++)
774 fillRow(access, y, z, pixelSize, &pixel.u8[0]);
778 for (int z = 0; z < access.getDepth(); z++)
779 for (int y = 0; y < access.getHeight(); y++)
780 for (int x = 0; x < access.getWidth(); x++)
781 access.setPixel(color, x, y, z);
785 void clear (const PixelBufferAccess& access, const IVec4& color)
787 const int pixelSize = access.getFormat().getPixelSize();
788 const int pixelPitch = access.getPixelPitch();
791 if (access.getWidth()*access.getHeight()*access.getDepth() >= CLEAR_OPTIMIZE_THRESHOLD &&
801 PixelBufferAccess(access.getFormat(), 1, 1, 1, 0, 0, &pixel.u8[0]).setPixel(color, 0, 0);
803 for (int z = 0; z < access.getDepth(); z++)
804 for (int y = 0; y < access.getHeight(); y++)
805 fillRow(access, y, z, pixelSize, &pixel.u8[0]);
809 for (int z = 0; z < access.getDepth(); z++)
810 for (int y = 0; y < access.getHeight(); y++)
811 for (int x = 0; x < access.getWidth(); x++)
812 access.setPixel(color, x, y, z);
816 void clear (const PixelBufferAccess& access, const UVec4& color)
818 clear(access, color.cast<deInt32>());
821 void clearDepth (const PixelBufferAccess& access, float depth)
823 DE_ASSERT(access.getFormat().order == TextureFormat::DS || access.getFormat().order == TextureFormat::D);
825 clear(getEffectiveDepthStencilAccess(access, Sampler::MODE_DEPTH), tcu::Vec4(depth, 0.0f, 0.0f, 0.0f));
828 void clearStencil (const PixelBufferAccess& access, int stencil)
830 DE_ASSERT(access.getFormat().order == TextureFormat::DS || access.getFormat().order == TextureFormat::S);
832 clear(getEffectiveDepthStencilAccess(access, Sampler::MODE_STENCIL), tcu::UVec4(stencil, 0u, 0u, 0u));
842 static void fillWithComponentGradients1D (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal, GradientStyle)
844 DE_ASSERT(access.getHeight() == 1);
845 for (int x = 0; x < access.getWidth(); x++)
847 float s = ((float)x + 0.5f) / (float)access.getWidth();
854 access.setPixel(tcu::Vec4(r, g, b, a), x, 0);
858 static void fillWithComponentGradients2D (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal, GradientStyle style)
862 int xedge = deFloorFloatToInt32(float(access.getWidth()) * 0.6f);
863 int yedge = deFloorFloatToInt32(float(access.getHeight()) * 0.6f);
865 for (int y = 0; y < access.getHeight(); y++)
867 for (int x = 0; x < access.getWidth(); x++)
869 float s = ((float)x + 0.5f) / (float)access.getWidth();
870 float t = ((float)y + 0.5f) / (float)access.getHeight();
891 access.setPixel(tcu::Vec4(r, g, b, a), x, y);
897 for (int y = 0; y < access.getHeight(); y++)
899 for (int x = 0; x < access.getWidth(); x++)
901 float s = ((float)x + 0.5f) / (float)access.getWidth();
902 float t = ((float)y + 0.5f) / (float)access.getHeight();
909 access.setPixel(tcu::Vec4(r, g, b, a), x, y);
952 void fillWithComponentGradientsStyled (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal, GradientStyle style)
954 if (isCombinedDepthStencilType(access.getFormat().type))
956 const bool hasDepth = access.getFormat().order == tcu::TextureFormat::DS || access.getFormat().order == tcu::TextureFormat::D;
957 const bool hasStencil = access.getFormat().order == tcu::TextureFormat::DS || access.getFormat().order == tcu::TextureFormat::S;
963 fillWithComponentGradientsStyled(getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_DEPTH), minVal, maxVal, style);
965 fillWithComponentGradientsStyled(getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_STENCIL), minVal.swizzle(3,2,1,0), maxVal.swizzle(3,2,1,0), style);
969 if (access.getHeight() == 1 && access.getDepth() == 1)
970 fillWithComponentGradients1D(access, minVal, maxVal, style);
971 else if (access.getDepth() == 1)
972 fillWithComponentGradients2D(access, minVal, maxVal, style);
974 fillWithComponentGradients3D(access, minVal, maxVal, style);
978 void fillWithComponentGradients (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal)
980 fillWithComponentGradientsStyled(access, minVal, maxVal, GRADIENT_STYLE_OLD);
983 void fillWithComponentGradients2 (const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal)
985 fillWithComponentGradientsStyled(access, minVal, maxVal, GRADIENT_STYLE_NEW);
988 void fillWithComponentGradients3(const PixelBufferAccess& access, const Vec4& minVal, const Vec4& maxVal)
990 fillWithComponentGradientsStyled(access, minVal, maxVal, GRADIENT_STYLE_PYRAMID);
993 static void fillWithGrid1D (const PixelBufferAccess& access, int cellSize, const Vec4& colorA, const Vec4& colorB)
995 for (int x = 0; x < access.getWidth(); x++)
1000 access.setPixel(colorB, x, 0);
1002 access.setPixel(colorA, x, 0);
1006 static void fillWithGrid2D (const PixelBufferAccess& access, int cellSize, const Vec4& colorA, const Vec4& colorB)
1008 for (int y = 0; y < access.getHeight(); y++)
1010 for (int x = 0; x < access.getWidth(); x++)
1016 access.setPixel(colorB, x, y);
1018 access.setPixel(colorA, x, y);
1023 static void fillWithGrid3D (const PixelBufferAccess& access, int cellSize, const Vec4& colorA, const Vec4& colorB)
1025 for (int z = 0; z < access.getDepth(); z++)
1027 for (int y = 0; y < access.getHeight(); y++)
1029 for (int x = 0; x < access.getWidth(); x++)
1036 access.setPixel(colorB, x, y, z);
1038 access.setPixel(colorA, x, y, z);
1044 void fillWithGrid (const PixelBufferAccess& access, int cellSize, const Vec4& colorA, const Vec4& colorB)
1046 if (isCombinedDepthStencilType(access.getFormat().type))
1048 const bool hasDepth = access.getFormat().order == tcu::TextureFormat::DS || access.getFormat().order == tcu::TextureFormat::D;
1049 const bool hasStencil = access.getFormat().order == tcu::TextureFormat::DS || access.getFormat().order == tcu::TextureFormat::S;
1055 fillWithGrid(getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_DEPTH), cellSize, colorA, colorB);
1057 fillWithGrid(getEffectiveDepthStencilAccess(access, tcu::Sampler::MODE_STENCIL), cellSize, colorA.swizzle(3,2,1,0), colorB.swizzle(3,2,1,0));
1061 if (access.getHeight() == 1 && access.getDepth() == 1)
1062 fillWithGrid1D(access, cellSize, colorA, colorB);
1063 else if (access.getDepth() == 1)
1064 fillWithGrid2D(access, cellSize, colorA, colorB);
1066 fillWithGrid3D(access, cellSize, colorA, colorB);
1070 void fillWithRepeatableGradient (const PixelBufferAccess& access, const Vec4& colorA, const Vec4& colorB)
1072 for (int y = 0; y < access.getHeight(); y++)
1074 for (int x = 0; x < access.getWidth(); x++)
1076 float s = ((float)x + 0.5f) / (float)access.getWidth();
1077 float t = ((float)y + 0.5f) / (float)access.getHeight();
1083 access.setPixel(linearInterpolate(p, colorA, colorB), x, y);
1249 void estimatePixelValueRange (const ConstPixelBufferAccess& access, Vec4& minVal, Vec4& maxVal)
1251 const TextureFormat& format = access.getFormat();
1272 for (int z = 0; z < access.getDepth(); z += 2)
1274 for (int y = 0; y < access.getHeight(); y += 2)
1276 for (int x = 0; x < access.getWidth(); x += 2)
1278 Vec4 p = access.getPixel(x, y, z);
1296 void computePixelScaleBias (const ConstPixelBufferAccess& access, Vec4& scale, Vec4& bias)
1299 estimatePixelValueRange(access, minVal, maxVal);