fix building and running on linux

This commit is contained in:
Ivan 'provod' Avdeev 2021-06-06 14:17:35 -07:00
parent b58eb5b4b2
commit 656c00d0b8
12 changed files with 30 additions and 16 deletions

View File

@ -19,7 +19,7 @@
#define PRINT_NOT_IMPLEMENTED_ARGS(msg, ...) do { \
static int called = 0; \
if ((called&1023) == 0) { \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s " msg "\n", called, __FUNCTION__, __VA_ARGS__ ); \
gEngine.Con_Printf( S_ERROR "VK NOT_IMPLEMENTED(x%d): %s " msg "\n", called, __FUNCTION__, ##__VA_ARGS__ ); \
} \
++called; \
} while(0)

View File

@ -190,11 +190,11 @@ static void loadDeviceFunctions(dllfunc_t *funcs, int count)
static qboolean createInstance( void )
{
char ** instance_extensions = NULL;
const char ** instance_extensions = NULL;
unsigned int num_instance_extensions = vk_core.debug ? 1 : 0;
VkApplicationInfo app_info = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.apiVersion = vk_core.rtx ? VK_API_VERSION_1_2 : VK_API_VERSION_1_0,
.apiVersion = vk_core.rtx ? VK_API_VERSION_1_2 : VK_API_VERSION_1_1,
.applicationVersion = VK_MAKE_VERSION(0, 0, 0), // TODO
.engineVersion = VK_MAKE_VERSION(0, 0, 0),
.pApplicationName = "",
@ -286,8 +286,10 @@ static qboolean hasExtension( const VkExtensionProperties *exts, uint32_t num_ex
static qboolean deviceSupportsRtx( const VkExtensionProperties *exts, uint32_t num_exts )
{
for (int i = 1 /* skip swapchain ext */; i < ARRAYSIZE(device_extensions); ++i) {
if (!hasExtension(exts, num_exts, device_extensions[i]))
if (!hasExtension(exts, num_exts, device_extensions[i])) {
gEngine.Con_Reportf(S_ERROR "Extension %s is not supported\n", device_extensions[i]);
return false;
}
}
return true;
}
@ -328,15 +330,17 @@ static qboolean pickAndCreateDevice( void )
for (uint32_t j = 0; j < num_queue_family_properties; ++j)
{
VkBool32 present = 0;
if (!(queue_family_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT))
if (!(queue_family_props[j].queueFlags & VK_QUEUE_GRAPHICS_BIT))
continue;
vkGetPhysicalDeviceSurfaceSupportKHR(physical_devices[i], j, vk_core.surface.surface, &present);
gEngine.Con_Reportf("Queue %d/%d present: %d\n", j, num_queue_family_properties, present);
if (!present)
continue;
queue_index = i;
queue_index = j;
break;
}

View File

@ -100,7 +100,6 @@ do { \
if (result != VK_SUCCESS) { \
gEngine.Con_Printf( S_ERROR "%s:%d " #f " failed (%d): %s\n", \
__FILE__, __LINE__, result, resultName(result)); \
Sleep(3000); \
gEngine.Host_Error( S_ERROR "%s:%d " #f " failed (%d): %s\n", \
__FILE__, __LINE__, result, resultName(result)); \
} \

View File

@ -143,14 +143,14 @@ void VK_DescriptorsCreate(vk_descriptors_t *desc)
int j;
for (j = 0; j < num_desc_types; ++j) {
if (pools[j].type == bind->descriptorType) {
pools[j].descriptorCount++;
pools[j].descriptorCount += bind->descriptorCount;
break;
}
}
if (j == num_desc_types) {
ASSERT(num_desc_types < ARRAYSIZE(pools));
pools[j].descriptorCount = 1;
pools[j].descriptorCount = bind->descriptorCount;
pools[j].type = bind->descriptorType;
++num_desc_types;
}
@ -158,7 +158,9 @@ void VK_DescriptorsCreate(vk_descriptors_t *desc)
VkDescriptorPoolCreateInfo dpci = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.maxSets = 1, .poolSizeCount = num_desc_types, .pPoolSizes = pools,
.maxSets = desc->num_sets,
.poolSizeCount = num_desc_types,
.pPoolSizes = pools,
};
XVK_CHECK(vkCreateDescriptorPool(vk_core.device, &dpci, NULL, &desc->desc_pool));
}

View File

@ -3,6 +3,7 @@
#include "vk_2d.h"
#include "vk_scene.h"
#include "vk_render.h"
#include "vk_rtx.h"
#include "eiface.h"

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h> // isalnum...
vk_lights_t g_lights = {0};

View File

@ -1,6 +1,6 @@
#ifdef USE_AFTERMATH
#include "vk_nv_aftermath.h"
#ifdef USE_AFTERMATH
#include "vk_common.h"
#include "xash3d_types.h"

View File

@ -1,5 +1,7 @@
#pragma once
#ifdef USE_AFTERMATH
#include "xash3d_types.h"
qboolean VK_AftermathInit();
void VK_AftermathShutdown();
#endif

View File

@ -113,5 +113,9 @@ void VK_RenderModelDynamicCommit( void );
void VK_RenderFrameEnd( VkCommandBuffer cmdbuf );
void VK_RenderFrameEndRTX( VkCommandBuffer cmdbuf, VkImageView img_dst_view, VkImage img_dst, uint32_t w, uint32_t h );
// void VK_RenderDebugLabelBegin( const char *label );
// void VK_RenderDebugLabelEnd( void );
void VK_RenderDebugLabelBegin( const char *label );
void VK_RenderDebugLabelEnd( void );
void VK_RenderBegin( void );
void VK_RenderEnd( VkCommandBuffer cmdbuf );
void VK_RenderEndRTX( VkCommandBuffer cmdbuf, VkImageView img_dst_view, VkImage img_dst, uint32_t w, uint32_t h );

View File

@ -9,6 +9,7 @@
#include "vk_sprite.h"
#include "vk_studio.h"
#include "vk_beams.h"
#include "vk_brush.h"
#include "xash3d_types.h"
#include "com_strings.h"

View File

@ -218,6 +218,7 @@ static vk_ray_model_t *getModelFromCache(int num_geoms, const VkAccelerationStru
int i;
for (i = 0; i < ARRAYSIZE(g_rtx.models_cache); ++i)
{
int j;
model = g_rtx.models_cache + i;
if (model->taken)
continue;
@ -228,7 +229,6 @@ static vk_ray_model_t *getModelFromCache(int num_geoms, const VkAccelerationStru
if (model->num_geoms != num_geoms)
continue;
int j;
for (j = 0; j < num_geoms; ++j) {
if (model->geoms[j].geometryType != geoms[j].geometryType)
break;
@ -1060,7 +1060,7 @@ vk_ray_model_t* VK_RayModelCreate( vk_ray_model_init_t args ) {
VkAccelerationStructureGeometryKHR *geoms;
uint32_t *geom_max_prim_counts;
VkAccelerationStructureBuildRangeInfoKHR *geom_build_ranges;
VkAccelerationStructureBuildRangeInfoKHR **geom_build_ranges_ptr;
const VkAccelerationStructureBuildRangeInfoKHR **geom_build_ranges_ptr;
const VkDeviceAddress buffer_addr = getBufferDeviceAddress(args.buffer);
vk_kusok_data_t *kusochki;
const uint32_t kusochki_count_offset = VK_RingBuffer_Alloc(&g_rtx.kusochki_alloc, args.model->num_geometries, 1);

View File

@ -77,7 +77,7 @@ def build(bld):
# libs.append(bld.env.AFTERMATH_LIB)
# libpath.append(bld.env.AFTERMATH_LIBDIR)
bld.env.CFLAGS += ["/WX"]
#bld.env.CFLAGS += ["/WX"]
bld.shlib(
source = source,