posts - 34,  comments - 14,  trackbacks - 0
 
QPF = QueryPerformanceFrequency(); 

QueryPerformanceCounter( &begin ); 

// Code that you are going to measure
  .... 

QueryPerformanceCounter( &end ); 
#ticks            =  begin - end 

clock cycles   = CPU speed  *  # ticks  /  QPF 

time elapsed   = # tick / QPF          //  time scale is SECOND. 

-------------------------------------------------------------------------------------------------------------------- 

// Be carefully following APIs, they will cause command buffer to be emptied. 

● When one of the lock methods (IDirect3DVertexBuffer9::Lock) is called on a vertex 
buffer, index buffer, or texture (under certain conditions with certain flags). 
● When a device or vertex buffer, index buffer, or texture is created. 
● When a device or vertex buffer, index buffer, or texture is destroyed by the last 
release. 
● When IDirect3DDevice9::ValidateDevice is called. 
● When IDirect3DDevice9::Present is called. 
● When the command buffer fills up. 
● When IDirect3DQuery9::GetData is called with D3DGETDATA_FLUSH. 

-------------------------------------------------------------------------------------------------------------------- 

Summary 
This paper demonstrates how to control the command buffer so that individual calls can 
be accurately profiled. The profiling numbers can be generated in ticks, cycles, or 
absolute time. They represent the amount of runtime and driver work associated with each 
API call. 
Start by profiling a Draw*Primitive call in a render sequence. Remember to: 

1. Use QueryPerformanceCounter to measure the number of ticks per API call. Use 
QueryPerformanceFrequency to convert the results to cycles or time if you like. 

2. Use the query mechanism to empty the command buffer before starting. 

3. Include the render sequence in a loop to minimize the impact of the mode 
transition. 

4. Use the query mechanism to measure when the GPU has completed its work. 

5. Watch out for runtime concatenation that will have a major impact on the amount 
of work done. 

This gives you a baseline performance for IDirect3DDevice9::DrawPrimitive that can be 
used to build from. To profile one state change, follow these additional tips: 

1. Add the state change to a known render sequence profile the new sequence. Since 
the testing is done in a loop, this requires setting the state twice into opposite 
values (like enable and disable for instance). 

2. Compare the difference in cycle times between the two sequences. 

3. For state changes that significantly change the pipeline (like 
IDirect3DDevice9::SetTexture), subtract the difference between the two sequences to get 
the time for state change. 

4. For state changes that significantly change the pipeline (and therefore require 
toggling states like IDirect3DDevice9::SetRenderState), subtract the difference between 
the render sequences and divide by 2. This will generate the average number of cycles 
for each state change. 



------------------------------------------------------------------------------------------------------------------------------------------------------
There are two important things to realize:

1) There is no single correct way to design or build an engine; if there was, we'd all be using that. 
The architecture needs to fit the requirements and serve your needs.

2) Figuring out those needs is much easier if you're actually building a game, and not just an engine. 
Building engines in isolation is folly unless one is already quite experienced (and even then it can be chore); 
by focusing on building games and refactoring the engine components out from underneath those games 
(they can be pretty simple), you end up with something much more robust that feels much better to use 
because its proven to be usable, as opposed to engines designed in isolation which often are not as 
usable as one would think.

Eberly's books are a good read.

posted @ 2007-10-04 10:04 Konami wiki 阅读(141) | 评论 (0)编辑 收藏

"Always design a thing by considering it in its next larger context — a chair in a room, a room in a house, a house
in an environment, an environment in a city plan."

—Eliel Saarinen, "Time," July 2, 1956


"As a director, I wouldn't like me as an actor. As an actor, I wouldn't like me as a director."

—Robert Redford

posted @ 2006-10-29 16:42 Konami wiki 阅读(156) | 评论 (0)编辑 收藏
     哈哈!花了几个小时的时间学习decal算法,嗯!不错,有收获!
这个算法虽然简单但我个人认为相当重要,可以解决一些很棘手的
问题!
     下面我来介绍一下我所用的方法:


      method 1:
      
                        这个方法是我最推荐的一种方法,因为最简单!尤其
               在Direct3D下最明显。在平时常用的Projection matrix API里
               修改一下near和far的值,给他们都加一个Z bias!
                         For example:
             
                         D3DXMatrixPerspectiveFovLH( &out, FOV, aspect,  near + zbias, far + zbias );


      method 2:
      
                        这个方法是由我的同事自己推算出来的,根据projection transformation的过程,因
              为点在投影到projection plane后的坐标是normalized, i.e  [0.0, 1.0]( assume you are using d3d ),
              而projection matrix里影响z值主要是33和43两个元素,根据这个公式把你要使用的zbias加入
              并建立方程:
                        //  projected z = z * 33 + 43
                        // 把near和far加上zbias带入求出新的zmin 和zmax(也就是[0.0, 1.0])
                        zmin = ( near + zbias ) * 33 + 43 ;
                        zmax = ( far + zbias ) * 33 + 43 ;

               原理和method1相似。



                      
posted @ 2006-10-16 09:25 Konami wiki 阅读(359) | 评论 (1)编辑 收藏
http://www.ocremix.org/games/ 吐血推荐!
posted @ 2006-10-13 10:15 Konami wiki 阅读(88) | 评论 (0)编辑 收藏

  唉!为了生活啊!太忙了!呵呵!!!
  最近看一本书,发现一个不错的算法叫作:Decal算法(我自己翻译叫作:贴花算法)。
Decal实际上我们经常在游戏里看到的,例如:脚印、弹孔(例如CS里,用枪射击到枪)等。
  该算法是修改Projection matrix, 但我还是有些糊涂。我自己思考了一下以后,我觉得
使用zbuffer里的z-bias渲染状态也可以做到。


posted @ 2006-10-06 15:15 Konami wiki 阅读(602) | 评论 (1)编辑 收藏
1:
There are no standard or generic game architectures. The architecture for every game is different and it depends on the game, the platform, and the people designing and implementing the software.

2:
我们没当过神!我们不专业啊!

posted @ 2006-08-31 15:54 Konami wiki 阅读(99) | 评论 (0)编辑 收藏
  what a thrill
  with darkness and silence through the night
  what a thrill
  I'm searching and I'll melt into you
  what a fear in my heart
  but you're so supreme

  I give my life
  not for honor,but for you (snake eater)
  in my time there'll be no one else
  crime,it's the way I fly to you (snake eater)
  I'm still in a dream of the snake eater

  someday you go through the rain
  someday you feed on a tree frog
  it's ordeal,the trail to survive
  for the day we see new light

  I give my life
  not for honor,but for you , snake eater ...
  in my time there'll be no one else
  crime,it's the way I fly to you (snake eater)
  I'm still in a dream of the snake eater
  I'm still in a dream of the snake eater  ....

posted @ 2006-08-28 17:51 Konami wiki 阅读(813) | 评论 (0)编辑 收藏
  最近忙着张罗工作的事情,所以一直没有更新BLOG!
  世事多变啊,转眼间我在UIS混了了半年了……。回头想想UIS对员工还是不错的,
福利待遇方面都不错,能为员工想到都想到了,至少从我个人来说目前是呆得最满意
公司(也许其他员工不同意,但只是我个人的感受而已)。
  至于离开UIS是因为对手机游戏的前景堪忧,而且起开发环境机器混乱,各有各的
标准(很像以前PC下的DOS下的硬件环境)。结果果然不出所料,现在手游市场急剧萎
缩……
  当然最近也没闲着,在研究Ray Triangle Intersection的时候发现一个叫
barycentric coordinates(字典翻译:重心坐标),该坐标系统可以表示出多边形里
的任意点坐标,例如三角形: ( u, v, w )。
  累了,继续工作吧~~~!希望我能找到如意的地方(但要坚持初衷)……
posted @ 2006-08-07 12:25 Konami wiki 阅读(122) | 评论 (0)编辑 收藏

在研究一些3D引擎的时候,常常看到一个术语:Scene Graph, 从字面上看了半天没看出个究竟,
看了看相关内部代码,同样糊涂……于是到国外的几个游戏编程论坛查了查,呵呵……收获不好啊!
    下面是我收集的一些资料关键:

  1) What is a Scene Graph?
   Abstractly put, a Scene Graph is an organized hierarchy of nodes in a data structure with special relationships that
  simplify a problem. Put more concretely for our project: A Scene Graph is an m-ary tree, a tree with any node possessing
    any number of children, in which any particular node will inherit and amalgamate the transformations and render states,
    or other such states of the parent.


    2) Inheritance and Polymorphism (OOP) 。// 呵呵,C++
      As the complexities of game programming increase, it is immediately important in the beginning of a project's lifetime
    to start organizing your core engine. The more time that is spent understanding the purpose of your project, defining the
    features and limitations, and planning the long-term scale, the faster projects will fall together in a well-polished final
    product. Object-oriented programming can greatly help in this organization.

      The real powers in OOP lie in two key areas: Inheritance and Polymorphism. Inheritance allows for an object to extend the
    functionality of a base class, if necessary. Polymorphism allows you to call derived class methods which have been marked as
    virtual through a base class pointer.

      These two concepts are used heavily in the scene management framework that will be described later in this article. For
    further information on Object-Oriented Programming check out Bjarne Stroustrup's book (Stroustrup97).


    3) Object Ownership
      Determining ownership of objects is an important part of constructing a game engine for two reasons. First and most
    important, objects are used and reused all over the lifetime of the game. It is important to know when it is safe to
    change or delete an object. Second, to avoid memory leaks, objects must be deleted. Since a game will deal with many        

    objects, it is wise to design a good solution to deal with object lifetime so that object management does not get out
    of control.

      A good resolution is to allow parent objects to take ownership of their directly descendent child objects. This method
    allows the ability to divide the responsibility of objects being deleted. Later we will be adding child objects similar to
    this:

    void LoadModel(char* pFile, char* pName)
    {
      FFObject* pObj = new FFMeshObject(pFile, pName);
      m_pSceneRoot->AttachChild(pObj);
    }

      Here, pObj is a dynamically allocated object that is handed to the scene root, and m_pSceneRoot takes full
    responsibility of pObj. Whenever m_pSceneRoot determines that it no longer needs pObj, it must free the resources.

 


  好了,文盲的我“憋”到这里也实在不知道怎么“憋”不下去了…… It's time to rest!

posted @ 2006-07-25 11:34 Konami wiki 阅读(583) | 评论 (0)编辑 收藏

  花了1000左右的RMB买了台PS2,呵呵……感觉不错啊非常值得啊(为什么到现在才买?
因为我是穷人嘛,没办法…………想到某杂志上写的一台为了体验中国第一台NDS,7000多
RMB还只呼便宜的,我是望尘莫及啊!),玩了玩游戏店老板推荐的游戏和自己一直想玩的
游戏,的确感觉很爽啊!

    1) PS2的操作完美地解决了3D空间来的移动控制问题,用L3控制的任意移动。

    2) PS2的机能确实不错啊(当然别拿来跟即将出台的PS3和现在的XBOX360比)了,呵呵
   
    3) PS2上的游戏都蛮好玩的,例如《汪达与巨像》《Metal Gear3》 etc.


  当然,在堕落之余我也顺利地完成了我的MDX与引擎的结合,哈哈!!!!现在使用WC3
的模型了!接着开始做点Application来考验考验我的引擎试试,呵呵。。。。。虽然是个非
非简单的引擎,但这个引擎见证了我学3D的过程!目前看来是有很多不完善的地方…………
  XXX:NULI FENGDOU !!!!!!!

posted @ 2006-07-17 10:05 Konami wiki 阅读(91) | 评论 (0)编辑 收藏
仅列出标题
共4页: 1 2 3 4