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

Function SetComputeSampler

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

sets texture samplers in a compute program * Sets texture samplers in a compute program, if the samplers exist. Use this function to change the settings of texture samplers. * To set actual textures that should be bound to the samplers, use the `compute.set_textures` function instead. * * @name compute.set_samplers * * @param path [type:hash|string] The path to the re

Source from the content-addressed store, hash-verified

367 * ```
368 */
369 static int SetComputeSampler(lua_State* L, ComputeResource* compute_res, dmhash_t name_hash, int args_index)
370 {
371 args_index = args_index < 0 ? lua_gettop(L) + args_index + 1 : args_index;
372
373 uint32_t unit = dmRender::GetComputeProgramSamplerUnit(compute_res->m_Program, name_hash);
374 if (unit == dmRender::INVALID_SAMPLER_UNIT)
375 {
376 return luaL_error(L, "Compute program sampler '%s' not found", dmHashReverseSafe64(name_hash));
377 }
378
379 dmRender::HSampler sampler = dmRender::GetComputeProgramSampler(compute_res->m_Program, unit);
380
381 dmRender::SamplerInfo sampler_info = {};
382 dmRender::GetSamplerInfo(sampler, &sampler_info);
383
384 luaL_checktype(L, args_index, LUA_TTABLE);
385 lua_pushvalue(L, args_index);
386
387 GetSamplerParametersFromLua(L, &sampler_info.m_UWrap, &sampler_info.m_VWrap, &sampler_info.m_MinFilter, &sampler_info.m_MagFilter, &sampler_info.m_MaxAnisotropy);
388
389 lua_pop(L, 1);
390
391 dmRender::SetComputeProgramSampler(compute_res->m_Program, name_hash, unit, sampler_info.m_UWrap, sampler_info.m_VWrap, sampler_info.m_MinFilter, sampler_info.m_MagFilter, sampler_info.m_MaxAnisotropy);
392
393 return 0;
394 }
395
396 static int Compute_SetSamplers(lua_State* L)
397 {

Callers 1

Compute_SetSamplersFunction · 0.85

Calls 10

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
dmHashReverseSafe64Function · 0.85
GetComputeProgramSamplerFunction · 0.85
GetSamplerInfoFunction · 0.85
luaL_checktypeFunction · 0.85
lua_pushvalueFunction · 0.85
SetComputeProgramSamplerFunction · 0.85

Tested by

no test coverage detected