Global Game Jam 2014 体会

参加了Global Game Jam DePaul Site 2014

这是我第二次参加GGJ了,

在去年GGJ上认识了DG,然后被几个老外坑了,最后什么也没做出来,算是被虐了吧!

今年再次和DG一起去,磨练了一年后,我们也算是有备而去。

2天非常辛苦,最后大家都在电脑前睡着了,不过最后我们也拿到了我们应得的那份:

Audience Choice Award!

也算是最有价值的奖项了,因为是全部人一起投票,并且需要最多选票的奖项,送组员每人一份3个月的Adobe Photoshop,外加有机会去参加PopCon什么的几个游戏动漫展,摆摊摆到米国了哇哈哈。

体会嘛,我只能说,这个世界没有什么做不到的事情,关键是看你付出了多少。

这几年来,虽然我也不算是特别认真的人,但是几乎一直专注在做游戏,各种东西都有涉猎,也算是全身心的投入到了这个领域了。我相信,一个人只要有强烈的愿望,是没什么事情做不到的。要说付出嘛,其实也很多,半年几乎都没有去参加过任何社交活动。不过我这个人也就是这样,和那些没有共同语言的人交流,感觉会很难形成价值的交谈,更多是互相敷衍问好,会让我很痛苦。

下面说说游戏

今年GGJ的主题是:
We don’t see things as they are, we see them as we are.

我很小的时候,看到家里堆放的一些杂乱的东西,会想到这是个坦克,这是个大灰狼等等。

虽然现在我已经没有这种神奇的能力了,但是真的很想再现那种感觉,以一个孩子的眼光去看待一个生硬的世界。

于是我们做了一个游戏,场景是一个办公室,里面都是很生硬的元素,但是各种生硬的东西在特定的角度或者光影下,会变成很多有趣的场景。

GGJ的时间很有限,所以做的挺粗糙的,不过2天内这个完成度,我们还是很满意了。

如果有更多的时间继续这个游戏,我希望把游戏做的非常轻松,有很多很多非常简单的关卡,主要目的就是让玩家感受到“发现生活中的美”这一点。

用鼠标左键拖动镜头,右键拖动光影,点Check确定来检测是否找到(这个地方希望今后再改改)

一共有5个关卡,不过最后一个关卡并没有检测功能。

另外感谢一下在GGJ期间关心我帮助我鼓励我的朋友,最后第五关隐藏的话语便送给你们的。

GGJ官网游戏地址(下面有EXE下载):

http://globalgamejam.org/2014/games/perspective-2

网页版地址(需要UnityPlayer):

http://www.myacg.cc/WebGames/Perspective/Perspective.html

ggj2014

 

关于程序。。。

这种感觉,已经很久很久都没有存在过了,

于是我不得不说。

。。。

极端的理性思维确实能够让人沉醉,

封闭自己的灵魂其实也不是什么坏事,

能让人看清自己,并且冷静下来。

。。。

程序是简单而又复杂的,

可以复杂到让人根本无法阅读,

也可以简单的能够以一种没有情感的状态去编写,

遍历,判断,返回,

编译,修正,再编译

。。。

一段时间后,

我没有失去目标却失去了方向,

我不明白是为了什么,

我只知道要如何做。

。。。

程序员是否需要信奉上帝,

我原本以为我不信,

但是我又不得不钦佩他。

不可思议的机缘巧合,

这个世界上不可能的事情,

总以你万万没想到的方式,

突然出现。

。。。

我会去抓住,

就算是失败,

就和写任何程序一样,

即使是隐式表达,也是需要有定义的,

最无厘头的程序崩溃,也是能够找到原因的。

只怕你甚至都没有尝试,

在这一点上,

我绝不会向命运低头。

。。。

待续

数个近况

发现自己快4个月没更新blog了。。。

不知道从何说起,干脆timeline+图片

 

1. 尝试使用unity,东方打地鼠项目竣工,www.MyACG.cc 成立。

dds

游戏网页版及下载版:

http://www.myacg.cc/forum.php?mod=forumdisplay&fid=42

 

2.正经同人游戏项目,东方打僵尸项目开启,图为游戏地形,请不要在意我的厨技

WP_20131110_16_47_34_Pro

3.期末C++优化课程和分布式软件开发课程final搞的我差点心脏病,最后功德圆满,

游戏粒子系统优化小比赛,全班第二名??!(第一名的有bug!!!别以为我不知道!!!)

111

4. 期末压力莫名的大,直接导致我寒假完全不想填坑,于是打了一寒假dota2,刷到了4100+分(top 1%及格线),勉强能被家猫看得起,我太菜了。

PS:还遇到几个玩dota2的妹子,各种被carry,简直叼,为何我这么菜。 顺便我的开黑分充分体现了柚子同学的水平。

dota

5.美国遭遇严寒,芝加哥各种凶残大雪,车被埋,被困家中一周,库存全部吃完,差点饿死

快看这流线型,我升级兰博基尼了(误)

 

WP_20140109_13_22_22_Pro

6.又开学,计划回坑,Dota2暂少玩,有点想搞搞饰品制作顺便练习下建模。

本学期参加game studio课程,目测分组被分到6坑爹老外,貌似只有一个越南哥比较靠谱,我们小组没artist,我又要兼职2D 3D artist了。

 

7.和DG备战Global Game Jam,磨练了一年准备去虐人了!

 

8.久违的自爆,三个月没理发,电脑前,今日,照片x1,回坑纪念

HJ-CORSAIR - WIN_20140114_054008

IGDA TGS Scholar Essay

参加TGS后写给IGDA Japan的短文,反正也大概明说了我们在TGS干了啥。这次东京之行真的很美好!

然后回美国后就一直忙,之前的同人坑的计划有比较大的调整,然后作业啥的一直在补,赶得很累,TGS的东西很多都还没有整理,当时拿了很多公司的名片,也没空答复什么的。
还有之前室友搬了,家里很乱,整理了好几天,深感时间完全不够用。

英语略渣见谅 = =。

IGDA TGS Scholar Essay – Han/Jin 韩珒 DePaul University

First, I would like to thank IGDA Japan that gave me such a good opportunity to visit Japan. I’m a Chinese and I study in USA. This is the first time I visit Japan, and this trip gave me such a wonderful experience that I will never forget. It’s absolutely AWESOME!

During the trip, we visited several game studios, attended Tokyo Game Show, and had party with other game developers. I really learnt a lot from all of these nice event.

One of the best part is that we are able to visit 3 game studio in Tokyo, CRI middleware, Land Ho! and Cygames. We had chance to communicate with these companies directly. They showed us their products, shared the experience of managing the company, and allowed us to see their studio equipment and under-developing games. These three company range from middleware provider to game publisher, so the trip gave us an overall understanding of game industry. Before this trip, I had no idea how actual game industry was, but now I felt better.

CRI is a middleware company, a lot of games including many famous games are using their technology. They show the demo of their product, and their developers explained some details to us. I was not familiar with the products they made, but I’m still impressed by the Alpha movie technology which can play a movie with the alpha channel. I think this technology would be very useful especially on mobile devices.

The manager from Land Ho! told us a lot about developer and publisher and some problems and stories of their company, which we may meet in the future. Land Hoo! has multiple game titles, some are big projects, some are small, and their company is starting from doing something very small. We also visit their studio, we saw a game they were developing, using UDK. Because my own project are also plan to use UDK, I actually got a lot of information by observing what their stuff were doing. (And I decide not to use UDK for my own project after the trip, because we don’t have so many people, even we had spent a month on it)

Cygames has a really really awesome environment for the employees. They have a very nice office with awesome view, they also offer the artist best devices. That’s amazing! I saw illustrators painting some awesome pictures. Oh! I really want to work in that environment.

On TGS, we were able to attend the meeting. On the first day, we heard about the story of the creator of Puzzle and Dragons, his story is quite informative. The managers from several big companies discussed the trend of the game industry. They all mentioned that Chinese main land may be the most important market in the future. As I am a Chinese and my family has an investment company in Shanghai, it’s a really good news for me.

On the second day, we attended Sense of Wonder Night, a festival for indie developer. It gave me a lot of new ideas. I was impressed by the game “Museum of Simulation Technology”, that game is really awesome. We got a change to talk with all the winner after that. Three of them can speak Chinese! I asked a lot of details about their game, and their future plans. I also noticed that over half of the indie game on TGS are using Unity3D as game engine.

After that we went to have dinner with many indie game maker, I’m glad that I met many people from Taiwan. We can communicate with Chinese. I tied their games and we soon become friends. They also shared many information about indie game with me. That was quite a nice night.

I am a big fan of Touhou project, and I made Touhou Douji Games. On the third day of TGS, the creator of the Touhou project ZUN announced his new release of Touhou game on indie game corner, I was manage to see him in real person, but I don’t know what he was talking about and it was too crowded there, so I was a little sad at that time.

But here is what the IGDA scholarship is really awesome for! On the last day, we went to Sony Entertainment Indie Stream Party. On the SCE party, I met Mr.ZUN face to face! He was right there! I got the chance to talk with him! I took a photo with him, and show him some of my work on Touhou Douji Game, I never thought that I could get the chance to do so! This gave my trip to Tokyo Game Show an unforgettable ending.

I also visited several famous places in Tokyo during the time I was in Tokyo. Tokyo gave me such a very nice impression. People here are so nice. The whole city is so clean even it is very crowded. I love animation, manga and games. You can find them everywhere in Japan. I think Japanese treat these “New-Type” arts much seriously than any other country. I really like the environment for game industry here. Tokyo is one of the best cities I ever been. I must spend at least 1~2 years staying here in the future. I’m planning now, really!

At last, I really want thank IGDA Japan again for offering me such a nice chance. I really miss the wonderful time in Tokyo. Thank Mr.Ono, Mr.Masahito and all other friends! I won’t forget this trip in my life!

Han/Jin 韩珒 DePaul University

SONY DSC

DSC_0231

【东方同人游戏】永动之轮 人员招募

东方project 3D同人游戏 <东方永动之轮>(暂定名)开坑决定! 现招募各路大神!

小朋友们大家好,屏幕前的各位最近正在忙什么呢。

或许正忙于学业祈求毕业后能找到一份好工作?或许没日没夜的打着DOTA?或许过着上班下班枯燥的生活?或许纠结在感情问题之中无法自拔?

是啊,也许某天,就忘记了最初的梦想,忘记了那童年的时候想过无数次的事,忘记了她或他,甚至忘记了自己是谁。。。

永恒的爱与忧伤,不知道还有没有那样的中二,不想屈服于这一切的。

是的,想要做游戏,从很久以前就想,这是一个梦想。

在某个阳光明媚的下午,下定了这样的决心,从此会失去很多,但也会收获很多。

而那个阳光明媚的下午却会永远留在心中。

然后无论面对多少的困难,都会坦然面对。

考虑到游戏制作可行性等多种因素,东方Project 3D 同人游戏<东方永动之轮>(暂定名)决定开坑!现招募各路大神,希望我们能够一起实现梦想,做出一款能够收到普遍主流游戏价值观认可的优秀同人游戏。

这个过程,不仅仅是一个挑战,更是一次旅行,一个新的起点。

开始在那个阳光明媚的午后。

 

招募 游程序 和 游戏美工

如果你有技术且有兴趣参与我们的制作组,共同编织梦想,请填写以下问卷,作为申请加入制作组。

我们会认真查看每一份申请,如果您的能力符合要求,我们会主动联系你。

如果我们没联系你,非常抱歉无法一一进行回复。

我们特别需要(比较缺):

美工:

   3D场景设计师:将3维模型放入引擎并且搭建场景,或者按照已有2D设计搭建3D场景。

   人物3D模型:能按照2D设计建模,面数要求游戏可以使用。

   人物3D动画:能够使用Maya或3DsMax创建流畅且不生硬的动画。

   粒子特效师:创建类似刀光,爆炸,施法等特效。

程序:

   精通3D技术和游戏引擎技术的

   有使用游戏引擎,特别是先进3D游戏引擎的经验的

   有正规游戏公司工作经验的

 

游戏美工申请表格:

https://docs.google.com/forms/d/1LpcwhCvc9KHAJ40_PJqBd1anUZXB8Rj8Fj-OWIGVIOQ/viewform

 

游戏程序申请表格:

https://docs.google.com/forms/d/1d5fSWgNVHjvGaSbNKLyPp_vY1YQb2jLh32HycJ_ZW8Q/viewform

游戏介绍

名称:

东方 永动之轮 (暂定)

游戏类型:

东方Project 3D 自动镜头 射击类游戏

游戏模式类似死亡之屋,VR战警之类

鼠标控制,支持单机双人游戏,或联机双人游戏。

多级别难度。

灵力槽(装弹)符卡(弹药种类)系统. (暂定)

游戏简介:

灵梦某日醒来,发现赛钱箱变成了自动贩卖机,幻想乡的各处也发生了奇怪的现象,各种平常的物体无故变成了精巧的机械,于是灵梦再次展开解决异变的冒险。。。(其他暂不公开)

新人物x1:

轻中国元素(毕竟是中国同人)

使得物体机械化的能力(其他暂不公开)

美术风格:

东方+蒸汽机械风格 (美术风格参考:天空之城,爱丽丝疯狂回归,东方红魔城,生化奇兵:无限)

人物风格5头身体,miku音乐会类似风格基础上更哥特或写实,各人物服饰配色及细节进行原创。

游戏程序,引擎:

或许使用UDK或其他提供免费选项的引擎(未定)

规模及开发时限:

一年内完成程序主框架,游戏流程3关(总6关+EX)。

DEMO争取参加明年IGF。

美术风格:

东方+蒸汽机械风格 (美术风格参考:天空之城,爱丽丝疯狂回归,东方红魔城,生化奇兵:无限)

人物风格5头身体,miku音乐会类似风格基础上更哥特或写实,各人物服饰配色及细节进行原创。

场景游戏画面DEMO:

(策划随便画的,目前还没正式画师)

Mechanical Shrine Demo

人设风格设计DEMO:

(策划随便画的,目前还没正式人设)

Mechanical Reimu

游戏DEMO:

(程序用XNA花5小时写的,很瞎)

招募 游程序 和 游戏美工

如果你有技术且有兴趣参与我们的制作组,共同编织梦想,请填写以下问卷,作为申请加入制作组。

我们会认真查看每一份申请,如果您的能力符合要求,我们会主动联系你。

如果我们没联系你,非常抱歉无法一一进行回复。

我们特别需要(比较缺):

美工:

   3D场景设计师:将3维模型放入引擎并且搭建场景,或者按照已有2D设计搭建3D场景。

   人物3D模型:能按照2D设计建模,面数要求游戏可以使用。

   人物3D动画:能够使用Maya或3DsMax创建流畅且不生硬的动画。

   粒子特效师:创建类似刀光,爆炸,施法等特效。

程序:

   精通3D技术和游戏引擎技术的

   有使用游戏引擎,特别是先进3D游戏引擎的经验的

   有正规游戏公司工作经验的

游戏美工申请表格:

https://docs.google.com/forms/d/1LpcwhCvc9KHAJ40_PJqBd1anUZXB8Rj8Fj-OWIGVIOQ/viewform

游戏程序申请表格:

https://docs.google.com/forms/d/1d5fSWgNVHjvGaSbNKLyPp_vY1YQb2jLh32HycJ_ZW8Q/viewform

 

感谢各位支持!

HJISTC(主策划)

2013年06月24日

HJ同学@提不起劲

连续打了好几天游戏(dota)逃避现实作业都没做,

本学期学习填坑状态严重下滑,还欠下了很多的坑。

总结下目前的一堆坑:

1.学校作业,拖了n天没做,后天due了还没动。

2.阅读教科书,书从来没有来得及读过。

3.弄好学生会的论坛投入使用,www.depaulcssa.com,没时间。

4.帮别人填Unreal Development Kit的场景,想搞却没力气。

5.完成 SC2 沙漠风暴vHJ DesertStrike vHJ,一个人填坑太寂寞啊。

6.帮CSSA设计logo,一直坑…

7.Where is my girl friend???耗费时间啊…

8.写学习博客,去学校论坛和同学“学术讨论”(算成绩的),懒得看。

9.得换驾照去,洗车去,交xx费,改xx地址,干xx事。。。懒。

10.其他,懒得想也懒得写了。

浑身没劲没动力啊,难道是传说中的五月病么

 

不行啊,先写作业吧,不过写完又怎么样呢?写完就能打游戏了?!那还不如现在就打游戏吧!

不行啊,天天打游戏什么的一定会死?真的会死吗?天天写作业不会死吗?

为啥要学习啊?学习能救我吗?为啥那些从不学习的小哈比天天都活的那么快乐啊。

而且打游戏有啥意思啊,打了几百年也是这样子了,浪费时间啊!寂寞啊!

我没时间!我没时间!我没时间啊!!!

我要学习!?什么?我要玩!?什么?没意思!?

WTF??打出了GG。

我还是先从补作业做起吧@#¥%……&*(

 

求救命。

This is a life all about dreams!

Be Your Hero

曾有一个梦想
如今
却已遗忘
闭上眼
才发现
迷失的恐慌
若有一个地方
能将夜空划亮
渐渐地
我也能
孤单终成坚强

时间冲破水面
永不停歇
散落成幻想
若是模糊视线
回首从前
思绪彷徨
希望穿越蓝天
扩散蔓延
勇敢的翱翔
痛苦为何会
烟消云散
再一次起航

若是伸出双手
是否
就能拥有
黑暗中
也不能
掩藏住伤口
总以为一直走
就能到达出口
倔强中
不回头
always be my hero

祈愿就在终点
一往无前
指引我方向
未来在我指间
握紧明天
终将造访
从来不曾想象
爱和欲望
同一个摸样
坠落中看清
彼岸的花
又一次绽放

一步
一步
接近着终点
一点
一点
甩开了从前
时间总是无时无刻夺走了一切
却不能
阻止
明天(嗷——)

Memory System

Memory System

Preface

I have spent a lot of time on this. I know nothing about this kind of stuff before. Also, I’m not that familiar with the C++ programming pattern. For PA2, the teacher’s code include a “singleton pattern” which confuse me a lot at the beginning. After I read the book and look for the website, I learnt that this is a very common design pattern, which help creating a global single object, I think I should take some time to learn something about that.

I have no idea how to deal with everything at the beginning, but some of my class mates finish their homework very fast, which makes me under pressure. I check my classmate Weixing An’s code, and under how the whole system working. I write my code referenced his code at first, and finally finished non-fixed block part for this assignment.

Two weeks later, after the midterm, I finally got some time to re-work on this Memory System. I read the book Memory Allocation Chapter of “Game Engine Architecture”, which helps me understand why we need to do this and how to adjust alignment. This time, I delete all my previous code, and write it from blank. I finally finished the normal and fixed block, which, I think, should follow the design better than others students. This assignment helps me a lot on the understanding of memory stuff.

Why we need memory system for game engine

malloc & new is slow

It’s a general-purpose facility, need to handle a lots of management.

In most operate system, call malloc and free must context-switch from user mode into kernel mode.

Count the usage of the memory

We need to count the current usage memory, allocation times, and peak memory usage for debugging and improving performance.

Deal with memory fragmentation

We can improve the problem of fragmentation, like design the memory as a stack or pool.

Memory System Design

Untitled-1

Tracking Block class

Store the information for each block. Include 4 pointer for two double links.

Heap class

Store the information for each heap. Include 2 pointer for Heap links.

HeapInfo

The structure in the Heap class storing the heap block information.

Mem class

Store the whole memory system information.

Store the head pointers point to Heap list head and Tracking Block list head.

MemInfo

The structure in the Mem class storing the memory system information.

Overload new & delete

To use our memory system, it means, we create our object into the memory where the tracking block is, and use tracking block to manage them.

So we need to overload original new and delete to offer these function.

Out new function should return the pointer that points to the raw memory in the tracking block.

Alignment

Data should be stored in alignment. The return pointer of the new operator should be aligned.

To adjust the data to be aligned, we should put an extra padding in each block’s tracking block.

And, when delete, we need a return pointer to get the Tracking block. We can store it in the 4 bytes just upon the raw memory.

head

Implement

Singleton Pattern

Only one Mem object is created in the whole system. We use a singleton pattern to design it.

Code Example

// create a singleton
class Mem
{
private:
   // Prevent default constructor, copy constructor, assignment operator from being called externally
      Mem(){};
      Mem( const Mem &in ){};
      Mem &operator = (const Mem &in){};
      ~Mem(){};

   // Magical internal function (singleton Keeper)
      static Mem	*privGetInstance( void );
};

// Magical internal function (singleton Keeper)
Mem* Mem::privGetInstance( void )
{
   static Mem mSingleton;
   return &mSingleton;
}

Windows Heap API

Get the memory from system memory.

HeapCreate

Creates a private heap object, return a win handle

HeapAlloc

Allocates a block of memory from a heap. The allocated memory is not movable.

new(pointer)object

“new” an object at the pointer’s memory location. Help us put the Heap head object in to the heap’s real memory location.

New & delete

There are two way to new and delete the system.

Normal Block

Call new

Get the needed size of allocation

Allocate the size + tracking block + padding

Put the tracking block into the memory

Link the linked list

Fixed Block

Allocate all heap when we create the heap

We should decide how large per block is before new

Create all the tracking block in the heap

Link all free block

When new, get the first node in the free memory linked list, unlink the node.

Return the aligned address.

When delete, relink the block in to the free list.

Linked list

Heap linked list

List links all heaps.

Heap tracking block linked list

Inside heap tracking block list.

Global tracking block linked list

A global linked list to track every allocation.

Notice:

When we destroy a Heap, we need to first remove all the tracking block, so the global list will not mess.

Need to rework

Here are something that I haven’t deal well when I do the assignment.

Need to rework when I have time.

All two kind of heap has a fixed size, how the deal with the issue, if I allocate more memory than it could offer.

The alignment might cost too many memories, need to make it better.

 

Jin Han

February 22, 2013

Dynamic Memory Allocation Summary

Dynamic Memory Allocation Summary

Preface

This is the hard part of the engine, it took me a little bit longer to understand the detail, and make me about 1 week behind the class.

In the assignment PA2, it’s important to understand this. Here are my reading notes for Game Engine Architecture Page 205 – 215.

Why we need to do this?

C++ malloc(), free(), new, delete operator is slow, because they have to meet any different situation and need to context-switch from user mode to kernel mode.

Solution

Implement custom dynamic allocation for games. Pre-allocate the memory at the beginning of the game.

A rule in game development:

Keep heap allocations to a minimum, and never allocate from the heap within a tight loop.

Memory Allocator Implementation

Several ways to implement the custom memory allocators

Stack-Based Allocators

Allocate a large contiguous block by malloc(), new, or declaring a global array of bytes.

A pointer to top of the stack is maintained.

Add/Delete from top, memory cannot be freed in an arbitrary order.

Double-Ended Stack Allocators

A single memory can contain two stack allocators.

One from top, one from down.

More efficient.

Pool Allocators

Perfect for the allocation of lots of small blocks of memory which are the same size.

Pre-allocate a large block of memory.

Pre-allocation size should be exact multiple of the size of the elements that will be allocated.

Each element in within the pool is added to a linked list of free elements.

Whenever an allocation request is made, simply grab the next free element off the free list and return it.

When an element is freed, track back it onto the free list.

Single linked list pointer can stored in the free block.

Aligned Allocators

Every data and variable has an alignment requirement.

All memory allocator must be capable of returning aligned memory blocks.

Implement

Allocate a little bit more memory than was actually requested.

Adjust the address of the memory block upward slightly so that it is aligned properly.

Mostly, additional bytes allocated is equal to the alignment.

Determine the adjustment bytes. (By using a mask calculation)

Add adjustment bytes to the original address.

Need to store original address in the byte immediately preceding the adjusted address for free().

Adjustment will never be more than 256 so only 1 bytes will be used.

Return the adjusted address.

Alignment Graph

ss

Code Example

// Aligned allocation function. IMPORTANT: 'alignment'
// must be a power of 2 (typically 4 or 16
void* allocateAligned(U32 size_bytes, U32 alignment)
{
   // Clients must call allocateUnaligned() and
   // freeUnaligned() if alignment == 1.
   ASSERT(alignment &gt; 1);

   // Determine total amount of memory to allocate.
   U32 expandedSize_bytes = size_bytes + alignment;

   // Allocate an unaligned block &amp; convert address to a
   // U32
   U32 rawAddress
      = (U32)allocateUnaligned(expandedSize_bytes);

   // Calculate the adjustment by masking off the lower
   // bits of the address, to determine how "misaligned"
   // it is.
   U32 mask = (alignment - 1);
   U32 misalignment = (rawAddress &amp; mask);
   U32 adjustment = alignment - misalignment;

   // calculate the adjusted address, and return as a
   // pointer.
   U32 alignedAddress = rawAddress + adjustment;

   // Store the adjustment in the four bytes immediately
   // preceding the adjusted address that we're
   // returning.

   U32* pAdjustment = (U32*)(alignedAddress - 4);
   *pAdjustment = adjustment;
   // adjustment will never be more than 256
   // so only 1 bytes will be used

   return (void*)alignedAddress;
}

// corresponding freeAligned()
void freeAligned(void* p)
{
   U32 alignedAddress = (U32)p;
   U8* pAdjustment = (U8*)(alignedAddress - 4);
   U32 adjustment = (U32)*pAdjustment;

   U32 rawAddress = alignedAddress - adjustment;

   freeUnaligned((void*)rawAddress);
}

 

Single-Frame and Double-Buffered Memory Allocators

For temporary data storage for games.

Single-Frame Allocators

A block of memory can be allocated and used the only in the current frame. Clear every frame.

Benefits

Allocated memory needn’t ever be freed

Negative

Requires a reasonable level of discipline on the part of the programmer.

Only valid on current frame.

Never cache a pointer to a single-frame memory block across the frame boundary.

Double-Buffered Allocators

A block of memory can be allocated on frame i to be used on frame (i+1);

Useful for caching the results of asynchronous processing on a multicore game console.

 

Jin Han

February 18, 2013