2016-07-12 00:40:13 +00:00
|
|
|
//#include "glquake.h"
|
|
|
|
|
2018-05-19 05:07:30 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#define VK_USE_PLATFORM_WIN32_KHR
|
|
|
|
#define VKInstWin32Funcs VKFunc(CreateWin32SurfaceKHR)
|
|
|
|
#elif defined(ANDROID)
|
2018-03-24 04:02:09 +00:00
|
|
|
#define VK_USE_PLATFORM_ANDROID_KHR
|
|
|
|
#define VKInstXLibFuncs VKFunc(CreateAndroidSurfaceKHR)
|
2017-10-13 17:50:28 +00:00
|
|
|
#elif defined(__linux__)
|
2018-08-23 07:04:55 +00:00
|
|
|
#ifndef NO_X11
|
|
|
|
#define VK_USE_PLATFORM_XLIB_KHR
|
|
|
|
#define VKInstXLibFuncs VKFunc(CreateXlibSurfaceKHR)
|
|
|
|
|
|
|
|
#define VK_USE_PLATFORM_XCB_KHR
|
|
|
|
#define VKInstXCBFuncs VKFunc(CreateXcbSurfaceKHR)
|
|
|
|
#endif
|
|
|
|
#ifdef WAYLANDQUAKE
|
|
|
|
#define VK_USE_PLATFORM_WAYLAND_KHR
|
|
|
|
#define VKInstWaylandFuncs VKFunc(CreateWaylandSurfaceKHR)
|
|
|
|
#endif
|
2018-05-19 05:07:30 +00:00
|
|
|
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
|
|
#define VK_USE_PLATFORM_XLIB_KHR
|
|
|
|
#define VKInstXLibFuncs VKFunc(CreateXlibSurfaceKHR)
|
|
|
|
|
|
|
|
#define VK_USE_PLATFORM_XCB_KHR
|
|
|
|
#define VKInstXCBFuncs VKFunc(CreateXcbSurfaceKHR)
|
2016-07-12 00:40:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define VK_NO_PROTOTYPES
|
2018-11-28 05:41:39 +00:00
|
|
|
#include <../vulkan/vulkan.h>
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
#if defined(_MSC_VER) && !defined(UINT64_MAX)
|
|
|
|
#define UINT64_MAX _UI64_MAX
|
2016-08-25 00:12:14 +00:00
|
|
|
#ifndef _UI64_MAX
|
|
|
|
#define _UI64_MAX 0xffffffffffffffffui64
|
|
|
|
#endif
|
2016-07-12 00:40:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VKInstWin32Funcs
|
|
|
|
#define VKInstWin32Funcs
|
|
|
|
#endif
|
|
|
|
#ifndef VKInstXLibFuncs
|
|
|
|
#define VKInstXLibFuncs
|
|
|
|
#endif
|
2016-07-30 17:59:55 +00:00
|
|
|
#ifndef VKInstXCBFuncs
|
|
|
|
#define VKInstXCBFuncs
|
|
|
|
#endif
|
2018-03-24 04:02:09 +00:00
|
|
|
#ifndef VKInstWaylandFuncs
|
|
|
|
#define VKInstWaylandFuncs
|
|
|
|
#endif
|
|
|
|
#define VKInstArchFuncs VKInstWin32Funcs VKInstXLibFuncs VKInstXCBFuncs VKInstWaylandFuncs
|
2016-07-30 17:59:55 +00:00
|
|
|
|
2018-11-19 06:37:25 +00:00
|
|
|
#ifdef VK_EXT_debug_utils
|
|
|
|
#define VKDebugFuncs \
|
|
|
|
VKFunc(SetDebugUtilsObjectNameEXT)
|
|
|
|
#else
|
|
|
|
#define VKDebugFuncs
|
|
|
|
#endif
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
//funcs needed for creating an instance
|
|
|
|
#define VKInstFuncs \
|
|
|
|
VKFunc(EnumerateInstanceLayerProperties) \
|
|
|
|
VKFunc(EnumerateInstanceExtensionProperties) \
|
|
|
|
VKFunc(CreateInstance)
|
|
|
|
|
|
|
|
//funcs specific to an instance
|
|
|
|
#define VKInst2Funcs \
|
|
|
|
VKFunc(EnumeratePhysicalDevices) \
|
2016-07-26 11:47:59 +00:00
|
|
|
VKFunc(EnumerateDeviceExtensionProperties) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(GetPhysicalDeviceProperties) \
|
|
|
|
VKFunc(GetPhysicalDeviceQueueFamilyProperties) \
|
|
|
|
VKFunc(GetPhysicalDeviceSurfaceSupportKHR) \
|
|
|
|
VKFunc(GetPhysicalDeviceSurfaceFormatsKHR) \
|
|
|
|
VKFunc(GetPhysicalDeviceSurfacePresentModesKHR) \
|
|
|
|
VKFunc(GetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
|
|
|
VKFunc(GetPhysicalDeviceMemoryProperties) \
|
2016-07-21 19:27:59 +00:00
|
|
|
VKFunc(GetPhysicalDeviceFormatProperties) \
|
2017-07-28 01:49:25 +00:00
|
|
|
VKFunc(GetPhysicalDeviceFeatures) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(DestroySurfaceKHR) \
|
|
|
|
VKFunc(CreateDevice) \
|
|
|
|
VKFunc(DestroyInstance) \
|
2018-11-19 06:37:25 +00:00
|
|
|
VKDebugFuncs \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKInstArchFuncs
|
|
|
|
|
|
|
|
//funcs specific to a device
|
|
|
|
#define VKDevFuncs \
|
|
|
|
VKFunc(AcquireNextImageKHR) \
|
|
|
|
VKFunc(QueuePresentKHR) \
|
|
|
|
VKFunc(CreateSwapchainKHR) \
|
|
|
|
VKFunc(GetSwapchainImagesKHR) \
|
|
|
|
VKFunc(DestroySwapchainKHR) \
|
|
|
|
VKFunc(CmdBeginRenderPass) \
|
|
|
|
VKFunc(CmdEndRenderPass) \
|
|
|
|
VKFunc(CmdBindPipeline) \
|
|
|
|
VKFunc(CmdDrawIndexedIndirect) \
|
|
|
|
VKFunc(CmdDraw) \
|
|
|
|
VKFunc(CmdDrawIndexed) \
|
|
|
|
VKFunc(CmdSetViewport) \
|
|
|
|
VKFunc(CmdSetScissor) \
|
|
|
|
VKFunc(CmdBindDescriptorSets) \
|
|
|
|
VKFunc(CmdBindIndexBuffer) \
|
|
|
|
VKFunc(CmdBindVertexBuffers) \
|
|
|
|
VKFunc(CmdPushConstants) \
|
2017-07-28 01:49:25 +00:00
|
|
|
VKFunc(CmdPushDescriptorSetKHR) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(CmdClearAttachments) \
|
|
|
|
VKFunc(CmdClearColorImage) \
|
|
|
|
VKFunc(CmdClearDepthStencilImage) \
|
|
|
|
VKFunc(CmdCopyImage) \
|
|
|
|
VKFunc(CmdCopyBuffer) \
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
VKFunc(CmdCopyImageToBuffer) \
|
2017-07-12 08:15:27 +00:00
|
|
|
VKFunc(CmdCopyBufferToImage) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(CmdBlitImage) \
|
|
|
|
VKFunc(CmdPipelineBarrier) \
|
2016-11-20 20:52:41 +00:00
|
|
|
VKFunc(CmdSetEvent) \
|
|
|
|
VKFunc(CmdResetEvent) \
|
|
|
|
VKFunc(CmdWaitEvents) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(CreateDescriptorSetLayout) \
|
|
|
|
VKFunc(DestroyDescriptorSetLayout) \
|
|
|
|
VKFunc(CreatePipelineLayout) \
|
|
|
|
VKFunc(DestroyPipelineLayout) \
|
|
|
|
VKFunc(CreateShaderModule) \
|
|
|
|
VKFunc(DestroyShaderModule) \
|
|
|
|
VKFunc(CreateGraphicsPipelines) \
|
|
|
|
VKFunc(DestroyPipeline) \
|
|
|
|
VKFunc(CreatePipelineCache) \
|
|
|
|
VKFunc(GetPipelineCacheData) \
|
|
|
|
VKFunc(DestroyPipelineCache) \
|
|
|
|
VKFunc(QueueSubmit) \
|
|
|
|
VKFunc(QueueWaitIdle) \
|
|
|
|
VKFunc(DeviceWaitIdle) \
|
|
|
|
VKFunc(BeginCommandBuffer) \
|
|
|
|
VKFunc(ResetCommandBuffer) \
|
|
|
|
VKFunc(EndCommandBuffer) \
|
|
|
|
VKFunc(DestroyDevice) \
|
|
|
|
VKFunc(GetDeviceQueue) \
|
|
|
|
VKFunc(GetBufferMemoryRequirements) \
|
|
|
|
VKFunc(GetImageMemoryRequirements) \
|
2018-06-18 16:44:29 +00:00
|
|
|
VKFunc(GetImageMemoryRequirements2KHR) \
|
2016-07-12 00:40:13 +00:00
|
|
|
VKFunc(GetImageSubresourceLayout) \
|
|
|
|
VKFunc(CreateFramebuffer) \
|
|
|
|
VKFunc(DestroyFramebuffer) \
|
|
|
|
VKFunc(CreateCommandPool) \
|
|
|
|
VKFunc(ResetCommandPool) \
|
|
|
|
VKFunc(DestroyCommandPool) \
|
|
|
|
VKFunc(CreateDescriptorPool) \
|
|
|
|
VKFunc(ResetDescriptorPool) \
|
|
|
|
VKFunc(DestroyDescriptorPool) \
|
|
|
|
VKFunc(AllocateDescriptorSets) \
|
|
|
|
VKFunc(CreateSampler) \
|
|
|
|
VKFunc(DestroySampler) \
|
|
|
|
VKFunc(CreateImage) \
|
|
|
|
VKFunc(DestroyImage) \
|
|
|
|
VKFunc(CreateBuffer) \
|
|
|
|
VKFunc(DestroyBuffer) \
|
|
|
|
VKFunc(AllocateMemory) \
|
|
|
|
VKFunc(FreeMemory) \
|
|
|
|
VKFunc(BindBufferMemory) \
|
|
|
|
VKFunc(BindImageMemory) \
|
|
|
|
VKFunc(MapMemory) \
|
|
|
|
VKFunc(FlushMappedMemoryRanges) \
|
|
|
|
VKFunc(UnmapMemory) \
|
|
|
|
VKFunc(UpdateDescriptorSets) \
|
|
|
|
VKFunc(AllocateCommandBuffers) \
|
|
|
|
VKFunc(FreeCommandBuffers) \
|
|
|
|
VKFunc(CreateRenderPass) \
|
|
|
|
VKFunc(DestroyRenderPass) \
|
|
|
|
VKFunc(CreateSemaphore) \
|
|
|
|
VKFunc(DestroySemaphore) \
|
|
|
|
VKFunc(CreateFence) \
|
|
|
|
VKFunc(GetFenceStatus) \
|
|
|
|
VKFunc(WaitForFences) \
|
|
|
|
VKFunc(ResetFences) \
|
|
|
|
VKFunc(DestroyFence) \
|
|
|
|
VKFunc(CreateImageView) \
|
|
|
|
VKFunc(DestroyImageView)
|
|
|
|
|
|
|
|
//all vulkan funcs
|
|
|
|
#define VKFuncs \
|
|
|
|
VKInstFuncs \
|
|
|
|
VKInst2Funcs \
|
|
|
|
VKDevFuncs \
|
|
|
|
VKFunc(GetInstanceProcAddr)\
|
|
|
|
VKFunc(GetDeviceProcAddr)
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef VK_NO_PROTOTYPES
|
|
|
|
#define VKFunc(n) extern PFN_vk##n vk##n;
|
|
|
|
VKFuncs
|
|
|
|
#undef VKFunc
|
|
|
|
#else
|
|
|
|
// #define VKFunc(n) static const PFN_vk##n vk##n = vk##n;
|
|
|
|
// VKFuncs
|
|
|
|
// #undef VKFunc
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define vkallocationcb NULL
|
|
|
|
#ifdef _DEBUG
|
2019-02-01 08:29:14 +00:00
|
|
|
#define VkAssert(f) do {VkResult err = f; if (err) Sys_Error("%s == %s", #f, VK_VKErrorToString(err)); } while(0)
|
|
|
|
#define VkWarnAssert(f) do {VkResult err = f; if (err) Con_Printf("%s == %s\n", #f, VK_VKErrorToString(err)); } while(0)
|
2016-07-12 00:40:13 +00:00
|
|
|
#else
|
|
|
|
#define VkAssert(f) f
|
2016-08-25 00:12:14 +00:00
|
|
|
#define VkWarnAssert(f) f
|
2016-07-12 00:40:13 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-18 16:44:29 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct vk_mempool_s *pool;
|
|
|
|
VkDeviceMemory memory;
|
|
|
|
size_t size;
|
|
|
|
size_t offset;
|
|
|
|
} vk_poolmem_t;
|
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
typedef struct vk_image_s
|
|
|
|
{
|
|
|
|
VkImage image;
|
2018-06-18 16:44:29 +00:00
|
|
|
vk_poolmem_t mem;
|
2016-07-12 00:40:13 +00:00
|
|
|
VkImageView view;
|
|
|
|
VkSampler sampler;
|
|
|
|
VkImageLayout layout;
|
|
|
|
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t layers;
|
|
|
|
uint32_t mipcount;
|
|
|
|
uint32_t encoding;
|
2017-07-28 01:49:25 +00:00
|
|
|
uint32_t type; //PTI_2D/3D/CUBE
|
2016-07-12 00:40:13 +00:00
|
|
|
} vk_image_t;
|
|
|
|
enum dynbuf_e
|
|
|
|
{
|
|
|
|
DB_VBO,
|
|
|
|
DB_EBO,
|
|
|
|
DB_UBO,
|
2017-07-28 01:49:25 +00:00
|
|
|
DB_STAGING,
|
2016-07-12 00:40:13 +00:00
|
|
|
DB_MAX
|
|
|
|
};
|
|
|
|
struct vk_rendertarg
|
|
|
|
{
|
2017-07-28 01:49:25 +00:00
|
|
|
VkCommandBuffer cbuf; //cbuf allocated for this render target.
|
2016-07-12 00:40:13 +00:00
|
|
|
VkFramebuffer framebuffer;
|
2017-07-28 01:49:25 +00:00
|
|
|
vk_image_t colour, depth, mscolour;
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2017-07-28 01:49:25 +00:00
|
|
|
image_t q_colour, q_depth, q_mscolour; //extra sillyness...
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
|
2019-07-16 02:59:12 +00:00
|
|
|
uint32_t rpassflags;
|
2016-07-12 00:40:13 +00:00
|
|
|
qboolean depthcleared; //starting a new gameview needs cleared depth relative to other views, but the first probably won't.
|
|
|
|
|
|
|
|
VkRenderPassBeginInfo restartinfo;
|
2016-08-25 00:12:14 +00:00
|
|
|
VkSemaphore presentsemaphore;
|
|
|
|
qboolean firstuse;
|
2020-05-14 15:50:26 +00:00
|
|
|
qboolean externalimage;
|
2017-07-28 01:49:25 +00:00
|
|
|
|
|
|
|
struct vk_rendertarg *prevtarg;
|
2016-07-28 13:18:22 +00:00
|
|
|
};
|
|
|
|
struct vk_rendertarg_cube
|
|
|
|
{
|
|
|
|
uint32_t size;
|
|
|
|
image_t q_colour, q_depth; //extra sillyness...
|
|
|
|
vk_image_t colour, depth;
|
|
|
|
struct vk_rendertarg face[6];
|
2016-07-12 00:40:13 +00:00
|
|
|
};
|
|
|
|
|
2016-11-20 20:52:41 +00:00
|
|
|
#define VQ_RENDER 0
|
|
|
|
#define VQ_PRESENT 1
|
|
|
|
#define VQ_ALTRENDER 2
|
|
|
|
#define VQ_ALTRENDER_COUNT 16
|
|
|
|
#define VQ_COUNT 3
|
2016-07-12 00:40:13 +00:00
|
|
|
extern struct vulkaninfo_s
|
|
|
|
{
|
|
|
|
unsigned short triplebuffer;
|
|
|
|
qboolean vsync;
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
qboolean allowsubmissionthread;
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2018-06-18 16:44:29 +00:00
|
|
|
qboolean khr_swapchain; //aka: not headless. we're actually rendering stuff!
|
|
|
|
qboolean nv_glsl_shader; //we can load glsl shaders. probably missing lots of reflection info though, so this is probably too limited.
|
|
|
|
qboolean khr_get_memory_requirements2; //slightly richer info
|
|
|
|
qboolean khr_dedicated_allocation; //standardised version of the above where the driver decides whether a resource is worth a dedicated allocation.
|
|
|
|
qboolean khr_push_descriptor; //more efficient descriptor streaming
|
|
|
|
qboolean amd_rasterization_order; //allows primitives to draw in any order
|
2019-09-04 08:32:22 +00:00
|
|
|
qboolean ext_astc_decode_mode; //small perf boost
|
2017-07-28 01:49:25 +00:00
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
VkInstance instance;
|
|
|
|
VkDevice device;
|
|
|
|
VkPhysicalDevice gpu;
|
|
|
|
VkSurfaceKHR surface;
|
2016-11-20 20:52:41 +00:00
|
|
|
uint32_t queuefam[VQ_COUNT];
|
|
|
|
uint32_t queuenum[VQ_COUNT];
|
2016-07-12 00:40:13 +00:00
|
|
|
VkQueue queue_render;
|
|
|
|
VkQueue queue_present;
|
2016-11-20 20:52:41 +00:00
|
|
|
VkQueue queue_alt[1];
|
2016-07-12 00:40:13 +00:00
|
|
|
VkPhysicalDeviceMemoryProperties memory_properties;
|
|
|
|
VkCommandPool cmdpool;
|
2017-07-28 01:49:25 +00:00
|
|
|
VkPhysicalDeviceLimits limits;
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2018-10-27 04:32:18 +00:00
|
|
|
#define ACQUIRELIMIT 8 //don't run more than this many frames behind
|
2017-11-14 14:37:04 +00:00
|
|
|
VkSemaphore acquiresemaphores[ACQUIRELIMIT];
|
2016-07-12 00:40:13 +00:00
|
|
|
VkFence acquirefences[ACQUIRELIMIT];
|
|
|
|
uint32_t acquirebufferidx[ACQUIRELIMIT];
|
|
|
|
unsigned int aquirenext;
|
|
|
|
volatile unsigned int aquirelast; //set inside the submission thread
|
|
|
|
|
|
|
|
VkPipelineCache pipelinecache;
|
|
|
|
|
|
|
|
struct vk_fencework
|
|
|
|
{
|
|
|
|
VkFence fence;
|
|
|
|
struct vk_fencework *next;
|
|
|
|
void (*Passed) (void*);
|
|
|
|
VkCommandBuffer cbuf;
|
|
|
|
} *fencework, *fencework_last; //callback for each fence as its passed. mostly for loading code or freeing memory.
|
|
|
|
|
|
|
|
int filtermip[3];
|
|
|
|
int filterpic[3];
|
|
|
|
int mipcap[2];
|
2019-02-19 06:49:03 +00:00
|
|
|
float lodbias;
|
2019-07-16 02:59:12 +00:00
|
|
|
float max_anistophy; //limits.maxSamplerAnistrophy
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2018-06-18 16:44:29 +00:00
|
|
|
struct vk_mempool_s
|
|
|
|
{
|
|
|
|
struct vk_mempool_s *next;
|
|
|
|
|
|
|
|
uint32_t memtype;
|
|
|
|
VkDeviceMemory memory;
|
|
|
|
|
|
|
|
//FIXME: replace with an ordered list of free blocks.
|
|
|
|
VkDeviceSize gaps;
|
|
|
|
VkDeviceSize memoryoffset;
|
|
|
|
VkDeviceSize memorysize;
|
|
|
|
} *mempools;
|
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
struct descpool
|
|
|
|
{
|
|
|
|
VkDescriptorPool pool;
|
2016-07-17 18:41:01 +00:00
|
|
|
int availsets;
|
|
|
|
int totalsets;
|
2016-07-12 00:40:13 +00:00
|
|
|
struct descpool *next;
|
|
|
|
} *descpool;
|
|
|
|
struct dynbuffer
|
|
|
|
{
|
2016-11-20 20:52:41 +00:00
|
|
|
size_t flushed; //size already copied to the gpu
|
|
|
|
size_t offset; //size written by the cpu (that might not yet be flushed)
|
|
|
|
size_t size; //maximum buffer size
|
2016-07-12 00:40:13 +00:00
|
|
|
size_t align;
|
2017-07-28 01:49:25 +00:00
|
|
|
qboolean stagingcoherent;
|
2016-07-12 00:40:13 +00:00
|
|
|
VkBuffer stagingbuf;
|
|
|
|
VkDeviceMemory stagingmemory;
|
|
|
|
VkBuffer devicebuf;
|
|
|
|
VkDeviceMemory devicememory;
|
2017-07-28 01:49:25 +00:00
|
|
|
VkBuffer renderbuf; //either staging or device. this is the buffer that we tell vulkan about
|
2016-07-12 00:40:13 +00:00
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
struct dynbuffer *next;
|
|
|
|
} *dynbuf[DB_MAX];
|
|
|
|
struct vk_rendertarg *backbufs;
|
|
|
|
struct vk_rendertarg *rendertarg;
|
|
|
|
struct vkframe {
|
|
|
|
struct vkframe *next;
|
|
|
|
struct dynbuffer *dynbufs[DB_MAX];
|
|
|
|
struct descpool *descpools;
|
2017-11-14 14:37:04 +00:00
|
|
|
VkSemaphore acquiresemaphore;
|
2017-07-28 01:49:25 +00:00
|
|
|
VkCommandBuffer *cbufs;
|
|
|
|
size_t numcbufs;
|
|
|
|
size_t maxcbufs;
|
2016-07-12 00:40:13 +00:00
|
|
|
VkFence finishedfence;
|
2017-07-28 01:49:25 +00:00
|
|
|
struct vk_frameend {
|
|
|
|
struct vk_frameend *next;
|
|
|
|
void (*FrameEnded) (void*);
|
|
|
|
} *frameendjobs;
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
struct vk_rendertarg *backbuf;
|
|
|
|
} *frame, *unusedframes;
|
2017-07-28 01:49:25 +00:00
|
|
|
struct vk_frameend *frameendjobs;
|
2016-07-12 00:40:13 +00:00
|
|
|
uint32_t backbuf_count;
|
|
|
|
|
2019-07-16 02:59:12 +00:00
|
|
|
#define RP_RESUME 0
|
|
|
|
#define RP_DEPTHCLEAR 1 //
|
|
|
|
#define RP_FULLCLEAR 2
|
|
|
|
#define RP_DEPTHONLY 3 //shadowmaps (clears depth)
|
|
|
|
#define RP_MULTISAMPLE (1u<<2)
|
|
|
|
#define RP_PRESENTABLE (1u<<3)
|
|
|
|
#define RP_FP16 (1u<<4)
|
|
|
|
VkRenderPass renderpass[1u<<5];
|
2016-07-12 00:40:13 +00:00
|
|
|
VkSwapchainKHR swapchain;
|
|
|
|
uint32_t bufferidx;
|
|
|
|
|
2017-07-28 01:49:25 +00:00
|
|
|
VkSampleCountFlagBits multisamplebits;
|
2016-07-12 00:40:13 +00:00
|
|
|
VkFormat depthformat;
|
|
|
|
VkFormat backbufformat;
|
2017-07-12 08:15:27 +00:00
|
|
|
qboolean srgbcapable;
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2017-07-28 01:49:25 +00:00
|
|
|
qboolean neednewswapchain; //something changed that invalidates the old one.
|
|
|
|
qboolean devicelost; //we seriously fucked up somewhere. or the gpu is shite.
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
struct vkwork_s
|
|
|
|
{
|
|
|
|
struct vkwork_s *next;
|
2016-11-20 20:52:41 +00:00
|
|
|
VkQueue queue;
|
2016-07-12 00:40:13 +00:00
|
|
|
VkCommandBuffer cmdbuf;
|
|
|
|
VkSemaphore semwait;
|
|
|
|
VkPipelineStageFlags semwaitstagemask;
|
|
|
|
VkSemaphore semsignal;
|
|
|
|
VkFence fencesignal;
|
|
|
|
|
|
|
|
struct vk_fencework *fencedwork;
|
|
|
|
struct vkframe *present;
|
|
|
|
} *work;
|
|
|
|
void *submitthread;
|
|
|
|
void *submitcondition;
|
2016-08-25 00:12:14 +00:00
|
|
|
void (*dopresent)(struct vkframe *theframe);
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
texid_t sourcecolour;
|
|
|
|
texid_t sourcedepth;
|
|
|
|
|
|
|
|
shader_t *scenepp_waterwarp;
|
2016-07-26 11:47:59 +00:00
|
|
|
shader_t *scenepp_antialias;
|
|
|
|
shader_t *scenepp_rescale;
|
2016-07-12 00:40:13 +00:00
|
|
|
} vk;
|
|
|
|
|
|
|
|
struct pipeline_s
|
|
|
|
{
|
|
|
|
struct pipeline_s *next;
|
|
|
|
unsigned int permu:16; //matches the permutation (masked by permutations that are supposed to be supported)
|
|
|
|
unsigned int flags:16; //matches the shader flags (cull etc)
|
|
|
|
unsigned int blendbits; //matches blend state.
|
|
|
|
VkPipeline pipeline;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t vk_find_memory_try(uint32_t typeBits, VkFlags requirements_mask);
|
|
|
|
uint32_t vk_find_memory_require(uint32_t typeBits, VkFlags requirements_mask);
|
|
|
|
|
2016-08-25 00:12:14 +00:00
|
|
|
void VK_DoPresent(struct vkframe *theframe);
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2017-09-20 11:27:13 +00:00
|
|
|
qboolean VK_Init(rendererstate_t *info, const char **sysextname, qboolean (*createSurface)(void), void (*dopresent)(struct vkframe *theframe));
|
2016-07-12 00:40:13 +00:00
|
|
|
void VK_Shutdown(void);
|
|
|
|
|
2016-07-28 13:18:22 +00:00
|
|
|
void VK_R_BloomBlend (texid_t source, int x, int y, int w, int h);
|
|
|
|
void VK_R_BloomShutdown(void);
|
|
|
|
qboolean R_CanBloom(void);
|
|
|
|
|
2016-07-26 11:47:59 +00:00
|
|
|
struct programshared_s;
|
2018-11-27 16:48:19 +00:00
|
|
|
struct programpermu_s;
|
|
|
|
qboolean VK_LoadGLSL(struct programshared_s *prog, struct programpermu_s *permu, int ver, const char **precompilerconstants, const char *vert, const char *tcs, const char *tes, const char *geom, const char *frag, qboolean noerrors, vfsfile_t *blobfile);
|
2016-07-26 11:47:59 +00:00
|
|
|
|
2017-07-28 01:49:25 +00:00
|
|
|
VkCommandBuffer VK_AllocFrameCBuf(void);
|
|
|
|
void VK_Submit_Work(VkCommandBuffer cmdbuf, VkSemaphore semwait, VkPipelineStageFlags semwaitstagemask, VkSemaphore semsignal, VkFence fencesignal, struct vkframe *presentframe, struct vk_fencework *fencedwork);
|
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
void VKBE_Init(void);
|
|
|
|
void VKBE_InitFramePools(struct vkframe *frame);
|
|
|
|
void VKBE_RestartFrame(void);
|
|
|
|
void VKBE_FlushDynamicBuffers(void);
|
|
|
|
void VKBE_Set2D(qboolean twodee);
|
|
|
|
void VKBE_ShutdownFramePools(struct vkframe *frame);
|
|
|
|
void VKBE_Shutdown(void);
|
|
|
|
void VKBE_SelectMode(backendmode_t mode);
|
|
|
|
void VKBE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **mesh, vbo_t *vbo, texnums_t *texnums, unsigned int beflags);
|
|
|
|
void VKBE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, unsigned int beflags);
|
|
|
|
void VKBE_SubmitBatch(batch_t *batch);
|
|
|
|
batch_t *VKBE_GetTempBatch(void);
|
|
|
|
void VKBE_GenBrushModelVBO(model_t *mod);
|
2017-11-30 17:59:11 +00:00
|
|
|
void VKBE_ClearVBO(vbo_t *vbo, qboolean dataonly);
|
2016-07-12 00:40:13 +00:00
|
|
|
void VKBE_UploadAllLightmaps(void);
|
2016-11-20 20:52:41 +00:00
|
|
|
void VKBE_DrawWorld (batch_t **worldbatches);
|
2016-07-12 00:40:13 +00:00
|
|
|
qboolean VKBE_LightCullModel(vec3_t org, model_t *model);
|
|
|
|
void VKBE_SelectEntity(entity_t *ent);
|
|
|
|
qboolean VKBE_SelectDLight(dlight_t *dl, vec3_t colour, vec3_t axis[3], unsigned int lmode);
|
|
|
|
void VKBE_VBO_Begin(vbobctx_t *ctx, size_t maxsize);
|
|
|
|
void VKBE_VBO_Data(vbobctx_t *ctx, void *data, size_t size, vboarray_t *varray);
|
|
|
|
void VKBE_VBO_Finish(vbobctx_t *ctx, void *edata, size_t esize, vboarray_t *earray, void **vbomem, void **ebomem);
|
|
|
|
void VKBE_VBO_Destroy(vboarray_t *vearray, void *mem);
|
|
|
|
void VKBE_Scissor(srect_t *rect);
|
2019-07-02 04:12:20 +00:00
|
|
|
void VKBE_BaseEntTextures(const qbyte *scenepvs, const int *sceneareas);
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
struct vk_shadowbuffer;
|
|
|
|
struct vk_shadowbuffer *VKBE_GenerateShadowBuffer(vecV_t *verts, int numverts, index_t *indicies, int numindicies, qboolean istemp);
|
|
|
|
void VKBE_DestroyShadowBuffer(struct vk_shadowbuffer *buf);
|
|
|
|
void VKBE_RenderShadowBuffer(struct vk_shadowbuffer *buf);
|
2018-01-22 19:18:04 +00:00
|
|
|
void VKBE_SetupForShadowMap(dlight_t *dl, int texwidth, int texheight, float shadowscale);
|
2016-07-12 00:40:13 +00:00
|
|
|
qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height);
|
|
|
|
void VKBE_BeginShadowmapFace(void);
|
|
|
|
void VKBE_DoneShadows(void);
|
|
|
|
|
2016-07-28 13:18:22 +00:00
|
|
|
void VKBE_RT_Gen_Cube(struct vk_rendertarg_cube *targ, uint32_t size, qboolean clear);
|
2020-05-14 15:50:26 +00:00
|
|
|
void VKBE_RT_Gen(struct vk_rendertarg *targ, vk_image_t *colour, uint32_t width, uint32_t height, qboolean clear, unsigned int flags);
|
2016-07-28 13:18:22 +00:00
|
|
|
void VKBE_RT_Begin(struct vk_rendertarg *targ);
|
2017-07-28 01:49:25 +00:00
|
|
|
void VKBE_RT_End(struct vk_rendertarg *targ);
|
2016-07-12 00:40:13 +00:00
|
|
|
void VKBE_RT_Destroy(struct vk_rendertarg *targ);
|
|
|
|
|
2019-02-01 08:29:14 +00:00
|
|
|
char *VK_VKErrorToString(VkResult err); //helper for converting vulkan error codes to strings, if we get something unexpected.
|
2016-07-12 00:40:13 +00:00
|
|
|
|
2018-06-18 16:44:29 +00:00
|
|
|
qboolean VK_AllocatePoolMemory(uint32_t pooltype, VkDeviceSize memsize, VkDeviceSize poolalignment, vk_poolmem_t *mem);
|
|
|
|
void VK_ReleasePoolMemory(vk_poolmem_t *mem);
|
|
|
|
qboolean VK_AllocateImageMemory(VkImage image, qboolean dedicated, vk_poolmem_t *mem); //dedicated should normally be TRUE for render targets
|
2018-09-29 17:31:58 +00:00
|
|
|
qboolean VK_AllocateBindImageMemory(vk_image_t *image, qboolean dedicated); //dedicated should normally be TRUE for render targets
|
2016-07-12 00:40:13 +00:00
|
|
|
struct stagingbuf
|
|
|
|
{
|
|
|
|
VkBuffer buf;
|
|
|
|
VkBuffer retbuf;
|
2018-06-18 16:44:29 +00:00
|
|
|
vk_poolmem_t mem;
|
2016-07-12 00:40:13 +00:00
|
|
|
size_t size;
|
|
|
|
VkBufferUsageFlags usage;
|
|
|
|
};
|
2018-11-19 06:37:25 +00:00
|
|
|
vk_image_t VK_CreateTexture2DArray(uint32_t width, uint32_t height, uint32_t layers, uint32_t mips, uploadfmt_t encoding, unsigned int type, qboolean rendertarget, const char *debugname);
|
2018-03-24 04:02:09 +00:00
|
|
|
void set_image_layout(VkCommandBuffer cmd, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkAccessFlags srcaccess, VkPipelineStageFlagBits srcstagemask, VkImageLayout new_image_layout, VkAccessFlags dstaccess, VkPipelineStageFlagBits dststagemask);
|
2016-07-12 00:40:13 +00:00
|
|
|
void VK_CreateSampler(unsigned int flags, vk_image_t *img);
|
|
|
|
void *VKBE_CreateStagingBuffer(struct stagingbuf *n, size_t size, VkBufferUsageFlags usage);
|
2018-06-18 16:44:29 +00:00
|
|
|
VkBuffer VKBE_FinishStaging(struct stagingbuf *n, vk_poolmem_t *memptr);
|
2016-07-12 00:40:13 +00:00
|
|
|
void *VK_FencedBegin(void (*passed)(void *work), size_t worksize);
|
|
|
|
void VK_FencedSubmit(void *work);
|
|
|
|
void VK_FencedCheck(void);
|
2017-07-28 01:49:25 +00:00
|
|
|
void *VK_AtFrameEnd(void (*passed)(void *work), void *data, size_t worksize);
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void VK_Draw_Init(void);
|
|
|
|
void VK_Draw_Shutdown(void);
|
|
|
|
|
2019-02-19 06:49:03 +00:00
|
|
|
void VK_UpdateFiltering (image_t *imagelist, int filtermip[3], int filterpic[3], int mipcap[2], float lodbias, float anis);
|
2017-08-14 16:38:44 +00:00
|
|
|
qboolean VK_LoadTextureMips (texid_t tex, const struct pendingtextureinfo *mips);
|
2016-07-12 00:40:13 +00:00
|
|
|
void VK_DestroyTexture (texid_t tex);
|
|
|
|
void VK_DestroyVkTexture (vk_image_t *img);
|
|
|
|
|
|
|
|
void VK_R_Init (void);
|
|
|
|
void VK_R_DeInit (void);
|
|
|
|
void VK_R_RenderView (void);
|
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
char *VKVID_GetRGBInfo (int *bytestride, int *truevidwidth, int *truevidheight, enum uploadfmt *fmt);
|
2016-07-12 00:40:13 +00:00
|
|
|
|
|
|
|
qboolean VK_SCR_UpdateScreen (void);
|
|
|
|
|
|
|
|
void VKBE_RenderToTextureUpdate2d(qboolean destchanged);
|
2019-07-16 02:59:12 +00:00
|
|
|
VkRenderPass VK_GetRenderPass(int pass);
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
|
|
|
|
//improved rgb get that calls the callback when the data is actually available. used for video capture.
|
|
|
|
void VKVID_QueueGetRGBData (void (*gotrgbdata) (void *rgbdata, qintptr_t bytestride, size_t width, size_t height, enum uploadfmt fmt));
|