tgfrerer / island

🌋🐎 Project Island is an experimental, hot-reloading Vulkan Renderer for Linux and Windows, written in C/C++.
MIT License
1.04k stars 42 forks source link

Running on ubuntu #8

Closed Hperigo closed 4 years ago

Hperigo commented 4 years ago

Hi, this is a pretty cool project =)

unfortunately after compiling and running the hello_triangle sample I get a crash:

X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  149 ()
  Minor opcode of failed request:  4
  Resource id in failed request:  0x420000f
  Serial number of failed request:  217
  Current serial number in output stream:  223

also, not sure if this helps. Since this was a fresh Ubuntu I had to install this packages:

   27  sudo apt-get install Ninja
   37  sudo apt-get install xorg openbox
   52  sudo apt install libx11-dev
   63  sudo apt-get install libxrandr-dev
   67  sudo apt-get install libxinerama-dev
   71  sudo apt-get install libxcursor-dev
   75  sudo apt-get install libxi-dev
   77  sudo apt-get install libxi-dev
  193 sudo apt install mesa-common-dev

let me know if there's any other information that can help..

tgfrerer commented 4 years ago

Hey @Hperigo, thanks for checking Island out!

It looks like the error is somehow X related - my hunch woud be - as you say you set up a fresh Ubuntu system - to check whether vulkan is set up properly. If you installed Vulkan via the sdk you should have an utility named vulkaninfo on your system.

Could you post a gist / a listing of the output of what vulkaninfo prints when you run it on your system?

./vulkaninfo >> info.txt 

Another way of testing a vulkan sdk install is to run vulkan cube - you should see a spinning cube.

./vkcube 

Perhaps it would help to know a little bit more about the hardware, and the driver version you're using - so far I've tested on Intel Iris Pro, and an assortment of Desktop NVidia cards (for Nvidia cards always with their latest binary driver).

Cheers

Hperigo commented 4 years ago

cool! here's the info.txt file: https://gist.github.com/Hperigo/6fe797d3b87dfda96b6d769f1f2d0ee3

Iḿ running this from a samsung np350xaa laptop, with a Intel UHD Graphics 620 and an GeForce MX110/PCIe/SSE2 / GeForce MX110/PCIe/SSE2

this is what lshw -C display shows me:

  *-display                 
       description: VGA compatible controller
       product: UHD Graphics 620
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 07
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:129 memory:f5000000-f5ffffff memory:d0000000-dfffffff ioport:f000(size=64) memory:c0000-dffff
  *-display
       description: 3D controller
       product: GM108M [GeForce MX110]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a2
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:132 memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:e000(size=128) memory:f7000000-f707ffff

and I did manage to get the spinning cube, but I had to vkcube --gpu_number 1 if I use gpu_number=0 then its just a black screen.

Hperigo commented 4 years ago

well.. so updating the nvidia driver fixes the crash, I'm able to run all the samples

but I do get some visual glitches: Screenshot from 2020-08-20 22-21-23

Screenshot from 2020-08-20 22-20-13

tgfrerer commented 4 years ago

That's really helpful, thank you!

I think it points to two things:

  1. It appears that selecting the first available device on multi-gpu systems not necessarily selects the dedicated (in this case Nvidia) GPU.
  2. There might be an issue with Images at mipmap level 0 which has escaped the debug layers - i was able to reproduce these artifacts on my Intel GPU machine, and I'm hunting that down now.

One interesting thing to try would be what happens if you force Island to take the last available GPU - change https://github.com/tgfrerer/island/blob/729d56ac6d78da327f8736d3f3c4fa5bd95bb866/modules/le_backend_vk/le_device_vk.cpp#L161 to:

    self->vkPhysicalDevice = deviceList.back();

to print out the name of the currently selected GPU you can say:

self->vkPhysicalDevice = deviceList.front();
std::cout << "Selected GPU: " << self->vkPhysicalDeviceProperties.deviceName << std::endl
          << std::flush;
arturoc commented 4 years ago

I think in vulkan you can select a device manually so this might be opengl only but in opengl exporting certain symbols makes an application select the discrete card by default instead of the integrated:

extern "C" {
    __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; 
}
extern "C"
  {
    __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
  }
Hperigo commented 4 years ago

alright, some updates

I also made the sniped of code print out all available devices:

    std::cout << "available gpus: " << std::endl;
    for( auto& l : deviceList ){
        std::cout << "  --- " << l.getProperties().deviceName << std::endl;
    }

    std::cout << "Selected GPU: " << self->vkPhysicalDeviceProperties.deviceName << std::endl << std::flush;

surprisingly, the updated driver ( 450 on the image at the bottom ) disappears with the GeForce card. Only the Intel one is available:

available gpus: 
  --- Intel(R) UHD Graphics 620 (KBL GT2)
Selected GPU: Intel(R) UHD Graphics 620 (KBL GT2)

If I revert back to the 440 driver both NVidia and Intel show up on the list and I'm able to select the discrete card

available gpus: 
  --- Intel(R) UHD Graphics 620 (KBL GT2)
  --- GeForce MX110
Selected GPU: GeForce MX110

but I get a validation error due to the different SPIR-V version that I have available

[ VALIDATION | ERROR ] Validation Error: [ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object 0: handle = 0x5562cd6ac6e0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x6bbb14 | SPIR-V module not valid: Invalid SPIR-V binary version 1.5 for target environment SPIR-V 1.3 (under Vulkan 1.1 semantics). terminate called after throwing an instance of 'vk::ValidationFailedEXTError' what(): vk::Device::createShaderModule: ErrorValidationFailedEXT

Screenshot from 2020-08-21 09-24-41

tgfrerer commented 4 years ago

@arturoc awesome, that's good to know! I need to dig a little deeper into this to find out the best way to select the high-performance card. Although it's possible to list all available devices (just like @Hperigo did) I wonder if there is a best practice to figure out the highest performance device from the list, without having to enumerate all device properties...

@Hperigo it looks like the Intel driver takes issue with how images are uploaded when images are set to be not linear. this seems to have changed with more modern versions of the intel driver. I'm still trying to find out what's actually happening, and how this can be fixed.

As for the nvidia driver, it looks like the default driver version does not yet support vulkan 1.2, or the more modern version of SPIR-V. I'm running with the Nvidia binary driver installed from the Nvidia website: https://developer.nvidia.com/vulkan-driver - if you only just set up your laptop and might feel adventurous (it's not such a big deal, really) i can recommend installing the nvidia driver manually.

How-to: Install the nvidia vulkan beta driver manually on ubuntu 20

For this, download the vulkan beta binary driver via the nvidia website above, then:

Save everything! (The next step will log you out from your X session!)

Now, drop down to text-only mode:

sudo telinit 3

And install the nvidia driver:

chmod +x NVIDIA-Linux-x86_64-450.56.06.run
sudo ./NVIDIA-Linux-x86_64-450.56.06.run

follow the on-screen instructions, cross thumbs, reboot ;)

tgfrerer commented 4 years ago

That said, if it's just the spir-v version that trips up the card, you can perhaps try to change this line:

https://github.com/tgfrerer/island/blob/729d56ac6d78da327f8736d3f3c4fa5bd95bb866/modules/le_shader_compiler/le_shader_compiler.cpp#L495

to

shaderc_compile_options_set_target_spirv( local_options, shaderc_spirv_version_1_2 );

SPIR-V 1.5 is only needed for RTX shaders etc, and if you don't use these, version 1.2 should be okay.

tgfrerer commented 4 years ago

Update

the artifacts on intel should be fixed with the latest commit be6604b - these were because of an erroneous layout transition which happened when uploading images.

Since image layouts are meaningless on Nvidia cards, this did not show there. But Intel cards (and I'm pretty sure mobile GPUs too) respect Image Layouts, which is why it showed on Intel GPUs.

Hperigo commented 4 years ago

awesome! I changed the spirv version to 1.2 and everything run fine! the correct GPU got selected etc..

I'll try to update the NVIDIA driver later, but feel free to close this issue if you want