|
|
@ -329,39 +329,55 @@ VkResult create_layer(
|
|
|
|
uint32_t max_codes = (input->num_codes > input->max_codes) ? input->num_codes : input->max_codes;
|
|
|
|
uint32_t max_codes = (input->num_codes > input->max_codes) ? input->num_codes : input->max_codes;
|
|
|
|
uint32_t max_drawables = (input->num_drawables > input->max_drawables) ? input->num_drawables : input->max_drawables;
|
|
|
|
uint32_t max_drawables = (input->num_drawables > input->max_drawables) ? input->num_drawables : input->max_drawables;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(max_strings > 0) {
|
|
|
|
|
|
|
|
container->layers[index].strings_buffer = malloc(sizeof(GPUString)*max_strings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(max_drawables > 0) {
|
|
|
|
|
|
|
|
container->layers[index].drawables_buffer = malloc(sizeof(GPUDrawable)*max_drawables);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(max_codes > 0) {
|
|
|
|
|
|
|
|
container->layers[index].codes_buffer = malloc(sizeof(uint32_t)*max_codes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
|
|
|
|
for(uint32_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, sizeof(GPULayer), &container->layers[index].layer[i], &container->layers[index].layer_memory[i]));
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, sizeof(GPULayer), &container->layers[index].layer[i], &container->layers[index].layer_memory[i]));
|
|
|
|
if(max_strings > 0) {
|
|
|
|
if(max_strings > 0) {
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(GPUString)*max_strings, &container->layers[index].strings[i], &container->layers[index].strings_memory[i]));
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(GPUString)*max_strings, &container->layers[index].strings[i], &container->layers[index].strings_memory[i]));
|
|
|
|
container->layers[index].strings_buffer = malloc(sizeof(GPUString)*max_strings);
|
|
|
|
VkDeviceAddress address = buffer_address(gpu->device, container->layers[index].strings[i]);
|
|
|
|
|
|
|
|
add_transfer(
|
|
|
|
|
|
|
|
&address,
|
|
|
|
|
|
|
|
container->layers[index].layer[i],
|
|
|
|
|
|
|
|
offsetof(GPULayer, strings),
|
|
|
|
|
|
|
|
sizeof(VkDeviceAddress),
|
|
|
|
|
|
|
|
i,
|
|
|
|
|
|
|
|
gpu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(max_codes + max_drawables > 0) {
|
|
|
|
if(max_codes + max_drawables > 0) {
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(GPUDrawable)*(max_drawables + max_codes), &container->layers[index].drawables[i], &container->layers[index].drawables_memory[i]));
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(GPUDrawable)*(max_drawables + max_codes), &container->layers[index].drawables[i], &container->layers[index].drawables_memory[i]));
|
|
|
|
container->layers[index].drawables_buffer = malloc(sizeof(GPUDrawable)*max_drawables);
|
|
|
|
VkDeviceAddress address = buffer_address(gpu->device, container->layers[index].drawables[i]);
|
|
|
|
|
|
|
|
add_transfer(
|
|
|
|
|
|
|
|
&address,
|
|
|
|
|
|
|
|
container->layers[index].layer[i],
|
|
|
|
|
|
|
|
offsetof(GPULayer, drawables),
|
|
|
|
|
|
|
|
sizeof(VkDeviceAddress),
|
|
|
|
|
|
|
|
i,
|
|
|
|
|
|
|
|
gpu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(max_codes > 0) {
|
|
|
|
if(max_codes > 0) {
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(uint32_t)*max_codes, &container->layers[index].codes[i], &container->layers[index].codes_memory[i]));
|
|
|
|
VK_RESULT(create_storage_buffer(gpu->allocator, 0, sizeof(uint32_t)*max_codes, &container->layers[index].codes[i], &container->layers[index].codes_memory[i]));
|
|
|
|
container->layers[index].codes_buffer = malloc(sizeof(uint32_t)*max_codes);
|
|
|
|
VkDeviceAddress address = buffer_address(gpu->device, container->layers[index].codes[i]);
|
|
|
|
|
|
|
|
add_transfer(
|
|
|
|
|
|
|
|
&address,
|
|
|
|
|
|
|
|
container->layers[index].layer[i],
|
|
|
|
|
|
|
|
offsetof(GPULayer, codes),
|
|
|
|
|
|
|
|
sizeof(VkDeviceAddress),
|
|
|
|
|
|
|
|
i,
|
|
|
|
|
|
|
|
gpu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(max_strings > 0) {
|
|
|
|
|
|
|
|
container->layers[index].data.strings = buffer_address(gpu->device, container->layers[index].strings[i]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
container->layers[index].data.strings = 0x00000000;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(max_codes > 0) {
|
|
|
|
|
|
|
|
container->layers[index].data.codes = buffer_address(gpu->device, container->layers[index].codes[i]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
container->layers[index].data.codes = 0x00000000;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(max_codes + max_drawables > 0) {
|
|
|
|
|
|
|
|
container->layers[index].data.drawables = buffer_address(gpu->device, container->layers[index].drawables[i]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
container->layers[index].data.drawables = 0x00000000;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
container->layers[index].address[i] = buffer_address(gpu->device, container->layers[index].layer[i]);
|
|
|
|
container->layers[index].address[i] = buffer_address(gpu->device, container->layers[index].layer[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(stderr, "Created layer with storage buffers %p/%p\n", container->layers[index].layer[0], container->layers[index].layer[1]);
|
|
|
|
fprintf(stderr, "Created layer with storage buffers %p/%p\n", container->layers[index].layer[0], container->layers[index].layer[1]);
|
|
|
@ -391,7 +407,7 @@ VkResult create_layer(
|
|
|
|
container->layers[index].data.max_strings = max_strings;
|
|
|
|
container->layers[index].data.max_strings = max_strings;
|
|
|
|
container->layers[index].data.max_codes = max_codes;
|
|
|
|
container->layers[index].data.max_codes = max_codes;
|
|
|
|
container->layers[index].data.num_drawables = max_drawables;
|
|
|
|
container->layers[index].data.num_drawables = max_drawables;
|
|
|
|
add_transfers(&container->layers[index].data, container->layers[index].layer, 0, sizeof(GPULayer)-sizeof(VkDeviceAddress), gpu);
|
|
|
|
add_transfers(&container->layers[index].data, container->layers[index].layer, 0, sizeof(GPULayer)-4*sizeof(VkDeviceAddress), gpu);
|
|
|
|
|
|
|
|
|
|
|
|
if(input->num_strings > 0) {
|
|
|
|
if(input->num_strings > 0) {
|
|
|
|
memcpy(container->layers[index].strings_buffer, input->strings, sizeof(GPUString)*input->num_strings);
|
|
|
|
memcpy(container->layers[index].strings_buffer, input->strings, sizeof(GPUString)*input->num_strings);
|
|
|
|