MCPcopy Create free account
hub / github.com/defold/defold / NewRenderScriptInstance

Function NewRenderScriptInstance

engine/render/src/render/render_script.cpp:3318–3355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3316 }
3317
3318 HRenderScriptInstance NewRenderScriptInstance(dmRender::HRenderContext render_context, HRenderScript render_script)
3319 {
3320 lua_State* L = render_context->m_RenderScriptContext.m_LuaState;
3321
3322 int top = lua_gettop(L);
3323 (void) top;
3324
3325 RenderScriptInstance* i = (RenderScriptInstance*)lua_newuserdata(L, sizeof(RenderScriptInstance));
3326 ResetRenderScriptInstance(i);
3327 i->m_PredicateCount = 0;
3328 i->m_UniqueScriptId = dmScript::GenerateUniqueScriptId();
3329 i->m_RenderScript = render_script;
3330 i->m_ScriptWorld = render_context->m_ScriptWorld;
3331 i->m_RenderContext = render_context;
3332 i->m_CommandBuffer.SetCapacity(render_context->m_RenderScriptContext.m_CommandBufferSize);
3333 i->m_RenderResources.SetCapacity(16, 8);
3334
3335 lua_pushvalue(L, -1);
3336 i->m_InstanceReference = dmScript::Ref( L, LUA_REGISTRYINDEX );
3337
3338 lua_newtable(L);
3339 i->m_RenderScriptDataReference = dmScript::Ref( L, LUA_REGISTRYINDEX );
3340
3341 lua_newtable(L);
3342 i->m_ContextTableReference = dmScript::Ref( L, LUA_REGISTRYINDEX );
3343
3344 luaL_getmetatable(L, RENDER_SCRIPT_INSTANCE);
3345 lua_setmetatable(L, -2);
3346
3347 dmScript::SetInstance(L);
3348 dmScript::InitializeInstance(i->m_ScriptWorld);
3349 lua_pushnil(L);
3350 dmScript::SetInstance(L);
3351
3352 assert(top == lua_gettop(L));
3353
3354 return i;
3355 }
3356
3357 static void ReleaseConstantBufferLuaRefs(lua_State* L, HRenderScriptInstance instance)
3358 {

Callers 3

TEST_FFunction · 0.85
AcquireResourcesFunction · 0.85
TEST_FFunction · 0.85

Calls 12

lua_gettopFunction · 0.85
lua_newuserdataFunction · 0.85
GenerateUniqueScriptIdFunction · 0.85
lua_pushvalueFunction · 0.85
RefFunction · 0.85
lua_setmetatableFunction · 0.85
SetInstanceFunction · 0.85
InitializeInstanceFunction · 0.85
lua_pushnilFunction · 0.85
assertFunction · 0.50
SetCapacityMethod · 0.45

Tested by 2

TEST_FFunction · 0.68
TEST_FFunction · 0.68