查看: 761|回复: 10

[编程指南] 【FShaderCache | Unreal Engine】

[复制链接]

1

主题

342

帖子

7万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
75866
发表于 2016-6-27 00:49:26 | 显示全部楼层 |阅读模式


Overview
The FShaderCache provides mechanisms for reducing shader hitching in-game. It supports the OpenGLDrv RHI, and works on Mac, Linux, and Windows platforms.

There are a number of console commands that can be used to enable or disable FShaderCache functionality.


Console Command
Description

r.UseShaderCaching [0/1]
Early submission during shader deserialisation rather than on-demand.

Tracking of bound-shader-states so that they may be pre-bound during early submission.
r.UseShaderDrawLog [0/1]Tracking of RHI draw states so that each bound-shader-state can be predrawn.r.UseShaderPredraw [0/1]Predrawing of tracked RHI draw states to eliminate first-use hitches.r.PredrawBatchTime [Time in (ms)]Control over time spent predrawing each frame to distribute over many frames if required. Use -1 for all.Use
The cache should be populated by enabling r.UseShaderCaching and r.UseShaderDrawLog on a development machine. Users/players should then consume the cache by enabling r.UseShaderCaching and r.UseShaderPredraw. Draw logging (r.UseShaderDrawLog) adds noticeable fixed overhead so avoid enabling it in shipped products if possible. Since the caching is done via shader hashes, it is also advisable to only use this as a final optimization tool when content is largely complete as changes to shader hashes will result in unused entries accumulating in the cache, increasing cache size without reducing hitches.

The code will first try and load the writable cache, then fall back to the distribution cache if needed.




Cache Type
Cache Location

WritableGame/Saved/ShaderCache.ushadercacheDistributionGame/Content/ShaderCache.ushadercacheHandling Updates/Invalidation
When the cache needs to be updated and writable caches invalidated the game should specify a new GameVersion.Call FShaderCache::SetGameVersion before initializing the RHI (which initializes the cache). This will cause the contents of a cache generated by a previous version to be ignored. At present you cannot carry over cache entries from a previous version.
Region/Stream Batching
For streaming games, or where the cache becomes very large, calls to FShaderCache::SetStreamingKey should be added with unique values for the currently relevant game regions/streaming levels (as required). Logged draw states will be linked to the active streaming key. This limits predrawing to only those draw states required by the active streaming key on subsequent runs.
回复

使用道具 举报

0

主题

847

帖子

2783

积分

vip会员

Rank: 1

积分
2783
发表于 2016-7-2 19:29:59 来自手机 | 显示全部楼层
我现在有的是钱,我要下了!
回复 支持 反对

使用道具 举报

0

主题

840

帖子

2774

积分

vip会员

Rank: 1

积分
2774
发表于 2016-7-3 23:31:10 来自手机 | 显示全部楼层
全就行啊,,支持 一下
回复 支持 反对

使用道具 举报

0

主题

1271

帖子

3982

积分

vip会员

Rank: 1

积分
3982
发表于 2016-7-4 11:30:41 | 显示全部楼层
资源都让你发了。
回复 支持 反对

使用道具 举报

0

主题

844

帖子

2780

积分

vip会员

Rank: 1

积分
2780
发表于 2016-7-9 16:16:30 来自手机 | 显示全部楼层
我一天来看一回,看看能不能打折。
回复 支持 反对

使用道具 举报

0

主题

836

帖子

2772

积分

vip会员

Rank: 1

积分
2772
发表于 2016-7-10 07:41:31 来自手机 | 显示全部楼层
感谢楼主的大爱无私
回复 支持 反对

使用道具 举报

0

主题

856

帖子

2864

积分

vip会员

Rank: 1

积分
2864
发表于 2016-7-12 22:53:04 来自手机 | 显示全部楼层
好东西,多些楼主分享
回复 支持 反对

使用道具 举报

0

主题

899

帖子

3006

积分

vip会员

Rank: 1

积分
3006
发表于 2016-7-19 09:56:17 来自手机 | 显示全部楼层
这个多少金币啊。
回复 支持 反对

使用道具 举报

0

主题

843

帖子

2803

积分

vip会员

Rank: 1

积分
2803
发表于 2016-7-21 13:45:26 | 显示全部楼层
下来看看,多谢楼主分享了。
回复 支持 反对

使用道具 举报

0

主题

1191

帖子

3772

积分

vip会员

Rank: 1

积分
3772
发表于 2016-7-26 06:56:17 | 显示全部楼层
很想看看看了
回复 支持 反对

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | enginedx注册

本版积分规则

 
 



邮件留言:


 
返回顶部