@ -166,7 +166,7 @@ get_image_prop(struct buffer *buf, struct image_header *header)
static void
static void
gen_ramp_rgb ( const struct image_header * header , int bitwidth , int width_bar )
gen_ramp_rgb ( const struct image_header * header , int bitwidth , int width_bar )
{
{
static const int hue [ ] [ 3 ] = {
static const int hue [ ] [ COLOR_CHAN_NUM ] = {
{ 1 , 1 , 1 } , /* White */
{ 1 , 1 , 1 } , /* White */
{ 1 , 1 , 0 } , /* Yellow */
{ 1 , 1 , 0 } , /* Yellow */
{ 0 , 1 , 1 } , /* Cyan */
{ 0 , 1 , 1 } , /* Cyan */
@ -180,6 +180,7 @@ gen_ramp_rgb(const struct image_header *header, int bitwidth, int width_bar)
float val_max ;
float val_max ;
int x , y ;
int x , y ;
int hue_index ;
int hue_index ;
int chan ;
float value ;
float value ;
unsigned char r , g , b ;
unsigned char r , g , b ;
uint32_t * pixel ;
uint32_t * pixel ;
@ -200,12 +201,10 @@ gen_ramp_rgb(const struct image_header *header, int bitwidth, int width_bar)
if ( width_bar > 1 )
if ( width_bar > 1 )
value = floor ( value * n_steps ) / n_steps ;
value = floor ( value * n_steps ) / n_steps ;
if ( hue [ hue_index ] [ 0 ] )
for ( chan = 0 ; chan < COLOR_CHAN_NUM ; chan + + ) {
rgb . r = value ;
if ( hue [ hue_index ] [ chan ] )
if ( hue [ hue_index ] [ 1 ] )
rgb . rgb [ chan ] = value ;
rgb . g = value ;
}
if ( hue [ hue_index ] [ 2 ] )
rgb . b = value ;
sRGB_delinearize ( & rgb ) ;
sRGB_delinearize ( & rgb ) ;
@ -359,14 +358,15 @@ process_pipeline_comparison(const struct image_header *src,
const struct image_header * shot ,
const struct image_header * shot ,
const struct setup_args * arg )
const struct setup_args * arg )
{
{
const char * const chan_name [ COLOR_CHAN_NUM ] = { " r " , " g " , " b " } ;
const float max_pixel_value = 255.0 ;
const float max_pixel_value = 255.0 ;
struct color_float max_diff_pipeline = { . rgb = { 0.0f , 0.0f , 0.0f } } ;
struct color_float max_diff_pipeline = { . rgb = { 0.0f , 0.0f , 0.0f } } ;
float max_allow_diff = arg - > pipeline . tolerance / max_pixel_value ;
float max_allow_diff = arg - > pipeline . tolerance / max_pixel_value ;
float max_err = 0 ;
float max_err = 0.0f ;
float f_max_err = 0 ;
bool ok = true ;
bool ok = true ;
uint32_t * row_ptr , * row_ptr_shot ;
uint32_t * row_ptr , * row_ptr_shot ;
int y , x ;
int y , x ;
int chan ;
struct color_float pix_src ;
struct color_float pix_src ;
struct color_float pix_src_pipeline ;
struct color_float pix_src_pipeline ;
struct color_float pix_shot ;
struct color_float pix_shot ;
@ -383,26 +383,25 @@ process_pipeline_comparison(const struct image_header *src,
& arg - > pipeline . mat ,
& arg - > pipeline . mat ,
arg - > pipeline . post_fn ,
arg - > pipeline . post_fn ,
& pix_src , & pix_src_pipeline ) ;
& pix_src , & pix_src_pipeline ) ;
/* check if pipeline matches to shader variant */
/* check if pipeline matches to shader variant */
ok & = compare_float ( pix_src_pipeline . r , pix_shot . r , x , " r " ,
for ( chan = 0 ; chan < COLOR_CHAN_NUM ; chan + + ) {
& max_diff_pipeline . r , max_allow_diff ) ;
ok & = compare_float ( pix_src_pipeline . rgb [ chan ] ,
ok & = compare_float ( pix_src_pipeline . g , pix_shot . g , x , " g " ,
pix_shot . rgb [ chan ] ,
& max_diff_pipeline . g , max_allow_diff ) ;
x , chan_name [ chan ] ,
ok & = compare_float ( pix_src_pipeline . b , pix_shot . b , x , " b " ,
& max_diff_pipeline . rgb [ chan ] ,
& max_diff_pipeline . b , max_allow_diff ) ;
max_allow_diff ) ;
}
}
}
}
}
max_err = max_diff_pipeline . r ;
if ( max_err < max_diff_pipeline . g )
max_err = max_diff_pipeline . g ;
if ( max_err < max_diff_pipeline . b )
max_err = max_diff_pipeline . b ;
f_max_err = max_pixel_value * max_err ;
for ( chan = 0 ; chan < COLOR_CHAN_NUM ; chan + + )
max_err = MAX ( max_err , max_diff_pipeline . rgb [ chan ] ) ;
testlog ( " %s %s %s tol_req %d, tol_cal %f, max diff: r=%f, g=%f, b=%f \n " ,
testlog ( " %s %s %s tol_req %d, tol_cal %f, max diff: r=%f, g=%f, b=%f \n " ,
__func__ , ok = = true ? " SUCCESS " : " FAILURE " ,
__func__ , ok = = true ? " SUCCESS " : " FAILURE " ,
arg - > meta . name , arg - > pipeline . tolerance , f_max_err ,
arg - > meta . name , arg - > pipeline . tolerance ,
max_err * max_pixel_value ,
max_diff_pipeline . r , max_diff_pipeline . g , max_diff_pipeline . b ) ;
max_diff_pipeline . r , max_diff_pipeline . g , max_diff_pipeline . b ) ;
return ok ;
return ok ;