Giter Club home page Giter Club logo

kdgpu's Introduction

KDGpu

KDGpu is a thin wrapper around Vulkan to make modern graphics easier to learn and use.

Introduction

Is KDGpu for me?

Have you ever wanted to be productive with Vulkan but can't get your head around the verbose syntax, managing object lifetimes, and the intricacies of just getting something working without drowning in synchronization and memory handling?

If the answer is yes, then KDGpu is the library for you!

KDGpu is a thin wrapper around Vulkan (and perhaps later other modern graphics APIs) with the aim of making modern graphics available to mortals and to massively reduce the amount of verbosity involved.

KDGpu also aims to make it easy to teach the concepts of modern graphics programming without having to be bogged down in the intricacies.

KDGpu is independent of any particular windowing system. You can use it purely with platform native APIs or you can checkout the included KDGpuExample library which makes it trivial to use KDGpu with KDGui::Window. Check out the handy KDBindings repository too for some more syntactic sugar.

In addition to being an enabler for Vulkan, the KDGpu project now also includes a new library, KDXr, which aims to be an enabler for OpenXR. Using the combination of KDGpu and KDXr allows application developers to very easily create AR and VR application experiences.

More information can be found in the documentation.

What does KDGpu provide?

  • The KDGpu library
  • The KDXr library to make OpenXR easier to use
  • An example framework called KDGpuExample that provides integration with KDGui to make it easy to experiment. Let us take care of the boring bits so you can make pretty pictures.
  • A set of illustrative examples showing how to use KDGpu for common rendering tasks.

How do I get up and running with KDGpu?

  • Install the Vulkan SDK, setup the runtime environment and verify the SDK as described in the Vulkan documentation
  • Clone this repository
  • Open up the directory in VS Code with the CMakeTools extension loaded
  • Configure and Build - all of the dependencies will be pulled down via CMake's FetchContent feature (see cmake/dependencies.cmake)
  • Try running the examples

What does KDGpu code look like?

A typical render function for KDGPu looks something like this:

auto opaquePass = commandRecorder.beginRenderPass(m_opaquePassOptions);
opaquePass.setPipeline(m_pipeline);
opaquePass.setVertexBuffer(0, m_buffer);
opaquePass.setBindGroup(0, m_textureBindGroup);
opaquePass.draw(DrawCommand{ .vertexCount = 4 });
renderImGuiOverlay(&opaquePass);
opaquePass.end();
m_commandBuffer = commandRecorder.finish();

Creating GPU resources is just as easy and intuitive. Creating a Buffer that resides on the GPU and can be uploaded to and used as a vertex buffer is as simple as:

const DeviceSize dataByteSize = vertexData.size() * sizeof(Vertex);
BufferOptions bufferOptions = {
    .size = dataByteSize,
    .usage = BufferUsageFlagBits::VertexBufferBit | BufferUsageFlagBits::TransferDstBit,
    .memoryUsage = MemoryUsage::GpuOnly
};
m_buffer = m_device.createBuffer(bufferOptions);

This pattern of using options structs and initializing them with C++20 designated initializers permeates through the API. It makes it easily discoverable, extensible and trivial to queue up for deferred invocations.

Uploading data to the above buffer is just as easy:

const BufferUploadOptions uploadOptions = {
    .destinationBuffer = m_buffer,
    .dstStages = PipelineStageFlagBit::VertexAttributeInputBit,
    .dstMask = AccessFlagBit::VertexAttributeReadBit,
    .data = vertexData.data(),
    .byteSize = dataByteSize
};
m_queue.uploadBufferData(uploadOptions);

Contact

Stay up-to-date with KDAB product announcements:

Licensing

KDGpu is © Klarälvdalens Datakonsult AB and is available under the terms of the MIT license.

Contact KDAB at [email protected] if you need different licensing options.

KDGpu includes these source files, also available under the terms of the MIT license:

doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD (C) 2016-2021 Viktor Kirilov [email protected]

Get Involved

Please submit your contributions or issue reports from our GitHub space at https://github.com/KDAB/KDGpu.

Contact [email protected] for more information.

About KDAB

KDGpu is supported and maintained by Klarälvdalens Datakonsult AB (KDAB).

The KDAB Group is the global No.1 software consultancy for Qt, C++ and OpenGL applications across desktop, embedded and mobile platforms.

The KDAB Group provides consulting and mentoring for developing Qt applications from scratch and in porting from all popular and legacy frameworks to Qt. We continue to help develop parts of Qt and are one of the major contributors to the Qt Project. We can give advanced or standard trainings anywhere around the globe on Qt as well as C++, OpenGL, 3D and more.

Please visit https://www.kdab.com to meet the people who write code like this.

kdgpu's People

Contributors

0x6e avatar agrael1 avatar alistair-baxter-kdab avatar bog-dan-ro avatar krf avatar lemirep avatar mkrus avatar morganbengtsson avatar mpersano avatar nicolas-guichard avatar redstrate avatar seanharmer avatar the-argus avatar winterz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kdgpu's Issues

Link minimal dependencies

Hello. Thank you for open-sourcing this library, the API is neat and I've enjoyed experimenting with it so far.
In creating a minimal project with CMake on Windows I linked just the KDGpu target - yet noticed it dragged in DLLs for GLM, libKDGpuKDGui, libKDGui, libKDFoundation, and libKDUtils . This is much more code than I wanted!

A few things:

  • It appears that the assets and KDGpuExample targets are built, even when KDGPU_BUILD_EXAMPLES is disabled - meaning we're always downloading+building GLM, STB, and Imgui, and trying to copy fonts+textures.
  • The defunct TOYRENDERER_BUILD_TESTS define is used in dependencies.cmake.
  • KDUtils is only used twice; for bitflags (could probably be dropped directly into this repo) and the readShaderFile method (file IO is arguably out-of-scope for a graphics abstraction).
  • An option to disable the KDGpuKDGui layer.
  • KDFoundation is only used for KDExample and KDGpuKDGui; it should be excluded if you choose to build neither.

These are superficial changes - however it seems like this repo is a mirror of some internal repo, so you don't take PRs? Hopefully documenting this is sufficient..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.