`
isiqi
  • 浏览: 16493821 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论
阅读更多
http://blog.csdn.net/weili_2007/archive/2007/12/03/1914170.aspx

document.body.oncopy = function() { if (window.clipboardData) { setTimeout(function() { var text = clipboardData.getData("text"); if (text && text.length > 300) { text = text + "\r\n\n本文来自CSDN博客,转载请标明出处:" + location.href; clipboardData.setData("text", text); } }, 100); } }

这一章讲述了Direct3D的设备对象,它提供了渲染流水线的一个抽象层。流水线的操作是通过设备的属性方法配置的。渲染在设备上的图片是要么2D拷贝操作,要么通过三维场景渲染。

设备的属性和方法控制了整个图形流水线,属性一般是通过Get和Set方法管理。每个设备都有一组它自己的capabilities。设备也是 resource对象的容器,Direct3D通过IDirect3DResource9接口管理资源。图形流水线的很多行为都是通过Render state控制的。应用程序可能需要频繁的设置render states,但是使用state block来保存一组设备属性(包括render state),使应用程序的设置更加方便和容易。

IDirect3DDevice9

IDrect3DDevice9控制流水线的行为,它包含大量的属性和方法。下面我们将探讨它的每个属性和方法。device 对象代表了渲染流水线。我们也可以从流水线里取到图片,提供流水线场景数据,然后将场景渲染到图片上。我们能够把流水线分成几个大的section:顶点 数据Assembly,顶点处理,primitive Assembly以光栅化,像素处理,frame buffer和Video scan out。IDirect3DDevice9的接口如下:

Read-Only Properties
GetAvailableTextureMem 可用的纹理内存,单位是KB
GetBackBuffer back buffer image surface 接口
GetCreationParameters 设备的创建参数
GetDirect3D creating IDirect3D9接口
GetDisplayMode 视频显示模式
GetFrontBufferData front buffer 的拷贝
GetNumberOfSwapChains Number of swap chain
GetRasterStatus Raster display status
GetRenderTargetData surface data in a render target
GetSwapChain swap chain on the device
Write-only Properties
SetCursorPosition cursor position
SetCursorProperties cursor image and hot spot
SetDialogBoxMode GDI compatability flag
Properties
GetClipPlane user-defined clipping plane
SetClipPlane
GetClipStatus clip status of rendered primitives
SetClipStatus
GetCurrentTexturePalette current texture palette index
SetCurrentTexturePalette
GetDepthStencilSurface Depth surface 接口
SetDepthStencilSurface
GetFVF Flexible vertex format
SetFVF
GetGammaRamp Gamma correction lookup table
SetGammaRamp
GetIndices current index buffer
SetIndices
GetLight light definition
SetLight
GetLightEnable light enabled flag
LightEnable
GetMaterial Primitive material properties
SetMaterial
GetNPatchMode N-Patch tessellation mode
SetNPatchMode
GetPaletteEntries Texture palette entries
SetPaletteEntries
GetPixelShader pixel shader program handle
SetPixelShader
GetPixelShaderConstantB Boolean constant registers
SetPixelShaderConstantB
GetPixelShaderConstantF floating-pont constant registers
SetPixelShaderConstantF
GetPixelShaderConstantI integer constant registers
SetPixelShaderConstantI
GerRenderState Pipeline control values
SetRenderState
GetRenderTarget Target surface for rendered pixels
SetRenderTarget
GetSamplerState Texture sampler control values
SetSamplerState
GetScissorRect Scissor test rectangle
SetScissorRect
GetSoftwareVertexProcessing Vertex processing control
SetSoftwareVertexProcessing
GetStreamSource source vertex data buffers
SetStreamSource
GetStreamSourceFreq stream source sampling frequency
SetStreamSourceFreq
GetTexture Texture resources used by each stage
SetTexture
GetTextureStageState Texture stage control values
SetTextureStageState
GetTransform tranformation matrix
SetTransform
GetVertexDeclaration Vertex component declaration
SetVertexDeclaration
GetVertexShader vertex shader program handle
SetVertexShader
GetVertexShaderConstantB boolean constant registers
SetVertexShaderConstantB
GetVertexShaderConstantF floating-point constant registers
SetVertexShaderConstantF
GetVertexShaderConstantI Integer constant registers
SetVertexShaderConstantI
GetViewport Rendering viewport extent
SetViewport
Methods
BeginScene Make the start of a scene
BeginStateBlock Make device state for capture
Clear Clear the current viewport on the device
ColorFill Fills a rectangular area with a color
CreateAdditionalSwapChain Create an additional swap chain on a windowed device
CreateCubeTexture Create a cube map texture sources
CreateDepthStencilSurface Create a depth/stencil surface resource
CreateIndexBuffer Create an index buffer resource
CreateOffScreenPlainSurface Create an off-screen surface resource
CreatePixelShader Create a pixel shader
CreateQuery Create a device query
CreateRenderTarget Create a render target resource
CreateStateBlock Create a state block
CreateTexture Create a texture resource
CreateVertexBuffer Create a vertex buffer resource
CreateVertexDeclaration Create a vertex declaration
CreateVertexShader Create a vertex shader
CreateVolumeTexture Create a volume texture resource
DeletePatch Destroy a cached patch tesselation
DrawIndexedPrimitive Draw indexed primitives from the current streams.
DrawIndexedPrimitiveUP Draw indexed primitives from user data.
DrawPrimitiveUP Draw primitives from usr data.
DrawRectData Rectangular higher order surface patch
DrawTriPatch Triangular higher order surface patch.
EndScene Make the end of a scene
EndStateBlock Capture device state changes
EvictManagedResources Flush managed resources from the device
MultiplyTransform Post-multiply onto a device transformation matrix
Present Presents a rendered image for display
ProcessVertices Process vertices in software
Reset Resets the device's display characteristcs
ShowCursor Displays or hides the cursor
StretchRect Device memory blit with stretching
TestCooperativeLevel Checks exclusive ownership of the device
UpdateSurface system to device memory surfaces
UpdateTexture system to device memory texture transfer.
ValidateDevice Validate current device state.

Device methods by pipeline section

Vertex Assembly
BeginScene
CreateIndexBuffer
CreateVertexBuffer
DeletePatch
DrawIndexedPrimitive
DrawIndexedPrimitiveUP
DrawPrimitive
DrawPrimitiveUP
DrawRectPatch
DrawTriPatch
EndScene
SetIndices
SetNPatchMode
SetRenderState
SetStreamSource
SetStreamSourceFreq
SetVertexDeclaration
Vertex Processing CreateVertexDeclaration
CreateVertexShader
LightEnable
MultiplyTransform
ProcessVertices
SetClipPlane
SetClipStatus
SetFVF
SetLight
SetMaterial
SetRenderState
SetSoftwareVertexProcessing
SetTransform
SetVertexShader
SetVertexShaderConstantB
SetVertexShaderConstantF
SetVertexShaderConstantI
SetViewPort
Primitive Rasterization SetRenderState
Pixel Processing CreatePixelShader
MultiplyTransform
SetCurrentTexturePalette
SetPaletteEntries
SetPixelShader
SetPixelShaderConstantB
SetPixelShaderConstantF
SetPixelShaderConstantI
SetRenderState
SetSamplerState
SetTexture
SetTextureStageState
SetTransform
Frame Buffer Clear
ColorFill
CreateAdditionalSwapChain
CreateCubeTexture
CreateDepthStencilSurface
CreateOffscreenPlainSurface
CreateRenderTarget
CreateTexture
CreateVolumeTexture
EvictManagedResources
GetAvailableTextureMem
GetBackBuffer
GetFrontBufferData
GetNumberOfSwapChains
GetRenderTargetData
GetSwapChain
Reset
SetDepthStencilSurface
SetDialogBoxMode
SetRenderState
SetRenderTarget
SettScissorRect
SetViewPort
StretchRect
UpdateSurface
UpdateTexture
Video Scan out GetDisplayMode
GetRasterStatus
Present
SetCursorPosition
SetCursorProperties
SetGammaRamp
ShowCursor

Capabilities

一旦创建了设备,某些capabilities允许轻微的变化。 在某个设备上调用GetDeviceCaps可以返回一个真实设备对象的capabilities,但是如果在Direct3D对象上调用 GetDeviceCaps则返回设备通用的一些capabilities。

HRESULT GetDeviceCaps(D3DCAPS9 * value);

typedef struct _D3DCAPS9

{

D3DDEVTYPE DeviceType;

UINT AdapterOrdinal;

DWORD Caps;

DWORD Caps2;

DWORD Caps3;

DWORD PresentationIntervals;

DWORD CursorCaps;

DWORD DevCaps;

DWORD PrimitiveMiscCaps;

DWORD RasterCaps;

DWORD ZCmpCaps;

DWORD SrcBlendCaps;

DWORD DestBlendCaps;

DWORD AlphaCmpCaps;

DWORD ShadeCaps;

DWORD TextureCaps;

DWORD TextureFilterCaps;

DWORD CubeTextureFilterCaps;

DWORD VolumeTextureFilterCaps;

DWORD TextureAddressCaps;

DWORD VolumeTextureAddressCaps;

DWORD LineCaps;

DWORD MaxTextureWidth;

DWORD MaxTextureHeight;

DWORD MaxVolumeExtent;

DWORD MaxTextureRepeat;

DWORD MaxTextureAspectRatio;

DWORD MaxAnisotropy;

float MaxVertexW;

float GuardBandLeft;

float GuardBandTop;

float GuardBandRight;

float GuardBandBottom;

float ExtentAdjust;

DWORD StencilCaps;

DWORD FVFCaps;

DWORD TextureOpCaps;

DWORD MaxTextureBlendStages;

DWORD MaxSimultaneousTextures;

DWORD VertexProcessingCaps;

DWORD MaxActiveLights;

DWORD MaxUserClipPlanes;

DWORD MaxVertexBlendMatrices;

DWORD MaxVertexBlendMatrixIndex;

float MaxPointSize;

DWORD MaxPrimitiveCount;

DWORD MaxVertexIndex;

DWORD MaxStreams;

DWORD MaxStreamStride;

DWORD VertexShaderVersion;

DWORD MaxVertexShaderConst;

DWORD PixelShaderVersion;

float PixelShader1XMaxValue;

DWORD DevCaps2;

float MaxNpatchTessellationLevel;

DWORD Reserved5;

UINT MasterAdapterOrdinal;

UINT AdapterOrdinalInGroup;

UINT NumberOfAdaptersInGroup;

UINT DeclTypes;

DWORD NumSimultaneousRTs;

DWORD StretchRectFilterCaps;

D3DVSHADERCAPS2_0 VS20Caps;

D3DPSSHADERCAPS2_0 PS20Caps;

DWORD VertexTextureFilterCaps;

DWORD MaxVShaderInstructionsExecuted;

DWORD MaxPShaderInstructionsExecuted;

DWORD MaxVertexShader30InstructionSlots;

DWORD MaxPixelShader30InstructionsSlots;

}

Device Capabilities By pipleline section

Vertex Assembly Dev Caps:
Draw Prim TL Vertex
Quintic RT Patches
RT Patches
RT Patch Handle Zero
TL Vertex System Memory
TL Vertex Video Memory
Dev Caps 2:
Adaptive Tess N Patch
Adaptive Tess RT Patch
D Map N Patch
Stream Offset
Vertex Elements Can share Stream offset
Decl Types
FVF Caps
Max Primitive Count
Max Streams
Max Stream Stride
Max Vertex Index
Max N Patch Tessellation Level
Vertex Processing Dev Caps:
HW Transform And Light
Pure Device
Max Active Lights
Max User Clip Planes
Max Vertex Blend Matrices
Max Vertex Blend Matrices Index
Max Vertex Shader 30 Instruction Slots
Max Vertex Shader Const
Max V Shader Instruction Executed
Primitive Misc Caps:
Clip Plane Scaled Points
Clip TL Verts
Fog Vertex Clamped
Raster Caps
Fog Range
Fog Vertex
Vertex Processing Caps
Vertex Shader Version
Vertex Texture Filter Caps
VS 20 Caps
Primitive Processing Max User Clip Planes
Primitive Misc Caps:
Clip Plane Scaled Points
Clip TL Verts
Cull CW
Cull CCW
Cull None
Primitive Rasterization Dev Caps:
HW Rasterization
Pure Hardware
Extents Adjust
Guard Band Left
Guard Band Top
Guard Band Right
Guard Band Bottom
Line Caps:
Antialias
Texture
Max Point Size
Max Vertex W
Raster Caps:
Color Perspective
Shade Caps
Texture Caps:
Projected
Pixel Processing Caps 2:
Can Auto Gen Mipmap
Cube Texture Filter Caps
Dev Caps:
Separate Texture Memories
Texture Non Local Vid Mem
Texture System Memory
Texture Video Memory
Max Anisotropy
Max Pixel Shader 30 Instruction Slots
Max P Shader Instructions Executed
Max Simultaneous Textures
Max Texture Aspect Ratio
Max Texture Blend Stages
Max Texture Height
Max Texture Repeat
Max Texture Width
Max Volume Extent
Pixel Shader Version
Pixel Shader 1* max Value
Primitive Misc Caps:
Per Stage Constant
TSS Arg Temp
PS 20 Caps
Raster Caps
Anisotropy
Mipmap LOD Bias
Frame Buffer Alpha Cmp Caps
Caps 3:
Alpha FullScreen Flip or Discard
Copy To System Mem
Copy To Vid Mem
Dest Blend Caps
Line Caps:
Alpha Cmp
Blend
Fog
Z Test
Num Simultaneous RTS
Primitive Misc Caps
Blend Op
Color Write Enable
Independent Write Masks
Mask Z
MRT Independent Bit Depths
MRT Post Pixel Shader Blending
Separate Alpha Blend
Vide Scan out Adapter Ordinal In Group
Caps:
Read Scan line
Caps 2
Can Calibrate Gamma
Full Screen Gamma
Caps 3
Linear To sRGB Presentation
Cursor Caps
Dev Caps
Can Render after Flip
Master Adapter Ordinal
Number of Adapters in Group
Presentation Intervals

Resources

设备与资源对象协同工作来执行场景渲染。 资源对象通常是场景数据的容器。两维和三维的纹理分别使用surface和volume来存放他们的内容。 back buffer,depth/stencil buffer 和设备的render target属性也是使用surfaces来存放数据。

纹理接口的继承层次图

   基类接口包括IDirect3DVolume9和IDirect3DResource9。Volume对象并不是继承 IDirect3DResource9的,所以它并不参与资源管理。剩下的资源都是继承于IDirect3DResource9。另外所有的 Texture对象都是继承于IDirect3DBaseTexture9。

IDirect3DResource9

   IDirect3DResource9是所有资源对象的基本接口,它给可管理的资源提供了资源内存管理功能。它只能管理创建在 D3DPOOL_MANAGED池里面的资源。Managed的资源都有一个整数优先级,数字越大优先级越高。优先级越低的资源就可能先被 discarded。 Non-Managed 资源优先级总是0。在同样的优先级,Direct3D总是优先discard那些最近使用最少的资源。在渲染的时候如果应用程序使用的资源内存超过了显卡 的资源,Direct3D将使用最近使用最多的策略来释放资源。应用程序也可以显示的调用资源管理器来释放资源,EvictManageResource 可以完成这个操作。释放的设备内存不必是连续的,分配一个对象可能会由于设备内存不足而失败,即使资源管理器已经释放了足够的空间。

创建在D3DPOOL_DEFAULT的资源不能进行管理,并且不能被资源管理器释放。应用程序只能手工的分配,拷贝和释放default pool里面的内存。

当纹理加载到设备里面是,你可以先使用GetAvailableTextureMem来查询可用纹理内存空间的估计值,然后根据值来调节纹理的detail。这个是值只是一个粗略的估计值不是一个准确的值。

interface IDirect3DResource9 : IUnknown

{

//read -only properties

HRESULT GetDevice(IDirect3DDevic9 ** value);

D3DRESOURCETYPE GetType();

//read /write properties

DWORD GetPriority();

DWORD SetPriority();

HRESULT GetPrivateData(REFGUID data_guid, void* value, DWORD * size);

HRESULT SetPrivateData(REFGUID data_guid, const void * value, DWORD size, DWORD flags);

//methods

HRESULT FreePrivateData(RFEGUID data_guid);

void PreLoad();

}

GetDevice 方法返回拥有这个资源的设备。资源不能跨设备共享。资源类型可以通过GetType获取。根据这个类型我们就可以知道这个资源IID,然后使用 QueryInterface就可以得到具体的资源接口。GetPrivateDat和SetPrivateData可以将任意的数据快绑定到任何 Direct3D资源上。

Miscellaneous Properties

有几个设备属性与图形流水线没有直接的联系。 GetCreationParameters方法使用D3DDEVICE_CREATION_PARAMETERS结构体返回设备创建的参数。

HRESULT GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS * value);

HRESULT GetDirect3D(IDirect3D** value);

typedef struct _D3DDEVICE_CREATION_PARAMETERS

{

UINT AdapterOrdinal;

D3DDEVTYPE DeviceType;

HWND hFocusWindow;

DWORD BehaviorFlags;
}D3DDEVICE_CREATION_PARAMETERS;

创建设备的IDirect3D实例可以通过GetDirect3D获取。

设备查询

设备查询就是从设备的驱动层获取信息。主要用途是渲染统计和设备的时间通知。只要设备查询对象和设备对象存在,你就可以向设备查询最新的信息。可以通过CreateQuery创建查询对象,D3DQUERYTPE是查询信息的类别。

typedef enum _D3DQUERYTYPE

{

D3DQUERYTYPE_BANDWIDTHTIMINGS = 17,

D3DQUERYTYPE_CACHEUTILIZATION = 18,

D3DQUERYTYPE_EVENT = 8,

D3DQUERYTYPE_INTERFACETIMINGS = 14,

D3DQUERYTYPE_OCCLUSION = 9,

D3DQUERYTYPE_PIPELINETIMINGS = 13,

D3DQUERYTYPE_PIXELTIMINGS = 16,

D3DQUERYTYPE_RESOURCEMANAGER = 5,

D3DQUERYTYPE_TIMESTAMP = 10,

D3DQUERYTYPE_TIMESTAMPFDISJOINT = 11,

D3DQUERYTYPE_TIMESTAMPFREQ = 12,

D3DQUERYTYPE_VCACHE = 4,

D3DQUERYTYPE_VERTEXSTATS = 6,

D3DQUERYTYPE_VERTEXTIMING = 15

} D3DQUERYTYPE;

HRESULT CreateQuery(D3DQUREYTYPE kind, IDirect3DQuery9 ** result);

interface IDirect3DQuery9 : IUnknown

{

//read-only properties

HRESULT GetDevice(IDirect3DDevice9 ** value);

D3DQUERYTYPE GetType();

HRESULT GetData(void * data, DWORD size,DWORD flags);

DWORD GetDataSize();

//methods

HRESULT ISSUE(DWORD flags);

}

一 个查询对象通常有三种状态:signaled, building, 或者issued。Issue 方法用于将一个状态转换标记为有信号。当设备驱动返回了查询信息时,它也可以改变一个查询对象的状态。查询信息将通过渲染命令流发送给设备。Issue的 flags参数将用于标识查询的开始和结束。

#define D3DISSUE_END (1<<0)

#define D3DISSUE_BEGIN (1<<1)

在 查询开始和结束之间,查询对象可以汇报被发布的primitive的情况。顶点cache,资源管理统计和事件查询都有一个隐式的开始,应用程序 issue查询对象结束。隐式查询开始如下表。统计查询自从present调用后收集的数据,然而时间和顶点cache查询返回自设备创建后的数据。对于 occlusion, disjoint timestamp和timing 查询,应用程序只能显示的指定查询开始和结束。

Query Type Beginning
Vertex Cache CreateDevice
Resource Manager Statistics Present
Vertex Statistics Present
Event CreateDevice

为了取得查询的结果,GetDataSize和GetData方法可以获得查询信息的拷贝。每种查询结果都对应一个数据结构。如下表,

Query Type Data Type
Bandwidth Timings D3DDEVINFO_D3D9BANDWIDTHTIMINGS
Cache Utilization D3DDEVINFO_D3D9CACHEUTILIZATION
Event BOOL
Interface Timings D3DDEVINFO_D3D9INTERFACETIMINGS
Occlusion DWORD
Pipeline Timings D3DDEVINFO_D3D9INTERFACETIMINGS
Pixel Shader Timings D3DDEVINFO_D3D9STAGETIMINGS
Resource Manager Statistics D3DDEVINFO_RESOURCEMANAGER
Timestamp UINT64
Timestamp Disjoint BOOL
Timestamp Frequency UINT64
Vertex Cache D3DDEVINFO_CACHE
Vertex Shader Timings D3DDEVINFO_D3D9STAGETIMING
Vertex Statistics D3DDEVINFO_D3DVERTEXSTATS

GetData的flags参数可以让你同步刷新设备的命令队列。

事件查询可以用来当命令流里的某个特定点被驱动处理的时候通知应用程序,Occlusion查询返回传递到depth测试的像素数目。如果值为0,标识这组primitive全部被obscured。应用程序使用这个信息来cull occlueded物体。

顶点统计和资源管理查询只在debug时支持,retail runtime不支持这两个查询。

  • 资源管理统计查询

资源管理统计查询返回一个D3DDEVINFO_RESOURCEMANAGER结构体,它包含了一个D3DRESOURCESTATS结构体数组,每个资源类型对应一个D3DRESOURCESTATS。D3DRTYPECOUNT定义了资源类型数目。

#define D3DRTYPECOUNT (D3DRTYPE_INDEXBUFFER + 1)

typedef struct _D3DDEVINFO_RESOURCEMANAGER

{

D3DRESOURCESTATS stats[D3DRTYPECOUNT];

} D3DDEVINFO_RESOURCEMANAGER;

D3DRESOURCESTAS不仅包括自从上次调用Present后的统计数据外,还包含自从设备Reset后保存的统计数据。每个资源的统计数据暗示 着D3DPOOL_MANAGED池里的资源的performance。 其他池里面的资源不在这个这个统计数组里面。

typedef struct _D3DRESOURCESTATS

{

// Data collected since last Present()

BOOL bThrashing;

DWORD ApproxBytesDownloaded;

DWORD NumEvicts;

DWORD NumVidCreates;

DWORD LastPri;

DWORD NumUsed;

DWORD NumUsedVidMem;

// Persistent data

DWORD Workingset;

DWORD WorkingSetBytes;

DWORD TotalManaged;

DWORD TotalBytes;

} D3DRESOURCESTATS;

Persistent数据设备内存working set和一些汇总数据。Working set成员是video内存资源对象的数目。WorkingSetBytes是working set的大小。TotalManaged 成员是可管理资源对象的数目,TotalBytes是他们总的大小。

bThrashing成员设置是否资源管理器thrashing。当资源管理器不断的把资源流化到video内存,thrashing 就发生了。例如,假定场景里面有很多物体,每个都使用纹理集合中的一个纹理。如果物体按照纹理排序顺序绘制,极有可能是必需的纹理将会装载到设备内存里 面。如果物体绘制的顺序不根据纹理顺序,资源管理器将会花很多时间在working set的不同纹理之间来回thrashing。

ApproxBytesDownloaded ,NumEvicts和NumVidCreates成员描述了自从上次调用Present后资源管理器的资源消耗行为。LastPri给出了上一次从设备 内存里面回收的资源对象的优先级。NumUsed和NumUsedInVidMem分别表示已经设置到设备的资源对象的数目和已经present到设备内 存上资源对象的数目。

  • 顶点统计查询

设备也能统计自上次调用Present以来的顶点处理,如三角形的数目以及clipping后增加的三角形数目。

typedef struct _D3DDEVINFO_D3DVERTEXSTATS

{

DWORD NumRenderedTriangles;

DWORD NumberExtraClippingTriangles;

}D3DDEVINFO_D3DVERTEXSTATS;

  • 顶点cache查询

顶点cache查询返回设备上顶点cache的大小等信息。顶点cache是一块临近GPU的内存cache,它避免访问一些最近使用的顶点内存。这个查询返回的是D3DDEVINFO_VCACHE结构体。

typdef struct _D3DDEVINFO_VCACHE

{

DWORD Pattern //必须是四字符代码CACH

DWORD OptMethod; //当它的值是0的时候,应用程序必须使用尽可能长的三角形步长来最大化顶点cache。 如果值是1表示应用程序将使用CacheSize大小的顶点Cache来优化。

DWORD CacheSize;

DWORD MagicNumber;// 当OptMethod 是的时候,它决定了重启三角形步长的时间。
} D3DDEVINFO_VCACHE, *LPD3DDEVINFO_VCACHE;

  • PIX 相关查询

PIX是DirectX应用程序的性能测量工具。余下的查询类型返回性能测量的数据。一个驱动可能不支持所有查询。如果值是0,它将忽略测量的结果。cache利用查询,返回texel和顶点cache的命中率。

typedef struct _D3DDEVINFO_D3D9CACHEUTILIZATION

{

float TextureCacheHitRate;

float PostTransformVertexCacheHitRate;

}D3DDEVINFO_D3D9CACHEUTILIZATION;

所有的时间查询返回都是流水线各个部分的查询时间消耗情况。这个测量反应查询开始和结束之间的百分比。

typedef struct _D3DDEVINFO_D3D9BANDWIDTHTIMINGS

{

float MaxBandwidthUtilized;

float FrontEndUploadMemoryUtilizedPercent;

float VertexRateUtilizedPercent;

float TriangleSetupRateUtilizedPercent;

float FillRateUtilizedPercent;

}D3DDEVINFO_D3D9BANDWIDTHTIMINGS;

typedef struct _D3DDEVINFO_D3D9INTERFACETIMINGS

{

float WaitingForGPUToUseApplicationResourceTimePercent;

float WaitingForGPUToAcceptMoreCommandsTimePercent;

float WaitingForGPUToStayWithinLatencyTimePercent;

float WaitingForGPUExclusiveResourceTimePercent;

float WaitingForGPUOtherTimePercent;

} D3DDEVINFO_D3D9INTERFACETIMINGS;

typedef struct _D3DDEVINFO_D3D9PIPELINETIMINGS

{

float VertexProcessingTimePercent;

float PixelProcessingTimePercent;

float OtherGPUProcessingTimePercent;

float GPUIdleTimePercent;

} D3DDEVINFO_D3D9PIPELINETIMINGS;

顶点shader timing和pixel shader timing查询都返回了D3DDEVINFO_D3D9STAGETIMINGS结构体里面的信息。

typdef struct _D3DDEVINFO_D3D9STAGETIMINGS

{

float MemoryProcessingPercent;

float ComputationProcessingPercent;
}D3DDEVINFO_D3D9STAGETIMINGS;

设备状态

设备对象的属性控制渲染流水线的行为,它的方法给流水线供应数据。设备的渲染,采样器,纹理阶段的状态属性控制了很多流水线行为,总结如下表:

Vertex Assembly RS Patch Edge Style RS Adaptive Tess X, Y,Z,W
RS Position Degree RS Enable Adaptive Tessellation
RS Normal Degree RS Max Tessellation Level
RS Color Vertex RS Min Tessellation Level
RS Point Size SS D Map offset
Vertex Processing RS Tween Factor RS Clipping
RS Vertex Blend RS Indexed Vertex Blend Enable
TSS Tex Coord Index RS Ambient Material Source
RS FOG Vertex Mode RS Diffuse Material Source
RS Range Fog Enable RS Specular Material Source
RS Ambient RS Emissive Material Source
RS Local Viewer RS Lighting
RS Specular Enable RS Normailze Normals
RS Shade Mode TSS Texture Transform Flags
RS Cull Mode RS Clip Plane Enable
Pixel Processing SS Border Color
RS Fill Mode SS Mag Filter
RS Last Pixel SS Min Filter
SS Mip Filter
RS Specular Enable SS Mip Map LOD Bias
RS Texture Factor SS Max Mip level
RS Wrap 0——15 SS Max Anisotrophy
SS Address U, V, W TSS Color Arg 0-2
TSS Color Op TSS Constant
TSS Alpha Arg 0-2 RS Fog Table Mode
TSS Alpha Op RS Fog Density
TSS Result Arg RS Fog End
TSS Bump Env Mat 00-11 RS Fog Start
TSS Bump Env L Scale RS Fog Color
TSS Bump Env L Offset RS Fog Enable
RS Depth Bias RS Slope Scale Depth Bias
SS sRGB Texture RS Antialiased Line Enable
Frame Buffer RS Alpha Ref RS Alpha Test Enable
RS Alpha Func RS Z Enable
RS Z Func
RS Stencil Enable RS Stencil Func
RS Stencil Fail RS Stencil Z Fail
RS Stencil Pass RS Alpha Blend Enable
RS Src Blend RS Dest Blend
RS Blend Op RS Dither Enable
RS Color Write Enable RS Stencil Write Mask
RS Z Write Enable RS Multi Sample Antialias
RS Multi Sample Mask RS Scissor Test Enable
RS Src Blend Alpha RS Separate Alpha Blend Enable
RS Dest Blend Alpha RS Blend Op Alpha
RS Blend Factor RS CCW Stencil Fail
RS CCW Stencil Z Fail RS CCW Stencil Pass
RS sRGB Write Enable RS CCW Stencil Func
SS Element Index RS Color Write Enable 1-3
RS Two Sided Stencil Mode

注意:RS,SS和TSS 分别表示render, sampler和texture stage states。

Render state, sampler state和纹理阶段state都是32位的数量,并且携带一个名字和值。名字取值于D3DRENDERSTATETYPE, D3DSAMPLERSTATETYPE和D3DTEXTURESTAGESTATETYPE 枚举值。

分享到:
评论

相关推荐

    directsound开发指南-智慧的鱼

    - **Dsound 设备对象 (DirectSound Devices)**:这部分主要介绍如何创建和管理 DirectSound 设备对象,包括获取可用设备列表、选择设备等。 - **Dsound 的 buffer 对象 (DirectSound Buffers)**:深入探讨 Direct...

    DirectSound_Develop手册

    1. **Dsound设备对象(DirectSound Devices)**: - 介绍了如何管理和选择音频设备。 - 包括获取可用设备列表、设置默认设备等。 2. **Dsound的缓冲区对象(DirectSound Buffers)**: - 解释了不同类型的缓冲区及其...

    D3D render pipeline

    This book describes the Direct3D graphics pipeline, from presentation of scene data to pixels appearing on the screen. The book is organized sequentially following the data °ow through the pipeline ...

    CUDA Reference from NVIDIA official site.

    The Direct3D Interoperability section of the Runtime API includes functions for integrating CUDA with Direct3D, enabling shared memory access between CUDA and Direct3D contexts. **1.9.1 cudaD3D9Get...

    Managed Directx 9 Kick Start - Graphics And Game Programming

    The Direct3D Device Making Our Triangle Three Dimensional Automatic Device Resets During a Resize We've Got Camera and Action; What About Lights? Device States and Transforms Swapchains and...

    OpenCL Programming Guide - A. Munshi, et al

    Sharing and synchronizing data with OpenGL and Microsoft’s Direct3D Simplifying development with the C++ Wrapper API Using OpenCL Embedded Profiles to support devices ranging from cellphones to ...

    Pro JavaFX 9, 4th Edition

    Additionally, there is coverage of the Shader DSL for JavaFX that allows you to generate Shaders for OpenGL and Direct3D. After reading and using this book, you’ll have the knowledge to give you an ...

    Pro JavaFX 9: A Definitive Guide to Building Desktop, Mobile, and Embedded Java

    Additionally, there is coverage of the Shader DSL for JavaFX that allows you to generate Shaders for OpenGL and Direct3D. After reading and using this book, you'll have the knowledge to give you an ...

    StereoIssues

    // Only accept hardware devices return DeviceType == D3D10_DRIVER_TYPE_HARDWARE; } // ------------------------------------------------------------------------------------------------ HRESULT ...

    GPU Pro 6 Advanced Rendering Techniques 无水印pdf 0分

    rendering techniques, handheld devices programming, effects in image space, shadows, 3D engine design, graphics-related tools, and environmental effects. It also includes a dedicated section on ...

    GPU.Pro.6.Advanced.Rendering.Techniques.148226461

    rendering techniques, handheld devices programming, effects in image space, shadows, 3D engine design, graphics-related tools, and environmental effects. It also includes a dedicated section on ...

    GPU Pro 7 Advanced Rendering Techniques 2016新书 kindle azw4 0分

    rendering techniques, handheld devices programming, effects in image space, lighting, 3D engine design, graphics-related tools, and environmental effects. It also includes a dedicated section on ...

    Windows api.pdf

    以及DirectX系列,如Direct2D、Direct3D等,用于高性能的图形处理。 二、System Services & Security Windows API提供了多种系统服务,如Background Intelligent Transfer Service (BITS)用于后台数据传输,Backup ...

    ATI显卡发展之路简介

    进入90年代中期,ATI进一步发展了其图形处理能力,推出了Rage系列显卡,该系列在游戏性能上表现出色,尤其是在Direct3D支持方面,成为了当时游戏爱好者的首选。随着3D图形技术的快速发展,ATI在1998年发布了Rage Pro...

    Learning Windows 8 Game Development

    If you want to program a game, this book is for you, as it will provide a great overview of Direct3D and Windows 8 game development and will kick-start your journey into 3D development.

    linux下的AMDGPU驱动源码

    在配置过程中,可能还需要安装特定的库,如drm(Direct Rendering Manager)和 mesa 3D图形库,它们是Linux系统中处理图形硬件接口的关键组件。确保这些库的版本与内核和驱动源码兼容。 编译过程通常分为几个步骤:...

    AMD-APP-SDKInstaller-v3.0.130.135-GA-windows-F-x64.rar

    AMD APP SDK(Advanced Micro Devices Accelerated Parallel Processing Software Development Kit)是一款由AMD公司推出的软件开发工具包,主要用于利用AMD处理器和GPU的并行计算能力。这个压缩包“AMD-APP-...

Global site tag (gtag.js) - Google Analytics