| 1 |
/* |
| 2 |
* Copyright © 2024 Collabora Ltd. |
| 3 |
* |
| 4 |
* Derived from tu_cmd_buffer.c which is: |
| 5 |
* Copyright © 2016 Red Hat. |
| 6 |
* Copyright © 2016 Bas Nieuwenhuizen |
| 7 |
* Copyright © 2015 Intel Corporation |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: MIT |
| 10 |
*/ |
| 11 |
|
| 12 |
#include "genxml/gen_macros.h" |
| 13 |
|
| 14 |
#include "panvk_buffer.h" |
| 15 |
#include "panvk_cmd_alloc.h" |
| 16 |
#include "panvk_cmd_buffer.h" |
| 17 |
#include "panvk_cmd_desc_state.h" |
| 18 |
#include "panvk_entrypoints.h" |
| 19 |
|
| 20 |
#include "pan_pool.h" |
| 21 |
|
| 22 |
#include "util/rounding.h" |
| 23 |
|
| 24 |
#include "vk_alloc.h" |
| 25 |
#include "vk_command_buffer.h" |
| 26 |
#include "vk_command_pool.h" |
| 27 |
|
| 28 |
static void |
| 29 |
cmd_desc_state_bind_sets(struct panvk_descriptor_state *desc_state, |
| 30 |
const VkBindDescriptorSetsInfoKHR *info) |
| 31 |
{ |
| 32 |
unsigned dynoffset_idx = 0; |
| 33 |
for (unsigned i = 0; i < info->descriptorSetCount; ++i) { |
| 34 |
unsigned set_idx = i + info->firstSet; |
| 35 |
VK_FROM_HANDLE(panvk_descriptor_set, set, info->pDescriptorSets[i]); |
| 36 |
|
| 37 |
/* Invalidate the push set. */ |
| 38 |
if (desc_state->sets[set_idx] && |
| 39 |
desc_state->sets[set_idx] == desc_state->push_sets[set_idx]) |
| 40 |
desc_state->push_sets[set_idx]->descs.dev = 0; |
| 41 |
|
| 42 |
desc_state->sets[set_idx] = set; |
| 43 |
|
| 44 |
if (set) { |
| 45 |
for (unsigned b = 0; b < set->layout->dyn_buf_count; b++) { |
| 46 |
desc_state->dyn_buf_offsets[set_idx][b] = |
| 47 |
info->pDynamicOffsets[dynoffset_idx++]; |
| 48 |
} |
| 49 |
desc_state->dyn_ssbos[set_idx] = set->layout->dyn_ssbos; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
assert(dynoffset_idx == info->dynamicOffsetCount); |
| 54 |
} |
| 55 |
|
| 56 |
static struct panvk_descriptor_set * |
| 57 |
cmd_get_push_desc_set(struct vk_command_buffer *vk_cmdbuf, |
| 58 |
struct panvk_descriptor_state *desc_state, |
| 59 |
uint32_t set_idx) |
| 60 |
{ |
| 61 |
struct panvk_cmd_buffer *cmdbuf = |
| 62 |
container_of(vk_cmdbuf, struct panvk_cmd_buffer, vk); |
| 63 |
struct panvk_cmd_pool *pool = |
| 64 |
container_of(cmdbuf->vk.pool, struct panvk_cmd_pool, vk); |
| 65 |
struct panvk_push_set *push_set; |
| 66 |
|
| 67 |
assert(set_idx < MAX_SETS); |
| 68 |
|
| 69 |
if (likely(desc_state->push_sets[set_idx])) { |
| 70 |
push_set = container_of(desc_state->push_sets[set_idx], |
| 71 |
struct panvk_push_set, set); |
| 72 |
} else if (!list_is_empty(&pool->push_sets)) { |
| 73 |
push_set = |
| 74 |
list_first_entry(&pool->push_sets, struct panvk_push_set, base.node); |
| 75 |
list_del(&push_set->base.node); |
| 76 |
list_addtail(&push_set->base.node, &cmdbuf->push_sets); |
| 77 |
memset(push_set->descs, 0, sizeof(push_set->descs)); |
| 78 |
} else { |
| 79 |
push_set = vk_zalloc(&pool->vk.alloc, sizeof(*push_set), 8, |
| 80 |
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| 81 |
if (unlikely(!push_set)) { |
| 82 |
vk_command_buffer_set_error(&cmdbuf->vk, VK_ERROR_OUT_OF_HOST_MEMORY); |
| 83 |
return NULL; |
| 84 |
} |
| 85 |
list_addtail(&push_set->base.node, &cmdbuf->push_sets); |
| 86 |
} |
| 87 |
|
| 88 |
if (desc_state->push_sets[set_idx] == NULL) { |
| 89 |
desc_state->push_sets[set_idx] = &push_set->set; |
| 90 |
push_set->set.descs.host = push_set->descs; |
| 91 |
} |
| 92 |
|
| 93 |
struct panvk_descriptor_set *set = desc_state->push_sets[set_idx]; |
| 94 |
|
| 95 |
/* Pushing descriptors replaces whatever sets are bound */ |
| 96 |
desc_state->sets[set_idx] = set; |
| 97 |
|
| 98 |
BITSET_SET(desc_state->dirty_push_sets, set_idx); |
| 99 |
return set; |
| 100 |
} |
| 101 |
|
| 102 |
#if PAN_ARCH < 9 |
| 103 |
VkResult |
| 104 |
panvk_per_arch(cmd_prepare_dyn_ssbos)( |
| 105 |
struct panvk_cmd_buffer *cmdbuf, |
| 106 |
const struct panvk_descriptor_state *desc_state, |
| 107 |
const struct panvk_shader_variant *shader, |
| 108 |
struct panvk_shader_desc_state *shader_desc_state) |
| 109 |
{ |
| 110 |
shader_desc_state->dyn_ssbos = 0; |
| 111 |
|
| 112 |
if (!shader || !shader->desc_info.dyn_ssbos.count) |
| 113 |
return VK_SUCCESS; |
| 114 |
|
| 115 |
struct pan_ptr ptr = panvk_cmd_alloc_dev_mem( |
| 116 |
cmdbuf, desc, shader->desc_info.dyn_ssbos.count * PANVK_DESCRIPTOR_SIZE, |
| 117 |
PANVK_DESCRIPTOR_SIZE); |
| 118 |
if (!ptr.gpu) |
| 119 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 120 |
|
| 121 |
struct panvk_ssbo_addr *ssbos = ptr.cpu; |
| 122 |
for (uint32_t i = 0; i < shader->desc_info.dyn_ssbos.count; i++) { |
| 123 |
uint32_t src_handle = shader->desc_info.dyn_ssbos.map[i]; |
| 124 |
uint32_t set_idx = COPY_DESC_HANDLE_EXTRACT_TABLE(src_handle); |
| 125 |
uint32_t dyn_buf_idx = COPY_DESC_HANDLE_EXTRACT_INDEX(src_handle); |
| 126 |
const struct panvk_descriptor_set *set = desc_state->sets[set_idx]; |
| 127 |
const uint32_t dyn_buf_offset = |
| 128 |
desc_state->dyn_buf_offsets[set_idx][dyn_buf_idx]; |
| 129 |
|
| 130 |
assert(set_idx < MAX_SETS); |
| 131 |
assert(set); |
| 132 |
|
| 133 |
ssbos[i] = (struct panvk_ssbo_addr){ |
| 134 |
.base_addr = set->dyn_bufs[dyn_buf_idx].dev_addr + dyn_buf_offset, |
| 135 |
.size = set->dyn_bufs[dyn_buf_idx].size, |
| 136 |
}; |
| 137 |
} |
| 138 |
|
| 139 |
shader_desc_state->dyn_ssbos = ptr.gpu; |
| 140 |
return VK_SUCCESS; |
| 141 |
} |
| 142 |
|
| 143 |
static void |
| 144 |
panvk_cmd_fill_dyn_ubos(const struct panvk_descriptor_state *desc_state, |
| 145 |
const struct panvk_shader_variant *shader, |
| 146 |
struct mali_uniform_buffer_packed *ubos, |
| 147 |
uint32_t ubo_count) |
| 148 |
{ |
| 149 |
for (uint32_t i = 0; i < shader->desc_info.dyn_ubos.count; i++) { |
| 150 |
uint32_t src_handle = shader->desc_info.dyn_ubos.map[i]; |
| 151 |
uint32_t set_idx = COPY_DESC_HANDLE_EXTRACT_TABLE(src_handle); |
| 152 |
uint32_t dyn_buf_idx = COPY_DESC_HANDLE_EXTRACT_INDEX(src_handle); |
| 153 |
uint32_t ubo_idx = |
| 154 |
i + shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_UBO]; |
| 155 |
const struct panvk_descriptor_set *set = desc_state->sets[set_idx]; |
| 156 |
const uint32_t dyn_buf_offset = |
| 157 |
desc_state->dyn_buf_offsets[set_idx][dyn_buf_idx]; |
| 158 |
|
| 159 |
assert(set_idx < MAX_SETS); |
| 160 |
assert(set); |
| 161 |
assert(ubo_idx < ubo_count); |
| 162 |
|
| 163 |
pan_pack(&ubos[ubo_idx], UNIFORM_BUFFER, cfg) { |
| 164 |
cfg.pointer = set->dyn_bufs[dyn_buf_idx].dev_addr + dyn_buf_offset; |
| 165 |
cfg.entries = DIV_ROUND_UP(set->dyn_bufs[dyn_buf_idx].size, 16); |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
VkResult |
| 171 |
panvk_per_arch(cmd_prepare_shader_desc_tables)( |
| 172 |
struct panvk_cmd_buffer *cmdbuf, |
| 173 |
const struct panvk_descriptor_state *desc_state, |
| 174 |
const struct panvk_shader_variant *shader, |
| 175 |
struct panvk_shader_desc_state *shader_desc_state) |
| 176 |
{ |
| 177 |
memset(shader_desc_state->tables, 0, sizeof(shader_desc_state->tables)); |
| 178 |
shader_desc_state->img_attrib_table = 0; |
| 179 |
|
| 180 |
if (!shader) |
| 181 |
return VK_SUCCESS; |
| 182 |
|
| 183 |
for (uint32_t i = 0; i < ARRAY_SIZE(shader->desc_info.others.count); i++) { |
| 184 |
uint32_t desc_count = |
| 185 |
shader->desc_info.others.count[i] + |
| 186 |
(i == PANVK_BIFROST_DESC_TABLE_UBO ? shader->desc_info.dyn_ubos.count |
| 187 |
: 0); |
| 188 |
uint32_t desc_size = |
| 189 |
i == PANVK_BIFROST_DESC_TABLE_UBO ? 8 : PANVK_DESCRIPTOR_SIZE; |
| 190 |
|
| 191 |
if (!desc_count) |
| 192 |
continue; |
| 193 |
|
| 194 |
struct pan_ptr ptr = panvk_cmd_alloc_dev_mem( |
| 195 |
cmdbuf, desc, desc_count * desc_size, PANVK_DESCRIPTOR_SIZE); |
| 196 |
if (!ptr.gpu) |
| 197 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 198 |
|
| 199 |
shader_desc_state->tables[i] = ptr.gpu; |
| 200 |
|
| 201 |
if (i == PANVK_BIFROST_DESC_TABLE_UBO) |
| 202 |
panvk_cmd_fill_dyn_ubos(desc_state, shader, ptr.cpu, desc_count); |
| 203 |
|
| 204 |
/* The image table being actually the attribute table, this is handled |
| 205 |
* separately for vertex shaders. */ |
| 206 |
if (i == PANVK_BIFROST_DESC_TABLE_IMG && |
| 207 |
shader->info.stage != MESA_SHADER_VERTEX) { |
| 208 |
ptr = panvk_cmd_alloc_desc_array(cmdbuf, desc_count, ATTRIBUTE); |
| 209 |
if (!ptr.gpu) |
| 210 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 211 |
|
| 212 |
shader_desc_state->img_attrib_table = ptr.gpu; |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
uint32_t tex_count = |
| 217 |
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_TEXTURE]; |
| 218 |
uint32_t sampler_count = |
| 219 |
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_SAMPLER]; |
| 220 |
|
| 221 |
if (tex_count && !sampler_count) { |
| 222 |
struct pan_ptr sampler = panvk_cmd_alloc_desc(cmdbuf, SAMPLER); |
| 223 |
if (!sampler.gpu) |
| 224 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 225 |
|
| 226 |
/* Emit a dummy sampler if we have to. */ |
| 227 |
pan_cast_and_pack(sampler.cpu, SAMPLER, cfg) { |
| 228 |
cfg.clamp_integer_array_indices = false; |
| 229 |
} |
| 230 |
|
| 231 |
shader_desc_state->tables[PANVK_BIFROST_DESC_TABLE_SAMPLER] = sampler.gpu; |
| 232 |
} |
| 233 |
|
| 234 |
return VK_SUCCESS; |
| 235 |
} |
| 236 |
#else |
| 237 |
void |
| 238 |
panvk_per_arch(cmd_fill_dyn_bufs)( |
| 239 |
const struct panvk_descriptor_state *desc_state, |
| 240 |
const struct panvk_shader_variant *shader, |
| 241 |
struct mali_buffer_packed *buffers) |
| 242 |
{ |
| 243 |
if (!shader) |
| 244 |
return; |
| 245 |
|
| 246 |
for (uint32_t i = 0; i < shader->desc_info.dyn_bufs.count; i++) { |
| 247 |
uint32_t src_handle = shader->desc_info.dyn_bufs.map[i]; |
| 248 |
uint32_t set_idx = COPY_DESC_HANDLE_EXTRACT_TABLE(src_handle); |
| 249 |
uint32_t dyn_buf_idx = COPY_DESC_HANDLE_EXTRACT_INDEX(src_handle); |
| 250 |
const struct panvk_descriptor_set *set = desc_state->sets[set_idx]; |
| 251 |
const uint32_t dyn_buf_offset = |
| 252 |
desc_state->dyn_buf_offsets[set_idx][dyn_buf_idx]; |
| 253 |
const bool is_ssbo = |
| 254 |
desc_state->dyn_ssbos[set_idx] & BITFIELD_BIT(dyn_buf_idx); |
| 255 |
|
| 256 |
assert(set_idx < MAX_SETS); |
| 257 |
assert(set); |
| 258 |
|
| 259 |
pan_pack(&buffers[i], BUFFER, cfg) { |
| 260 |
cfg.size = align(set->dyn_bufs[dyn_buf_idx].size, is_ssbo ? 4 : 16); |
| 261 |
cfg.address = set->dyn_bufs[dyn_buf_idx].dev_addr + dyn_buf_offset; |
| 262 |
} |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
VkResult |
| 267 |
panvk_per_arch(cmd_prepare_shader_res_table)( |
| 268 |
struct panvk_cmd_buffer *cmdbuf, |
| 269 |
const struct panvk_descriptor_state *desc_state, |
| 270 |
const struct panvk_shader_variant *shader, |
| 271 |
struct panvk_shader_desc_state *shader_desc_state, uint32_t repeat_count) |
| 272 |
{ |
| 273 |
if (!shader) { |
| 274 |
shader_desc_state->res_table = 0; |
| 275 |
return VK_SUCCESS; |
| 276 |
} |
| 277 |
|
| 278 |
uint32_t first_unused_set = util_last_bit(shader->desc_info.used_set_mask); |
| 279 |
uint32_t res_count = |
| 280 |
ALIGN_POT(1 + first_unused_set, MALI_RESOURCE_TABLE_SIZE_ALIGNMENT); |
| 281 |
struct pan_ptr ptr = |
| 282 |
panvk_cmd_alloc_desc_array(cmdbuf, res_count * repeat_count, RESOURCE); |
| 283 |
if (!ptr.gpu) |
| 284 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 285 |
|
| 286 |
struct mali_resource_packed *res_table = ptr.cpu; |
| 287 |
|
| 288 |
for (uint32_t r = 0; r < repeat_count; r++) { |
| 289 |
uint64_t drv_set_addr = shader_desc_state->driver_set.dev_addr + |
| 290 |
(r * shader_desc_state->driver_set.size); |
| 291 |
/* First entry is the driver set table, where we store the vertex |
| 292 |
* attributes, the dummy sampler, the dynamic buffers and the vertex |
| 293 |
* buffers. */ |
| 294 |
pan_pack(&res_table[0], RESOURCE, cfg) { |
| 295 |
cfg.address = drv_set_addr; |
| 296 |
cfg.size = shader_desc_state->driver_set.size; |
| 297 |
cfg.contains_descriptors = cfg.size > 0; |
| 298 |
} |
| 299 |
|
| 300 |
for (uint32_t i = 0; i < first_unused_set; i++) { |
| 301 |
const struct panvk_descriptor_set *set = desc_state->sets[i]; |
| 302 |
|
| 303 |
pan_pack(&res_table[i + 1], RESOURCE, cfg) { |
| 304 |
if (shader->desc_info.used_set_mask & BITFIELD_BIT(i)) { |
| 305 |
cfg.address = set->descs.dev; |
| 306 |
cfg.contains_descriptors = true; |
| 307 |
cfg.size = set->desc_count * PANVK_DESCRIPTOR_SIZE; |
| 308 |
} else { |
| 309 |
cfg.address = 0; |
| 310 |
cfg.contains_descriptors = false; |
| 311 |
cfg.size = 0; |
| 312 |
} |
| 313 |
} |
| 314 |
} |
| 315 |
for (uint32_t i = first_unused_set + 1; i < res_count; i++) { |
| 316 |
pan_pack(&res_table[i], RESOURCE, cfg) { |
| 317 |
cfg.address = 0; |
| 318 |
cfg.contains_descriptors = false; |
| 319 |
cfg.size = 0; |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
res_table += res_count; |
| 324 |
} |
| 325 |
|
| 326 |
shader_desc_state->res_table = ptr.gpu | res_count; |
| 327 |
return VK_SUCCESS; |
| 328 |
} |
| 329 |
#endif |
| 330 |
|
| 331 |
VkResult |
| 332 |
panvk_per_arch(cmd_prepare_push_descs)(struct panvk_cmd_buffer *cmdbuf, |
| 333 |
struct panvk_descriptor_state *desc_state, |
| 334 |
uint32_t used_set_mask) |
| 335 |
{ |
| 336 |
for (unsigned i = 0; i < ARRAY_SIZE(desc_state->push_sets); i++) { |
| 337 |
struct panvk_descriptor_set *push_set = desc_state->push_sets[i]; |
| 338 |
|
| 339 |
if (!(used_set_mask & BITFIELD_BIT(i)) || !push_set || |
| 340 |
desc_state->sets[i] != push_set || push_set->descs.dev || |
| 341 |
!BITSET_TEST(desc_state->dirty_push_sets, i)) |
| 342 |
continue; |
| 343 |
|
| 344 |
struct pan_ptr ptr = panvk_cmd_alloc_dev_mem( |
| 345 |
cmdbuf, desc, push_set->desc_count * PANVK_DESCRIPTOR_SIZE, |
| 346 |
PANVK_DESCRIPTOR_SIZE); |
| 347 |
if (!ptr.gpu) |
| 348 |
return VK_ERROR_OUT_OF_DEVICE_MEMORY; |
| 349 |
|
| 350 |
memcpy(ptr.cpu, push_set->descs.host, |
| 351 |
push_set->desc_count * PANVK_DESCRIPTOR_SIZE); |
| 352 |
push_set->descs.dev = ptr.gpu; |
| 353 |
|
| 354 |
BITSET_CLEAR(desc_state->dirty_push_sets, i); |
| 355 |
} |
| 356 |
|
| 357 |
return VK_SUCCESS; |
| 358 |
} |
| 359 |
|
| 360 |
VKAPI_ATTR void VKAPI_CALL |
| 361 |
panvk_per_arch(CmdBindDescriptorSets2KHR)( |
| 362 |
VkCommandBuffer commandBuffer, |
| 363 |
const VkBindDescriptorSetsInfoKHR *pBindDescriptorSetsInfo) |
| 364 |
{ |
| 365 |
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer); |
| 366 |
|
| 367 |
/* TODO: Invalidate only if the shader tables are disturbed */ |
| 368 |
if (pBindDescriptorSetsInfo->stageFlags & VK_SHADER_STAGE_ALL_GRAPHICS) { |
| 369 |
cmd_desc_state_bind_sets(&cmdbuf->state.gfx.desc_state, |
| 370 |
pBindDescriptorSetsInfo); |
| 371 |
|
| 372 |
gfx_state_set_dirty(cmdbuf, DESC_STATE); |
| 373 |
} |
| 374 |
|
| 375 |
if (pBindDescriptorSetsInfo->stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) { |
| 376 |
cmd_desc_state_bind_sets(&cmdbuf->state.compute.desc_state, |
| 377 |
pBindDescriptorSetsInfo); |
| 378 |
|
| 379 |
compute_state_set_dirty(cmdbuf, DESC_STATE); |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
static void |
| 384 |
push_desc_set_write(struct panvk_cmd_buffer *cmd, |
| 385 |
struct panvk_descriptor_state *desc, |
| 386 |
const VkPushDescriptorSetInfoKHR *info) |
| 387 |
{ |
| 388 |
VK_FROM_HANDLE(vk_pipeline_layout, playout, info->layout); |
| 389 |
|
| 390 |
const struct panvk_descriptor_set_layout *set_layout = |
| 391 |
to_panvk_descriptor_set_layout(playout->set_layouts[info->set]); |
| 392 |
|
| 393 |
struct panvk_descriptor_set *push_set = |
| 394 |
cmd_get_push_desc_set(&cmd->vk, desc, info->set); |
| 395 |
if (!push_set) |
| 396 |
return; |
| 397 |
|
| 398 |
push_set->layout = set_layout; |
| 399 |
push_set->desc_count = set_layout->desc_count; |
| 400 |
|
| 401 |
for (uint32_t i = 0; i < info->descriptorWriteCount; i++) |
| 402 |
panvk_per_arch(descriptor_set_write)(push_set, |
| 403 |
&info->pDescriptorWrites[i], true); |
| 404 |
|
| 405 |
push_set->descs.dev = 0; |
| 406 |
push_set->layout = NULL; |
| 407 |
} |
| 408 |
|
| 409 |
VKAPI_ATTR void VKAPI_CALL |
| 410 |
panvk_per_arch(CmdPushDescriptorSet2KHR)( |
| 411 |
VkCommandBuffer commandBuffer, |
| 412 |
const VkPushDescriptorSetInfoKHR *pPushDescriptorSetInfo) |
| 413 |
{ |
| 414 |
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer); |
| 415 |
|
| 416 |
if (pPushDescriptorSetInfo->stageFlags & VK_SHADER_STAGE_ALL_GRAPHICS) { |
| 417 |
push_desc_set_write(cmdbuf, &cmdbuf->state.gfx.desc_state, |
| 418 |
pPushDescriptorSetInfo); |
| 419 |
|
| 420 |
gfx_state_set_dirty(cmdbuf, DESC_STATE); |
| 421 |
} |
| 422 |
|
| 423 |
if (pPushDescriptorSetInfo->stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) { |
| 424 |
push_desc_set_write(cmdbuf, &cmdbuf->state.compute.desc_state, |
| 425 |
pPushDescriptorSetInfo); |
| 426 |
|
| 427 |
compute_state_set_dirty(cmdbuf, DESC_STATE); |
| 428 |
} |
| 429 |
} |
| 430 |
|
| 431 |
VKAPI_ATTR void VKAPI_CALL |
| 432 |
panvk_per_arch(CmdPushDescriptorSetWithTemplate2KHR)( |
| 433 |
VkCommandBuffer commandBuffer, const VkPushDescriptorSetWithTemplateInfoKHR |
| 434 |
*pPushDescriptorSetWithTemplateInfo) |
| 435 |
{ |
| 436 |
VK_FROM_HANDLE(vk_descriptor_update_template, template, |
| 437 |
pPushDescriptorSetWithTemplateInfo->descriptorUpdateTemplate); |
| 438 |
VK_FROM_HANDLE(panvk_cmd_buffer, cmdbuf, commandBuffer); |
| 439 |
VK_FROM_HANDLE(vk_pipeline_layout, playout, |
| 440 |
pPushDescriptorSetWithTemplateInfo->layout); |
| 441 |
const uint32_t set = pPushDescriptorSetWithTemplateInfo->set; |
| 442 |
const struct panvk_descriptor_set_layout *set_layout = |
| 443 |
to_panvk_descriptor_set_layout(playout->set_layouts[set]); |
| 444 |
struct panvk_descriptor_state *desc_state = |
| 445 |
panvk_cmd_get_desc_state(cmdbuf, template->bind_point); |
| 446 |
struct panvk_descriptor_set *push_set = |
| 447 |
cmd_get_push_desc_set(&cmdbuf->vk, desc_state, set); |
| 448 |
if (!push_set) |
| 449 |
return; |
| 450 |
|
| 451 |
push_set->layout = set_layout; |
| 452 |
push_set->desc_count = set_layout->desc_count; |
| 453 |
|
| 454 |
panvk_per_arch(descriptor_set_write_template)( |
| 455 |
push_set, template, pPushDescriptorSetWithTemplateInfo->pData, true); |
| 456 |
|
| 457 |
push_set->descs.dev = 0; |
| 458 |
push_set->layout = NULL; |
| 459 |
|
| 460 |
if (template->bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) |
| 461 |
gfx_state_set_dirty(cmdbuf, DESC_STATE); |
| 462 |
else |
| 463 |
compute_state_set_dirty(cmdbuf, DESC_STATE); |
| 464 |
} |