Closed RobertBeckebans closed 1 year ago
@RobertBeckebans wouldn't it also be wiser to have the GLSL as a source for the SPIR-V shader files instead of the discontinued CG? I could try to work on it.
Let me know if you want any help. Look forward to seeing it :)
SDL 2.0.6 has been release, which includes full Vulkan support. Perhaps that might also help? The builds haven't been released, yet, but you can compile it from source (you will probably want to do that anyways).
@ROCKNROLLKID +1 I second the use of SDL 2.0.6 for Vulkan Instance creation as soon as that is available. It would be the logical choice given that we're already using SDL for other parts of the engine.
Builds for SDL 2.0.6 are here: https://www.libsdl.org/tmp/download-2.0.php
I got the code for loading GLSL as a source file working, I'll do a PR pronto!
my pull request is ready: Use GLSL as source for the shaders instead of the CG files: annulled
I retired my previous PR because I did it from the OTE fork and so the PR included a lot of unwanted changes, Instead I patched up the two commits and uploaded the patch here: https://mega.nz/#!U2oj2YRb!e97gY1YTyVLJOXsw_41o6-sLyKDS0gOV51jmsx5kaLw
In order to apply the patch if you don't know how to do it, in your local repository extract the patch and type the following:
git am --signoff < fix_CG_dependency.patch
There shouldn't be any conflicts between this patch and the master, I've tried it successfully in a local clone. This patch move all the CG files to the new /renderprogs/cg/ directory. and then add changes to a single c++ file: neo/renderer/RenderProgs_GLSL.cpp
The instructions to follow in order to use the GLSL code remains the same as the pull request, it's a two step process:
First, generate the correct GLSL files in the correct folder:
+set r_useOpengl32 2 +set r_sourceGLSL 1 +set r_alwaysExportGLSL 1
Second, don't create GLSL files anymore and use the ones created:
+set r_useOpengl32 2 +set r_sourceGLSL 1 +set r_alwaysExportGLSL 0
Once at this stage, back in the c++ code, cvar r_sourceGLSL could be set to default 1, and cvar r_alwaysExportGLSL set to default 0. So we could start updating the GLSL code manually without remorse of it being automatically replaced.
If one runs the engine with just; +set r_useOpengl32 2
then the engine will still use the CG files as it has been doing up to this point.
@BielBdeLuna You should try to make a PR if you can. I am sure he is busy with a lot of other things to be jumping through hoops like that. Just a suggestion.
Yeah, I already have above, I might make the changes manually, it's just a single file, I'll look into it.
Or also, If someone has already a RBDoom3BFG fork, the inclination and time, and want to apply the patch and make a pull-request feel free :1st_place_medal:
so what is the decryption key for the download?
updated the link, sorry I though it didn't need that decryption key, it was my first time posting anything in Mega :)
cool, i'll check it out
Is Vulkan available?
I wonder as well if this is something we can test soon. It would be nice to get an update regarding the Vulkan status and/or difficulties.
@romulus2k4 and @raneon ignore my previous post, it looks like @RobertBeckebans got tied up in his main project, CattleAndCrops, and has postponed this for the time being.
And VR please too
You should have said months , not weeks.
Considering that this is an open sourced project licensed under GPL 3, where @RobertBeckebans is under no obligation, be it legal or otherwise, does not have to bend to demands.
It will be done when it is done.
What are you willing to offer to further development?
Looks like he managed to merge VkDoom3 into RBDoom 3. I guess he hasn't given up on this afterall. https://github.com/RobertBeckebans/RBDOOM-3-BFG/commit/735a925bd305e78a9d7528d9a56c7816c2296dc1
I haven't merged vkdoom3 yet. Only the parts of the refactoring process from last year.
I'm sorry I had to ship a game on Steam and had no energy left to do any programming stuff in my spare time. However I want to master Vulkan until the end of this year. I spent 18 years on OpenGL programming and OpenGL programming is really frustrating if you have to do all the guesswork what the driver might do. Dustin made a fantastic job in porting Doom 3 BFG to Vulkan and I'm going to reconstruct most of it and maybe in a slightly different manner. It is a great learning opportunity and I'm curious if I can fix the renderer bugs and performance problems when comparing all the new OpenGL code I wrote with the Vulkan stuff.
Great to here, is the current parts of the refactoring process from last year going to be the starting point or will you refactor the refactor, also is there any way you could blog about your process to sort of drag us along with your learning experience? It would really help, and I think before I was just upset because it seemed most of the developing community (namely Epic and some of their employees) just considered Vulkan as mobile only and didn't take it serious as a desktop api and blew it off, and before I found out about you working on CattleAndCrops I thought you fell into that category also. I am more upset that I don't have the programming skill to learn 3D engine programming let-a-lone Vulkan to even help out with this project.
I'm making good progress on the Vulkan backend. I can compile all new embedded RBDOOM shaders to SPIR-V and I get all images and geometries uploaded to the GPU. I updated the Vulkan Roadmap.
those are great news! whit Vulkan do we have still the possibility to use GLSL shaders and make the engine embed them into the SPIR-V intermediate?
Yes I can still embed the shaders. However I renamed the Doom 3 BFG .vertex and .pixel shaders to .vs.hlsl and .ps.hlsl in this branch. I added them to the solution through CMake and this allows me to use Visual Studio syntax highlighting and intellisense to jump between functions and function calls.
but that is DirectX nomenclature, the .vertex and .pixel shaders are CG files not DirectX shaders
I already had the CG files inside their own folder so GLSL could be in their own folder, so all the files are not mixed in a single folder, take a look at this comment: https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/398#issuecomment-329423037 and this pr for OTE where I did the same thing: https://github.com/BielBdeLuna/OpenTechBFG/commit/35353b90f09a29bf4274f164a0b0550948c7c833 and this one where GLSL is made the source of the shaders: https://github.com/BielBdeLuna/OpenTechBFG/commit/eacbcbdd43584ccc35b42b2cc85ba034233034cc
Is this still being worked on? I suppose vulkan support would make it a lot easier for an oculus Quest version to perform well.
Probably that is canned , at least months of inactivity implies that.
At least we still got this: https://github.com/MadDeCoDeR/Classic-RBDOOM-3-BFG
this project isnt dead but the vulkan backend seems to be lol
Yup.
Can you tag this as cancelled or something similar to that? At least that can prevent people from asking about status of it. @RobertBeckebans
he come back to it its just on hold atm
I get error: ‘VkXcbSurfaceCreateInfoKHR’ was not declared in this scope
when compiling on linux
I get
error: ‘VkXcbSurfaceCreateInfoKHR’ was not declared in this scope
when compiling on linux
@10010101001 don't cross post issues
looks like we finally getting finishing touches on this
I get
error: ‘VkXcbSurfaceCreateInfoKHR’ was not declared in this scope
when compiling on linux
That particular problems stems from the fact that there's a define missing prior to the vulkan include to make the headers assume X11/XCB specific versions of the API. Once you get a bit further in the compilation process, you then hit a road block where the code paths for CreateSurface fail. This stems from the fact that the WIN32 enabled code paths grab a separately tracked chunk of window data, including WIN32 handles, via an extern found in win_local.h, and populated in win_main.
The real problem is that all of the window management was more or less handled by GLX in the Linux world. Someone will need to wrangle this window management code somehow in some way in Linux via X11 lib calls or XCB calls if we want an analog. Another possible suggestion might be to allow SDL to do all the window management functions - as they seem to have somewhat sane functions to handle this with Vulkan in SDL2. It might mean, however, handing a lot of the Vulkan swapchain over to SDL to be managed, I'm not entirely sure on the specifics of that.
@KungFuJesus What branch are you on and what settings do you use for CMake?
Master, with USE_VULKAN on.
On Fri, Dec 27, 2019, 12:33 PM Eric notifications@github.com wrote:
@KungFuJesus https://github.com/KungFuJesus What branch are you on?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/398?email_source=notifications&email_token=AA3T3NJOEROQQ322OE4JVDDQ2Y36LA5CNFSM4DZLPS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHXQL3I#issuecomment-569312749, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3T3NMRKKHBVRHERROG26DQ2Y36LANCNFSM4DZLPS5Q .
I end up with this
CMake Error at CMakeLists.txt:319 (add_subdirectory):
add_subdirectory given source
"/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/glslang" which is not an
existing directory.
Got past that part by copying the glslang dir from neo/extern to neo/lib but now I have this issue
[34/642] Creating idlib/precompiled.h.gch for idlib
FAILED: idlib/CMakeFiles/precomp_header_idlib
cd /home/rake/src/Engines/RBDOOM-3-BFG/neo/idlib && /usr/bin/c++ -O3 -DNDEBUG -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/zlib -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/png -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/jpeg-6 -I/Include -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/glslang/glslang -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/rapidjson/include -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/idlib/. -pipe -Werror=format-security -Werror=format -std=c++11 -mmmx -msse -msse2 -DUSE_INTRINSICS -DUSE_EXCEPTIONS -march=native -DUSE_VULKAN -D__IDLIB__ -D__DOOM_DLL__ -x c++-header precompiled.h -o precompiled.h.gch
In file included from ../renderer/Vulkan/qvk.h:38,
from precompiled.h:93:
/usr/include/vulkan/vulkan.h:57:10: fatal error: windows.h: No such file or directory
57 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
[42/642] Building CXX object libs/glslang/SPIRV/CMakeFiles/SPIRV.dir/GlslangToSpv.cpp.o
ninja: build stopped: subcommand failed.
Yes, that's due the wrong define being hardcoded (there should be some
things from GLEW leaking into the USE_VULKAN protected code and some texture class that fails to build due to a GL texture number being dereferenced and returned, but ultimately the problem isn't going to be solved without using Xlib to establish a window and get an XCB window_t and connection_t - stashed away likely in some global extern and set in the main() function's body.
There's also a vulkan branch that seems to have slightly newer commits (but doesn't fix this X11/Linux specific problems) - I don't know which would be the more canonical thing to go on for the vkdoom3 integrations.
On Fri, Dec 27, 2019 at 3:08 PM Eric notifications@github.com wrote:
Got past that part by copying the glslang dir from neo/extern to neo/lib but now I have this issue
[34/642] Creating idlib/precompiled.h.gch for idlib FAILED: idlib/CMakeFiles/precomp_header_idlib cd /home/rake/src/Engines/RBDOOM-3-BFG/neo/idlib && /usr/bin/c++ -O3 -DNDEBUG -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/zlib -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/png -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/jpeg-6 -I/Include -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/glslang/glslang -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/libs/rapidjson/include -I/home/rake/src/Engines/RBDOOM-3-BFG/neo/idlib/. -pipe -Werror=format-security -Werror=format -std=c++11 -mmmx -msse -msse2 -DUSE_INTRINSICS -DUSE_EXCEPTIONS -march=native -DUSE_VULKAN -DIDLIB -D__DOOM_DLL__ -x c++-header precompiled.h -o precompiled.h.gch In file included from ../renderer/Vulkan/qvk.h:38, from precompiled.h:93: /usr/include/vulkan/vulkan.h:57:10: fatal error: windows.h: No such file or directory 57 | #include
| ^ ~~compilation terminated. [42/642] Building CXX object libs/glslang/SPIRV/CMakeFiles/SPIRV.dir/GlslangToSpv.cpp.o ninja: build stopped: subcommand failed.— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/398?email_source=notifications&email_token=AA3T3NIFWTLIREU5XJ2GPG3Q2ZOCLA5CNFSM4DZLPS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHXWLUQ#issuecomment-569337298, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3T3NMZ22UO2NU74MCNCKDQ2ZOCLANCNFSM4DZLPS5Q .
Unless RB-DOOM-BFG specifically utilizes the XCB window_t and connection_t variables specifically, you can use SDL2s implantation of accessing Vulkan but you will have to use SDL2s methods for initialization of those elements and not hard code via the Vulkan methods. Like with the change here, https://github.com/ericwomer/raytracer/blob/sdl-try-this-again/src/system/window/vk_core.cpp#L51
Right but by doing so SDL is a dependency rather than something optional for handling input. If the code were refactored to use SDL for the window management then a lot of the win32 code could probably be dumped as well, as SDL has platform independent glue. This of course diverges the code quite a bit further from vkdoom3, but I'd argue that project isn't actively contributed to, anyway.
The path of least resistance is likely to add some xlib shims.
On Fri, Dec 27, 2019, 4:09 PM Eric notifications@github.com wrote:
Unless RB-DOOM-BFG specifically utilizes the XCB window_t and connection_t variables specifically, you can use SDL2s implantation of accessing Vulkan but you will have to use SDL2s methods for initialization of those elements and not hard code via the Vulkan methods. Like with the change here, https://github.com/ericwomer/raytracer/blob/sdl-try-this-again/src/system/window/vk_core.cpp#L51
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/398?email_source=notifications&email_token=AA3T3NJEUBPOFLWV6HATUF3Q2ZVKHA5CNFSM4DZLPS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHXYQPY#issuecomment-569346111, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3T3NK6NSZ5I7IXRGKNCX3Q2ZVKHANCNFSM4DZLPS5Q .
If you want an SDL2 less implementation for Vulkan you can look at Intel's API without Secrets introduction to Vulkan tutorial.
Way ahead of ya - I have a patch that makes things compile but it errors out on a vkWaitForFences call.
See patch below:
diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt
index b8ef7fe..736204f 100644
--- a/neo/CMakeLists.txt
+++ b/neo/CMakeLists.txt
@@ -315,10 +315,10 @@ if(USE_VULKAN)
#option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
#option(ENABLE_OPT "Enables spirv-opt capability if present" ON)
- set(GLSLANG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/glslang)
- add_subdirectory(${GLSLANG_DIR})
+ #set(GLSLANG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/glslang)
+ #add_subdirectory(${GLSLANG_DIR})
- include_directories(${GLSLANG_DIR}/glslang)
+ #include_directories(${GLSLANG_DIR}/glslang)
else()
@@ -1321,6 +1321,7 @@ if(MSVC)
${Vulkan_LIBRARY}
glslang
SPIRV
+ xcb
)
if(ENABLE_GLSLANG_BINARIES)
diff --git a/neo/idlib/geometry/DrawVert.h b/neo/idlib/geometry/DrawVert.h
index 2c97f85..bbbe580 100644
--- a/neo/idlib/geometry/DrawVert.h
+++ b/neo/idlib/geometry/DrawVert.h
@@ -122,11 +122,11 @@ class idDrawVert
public:
idVec3 xyz; // 12 bytes
-private:
- // RB: don't let the old tools code mess with these values
halfFloat_t st[2]; // 4 bytes
byte normal[4]; // 4 bytes
byte tangent[4]; // 4 bytes -- [3] is texture polarity sign
+//private:
+ // RB: don't let the old tools code mess with these values
public:
byte color[4]; // 4 bytes
byte color2[4]; // 4 bytes -- weights for skinning
diff --git a/neo/idlib/precompiled.h b/neo/idlib/precompiled.h
index f476597..229e580 100644
--- a/neo/idlib/precompiled.h
+++ b/neo/idlib/precompiled.h
@@ -113,7 +113,7 @@ const uint32 NUM_FRAME_DATA = 2;
#include "../ui/UserInterface.h"
// RB: required for SWF extensions
-#include "rapidjson/document.h"
+//#include "rapidjson/document.h"
#include "../swf/SWF.h"
diff --git a/neo/idlib/sys/sys_types.h b/neo/idlib/sys/sys_types.h
index 7af3bbb..1a2e574 100644
--- a/neo/idlib/sys/sys_types.h
+++ b/neo/idlib/sys/sys_types.h
@@ -118,9 +118,9 @@ struct idNullPtr
//#endif
// C99 Standard
-#ifndef nullptr
-#define nullptr idNullPtr()
-#endif
+//#ifndef nullptr
+//#define nullptr idNullPtr()
+//#endif
#ifndef BIT
#define BIT( num ) ( 1ULL << ( num ) )
diff --git a/neo/renderer/Image.h b/neo/renderer/Image.h
index 183fee7..b69103b 100644
--- a/neo/renderer/Image.h
+++ b/neo/renderer/Image.h
@@ -394,7 +394,11 @@ public:
ActuallyLoadImage( true );
}
+ #ifndef USE_VULKAN
return ( void* )( intptr_t )texnum;
+ #else
+ return ( void* )( intptr_t )garbageIndex;
+ #endif
}
// DG end
diff --git a/neo/renderer/Vulkan/Allocator_VK.cpp b/neo/renderer/Vulkan/Allocator_VK.cpp
index 5a8236e..006cf22 100644
--- a/neo/renderer/Vulkan/Allocator_VK.cpp
+++ b/neo/renderer/Vulkan/Allocator_VK.cpp
@@ -610,11 +610,11 @@ CONSOLE_COMMAND( Vulkan_PrintHeapInfo, "Print out the heap information for this
{
VkPhysicalDeviceMemoryProperties& props = vkcontext.gpu->memProps;
- idLib::Printf( "Heaps %lu\n------------------------\n", props.memoryHeapCount );
+ idLib::Printf( "Heaps %u\n------------------------\n", props.memoryHeapCount );
for( uint32 i = 0; i < props.memoryHeapCount; ++i )
{
VkMemoryHeap heap = props.memoryHeaps[ i ];
- idLib::Printf( "id=%d, size=%llu, flags=", i, heap.size );
+ idLib::Printf( "id=%d, size=%lu, flags=", i, heap.size );
if( heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT )
{
idLib::Printf( "DEVICE_LOCAL" );
@@ -657,11 +657,11 @@ CONSOLE_COMMAND( Vulkan_PrintHeapInfo, "Print out the heap information for this
if( properties.Length() > 0 )
{
- idLib::Printf( "memory_type=%lu\n", j );
- idLib::Printf( properties.c_str() );
+ idLib::Printf( "memory_type=%u\n", j );
+ idLib::Printf( "%s", properties.c_str() );
}
}
idLib::Printf( "\n" );
}
-}
\ No newline at end of file
+}
diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp
index a3f865d..e6dcc44 100644
--- a/neo/renderer/Vulkan/RenderBackend_VK.cpp
+++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp
@@ -31,6 +31,10 @@ If you have questions concerning this license or the applicable additional terms
#pragma hdrstop
#include "precompiled.h"
+#ifdef __linux__
+#include "../../sys/posix/posix_public.h"
+#endif
+
#include "../RenderCommon.h"
#include "../RenderBackend.h"
#include "Staging_VK.h"
@@ -53,7 +57,7 @@ static const int g_numInstanceExtensions = 2;
static const char* g_instanceExtensions[ g_numInstanceExtensions ] =
{
VK_KHR_SURFACE_EXTENSION_NAME,
- VK_KHR_WIN32_SURFACE_EXTENSION_NAME
+ VK_KHR_XCB_SURFACE_EXTENSION_NAME
};
static const int g_numDebugInstanceExtensions = 1;
@@ -301,6 +305,8 @@ static void EnumeratePhysicalDevices()
uint32 numDevices = 0;
ID_VK_CHECK( vkEnumeratePhysicalDevices( vkcontext.instance, &numDevices, NULL ) );
ID_VK_VALIDATE( numDevices > 0, "vkEnumeratePhysicalDevices returned zero devices." );
+
+ idLib::Printf("found %u devices\n", numDevices);
idList< VkPhysicalDevice > devices;
devices.SetNum( numDevices );
@@ -312,11 +318,15 @@ static void EnumeratePhysicalDevices()
for( uint32 i = 0; i < numDevices; ++i )
{
+ idLib::Printf("Iterating over gpu %u\n", i);
gpuInfo_t& gpu = vkcontext.gpus[ i ];
+ idLib::Printf("have gpuInfo_t ref at %p\n", &vkcontext.gpus[i]);
gpu.device = devices[ i ];
+ idLib::Printf("set gpu.device\n");
// get Queue family properties
{
+ idLib::Printf("Getting queue family props...\n");
uint32 numQueues = 0;
vkGetPhysicalDeviceQueueFamilyProperties( gpu.device, &numQueues, NULL );
ID_VK_VALIDATE( numQueues > 0, "vkGetPhysicalDeviceQueueFamilyProperties returned zero queues." );
@@ -328,6 +338,7 @@ static void EnumeratePhysicalDevices()
// grab available Vulkan extensions
{
+ idLib::Printf("Getting available vulkan extensions...\n");
uint32 numExtension;
ID_VK_CHECK( vkEnumerateDeviceExtensionProperties( gpu.device, NULL, &numExtension, NULL ) );
ID_VK_VALIDATE( numExtension > 0, "vkEnumerateDeviceExtensionProperties returned zero extensions." );
@@ -422,10 +433,11 @@ static void CreateSurface()
VkXcbSurfaceCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = NULL;
+ createInfo.flags = 0;
createInfo.connection = info.connection;
createInfo.window = info.window;
- ID_VK_CHECK( vkCreateXcbSurfaceKHR( info.inst, &createInfo, NULL, &info.surface ) );
+ ID_VK_CHECK( vkCreateXcbSurfaceKHR( vkcontext.instance, &createInfo, NULL, &vkcontext.surface ) );
#endif // _WIN32
@@ -540,22 +552,22 @@ static void SelectPhysicalDevice()
switch( gpu.props.vendorID )
{
case 0x8086:
- idLib::Printf( "Vendor: Intel\n", i );
+ idLib::Printf( "Vendor: Intel\n");
glConfig.vendor = VENDOR_INTEL;
break;
case 0x10DE:
- idLib::Printf( "Vendor: NVIDIA\n", i );
+ idLib::Printf( "Vendor: NVIDIA\n");
glConfig.vendor = VENDOR_NVIDIA;
break;
case 0x1002:
- idLib::Printf( "Vendor: AMD\n", i );
+ idLib::Printf( "Vendor: AMD\n");
glConfig.vendor = VENDOR_AMD;
break;
default:
- idLib::Printf( "Vendor: Unknown (0x%x)\n", i, gpu.props.vendorID );
+ idLib::Printf( "Vendor: Unknown (0x%x)\n", gpu.props.vendorID );
}
return;
@@ -1276,30 +1288,38 @@ void idRenderBackend::Init()
glConfig.driverType = GLDRV_VULKAN;
glConfig.gpuSkinningAvailable = true;
+ idLib::Printf( "Creating Vulkan Instance...\n" );
// create the Vulkan instance and enable validation layers
CreateVulkanInstance();
// create the windowing interface
-#ifdef _WIN32
+//#ifdef _WIN32
+ idLib::Printf( "Creating Vulkan Surface...\n" );
CreateSurface();
-#endif
+//#endif
// Enumerate physical devices and get their properties
+ idLib::Printf( "Enumerating physical devices and their properties...\n" );
EnumeratePhysicalDevices();
// Find queue family/families supporting graphics and present.
+ idLib::Printf( "Selecting physical device...\n" );
SelectPhysicalDevice();
// Create logical device and queues
+ idLib::Printf( "Creating logical device and queues...\n" );
CreateLogicalDeviceAndQueues();
// Create semaphores for image acquisition and rendering completion
+ idLib::Printf( "Creating semaphores...\n" );
CreateSemaphores();
// Create Command Pool
+ idLib::Printf( "Creating command pool...\n" );
CreateCommandPool();
// Create Command Buffer
+ idLib::Printf( "Creating command buffer...\n" );
CreateCommandBuffer();
// setup the allocator
@@ -1319,21 +1339,27 @@ void idRenderBackend::Init()
#endif
// Start the Staging Manager
+ idLib::Printf( "Creating staging manager...\n" );
stagingManager.Init();
// Create Swap Chain
+ idLib::Printf( "Creating swapchain...\n" );
CreateSwapChain();
// Create Render Targets
+ idLib::Printf( "Creating render targets...\n" );
CreateRenderTargets();
// Create Render Pass
+ idLib::Printf( "Creating render pass...\n" );
CreateRenderPass();
// Create Pipeline Cache
+ idLib::Printf( "Creating pipeline cache...\n" );
CreatePipelineCache();
// Create Frame Buffers
+ idLib::Printf( "Creating frame buffers...\n" );
CreateFrameBuffers();
// init RenderProg Manager
@@ -2355,4 +2381,11 @@ void Framebuffer::Check()
void Framebuffer::CheckFramebuffers()
{
// TODO
-}
\ No newline at end of file
+}
+
+void idRenderBackend::ImGui_RenderDrawLists( ImDrawData* draw_data )
+{
+ // TODO
+
+ renderProgManager.Unbind();
+}
diff --git a/neo/renderer/Vulkan/RenderProgs_VK.cpp b/neo/renderer/Vulkan/RenderProgs_VK.cpp
index ee8901c..92298b9 100644
--- a/neo/renderer/Vulkan/RenderProgs_VK.cpp
+++ b/neo/renderer/Vulkan/RenderProgs_VK.cpp
@@ -343,8 +343,8 @@ CompileGLSLtoSPIRV
#include <glslang/Public/ShaderLang.h>
#include <glslang/Include/ResourceLimits.h>
-#include <SPIRV/GlslangToSpv.h>
-#include <StandAlone/DirStackFileIncluder.h>
+#include <glslang/SPIRV/GlslangToSpv.h>
+//#include <glslang/StandAlone/DirStackFileIncluder.h>
namespace glslang
{
@@ -352,7 +352,7 @@ namespace glslang
// These are the default resources for TBuiltInResources, used for both
// - parsing this string for the case where the user didn't supply one,
// - dumping out a template for user construction of a config file.
-#if 0
+#if 1
extern const TBuiltInResource DefaultTBuiltInResource;
#else
const TBuiltInResource DefaultTBuiltInResource =
diff --git a/neo/renderer/Vulkan/qvk.h b/neo/renderer/Vulkan/qvk.h
index dbd8b85..8e9c8bc 100644
--- a/neo/renderer/Vulkan/qvk.h
+++ b/neo/renderer/Vulkan/qvk.h
@@ -32,7 +32,8 @@ If you have questions concerning this license or the applicable additional terms
#if defined( USE_VULKAN )
-#define VK_USE_PLATFORM_WIN32_KHR
+//#define VK_USE_PLATFORM_XLIB_KHR
+#define VK_USE_PLATFORM_XCB_KHR
#define USE_AMD_ALLOCATOR
#include <vulkan/vulkan.h>
@@ -64,4 +65,4 @@ static const int MAX_UBO_PARMS = 2;
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/neo/renderer/Vulkan/vma.h b/neo/renderer/Vulkan/vma.h
index f0138a9..e70e965 100644
--- a/neo/renderer/Vulkan/vma.h
+++ b/neo/renderer/Vulkan/vma.h
@@ -766,6 +766,7 @@ remove them if not needed.
#include <cassert> // for assert
#include <algorithm> // for min, max
#include <mutex> // for std::mutex
+#include <string.h>
#if !defined(_WIN32)
#include <malloc.h> // for aligned_alloc()
diff --git a/neo/swf/SWF_Sprites.h b/neo/swf/SWF_Sprites.h
index ba1f652..6001d4f 100644
--- a/neo/swf/SWF_Sprites.h
+++ b/neo/swf/SWF_Sprites.h
@@ -29,6 +29,9 @@ If you have questions concerning this license or the applicable additional terms
#ifndef __SWF_SPRITES_H__
#define __SWF_SPRITES_H__
+#undef Bool
+#include "rapidjson/document.h"
+
/*
================================================
What the swf file format calls a "sprite" is known as a "movie clip" in Flash
diff --git a/neo/sys/posix/platform_linux.cpp b/neo/sys/posix/platform_linux.cpp
index 3837cea..afcee59 100644
--- a/neo/sys/posix/platform_linux.cpp
+++ b/neo/sys/posix/platform_linux.cpp
@@ -49,6 +49,10 @@ static int cmdargc = 0;
#include <mcheck.h>
#endif
+#ifdef USE_VULKAN
+#include <xcb/xcb.h>
+#endif
+
/*
==============
Sys_EXEPath
@@ -509,6 +513,61 @@ void Sys_ReLaunch()
// DG end
}
+#ifdef USE_VULKAN
+/* Declare the global posixInfo */
+posixInfo info;
+
+static void createWindow(size_t winWidth, size_t winHeight)
+{
+ /* establish the connection with DISPLAYNAME as NULL,
+ * this will leverage the DISPLAY env var */
+ int screenp = 0; /* which "screen" to use */
+ info.connection = xcb_connect(NULL, &screenp);
+
+ /* Check for errors */
+ int xcbErr = xcb_connection_has_error(info.connection);
+
+ if (xcbErr) {
+ common->Printf("Failed to connect to X server using XCB.");
+ exit(-1);
+ }
+
+ /* Setup the window, iterating through screens */
+ const struct xcb_setup_t *xcbSetup = NULL;
+ xcbSetup = xcb_get_setup(info.connection);
+
+ xcb_screen_iterator_t scrIter = xcb_setup_roots_iterator(xcbSetup);
+
+ for (int screen = screenp; screen > 0; --screen) {
+ xcb_screen_next(&scrIter);
+ }
+
+ info.screen = scrIter.data;
+
+ /* Now generate the xid used for our window */
+ info.window = xcb_generate_id(info.connection);
+
+ /* Register events, creating background pixel */
+ uint32_t eventMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
+ uint32_t valueList[] = { info.screen->black_pixel, 0 };
+
+ /* Create the window, finally */
+ xcb_create_window(info.connection, XCB_COPY_FROM_PARENT, info.window,
+ info.screen->root, 0, 0, winWidth, winHeight, 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, info.screen->root_visual,
+ eventMask, valueList);
+
+ /* Set some properties, such as the window name, maybe? */
+ xcb_change_property(info.connection, XCB_PROP_MODE_REPLACE,
+ info.window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING,
+ 8, 7, "vkDOOM3");
+
+ /* map the window to the screen and flush the stream to the server */
+ xcb_map_window(info.connection, info.window);
+ xcb_flush(info.connection);
+}
+#endif
+
/*
===============
main
@@ -525,7 +584,14 @@ int main( int argc, const char** argv )
mcheck( abrt_func );
Sys_Printf( "memory consistency checking enabled\n" );
#endif
-
+
+#ifdef USE_VULKAN
+ /* Create the window if using Vulkan */
+ xcb_generic_event_t *event;
+ xcb_client_message_event_t *cm;
+ createWindow(1920, 1080);
+#endif
+
Posix_EarlyInit( );
if( argc > 1 )
@@ -538,9 +604,17 @@ int main( int argc, const char** argv )
}
Posix_LateInit( );
+
while( 1 )
{
+#ifdef USE_VULKAN
+ /* I'm not 100% sure if intercepting these xcb events interferes with
+ * SDL's input handling or not, but I suspect that it's necessary
+ * to pump some event loop. We'll see */
+ /*event = xcb_wait_for_event(info.connection);
+ free(event); */
+#endif
common->Frame();
}
}
diff --git a/neo/sys/posix/posix_public.h b/neo/sys/posix/posix_public.h
index c0a9a05..8fc2d3f 100644
--- a/neo/sys/posix/posix_public.h
+++ b/neo/sys/posix/posix_public.h
@@ -31,6 +31,10 @@ If you have questions concerning this license or the applicable additional terms
#include <signal.h>
+#ifdef USE_VULKAN
+#include <xcb/xcb.h>
+#endif
+
void Posix_QueEvent( sysEventType_t type, int value, int value2, int ptrLength, void* ptr );
const char* Posix_Cwd();
@@ -66,5 +70,19 @@ enum clk_id_t { CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW };
int clock_gettime( clk_id_t clock, struct timespec* tp );
#endif
+#ifdef USE_VULKAN
+/* Struct that holds global xcb state for vulkan */
+typedef struct _posixInfo {
+ xcb_connection_t *connection;
+ xcb_window_t window;
+ xcb_screen_t *screen;
+ xcb_atom_t wmProtocols;
+ xcb_atom_t wmDeleteWin;
+} posixInfo;
+
+extern posixInfo info;
+
+#endif
+
#endif
diff --git a/neo/sys/sdl/sdl_glimp.cpp b/neo/sys/sdl/sdl_glimp.cpp
index 7c7967d..0f479f9 100644
--- a/neo/sys/sdl/sdl_glimp.cpp
+++ b/neo/sys/sdl/sdl_glimp.cpp
@@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms
*/
#include "../../idlib/precompiled.h"
+#include <GL/glew.h>
// DG: SDL.h somehow needs the following functions, so #undef those silly
// "don't use" #defines from Str.h
@@ -98,6 +99,10 @@ GLimp_Init
*/
bool GLimp_Init( glimpParms_t parms )
{
+ #ifdef USE_VULKAN
+ return true;
+ #endif
+
common->Printf( "Initializing OpenGL subsystem\n" );
GLimp_PreInit(); // DG: make sure SDL is initialized
@@ -439,6 +444,10 @@ GLimp_SetScreenParms
*/
bool GLimp_SetScreenParms( glimpParms_t parms )
{
+#ifdef USE_VULKAN
+ return true;
+#endif
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( parms.fullScreen > 0 || parms.fullScreen == -2 )
{
@@ -506,7 +515,12 @@ GLimp_Shutdown
*/
void GLimp_Shutdown()
{
+#ifdef USE_VULKAN
+ common->Printf( "Shutting down Vulkan subsystem\n" );
+ return;
+#else
common->Printf( "Shutting down OpenGL subsystem\n" );
+#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( context )
@@ -528,6 +542,7 @@ void GLimp_Shutdown()
GLimp_SwapBuffers
===================
*/
+#ifndef USE_VULKAN
void GLimp_SwapBuffers()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
@@ -536,6 +551,7 @@ void GLimp_SwapBuffers()
SDL_GL_SwapBuffers();
#endif
}
+#endif
/*
=================
@@ -544,6 +560,7 @@ GLimp_SetGamma
*/
void GLimp_SetGamma( unsigned short red[256], unsigned short green[256], unsigned short blue[256] )
{
+#ifndef USE_VULKAN
if( !window )
{
common->Warning( "GLimp_SetGamma called without window" );
@@ -556,6 +573,7 @@ void GLimp_SetGamma( unsigned short red[256], unsigned short green[256], unsigne
if( SDL_SetGammaRamp( red, green, blue ) )
#endif
common->Warning( "Couldn't set gamma ramp: %s", SDL_GetError() );
+#endif
}
/*
@KungFuJesus Are you using the distro supplied sdk packages or manually installed LunarG sdk?
@KungFuJesus Why are you trying to link to xcb using MSVC?
Just use SDL2 and save yourself a lot of trouble.
Just use SDL2 and save yourself a lot of trouble.
Two problems with that. First, it puts a hard dependency on SDL2, which I don't know if Robert is willing to go along with, and second, SDL2 only uses xlib, it doesn't use xcb for rendering with Vulkan. I don't know how important that second one is, but supposedly xcb was supposed to supplant xlib on the X server rendering side.
I'm going to merge the Vulkan code from vkDoom3 over the next weekends.
This will happen in several separated steps:
[x] I move existing OpenGL stuff in the renderer accordingly to vkDoom3 into the same places and refactor things like the renderer backend RB_ files into classes like idRendererBackend
[x] Change renderer prog system to generate vkglsl with our custom and new renderprogs like we do with different GLSL targets
[x] Attach glslang compiler library to generate SPIR-V code from vkglsl shaders
[x] Merge Vulkan renderer backend from vkDoom3 to work at least with stencil shadows and no HDR
[x] Get Imgui to work with Vulkan and replace com_drawFPS 2 with it
[x] Get Video Playback to work with Vulkan
[ ] Get Shadow Mapping to work with Vulkan
[ ] Get HDR and Tone Mapping to work with Vulkan
[ ] Get SSAO to work with Vulkan
[ ] Get SMAA to work with Vulkan