Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: A thought
 Post Posted: December 15th, 2017, 1:52 am 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 656
Location: Merville, British Columbia Canada
I was wondering about Chilis' framework and i had a thought, imagine that ! lol. anyways i thought about the putpixel calls and got to thinking, i do that now and again ;) , but ... what i was thinking is say you load a sprite and get its color values ect. Now ... hmmm can all that data in the sprite colors get moved into the pixel buffer all at once,... like a std::move and just move the memory of the sprite into the pixel buffer (or back buffer ect) .. is this at all possible. I have little knowledge of memcopy, std::move and all that. I understand there are strides ect to account for and all that .. anyways just a thought.
Peace Out

_________________
Curiosity killed the cat, satisfaction brought him back


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 4:30 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3537
Location: Japan
Nah, move semantics don't really work like that. More for resource transfer stuff, and this is clearly a data (value) copy scenario.

Good news, I've got a video coming (I20) that is going to go over move semantics, rvalue references, std::move, etc.

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 5:35 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2962
Location: Oklahoma, United States
The problem would become you'd only be able to move it once, after that the original data is permanently on the system/back buffer, unless you could somehow move it, render it, then move it back to the correct sprites. The next issue would be what would you do for overlapping sprites?, you'd lose that information to be able to move it back.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 5:45 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3537
Location: Japan
Nah, that's not even the problem. Move semantics just make no sense here at all is the real problem. It's not like each individual pixel is a separate heap object that can be transferred from one container to another, so there isn't any point to the whole endeavour in the first place.

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 10:07 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2962
Location: Oklahoma, United States
Guess I took it differently, I thought he was referring to being able to move the sprite to a specific point in the buffer using move semantics.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 11:44 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3537
Location: Japan
I too think he was intending that, but by what mechanism do you propose that such an operation could be performed? :)

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 15th, 2017, 6:56 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2962
Location: Oklahoma, United States
Wow, such proper grammer.

I don't see it possible, but that does not change the hypothetical nature of the proposed procedure. My response was based on the possibility of the hypothetical. There was what-if part of the post, and a I-don't-understand part. I placated the what-if part, your practical response covered the I-don't-understand portion, we got it covered.

I just woke up, my words could be meaningless right now.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 16th, 2017, 2:57 am 
 

Joined: November 30th, 2013, 7:40 pm
Posts: 656
Location: Merville, British Columbia Canada
I guess i've had this idea for a long time of having 2 pages of memory and slapping them together and have something like .. any data that has not changed or is not mutable emit some kind of measurable energy so one could omit data that doen't need to be altered. I was thinking a color spectrum to measure from perhaps .. haha .. just a stoners idea :P
Cheers

_________________
Curiosity killed the cat, satisfaction brought him back


Top 
 Profile  
Reply with quote  
 Post subject: Re: A thought
 Post Posted: December 16th, 2017, 6:45 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2962
Location: Oklahoma, United States
Well the closest thing I can think of would be:

Have a static background layer ( perhaps this layer doesn't change, sky image for instance ).
Have a mutable foreground layer that handles all the foreground drawing.
Have a mask layer that is updated when a pixel is changed.
Have a combine layer ( pSysBuffer )

Code:
for each pixel,
const Color bgColor = ( bgLayer[index] & (~maskLayer[index] );
const Color fgColor =  ( fgLayer[index] & maskLayer );
pSysBuffer[index] = bgColor | fgColor;

// This is the same as
if( mask[index] == 0xFFFFFFFF )
    pSysBuffer[index] = bgLayer[index];
else
    pSysBuffer[index] = fgLayer[index];

The difference is there is no branching, only bit manipulation. Unfortunately, there isn't a way of doing this all at once, but I suppose &~ | & is about as close as you are going to get.

This is usually how it's done with SIMD instructions, since there is no SIMD bool to speak of.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


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

Board index » Everything


 
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:
cron