博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]Ogre Script Cache Plugin
阅读量:4338 次
发布时间:2019-06-07

本文共 4007 字,大约阅读时间需要 13 分钟。

 

Table of contents

 

Introduction

Script Cache

The Script Cache plugin attempts to speed up the time taken to parse resource script (like *.material, *.program etc). This is done by caching the binary representation of the compiled script (in memory) to disk, when the application is run the first time. Then on subsequent runs, the scripts would no longer be re-compiled again since their binary representation is already present in the cache. However, if the script is modified by the user, the cache would automatically be discarded and the modified version would be compiled and cached again.

Shader Cache

Ogre 1.8 introduced a new feature called ShaderCache. The plugin automatically uses the ShaderCache feature if compiled with Ogre 1.8+. The plugin would not use ShaderCache for Ogre 1.7 and below

Compiling

Download the latest code from here:

Use CMake to create the build system

Build the plugin. You should see the following modules:

  • Plugin_ScriptSerializer (Release mode)
  • Plugin_ScriptSerializer_d (Debug Mode)

Setup

  • After you have compiled your plugin, copy it over to your plugins folder (e.g. along side RenderSystem_OpenGL, Plugin_ParticleFX etc)
  • Open plugins.cfg and add an new entry for this new plugin.

Plugin=Plugin_ScriptSerializer

  • Create a new config file for this plugin named ScriptCache.cfg in your executable folder with the following contents

 

· [ScriptCache]

· extension=.sbin

· location=./ScriptCache

· searchExtensions=program material particle compositor os pu

·

· [ShaderCache]

filename=Shaders.cache

 

    • ScriptCache.extension: The extension to use when saving the compiled binary script
    • ScriptCache.location: The directory where the script cache should be saved. If this directory is unavailable, the plugin would attempt to create this directory. If it fails to create this directory, or if the directory is read-only, then the plugin would log a warning and disable itself. This path can have absolute or relative addressing
    • ScriptCache.searchExtensions:
    • ShaderCache.filename: The filename to use for the shader cache. This file would be saved in the location specified in ScriptCache.location. Provide only the filename here and not the path

 

  • If the above config file is not present, the plugin would use default values (same as the above mentioned config file)
  • Run your application. The first time, the plugin should create the cache directory and fill it with the compiled scripts. You should be able to notice performance improvements after the first run

Note: The Script Cache directory should not be added to your resources.cfg if you include your plain-text scripts. However, if you wish to deploy only the binary scripts, then remove the references to your plain-text scripts and add the Script Cache directory to resources.cfg.

 

Benchmark

Here is the time it took to compile the scripts and startup the sample browser:

Advantages

  • ScriptCache Reduces the script compilation time in Debug Mode significantly
  • Ogre's built in ShaderCache reduces the shader compilation time in both Debug and Release mode

Drawbacks

  • ScriptCache has no noticeable performance gain in Release mode. However ShaderCache boosts the speed considerably in Release mode

License

Released under MIT licence, similar to OGRE

References

Tracking Thread:

Download Code:


Contributors to this page:   .

Page last modified on Wednesday 02 of February, 2011 23:06:39 UTC by .


 

 

Ogre 1.8 Shader Cache

 

The idea is to save a cache before you release the product or at the first run on the client computer - and from then on use the cache to load shaders without compiling them.

If you want to save shaders to the cache:
* Before the resource load call GpuProgramManager::getSingleton().setSaveMicrocodesToCache(true);
* When you want to save the cache to a file call - GpuProgramManager::getSingleton().saveMicrocodeCache(...);
When you want to use the cache: 
* Before the resource load call - GpuProgramManager::getSingleton().loadMicrocodeCache(...);

转载于:https://www.cnblogs.com/pulas/archive/2012/02/14/2351191.html

你可能感兴趣的文章
jQueru中数据交换格式XML和JSON对比
查看>>
form表单序列化后的数据转json对象
查看>>
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
middle
查看>>
[Bzoj1009][HNOI2008]GT考试(动态规划)
查看>>
Blob(二进制)、byte[]、long、date之间的类型转换
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>