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 
● When IDirect3DDevice9::ValidateDevice is called. 
● When IDirect3DDevice9::Present is called. 
● When the command buffer fills up. 
● When IDirect3DQuery9::GetData is called with D3DGETDATA_FLUSH. 


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 

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 阅读(81) | 评论 (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 阅读(97) | 评论 (0)编辑 收藏

      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 ;


posted @ 2006-10-16 09:25 Konami wiki 阅读(269) | 评论 (1)编辑 收藏 吐血推荐!
posted @ 2006-10-13 10:15 Konami wiki 阅读(46) | 评论 (0)编辑 收藏

  该算法是修改Projection matrix, 但我还是有些糊涂。我自己思考了一下以后,我觉得

posted @ 2006-10-06 15:15 Konami wiki 阅读(438) | 评论 (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.


posted @ 2006-08-31 15:54 Konami wiki 阅读(61) | 评论 (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 阅读(729) | 评论 (0)编辑 收藏
  当然最近也没闲着,在研究Ray Triangle Intersection的时候发现一个叫
barycentric coordinates(字典翻译:重心坐标),该坐标系统可以表示出多边形里
的任意点坐标,例如三角形: ( u, v, w )。
posted @ 2006-08-07 12:25 Konami wiki 阅读(86) | 评论 (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

    void LoadModel(char* pFile, char* pName)
      FFObject* pObj = new FFMeshObject(pFile, pName);

      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 阅读(303) | 评论 (0)编辑 收藏


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

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


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