Tag Vulkan

Vulkan memory management in PasVulkan

Memory management in Vulkan is a complex and intricate process that gives developers control over how graphics memory is allocated and used. The primary principle of Vulkan’s memory management is that it offers a lower-level interface to the GPU than APIs like OpenGL, entrusting developers with the responsibility of managing memory allocations themselves. This can lead to more efficient use of memory and enhanced performance, but it also necessitates a deeper understanding of how the GPU operates and the optimal way to manage its resources.

In Vulkan, memory is organized in a hierarchy that includes heaps, memory types, and memory property flags. Heaps are fixed-size memory resources exposed by the device, and each heap can support different memory types. When creating a resource like a buffer, Vulkan provides information about which memory types are compatible with that resource. Depending on the resource’s usage flags, the developer must select the right memory type and, based on that type, the … (read more)

PasVulkan GLTF 2.0 support progress showcase with a sample with just one draw call per frame.

Here is a small PasVulkan GLTF 2.0 support progress showcase with a sample model case, which can draw with just one Vulkan CmdDrawIndexed call per frame, although that there are several animated nodes.  



My GLTF implementation at my PasVulkan framework tries to combine everything material-wise and primitive-topology-wise so that the GPU itself can do everything necessary animation-wise (joints and morph target vertices) in one go per material/primitive-topology-group. And in my GLTF implementation, there is no real hard limit on the number of joints and morph target vertices. 

For this purpose, each vertex points to respectively two special packed linked lists (one for joints in four-packed-pairs and for morph target vertices), which are stored in Vulkan storage buffers.  Each vertex is otherwise only 64 bytes in size, even though it contains position, the complete tangent-bitangent-normal space, two texture coordinates, color value, node index, linked list pointers, flags, etc.

And next to it there is also … (read more)

PasVulkan GLTF 2.0 support

I'm making progress with the GLTF 2.0 support in PasVulkan, but I'm still thinking about how to implement everything effectively so that as few draw calls as possible are necessary. The current plan is to pack everything in storage buffers, so that the vertex shaders always have the complete information about everything at any time such as for example morph targets, joints/bones, node transformations, etc. Because then the CPU only needs to update the most necessary and upload to the GPU what is necessary, the rest will be done by the GPU itself then. So stay tuned! 

SPIR-V reflection and Virtual Reality support at PasVulkan

PasVulkan now has SPIR-V reflection built in directly, without any external third-party dependencies, in other words, it is really pure Object Pascal code that parses the SPIR-V code and extracts information from it.

The new TpVulkanShaderModule.GetReflectionData API parses the SPIR-V code and then returns information about the types, specialization constants and variables used there as a TpvVulkanShaderModuleReflectionData data structure that can be used for example to automatically create Vulkan pipelines and render passes from it.

This is now especially useful for data-driven rendering concepts and dynamic material systems, which will be exactly the next steps at PasVulkan too.

And by the way, PasVulkan now also has Virtual Reality support (which currently uses the VK_KHR_multiview extension and the OpenVR/SteamVR API), see PasVulkan.VirtualReality.pas unit.

PasVulkan have now a working frame-graph API

PasVulkan have now a working frame-graph API with support for multiple GPU-queues, multithreaded cmdbuffer filling, multisampling, multiview rendering and so on.


An initial code example from a real-world project from me: https://gist.github.com/BeRo1985/ab4c97b5e17b84b46b9cecc19db450a9

It was really a lot of work, at least the validation layers didn't have anything to complain about anymore.

It was really a lot of work, so that at least the validation layers didn't have anything to complain about anymore, and that everything was also working. 🙂

And of course with resource lifetime analysis for resource aliasing support to save memory on the memory-usage side.


PasVulkan will get a frame graph feature

I'm currently working on a frame graph feature at PasVulkan, which can simplify a lot when using the Vulkan API, because a frame graph has all important informations about a frame like its compute passes, its render passes, its attachments, its inputs, its outputs, its resources and its lifetimes and so on, so that the frame graph compiler can ideally allocate the GPU resources quite optimally (including reusing/aliasing of GPU resources) and so that the frame graph compiler can generate a quite optimal parallelizable processing-ordering directed acyclic graph, where multiple processing-sequences for each previously created Vulkan GPU queue can be created from it then for more optimal usage of the GPU also.

Here you can find further informations about the frame graph concept:

New PasVulkan subproject named PasGLTF, a GLTF 2.0 loader and writer for the Object Pascal ecosystem

I've a new PasVulkan subproject named PasGLTF, a GLTF 2.0 loader and writer for the Object Pascal ecosystem, including a viewer tool based on PasGLTF.

You can find the project at https://github.com/BeRo1985/pasgltf 









GLSL Astronomy compute shader

Today I present you my GLSL Astronomy compute shader, which I use in my demo productions and games. ☺

// Copyright (C) 2018, Benjamin "BeRo" Rosseaux (benjamin@rosseaux.de) - License: CC0// Hint: It's not super accurate, but it should be good enough for games and demos with sky rendering.#version 430
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
uniform vec3 tc; // Time constant
layout(std430) buffer ssboAstronomy { vec3 sunPosition; float sunDistance; vec3 moonPosition; float moonDistance; float moonPhase; mat3 celestialTransform; };
const float HalfPI = 1.5707963267948966, // 1.570796326794896619231, PI = 3.141592653589793, // 3.141592653589793238463, PI2 = 6.283185307179586; // 6.283185307179586476925
// The AMD windows GPU drivers do not seem to like constant double precision values here, // so no const prefix in this case.double astronomicalUnitsToKiloMeters = 149597871.0;
const vec2 sinCosOffsets = vec2(0.0, HalfPI);
double(read more)

Successful PasVulkan test on an AMD Radeon RX580 8GB graphics card

Successful PasVulkan test on an AMD Radeon RX580 8GB graphics card, so it seems that PasVulkan now seems to work with NVIDIA, AMD, Mali, Adreno and Intel GPUs, although with Intel GPUs it does only under Linux correctly, under Windows however not (due to a still non-fixed Windows Intel graphics driver issue). And with PowerVR GPUs it still crashes right at the startup.


First working versions of TpvGUIColorWheel and TpvGUIColorPicker in the PasVulkan GUI subframework

First working versions of TpvGUIColorWheel and TpvGUIColorPicker in the PasVulkan GUI subframework, where the whole triangle color wheel is rendered by the GPU itself only with two GPU-triangles with help of fragment-shader-side 2D signed-distance-field-stuff, and  where it can be also controlled purely with the keyboard.