Hi Nathan, I can't check right now, so this may not be the root cause, but I think you would still need to make sure your _opChannels are requested from the input.
In engine, you're handling the case where the requested channels and your op channels don't intersect, but you could still get a request that includes just a single channel of your _opChannels (but not all of them), in which case it would fail the "no intersection" test. Later on you're calling get() on input0 for all the channels in _opChannels, but not all of them might have been requested (depending on what other nodes downstream are requesting from your node). If that's the actual problem, I believe you'd just need to make sure that you add your _opChannels in _request: void _request(int x, int y, int r, int t, ChannelMask channels, intcount) { ChannelSet req_chans(channels); req_chans += _opChannels; input0().request(x, y, r, t, req_chans, count); } Or, if you want, you could add them all only if they intersect, since you're already handling the non-intersecting case later. Hope that helps. Cheers, Ivan On Mon, Oct 31, 2011 at 9:58 PM, Nathan Rusch <nathan_ru...@hotmail.com>wrote: > As a quick follow-up, the reason I’m being so cautious about trying to > get my code checked is that I recently found and reported a bug involving > engine lock-ups and channel warning messages almost perfectly in line with > what I’m seeing here, dating back to 6.0v7. I’d like to try and root out > any errors on my end before I write this off as Nuke’s fault, since I can > run Nuke -x renders in that same script simply by disabling my plugin node. > > Thanks everyone, > > -Nathan > > > *From:* Nathan Rusch <nathan_ru...@hotmail.com> > *Sent:* Monday, October 31, 2011 9:40 PM > *To:* Nuke plug-in development discussion<nuke-dev@support.thefoundry.co.uk> > *Subject:* Re: [Nuke-dev] Altering only a specific ChannelSet in engine > > Alright, I thought I was in the clear, but I’m still running into an > issue and I’d like to (once again) get some more experienced eyes on my > code to make sure I’m not doing anything too dumb. > > My plugin works fine now, except in some scripts. When I try to render > using Nuke -x, things start normally, but then die with: > > Warning: Reformat1: get(channels=0x7), but request(channels=0x1) > > If I use a Python wrapper script and call it using Nuke -t, I get the > ever-verbose "RuntimeError: Cancelled" following the channel warning > message. > > Here’s my updated code (trimmed as much as seemed reasonable): > ---------------------------- > class AverageChannels : public Iop > { > Lock _engineLock; > ChannelSet _opChannels; > bool _firstTime; > double _pixAggregate[3]; > float _avgPix[3]; > > //............ > > void knobs(Knob_Callback f) > { > InputOnly_ChannelSet_knob(f, &_opChannels, 0, "channels"); > Tooltip(f, "Which channels to average."); > } > > void _validate(bool for_real) > { > _firstTime = true; > copy_info(); > set_out_channels(_opChannels); > Iop::_validate(for_real); > } > > void _request(int x, int y, int r, int t, ChannelMask channels, int > count) > { > input0().request(x, y, r, t, channels, count); > } > > void engine(int y, int x, int r, ChannelMask channels, Row& out) > { > if (!intersect(_opChannels, channels)) > { > input0().get(y, x, r, channels, out); > return; > } > > ChannelSet unchanged(channels); > unchanged -= _opChannels; > input0().get(y, x, r, unchanged, out); > > if (_firstTime) > { > Guard g(_engineLock); > if (_firstTime) > { > // Reinitialize value containers > for (int i = 0; i < _opChannels.size(); i++) > { > _avgPix[i] = _pixAggregate[i] = 0.0f; > } > > // Input image dimensions and info > Format format = input0().format(); > const int fx = format.x(); > const int fy = format.y(); > const int fr = format.r(); > const int ft = format.t(); > const int height = ft - fy; > const int width = fr - fx; > const unsigned long int pixCount = width * height; > > for (int ry = fy; ry < ft; ry++) > { > // Set any progress bars > progressFraction(ry, ft - fy); > > Row row(fx, fr); > row.get(input0(), ry, fx, fr, _opChannels); > > if (aborted()) return; > > // Aggregate pixel values from _opChannels into > container array > int chan = 0; > foreach(z, _opChannels) > { > const float *CUR = row[z] + fx; > const float *END = row[z] + fr; > while (CUR < END) > { > _pixAggregate[chan] += (float)*CUR++; > } > chan++; > } > } > > // Calculate the average for each channel > for (int c = 0; c < _opChannels.size(); c++) > { > _avgPix[c] = _pixAggregate[c] / pixCount; > } > > _firstTime = false; > } > } // Lock out of scope > > if (aborted()) return; > > int outChan = 0; > foreach(z, _opChannels) > { > float *CUR = out.writable(z) + x; > const float *END = out[z] + r; > while (CUR < END) > { > *CUR++ = _avgPix[outChan]; > } > outChan++; > } > } > }; > > -Nathan > > > *From:* Steven Booth <sbo...@legend3d.com> > *Sent:* Monday, October 31, 2011 4:56 PM > *To:* Nuke plug-in development discussion<nuke-dev@support.thefoundry.co.uk> > *Subject:* RE: [Nuke-dev] Altering only a specific ChannelSet in engine > > > No worries, Nathan! It’s why the Forums are so invaluable.**** > > **** > > Steve**** > > **** > > *From:* nuke-dev-boun...@support.thefoundry.co.uk [mailto: > nuke-dev-boun...@support.thefoundry.co.uk] *On Behalf Of *Nathan Rusch > *Sent:* Monday, October 31, 2011 4:54 PM > *To:* Nuke plug-in development discussion > *Subject:* Re: [Nuke-dev] Altering only a specific ChannelSet in engine*** > * > > **** > > 10 minute rewrite and it’s all working perfectly. Thanks for your info > guys... huge informational leap.**** > > **** > > -Nathan > > ------------------------------ > _______________________________________________ > Nuke-dev mailing list > Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev > > > _______________________________________________ > Nuke-dev mailing list > Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev > >
_______________________________________________ Nuke-dev mailing list Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev