OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Clearing framebuffer - loops randomly stop
PostPosted: Fri Feb 25, 2022 10:15 am 
Offline

Joined: Wed May 27, 2020 8:27 am
Posts: 8
Hello! I made a simple function to clear the framebuffer. The problem is that it stops randomly. I tried it in both virtualbox and qemu. What is causing that?
Code:
void renderer_clear(framebuffer_t* fb) {
   
    uint32_t color = 0xff0000ff;
   
    for(size_t y = 0; y < fb->height; y++) {
       
        uint32_t* pix_ptr = fb->base + fb->pps * y;
       
        for(size_t x = 0; x < fb->width; x++) {
           
            *pix_ptr = color;
            pix_ptr++;
           
        }
       
    }
   
}

Screenshots of virtualbox are attached. Thanks in advance!


Attachments:
screenshot2.png
screenshot2.png [ 13.19 KiB | Viewed 2962 times ]
screenshot1.png
screenshot1.png [ 13.47 KiB | Viewed 2962 times ]
Top
 Profile  
 
 Post subject: Re: Clearing framebuffer - loops randomly stop
PostPosted: Fri Feb 25, 2022 11:28 am 
Offline

Joined: Wed May 27, 2020 8:27 am
Posts: 8
Fixed it! I had to change "uint32_t* pix_ptr = fb->base + fb->pps * y;" to "uint32_t* pix_ptr = fb->base + fb->pps * y * 4;"


Top
 Profile  
 
 Post subject: Re: Clearing framebuffer - loops randomly stop
PostPosted: Thu Sep 22, 2022 3:39 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
You can also simply do a memset with 32 bits as value.
For faster performance (I guess this is mature for you now but however I'll write this so you remember it on the future) : Enable Write Combining, Perform an SIMD Memset (SSE (128 BITS)/AVX (256 BITS)/ AVX-512 (512 BITS). If supported,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group