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

Function Compute_GetTextures

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

gets textures associated with a compute program * Returns a table of all the textures from the compute program. * * @name compute.get_textures * * @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 compute textures: * * `path` * : [type:hash] the resource path

Source from the content-addressed store, hash-verified

283 * ```
284 */
285 static int Compute_GetTextures(lua_State* L)
286 {
287 DM_LUA_STACK_CHECK(L, 1);
288
289 ComputeResource* compute_res = CheckComputeResource(L, 1);
290
291 uint32_t texture_index = 1;
292
293 lua_newtable(L);
294
295 for (int i = 0; i < compute_res->m_NumTextures; ++i)
296 {
297 TextureResource* texture_res = compute_res->m_Textures[i];
298 if (texture_res)
299 {
300 lua_pushinteger(L, (lua_Integer) texture_index++);
301 lua_newtable(L);
302
303 dmGraphics::HContext graphics_context = dmRender::GetGraphicsContext(dmRender::GetProgramRenderContext(compute_res->m_Program));
304 PushTextureInfo(L, graphics_context, texture_res->m_Texture, compute_res->m_TextureResourcePaths[i]);
305 lua_rawset(L, -3);
306 }
307 }
308
309 return 1;
310 }
311
312 /*# sets texture samplers in a compute program
313 * Sets texture samplers in a compute program, if the samplers exist. Use this function to change the settings of texture samplers.

Callers

nothing calls this directly

Calls 6

CheckComputeResourceFunction · 0.85
lua_pushintegerFunction · 0.85
GetGraphicsContextFunction · 0.85
GetProgramRenderContextFunction · 0.85
PushTextureInfoFunction · 0.85
lua_rawsetFunction · 0.85

Tested by

no test coverage detected