r/vulkan

▲ 6 r/vulkan

Graphics pipeline fluency

I am not a vulkan programmer even I'm barely learning opengl but individually you guys are worth like 15 web devs or 6 game devs each do you guys have any tips on how you understood the graphics pipeline so well beyond just "practice and repetition makes perfect"

reddit.com
u/CorruptedSciencep — 2 days ago
▲ 43 r/vulkan+1 crossposts

Demo release of C++20 modern Vulkan(1.3) raylib-like low level game framework "Xenith", includes a full tutorial explaining how to make 3D cubic platformer game from scratch)

I released demo of Xenith - a lightweight, data-oriented C++20, 3D low level game framework.

If you want to make a game while having low level control, you're either forced to use high level game frameworks or engines that abstract everything, or, if choosing raw API's you face lots of problems, such as linking libraries, making own loaders(e.g. model loader or image loader), adding different modules(such as physics, vfx), and eventually instead of making game you spent all that time building engine. Xenith fixes this problem by giving you essential modules(such as physics, ecs, math, input) out of box, and eliminates just enough boilerplate code, while leaving you the rest(such as making own game loop, or making own Vulkan pipeline).

This game framework makes you both use and learn modern Vulkan 1.3, provides you high level functions, but saves the exact Vulkan pipeline logic without thousands lines of code, for example FindAndSelectPhysicalDevice(), CreateLogicalDevice().

Tutorial 01, walks you through how to go from simple window application to entire cubic 3D platformer game, covering most basic and important topics.

https://github.com/ThoriumReactor/xenith/blob/main/tutorials/cube_platformer_tutorial_01/tutorial_01.md

Key architecture features:

- Explicit ownership Direct access to raw handles such as VkImage, VkSwapchainKHR.

- Deterministic in this game framework functions are deterministic, e.g. EmplaceEntityComponentToRegistry(registry, entity, component_data) instead of registry.emplace(...)

- Modular architecture gives you freedom to remove or add modules you need or want.

Links & Repository:

https://github.com/ThoriumReactor/xenith

u/BIoomyl — 2 days ago
▲ 169 r/vulkan+2 crossposts

Wind Tunnel Simulation | Vulkan and C++

It’s the first step in my attempt to simulate an F1 car. Right now, the simulation is very low-resolution and quite slow, so there’s still a lot of optimization to do. It’s also my first time working with compute shaders, so there’s plenty to learn and improve along the way.

u/ThatTanishqTak — 3 days ago
▲ 23 r/vulkan

Turning a floorplan photo into a 3D house — my own Vulkan CAD engine

Drop in a floorplan image and the house gets built.

The AI only reads the dimension numbers. Where the walls actually are is found by the engine, straight from the pixels. Reading numbers is what the model is good at; seeing which line is a wall is not.

The rules come from architecture. Dimensions are measured to wall centrelines, exterior and interior walls have different thicknesses, and where walls meet is where a room ends. A window isn't a missing wall — it's a hole in one.

The original drawing is laid underneath at the same scale, so you can see straight away whether it got it right.

A CAD engine I'm building from scratch in Vulkan and C++17. The model runs locally, 7B.

평면도 이미지를 넣으면 3D 모델링이 됩니다.

AI 는 치수 숫자만 읽습니다. 벽이 어디에 있는지는 엔진이 이미지에서 직접 찾습니다. 숫자를 읽는 건 AI 가 잘하고, 어디가 벽인지 보는 건 못하기 때문입니다.

도면을 읽는 규칙은 건축에서 그대로 가져왔습니다. 치수는 벽 중심을 재고, 외벽과 내벽은 두께가 다르며, 벽이 만나는 자리가 방의 경계입니다. 창은 벽이 없는 게 아니라 벽에 뚫린 것이고요.

만들어진 3D 모델 아래에 원본 도면을 같은 축척으로 깔아 두었습니다. 맞게 그렸는지 확인합니다.

Vulkan + C++17 로 제가 직접 만들고 있는 CAD 엔진입니다. 로컬에서 도는 7B 모델을 씁니다.

https://youtu.be/dCkcYsRAOTE?si=AeltSbmePtQh3AfY

u/innolot — 3 days ago
▲ 2 r/vulkan+4 crossposts

Why does Vulkan always crash my game??

The new operating system for Minecraft is Vulkan and I'd really like to use it as my pc has some framerate issues with openGL however when I switch it over to Vulkan it gives me this crash code:

My pc's specs are also attached, why is this happening???? what can I fix???

u/OwlBirdDemon — 4 days ago
▲ 74 r/vulkan+7 crossposts

My Rust engine performance

4 physics simulation with increasing physics body count

u/IamRustyRust — 5 days ago
▲ 6 r/vulkan

How I am supposed to restrict bindings across shaders in the same file for slang?

I am a little confused on what is broken. I thought slang compilation was supposed to "handle the bindings." so here I would of expected that ubo would of been included in only the vertex spirv, and texSampler would only be included in the fragment spirv. I am sure that there is probably something I need to do explicitly here, but I was sold on slang auto-magically handing these types of things. I am new to graphics programming and initially followed the old tutorial to completion then wanted to try porting over to slang. Any help is appreciated, as i have been digging through the slang and vulkan documentation for a while and its been hard to figure out how it all comes together without a real example.

slang file :

struct MatrixParameters{
float4x4 model;
float4x4 view;
float4x4 proj;
}
struct Vertex{
float3 position;
float3 color;
float2 uv;
}
struct VOut
{
float4 position : SV_POSITION;
float3 fragColor;
float2 fragTexCoord;
}
ConstantBuffer<MatrixParameters> ubo;
[shader("vertex")]
VOut main(Vertex input)
{
VOut output;
output.position = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.position, 1.0))));
output.fragColor = input.color;
output.fragTexCoord = input.uv;
return output;
}
uniform DescriptorHandle<Sampler2D> texSampler;
[shader("fragment")]
float4 main(VOut input) : SV_TARGET
{
float4 outColor = float4(input.fragColor * texSampler.Sample(input.fragTexCoord).rgb, 1.0);
return outColor;
}

c++ program file :

// CREATING DESCRIPTOR SET LAYOUT
VkDescriptorSetLayoutBinding uboLayoutBinding{};
uboLayoutBinding.binding = 0;
uboLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
uboLayoutBinding.descriptorCount = 1;
uboLayoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
uboLayoutBinding.pImmutableSamplers = nullptr;

VkDescriptorSetLayoutBinding samplerLayoutBinding{};
samplerLayoutBinding.binding = 1;
samplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
samplerLayoutBinding.descriptorCount = 1;
samplerLayoutBinding.pImmutableSamplers = nullptr;
samplerLayoutBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;

std::array<VkDescriptorSetLayoutBinding, 2> bindings = { uboLayoutBinding, samplerLayoutBinding };

VkDescriptorSetLayoutCreateInfo layoutInfo{};
layoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layoutInfo.bindingCount = static_cast<uint32_t>(bindings.size());
layoutInfo.pBindings = bindings.data();

vkCreateDescriptorSetLayout(device, &layoutInfo, nullptr, &outDescriptorSetLayout)
...
slangModule->getDefinedEntryPoint(0, vertexEntryPoint.writeRef());
slangModule->getDefinedEntryPoint(1, fragmentEntryPoint.writeRef());

slangResources.mpSessionInstance->createCompositeComponentType(
componentTypes.data(), // {slangModule, vertexEntryPoint, fragmentEntryPoint }
componentTypes.size(),
composedProgram.writeRef(),
diagnosticBlob.writeRef());

composedProgram->getEntryPointCode(
0,
0,
spirvCode,
diagnosticBlob.writeRef()
);
VkShaderModuleCreateInfo shaderModuleCreateInfo{};
shaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
shaderModuleCreateInfo.codeSize = spirvCode->getBufferSize();
shaderModuleCreateInfo.pCode = reinterpret_cast<const uint32_t *>(spirvCode->getBufferPointer());
VkShaderModule vertexModule;
vkCreateShaderModule(device, &shaderModuleCreateInfo, nullptr, &comboModule);



composedProgram->getEntryPointCode(
1,
0,
spirvCode2,
diagnosticBlob.writeRef()
);
VkShaderModuleCreateInfo shaderModuleCreateInfoFr{};
shaderModuleCreateInfoFr.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
shaderModuleCreateInfoFr.codeSize = spirvCode2->getBufferSize();
shaderModuleCreateInfoFr.pCode = reinterpret_cast<const uint32_t *>(spirvCode2->getBufferPointer());
VkShaderModule fragmentModule;
vkCreateShaderModule(device, &shaderModuleCreateInfoFr, nullptr, &fragmentModule;

ERROR output :

validation layer: vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[0] shader [VK_SHADER_STAGE_VERTEX_BIT] uses descriptor [Set 0, Binding 1, variable "ubo"] (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) but the VkDescriptorSetLayoutBinding::stageFlags was VK_SHADER_STAGE_FRAGMENT_BIT.
(VkDescriptorSetLayout from VkPipelineLayoutCreateInfo::pSetLayouts[0]).
The Vulkan spec states: If a resource variable is declared in a shader and layout is not VK_NULL_HANDLE, the corresponding descriptor set in layout must match the shader stage (https://docs.vulkan.org/spec/latest/chapters/pipelines.html#VUID-VkGraphicsPipelineCreateInfo-layout-07988)
validation layer: vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] shader [VK_SHADER_STAGE_FRAGMENT_BIT] uses descriptor [Set 0, Binding 0, variable "globalParams"] (VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) but the VkDescriptorSetLayoutBinding::stageFlags was VK_SHADER_STAGE_VERTEX_BIT.
reddit.com
u/Longjumping-Cup-8927 — 4 days ago
▲ 49 r/vulkan+1 crossposts

Nu Game Engine - BIG NEWS - Vulkan support

https://github.com/bryanedds/Nu/releases/tag/v20.0.0

>After many many months of work from multiple contributors, we finally present Nu with Vulkan rendering and support for Mac, iOS, and Android!

>This branch not only replaces our OpenGL renderers completely with Vulkan renderers, it also features important rendering and performance enhancements as well as makes Nu deployable on Mac, iOS, and Android!

(I just saw release - not my project)

u/S48GS — 6 days ago
▲ 67 r/vulkan+1 crossposts

Vulkan: Beyond the Triangle

Hey everyone, I've just finished the 2nd video, and followup to my "Modern Vulkan in 2 Hrs" video. Thanks for the awesome feedback on the first one! This 2nd video tackles a ton of stuff:

glTF Model Parsing, Loading, Rendering

Camera, Basic Lighting, Multi-Draw Indirect, Vertex Pulling, Buffer Device Address, etc.

Hope you guys like it!

youtube.com
u/nenchev — 8 days ago
▲ 29 r/vulkan+1 crossposts

How do you handle resource management in bindless renderers?

Resource handling consists of two different parts: managing a CPU-side version like a VkBuffer, VkImage, etc., and managing a GPU-side version like a combination of set, binding, and array indices. From what I've read, it looks to me like a GPU-side handle is created when a CPU-side resource is created. And it makes sense to create them together, since there should be only one reference to such a resource Thus, a resource would look like this:

struct Resource {
    union {
        VkBuffer buffer;
        VkImage image;
        // ...
    };

    struct {
        int set;
        int binding;
        int index;
    } reference;
};

However, such a design would tightly couple resource management with descriptor set handling, because a resource manager would need to know where and how to bind a resource, and this doesn't look too good to me.

Considering all of the above, I have a few questions I can't answer myself:

  1. Does the resource manager need to know how to handle descriptors? If not, should the API user handle them himself, given that they should know where to bind the requested resources?
  2. If it is the resource manager's job to handle descriptors, doesn't that impose some predefined descriptor layout so that the manager knows where to bind them?
  3. If it does enforce some descriptor layout, how do you write shaders that need different input data?
reddit.com
u/Slow-Juggernaut-9065 — 9 days ago
▲ 10 r/vulkan

Apple Vulkan Support

Why doesnt Apple support Vulkan? (I know KosmicKrisp exists)

Is vendor lockin that important? Does that strategy work for them - are there many developers that use metal and not support other platforms? Seems like the result is not really lockin, but just forcing more work for developers?

Kind of feels like a poor architecture decision that helps no one, except maybe giving slightly more control to Apple at the expense of their developers as well as the complexity of maintaining another api.

reddit.com
u/OptimisticMonkey2112 — 12 days ago
▲ 87 r/vulkan+2 crossposts

Tidy GPU Image Builder - Add Nvidia drivers to SteamOs

SteamOS on NVIDIA desktop PCs is getting easier — major update now available

I’ve been developing SteamOS NVIDIA Image Builder, an independent Windows application that makes preparing a SteamOS installation image for NVIDIA-powered desktop and laptop PCs much simpler.

Instead of manually configuring Linux tools and entering a long series of commands, the application guides you through the process and prepares the NVIDIA-compatible image for you.

What’s new

  • Support for NVIDIA RTX 20, 30, 40 and 50 series GPUs
  • Guided NVIDIA driver integration
  • Automatic Linux build-environment setup
  • Improved SteamOS installation workflow
  • Better physical-drive detection
  • Drives clearly identified as empty, occupied, system-related or installer media
  • Empty drives shown as recommended installation targets
  • Clear warnings for drives containing Windows, partitions or personal files
  • Improved build validation, recovery and progress information
  • Option to remove the Arch Linux build environment when it is no longer needed
  • Tools for easier future NVIDIA driver maintenance
  • Arch Linux uninstall button in app

The original SteamOS recovery image is never modified. The application works from a copy, validates the finished image and generates a checksum and build report.

Download from Microsoft Store

Download SteamOS NVIDIA Image Builder

This tool is intended for desktop and laptop PCs, not handheld devices. It is experimental and unofficial, and it is not affiliated with, endorsed by or supported by Valve, NVIDIA or Microsoft.

Installation might take some time so please be patient!

Secure Boot may need to be disabled, and testing the generated image on a spare drive is strongly recommended. Installing an operating system can erase the selected drive, so always verify the drive information and keep a backup of important files.

The goal is to turn a complicated command-line procedure into a clear, guided process that more PC users can understand.

Feedback is very welcome—especially from people testing SteamOS on NVIDIA hardware. Which GPU are you using, and what would you like to see improved next?

u/OldSherbet2636 — 14 days ago
▲ 18 r/vulkan

Mulithreading Shader Compilation?

I was reading this tutorial https://vkguide.dev/docs/extra-chapter/multithreading/ and it claims that you can compile shaders on a background thread and avoid hitching. Is this true? Are there any drawbacks to this approach?

"For compiling pipelines, vkCreateShaderModule and vkCreateGraphicsPipeline are both allowed to be called from multiple threads at once. A common approach for multithreaded shader compilation is to have a background thread dedicated to it, with it constantly looking into a parallel queue to receive compilation requests, and putting the compiled pipelines into another queue that then the main renderthread will connect to the simulation. This is very important to do if you want to have an engine that doesn’t have a lot of hitching. Compiling shader pipelines can take a very long time, so if you have to compile pipelines at runtime outside of a load screen, then you need to implement such a multithreaded async compile scheme for your game to work well."

reddit.com
u/Longjumping-Cup-8927 — 11 days ago