processing / processing/processing4

Initial Pause When Not Clearing in P2D and P3D Renderers

Đang mở
#642 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

help wanted opengl
Ngôn ngữ chính
Java
Star
497
Fork
183
Merge trung bình
4 giờ 39 phút
Pull request đã merge (30 ngày)
3

Mô tả

Created by: JeremyEastham

Description

When rendering with either the P2D or P3D renderers, there is a noticeable pause on the first frame of the sketch if background is not called. Normally this pause is not very long, but this pause becomes more noticeable at higher resolutions and if multiple PGraphics objects are used as buffers.

Minimal Code to Reproduce

void setup()
{
  fullScreen( P2D );
}

void draw()
{
  fill( frameCount % 2 * 255 ); //Flash every odd frame
  rect( 0, 0, width, height );
  //A workaround would be to replace the above lines with background(...);
}

Testing Code

//Testing variables
boolean callBackground = false; //Toggle bug
boolean useBuffers = false;
int numBuffers = 2;

//Public variables
PGraphics[] buffers;
long startTime; //Time when setup returns

void setup()
{
  fullScreen( P2D ); //Also works with P3D
  background( 0 );
  noStroke();
  fill( 0 );
  if( useBuffers )
  {
    //Allocate buffers
    buffers = new PGraphics[numBuffers];
    for( int i = 0; i < numBuffers; i++ )
      buffers[i] = createGraphics( width, height, P2D );
  }
  //Record time before first frame
  startTime = millis();
}

void draw()
{
  if( frameCount == 1 ) //1st Frame
  {
    if( callBackground )
      background( 0 );
    else
      rect( 0, 0, width, height );
    if( useBuffers )
      for( PGraphics buffer : buffers )
      {
        buffer.beginDraw();
        if( callBackground )
          buffer.background( 0 );
        else
          buffer.rect( 0, 0, width, height );
        buffer.endDraw();
      }
  }
  
  if( frameCount == 2 ) //2nd Frame
  {
    long elapsed = millis() - startTime;
    fill( 255 );
    text( "2nd frame took " + elapsed + "ms", width / 2, height / 2 );
    println( elapsed + "ms" );
  }
}

With the testing code above, the amount of time to render the 2nd frame is ~40ms when callBackground is false and ~4000ms when callBackground is true (without buffers). Adding buffers increases the time by multiple seconds.

Your Environment

  • Processing version: 3.5.4 (have not tested with Processing 4)
  • Operating System and OS version: Windows 10.0.19043 Build 19043
  • Other information: Intel Core i5-10210U with Intel UHD Graphics 620

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các sketch tối thiểu và sketch kiểm thử được cung cấp, so sánh thời gian của frame đầu tiên đối với P2D và P3D khi có và không có background(), cũng như với các bộ đệm PGraphics. Truy vết quá trình khởi tạo renderer và việc xóa có liên quan đến frame đầu tiên; được xem là hoàn tất khi sketch kiểm thử không còn hiển thị khoảng tạm dừng vài giây đã được báo cáo khi không gọi background().

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
computer-graphics, performance
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.