A thought

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

A thought

Post by MrGodin » December 15th, 2017, 1:52 am

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

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: A thought

Post by chili » December 15th, 2017, 4:30 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: A thought

Post by albinopapa » December 15th, 2017, 5:35 am

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

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: A thought

Post by chili » December 15th, 2017, 5:45 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: A thought

Post by albinopapa » December 15th, 2017, 10:07 am

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

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: A thought

Post by chili » December 15th, 2017, 11:44 am

I too think he was intending that, but by what mechanism do you propose that such an operation could be performed? :)
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: A thought

Post by albinopapa » December 15th, 2017, 6:56 pm

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

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: A thought

Post by MrGodin » December 16th, 2017, 2:57 am

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

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: A thought

Post by albinopapa » December 16th, 2017, 6:45 am

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: Select all

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

Post Reply