update:
just noticed i posted in OpenGL advanced forum which may not be best place for my question ? If so let me know how and where shall i move my post please, thanks in advance.
Hi, i been following post:
…setting up dev env in vs code:
- mingw Get Started with C++ and Mingw-w64 in Visual Studio Code
- GLFW
- GLAD
had a strange problem where i would compile the simple helloworld consout output to verify vs cide building/debugging with g++ and other cli ftom mingw (had to move helloworld.cpp out of google drive).
now going to continue the next step a simple window with a triangle.
Ok the point of this post, i been googling and reading many stuff to understand what APIs exist, shaders languages, the spir-v thingie , vulkan and im still struggling to have in simple ascii mode what apis tools people use, and even some concepts.
Bellow/final part of this post I sharemy plain text file where i keep updating as im researching/googling/interesting sentences.
In short my understanding now is:
- apis, theres open gl, directx and im wondering if vulkan is like opengl api as functions also start with glxxxxx() ?
- if yes does vukan needs or used opengl dll or is it standalone like *.h, *.cpp, *.lib and runtime like *.dll etc ?
- about shaders seems before vulkan we coded:
- HLSL for directx
- GLSL for opengl
but now with some cli tools (vulkan?) like gslang can compile 3) both HLSL or GLSL into SPIR-V bytecode. now my doubt what runtime gets used then ? does vulkan runtime executes on opengl dlls or d3d ? or does vulkan talks with gpu driver directly ?
- last-not-least heres sequences im wondering from perspective of developer:
4.1) uses opengl h/lib/dll + shaders in GLSL
4.2) uses vulkan h/lib/dll + shaders in GLSL compiled into SPIR-V via gslang/glsl (opengl .h/.lib or .dll not used right?)
4.3) for directx (which im not interested atm as i decided starting with 4.1 classic opengl (instead of what i think its alternative vulkan completely independent from opengl or not)
Thanks for any pointers, confirmations and/or rectifications on my still big foggy mind on these initial steps learning opengl.
-kb–apis.txt
1 high level shaders languages
- GLSL - opengl
- compiles to: glslang
- compiles to: SPIR-V
- HLSL - microsoft
- compiles to: glslang
- compiles to: DXC
- compiles to: SPIR-V
2 compilation to bytecode - what is distributed with game:
- SPIR-V
32-bit word stream - DXBC/DXIL (Microsoft has had 3 different byte code formats)
- Shader model 1-3 (D3D8-9)
- Shader model 4-5 (D3D10-12) ← DXBC bytecode
- Shader model 6 (D3D12) ← DXIL bytecode
3 driver
- microsoft D3D → uses DXBC/DXIL
- DXVK (vulkan driver) → uses SPIR-V (1)
HLL | tool | bytecode | api/driver |
-------±-----------------±---------------------------------------------------------------±-----------±-------------------
GLSL | glslang compiler | SPIR-V “A binary intermediate representation * cross api” | vulkan | March 2015
// SPIR-V Tools
Khronos have open sourced two projects on GitHub:
• glslang compiler (GLSL → SPIR-V) & SPIR-V remapper
https://github.com/KhronosGroup/glslang
• SPIR-V tools (assembler, disassembler, validator)
https://github.com/KhronosGroup/SPIRV-Tools
// compile GLSL shader into spv -V to output SPIR-V binary
./glslang –V –o our_shader.spv our_shader.frag
// spirv-dis takes SPIR-V binaries, turns them into a textual form
./spirv-dis –o our_shader.spvasm our_shader.spv
// spirv-as takes SPIR-V assembly, turns it into SPIR-V binaries
./spirv-as –o our_shader.spv our_shader.spvasm
-------±------------±-----------±----------
GLSL | ARB | < opengl 2 |
GLSL | glslang | opengl | opengl 4.1 driver |
HLSL | glslang | api/driver |
-------±------------±-----------±----------
HLSL | DXC/SPIR-V | vulkan |
HLSL | DXC/DXIL | d3d |
glslang compiler (GLSL → SPIR-V)
(1) note on multi platform:
- So for D3D11 game running on DXVK, the whole life cycle of a shader looks like this:
- Shader written in HLSL → compiled by the game dev to DXBC → DXVK compiles in run-time to SPIR-V → Vulkan driver compiles in run-time to GPU shader.