set the current compute program * * The name of the compute program must be specified in the ".render" resource set * in the "game.project" setting. If nil (or no arguments) are passed to this function, * the current compute program will instead be disabled. * * @name render.set_compute * @param compute [type:string|hash|nil] compute id to use, or nil to disable
| 2884 | * ``` |
| 2885 | */ |
| 2886 | static int RenderScript_SetCompute(lua_State* L) |
| 2887 | { |
| 2888 | DM_LUA_STACK_CHECK(L, 0); |
| 2889 | |
| 2890 | RenderScriptInstance* i = RenderScriptInstance_Check(L); |
| 2891 | void* compute_program = 0x0; |
| 2892 | |
| 2893 | CHECK_COMPUTE_SUPPORT(i); |
| 2894 | |
| 2895 | if (lua_gettop(L) > 0 && !lua_isnil(L, 1)) |
| 2896 | { |
| 2897 | dmhash_t program_id = dmScript::CheckHashOrString(L, 1); |
| 2898 | RenderResource* render_resource = i->m_RenderResources.Get(program_id); |
| 2899 | |
| 2900 | if (render_resource == 0x0) |
| 2901 | { |
| 2902 | return DM_LUA_ERROR("Could not find compute program '%s'", dmHashReverseSafe64(program_id)); |
| 2903 | } |
| 2904 | else if (render_resource->m_Type != RENDER_RESOURCE_TYPE_COMPUTE) |
| 2905 | { |
| 2906 | return DM_LUA_ERROR("Render resource is not a compute program."); |
| 2907 | } |
| 2908 | |
| 2909 | compute_program = (void*) render_resource->m_Resource; |
| 2910 | } |
| 2911 | |
| 2912 | if (InsertCommand(i, Command(COMMAND_TYPE_SET_COMPUTE, (uint64_t) compute_program))) |
| 2913 | { |
| 2914 | return 0; |
| 2915 | } |
| 2916 | return DM_LUA_ERROR("Command buffer is full (%d).", i->m_CommandBuffer.Capacity()); |
| 2917 | } |
| 2918 | |
| 2919 | /*# dispatches the currently enabled compute program |
| 2920 | * Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes |
nothing calls this directly
no test coverage detected