How to enable the Software Rasterizer for Vulkan?

Hi, how to enable the “Software Rasterizer for Vulkan” which means that a simulation of GPU on CPU? Because my current laptop doesn’t support RTX, but I’m preparing everything for future RTX project. I tried to google it but I didn’t find an answer, that’s because Vulkan is difficult.

rayquery.cpp:
This is an example .cpp code, but how to enable “Software Rasterizer for Vulkan” in this code?

rayquery/scene.frag:

What gives you the impression that this is a thing that exists and can be enabled? I’ve never heard of any such thing, and even if one existed, I highly doubt it would support RTX.

2 Likes

I was moving from DirectX to Vulkan, and DirectX has 3 things:

  • Hardware (GPU and it’s very fast)
  • WARP (CPU & GPU and it’s fast enough)
  • Reference Rasterizer (CPU only, it’s for experimental but it’s extremely slow, like 50 times slower)

People say that OpenGL/Vulkan is powerful than DirectX, that’s why I’m asking “If DirectX has that Software Rasterizer, then why not Vulkan?”. And I noticed that the Reference Rasterizer in DirectX supports all the features, but it’s 50+ times slower, the reason is the compiled shader is designed for GPU but not for CPU, that’s why it’s too slow, it’s like an emulator. But I don’t mind if it’s slow because my goal is to learn how raytracing functions in Vulkan work by re-creating their behavior on 100% CPU, and it will not be a waste of time because the debugging on CPU is extremely important, it will speed up my development a lot, I showed an explanation in the picture I posted.

Question: If someone can give hints, like links or documentation or hints on how to enable that Software Rasterizer for Vulkan (like an emulator on CPU) then I will be thankful.

https://docs.mesa3d.org/drivers/llvmpipe.html

Maybe that link will be helpful. I’ve never personally tried to use it. Although when I print out the list of VkPhysicalDevices on my system, llvmpipe is there and listed as VK_PHYSICAL_DEVICE_TYPE_CPU device type.

1 Like

If I understand, the link you gave to me is LLVM (a compiler) that’s used in your system to compile a .glsl code into CPU machine code. And talking about programming language, the programming language I showed in the picture is made by me, and it’s completely stable, I’ve never stuck on a bug that’s impossible to detect, it’s just amazing to build your own programming language (glsl-C# like).

When I print out the list of VkPhysicalDevices on my system, then I only get 1 list item (gpu_count = 1) and it’s only VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, I mean that there is no CPU, I don’t understand why? Should I update to the latest Vulkan? I’m currently using Vulkan 1.3.204.1 on Win10.

// Select GPU
{
    uint32_t gpu_count;
    err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL);
    check_vk_result(err);
    IM_ASSERT(gpu_count > 0);

    VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count);
    err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus);
    check_vk_result(err);

    // If a number >1 of GPUs got reported, find discrete GPU if present, or use first one available. This covers
    // most common cases (multi-gpu/integrated+dedicated graphics). Handling more complicated setups (multiple
    // dedicated GPUs) is out of scope of this sample.
    int use_gpu = 0;
    for (int i = 0; i < (int)gpu_count; i++) {
        VkPhysicalDeviceProperties properties;
        vkGetPhysicalDeviceProperties(gpus[i], &properties);
        if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { // <-- I only have this type.
            use_gpu = i;
            break;
        }
    }

    g_PhysicalDevice = gpus[use_gpu];
    free(gpus);
}

From my understanding, its a mesa driver which uses LLVM. You need to install the mesa driver, called LLVMpipe in this case. Once correctly installed, you should see it as an option when listing your physical devices. From your screenshot it looked like you’re on windows. That link has a section on windows. However I’m on linux which has the mesa driver preinstalled. Below is a link directly to the windows section on that page:

https://docs.mesa3d.org/drivers/llvmpipe.html#windows

1 Like

Because the “power of an API” and whether it has a software rasterizer are two separate questions. Apparently, LLVMpipe provides a Vulkan implementation. But I don’t see raytracing support.

1 Like

FWIW, there is also Chrome’s (née Transgaming) SwiftShader software renderer. But it does not implement RTX.

2 Likes

There’s also like $100 second hand GPUs, which is probably the best renderer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.