brw: Add explicit way to get an empty brw_builder

And use brw_builder(brw_shader *) and brw_builder() constructors
where possible.

The way tests are written, it is necessary to initialize an "empty"
builder -- which is later replaced by a proper one.  Default parameter
NULL make that initialization implicit.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33815>
This commit is contained in:
Caio Oliveira 2025-02-27 22:48:36 -08:00 committed by Marge Bot
parent 32e562ae01
commit 6f37e6f104
7 changed files with 9 additions and 7 deletions

View file

@ -50,7 +50,14 @@ public:
{
}
explicit brw_builder(brw_shader *s) : brw_builder(s, s->dispatch_width) {}
/**
* Construct an brw_builder that inserts instructions into \p shader,
* using its dispatch width.
*/
explicit brw_builder(brw_shader *s = NULL) :
brw_builder(s, s ? s->dispatch_width : 0)
{
}
/**
* Construct an brw_builder that inserts instructions before

View file

@ -42,7 +42,6 @@ protected:
};
scoreboard_test::scoreboard_test()
: bld(NULL, 0)
{
ctx = ralloc_context(NULL);
compiler = rzalloc(ctx, struct brw_compiler);

View file

@ -53,7 +53,6 @@ protected:
};
cmod_propagation_test::cmod_propagation_test()
: bld(NULL, 0)
{
ctx = ralloc_context(NULL);
compiler = rzalloc(ctx, struct brw_compiler);

View file

@ -68,7 +68,7 @@ struct FSCombineConstantsTest : public ::testing::Test {
static brw_builder
make_builder(brw_shader *s)
{
return brw_builder(s, s->dispatch_width).at_end();
return brw_builder(s).at_end();
}
TEST_F(FSCombineConstantsTest, Simple)

View file

@ -42,7 +42,6 @@ protected:
};
copy_propagation_test::copy_propagation_test()
: bld(NULL, 0)
{
ctx = ralloc_context(NULL);
compiler = rzalloc(ctx, struct brw_compiler);

View file

@ -24,7 +24,6 @@ protected:
};
cse_test::cse_test()
: bld(NULL, 0)
{
ctx = ralloc_context(NULL);
compiler = rzalloc(ctx, struct brw_compiler);

View file

@ -42,7 +42,6 @@ protected:
};
saturate_propagation_test::saturate_propagation_test()
: bld(NULL, 0)
{
ctx = ralloc_context(NULL);
compiler = rzalloc(ctx, struct brw_compiler);