Closed ericoporto closed 4 years ago
An official build_examples.sh
could exist, but we'd have to iron out some important details:
Do we assume Linux users have glslc installed and on the PATH? If GLFW or GLM are missing, do we teach them how to download these or attempt to install things locally? If the script dies an ugly death, lots of github issues will be created.
What's the preferred default compiler? $CC? gcc? clang?
The code/
folder doesn't have a local shaders/
where most example programs expect the compiled shaders to live.
For my Ubuntu 20.04 setup I have a poorman's build.sh
inside code/
. I assume the latest clang is installed:
#!/usr/bin/env bash
SRC=$1 # e.g. 15_hello_triangle.cpp
SHADER_VERT=$2 # e.g. 09_shader_base.vert
SHADER_FRAG=$3 # e.g. 09_shader_base.frag
# Create shaders folder if needed
if [ ! -d shaders ]; then
mkdir shaders
fi
# Exit if GLM isn't installed locally (remove check if it's available system-wide)
if [ ! -d glm ]; then
echo 'glm library not in this folder' ; exit 1;
fi
# Compile shaders; we assume glslc is installed and on the PATH
pushd shaders
glslc ../$SHADER_VERT -o vert.spv
glslc ../$SHADER_FRAG -o frag.spv
popd
clang++ -std=c++17 -I. $SRC -lglfw3 -lvulkan -ldl -lm -lpthread
My script takes three arguments (order matters in this simple script):
Example program
Vertex shader
Fragment shader
This lets me compile the Hello Triangle program like so:
./build.sh 15_hello_triangle.cpp 09_shader_base.vert 09_shader_base.frag
or the Index buffer program with the colored quad:
./build.sh 20_index_buffer.cpp 17_shader_vertexbuffer.vert 17_shader_vertexbuffer.frag
Do we assume Linux users have glslc installed and on the PATH? If GLFW or GLM are missing, do we teach them how to download these or attempt to install things locally? If the script dies an ugly death, lots of github issues will be created.
GLFW and GLM should be available on the package manager of most distributions. The advantage of placing it in the repository itself instead is to simplify future cross platform of a repository to be easier for Windows developers.
So, glslc
is provided with the LunarG package and alternatively can also be downloaded in unsupported binaries from the shaderc Google project page - without matching a release version. I had most trouble to build glslc
due to googletest
dependency which is hard to get. You need to disable all tests and flags are separated in shaderc pieces...
googletest
is not shipped in package managers, it's shipped a fake library that has only the headers, and building and installing it is not trivial so unless it is shipped in the project itself and pre configured with the gn
and CMake it's hard to figure it out.
What's the preferred default compiler? $CC? gcc? clang?
I imagine gcc is installed in most user systems but many would also have clang installed too. If there's any gains in maintenance over dues to MacOS using clang, I can see going for clang. I am more familiar with gcc so I try to use it when possible.
There are some vulkan packages in Ubuntu but I can't figure out if any of them are relevant
, except maybe vulkan-validationlayers-dev
?
I tried to document me trying to follow the tutorial here: https://github.com/ericoporto/vulkanLearning
I also have some messages on stderr reported here : https://gist.github.com/ericoporto/a3589a179dfc80268247347ad06e55ca
I haven't been able to see the triangle yet.
I'll have to go back and see what I did step-by-step to get the tutorials working on Ubuntu 20.04. I'll start that process tonight.
Based on your feedback I think we should go ahead and try to write that build_examples.sh
, or at the very least document how to get up-and-running without the Lunar package. That way we minimize duplicated efforts.
Here are the steps I took to setup the Vulkan Tutorials on Ubuntu 20.04
sudo apt install libglfw3-dev
: Installs latest GLFW library.
sudo apt install libglm-dev
: Installs latest GLM library.
sudo apt install vulkan-tools
: Command-line utilities, most importantly vulkaninfo
and vkcube
. Run these to confirm your machine is Vulkan-capable.
sudo apt install libvulkan-dev
: Installs Vulkan loader
sudo apt install vulkan-validationlayers-dev
: Installs the validation layers.
Download Google's unofficial binaries, and copy glslc
to your /usr/local/bin
folder.
NOTE: After finding these packages, I personally skipped the LunarG SDK entirely. Instead I use my own small script or Makefile. Not saying you should follow my path, but for testing it's useful.
For example, if the LunarG SDK still doesn't work for you, try the following:
Navigate to VulkanTutorial/code
Create shaders/
folder and compile the shaders in there:
$ glslc 09_shader_base.frag -o shaders/frag.spv
$ glslc 09_shader_base.vert -o shaders/vert.spv
g++ -std=c++17 15_hello_triangle.cpp -lglfw -lvulkan -ldl -lm -lpthread
and it's the same for clang, just replace g++
with clang++
. I tried similar steps and running ./a.out
successfully executes the Hello Triangle program. It should work for the other example programs too.
@abnercoimbre HEEEY IT WORKS!
In my Linux it's -lglfw
and not -lglfw3
for some reason.
g++ -std=c++17 15_hello_triangle.cpp -lglfw -lvulkan -ldl -lm -lpthread
I undid everything I had redone and redid everything as you said. :smiley:
glslc ↓
and placed it directly in my /usr/local/bin
. I did not pick anything else from the shaderc distributable. I tried to reinstall libvulkan1
and everything on my system blew up, so if someone ever thinks about it, don't.
I found the error in my code! Someone pointed me it. In the shader.frag
I had an out
in fragColor where it was supposed to be an in
. Now I have a triangle in my code too!
I updated the code in my repository to reflect all this. I think I will move to other things now and return to Vulkan later. Thank you for the help.
Awesome! You should be able to compile any program in the tutorial now.
In my Linux it's -lglfw and not -lglfw3 for some reason.
That was a typo on my end; I've fixed the instructions along with other edits to make things more professional.
I think I will move to other things now and return to Vulkan later. Thank you for the help.
No problem. To close this issue, I could make a PR to update the Linux Development environment section saying the LunarG SDK won't support Ubuntu 20.04 for a while. We either link to this issue for a possible workaround, or update the chapter text with instructions? We should wait and see what @Overv has to say :)
I'll get back to this on Saturday :)
@abnercoimbre For GLFW it makes sense at this point to just recommend installing it from a standard package, but with the Vulkan SDK and its validation layers I'm curious how up-to-date the vulkan-validationlayers-dev
package will be at any point in time. Do you know if it's updated soon after a new version is released?
Sorry I've taken a while to respond -- life suddenly got hectic after your reply. Things are slowing down so I'll get back to this thread this week :)
EDIT: Not this week, but this month.
@Overv I'm still alive! This year is a real peach.
For GLFW it makes sense at this point to just recommend installing it from a standard package
Yeah, agreed.
I'm curious how up-to-date the
vulkan-validationlayers-dev
package will be at any point in time. Do you know if it's updated soon after a new version is released?
They're maintained through MOTU which I think is already a good sign. Scanning the changelogs shows they're pretty on top of the validation layers, updating them as recently as last month. That pace is faster than LunarG SDK, who have yet to upgrade their packages for Ubuntu 20.04.
@abnercoimbre Would you be willing to create a PR with updates for the Linux instructions based on your findings?
Ubuntu 20.04 has been released. GLFW can now be safely installed from apt to get a very recent version.
Maybe there is an easier way too to get the Lunar package, but so far they haven't been updated for Ubuntu 20.04 yet.
The sdk also doesn't have an
./build_examples.sh
script so I am not sure what to do after downloading.