Jump to content

CPUShader issue


photo

Recommended Posts

Hi,

We had a bug in our engine when using CPUShader and I believe this could have been avoided if Unigine would have give us an error or assert in place. To reproduce it, here is a small code snippet:

	TestShader shader;
	shader.runAsync(2);
	shader.runAsync(2);
	shader.wait();

TestShader is derived from CPUShader and can do anything in its process, preferably something very quick. So as you can see we've ran runAsync twice without waiting for threads to finish first, of course a mistake on our end, but the engine should have asserted or give an error in that case (maybe to console and ignore the second call).

So wait will run forever since at one point CPUShader::num_active_threads may become negative (too many deactivate threads calls). This may happen or not, depending if wait catches the counter on zero, which also makes it very hard to reproduce in some cases (like ours, where we had to run multiple instances of the application for a long time to reproduce it).

Of course the bug was much more evolved than this with lots of calls between the two runAsync and in the end very hard to find, probably impossible without access to Unigine source. Don't know exactly what your decision here should be (e.g. allow multiple runAsync and just add the number of threads? assert at second runAsync? assert when num_active_threads is negative?), but anything from the engine would help catch this kind of errors.

Kind Regards,
Adrian

Link to comment
×
×
  • Create New...