@@ -32,20 +32,20 @@ namespace {
32
32
// / PIMPL state for the transform.
33
33
struct State {
34
34
// / The IR module.
35
- Module* ir = nullptr ;
35
+ Module& ir;
36
36
37
37
// / The IR builder.
38
- Builder b{* ir};
38
+ Builder b{ir};
39
39
40
40
// / The type manager.
41
- core::type::Manager& ty{ir-> Types ()};
41
+ core::type::Manager& ty{ir. Types ()};
42
42
43
43
// / Process the module.
44
44
void Process () {
45
45
// Find module-scope variables that need to be replaced.
46
- if (ir-> root_block ) {
46
+ if (ir. root_block ) {
47
47
Vector<Instruction*, 4 > to_remove;
48
- for (auto inst : *ir-> root_block ) {
48
+ for (auto inst : *ir. root_block ) {
49
49
auto * var = inst->As <Var>();
50
50
if (!var) {
51
51
continue ;
@@ -67,7 +67,7 @@ struct State {
67
67
}
68
68
69
69
// Find function parameters that need to be replaced.
70
- for (auto * func : ir-> functions ) {
70
+ for (auto * func : ir. functions ) {
71
71
for (uint32_t index = 0 ; index < func->Params ().Length (); index++) {
72
72
auto * param = func->Params ()[index];
73
73
auto * storage_texture = param->Type ()->As <core::type::StorageTexture>();
@@ -90,8 +90,8 @@ struct State {
90
90
auto bp = old_var->BindingPoint ();
91
91
new_var->SetBindingPoint (bp->group , bp->binding );
92
92
new_var->InsertBefore (old_var);
93
- if (auto name = ir-> NameOf (old_var)) {
94
- ir-> SetName (new_var, name.NameView ());
93
+ if (auto name = ir. NameOf (old_var)) {
94
+ ir. SetName (new_var, name.NameView ());
95
95
}
96
96
97
97
// Replace all uses of the old variable with the new one.
@@ -111,8 +111,8 @@ struct State {
111
111
auto * rgba8 = ty.Get <core::type::StorageTexture>(
112
112
bgra8->dim (), core::TexelFormat::kRgba8Unorm , bgra8->access (), bgra8->type ());
113
113
auto * new_param = b.FunctionParam (rgba8);
114
- if (auto name = ir-> NameOf (old_param)) {
115
- ir-> SetName (new_param, name.NameView ());
114
+ if (auto name = ir. NameOf (old_param)) {
115
+ ir. SetName (new_param, name.NameView ());
116
116
}
117
117
118
118
Vector<FunctionParam*, 4 > new_params = func->Params ();
@@ -170,8 +170,8 @@ struct State {
170
170
171
171
} // namespace
172
172
173
- Result<SuccessType> Bgra8UnormPolyfill (Module* ir) {
174
- auto result = ValidateAndDumpIfNeeded (* ir, " Bgra8UnormPolyfill transform" );
173
+ Result<SuccessType> Bgra8UnormPolyfill (Module& ir) {
174
+ auto result = ValidateAndDumpIfNeeded (ir, " Bgra8UnormPolyfill transform" );
175
175
if (!result) {
176
176
return result;
177
177
}
0 commit comments