论坛风格切换切换到宽版
  • 7103阅读
  • 26回复

奇怪的处理落? [复制链接]

上一主题 下一主题
离线mk124
 
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看楼主 倒序阅读 楼主  发表于: 2009-03-26
现在我的程序是自己处理Sleep时间控制帧数的,不过貌似偶尔有卡帧的处理落问题……
我去掉了我的帧率控制代码,开启了垂直更新同步,结果还是有古怪的处理落卡帧问题= =

结果我将进程的优先级改为实时后,问题解决……
为啥会这样呢= =?我明明已经将游戏的主线程的优先级设为最高了啊……貌似这样:
  1.     HANDLE currentThread = GetCurrentThread();
  2.     SetThreadPriority(currentThread, THREAD_PRIORITY_TIME_CRITICAL);

而且我的东西占用CPU也只是4-8%左右而已,想不通为啥会处理落……
求助……
离线绯想の夜
发帖
63
樱饼
0
博丽神社的喝茶券(威望)
0
春度
0
交易币
0
只看该作者 1楼 发表于: 2009-03-26
其实应该用游戏时间来控制。。。。
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 2楼 发表于: 2009-03-26
就是拿timeGetTime(精度:1ms)获得的实际时间来控制的啊= =
离线littlewater
发帖
793
樱饼
5
博丽神社的喝茶券(威望)
1
春度
59
交易币
0
只看该作者 3楼 发表于: 2009-03-26
瞬间CPU占用过高的关系吧?

看看每一次帧渲染的时间间隔,如果起伏变化很大的话……

建议试试D3D多缓冲……
水水
离线h5nc
发帖
2724
樱饼
0
博丽神社的喝茶券(威望)
2
春度
738
交易币
0
只看该作者 4楼 发表于: 2009-03-26
所以说请用orz……
没有比orz再优的办法了。。。
然后intel分析之。。

补充:orz
莫要挖坟
http://bbs.thproject.org/read.php?tid=26160&fpage=16
[ 此帖被h5nc在2009-03-26 10:32重新编辑 ]

0x073《東方弾置場》开发版即将问世
【Leah】引擎问世
同人STG《叛境东方游》已经腰斩
《叛之境界无双篇》已死
离线littlewater
发帖
793
樱饼
5
博丽神社的喝茶券(威望)
1
春度
59
交易币
0
只看该作者 5楼 发表于: 2009-03-26
不一定的,找到问题根源动手解决之,知道问题所在以后,
方法并不一定只有一二种^^

求每帧描绘MS统计~♪
水水
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 6楼 发表于: 2009-03-26
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=14, realSleepTime=14, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=2


精度=timeGetTime()精度=1ms;
renderTime = 逻辑运算时间+图形渲染时间;


已经看了AVC大的ORZ,其实想法还不错,不过有好多层古怪的API封装= =
其实也就是跟目标时间相差大的时候Sleep()挂起线程,相差小就循环抢CPU卡准确时间~
那啥= = 暂时没考虑过用这个方法呢 虽然并不难用~
[ 此帖被mk124在2009-03-26 21:28重新编辑 ]
离线littlewater
发帖
793
樱饼
5
博丽神社的喝茶券(威望)
1
春度
59
交易币
0
只看该作者 7楼 发表于: 2009-03-27
=3= 从你这输出上看,那不就是很流畅了嘛……
你确定以上输出的数据中有至少一次处理落么 OTL

另外我很难相信这是真的,请求的时间和SLEEP的时间居然那么准……
也许机器比较准?水水自己的机器SLEEP都不准的……

求含此输出的EXE程序,想自己跑一跑确认出现30FPS的时候是否还是对的……

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

再去跑了几趟游戏,发现运动中并且挂的时候,机箱有时候会有鸣叫,于是又
看了一下LZ的API调用,发现并未使用DINPUT,也不是WIN32API的GetAsyncKeyState,而是用的是回调的WM_KEYDOWN和WM_KEYUP
通常不应该也不建议使用消息循环回调来处理人物运行,推荐是放到帧循环中每帧轮询吧……

不过实测不按键也会偶尔有卡住现象……问题依然迷茫= =
[ 此帖被littlewater在2009-03-27 09:58重新编辑 ]
水水
离线h5nc
发帖
2724
樱饼
0
博丽神社的喝茶券(威望)
2
春度
738
交易币
0
只看该作者 8楼 发表于: 2009-03-27
私以为调用机箱鸣叫很有嫌疑。。。那是中弹。。

0x073《東方弾置場》开发版即将问世
【Leah】引擎问世
同人STG《叛境东方游》已经腰斩
《叛之境界无双篇》已死
离线Advance
发帖
2680
樱饼
0
博丽神社的喝茶券(威望)
2
春度
427
交易币
0
只看该作者 9楼 发表于: 2009-03-27
timeGetTime的精度取决于所有进程调用timeBeginPeriod的最小值,在NT4.0以上的系统中默认值是5ms
Sleep的精度同上,当然真要准的话除非优先级特别高……

THREAD_PRIORITY_TIME_CRITICAL优先级不应在一般的应用程序中使用

关于瞬间FPS低下,关闭GC试试。相应的tracer需要准备一个
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 10楼 发表于: 2009-03-27
至少有一个处理落啊|||
我在感到有轻微卡帧现象的时候就立即停止执行的呢……
咩= =中弹已经不用Beep()乱叫了,所以肯定不是这个问题呐|||
只是所有残机用完的时候才Beep() 一次……

好吧……样本上传了= =
用了OutputDebugString()输出~拖进调试器里就能看到了。
附件: Touhou_MK.rar (1321 K) 下载次数:30
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 11楼 发表于: 2009-03-27
使用THREAD_PRIORITY_TIME_CRITICAL应该没啥问题吧= =,至少不陷入死循环就不会有问题……(默|||)
还有,啥是GC呢?= =
离线littlewater
发帖
793
樱饼
5
博丽神社的喝茶券(威望)
1
春度
59
交易币
0
只看该作者 12楼 发表于: 2009-03-27
水水自己跑了一次,你可以看一下这两段比较明显的时间间隔:
第一处,最大真实时间间隔有90ms+
00000774    13.08438396    [832] destSleepTime=14, realSleepTime=14, renderTime=1    
00000775    13.10101509    [832] destSleepTime=16, realSleepTime=17, renderTime=1    <---- start
00000776    13.19690228    [832] destSleepTime=15, realSleepTime=15, renderTime=2    <---- stop
00000777    13.19899559    [832] destSleepTime=14, realSleepTime=15, renderTime=51    
00000778    13.20046902    [832] destSleepTime=0, realSleepTime=1, renderTime=31    
00000779    13.21989250    [832] destSleepTime=0, realSleepTime=0, renderTime=1    
第二处,最大真实时间间隔有100ms+
00001548    26.19770050    [832] destSleepTime=13, realSleepTime=13, renderTime=1    <---- start
00001549    26.30513191    [832] destSleepTime=16, realSleepTime=17, renderTime=1    <---- stop
00001550    26.30688667    [832] destSleepTime=15, realSleepTime=16, renderTime=54    
00001551    26.31012535    [832] destSleepTime=0, realSleepTime=0, renderTime=39    
其他也存在一些,至于为什么描绘并没有跳变,因为后面被你用数个destSleepTime=0覆盖了漏洞
不过这只是我自己机器上跑的结果……附上完整的文件~
顺便,我的本子只能跑到25FPS,哭啊,看来显卡太烂、显存太小=3=~

--------------------
自己的一点点(微不足道)的说法,所谓FPS=60或者多少,并不是为了尽可能去达到它(除非你做3D那肯定不应该锁定),
我不清楚一次处理是否等同于一次真实的渲染(我这里假定处理和绘制是同一个概念,即同一个线程,事实上大多程序也这么做),
FPS的存在意义,是让它真实的反应描绘速率,如果慢了发生掉帧,那就应该让它掉,而不是去补回来,因为在同一个16~17ms之间绘制多少次
意义几乎不大(夸张点想象0ms的间隔),绘制多少次,差不多等于只绘制了一次罢了……请勿为了追求60FPS而去弄60FPS。

我自己也没做过很高深的STG,以上言论也可以无视之~♪
[ 此帖被littlewater在2009-03-27 18:23重新编辑 ]
描述:LWL的调试文件
附件: LWL.rar (19 K) 下载次数:13
水水
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 13楼 发表于: 2009-03-27
控制帧率算法有严重问题么|||
我去检查下……

谢谢~!
离线mk124
发帖
58
樱饼
0
博丽神社的喝茶券(威望)
0
春度
10
交易币
0
只看该作者 14楼 发表于: 2009-03-27
貌似很诡异呢= =我没有去刻意保持60FPS啊= =
更没有destSleepTime=0达到加速补帧的行为……

以下测试为:
我开启了游戏,故意去点游戏的标题栏,达到卡帧的目的,然后发现FPS的确下降了啊……
乃的问题……莫非timeGetTime()抽风了?-_____-

destSleepTime=14, realSleepTime=14, renderTime=5
destSleepTime=12, realSleepTime=12, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=188    <-Click
destSleepTime=0, realSleepTime=0, renderTime=5
destSleepTime=11, realSleepTime=12, renderTime=3
destSleepTime=13, realSleepTime=14, renderTime=5
destSleepTime=11, realSleepTime=11, renderTime=3

destSleepTime=11, realSleepTime=11, renderTime=3
destSleepTime=13, realSleepTime=14, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=2
destSleepTime=15, realSleepTime=15, renderTime=89    <-Click
destSleepTime=0, realSleepTime=0, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=4
destSleepTime=12, realSleepTime=12, renderTime=2
destSleepTime=15, realSleepTime=16, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=2


-------------------------------------------------------------------------------- 附上后来测试的明显有处理落的调试数据:
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=6
destSleepTime=11, realSleepTime=11, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=11       <
destSleepTime=5, realSleepTime=5, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=5
destSleepTime=11, realSleepTime=11, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=4
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=20       <
destSleepTime=0, realSleepTime=0, renderTime=7
destSleepTime=9, realSleepTime=9, renderTime=18       <
destSleepTime=0, realSleepTime=0, renderTime=3
destSleepTime=14, realSleepTime=15, renderTime=4
destSleepTime=11, realSleepTime=11, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=3
destSleepTime=13, realSleepTime=13, renderTime=3
destSleepTime=14, realSleepTime=14, renderTime=3


-------------------------------------------------------------------------------- 后来继续发现= =
系统空载或将进程设置为实时的时候,renderTime稳定在1~2ms
执行了比较多程序的时候……(见上面的调试信息)
destSleepTime==realSleepTime,不过renderTime时间非常不稳定,在1-10MS之间飘~
[ 此帖被mk124在2009-03-27 18:39重新编辑 ]
快速回复
限100 字节
 
上一个 下一个