From 19749d74c812f463c5fb27ac3b37c22a79fde3d4 Mon Sep 17 00:00:00 2001 From: Artem Kharytoniuk Date: Fri, 17 Mar 2017 12:13:51 +0200 Subject: [PATCH] Created separate vulkan window with running demo and update it on each renderer tick. --- config/visual-studio/quake3.vcxproj | 7 +- config/visual-studio/renderer.vcxproj | 225 ++++-------------- config/visual-studio/renderer.vcxproj.filters | 33 +++ source/engine/platform/win_glimp.c | 20 ++ source/engine/platform/win_snd.c | 21 +- source/engine/renderer/tr_image.c | 4 +- source/engine/renderer/tr_local.h | 4 + source/engine/renderer/tr_main.c | 3 + source/engine/renderer/tr_scene.c | 6 + 9 files changed, 118 insertions(+), 205 deletions(-) diff --git a/config/visual-studio/quake3.vcxproj b/config/visual-studio/quake3.vcxproj index 40fd54f..f96351d 100644 --- a/config/visual-studio/quake3.vcxproj +++ b/config/visual-studio/quake3.vcxproj @@ -72,7 +72,6 @@ MultiThreadedDebug Level3 true - ProgramDatabase CompileAsCpp @@ -80,11 +79,12 @@ 0x0409 - winmm.lib;wsock32.lib;%(AdditionalDependencies) + SDL2.lib;Imm32.lib;Version.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) true true Windows 8388608 + $(ProjectDir)..\..\third_party\lib @@ -120,10 +120,11 @@ 0x0409 - winmm.lib;wsock32.lib;%(AdditionalDependencies) + SDL2.lib;Imm32.lib;Version.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) true Windows 8388608 + $(ProjectDir)..\..\third_party\lib diff --git a/config/visual-studio/renderer.vcxproj b/config/visual-studio/renderer.vcxproj index 61d0c07..ba5ba77 100644 --- a/config/visual-studio/renderer.vcxproj +++ b/config/visual-studio/renderer.vcxproj @@ -64,6 +64,7 @@ Level3 true CompileAsCpp + $(ProjectDir)..\..\third_party\include NDEBUG;%(PreprocessorDefinitions) @@ -71,7 +72,7 @@ true - SDL2.lib + vulkan-1.lib $(ProjectDir)..\..\third_party\lib @@ -85,6 +86,7 @@ true ProgramDatabase CompileAsCpp + $(ProjectDir)..\..\third_party\include _DEBUG;%(PreprocessorDefinitions) @@ -92,197 +94,52 @@ true - SDL2.lib + vulkan-1.lib $(ProjectDir)..\..\third_party\lib - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - - - Disabled - %(PreprocessorDefinitions) - EnableFastChecks - MaxSpeed - %(PreprocessorDefinitions) - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/visual-studio/renderer.vcxproj.filters b/config/visual-studio/renderer.vcxproj.filters index f525ce7..37b71dd 100644 --- a/config/visual-studio/renderer.vcxproj.filters +++ b/config/visual-studio/renderer.vcxproj.filters @@ -92,6 +92,21 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -133,5 +148,23 @@ jpeg + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/source/engine/platform/win_glimp.c b/source/engine/platform/win_glimp.c index 1d417c3..5cd3aa9 100644 --- a/source/engine/platform/win_glimp.c +++ b/source/engine/platform/win_glimp.c @@ -41,6 +41,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "glw_win.h" #include "win_local.h" +// VULKAN +#include "../../engine/renderer/vk_demo.h" +#define SDL_MAIN_HANDLED +#include "sdl/SDL.h" +#include "sdl/SDL_syswm.h" + + extern void WG_CheckHardwareGamma( void ); extern void WG_RestoreGamma( void ); @@ -678,6 +685,19 @@ static qboolean GLW_CreateWindow( const char *drivername, int width, int height, SetForegroundWindow( g_wv.hWnd ); SetFocus( g_wv.hWnd ); + // VULKAN + if (SDL_Init(SDL_INIT_VIDEO) != 0) + ri.Error(ERR_FATAL, "SDL_Init error"); + SDL_Window* window = SDL_CreateWindow("Vulkan app", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, SDL_WINDOW_SHOWN); + if (window == nullptr) + ri.Error(ERR_FATAL, "failed to create SDL window"); + SDL_SysWMinfo window_sys_info; + SDL_VERSION(&window_sys_info.version) + if (SDL_GetWindowWMInfo(window, &window_sys_info) == SDL_FALSE) + ri.Error(ERR_FATAL, "failed to get platform specific window information"); + vulkan_demo = new Vulkan_Demo(width, height, window_sys_info); + return qtrue; } diff --git a/source/engine/platform/win_snd.c b/source/engine/platform/win_snd.c index 2e7fdb1..b59df9c 100644 --- a/source/engine/platform/win_snd.c +++ b/source/engine/platform/win_snd.c @@ -133,22 +133,6 @@ qboolean SNDDMA_Init(void) { return qtrue; } -#undef DEFINE_GUID - -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } - -// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} -DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - -// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} -DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); - -DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); -DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - - int SNDDMA_InitDS () { HRESULT hresult; @@ -159,6 +143,11 @@ int SNDDMA_InitDS () Com_Printf( "Initializing DirectSound\n"); + const GUID CLSID_DirectSound = {0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0}; + const GUID CLSID_DirectSound8 = {0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b}; + const GUID IID_IDirectSound8 = {0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66}; + const GUID IID_IDirectSound = {0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60}; + use8 = 1; // Create IDirectSound using the primary sound device if( FAILED( hresult = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (void **)&pDS))) { diff --git a/source/engine/renderer/tr_image.c b/source/engine/renderer/tr_image.c index abba9a3..4a3b6a7 100644 --- a/source/engine/renderer/tr_image.c +++ b/source/engine/renderer/tr_image.c @@ -46,10 +46,10 @@ static void* q3_stbi_realloc(void* p, size_t old_size, size_t new_size) { #define STBI_FREE q3_stbi_free #define STBI_REALLOC_SIZED q3_stbi_realloc #define STB_IMAGE_IMPLEMENTATION -#include "../../../third_party/stb_image.h" +#include "stb_image.h" #define TJE_IMPLEMENTATION -#include "../../../third_party/tiny_jpeg.h" +#include "tiny_jpeg.h" static void LoadBMP( const char *name, byte **pic, int *width, int *height ); static void LoadTGA( const char *name, byte **pic, int *width, int *height ); diff --git a/source/engine/renderer/tr_local.h b/source/engine/renderer/tr_local.h index 9de4d64..73b33a3 100644 --- a/source/engine/renderer/tr_local.h +++ b/source/engine/renderer/tr_local.h @@ -964,6 +964,10 @@ extern trGlobals_t tr; extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init +// VULKAN +class Vulkan_Demo; +extern Vulkan_Demo* vulkan_demo; + // // cvars diff --git a/source/engine/renderer/tr_main.c b/source/engine/renderer/tr_main.c index 064dccd..4bcc823 100644 --- a/source/engine/renderer/tr_main.c +++ b/source/engine/renderer/tr_main.c @@ -25,6 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA trGlobals_t tr; +// VULKAN +Vulkan_Demo* vulkan_demo; + static float s_flipMatrix[16] = { // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) diff --git a/source/engine/renderer/tr_scene.c b/source/engine/renderer/tr_scene.c index dc15cfb..193fde8 100644 --- a/source/engine/renderer/tr_scene.c +++ b/source/engine/renderer/tr_scene.c @@ -22,6 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" +// VULKAN +#include "vk_demo.h" + int r_firstSceneDrawSurf; int r_numdlights; @@ -394,4 +397,7 @@ void RE_RenderScene( const refdef_t *fd ) { r_firstScenePoly = r_numpolys; tr.frontEndMsec += ri.Milliseconds() - startTime; + + // VULKAN + vulkan_demo->run_frame(); }