1/* 2 * Copyright 2024 Valve Corporation 3 * SPDX-License-Identifier: MIT 4 */ 5#include "libagx.h" 6#include "draws.h" 7 8/* 9 * To implement drawIndirectCount generically, we dispatch a kernel to 10 * clone-and-patch the indirect buffer, predicating out draws as appropriate. 11 */ 12void 13libagx_predicate_indirect(constant struct libagx_predicate_indirect_push *push, 14 uint draw, bool indexed) 15{ 16 uint words = indexed ? 5 : 4; 17 global uint *out = &push->out[draw * words]; 18 constant uint *in = &push->in[draw * push->stride_el]; 19 bool enabled = draw < *(push->draw_count); 20 21 /* Copy enabled draws, zero predicated draws. */ 22 for (uint i = 0; i < words; ++i) { 23 out[i] = enabled ? in[i] : 0; 24 } 25} 26