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

Function Compute_GetConstants

engine/gamesys/src/gamesys/scripts/script_compute.cpp:199–229  ·  view source on GitHub ↗

gets shader constants from a compute program * Returns a table of all the shader constants in the compute program. * * @name compute.get_constants * * @param path [type:hash|string] The path to the resource * @return table [type:table] A table of tables, where each entry contains info about the shader constants: * * `name` * : [type:hash] the hashed nam

Source from the content-addressed store, hash-verified

197 * ```
198 */
199 static int Compute_GetConstants(lua_State* L)
200 {
201 DM_LUA_STACK_CHECK(L, 1);
202
203 ComputeResource* compute_res = CheckComputeResource(L, 1);
204
205 lua_newtable(L);
206
207 uint32_t constant_index = 1;
208
209 uint32_t constant_count = dmRender::GetComputeProgramConstantCount(compute_res->m_Program);
210 for (int i = 0; i < constant_count; ++i)
211 {
212 dmhash_t name_hash;
213 dmRender::GetComputeProgramConstantNameHash(compute_res->m_Program, i, &name_hash);
214
215 dmRender::HConstant constant;
216
217 if (dmRender::GetComputeProgramConstant(compute_res->m_Program, name_hash, constant))
218 {
219 lua_pushinteger(L, (lua_Integer) constant_index++);
220 lua_newtable(L);
221
222 PushRenderConstant(L, constant);
223
224 lua_rawset(L, -3);
225 }
226 }
227
228 return 1;
229 }
230
231 /*# gets textures associated with a compute program
232 * Returns a table of all the textures from the compute program.

Callers

nothing calls this directly

Calls 7

CheckComputeResourceFunction · 0.85
lua_pushintegerFunction · 0.85
PushRenderConstantFunction · 0.85
lua_rawsetFunction · 0.85

Tested by

no test coverage detected