130 points · by gulpahum · 10y ago · 70 comments
People have been aware of this problem for some time. It's one of the reasons the C++ community is trying to develop a proper module system (or was the last time I checked, which was a while back).
I like Rust and all, but C++ isn't going away in the next three years.
https://github.com/jherico/Vulkan
Here's a basic tutorial with comments for the Vulkan C API. Vulkan is a very low level API, so there's a lot of code. It should be straightforward to port the C tutorial to use the C++ API.
edit: for the downvoters, I'd LOVE to be happily corrected with a link to documentation about C language support for a type safe enum.
enum a { A };
enum b { B };
static enum a a = B;
$ clang -Wenum-conversion -Werror a.c b.c:4:19: error: implicit conversion from enumeration type 'enum b' to different enumeration type 'enum a' [-Werror,-Wenum-conversion]
static enum a a = B;
~ ^
1 error generated.I'm not very knowledge regarding Vulkan so hopefully that isn't a stupid question but I want to brush up on my C++ skills and play with this!
Also how similar is Vulkan to SDL? I used to use SDL quite a bit back in the day and it was awesome but I'm assuming Vulkan is far more comprehensive?
They are not. You use SDL to create and manage your window and handle input, and use Vulkan or OpenGL to draw to that window.
With that in mind, if you are working on a AAA game that will come out in a couple of years, your target platforms will most likely be PS4, Xbox One and Windows 10. With those three, Vulkan doesn't make sense; DX12 will be used on Windows and Xbox One, and PS4 has its own proprietary API. Why complicate things with another API if you can use (almost) the same implementation for Xbox One and Windows 10?
If Windows 7 proves itself to be still somewhat popular amongs gamers, then Vulkan might be used to port games to this platform, since it's similar to DX12 so it will be way easier than a DX11 port.
However, right now, if game developers wants to use the latest API, Vulkan is a good choice since you will still be able to target Windows 7. If a lot of big games are released with Vulkan within 2 years, then it might slow down Windows 10's adoption and the market share of Vulkan systems (Windows Vista and up) will stay greater than the DX12 one (Windows 10) for longer. But for how many years? At one point, Windows 10 (or whatever's after) will dominate and the backward compatibility of Vulkan will stop being a useful marketing point.
So I'm not sure why you say there's no reason to use DX12. There's many. There's also a lot of good reasons to choose Vulkan that I didn't talk about here. I just don't see how Vulkan can dominates the Windows market, much like OpenGL.
- iOS
- macOS
- PSP, PS3, PS4
- Wii U, 3DS
- XBox 360, ONE
- any Android version < Android 7
- UWP
But the point he was making was that there is no need for DX12 because Vulkan works everywhere else.
Right now Vulkan is only supported on custom Android 6 forks for Samsung S7 and NVidia Shield, Android 7, GNU/Linux and Windows on a restricted set of graphic cards.
Hardly a market to target for game developers that want to reach as much eyes as possible.
Though I'm sure there are ways around it, etc. I'm not very knowledgable on the subject but I'd certainly love to know more :)
Your statement couldnʼt have been more misleading. Vulkan is a cross{vendor,platform} API, based on AMD Mantle.
after you google it first, please.
It was gifted to Kronos from AMD where it had been called mantle.
For example, capturing a game screenshot. In OpenGL you have a method glReadPixels which will flush the GPU queue, wait for operations to finish, read the screen pixels, convert them and put them into an array. All in one method, all outside of programmer's control, done somewhere in the driver. Meanwhile in Vulkan, same task requires programmer to flush GPU, wait for operations to finish, allocate memory for an image, create an image in linear format, transition image to proper state (transfer destination), transition swapchain image to transfer source, blit the pixels from swapchain image (which could be linear, could be tiled) to linear image, transition swapchain image back, map memory of the linear image. A single line of code in OpenGL translates to about 50 lines of Vulkan code (lot of it is stuff you'll write once and reuse everywhere else), but you have full control over each of the steps.