float compute_error_of_weight_set_1plane(
	const endpoints_and_weights& eai,
	const decimation_info& di,
	const float* dec_weight_quant_uvalue
) {
	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)
		{
			// Compute the bilinear interpolation of the decimated weight grid
			vfloat current_values = bilinear_infill_vla(di, dec_weight_quant_uvalue, i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values = loada(eai.weights + i);
			vfloat diff = current_values - actual_values;
			vfloat significance = loada(eai.weight_error_scale + i);
			vfloat error = diff * diff * significance;

			haccumulate(error_summav, error);
		}
	}
	else
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			// Load the weight set directly, without interpolation
			vfloat current_values = loada(dec_weight_quant_uvalue + i);

			// Compute the error between the computed value and the ideal weight
			vfloat actual_values = loada(eai.weights + i);
			vfloat diff = current_values - actual_values;
			vfloat significance = loada(eai.weight_error_scale + i);
			vfloat error = diff * diff * significance;

			haccumulate(error_summav, error);
		}
	}

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

	return error_summa;
}
float compute_error_of_weight_set_1plane(
	const endpoints_and_weights& eai,
	const decimation_info& di,
	const float* dec_weight_quant_uvalue
) {
	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_values = bilinear_infill_vla(di, dec_weight_quant_uvalue, i);

			 
			vfloat actual_values = loada(eai.weights + i);
			vfloat diff = current_values - actual_values;
			vfloat significance = loada(eai.weight_error_scale + i);
			vfloat error = diff * diff * significance;

			haccumulate(error_summav, error);
		}
	}
	else
	{
		for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
		{
			 
			vfloat current_values = loada(dec_weight_quant_uvalue + i);

			 
			vfloat actual_values = loada(eai.weights + i);
			vfloat diff = current_values - actual_values;
			vfloat significance = loada(eai.weight_error_scale + i);
			vfloat error = diff * diff * significance;

			haccumulate(error_summav, error);
		}
	}

	 
	haccumulate(error_summa, error_summav);

	return error_summa;
}