diff options
-rwxr-xr-x | vulkan_compute_minimal_example.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/vulkan_compute_minimal_example.c b/vulkan_compute_minimal_example.c index 26f7e34..3e7d60c 100755 --- a/vulkan_compute_minimal_example.c +++ b/vulkan_compute_minimal_example.c @@ -15,12 +15,12 @@ cat <<EOF >~module.comp #version 450 -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; layout(binding = 0) buffer output_buffer { uint values_out[16]; }; void main() { - for (uint i = 0; i < 16; i++) values_out[i] = i; + atomicAdd(values_out[gl_GlobalInvocationID.x / 16], gl_GlobalInvocationID.x); } EOF @@ -185,10 +185,10 @@ i32 main(i32 argc, c8 **argv) { // Create buffer { if (vkCreateBuffer(device, &(VkBufferCreateInfo) { - .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, - .size = BUFFER_SIZE, - .usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, - .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, + .size = BUFFER_SIZE, + .usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, }, NULL, &buffer) != VK_SUCCESS) { printf("vkCreateBuffer failed.\n"); status = -1; @@ -417,7 +417,7 @@ i32 main(i32 argc, c8 **argv) { printf("Data:"); for (u32 i = 0; i < BUFFER_SIZE / 4; i++) - printf(" %2d", (int) p[i]); + printf(" %d", (int) p[i]); printf("\n"); vkUnmapMemory(device, buffer_memory); |