Skip to content

Commit

Permalink
llvmpipe: asst. clean-ups in lp_test_blend.c
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19289>
  • Loading branch information
brianpaul authored and Marge Bot committed Oct 25, 2022
1 parent eb4ff32 commit 4fa2660
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/gallium/drivers/llvmpipe/lp_test_blend.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ test_one(unsigned verbose,
unsigned i, j;
const unsigned stride = lp_type_width(type)/8;

if(verbose >= 1)
if (verbose >= 1)
dump_blend_type(stdout, blend, type);

context = LLVMContextCreate();
Expand Down Expand Up @@ -476,7 +476,7 @@ test_one(unsigned verbose,
res = align_malloc(stride, stride);
ref = align_malloc(stride, stride);

for(i = 0; i < n && success; ++i) {
for (i = 0; i < n && success; ++i) {
int64_t start_counter = 0;
int64_t end_counter = 0;

Expand All @@ -497,7 +497,7 @@ test_one(unsigned verbose,
read_vec(type, dst, fdst);
read_vec(type, con, fcon);

for(j = 0; j < type.length; j += 4)
for (j = 0; j < type.length; j += 4)
compute_blend_ref(blend, fsrc + j, fsrc1 + j, fdst + j, fcon + j, fref + j);

write_vec(type, ref, fref);
Expand All @@ -509,10 +509,10 @@ test_one(unsigned verbose,

cycles[i] = end_counter - start_counter;

if(!compare_vec(type, res, ref)) {
if (!compare_vec(type, res, ref)) {
success = FALSE;

if(verbose < 1)
if (verbose < 1)
dump_blend_type(stderr, blend, type);
fprintf(stderr, "MISMATCH\n");

Expand Down Expand Up @@ -559,7 +559,7 @@ test_one(unsigned verbose,
double avg, std;
unsigned m;

for(i = 0; i < n; ++i) {
for (i = 0; i < n; ++i) {
sum += cycles[i];
sum2 += cycles[i]*cycles[i];
}
Expand All @@ -569,8 +569,8 @@ test_one(unsigned verbose,

m = 0;
sum = 0.0;
for(i = 0; i < n; ++i) {
if(fabs(cycles[i] - avg) <= 4.0*std) {
for (i = 0; i < n; ++i) {
if (fabs(cycles[i] - avg) <= 4.0*std) {
sum += cycles[i];
++m;
}
Expand All @@ -580,7 +580,7 @@ test_one(unsigned verbose,

}

if(fp)
if (fp)
write_tsv_row(fp, blend, type, cycles_avg, success);

gallivm_destroy(gallivm);
Expand Down Expand Up @@ -649,15 +649,15 @@ test_all(unsigned verbose, FILE *fp)
const struct lp_type *type;
boolean success = TRUE;

for(rgb_func = blend_funcs; rgb_func < &blend_funcs[num_funcs]; ++rgb_func) {
for(alpha_func = blend_funcs; alpha_func < &blend_funcs[num_funcs]; ++alpha_func) {
for(rgb_src_factor = blend_factors; rgb_src_factor < &blend_factors[num_factors]; ++rgb_src_factor) {
for(rgb_dst_factor = blend_factors; rgb_dst_factor <= rgb_src_factor; ++rgb_dst_factor) {
for(alpha_src_factor = blend_factors; alpha_src_factor < &blend_factors[num_factors]; ++alpha_src_factor) {
for(alpha_dst_factor = blend_factors; alpha_dst_factor <= alpha_src_factor; ++alpha_dst_factor) {
for(type = blend_types; type < &blend_types[num_types]; ++type) {
for (rgb_func = blend_funcs; rgb_func < &blend_funcs[num_funcs]; ++rgb_func) {
for (alpha_func = blend_funcs; alpha_func < &blend_funcs[num_funcs]; ++alpha_func) {
for (rgb_src_factor = blend_factors; rgb_src_factor < &blend_factors[num_factors]; ++rgb_src_factor) {
for (rgb_dst_factor = blend_factors; rgb_dst_factor <= rgb_src_factor; ++rgb_dst_factor) {
for (alpha_src_factor = blend_factors; alpha_src_factor < &blend_factors[num_factors]; ++alpha_src_factor) {
for (alpha_dst_factor = blend_factors; alpha_dst_factor <= alpha_src_factor; ++alpha_dst_factor) {
for (type = blend_types; type < &blend_types[num_types]; ++type) {

if(*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
if (*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE ||
*alpha_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE)
continue;

Expand All @@ -671,7 +671,7 @@ test_all(unsigned verbose, FILE *fp)
blend.rt[0].alpha_dst_factor = *alpha_dst_factor;
blend.rt[0].colormask = PIPE_MASK_RGBA;

if(!test_one(verbose, fp, &blend, *type))
if (!test_one(verbose, fp, &blend, *type))
success = FALSE;

}
Expand All @@ -698,15 +698,14 @@ test_some(unsigned verbose, FILE *fp,
const unsigned *alpha_dst_factor;
struct pipe_blend_state blend;
const struct lp_type *type;
unsigned long i;
boolean success = TRUE;

for(i = 0; i < n; ++i) {
for (unsigned long i = 0; i < n; ++i) {
rgb_func = &blend_funcs[rand() % num_funcs];
alpha_func = &blend_funcs[rand() % num_funcs];
rgb_src_factor = &blend_factors[rand() % num_factors];
alpha_src_factor = &blend_factors[rand() % num_factors];

do {
rgb_dst_factor = &blend_factors[rand() % num_factors];
} while(*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE);
Expand All @@ -727,8 +726,8 @@ test_some(unsigned verbose, FILE *fp,
blend.rt[0].alpha_dst_factor = *alpha_dst_factor;
blend.rt[0].colormask = PIPE_MASK_RGBA;

if(!test_one(verbose, fp, &blend, *type))
success = FALSE;
if (!test_one(verbose, fp, &blend, *type))
success = FALSE;
}

return success;
Expand Down

0 comments on commit 4fa2660

Please sign in to comment.