Playing around with Vulkan (again)

Hello all,

Now that vulkan support has been advanced a bit, I decided to build off the vulkan branch and check the various samples. Unfortunately, even basic ones like asteroids give the following error:

/usr/share/panda3d/samples/asteroids$ python3 main.py 
Known pipe types:
  VulkanGraphicsPipe
(all display modules loaded.)
:display:vulkandisplay(error): Failure to create Vulkan instance: Specified layer does not exist.
:ShowBase(warning): Unable to open 'onscreen' window.
. . .

I am running a Ubuntu 20.04 based distro and running vulkantools does correctly identify my GPU, showing 3 layers:

Layers: count = 3
=======
VK_LAYER_LUNARG_standard_validation (LunarG Standard Validation Layer) Vulkan version 1.0.131, layer version 1:
        Layer Extensions: count = 0
        Devices: count = 1
                GPU id  : 0 (AMD RADV POLARIS10 (ACO))
                Layer-Device Extensions: count = 0

VK_LAYER_MESA_device_select (Linux device selection layer) Vulkan version 1.1.73, layer version 1:
        Layer Extensions: count = 0
        Devices: count = 1
                GPU id  : 0 (AMD RADV POLARIS10 (ACO))
                Layer-Device Extensions: count = 0

VK_LAYER_MESA_overlay (Mesa Overlay layer) Vulkan version 1.1.73, layer version 1:
        Layer Extensions: count = 0
        Devices: count = 1
                GPU id  : 0 (AMD RADV POLARIS10 (ACO))
                Layer-Device Extensions: count = 0

Am I missing something? Is there a way to show more detailed debug output?

Panda is currently requesting `VK_LAYER_KHRONOS_validation´

I seem to recall they renamed the layer at some point, you may need to edit it to VK_LAYER_LUNARG_standard_validation in panda/src/vulkandisplay/vulkanGraphicsPipe.cxx

Now, I just get the following:

 :display(warning): Unable to load libp3vulkandisplay.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
. . .

This is the exact diff:

diff --git a/panda/src/vulkandisplay/vulkanGraphicsPipe.cxx b/panda/src/vulkandisplay/vulkanGraphicsPipe.cxx
index 8ceb04dbb5..d99d100bc2 100644
--- a/panda/src/vulkandisplay/vulkanGraphicsPipe.cxx
+++ b/panda/src/vulkandisplay/vulkanGraphicsPipe.cxx
@@ -78,7 +78,7 @@ VulkanGraphicsPipe() : _max_allocation_size(0) {
   }
 
   const char *const layers[] = {
-    "VK_LAYER_KHRONOS_validation",
+    "VK_LAYER_LUNARG_standard_validation",
   };
 
   std::vector<const char *> extensions;

That’s weird. That suggests that libp3vulkandisplay.so no longer exists. Perhaps something went wrong when rebuilding?

FWIW, I looked into it and “VK_LAYER_LUNARG_standard_validation” is deprecated; I’ll change Panda to look for either one, but you may want to see if you can update your Vulkan drivers.

Yep, I removed the “built” folder and started over. now all the samples work correctly.

On a bit of a tangent, it seems that when I compile using gcc (9.3.0) I get the following error: (I isolated the specific command that is failing)

$ g++ -std=gnu++11 -ftemplate-depth-70 -fPIC -c -o built/tmp/p3pgraphnodes_composite1.o -Ibuilt/tmp -Ibuilt/include -I/usr/include/eigen3 -Ipanda/src/pgraphnodes -fvisibility=hidden -pthread -fno-exceptions -msse2 -fno-strict-aliasing -ffast-math -fno-stack-protector -fno-finite-math-only -fno-unsafe-math-optimizations -O2 -Wall -Wno-unused-function -Wno-reorder -DBUILDING_PANDA panda/src/pgraphnodes/p3pgraphnodes_composite1.cxx
In file included from built/include/shaderInput.h:31,
                 from built/include/nodePath.h:43,
                 from built/include/sceneSetup.h:20,
                 from built/include/cullTraverser.h:20,
                 from panda/src/pgraphnodes/callbackNode.cxx:16,
                 from panda/src/pgraphnodes/p3pgraphnodes_composite1.cxx:2:
built/include/shader.h:69:8: error: declaration of ‘enum Shader::ShaderType’ changes meaning of ‘ShaderType’ [-fpermissive]
   69 |   enum ShaderType {
      |        ^~~~~~~~~~
In file included from built/include/shaderModule.h:19,
                 from built/include/shader.h:38,
                 from built/include/shaderInput.h:31,
                 from built/include/nodePath.h:43,
                 from built/include/sceneSetup.h:20,
                 from built/include/cullTraverser.h:20,
                 from panda/src/pgraphnodes/callbackNode.cxx:16,
                 from panda/src/pgraphnodes/p3pgraphnodes_composite1.cxx:2:
built/include/shaderType.h:27:24: note: ‘ShaderType’ declared here as ‘class ShaderType’
   27 | class EXPCL_PANDA_GOBJ ShaderType : public TypedWritable {
      |                        ^~~~~~~~~~

However, compiling using clang completes with no errors.

P.S. I am using the latest opensource amdgpu drivers.

The shaderpipeline branch when built with makepanda.py throws this same error. Attempts to “quickly” refactor this error away have resulted in an untenable mess of linking and scope problems.

Time for some silly questions: Why do I have to use clang to build the shaderpipeline branch? Is there a flag I can set to make gcc/cmake more permissive in this regard?

Update: Answered my own question after a little searching around in makepanda.py . The shader.h error is downgraded to a warning, allowing compilation to continue by doing the following at line 1320:

if (COMPILER=="GCC"):
    if (src.endswith(".c")): cmd = GetCC() +' -fPIC -c -o ' + obj
    else:                    cmd = GetCXX()+' -std=gnu++11 -fpermissive -ftemplate-depth-70 -fPIC -c -o ' + obj

The shaderpipeline branch now compiles with makepanda.py for me.

I checked in a change that renames the conflicting ShaderType, it should be fine now. However, the Vulkan branch is not running very well for me anymore with the latest Vulkan SDK, I will have to go back to it later to investigate.

Thanks for taking the time to look at this and push some updates. Your work on Panda3D is very much appreciated!

1 Like