Esempio n. 1
0
static bool
are_formats_compatible(struct texture_format *f1, struct texture_format *f2)
{
	if (f1 == f2)
		return true;

	if (!f1->can_be_reinterpreted || !f2->can_be_reinterpreted)
		return false;

	if (is_format_compressed(f1) && is_format_compressed(f2)) {
		/* Compressed-to-compressed copies are not supported */
		return false;
	}

	return f1->bytes == f2->bytes;
}
Esempio n. 2
0
bool CImage::GenerateMipmaps(unsigned int nMipmaps)
{
	// Compressed formats should have mipmaps packed in //
	if(is_format_compressed(m_pixelFormat))
		return false;

	// We do not support non-square mipmapping at this time //
	if(!is_power_of_2(m_imageWidth, m_imageHeight))
		return false;


	m_mipMapCount = gmin(get_mipmap_count_from_dim(gmax(gmax(m_imageWidth, m_imageHeight), m_depth)), nMipmaps);
	m_pPixels = (unsigned char*)realloc(m_pPixels, GetSizeWithMipmaps());

	unsigned char *dest, *src = m_pPixels;
	int c = get_channel_count(m_pixelFormat);
	int cSize = get_bytes_per_channel(m_pixelFormat);
	if(IsCubemap())
	{
		int dim = m_imageWidth;
		for(int i = 1; i < m_mipMapCount; ++i)
		{
			int sliceSize = dim * dim * c * cSize;
			dest = src + 6 * sliceSize;

			for(unsigned int s = 0; s < 6; ++s)
			{
				if(cSize == 1)
					generate_mipmaps(src + s * sliceSize, dest + s * sliceSize / 4, dim, dim, 1, c);
				else if(cSize == 2)
					generate_mipmaps((unsigned short*)(src + s * sliceSize), (unsigned short*)(dest + s * sliceSize / 4), dim, dim, 1, c);
				else
					generate_mipmaps((float*)(src + s * sliceSize), (float*)(dest + s * sliceSize / 4), dim, dim, 1, c);
			}

			src = dest;
			dim >>= 1;
		}
	}

	else
	{
Esempio n. 3
0
enum piglit_result
piglit_display(void)
{
	enum piglit_result result = PIGLIT_PASS;
	enum piglit_result subtest;
	struct texture_format *src_format_list, *dst_format_list;
	struct texture_format *src_format, *dst_format;
	int sf, df, src_format_count, dst_format_count;

	if (src_format_arg) {
		src_format_list = src_format_arg;
		src_format_count = 1;
	} else {
		src_format_list = formats;
		src_format_count = ARRAY_LENGTH(formats);
	}

	if (dst_format_arg) {
		dst_format_list = dst_format_arg;
		dst_format_count = 1;
	} else {
		dst_format_list = formats;
		dst_format_count = ARRAY_LENGTH(formats);
	}

	for (sf = 0; sf < src_format_count; ++sf) {
		src_format = &src_format_list[sf];
		if (!is_format_supported(src_format))
			continue;

		for (df = 0; df < dst_format_count; ++df) {
			dst_format = &dst_format_list[df];
			if (!is_format_supported(dst_format))
				continue;
			if (!are_formats_compatible(src_format, dst_format))
				continue;

			setup_test_data(src_format, dst_format);
			if (samples == 1) {
				subtest = run_test(src_format,
						   dst_format);
			} else {
				if (is_format_compressed(src_format) ||
				    is_format_compressed(dst_format))
					continue;

				subtest = run_multisample_test(src_format,
							       dst_format);
			}

			if (!src_format_arg) {
				/* In this case, we're running a full suite
				 * of subtests, report accordingly.
				 */
				piglit_report_subtest_result(subtest,
					"Source: %s/Destination: %s",
					src_format->name, dst_format->name);
			} else if (!dst_format_arg) {
				/* In this case, the source format was
				 * specified but the destination was not.
				 * Report one subtest per destination.
				 */
				piglit_report_subtest_result(subtest,
					"Destination Format: %s",
					dst_format->name);
			}

			if (subtest == PIGLIT_FAIL)
				result = PIGLIT_FAIL;
			else if (subtest == PIGLIT_WARN && result == PIGLIT_PASS)
				result = PIGLIT_WARN;
		}
	}

	return result;
}