float compute_error_of_weight_set_2planes(
	const endpoints_and_weights& eai1,
	const endpoints_and_weights& eai2,
	const decimation_info& di,
	const float* dec_weight_quant_uvalue_plane1,
	const float* dec_weight_quant_uvalue_plane2
) {
	vfloat4 error_summav = vfloat4::zero();
	float error_summa = 0.0f;
	unsigned int texel_count = di.texel_count;
	bool is_decimated = di.texel_count != di.weight_count;

	// Process SIMD-width chunks, safe to over-fetch - the extra space is zero initialized
	if (is_decimated)
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			// Plane 1
			// Compute the bilinear interpolation of the decimated weight grid
			vfloat current_values1 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane1, i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values1 = loada(eai1.weights + i);
			vfloat diff = current_values1 - actual_values1;
			vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);

			// Plane 2
			// Compute the bilinear interpolation of the decimated weight grid
			vfloat current_values2 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane2, i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values2 = loada(eai2.weights + i);
			diff = current_values2 - actual_values2;
			vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);

			haccumulate(error_summav, error1 + error2);
		}
	}
	else
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			// Plane 1
			// Load the weight set directly, without interpolation
			vfloat current_values1 = loada(dec_weight_quant_uvalue_plane1 + i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values1 = loada(eai1.weights + i);
			vfloat diff = current_values1 - actual_values1;
			vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);

			// Plane 2
			// Load the weight set directly, without interpolation
			vfloat current_values2 = loada(dec_weight_quant_uvalue_plane2 + i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values2 = loada(eai2.weights + i);
			diff = current_values2 - actual_values2;
			vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);

			haccumulate(error_summav, error1 + error2);
		}
	}

	// Resolve the final scalar accumulator sum
	haccumulate(error_summa, error_summav);

	return error_summa;
}
float compute_error_of_weight_set_2planes(
	const endpoints_and_weights& eai1,
	const endpoints_and_weights& eai2,
	const decimation_info& di,
	const float* dec_weight_quant_uvalue_plane1,
	const float* dec_weight_quant_uvalue_plane2
) {
	vfloat4 error_summav = vfloat4::zero();
	float error_summa = 0.0f;
	unsigned int texel_count = di.texel_count;
	bool is_decimated = di.texel_count != di.weight_count;

	 
	if (is_decimated)
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			 
			 
			vfloat current_values1 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane1, i);

			 
			vfloat actual_values1 = loada(eai1.weights + i);
			vfloat diff = current_values1 - actual_values1;
			vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);

			 
			 
			vfloat current_values2 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane2, i);

			 
			vfloat actual_values2 = loada(eai2.weights + i);
			diff = current_values2 - actual_values2;
			vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);

			haccumulate(error_summav, error1 + error2);
		}
	}
	else
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			 
			 
			vfloat current_values1 = loada(dec_weight_quant_uvalue_plane1 + i);

			 
			vfloat actual_values1 = loada(eai1.weights + i);
			vfloat diff = current_values1 - actual_values1;
			vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);

			 
			 
			vfloat current_values2 = loada(dec_weight_quant_uvalue_plane2 + i);

			 
			vfloat actual_values2 = loada(eai2.weights + i);
			diff = current_values2 - actual_values2;
			vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);

			haccumulate(error_summav, error1 + error2);
		}
	}

	 
	haccumulate(error_summa, error_summav);

	return error_summa;
}