Merge branch 'kung' into vulkan-merge-2

This commit is contained in:
Eric Womer 2019-12-29 12:14:29 -05:00
commit 528da79001
13 changed files with 175 additions and 38 deletions

View file

@ -163,7 +163,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
#set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL})
#set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
@ -398,6 +398,7 @@ else (RAPIDJSON_FOUND)
endif (RAPIDJSON_FOUND)
add_subdirectory(idlib)
file(GLOB AAS_INCLUDES aas/*.h)
@ -536,7 +537,9 @@ endif()
file(GLOB MINIZIP_INCLUDES libs/zlib/minizip/*.h)
file(GLOB MINIZIP_SOURCES libs/zlib/minizip/*.c libs/zlib/minizip/*.cpp)
set(FREETYPE_SOURCES
libs/freetype/src/autofit/autofit.c
libs/freetype/src/bdf/bdf.c
@ -762,6 +765,7 @@ file(GLOB GAMED3XP_PHYSICS_SOURCES d3xp/physics/*.cpp)
file(GLOB GAMED3XP_SCRIPT_INCLUDES d3xp/script/*.h)
file(GLOB GAMED3XP_SCRIPT_SOURCES d3xp/script/*.cpp)
file(GLOB COMPILER_INCLUDES tools/compilers/*.h)
file(GLOB COMPILER_AAS_INCLUDES tools/compilers/aas/*.h)
@ -995,19 +999,15 @@ file(GLOB SDL_SOURCES sys/sdl/*.cpp)
source_group("aas" FILES ${AAS_INCLUDES})
source_group("aas" FILES ${AAS_SOURCES})
source_group("cm" FILES ${CM_INCLUDES})
source_group("cm" FILES ${CM_SOURCES})
source_group("framework" FILES ${FRAMEWORK_INCLUDES})
source_group("framework" FILES ${FRAMEWORK_SOURCES})
source_group("imgui" FILES ${FRAMEWORK_IMGUI_INCLUDES})
source_group("imgui" FILES ${FRAMEWORK_IMGUI_SOURCES})
source_group("renderer" FILES ${RENDERER_INCLUDES})
source_group("renderer" FILES ${RENDERER_SOURCES})
@ -1039,7 +1039,6 @@ source_group("renderer\\SMAA" FILES ${RENDERER_SMAA_INCLUDES})
source_group("renderer\\Shaders" FILES ${SHADERS})
source_group("libs\\irrxml" FILES ${IRRXML_INCLUDES})
source_group("libs\\irrxml" FILES ${IRRXML_SOURCES})
@ -1068,7 +1067,6 @@ source_group("libs\\rapidjson" FILES ${RAPIDJSON_INCLUDES})
source_group("libs\\freetype" FILES ${FREETYPE_SOURCES})
source_group("sound" FILES ${SOUND_INCLUDES})
source_group("sound" FILES ${SOUND_SOURCES})
@ -1084,19 +1082,15 @@ source_group("sound\\stub" FILES ${STUBAUDIO_SOURCES})
source_group("libs\\oggvorbis" FILES ${OGGVORBIS_INCLUDES})
source_group("libs\\oggvorbis" FILES ${OGGVORBIS_SOURCES})
source_group("ui" FILES ${UI_INCLUDES})
source_group("ui" FILES ${UI_SOURCES})
source_group("swf" FILES ${SWF_INCLUDES})
source_group("swf" FILES ${SWF_SOURCES})
source_group("sys" FILES ${SYS_INCLUDES})
source_group("sys" FILES ${SYS_SOURCES})
source_group("doomclassic" FILES ${DOOMCLASSIC_INCLUDES})
source_group("doomclassic" FILES ${DOOMCLASSIC_SOURCES})
@ -1104,7 +1098,6 @@ source_group("doomclassic" FILES ${DOOMCLASSIC_STUBAUDIO_SOURCES})
source_group("doomclassic" FILES ${DOOMCLASSIC_OPENAL_SOURCES})
source_group("doomclassic" FILES ${DOOMCLASSIC_XAUDIO2_SOURCES})
source_group("libs\\timidity" FILES ${TIMIDITY_INCLUDES})
source_group("libs\\timidity" FILES ${TIMIDITY_SOURCES})
@ -1131,6 +1124,8 @@ source_group("game-d3xp\\script" FILES ${GAMED3XP_SCRIPT_INCLUDES})
source_group("game-d3xp\\script" FILES ${GAMED3XP_SCRIPT_SOURCES})
source_group("sys\\win32" FILES ${WIN32_INCLUDES})
source_group("sys\\win32" FILES ${WIN32_SOURCES})
source_group("sys\\win32\\Resources" FILES ${WIN32_RESOURCES})
@ -1558,6 +1553,7 @@ if(MSVC)
endif()
else()
list(APPEND RBDOOM3_SOURCES
${SYS_INCLUDES} ${SYS_SOURCES})
@ -1624,6 +1620,7 @@ else()
${Vulkan_LIBRARY}
glslang
SPIRV
xcb
)
if(ENABLE_GLSLANG_BINARIES)
@ -1638,7 +1635,7 @@ else()
endif()
list(REMOVE_DUPLICATES RBDOOM3_SOURCES)
if(USE_PRECOMPILED_HEADERS)
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES} ${BINKDEC_SOURCES} ${IMGUI_SOURCES})
@ -1669,11 +1666,11 @@ else()
LIST(APPEND _compiler_FLAGS " -I${item}")
ENDFOREACH(item)
endif()
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
LIST(APPEND _compiler_FLAGS ${_directory_flags})
SEPARATE_ARGUMENTS(_compiler_FLAGS)
if(USE_PRECOMPILED_HEADERS)
# we need to recreate the precompiled header for RBDoom3BFG
# (i.e. can't use the one created for idlib before)
@ -1735,5 +1732,5 @@ else()
${CMAKE_DL_LIBS}
)
endif()
endif()

View file

@ -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

View file

@ -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"

View file

@ -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 ) )

View file

@ -698,11 +698,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" );
@ -745,8 +745,8 @@ 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() );
}
}
@ -761,4 +761,4 @@ CONSOLE_COMMAND( Vulkan_PrintAllocations, "Print out all the current allocations
#else
vulkanAllocator.Print();
#endif
}
}

View file

@ -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;
@ -304,6 +308,8 @@ static void EnumeratePhysicalDevices()
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 );
@ -314,11 +320,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." );
@ -330,6 +340,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." );
@ -424,6 +435,7 @@ 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;
@ -1277,30 +1289,37 @@ 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
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
@ -1320,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
@ -1663,7 +1688,7 @@ GL COMMANDS
|--------------------------| |-------------------------|
| ^
| |
`´ |
`\B4 |
|---------------------------------| |---------------------------------|
| | | |
| Backbuffer Semaphore | | Render Complete Semaphore |
@ -1671,7 +1696,7 @@ GL COMMANDS
|:--------------------------------| |---------------------------------|
| ^
| |
`´ |
`\B4 |
|-------------------------|
| vkQueueSubmit |
|-------------------------|
@ -2485,4 +2510,4 @@ void idRenderBackend::ImGui_RenderDrawLists( ImDrawData* draw_data )
// TODO
renderProgManager.Unbind();
}
}

View file

@ -397,8 +397,8 @@ static int CompileGLSLtoSPIRV( const char* filename, const idStr& dataGLSL, cons
#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
{
@ -406,7 +406,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

View file

@ -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
#endif

View file

@ -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()

View file

@ -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

View file

@ -49,6 +49,10 @@ static int cmdargc = 0;
#include <mcheck.h>
#endif
#ifdef USE_VULKAN
#include <xcb/xcb.h>
#endif
/*
==============
Sys_EXEPath
@ -515,6 +519,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
@ -532,6 +591,13 @@ int main( int argc, const char** argv )
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 )
@ -545,8 +611,16 @@ 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();
}
}

View file

@ -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

View file

@ -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
@ -100,6 +101,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
@ -479,6 +484,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 )
{
@ -556,7 +565,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 )
@ -578,6 +592,7 @@ void GLimp_Shutdown()
GLimp_SwapBuffers
===================
*/
#ifndef USE_VULKAN
void GLimp_SwapBuffers()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
@ -586,6 +601,7 @@ void GLimp_SwapBuffers()
SDL_GL_SwapBuffers();
#endif
}
#endif
/*
=================
@ -594,6 +610,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" );
@ -606,6 +623,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
}
/*