A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/uNetworking/libvc below:

uNetworking/libvc: Vulkan Compute for C++ (experimentation project)

Vulkan Compute for C++ (experimentation project)

libvc is a GPGPU engine based on Vulkan. It eats SPIR-V compute shaders and executes them without any graphical context, much like OpenCL. The interface is very abstract and allows you to get to work with your shaders as quickly as possible. With the current state of compute shaders, you should be able to achieve ~OpenCL 1.2 feature parity.

Compute shaders are constantly being evolved and extended with new versions of OpenGL, GLSL and/or Vulkan. They are here to stay and will only become more competent with time.

The interface is still being designed. It will feature abstractions for devices, memory, buffers, shaders, etc.

DevicePool devicePool;
for (Device &device : devicePool.getDevices()) {
    cout << "Found device: " << device.getName() << " from vendor: 0x"
         << hex << device.getVendorId() << dec << endl;

    try {
            // Allocate a buffer & clear it
            Buffer buffer(device, sizeof(double) * 10240);
            buffer.fill(0);

            // Compile the compute shader & prepare to use the buffer as argument
            Program program(device, "shaders/comp.spv", {BUFFER});
            Arguments args(program, {buffer});

            // Create and build the command buffer, making use of the program and arguments
            CommandBuffer commands(device, program, args);
            for (int i = 0; i < 100000; i++) {
                commands.dispatch(10);
                commands.barrier();
            }
            commands.end();

            // Time the execution on the GPU
            for (int i = 0; i < 5; i++) {
                steady_clock::time_point start = steady_clock::now();
                device.submit(commands);
                device.wait();
                cout << duration_cast<milliseconds>(steady_clock::now() - start).count() << "ms" << endl;
            }

            // Download results and show the first scalar
            double results[10240];
            buffer.download(results);
            cout << "Result: " << results[0] << endl;

    } catch(vc::Error e) {
        cout << "vc::Error thrown" << endl;
    }
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4