游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2065|回复: 5

关于D3DX Shader Effects State Management,一起讨论讨论

[复制链接]

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
发表于 2007-7-11 09:48:00 | 显示全部楼层 |阅读模式
这里有篇文章是关于D3DX Shader Effects State Management的,可以提高shader的效率

http://www.nesnausk.org/nearaz/texts/d3dx_fx_states.html

大家一起看看,并讨论讨论思路

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2007-7-11 09:52:00 | 显示全部楼层

Re:关于D3DX Shader Effects State Management,一起讨论讨论

D3DX effects do lots of work behind the scenes to make programmer's life easier. D3D guys are making serious improvements in reducing Effect system overhead (optimizing internals), but some things just can't be optimized away. I'm mostly talking about the fact that by default, effects save and restore all modified D3D device state - this obviously has some overhead (probably mostly in D3D runtime and the driver, not in Effects themselves). This behavior is great for quick prototyping, but what if we could reduce the state management overhead?

One common advice is "don't save/restore state in Effects" (via D3DXFX_DONOTSAVE* flags). Ok, fine, but what's then? After one effect, another one will be messed up because previous one might set some exotic states! Setting all states in each effect is also not a viable option: if just one of them wanted to set some rarely used state (e.g. ShadeMode=Flat), then all other effects would need to set it back to Gouraud.

里面表达的意思是什么?我认为这个很重要

8

主题

390

帖子

390

积分

中级会员

Rank: 3Rank: 3

积分
390
发表于 2007-7-11 11:34:00 | 显示全部楼层

Re:关于D3DX Shader Effects State Management,一起讨论讨论

dx10就很大程度上降低了state切换的成本。
对于dx10之前的应用,那就只好对所有待渲染物体进行排序,降低切换次数。

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2007-7-11 12:23:00 | 显示全部楼层

Re:关于D3DX Shader Effects State Management,一起讨论讨论

不看这篇文章还真不知道,state切换的成本是很高的,对效率的影响不容忽视,需要进行相当的优化。
虽然目前还在dx9,我相信这篇文章还是很有价值的。

13

主题

74

帖子

74

积分

注册会员

Rank: 2

积分
74
发表于 2007-7-12 09:36:00 | 显示全部楼层

Re:关于D3DX Shader Effects State Management,一起讨论讨论

天下没有免费的午餐,Effect在使得Shader应用方面简化了操作,同时也会牺牲部分性能,增加了额外的一层肯定会有所消耗。之前做过测试在地形渲染部分把Effect的Shader改成直接VS,PS,可以提高5-10帧左右。但是对于200帧的速率,5帧只是一个很细微的差别。如果在整个游戏世界中,这点差异也许早就湮灭在CPU和GPU大量的计算和磁盘IO瓶颈之中了。

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2007-7-12 10:50:00 | 显示全部楼层

Re:关于D3DX Shader Effects State Management,一起讨论讨论

是啊,现在基本都用effect,很少单独使用vs和ps了,确实方便很多。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-25 20:48

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表