Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
獨立遊戲開發者分享會 110220 ─ LuaJIT intro
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
IGDSHARE
January 09, 2012
Programming
940
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
獨立遊戲開發者分享會 110220 ─ LuaJIT intro
這是重新上傳第一場 IGDSHARE 時所分享的 LuaJIT 簡介資料,其中有少部份資訊已過時,參考時請注意。
LuaJIT 官方網站
http://luajit.org
IGDSHARE
January 09, 2012
More Decks by IGDSHARE
See All by IGDSHARE
Cogmind - a Well-Played Discussion (zh-TW)
igdshare
0
110
Guided Reading: Steam Tags, Discounts & Publishing Deals
igdshare
1
490
Steam in 2018 - notes from various talks
igdshare
2
160
Experimental Gameplay Workshop 2018 與 Alt. Ctrl. GDC 印象
igdshare
0
160
Experimental Gameplay Workshop 2017 & Alt. Ctrl. GDC Impressions
igdshare
0
190
IGDShare 160306 "Good Sound, Good Game" by IMBA Interactive
igdshare
1
510
Save your own game industry
igdshare
4
1.4k
Experimental Gameplay Workshop 2014 Impressions
igdshare
0
390
Making of CuBeat, Programming-wise
igdshare
1
2.2k
Other Decks in Programming
See All in Programming
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
480
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
スマートグラスで並列バイブコーディング
hyshu
0
290
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.3k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
170
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
610
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
130
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
580
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
210
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
500
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
340
Google's AI Overviews - The New Search
badams
0
1.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
Ruling the World: When Life Gets Gamed
codingconduct
0
280
Thoughts on Productivity
jonyablonski
76
5.2k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Being A Developer After 40
akosma
91
590k
New Earth Scene 8
popppiees
3
2.4k
Transcript
LuaJIT a Just-in-Time compiler for the language Lua
誰在用 Lua World of Warcraft Angry Birds Civilization 5 Homeworld
2 ... http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games ...AND YOU!(possibly)
認識 Lua 語法簡單、靈活 速度快 體積小 易延展(Lua/C API) =>Extensible & Embeddable
『通常不獨立使用』
Lua 效能
Lua 效能
LuaJIT http://luajit.org Michael (Mike) Pall 2005~ LuaJIT 1.x (stable 1.1.6)
2009~ LuaJIT 2.0-beta releases Now =>LuaJIT 2.0-beta6 (google for LuaJIT Roadmap 2011)
Just-in-Time Compiler? 即時編譯器 Source code => bytecode => machine code
Java Hotspot C# .Net Javascript V8/Trace(Jaeger) Monkey Python Pypy ...還有很多
JIT 效能
速度 & 程式碼量
LuaJIT 2.0 超級快 只算 interpreter 也比原本快 2x-4x Lua 5.1 語法完全相同
丟進去就可以用(drop-in replacement) Beta 已經很穩定 Foreign Function Interface(beta6) 現在只有 x86/64 版本
LuaJIT in Games? The Settlers 7 搶在上市前實裝 LuaJIT2-beta 個人測試: Civilization
5 只能用 LuaJIT1 (可能是因為 bytecode 不相容) Mike 本人透露,還有很多不能講...
LuaJIT 注意事項 Lua table 盡量用,不用怕 overhead 避免大量的 closure(目前) 避免只跑幾次的 inner
loop 避免 global object for i = 1, 100000000 do local t = {'a','b','c'} for j = 1, 3 do t[j] = .. end End --p.s.通常這可以被自動 unroll,但若其 loop 次數是由變數決定就很難講
LuaJIT 注意事項 避免無謂的暫存物件 多用 -jv option 查看執行效果 Bytecode 不相容於 Lua
5.1 不打算積極跟上 Lua 5.2
LuaJIT 近期重點 Qualcomm 贊助 ARM Port! Foreign Function Interface! local
ffi = require("ffi") ffi.cdef[[ typedef struct { float x,y,z; } SVertex; int MessageBoxA(void*,char const*,char const*,int); ]] ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0) local img = ffi.new("SVertex[?]", 100) img[0].x = 123
What's to come? 2011 年內: LuaJIT 2.0 正式版與 2.1 測試版
ARM port of LuaJIT 2.0 About 2.1: New Garbage Collector FFI C-preprocessor (?)
What's to come? 更遠程:LuaJIT FFI to C++ (!?) Binding 再也不用額外寫,運算可以幾乎
都寫在 Lua 裡... ...Full Lua 3D engines ? ...Full Lua Triple-A Titles ? What's in the next level ?
My 2 Cents: 沒有天天過年的啦 Lua nature1:沒有統一穩定的電池 Lua nature2:大概永遠不適合大團隊開發 因為太簡單,大家自成一套 =>
結果反而不穩定、難用? x86/64、ARM 以外的平台大概有得等
Demo Time Game of Life benchmark: 純邏輯速度比較 C/C++ 加上繪圖速度比較 =>
GL primitive、Vertex Array、 VBO、PBO 繪圖加速情況下把邏輯加速關掉 [1] https://github.com/archilifelin/mysandbox/blob/master/lua/lifegame_ffi_sdl_gl.lua [2] https://github.com/archilifelin/mysandbox/tree/master/cpp/lifegame_sdl
Lua 框架 CoronaSDK Scripting-Layer for Android (SL4A) Gamekit (based on
Ogre) ShiVa Engine Love2D ...and more
Love2D http://love2d.org OpenGL 加速的輕量 2D遊戲框架 Box2D integration TrueType Font(no unicode
yet) Pure Lua function love.draw() love.graphics.print('Hello World!', 400, 300) end
Q & A 資料來源 Lua mailing list http://luajit.org http://love2d.org http://en.wikipedia.org
http://shootout.alioth.debian.org
[email protected]
http://igdshare.org