From 24cd9a1c213a5f421fff40f3a7798a1117ce37bb Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 17 Jul 2016 18:41:01 +0000 Subject: [PATCH] update triptohell's self-signed cert. fix some more compile-time issues. fix some vulkan issues that are probably what's breaking amd gpus. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5005 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_parse.c | 2 +- engine/client/cl_tent.c | 1 - engine/client/merged.h | 39 -- engine/client/screen.h | 42 +- engine/client/view.c | 2 +- engine/common/bothdefs.h | 3 +- engine/common/net_ssl_winsspi.c | 9 +- engine/d3d/d3d_backend.c | 23 +- engine/dotnet2005/ftequake.vcproj | 1 + engine/gl/gl_screen.c | 2 +- engine/gl/gl_shader.c | 2 + engine/gl/gl_vidcommon.c | 2 +- engine/gl/r_bishaders.h | 144 +++--- engine/http/httpclient.c | 7 +- engine/server/net_preparse.c | 2 +- engine/shaders/generatebuiltinsl.c | 33 ++ engine/shaders/vulkan/depthonly.glsl | 2 +- engine/vk/vk_backend.c | 738 ++++++++++++++------------- engine/vk/vk_init.c | 52 +- engine/vk/vkrenderer.h | 2 + plugins/Makefile | 27 +- plugins/cef/cef.c | 2 + quakec/menusys/menu/options_audio.qc | 1 + 23 files changed, 651 insertions(+), 487 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index f23a6019a..db04fc256 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -376,7 +376,7 @@ void CL_CalcNet2 (float *pings, float *pings_min, float *pings_max, float *pingm *pings = 0; *pings_max = 0; - *pings_min = 1000000000000; + *pings_min = FLT_MAX; *pingfr = 0; *pingfr_max = 0; *pingfr_min = 0x7fffffff; diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 5cfef162c..ffd50cebb 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -191,7 +191,6 @@ typedef struct { int ef_impact; } tentmodels_t; -typedef struct beam_s beam_t; struct beam_s { tentmodels_t *info; int entity; diff --git a/engine/client/merged.h b/engine/client/merged.h index 52dd42682..1e7c86976 100644 --- a/engine/client/merged.h +++ b/engine/client/merged.h @@ -193,45 +193,6 @@ extern int r_regsequence; // qbyte *Mod_LeafPVS (struct mleaf_s *leaf, struct model_s *model, qbyte *buffer); #endif -typedef enum uploadfmt -{ - TF_INVALID, - TF_RGBA32, /*rgba byte order*/ - TF_BGRA32, /*bgra byte order*/ - TF_RGBX32, /*rgb byte order, with extra wasted byte after blue*/ - TF_BGRX32, /*rgb byte order, with extra wasted byte after blue*/ - TF_RGB24, /*rgb byte order, no alpha channel nor pad, and regular top down*/ - TF_BGR24, /*bgr byte order, no alpha channel nor pad, and regular top down*/ - TF_BGR24_FLIP, /*bgr byte order, no alpha channel nor pad, and bottom up*/ - TF_LUM8, /*8bit greyscale image*/ - TF_MIP4_LUM8, /*8bit 4-mip greyscale image*/ - TF_MIP4_SOLID8, /*8bit 4-mip image*/ - TF_MIP4_8PAL24, /*8bit 4-mip image*/ - TF_SOLID8, /*8bit quake-palette image*/ - TF_TRANS8, /*8bit quake-palette image, index 255=transparent*/ - TF_TRANS8_FULLBRIGHT, /*fullbright 8 - fullbright texels have alpha 255, everything else 0*/ - TF_HEIGHT8, /*image data is greyscale, convert to a normalmap and load that, uploaded alpha contains the original heights*/ - TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/ - TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/ - TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/ - TF_H2_T4A4, /*8bit data, weird packing*/ - - /*this block requires a palette*/ - TF_PALETTES, - TF_8PAL24, - TF_8PAL32, - - /*for render targets*/ - TF_DEPTH16, - TF_DEPTH24, - TF_DEPTH32, - TF_RGBA16F, - TF_RGBA32F, - - /*for weird systems where the gl driver needs to do the decode (read: webgl)*/ - TF_SYSTEMDECODE -} uploadfmt_t; - enum { TEX_NOTLOADED, diff --git a/engine/client/screen.h b/engine/client/screen.h index 5ec25f0e9..e15bdd934 100644 --- a/engine/client/screen.h +++ b/engine/client/screen.h @@ -80,7 +80,47 @@ void SCR_ShowPic_Remove_f(void); //a header is better than none... void Draw_TextBox (int x, int y, int width, int lines); enum fs_relative; -enum uploadfmt; + + +typedef enum uploadfmt +{ + TF_INVALID, + TF_RGBA32, /*rgba byte order*/ + TF_BGRA32, /*bgra byte order*/ + TF_RGBX32, /*rgb byte order, with extra wasted byte after blue*/ + TF_BGRX32, /*rgb byte order, with extra wasted byte after blue*/ + TF_RGB24, /*rgb byte order, no alpha channel nor pad, and regular top down*/ + TF_BGR24, /*bgr byte order, no alpha channel nor pad, and regular top down*/ + TF_BGR24_FLIP, /*bgr byte order, no alpha channel nor pad, and bottom up*/ + TF_LUM8, /*8bit greyscale image*/ + TF_MIP4_LUM8, /*8bit 4-mip greyscale image*/ + TF_MIP4_SOLID8, /*8bit 4-mip image*/ + TF_MIP4_8PAL24, /*8bit 4-mip image*/ + TF_SOLID8, /*8bit quake-palette image*/ + TF_TRANS8, /*8bit quake-palette image, index 255=transparent*/ + TF_TRANS8_FULLBRIGHT, /*fullbright 8 - fullbright texels have alpha 255, everything else 0*/ + TF_HEIGHT8, /*image data is greyscale, convert to a normalmap and load that, uploaded alpha contains the original heights*/ + TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/ + TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/ + TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/ + TF_H2_T4A4, /*8bit data, weird packing*/ + + /*this block requires a palette*/ + TF_PALETTES, + TF_8PAL24, + TF_8PAL32, + + /*for render targets*/ + TF_DEPTH16, + TF_DEPTH24, + TF_DEPTH32, + TF_RGBA16F, + TF_RGBA32F, + + /*for weird systems where the gl driver needs to do the decode (read: webgl)*/ + TF_SYSTEMDECODE +} uploadfmt_t; + qboolean SCR_ScreenShot (char *filename, enum fs_relative fsroot, void **buffer, int numbuffers, int width, int height, enum uploadfmt fmt); void SCR_DrawTwoDimensional(int uimenu, qboolean nohud); diff --git a/engine/client/view.c b/engine/client/view.c index 02a358647..a5556861d 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -325,7 +325,7 @@ qbyte gammatable[256]; // palette is sent through this unsigned short ramps[3][256]; -//extern qboolean gammaworks; +qboolean gammaworks; float hw_blend[4]; // rgba 0.0 - 1.0 /* void BuildGammaTable (float g) diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index a84d6871f..510970d43 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -218,7 +218,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef SERVERONLY // #define USE_MYSQL //allow mysql in dedicated servers. #endif - #if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) + #if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) #define SUBSERVERS //use subserver code. #elif defined(__linux__) && !defined(ANDROID) && !defined(FTE_SDL) #define SUBSERVERS //use subserver code. @@ -422,6 +422,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MULTITHREAD #define WEBCLIENT #endif + #undef SUBSERVERS #endif #if (defined(NOLOADERTHREAD) || !defined(MULTITHREAD)) && defined(LOADERTHREAD) diff --git a/engine/common/net_ssl_winsspi.c b/engine/common/net_ssl_winsspi.c index 699266e2a..629bd718d 100644 --- a/engine/common/net_ssl_winsspi.c +++ b/engine/common/net_ssl_winsspi.c @@ -344,7 +344,8 @@ static void SSPI_Encode(sslfile_t *f) //these are known sites that use self-signed certificates, or are special enough that we don't trust corporate networks to hack in their own certificate authority for a proxy/mitm //old static const qbyte triptohell_certdata[933] = "\x30\x82\x03\xa1\x30\x82\x02\x89\xa0\x03\x02\x01\x02\x02\x09\x00\x8b\xd0\x05\x63\x62\xd1\x6a\xe3\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x67\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x42\x44\x31\x0c\x30\x0a\x06\x03\x55\x04\x08\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x07\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x0b\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x03\x0c\x03\x42\x61\x64\x31\x12\x30\x10\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x09\x01\x16\x03\x42\x61\x64\x30\x1e\x17\x0d\x31\x34\x31\x32\x32\x34\x32\x32\x34\x32\x34\x37\x5a\x17\x0d\x32\x34\x31\x32\x32\x31\x32\x32\x34\x32\x34\x37\x5a\x30\x67\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x42\x44\x31\x0c\x30\x0a\x06\x03\x55\x04\x08\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x07\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x0b\x0c\x03\x42\x61\x64\x31\x0c\x30\x0a\x06\x03\x55\x04\x03\x0c\x03\x42\x61\x64\x31\x12\x30\x10\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x09\x01\x16\x03\x42\x61\x64\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01\x01\x00\xaf\x10\x33\xfa\x39\xf5\xae\x2c\x91\x0e\x20\xe6\x3c\x5c\x7c\x1e\xeb\x16\x50\x2f\x05\x30\xfe\x67\xee\xa9\x00\x54\xd9\x4a\x86\xe6\xba\x80\xfb\x1a\x80\x08\x7e\x7b\x13\xe5\x1a\x18\xc9\xd4\x70\xbd\x5d\xc4\x38\xef\x64\xf1\x90\x2c\x53\x49\x93\x24\x36\x3e\x11\x59\x69\xa6\xdf\x37\xb2\x54\x82\x28\x3e\xdd\x30\x75\xa0\x18\xd8\xe1\xf5\x52\x73\x12\x5b\x37\x68\x1c\x59\xbd\x8c\x73\x66\x47\xbc\xcb\x9c\xfe\x38\x92\x8f\x74\xe9\xd1\x2f\x96\xd2\x5d\x6d\x11\x59\xb2\xdc\xbd\x8c\x37\x5b\x22\x76\x98\xe7\xbe\x08\xef\x1e\x99\xc4\xa9\x77\x2c\x9c\x0e\x08\x3c\x8e\xab\x97\x0c\x6a\xd7\x03\xab\xfd\x4a\x1e\x95\xb2\xc2\x9c\x3a\x16\x65\xd7\xaf\x45\x5f\x6e\xe7\xce\x51\xba\xa0\x60\x43\x0e\x07\xc5\x0b\x0a\x82\x05\x26\xc4\x92\x0a\x27\x5b\xfc\x57\x6c\xdf\xe2\x54\x8a\xef\x38\xf1\xf8\xc4\xf8\x51\x16\x27\x1f\x78\x89\x7c\x5b\xd7\x53\xcd\x9b\x54\x2a\xe6\x71\xee\xe4\x56\x2e\xa4\x09\x1a\x61\xf7\x0f\x97\x22\x94\xd7\xef\x21\x6c\xe6\x81\xfb\x54\x5f\x09\x92\xac\xd2\x7c\xab\xd5\xa9\x81\xf4\xc9\xb7\xd6\xbf\x68\xf8\x4f\xdc\xf3\x60\xa3\x3b\x29\x92\x9e\xdd\xa2\xa3\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x19\xed\xd0\x7b\x16\xaf\xb5\x0c\x9a\xe8\xd3\x46\x2e\x3c\x64\x29\xb6\xc1\x73\x5a\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x19\xed\xd0\x7b\x16\xaf\xb5\x0c\x9a\xe8\xd3\x46\x2e\x3c\x64\x29\xb6\xc1\x73\x5a\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x82\x01\x01\x00\x62\xa7\x26\xeb\xd4\x03\x29\x9c\x09\x33\x69\x7a\x9c\x65\x68\xec\x4c\xb9\x06\xeb\x1e\x51\x6f\x78\x20\xdc\xf6\x44\x5e\x06\x6e\x53\x87\x73\xe6\x14\x15\xb9\x17\x74\x67\xe0\x4e\x48\x38\xbc\x1c\xbd\xd0\xad\xd6\xbd\x8c\xf0\x3a\xe0\x13\x73\x19\xad\x8b\x79\x68\x67\x65\x9b\x7a\x4c\x81\xfb\xd9\x92\x77\x89\xb5\xb0\x53\xb0\xa5\xf7\x2d\x8e\x29\x60\x31\xd1\x9b\x2f\x63\x8a\x5f\x64\xc1\x61\xd5\xb7\xdf\x70\x3b\x2b\xf6\x1a\x96\xb9\xa7\x08\xca\x87\xa6\x8c\x60\xca\x6e\xd7\xee\xba\xef\x89\x0b\x93\xd5\xfd\xfc\x14\xba\xef\x27\xba\x90\x11\x90\xf7\x25\x70\xe7\x4e\xf4\x9c\x13\x27\xc1\xa7\x8e\xd9\x66\x43\x72\x20\x5b\xe1\x5c\x73\x74\xf5\x33\xf2\xa5\xf6\xe1\xd5\xac\xf3\x67\x5c\xe7\xd4\x0a\x8d\x91\x73\x03\x3e\x9d\xbc\x96\xc3\x0c\xdb\xd5\x77\x6e\x76\x44\x69\xaf\x24\x0f\x4f\x8b\x47\x36\x8b\xc3\xd6\x36\xdd\x26\x5a\x9c\xdd\x9c\x43\xee\x29\x43\xdd\x75\x2f\x19\x52\xfc\x1d\x24\x9c\x13\x29\x99\xa0\x6d\x7a\x95\xcc\xa0\x58\x86\xd8\xc5\xb9\xa3\xc2\x3d\x64\x1d\x85\x8a\xca\x53\x55\x8e\x9a\x6d\xc9\x91\x73\xf4\xe1\xe1\xa4\x9b\x76\xfc\x7f\x63\xc2\xb9\x23"; -static const qbyte triptohell_certdata[917] = "\x30\x82\x03\x91\x30\x82\x02\x79\xa0\x03\x02\x01\x02\x02\x09\x00\xb5\x71\x47\x8d\x5e\x66\xf1\xd9\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x30\x5f\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x46\x54\x45\x31\x1c\x30\x1a\x06\x03\x55\x04\x03\x0c\x13\x66\x74\x65\x2e\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x1e\x17\x0d\x31\x34\x31\x32\x32\x35\x30\x30\x35\x38\x31\x34\x5a\x17\x0d\x31\x37\x30\x33\x30\x34\x30\x30\x35\x38\x31\x34\x5a\x30\x5f\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x46\x54\x45\x31\x1c\x30\x1a\x06\x03\x55\x04\x03\x0c\x13\x66\x74\x65\x2e\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01\x01\x00\xdd\xb8\x7c\x69\x3d\x63\x95\xe3\x88\x15\xfd\xad\x93\x5e\x6b\x97\xfb\x74\xba\x1f\x83\x33\xe5\x8a\x8d\x8f\xb0\xbf\xf9\xd3\xa1\x2c\x65\x53\xa7\xef\xd3\x0f\xdc\x03\x60\x0a\x40\xef\xa8\xef\x3f\xb3\xd9\x8d\x31\x39\x12\x8a\xd8\x0e\x24\x8f\xe5\x58\x26\x86\x4c\x76\x6c\x59\x9a\xab\xea\x1c\x3d\xfb\x62\x62\xad\xaf\xd6\x00\x33\x76\x2d\xbb\xeb\xe8\xec\xb4\x76\x4f\xb0\xbe\xcf\xf0\x46\x94\x40\x02\x99\xd4\xb2\x71\x71\xd6\xf5\x1f\xc3\x4f\x1e\x1e\xb4\x0d\x82\x49\xc4\xa2\xdc\xae\x6f\x4e\x3a\xf9\x0e\xdd\xf4\xd2\x53\xe3\xe7\x7d\x58\x79\xf4\xce\x1f\x6c\xac\x81\x8c\x8c\xe1\x03\x5b\x22\x56\x92\x19\x4f\x74\xc0\x36\x41\xac\x1b\xfa\x9e\xf7\x2a\x0f\xd6\x4b\xcc\x9a\xca\x67\x87\xb7\x95\xdf\xb7\xd4\x7d\x8c\xcc\xa9\x25\xde\xdd\x8c\x1b\xd7\x32\xf2\x84\x25\x46\x7b\x10\x55\xf9\x80\xfd\x5d\xad\xab\xf9\x4c\x1f\xc0\xa5\xd1\x3f\x01\x86\x4d\xfa\x57\xab\x7a\x6d\xec\xf1\xdb\xf4\xad\xf2\x33\xcd\xa0\xed\xfe\x1b\x27\x55\x56\xba\x8c\x47\x70\x16\xd5\x75\x17\x8e\x80\xaa\x49\x5e\x93\x83\x1d\x6f\x1f\x2c\xf7\xa7\x64\xe6\x2e\x88\x8e\xff\x70\x5a\x41\x52\xae\x93\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x4e\x76\x4a\xce\x7b\x45\x14\x39\xeb\x9c\x28\x56\xb5\x7b\x8a\x18\x6f\x22\x17\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x4e\x76\x4a\xce\x7b\x45\x14\x39\xeb\x9c\x28\x56\xb5\x7b\x8a\x18\x6f\x22\x17\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x03\x82\x01\x01\x00\x48\x22\x65\xed\x2e\xc5\xed\xbb\xe9\x40\x6c\x80\xc4\x63\x19\xd1\x00\xb4\x30\x34\x17\x7c\x7c\xbd\x1b\xc5\xa9\x43\x0c\x92\x6e\xd6\x2d\x11\x6c\x0d\xa6\xda\x30\xe9\xf7\x46\x7b\x01\xe4\x53\x23\xae\x88\xd1\xf2\xed\xca\x84\x06\x19\x97\xb9\x06\xfb\xda\xec\x72\x2d\x15\x20\xd2\x8f\x66\xad\xb5\xdd\x4b\x4f\xdf\x7e\xaf\xa3\x6c\x7f\x53\x32\x8f\xe2\x19\x5c\x44\x98\x86\x31\xee\xb4\x03\xe7\x27\xa1\x83\xab\xc3\xce\xb4\x9a\x01\xbe\x8c\x64\x2e\x2b\xe3\x4e\x55\xdf\x95\xeb\x16\x87\xbd\xfa\x11\xa2\x3e\x38\x92\x97\x36\xe9\x65\x60\xf3\xac\x68\x44\xb3\x51\x54\x3a\x42\xa8\x98\x9b\xee\x1b\x9e\x79\x6a\xaf\xc0\xbe\x41\xc4\xb1\x96\x42\xd9\x94\xef\x49\x5b\xbe\x2d\x04\xb9\xfb\x92\xbb\xdc\x0e\x29\xfd\xee\xa9\x68\x09\xf9\x9f\x69\x8b\x3d\xe1\x4b\xee\x24\xf9\xfe\x02\x3a\x0a\xb8\xcd\x6c\x07\x43\xa9\x4a\xe7\x03\x34\x2e\x72\xa7\x81\xaa\x40\xa9\x98\x5d\x97\xee\x2a\x99\xc6\x8f\xe8\x6f\x98\xa2\x85\xc9\x0d\x04\x19\x43\x6a\xd3\xc7\x15\x4c\x4b\xbc\xa5\xb8\x9f\x38\xf3\x43\x83\x0c\xef\x97\x6e\xa6\x20\xde\xc5\xd3\x1e\x3e\x5d\xcd\x58\x3d\x5c\x55\x7a\x90\x94"; +static const qbyte fte_triptohell_certdata[917] = "\x30\x82\x03\x91\x30\x82\x02\x79\xa0\x03\x02\x01\x02\x02\x09\x00\xb5\x71\x47\x8d\x5e\x66\xf1\xd9\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x30\x5f\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x46\x54\x45\x31\x1c\x30\x1a\x06\x03\x55\x04\x03\x0c\x13\x66\x74\x65\x2e\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x1e\x17\x0d\x31\x34\x31\x32\x32\x35\x30\x30\x35\x38\x31\x34\x5a\x17\x0d\x31\x37\x30\x33\x30\x34\x30\x30\x35\x38\x31\x34\x5a\x30\x5f\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x0c\x30\x0a\x06\x03\x55\x04\x0a\x0c\x03\x46\x54\x45\x31\x1c\x30\x1a\x06\x03\x55\x04\x03\x0c\x13\x66\x74\x65\x2e\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01\x01\x00\xdd\xb8\x7c\x69\x3d\x63\x95\xe3\x88\x15\xfd\xad\x93\x5e\x6b\x97\xfb\x74\xba\x1f\x83\x33\xe5\x8a\x8d\x8f\xb0\xbf\xf9\xd3\xa1\x2c\x65\x53\xa7\xef\xd3\x0f\xdc\x03\x60\x0a\x40\xef\xa8\xef\x3f\xb3\xd9\x8d\x31\x39\x12\x8a\xd8\x0e\x24\x8f\xe5\x58\x26\x86\x4c\x76\x6c\x59\x9a\xab\xea\x1c\x3d\xfb\x62\x62\xad\xaf\xd6\x00\x33\x76\x2d\xbb\xeb\xe8\xec\xb4\x76\x4f\xb0\xbe\xcf\xf0\x46\x94\x40\x02\x99\xd4\xb2\x71\x71\xd6\xf5\x1f\xc3\x4f\x1e\x1e\xb4\x0d\x82\x49\xc4\xa2\xdc\xae\x6f\x4e\x3a\xf9\x0e\xdd\xf4\xd2\x53\xe3\xe7\x7d\x58\x79\xf4\xce\x1f\x6c\xac\x81\x8c\x8c\xe1\x03\x5b\x22\x56\x92\x19\x4f\x74\xc0\x36\x41\xac\x1b\xfa\x9e\xf7\x2a\x0f\xd6\x4b\xcc\x9a\xca\x67\x87\xb7\x95\xdf\xb7\xd4\x7d\x8c\xcc\xa9\x25\xde\xdd\x8c\x1b\xd7\x32\xf2\x84\x25\x46\x7b\x10\x55\xf9\x80\xfd\x5d\xad\xab\xf9\x4c\x1f\xc0\xa5\xd1\x3f\x01\x86\x4d\xfa\x57\xab\x7a\x6d\xec\xf1\xdb\xf4\xad\xf2\x33\xcd\xa0\xed\xfe\x1b\x27\x55\x56\xba\x8c\x47\x70\x16\xd5\x75\x17\x8e\x80\xaa\x49\x5e\x93\x83\x1d\x6f\x1f\x2c\xf7\xa7\x64\xe6\x2e\x88\x8e\xff\x70\x5a\x41\x52\xae\x93\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x4e\x76\x4a\xce\x7b\x45\x14\x39\xeb\x9c\x28\x56\xb5\x7b\x8a\x18\x6f\x22\x17\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x4e\x76\x4a\xce\x7b\x45\x14\x39\xeb\x9c\x28\x56\xb5\x7b\x8a\x18\x6f\x22\x17\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x03\x82\x01\x01\x00\x48\x22\x65\xed\x2e\xc5\xed\xbb\xe9\x40\x6c\x80\xc4\x63\x19\xd1\x00\xb4\x30\x34\x17\x7c\x7c\xbd\x1b\xc5\xa9\x43\x0c\x92\x6e\xd6\x2d\x11\x6c\x0d\xa6\xda\x30\xe9\xf7\x46\x7b\x01\xe4\x53\x23\xae\x88\xd1\xf2\xed\xca\x84\x06\x19\x97\xb9\x06\xfb\xda\xec\x72\x2d\x15\x20\xd2\x8f\x66\xad\xb5\xdd\x4b\x4f\xdf\x7e\xaf\xa3\x6c\x7f\x53\x32\x8f\xe2\x19\x5c\x44\x98\x86\x31\xee\xb4\x03\xe7\x27\xa1\x83\xab\xc3\xce\xb4\x9a\x01\xbe\x8c\x64\x2e\x2b\xe3\x4e\x55\xdf\x95\xeb\x16\x87\xbd\xfa\x11\xa2\x3e\x38\x92\x97\x36\xe9\x65\x60\xf3\xac\x68\x44\xb3\x51\x54\x3a\x42\xa8\x98\x9b\xee\x1b\x9e\x79\x6a\xaf\xc0\xbe\x41\xc4\xb1\x96\x42\xd9\x94\xef\x49\x5b\xbe\x2d\x04\xb9\xfb\x92\xbb\xdc\x0e\x29\xfd\xee\xa9\x68\x09\xf9\x9f\x69\x8b\x3d\xe1\x4b\xee\x24\xf9\xfe\x02\x3a\x0a\xb8\xcd\x6c\x07\x43\xa9\x4a\xe7\x03\x34\x2e\x72\xa7\x81\xaa\x40\xa9\x98\x5d\x97\xee\x2a\x99\xc6\x8f\xe8\x6f\x98\xa2\x85\xc9\x0d\x04\x19\x43\x6a\xd3\xc7\x15\x4c\x4b\xbc\xa5\xb8\x9f\x38\xf3\x43\x83\x0c\xef\x97\x6e\xa6\x20\xde\xc5\xd3\x1e\x3e\x5d\xcd\x58\x3d\x5c\x55\x7a\x90\x94"; +static const qbyte triptohell_certdata[933] = "\x30\x82\x03\xa1\x30\x82\x02\x89\xa0\x03\x02\x01\x02\x02\x09\x00\xea\xb7\x13\xcf\x55\xe5\xe8\x8c\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x30\x67\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x18\x30\x16\x06\x03\x55\x04\x0a\x0c\x0f\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x31\x18\x30\x16\x06\x03\x55\x04\x03\x0c\x0f\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x1e\x17\x0d\x31\x34\x31\x32\x32\x35\x30\x30\x35\x38\x33\x37\x5a\x17\x0d\x31\x37\x30\x33\x30\x34\x30\x30\x35\x38\x33\x37\x5a\x30\x67\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x11\x30\x0f\x06\x03\x55\x04\x08\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x11\x30\x0f\x06\x03\x55\x04\x07\x0c\x08\x4e\x65\x77\x20\x59\x6f\x72\x6b\x31\x18\x30\x16\x06\x03\x55\x04\x0a\x0c\x0f\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x31\x18\x30\x16\x06\x03\x55\x04\x03\x0c\x0f\x74\x72\x69\x70\x74\x6f\x68\x65\x6c\x6c\x2e\x69\x6e\x66\x6f\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01\x01\x00\xd8\x77\x62\xf6\x74\xa7\x75\xde\xda\x09\xae\x9e\x76\x7a\xc6\x2a\xcf\x9a\xbe\xc6\xb9\x6d\xe2\xca\x0f\x2d\x95\xb8\x89\x93\xf7\x50\x64\x92\x7d\x95\x34\xe4\x6e\xef\x52\x56\xef\x13\x9a\x3a\xae\x84\x5b\x57\x82\x04\x86\x74\xbd\x4e\x38\x32\x56\x00\xd6\x34\x9c\x23\xd6\x81\x8e\x29\x77\x45\x61\x20\xdf\x28\xf8\xe5\x61\x83\xec\xe6\xa0\x1a\x75\xa8\x3b\x53\x6f\xc4\x09\x61\x66\x3a\xf0\x81\xbf\x2c\xf5\x8e\xf1\xe2\x35\xe4\x24\x7f\x16\xcc\xce\x60\xa2\x42\x6e\xc2\x3a\x29\x75\x6c\x79\xb0\x99\x9c\xe2\xfe\x27\x32\xb6\xf7\x0d\x71\xfd\x62\x9d\x54\x7c\x40\xb2\xf5\xa0\xa4\x25\x31\x8d\x65\xfd\x3f\x3b\x9b\x7e\x84\x74\x17\x3c\x1f\xec\x50\xcf\x75\xb8\x5c\xca\xfc\x0f\xe8\x47\xd8\x64\xec\x5f\x6c\x45\x9a\x55\x49\x97\x3f\xcb\x49\x34\x71\x0a\x12\x13\xbc\x3d\x53\x81\x17\x9a\x92\x44\x91\x07\xc2\xef\x6d\x64\x86\x5d\xfd\x67\xd5\x99\x38\x95\x46\x74\x6d\xb6\xbf\x29\xc9\x5b\xac\xb1\x46\xd6\x9e\x57\x5c\x7b\x24\x91\xf4\x7c\xe4\x01\x31\x8c\xec\x79\x94\xb7\x3f\xd2\x93\x6d\xe2\x69\xbe\x61\x44\x2e\x8f\x1a\xdc\xa8\x97\xf5\x81\x8e\x0c\xe1\x00\xf2\x71\x51\xf3\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x18\xb2\x6b\x63\xcc\x17\x54\xf6\xf0\xb6\x9e\x62\xa4\x35\xcf\x47\x74\x13\x29\xbf\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x18\xb2\x6b\x63\xcc\x17\x54\xf6\xf0\xb6\x9e\x62\xa4\x35\xcf\x47\x74\x13\x29\xbf\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x0b\x05\x00\x03\x82\x01\x01\x00\x7f\x24\x18\x8a\x79\xee\xf9\xeb\xed\x29\x1e\x21\x15\x8a\x53\xc9\xb7\xec\x30\xc4\x85\x9f\x45\x85\x26\x36\xb7\x07\xf3\xf1\xff\x3b\x89\x05\x0a\xd4\x30\x68\x31\x68\x33\xdd\xf6\x58\xa3\x85\x9f\x49\x50\x76\x9a\xc5\x79\x13\xe1\x4d\x67\x0c\xf3\x92\xf0\x1d\x02\x1f\xc4\x5c\xd4\xa1\x0c\x57\xdf\x46\x84\x43\x9f\xb0\xe2\x91\x62\xa8\xe0\x86\x0d\x47\xe1\xd9\x60\x01\xc4\xe0\xda\x6f\x06\x0a\xad\x38\xf3\x66\x68\xc5\xe2\x66\x3e\x47\x83\x65\x64\xcd\xff\xf3\xbb\xa7\xfa\x23\xf1\x82\x5e\x06\x6a\x91\x37\x51\xcd\xb9\x95\x20\x89\xff\xa1\x54\xb2\x76\xcf\x8e\xe1\xcd\x13\x93\x13\xd1\xda\x0d\x0d\xbc\x0f\xd5\x11\x26\xd6\xaf\x60\x0f\x4d\x8a\x4f\x28\xee\x6c\xf1\x99\xdc\xed\x16\xdc\x87\x26\xfd\x23\x8a\xb8\xb0\x20\x0e\xe2\x32\xf5\x8e\xb0\x65\x98\x13\xb8\x4b\x39\x7c\x8c\x98\xa2\x29\x75\x48\x3a\x89\xf9\x61\x77\x6c\x2d\x84\x41\x40\x17\xa6\x50\xc5\x09\x63\x10\xe7\x09\xd4\x5c\xdd\x0e\x71\x16\xaf\xb1\x32\xe4\xc0\xe6\xea\xfd\x26\x55\x07\x40\x95\x84\x48\x62\x04\x10\x92\xb2\xd9\x27\xfb\x8a\xf3\x7c\xe6\xfe\xd4\xfc\xa6\x33\x79\x01\x5c\xc3\x1f\x80\xa8\xf3"; static struct { wchar_t *hostname; @@ -354,7 +355,7 @@ static struct //FIXME: add alternative when one is about to expire } knowncerts[] = { {L"triptohell.info", sizeof(triptohell_certdata), triptohell_certdata}, - {L"fte.triptohell.info", sizeof(triptohell_certdata), triptohell_certdata}, + {L"fte.triptohell.info", sizeof(fte_triptohell_certdata), fte_triptohell_certdata}, {NULL} }; @@ -376,6 +377,10 @@ static DWORD VerifyKnownCertificates(DWORD status, wchar_t *domain, qbyte *data, for (j = 0; j < datasize; j++) Con_Printf("\\x%02x", data[j]); Con_Printf("\"\n", datasize); + + Con_Printf("\n", datasize); + for (j = 0; j < datasize; j++) + Con_Printf("%c", data[j]); continue; } #endif diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index 8f59a4852..e36f6a5ea 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -2154,12 +2154,20 @@ static void BE_DrawMeshChain_Internal(void) unsigned int passno = 0; shaderpass_t *pass; shader_t *useshader = shaderstate.curshader; - extern cvar_t r_polygonoffset_submodel_factor; - float pushdepth; + float pushdepth = shaderstate.curshader->polyoffset.factor; // float pushfactor; +#ifndef NOLEGACY + if (shaderstate.flags & BEF_PUSHDEPTH) + { + extern cvar_t r_polygonoffset_submodel_factor; + pushdepth += r_polygonoffset_submodel_factor.value; + } +#endif + pushdepth /= 0xffff; + D3D9BE_Cull(shaderstate.curshader->flags & (SHADER_CULL_FRONT | SHADER_CULL_BACK)); - pushdepth = (shaderstate.curshader->polyoffset.factor + ((shaderstate.flags & BEF_PUSHDEPTH)?r_polygonoffset_submodel_factor.value:0))/0xffff; + if (pushdepth != shaderstate.depthbias) { shaderstate.depthbias = pushdepth; @@ -3422,10 +3430,15 @@ void D3D9BE_BaseEntTextures(void) void D3D9BE_RenderShadowBuffer(unsigned int numverts, IDirect3DVertexBuffer9 *vbuf, unsigned int numindicies, IDirect3DIndexBuffer9 *ibuf) { - float pushdepth; + float pushdepth = shaderstate.curshader->polyoffset.factor; +#ifndef NOLEGACY extern cvar_t r_polygonoffset_submodel_factor; +// if (shaderstate.flags & BEF_PUSHDEPTH) + pushdepth += r_polygonoffset_submodel_factor.value; +#endif // D3D9BE_Cull(0);//shaderstate.curshader->flags & (SHADER_CULL_FRONT | SHADER_CULL_BACK)); - pushdepth = (shaderstate.curshader->polyoffset.factor + ((0/*shaderstate.flags & BEF_PUSHDEPTH*/)?r_polygonoffset_submodel_factor.value:0))/0xffff; + pushdepth /= 0xffff; + if (pushdepth != shaderstate.depthbias) { shaderstate.depthbias = pushdepth; diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index 810e91834..bbe65d4f7 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -1211,6 +1211,7 @@ /> permutations & (1<totalsets = 512; dpi.poolSizeCount = countof(dpisz); dpi.pPoolSizes = dpisz; @@ -740,20 +740,22 @@ static VkDescriptorSet VKBE_TempDescriptorSet(VkDescriptorSetLayout layout) { VkDescriptorSet ret; VkDescriptorSetAllocateInfo setinfo = {VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO}; - setinfo.descriptorPool = vk.descpool->pool; - setinfo.descriptorSetCount = 1; - setinfo.pSetLayouts = &layout; - if (VK_SUCCESS != vkAllocateDescriptorSets(vk.device, &setinfo, &ret)) + if (vk.descpool->availsets == 0) { if (vk.descpool->next) vk.descpool = vk.descpool->next; else vk.descpool = vk.descpool->next = VKBE_CreateDescriptorPool(); vkResetDescriptorPool(vk.device, vk.descpool->pool, 0); - setinfo.descriptorPool = vk.descpool->pool; - VkAssert(vkAllocateDescriptorSets(vk.device, &setinfo, &ret)); + vk.descpool->availsets = vk.descpool->totalsets; } + vk.descpool->availsets--; + + setinfo.descriptorPool = vk.descpool->pool; + setinfo.descriptorSetCount = 1; + setinfo.pSetLayouts = &layout; + vkAllocateDescriptorSets(vk.device, &setinfo, &ret); return ret; } @@ -948,6 +950,7 @@ void VKBE_RestartFrame(void) shaderstate.activepipeline = VK_NULL_HANDLE; vk.descpool = vk.frame->descpools; vkResetDescriptorPool(vk.device, vk.descpool->pool, 0); + vk.descpool->availsets = vk.descpool->totalsets; } void VKBE_ShutdownFramePools(struct vkframe *frame) @@ -995,7 +998,7 @@ void VKBE_Shutdown(void) shaderstate.inited = false; #ifdef RTLIGHTS -// VK_TerminateShadowMap(); + VK_TerminateShadowMap(); #endif Z_Free(shaderstate.wbatches); shaderstate.wbatches = NULL; @@ -2008,6 +2011,344 @@ static void deformgen(const deformv_t *deformv, int cnt, vecV_t *src, vecV_t *ds } } +static void BE_CreatePipeline(program_t *p, unsigned int shaderflags, unsigned int blendflags, unsigned int permu) +{ + struct pipeline_s *pipe; + VkDynamicState dynamicStateEnables[VK_DYNAMIC_STATE_RANGE_SIZE]={0}; + VkPipelineDynamicStateCreateInfo dyn = {VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO}; + VkVertexInputBindingDescription vbinds[VK_BUFF_MAX] = {{0}}; + VkVertexInputAttributeDescription vattrs[VK_BUFF_MAX] = {{0}}; + VkPipelineVertexInputStateCreateInfo vi = {VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; + VkPipelineInputAssemblyStateCreateInfo ia = {VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; + VkPipelineViewportStateCreateInfo vp = {VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO}; + VkPipelineRasterizationStateCreateInfo rs = {VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO}; + VkPipelineMultisampleStateCreateInfo ms = {VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO}; + VkPipelineDepthStencilStateCreateInfo ds = {VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO}; + VkPipelineColorBlendStateCreateInfo cb = {VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; + VkPipelineColorBlendAttachmentState att_state[1]; + VkGraphicsPipelineCreateInfo pipeCreateInfo = {VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO}; + VkPipelineShaderStageCreateInfo shaderStages[2] = {{0}}; + struct specdata_s + { + int alphamode; + int permu[16]; + union + { + float f; + int i; + } cvars[64]; + } specdata; + VkSpecializationMapEntry specentries[256] = {{0}}; + VkSpecializationInfo specInfo = {0}, *bugsbeware; + VkResult err; + uint32_t i, s; + unsigned char *cvardata; + + if (!p->vert || !p->frag) + Sys_Error("program missing required shader\n"); //PANIC + + + pipe = Z_Malloc(sizeof(*pipe)); + pipe->next = p->pipelines; + p->pipelines = pipe; + + pipe->flags = shaderflags; + pipe->blendbits = blendflags; + pipe->permu = permu; + + if (permu&PERMUTATION_BEM_WIREFRAME) + { + blendflags |= SBITS_MISC_NODEPTHTEST; + blendflags &= ~SBITS_MISC_DEPTHWRITE; + + blendflags &= ~(SHADER_CULL_FRONT|SHADER_CULL_BACK); + } + + dyn.flags = 0; + dyn.dynamicStateCount = 0; + dyn.pDynamicStates = dynamicStateEnables; + + //it wasn't supposed to be like this! + //this stuff gets messy with tcmods and rgbgen/alphagen stuff + vbinds[VK_BUFF_POS].binding = VK_BUFF_POS; + vbinds[VK_BUFF_POS].stride = sizeof(vecV_t); + vbinds[VK_BUFF_POS].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_POS].binding = vbinds[VK_BUFF_POS].binding; + vattrs[VK_BUFF_POS].location = VK_BUFF_POS; + vattrs[VK_BUFF_POS].format = VK_FORMAT_R32G32B32_SFLOAT; + vattrs[VK_BUFF_POS].offset = 0; + vbinds[VK_BUFF_TC].binding = VK_BUFF_TC; + vbinds[VK_BUFF_TC].stride = sizeof(vec2_t); + vbinds[VK_BUFF_TC].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_TC].binding = vbinds[VK_BUFF_TC].binding; + vattrs[VK_BUFF_TC].location = VK_BUFF_TC; + vattrs[VK_BUFF_TC].format = VK_FORMAT_R32G32_SFLOAT; + vattrs[VK_BUFF_TC].offset = 0; + vbinds[VK_BUFF_COL].binding = VK_BUFF_COL; + vbinds[VK_BUFF_COL].stride = sizeof(vec4_t); + vbinds[VK_BUFF_COL].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_COL].binding = vbinds[VK_BUFF_COL].binding; + vattrs[VK_BUFF_COL].location = VK_BUFF_COL; + vattrs[VK_BUFF_COL].format = VK_FORMAT_R32G32B32A32_SFLOAT; + vattrs[VK_BUFF_COL].offset = 0; + vbinds[VK_BUFF_LMTC].binding = VK_BUFF_LMTC; + vbinds[VK_BUFF_LMTC].stride = sizeof(vec2_t); + vbinds[VK_BUFF_LMTC].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_LMTC].binding = vbinds[VK_BUFF_LMTC].binding; + vattrs[VK_BUFF_LMTC].location = VK_BUFF_LMTC; + vattrs[VK_BUFF_LMTC].format = VK_FORMAT_R32G32_SFLOAT; + vattrs[VK_BUFF_LMTC].offset = 0; + + //fixme: in all seriousness, why is this not a single buffer? + vbinds[VK_BUFF_NORM].binding = VK_BUFF_NORM; + vbinds[VK_BUFF_NORM].stride = sizeof(vec3_t); + vbinds[VK_BUFF_NORM].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_NORM].binding = vbinds[VK_BUFF_NORM].binding; + vattrs[VK_BUFF_NORM].location = VK_BUFF_NORM; + vattrs[VK_BUFF_NORM].format = VK_FORMAT_R32G32B32_SFLOAT; + vattrs[VK_BUFF_NORM].offset = 0; + vbinds[VK_BUFF_SDIR].binding = VK_BUFF_SDIR; + vbinds[VK_BUFF_SDIR].stride = sizeof(vec3_t); + vbinds[VK_BUFF_SDIR].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_SDIR].binding = vbinds[VK_BUFF_SDIR].binding; + vattrs[VK_BUFF_SDIR].location = VK_BUFF_SDIR; + vattrs[VK_BUFF_SDIR].format = VK_FORMAT_R32G32B32_SFLOAT; + vattrs[VK_BUFF_SDIR].offset = 0; + vbinds[VK_BUFF_TDIR].binding = VK_BUFF_TDIR; + vbinds[VK_BUFF_TDIR].stride = sizeof(vec3_t); + vbinds[VK_BUFF_TDIR].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + vattrs[VK_BUFF_TDIR].binding = vbinds[VK_BUFF_TDIR].binding; + vattrs[VK_BUFF_TDIR].location = VK_BUFF_TDIR; + vattrs[VK_BUFF_TDIR].format = VK_FORMAT_R32G32B32_SFLOAT; + vattrs[VK_BUFF_TDIR].offset = 0; + + vi.vertexBindingDescriptionCount = countof(vbinds); + vi.pVertexBindingDescriptions = vbinds; + vi.vertexAttributeDescriptionCount = countof(vattrs); + vi.pVertexAttributeDescriptions = vattrs; + + ia.topology = (blendflags&SBITS_LINES)?VK_PRIMITIVE_TOPOLOGY_LINE_LIST:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + vp.viewportCount = 1; + dynamicStateEnables[dyn.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT; + vp.scissorCount = 1; + dynamicStateEnables[dyn.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR; + //FIXME: fillModeNonSolid might mean mode_line is not supported. + rs.polygonMode = (permu&PERMUTATION_BEM_WIREFRAME)?VK_POLYGON_MODE_LINE:VK_POLYGON_MODE_FILL; + rs.lineWidth = 1; + rs.cullMode = ((shaderflags&SHADER_CULL_FRONT)?VK_CULL_MODE_FRONT_BIT:0) | ((shaderflags&SHADER_CULL_BACK)?VK_CULL_MODE_BACK_BIT:0); + rs.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; + rs.depthClampEnable = VK_FALSE; + rs.rasterizerDiscardEnable = VK_FALSE; + if (shaderflags & SHADER_POLYGONOFFSET) + { + rs.depthBiasEnable = VK_TRUE; + rs.depthBiasConstantFactor = -25;//shader->polyoffset.unit; + rs.depthBiasClamp = 0; + rs.depthBiasSlopeFactor = -0.05;//shader->polyoffset.factor; + } + else + rs.depthBiasEnable = VK_FALSE; + + ms.pSampleMask = NULL; + ms.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + ds.depthTestEnable = (blendflags&SBITS_MISC_NODEPTHTEST)?VK_FALSE:VK_TRUE; + ds.depthWriteEnable = (blendflags&SBITS_MISC_DEPTHWRITE)?VK_TRUE:VK_FALSE; + if (blendflags & SBITS_MISC_DEPTHEQUALONLY) + ds.depthCompareOp = VK_COMPARE_OP_EQUAL; + else if (blendflags & SBITS_MISC_DEPTHCLOSERONLY) + ds.depthCompareOp = VK_COMPARE_OP_LESS; + else + ds.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL; + ds.depthBoundsTestEnable = VK_FALSE; + ds.back.failOp = VK_STENCIL_OP_KEEP; + ds.back.passOp = VK_STENCIL_OP_KEEP; + ds.back.compareOp = VK_COMPARE_OP_NEVER;//VK_COMPARE_OP_ALWAYS; + ds.stencilTestEnable = VK_FALSE; + ds.front = ds.back; + memset(att_state, 0, sizeof(att_state)); + att_state[0].colorWriteMask = + ((blendflags&SBITS_MASK_RED)?0:VK_COLOR_COMPONENT_R_BIT) | + ((blendflags&SBITS_MASK_GREEN)?0:VK_COLOR_COMPONENT_G_BIT) | + ((blendflags&SBITS_MASK_BLUE)?0:VK_COLOR_COMPONENT_B_BIT) | + ((blendflags&SBITS_MASK_ALPHA)?0:VK_COLOR_COMPONENT_A_BIT); + + if (blendflags & SBITS_BLEND_BITS) + { + switch(blendflags & SBITS_SRCBLEND_BITS) + { + case SBITS_SRCBLEND_ZERO: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ZERO; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; break; + case SBITS_SRCBLEND_ONE: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; break; + case SBITS_SRCBLEND_DST_COLOR: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_DST_COLOR; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; + case SBITS_SRCBLEND_ONE_MINUS_DST_COLOR: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; + case SBITS_SRCBLEND_SRC_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; + case SBITS_SRCBLEND_ONE_MINUS_SRC_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; + case SBITS_SRCBLEND_DST_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; + case SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; + case SBITS_SRCBLEND_ALPHA_SATURATE: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; + default: Sys_Error("Bad shader blend src\n"); return; + } + switch(blendflags & SBITS_DSTBLEND_BITS) + { + case SBITS_DSTBLEND_ZERO: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; break; + case SBITS_DSTBLEND_ONE: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE; break; + case SBITS_DSTBLEND_SRC_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; + case SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; + case SBITS_DSTBLEND_DST_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; + case SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; + case SBITS_DSTBLEND_SRC_COLOR: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_SRC_COLOR; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; + case SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; + default: Sys_Error("Bad shader blend dst\n"); return; + } + att_state[0].colorBlendOp = VK_BLEND_OP_ADD; + att_state[0].alphaBlendOp = VK_BLEND_OP_ADD; + att_state[0].blendEnable = VK_TRUE; + } + else + { + att_state[0].blendEnable = VK_FALSE; + } + if (permu&PERMUTATION_BEM_DEPTHONLY) + cb.attachmentCount = 0; + else + cb.attachmentCount = 1; + cb.pAttachments = att_state; + + + s = 0; + specentries[s].constantID = 0; + specentries[s].offset = offsetof(struct specdata_s, alphamode); + specentries[s].size = sizeof(specdata.alphamode); + s++; + if (blendflags & SBITS_ATEST_GE128) + specdata.alphamode = 3; + else if (blendflags & SBITS_ATEST_GT0) + specdata.alphamode = 2; + else if (blendflags & SBITS_ATEST_LT128) + specdata.alphamode = 1; + else //if (blendflags & SBITS_ATEST_NONE) + specdata.alphamode = 0; + + for (i = 0; i < countof(specdata.permu); i++) + { + specentries[s].constantID = 16+i; + specentries[s].offset = offsetof(struct specdata_s, permu[i]); + specentries[s].size = sizeof(specdata.permu[i]); + s++; + specdata.permu[i] = !!(permu & (1u<cvardata, i = 0; cvardata < p->cvardata + p->cvardatasize; ) + { + unsigned short id = (cvardata[0]<<8)|cvardata[1]; + unsigned char type = cvardata[2], size = cvardata[3]-'0'; + char *name; + cvar_t *var; + unsigned int u; + + cvardata += 4; + name = cvardata; + cvardata += strlen(name)+1; + + if (i + size > countof(specdata.cvars)) + break; //error + + if (type >= 'A' && type <= 'Z') + { //args will be handled by the blob loader. + for (u = 0; u < size && u < 4; u++) + { + specentries[s].constantID = id; + specentries[s].offset = offsetof(struct specdata_s, cvars[i]); + specentries[s].size = sizeof(specdata.cvars[i]); + + specdata.cvars[i].i = (cvardata[u*4+0]<<24)|(cvardata[u*4+1]<<16)|(cvardata[u*4+2]<<8)|(cvardata[u*4+3]<<0); + s++; + i++; + id++; + } + } + else + { + var = Cvar_FindVar(name); + if (var) + { + for (u = 0; u < size && u < 4; u++) + { + specentries[s].constantID = id; + specentries[s].offset = offsetof(struct specdata_s, cvars[i]); + specentries[s].size = sizeof(specdata.cvars[i]); + + if (type == 'i') + specdata.cvars[i].i = var->ival; + else + specdata.cvars[i].f = var->vec4[u]; + s++; + i++; + id++; + } + } + } + cvardata += 4*size; + } + + specInfo.mapEntryCount = s; + specInfo.pMapEntries = specentries; + specInfo.dataSize = sizeof(specdata); + specInfo.pData = &specdata; + +#if 0//def _DEBUG + //vk_layer_lunarg_drawstate fucks up and pokes invalid bits of stack. + bugsbeware = Z_Malloc(sizeof(*bugsbeware) + sizeof(*specentries)*s + sizeof(specdata)); + *bugsbeware = specInfo; + bugsbeware->pData = bugsbeware+1; + bugsbeware->pMapEntries = (VkSpecializationMapEntry*)((char*)bugsbeware->pData + specInfo.dataSize); + memcpy((void*)bugsbeware->pData, specInfo.pData, specInfo.dataSize); + memcpy((void*)bugsbeware->pMapEntries, specInfo.pMapEntries, sizeof(*specInfo.pMapEntries)*specInfo.mapEntryCount); +#else + bugsbeware = &specInfo; +#endif + //fixme: add more specialisations for custom cvars (yes, this'll flush+reload pipelines if they're changed) + //fixme: add specialisations for permutations I guess + //fixme: add geometry+tesselation support. because we can. + + shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; + shaderStages[0].module = p->vert; + shaderStages[0].pName = "main"; + shaderStages[0].pSpecializationInfo = bugsbeware; + shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; + shaderStages[1].module = p->frag; + shaderStages[1].pName = "main"; + shaderStages[1].pSpecializationInfo = bugsbeware; + + pipeCreateInfo.flags = 0; + pipeCreateInfo.stageCount = countof(shaderStages); + pipeCreateInfo.pStages = shaderStages; + pipeCreateInfo.pVertexInputState = &vi; + pipeCreateInfo.pInputAssemblyState = &ia; + pipeCreateInfo.pTessellationState = NULL; //null is okay! + pipeCreateInfo.pViewportState = &vp; + pipeCreateInfo.pRasterizationState = &rs; + pipeCreateInfo.pMultisampleState = &ms; + pipeCreateInfo.pDepthStencilState = &ds; + pipeCreateInfo.pColorBlendState = &cb; + pipeCreateInfo.pDynamicState = &dyn; + pipeCreateInfo.layout = p->layout; + pipeCreateInfo.renderPass = (permu&PERMUTATION_BEM_DEPTHONLY)?vk.shadow_renderpass:vk.renderpass[0]; + pipeCreateInfo.subpass = 0; + pipeCreateInfo.basePipelineHandle = VK_NULL_HANDLE; + pipeCreateInfo.basePipelineIndex = -1; //not sure what this is about. + +// pipeCreateInfo.flags = VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT; + + err = vkCreateGraphicsPipelines(vk.device, vk.pipelinecache, 1, &pipeCreateInfo, vkallocationcb, &pipe->pipeline); + + if (err) + Sys_Error("Error %i creating pipeline for %s. Check spir-v modules / drivers.\n", err, shaderstate.curshader->name); + + vkCmdBindPipeline(vk.frame->cbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, shaderstate.activepipeline=pipe->pipeline); +} static void BE_BindPipeline(program_t *p, unsigned int shaderflags, unsigned int blendflags, unsigned int permu) { struct pipeline_s *pipe; @@ -2032,346 +2373,17 @@ static void BE_BindPipeline(program_t *p, unsigned int shaderflags, unsigned int if (pipe->permu == permu) { if (pipe->pipeline != shaderstate.activepipeline) - vkCmdBindPipeline(vk.frame->cbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, shaderstate.activepipeline=pipe->pipeline); + { + shaderstate.activepipeline = pipe->pipeline; + vkCmdBindPipeline(vk.frame->cbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, shaderstate.activepipeline); + } return; } } //oh look. we need to build an entirely new pipeline object. hurrah... not. - - if (!p->vert || !p->frag) - Sys_Error("program missing required shader\n"); //PANIC - - - { - VkDynamicState dynamicStateEnables[VK_DYNAMIC_STATE_RANGE_SIZE]={0}; - VkPipelineDynamicStateCreateInfo dyn = {VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO}; - VkVertexInputBindingDescription vbinds[VK_BUFF_MAX] = {{0}}; - VkVertexInputAttributeDescription vattrs[VK_BUFF_MAX] = {{0}}; - VkPipelineVertexInputStateCreateInfo vi = {VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; - VkPipelineInputAssemblyStateCreateInfo ia = {VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; - VkPipelineViewportStateCreateInfo vp = {VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO}; - VkPipelineRasterizationStateCreateInfo rs = {VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO}; - VkPipelineMultisampleStateCreateInfo ms = {VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO}; - VkPipelineDepthStencilStateCreateInfo ds = {VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO}; - VkPipelineColorBlendStateCreateInfo cb = {VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; - VkPipelineColorBlendAttachmentState att_state[1]; - VkGraphicsPipelineCreateInfo pipeCreateInfo = {VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO}; - VkPipelineShaderStageCreateInfo shaderStages[2] = {{0}}; - struct specdata_s - { - int alphamode; - int permu[16]; - union - { - float f; - int i; - } cvars[64]; - } specdata; - VkSpecializationMapEntry specentries[256] = {{0}}; - VkSpecializationInfo specInfo = {0}, *bugsbeware; - VkResult err; - uint32_t i, s; - unsigned char *cvardata; - - pipe = Z_Malloc(sizeof(*pipe)); - pipe->next = p->pipelines; - p->pipelines = pipe; - - pipe->flags = shaderflags; - pipe->blendbits = blendflags; - pipe->permu = permu; - - if (permu&PERMUTATION_BEM_WIREFRAME) - { - blendflags |= SBITS_MISC_NODEPTHTEST; - blendflags &= ~SBITS_MISC_DEPTHWRITE; - - blendflags &= ~(SHADER_CULL_FRONT|SHADER_CULL_BACK); - } - - dyn.flags = 0; - dyn.dynamicStateCount = 0; - dyn.pDynamicStates = dynamicStateEnables; - - //it wasn't supposed to be like this! - //this stuff gets messy with tcmods and rgbgen/alphagen stuff - vbinds[VK_BUFF_POS].binding = VK_BUFF_POS; - vbinds[VK_BUFF_POS].stride = sizeof(vecV_t); - vbinds[VK_BUFF_POS].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_POS].binding = vbinds[VK_BUFF_POS].binding; - vattrs[VK_BUFF_POS].location = VK_BUFF_POS; - vattrs[VK_BUFF_POS].format = VK_FORMAT_R32G32B32_SFLOAT; - vattrs[VK_BUFF_POS].offset = 0; - vbinds[VK_BUFF_TC].binding = VK_BUFF_TC; - vbinds[VK_BUFF_TC].stride = sizeof(vec2_t); - vbinds[VK_BUFF_TC].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_TC].binding = vbinds[VK_BUFF_TC].binding; - vattrs[VK_BUFF_TC].location = VK_BUFF_TC; - vattrs[VK_BUFF_TC].format = VK_FORMAT_R32G32_SFLOAT; - vattrs[VK_BUFF_TC].offset = 0; - vbinds[VK_BUFF_COL].binding = VK_BUFF_COL; - vbinds[VK_BUFF_COL].stride = sizeof(vec4_t); - vbinds[VK_BUFF_COL].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_COL].binding = vbinds[VK_BUFF_COL].binding; - vattrs[VK_BUFF_COL].location = VK_BUFF_COL; - vattrs[VK_BUFF_COL].format = VK_FORMAT_R32G32B32A32_SFLOAT; - vattrs[VK_BUFF_COL].offset = 0; - vbinds[VK_BUFF_LMTC].binding = VK_BUFF_LMTC; - vbinds[VK_BUFF_LMTC].stride = sizeof(vec2_t); - vbinds[VK_BUFF_LMTC].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_LMTC].binding = vbinds[VK_BUFF_LMTC].binding; - vattrs[VK_BUFF_LMTC].location = VK_BUFF_LMTC; - vattrs[VK_BUFF_LMTC].format = VK_FORMAT_R32G32_SFLOAT; - vattrs[VK_BUFF_LMTC].offset = 0; - - //fixme: in all seriousness, why is this not a single buffer? - vbinds[VK_BUFF_NORM].binding = VK_BUFF_NORM; - vbinds[VK_BUFF_NORM].stride = sizeof(vec3_t); - vbinds[VK_BUFF_NORM].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_NORM].binding = vbinds[VK_BUFF_NORM].binding; - vattrs[VK_BUFF_NORM].location = VK_BUFF_NORM; - vattrs[VK_BUFF_NORM].format = VK_FORMAT_R32G32B32_SFLOAT; - vattrs[VK_BUFF_NORM].offset = 0; - vbinds[VK_BUFF_SDIR].binding = VK_BUFF_SDIR; - vbinds[VK_BUFF_SDIR].stride = sizeof(vec3_t); - vbinds[VK_BUFF_SDIR].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_SDIR].binding = vbinds[VK_BUFF_SDIR].binding; - vattrs[VK_BUFF_SDIR].location = VK_BUFF_SDIR; - vattrs[VK_BUFF_SDIR].format = VK_FORMAT_R32G32B32_SFLOAT; - vattrs[VK_BUFF_SDIR].offset = 0; - vbinds[VK_BUFF_TDIR].binding = VK_BUFF_TDIR; - vbinds[VK_BUFF_TDIR].stride = sizeof(vec3_t); - vbinds[VK_BUFF_TDIR].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - vattrs[VK_BUFF_TDIR].binding = vbinds[VK_BUFF_TDIR].binding; - vattrs[VK_BUFF_TDIR].location = VK_BUFF_TDIR; - vattrs[VK_BUFF_TDIR].format = VK_FORMAT_R32G32B32_SFLOAT; - vattrs[VK_BUFF_TDIR].offset = 0; - - vi.vertexBindingDescriptionCount = countof(vbinds); - vi.pVertexBindingDescriptions = vbinds; - vi.vertexAttributeDescriptionCount = countof(vattrs); - vi.pVertexAttributeDescriptions = vattrs; - - ia.topology = (blendflags&SBITS_LINES)?VK_PRIMITIVE_TOPOLOGY_LINE_LIST:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - vp.viewportCount = 1; - dynamicStateEnables[dyn.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT; - vp.scissorCount = 1; - dynamicStateEnables[dyn.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR; - //FIXME: fillModeNonSolid might mean mode_line is not supported. - rs.polygonMode = (permu&PERMUTATION_BEM_WIREFRAME)?VK_POLYGON_MODE_LINE:VK_POLYGON_MODE_FILL; - rs.lineWidth = 1; - rs.cullMode = ((shaderflags&SHADER_CULL_FRONT)?VK_CULL_MODE_FRONT_BIT:0) | ((shaderflags&SHADER_CULL_BACK)?VK_CULL_MODE_BACK_BIT:0); - rs.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; - rs.depthClampEnable = VK_FALSE; - rs.rasterizerDiscardEnable = VK_FALSE; - if (shaderflags & SHADER_POLYGONOFFSET) - { - rs.depthBiasEnable = VK_TRUE; - rs.depthBiasConstantFactor = -25;//shader->polyoffset.unit; - rs.depthBiasClamp = 0; - rs.depthBiasSlopeFactor = -0.05;//shader->polyoffset.factor; - } - else - rs.depthBiasEnable = VK_FALSE; - - ms.pSampleMask = NULL; - ms.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - ds.depthTestEnable = (blendflags&SBITS_MISC_NODEPTHTEST)?VK_FALSE:VK_TRUE; - ds.depthWriteEnable = (blendflags&SBITS_MISC_DEPTHWRITE)?VK_TRUE:VK_FALSE; - if (blendflags & SBITS_MISC_DEPTHEQUALONLY) - ds.depthCompareOp = VK_COMPARE_OP_EQUAL; - else if (blendflags & SBITS_MISC_DEPTHCLOSERONLY) - ds.depthCompareOp = VK_COMPARE_OP_LESS; - else - ds.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL; - ds.depthBoundsTestEnable = VK_FALSE; - ds.back.failOp = VK_STENCIL_OP_KEEP; - ds.back.passOp = VK_STENCIL_OP_KEEP; - ds.back.compareOp = VK_COMPARE_OP_NEVER;//VK_COMPARE_OP_ALWAYS; - ds.stencilTestEnable = VK_FALSE; - ds.front = ds.back; - memset(att_state, 0, sizeof(att_state)); - att_state[0].colorWriteMask = - ((blendflags&SBITS_MASK_RED)?0:VK_COLOR_COMPONENT_R_BIT) | - ((blendflags&SBITS_MASK_GREEN)?0:VK_COLOR_COMPONENT_G_BIT) | - ((blendflags&SBITS_MASK_BLUE)?0:VK_COLOR_COMPONENT_B_BIT) | - ((blendflags&SBITS_MASK_ALPHA)?0:VK_COLOR_COMPONENT_A_BIT); - - if (blendflags & SBITS_BLEND_BITS) - { - switch(blendflags & SBITS_SRCBLEND_BITS) - { - case SBITS_SRCBLEND_ZERO: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ZERO; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; break; - case SBITS_SRCBLEND_ONE: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; break; - case SBITS_SRCBLEND_DST_COLOR: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_DST_COLOR; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; - case SBITS_SRCBLEND_ONE_MINUS_DST_COLOR: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; - case SBITS_SRCBLEND_SRC_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; - case SBITS_SRCBLEND_ONE_MINUS_SRC_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; - case SBITS_SRCBLEND_DST_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; - case SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; - case SBITS_SRCBLEND_ALPHA_SATURATE: att_state[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; att_state[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; - default: Sys_Error("Bad shader blend src\n"); return; - } - switch(blendflags & SBITS_DSTBLEND_BITS) - { - case SBITS_DSTBLEND_ZERO: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; break; - case SBITS_DSTBLEND_ONE: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE; break; - case SBITS_DSTBLEND_SRC_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; - case SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; - case SBITS_DSTBLEND_DST_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_DST_ALPHA; break; - case SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; break; - case SBITS_DSTBLEND_SRC_COLOR: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_SRC_COLOR; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; break; - case SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR: att_state[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; att_state[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; break; - default: Sys_Error("Bad shader blend dst\n"); return; - } - att_state[0].colorBlendOp = VK_BLEND_OP_ADD; - att_state[0].alphaBlendOp = VK_BLEND_OP_ADD; - att_state[0].blendEnable = VK_TRUE; - } - else - { - att_state[0].blendEnable = VK_FALSE; - } - cb.attachmentCount = 1; - cb.pAttachments = att_state; - - - s = 0; - specentries[s].constantID = 0; - specentries[s].offset = offsetof(struct specdata_s, alphamode); - specentries[s].size = sizeof(specdata.alphamode); - s++; - if (blendflags & SBITS_ATEST_GE128) - specdata.alphamode = 3; - else if (blendflags & SBITS_ATEST_GT0) - specdata.alphamode = 2; - else if (blendflags & SBITS_ATEST_LT128) - specdata.alphamode = 1; - else //if (blendflags & SBITS_ATEST_NONE) - specdata.alphamode = 0; - - for (i = 0; i < countof(specdata.permu); i++) - { - specentries[s].constantID = 16+i; - specentries[s].offset = offsetof(struct specdata_s, permu[i]); - specentries[s].size = sizeof(specdata.permu[i]); - s++; - specdata.permu[i] = !!(permu & (1u<cvardata, i = 0; cvardata < p->cvardata + p->cvardatasize; ) - { - unsigned short id = (cvardata[0]<<8)|cvardata[1]; - unsigned char type = cvardata[2], size = cvardata[3]-'0'; - char *name; - cvar_t *var; - unsigned int u; - - cvardata += 4; - name = cvardata; - cvardata += strlen(name)+1; - - if (i + size > countof(specdata.cvars)) - break; //error - - if (type >= 'A' && type <= 'Z') - { //args will be handled by the blob loader. - for (u = 0; u < size && u < 4; u++) - { - specentries[s].constantID = id; - specentries[s].offset = offsetof(struct specdata_s, cvars[i]); - specentries[s].size = sizeof(specdata.cvars[i]); - - specdata.cvars[i].i = (cvardata[u*4+0]<<24)|(cvardata[u*4+1]<<16)|(cvardata[u*4+2]<<8)|(cvardata[u*4+3]<<0); - s++; - i++; - id++; - } - } - else - { - var = Cvar_FindVar(name); - if (var) - { - for (u = 0; u < size && u < 4; u++) - { - specentries[s].constantID = id; - specentries[s].offset = offsetof(struct specdata_s, cvars[i]); - specentries[s].size = sizeof(specdata.cvars[i]); - - if (type == 'i') - specdata.cvars[i].i = var->ival; - else - specdata.cvars[i].f = var->vec4[u]; - s++; - i++; - id++; - } - } - } - cvardata += 4*size; - } - - specInfo.mapEntryCount = s; - specInfo.pMapEntries = specentries; - specInfo.dataSize = sizeof(specdata); - specInfo.pData = &specdata; - -#if 0//def _DEBUG - //vk_layer_lunarg_drawstate fucks up and pokes invalid bits of stack. - bugsbeware = Z_Malloc(sizeof(*bugsbeware) + sizeof(*specentries)*s + sizeof(specdata)); - *bugsbeware = specInfo; - bugsbeware->pData = bugsbeware+1; - bugsbeware->pMapEntries = (VkSpecializationMapEntry*)((char*)bugsbeware->pData + specInfo.dataSize); - memcpy((void*)bugsbeware->pData, specInfo.pData, specInfo.dataSize); - memcpy((void*)bugsbeware->pMapEntries, specInfo.pMapEntries, sizeof(*specInfo.pMapEntries)*specInfo.mapEntryCount); -#else - bugsbeware = &specInfo; -#endif - //fixme: add more specialisations for custom cvars (yes, this'll flush+reload pipelines if they're changed) - //fixme: add specialisations for permutations I guess - //fixme: add geometry+tesselation support. because we can. - - shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; - shaderStages[0].module = p->vert; - shaderStages[0].pName = "main"; - shaderStages[0].pSpecializationInfo = bugsbeware; - shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; - shaderStages[1].module = p->frag; - shaderStages[1].pName = "main"; - shaderStages[1].pSpecializationInfo = bugsbeware; - - pipeCreateInfo.flags = 0; - pipeCreateInfo.stageCount = countof(shaderStages); - pipeCreateInfo.pStages = shaderStages; - pipeCreateInfo.pVertexInputState = &vi; - pipeCreateInfo.pInputAssemblyState = &ia; - pipeCreateInfo.pTessellationState = NULL; //null is okay! - pipeCreateInfo.pViewportState = &vp; - pipeCreateInfo.pRasterizationState = &rs; - pipeCreateInfo.pMultisampleState = &ms; - pipeCreateInfo.pDepthStencilState = &ds; - pipeCreateInfo.pColorBlendState = &cb; - pipeCreateInfo.pDynamicState = &dyn; - pipeCreateInfo.layout = p->layout; - pipeCreateInfo.renderPass = (permu&PERMUTATION_BEM_DEPTHONLY)?vk.shadow_renderpass:vk.renderpass[0]; - pipeCreateInfo.subpass = 0; - pipeCreateInfo.basePipelineHandle = VK_NULL_HANDLE; - pipeCreateInfo.basePipelineIndex = -1; //not sure what this is about. - -// pipeCreateInfo.flags = VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT; - - err = vkCreateGraphicsPipelines(vk.device, vk.pipelinecache, 1, &pipeCreateInfo, vkallocationcb, &pipe->pipeline); - - if (err) - Sys_Error("Error %i creating pipeline for %s. Check spir-v modules / drivers.\n", err, shaderstate.curshader->name); - } - - vkCmdBindPipeline(vk.frame->cbuf, VK_PIPELINE_BIND_POINT_GRAPHICS, shaderstate.activepipeline=pipe->pipeline); + //split into a different function because of abusive stack combined with windows stack probes. + BE_CreatePipeline(p, shaderflags, blendflags, permu); } static void BE_SetupTextureDescriptor(texid_t tex, texid_t fallbacktex, VkDescriptorSet set, VkWriteDescriptorSet *firstdesc, VkWriteDescriptorSet *desc, VkDescriptorImageInfo *img) @@ -3262,6 +3274,9 @@ void VKBE_ClearVBO(vbo_t *vbo) //FIXME: may still be in use by an active commandbuffer. VkDeviceMemory *retarded; + if (vbo->indicies.vk.buff || vbo->coord.vk.buff) + vkDeviceWaitIdle(vk.device); //just in case + if (vbo->indicies.vk.buff) { vkDestroyBuffer(vk.device, vbo->indicies.vk.buff, vkallocationcb); @@ -4809,6 +4824,35 @@ void VKBE_RenderShadowBuffer(struct vk_shadowbuffer *buf) vkCmdDrawIndexed(vk.frame->cbuf, buf->numindicies, 1, 0, 0, 0); } + +static void VK_TerminateShadowMap(void) +{ + struct shadowmaps_s *shad; + unsigned int sbuf, i; + + if (vk.shadow_renderpass != VK_NULL_HANDLE) + vkDestroyRenderPass(vk.device, vk.shadow_renderpass, vkallocationcb); + + for (sbuf = 0; sbuf < countof(shaderstate.shadow); sbuf++) + { + shad = &shaderstate.shadow[sbuf]; + if (!shad->image) + continue; + + for (i = 0; i < countof(shad->buf); i++) + { + vkDestroyImageView(vk.device, shad->buf[i].vimage.view, vkallocationcb); + vkDestroySampler(vk.device, shad->buf[i].vimage.sampler, vkallocationcb); + vkDestroyFramebuffer(vk.device, shad->buf[i].framebuffer, vkallocationcb); + } + vkDestroyImage(vk.device, shad->image, vkallocationcb); + vkFreeMemory(vk.device, shad->memory, vkallocationcb); + + shad->width = 0; + shad->height = 0; + } +} + qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height) { struct shadowmaps_s *shad = &shaderstate.shadow[isspot]; @@ -4818,7 +4862,7 @@ qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height) if (shad->width != width || shad->height != height) { - //actually, this will really only happen the first time. + //actually, this will really only happen once per. //so we can be lazy and not free here... check out validation/leak warnings if this changes... unsigned int i; @@ -4829,6 +4873,7 @@ qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height) imginfo.imageType = VK_IMAGE_TYPE_2D; imginfo.extent.width = width; imginfo.extent.height = height; + imginfo.extent.depth = 1; imginfo.mipLevels = 1; imginfo.arrayLayers = countof(shad->buf); imginfo.samples = VK_SAMPLE_COUNT_1_BIT; @@ -4850,6 +4895,7 @@ qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height) VkAssert(vkBindImageMemory(vk.device, shad->image, shad->memory, 0)); } + if (vk.shadow_renderpass == VK_NULL_HANDLE) { VkAttachmentReference depth_reference; VkAttachmentDescription attachments[1] = {{0}}; @@ -4865,7 +4911,7 @@ qboolean VKBE_BeginShadowmap(qboolean isspot, uint32_t width, uint32_t height) attachments[depth_reference.attachment].storeOp = VK_ATTACHMENT_STORE_OP_STORE; attachments[depth_reference.attachment].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachments[depth_reference.attachment].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attachments[depth_reference.attachment].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attachments[depth_reference.attachment].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; attachments[depth_reference.attachment].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; diff --git a/engine/vk/vk_init.c b/engine/vk/vk_init.c index 2d14709ef..1749bb9c6 100644 --- a/engine/vk/vk_init.c +++ b/engine/vk/vk_init.c @@ -47,6 +47,9 @@ const char *vklayerlist[] = void VK_Submit_Work(VkCommandBuffer cmdbuf, VkSemaphore semwait, VkPipelineStageFlags semwaitstagemask, VkSemaphore semsignal, VkFence fencesignal, struct vkframe *presentframe, struct vk_fencework *fencedwork); static int VK_Submit_Thread(void *arg); static void VK_Submit_DoWork(void); + +static void VK_DestroyRenderPass(void); +static void VK_CreateRenderPass(void); struct vulkaninfo_s vk; static struct vk_rendertarg postproc[2]; @@ -143,6 +146,13 @@ static void VK_DestroySwapChain(void) Sys_WaitOnThread(vk.submitthread); vk.submitthread = NULL; } +#ifdef THREADACQUIRE + while (vk.aquirenext < vk.aquirelast) + { + VkAssert(vkWaitForFences(vk.device, 1, &vk.acquirefences[vk.aquirenext%ACQUIRELIMIT], VK_FALSE, UINT64_MAX)); + vk.aquirenext++; + } +#endif while (vk.work) { Sys_LockConditional(vk.submitcondition); @@ -171,12 +181,15 @@ static void VK_DestroySwapChain(void) for (i = 0; i < vk.backbuf_count; i++) { //swapchain stuff - vkDestroyFramebuffer(vk.device, vk.backbufs[i].framebuffer, vkallocationcb); - vkDestroyImageView(vk.device, vk.backbufs[i].colour.view, vkallocationcb); + if (vk.backbufs[i].framebuffer) + vkDestroyFramebuffer(vk.device, vk.backbufs[i].framebuffer, vkallocationcb); + vk.backbufs[i].framebuffer = VK_NULL_HANDLE; + if (vk.backbufs[i].colour.view) + vkDestroyImageView(vk.device, vk.backbufs[i].colour.view, vkallocationcb); + vk.backbufs[i].colour.view = VK_NULL_HANDLE; VK_DestroyVkTexture(&vk.backbufs[i].depth); } - #ifdef THREADACQUIRE while (vk.aquirenext < vk.aquirelast) { @@ -222,6 +235,7 @@ static void VK_DestroySwapChain(void) static qboolean VK_CreateSwapChain(void) { + qboolean reloadshaders = false; uint32_t fmtcount; VkSurfaceFormatKHR *surffmts; uint32_t presentmodes; @@ -333,7 +347,8 @@ static qboolean VK_CreateSwapChain(void) if (vk.backbufformat != swapinfo.imageFormat) { - //FIXME: need to change the renderpasses. + VK_DestroyRenderPass(); + reloadshaders = true; } vk.backbufformat = swapinfo.imageFormat; @@ -368,6 +383,13 @@ static qboolean VK_CreateSwapChain(void) } #endif + VK_CreateRenderPass(); + if (reloadshaders) + { + Shader_NeedReload(true); + Shader_DoReload(); + } + attachments[1] = VK_NULL_HANDLE; attachments[0] = VK_NULL_HANDLE; @@ -2073,7 +2095,18 @@ void VKBE_RenderToTextureUpdate2d(qboolean destchanged) { } - +static void VK_DestroyRenderPass(void) +{ + int i; + for (i = 0; i < countof(vk.renderpass); i++) + { + if (vk.renderpass[i] != VK_NULL_HANDLE) + { + vkDestroyRenderPass(vk.device, vk.renderpass[i], vkallocationcb); + vk.renderpass[i] = VK_NULL_HANDLE; + } + } +} static void VK_CreateRenderPass(void) { int pass; @@ -2085,6 +2118,8 @@ static VkRenderPassCreateInfo rp_info = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_I for (pass = 0; pass < 3; pass++) { + if (vk.renderpass[pass] != VK_NULL_HANDLE) + continue; color_reference.attachment = 0; color_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; @@ -2558,9 +2593,6 @@ qboolean VK_Init(rendererstate_t *info, const char *sysextname, qboolean (*creat vk.depthformat = VK_FORMAT_D32_SFLOAT;//VK_FORMAT_D32_SFLOAT_S8_UINT;//VK_FORMAT_D24_UNORM_S8_UINT;//VK_FORMAT_D16_UNORM; - //this needs to be done before we have a swapchain. - VK_CreateRenderPass(); - #ifndef THREADACQUIRE { VkFenceCreateInfo fci = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO}; @@ -2665,8 +2697,7 @@ void VK_Shutdown(void) VKBE_RT_Destroy(&postproc[i]); vkDestroyCommandPool(vk.device, vk.cmdpool, vkallocationcb); - for (i = 0; i < countof(vk.renderpass); i++) - vkDestroyRenderPass(vk.device, vk.renderpass[i], vkallocationcb); + VK_DestroyRenderPass(); #ifndef THREADACQUIRE vkDestroyFence(vk.device, vk.acquirefence, vkallocationcb); #endif @@ -2689,6 +2720,7 @@ void VK_Shutdown(void) vkDestroyDebugReportCallbackEXT(vk.instance, vk_debugcallback, vkallocationcb); vk_debugcallback = VK_NULL_HANDLE; } + vkDestroySurfaceKHR(vk.instance, vk.surface, vkallocationcb); vkDestroyInstance(vk.instance, vkallocationcb); Sys_DestroyMutex(vk.swapchain_mutex); Sys_DestroyConditional(vk.submitcondition); diff --git a/engine/vk/vkrenderer.h b/engine/vk/vkrenderer.h index 60cb4653f..71a45c1d1 100644 --- a/engine/vk/vkrenderer.h +++ b/engine/vk/vkrenderer.h @@ -246,6 +246,8 @@ extern struct vulkaninfo_s struct descpool { VkDescriptorPool pool; + int availsets; + int totalsets; struct descpool *next; } *descpool; struct dynbuffer diff --git a/plugins/Makefile b/plugins/Makefile index 49d57322e..3e6849c7e 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -188,9 +188,32 @@ $(OUT_DIR)/fteplug_qi$(PLUG_NATIVE_EXT): qi/qi.c jabber/xml.c plugin.c qvm_api.c $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Ijabber $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) NATIVE_PLUGINS+=qi -$(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT): cef/cef.c plugin.c qvm_api.c - $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $@ -shared $(PLUG_CFLAGS) -Icef/2623 $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) -Wl,-rpath,. $(PLUG_LDFLAGS_DL) +ifeq ($(FTE_TARGET),win32) +#Yes, this is old, but it actually works without the gpu process crashing all the fucking time. +#multiple more recent versions are defective. and they don't support WinXP either. +CEF_VER=win32_2526 +endif +ifeq ($(FTE_TARGET),win64) +#I'm just too lazy to test this minor platform. +#CEF_VER=win64_2704 +endif + +ifneq ($(CEF_VER),) +.PHONEY: $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) +$(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT): $(OUT_DIR)/fteplug_cef_$(BITS).zip + +$(OUT_DIR)/fteplug_cef_$(BITS).zip: cef/cef.c plugin.c qvm_api.c + $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -o $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) -shared $(PLUG_CFLAGS) -Icef/2623 $^ $(PLUG_DEFFILE) $(PLUG_LDFLAGS) -Wl,-rpath,. $(PLUG_LDFLAGS_DL) + cp cef/2623/libcef_$(BITS).zip $@ + chmod 644 $@ + zip -9 -j $@ $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) + rm $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) #NATIVE_PLUGINS+=cef +else +.PHONEY: $(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT) +$(OUT_DIR)/fteplug_cef$(PLUG_NATIVE_EXT): + echo cef plugin not supported on this arch +endif #irc plugin can still be built as a qvm. $(OUT_DIR)/fteplug_irc$(PLUG_NATIVE_EXT): irc/ircclient.c plugin.c qvm_api.c diff --git a/plugins/cef/cef.c b/plugins/cef/cef.c index 131329510..13813960a 100644 --- a/plugins/cef/cef.c +++ b/plugins/cef/cef.c @@ -726,6 +726,8 @@ static int CEF_CALLBACK request_context_handler_on_before_plugin_load(cef_reques *plugin_policy = PLUGIN_POLICY_BLOCK; //block by default (user can manually override supposedly). most plugins are unlikely to cope well with our offscreen rendering stuff, and flash sucks. cef_release(plugin_info); + + Cvar_Update(&cef_allowplugins); if (!cef_allowplugins.value) { *plugin_policy = PLUGIN_POLICY_DISABLE; diff --git a/quakec/menusys/menu/options_audio.qc b/quakec/menusys/menu/options_audio.qc index 96082a031..80c0946d8 100644 --- a/quakec/menusys/menu/options_audio.qc +++ b/quakec/menusys/menu/options_audio.qc @@ -36,6 +36,7 @@ nonstatic void(mitem_desktop desktop) M_Options_Audio = "96000 \"96000hz\" " "192000 \"192000hz\" " )), fl, [0, pos], [0, 8]); pos += 8; + fr.add(menuitemcheck_spawn(_("Doppler"), "s_doppler", '280 8'), fl, [0, pos], [0, 8]); pos += 8; fr.add(menuitemcheck_spawn(_("8bit audio"), "s_loadas8bit", '280 8'), fl, [0, pos], [0, 8]); pos += 8; fr.add(menuitemcheck_spawn(_("Swap Speakers"), "s_swapstereo", '280 8'), fl, [0, pos], [0, 8]); pos += 8; fr.add(menuitemslider_spawn(_("Latency"), "s_mixahead", '0.1 0.3 0.01', '280 8'), fl, [0, pos], [0, 8]); pos += 8;