PGraphics beginDraw() performance

Hello,

My workplace uses a 3d application built on processing 4.2. I had no issues before, but trying to run it on my new laptop I got terrible performance, so I tried to have a look at the code and found that the beginDraw() command takes extremely long to execute.

For testing, I created this simple code, where I’m logging the execution of the beginDraw() command.

PGraphics pg;

boolean log = true;

void setup() {
  size(1366, 768, P3D);
  pg = createGraphics(4096, 4096, P3D);
}

void draw() {
  float start = millis();
  pg.beginDraw();
  if (log) println (millis() - start);
  log = false;
  pg.endDraw();
}

According to the results, the beginDraw() call takes ~13 seconds on average.
My PC is a brand new Asus Zenbook with a 12th gen intel i5 processor, 16 gbs of ddr5 ram, fast ssd and Intel Iris Xe integrated graphics, running Windows 11.

I’m aware that integrated graphics aren’t a perfect choice for processing, however this Iris Xe is supposed to be quite powerful, it’s meant for productivity tasks (I’m running GPU heavy apps like 3ds Max and After Effects without issues).

For reference, I also checked it on my wife’s ~7 years old Celeron PC, with 4 gb ram and integrated Intel HD graphics, and it was logging only 2.5 seconds execution time (which took 13 sconds on my laptop with 10 times the benchmark scores).

At this point I’m stuck, I’m not a programmer by any means, but I’d need to find a fix to run the app on my pc. Not sure if this could be a bug in Processing or maybe the GPU driver, or Windows 11, so if anyone has any helpful ideas, it would be highly appreciated. Also if there’s anyone around with similar PC specs or the same GPU it would be really helpful.
Note that I tried running it at my pc set to full performance, and I also tried the default renderer, which was all good, only P2D and P3D give me troubles - which are unfortunately a must.

Thank you!

Hello @Morzsamx,

I tested some PCs with this code:

PGraphics pg;

void setup() 
  {
  size(148, 100, P3D);
  pg = createGraphics(1*4096, 1*4096, P3D); //219ms
  //pg = createGraphics(2*4096, 2*4096, P3D); //828ms
  //pg = createGraphics(3*4096, 3*4096, P3D); //1765ms
  float start = millis();
  pg.beginDraw();
  println ("s1:", frameCount, millis() - start);
  pg.endDraw();
  start = millis();
  pg.beginDraw();
  println ("s2:", frameCount, millis() - start);
  pg.endDraw();
  }

void draw() 
  {
  float start = millis();
  pg.beginDraw();
  println ("d1:", frameCount, millis() - start);
  pg.endDraw();
  if(frameCount > 10) noLoop();
  }

Processing 4.2 on W10 laptop PC with NVIDIA card:

s1: 0 219.0
s2: 0 11.0
d1: 1 0.0
d1: 2 0.0
d1: 3 0.0
d1: 4 0.0
d1: 5 0.0
d1: 6 0.0
d1: 7 0.0
d1: 8 1.0
d1: 9 0.0
d1: 10 0.0
d1: 11 0.0

Processing 4.2 on W10 laptop at work with Intel(R) HD Graphics 630:

s1: 0 50844.0
s2: 0 16.0
d1: 1 0.0
d1: 2 0.0
d1: 3 0.0
d1: 4 0.0
d1: 5 0.0
d1: 6 1.0
d1: 7 0.0
d1: 8 0.0
d1: 9 0.0
d1: 10 0.0
d1: 11 0.0

:)

1 Like

Thank you so much for these, really appreciated!
I ran the same code you sent on my PC (Windows 11, Iris Xe):

s1: 0 15795.0
s2: 0 3.0
d1: 1 0.0
d1: 2 0.0
d1: 3 0.0
...

I think this is kind of aligned with the values you sent. What I still don’t understand is the results, again, from my wife’s PC (it’s actually a Pentium N3700 with Intel HD Graphics running Windows 10):

s1: 0 2264.0
s2: 0 206.0
d1: 1 0.0
d1: 2 0.0
d1: 3 0.0
...

I just don’t get how it’s able to do s1 in 2 seconds - I would expect similar values to your work PC with HD Graphics.

@Morzsamx,

How does it perform once you get over that initial hump?

:)

1 Like

Performance after this is great. Everything else besides beginDraw works flawlessly, I measured several functions, and found that all hangups are related to this.

The problem is, that the app has two submodules, both of them with their own UI and 3D viewport, and I need to switch back and forth between them very frequently. BeginDraw gets called each time on switch, and the hangups often take longer than the time I spend in the submodule. :frowning: