Skip to content

Commit

Permalink
Merge missing fixes for vk builds
Browse files Browse the repository at this point in the history
Also adds renderervk project for MSVC, you must manually set the main project to use it instead of the other renderer.
  • Loading branch information
ensiform committed Nov 28, 2023
1 parent dcdb181 commit cd4c1a2
Show file tree
Hide file tree
Showing 14 changed files with 563 additions and 79 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ jobs:
- name: Build Engine
working-directory: ${{github.workspace}}/src
run: |
msbuild win32\msvc2017\wolfded.vcxproj -m -p:TargetName=ETe.ded,Configuration=${{ matrix.config }},Platform=${{ matrix.platform }}
msbuild win32\msvc2017\ete-ded.vcxproj -m -p:TargetName=ETe.ded,Configuration=${{ matrix.config }},Platform=${{ matrix.platform }}
msbuild win32\msvc2017\renderer.vcxproj -m -p:Configuration=${{ matrix.config }},Platform=${{ matrix.platform }}
msbuild win32\msvc2017\wolf.vcxproj -m -p:TargetName=ETe,Configuration=${{ matrix.config }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0
#msbuild win32\msvc2017\steam.vcxproj -m -p:TargetName=ete-steamlaunch,Configuration=${{ matrix.config }},Platform=${{ matrix.platform }}
msbuild win32\msvc2017\ete.vcxproj -m -p:TargetName=ETe,Configuration=${{ matrix.config }},Platform=${{ matrix.platform }},UseWasapi=USE_WASAPI=0
- name: Build etmain
working-directory: ${{github.workspace}}/src
Expand Down
23 changes: 22 additions & 1 deletion src/renderervk/tr_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,15 @@ R_ImageList_f
void R_ImageList_f( void ) {
const image_t *image;
int i, estTotalSize = 0;
char *name, buf[MAX_QPATH*2 + 5];
char *name, buf[MAX_QPATH*2 + 7];
const char *match;
int matchCount = 0;

if ( ri.Cmd_Argc() > 1 ) {
match = ri.Cmd_Argv( 1 );
} else {
match = NULL;
}

ri.Printf( PRINT_ALL, "\n -n- --w-- --h-- type -size- --name-------\n" );

Expand All @@ -222,6 +230,16 @@ void R_ImageList_f( void ) {
int displaySize;

image = tr.images[ i ];

if ( match && !ri.Com_Filter( match, image->imgName ) ) {
if ( Q_stricmp( image->imgName, image->imgName2 ) == 0 ) {
continue;
}
else if ( !ri.Com_Filter( match, image->imgName2 ) ) {
continue;
}
}

estSize = image->uploadHeight * image->uploadWidth;

switch ( image->internalFormat )
Expand Down Expand Up @@ -310,12 +328,15 @@ void R_ImageList_f( void ) {
name = buf;
}

matchCount++;
ri.Printf( PRINT_ALL, " %3i %5i %5i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, name );
estTotalSize += estSize;
}

ri.Printf( PRINT_ALL, " -----------------------\n" );
ri.Printf( PRINT_ALL, " approx %i kbytes\n", (estTotalSize + 1023) / 1024 );
if ( match && matchCount > 0 && matchCount != tr.numImages )
ri.Printf( PRINT_ALL, " %i images found\n", matchCount );
ri.Printf( PRINT_ALL, " %i total images\n\n", tr.numImages );
}

Expand Down
4 changes: 2 additions & 2 deletions src/renderervk/tr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,15 +1994,15 @@ static void R_Register( void )
ri.Cvar_SetDescription( r_screenshotJpegQuality, "Controls quality of Jpeg screenshots when using screenshotJpeg" );

r_bloom_threshold = ri.Cvar_Get( "r_bloom_threshold", "0.6", CVAR_ARCHIVE_ND );
ri.Cvar_SetDescription( r_bloom_threshold, "Color level to extract to bloom texture, default is 0.6." );
ri.Cvar_SetDescription( r_bloom_threshold, "Color level to extract to bloom texture" );
ri.Cvar_SetGroup( r_bloom_threshold, CVG_RENDERER );

r_bloom_threshold_mode = ri.Cvar_Get( "r_bloom_threshold_mode", "0", CVAR_ARCHIVE_ND );
ri.Cvar_SetDescription( r_bloom_threshold_mode, "Color extraction mode:\n 0: (r|g|b) >= threshold\n 1: (r + g + b ) / 3 >= threshold\n 2: luma(r, g, b) >= threshold" );
ri.Cvar_SetGroup( r_bloom_threshold_mode, CVG_RENDERER );

r_bloom_intensity = ri.Cvar_Get( "r_bloom_intensity", "0.5", CVAR_ARCHIVE_ND );
ri.Cvar_SetDescription( r_bloom_intensity, "Final bloom blend factor, default is 0.5." );
ri.Cvar_SetDescription( r_bloom_intensity, "Final bloom blend factor" );
ri.Cvar_SetGroup( r_bloom_intensity, CVG_RENDERER );

r_bloom_modulate = ri.Cvar_Get( "r_bloom_modulate", "0", CVAR_ARCHIVE_ND );
Expand Down
110 changes: 70 additions & 40 deletions src/renderervk/vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define MAX_ATTACHMENTS_IN_POOL (8+VK_NUM_BLOOM_PASSES*2) // depth + msaa + msaa-resolve + depth-resolve + screenmap.msaa + screenmap.resolve + screenmap.depth + bloom_extract + blur pairs

typedef enum {
TYPE_COLOR_BLACK,
TYPE_COLOR_WHITE,
TYPE_COLOR_GREEN,
TYPE_COLOR_RED,
Expand All @@ -38,23 +39,41 @@ typedef enum {
TYPE_SIGNLE_TEXTURE_LIGHTING_LINEAR,

TYPE_SIGNLE_TEXTURE_DF,
TYPE_SIGNLE_TEXTURE_IDENTITY,

TYPE_GENERIC_BEGIN,
TYPE_GENERIC_BEGIN, // start of non-env/env shader pairs
TYPE_SIGNLE_TEXTURE = TYPE_GENERIC_BEGIN,
TYPE_SIGNLE_TEXTURE_ENV,

TYPE_MULTI_TEXTURE_MUL2,
TYPE_MULTI_TEXTURE_MUL2_ENV,
TYPE_SIGNLE_TEXTURE_IDENTITY,
TYPE_SIGNLE_TEXTURE_IDENTITY_ENV,

TYPE_SIGNLE_TEXTURE_FIXED_COLOR,
TYPE_SIGNLE_TEXTURE_FIXED_COLOR_ENV,

TYPE_SIGNLE_TEXTURE_ENT_COLOR,
TYPE_SIGNLE_TEXTURE_ENT_COLOR_ENV,

TYPE_MULTI_TEXTURE_ADD2_IDENTITY,
TYPE_MULTI_TEXTURE_ADD2_IDENTITY_ENV,
TYPE_MULTI_TEXTURE_MUL2_IDENTITY,
TYPE_MULTI_TEXTURE_MUL2_IDENTITY_ENV,

TYPE_MULTI_TEXTURE_ADD2_FIXED_COLOR,
TYPE_MULTI_TEXTURE_ADD2_FIXED_COLOR_ENV,
TYPE_MULTI_TEXTURE_MUL2_FIXED_COLOR,
TYPE_MULTI_TEXTURE_MUL2_FIXED_COLOR_ENV,

TYPE_MULTI_TEXTURE_MUL2,
TYPE_MULTI_TEXTURE_MUL2_ENV,
TYPE_MULTI_TEXTURE_ADD2_1_1,
TYPE_MULTI_TEXTURE_ADD2_1_1_ENV,
TYPE_MULTI_TEXTURE_ADD2,
TYPE_MULTI_TEXTURE_ADD2_ENV,

TYPE_MULTI_TEXTURE_MUL3,
TYPE_MULTI_TEXTURE_MUL3_ENV,
TYPE_MULTI_TEXTURE_ADD3_IDENTITY,
TYPE_MULTI_TEXTURE_ADD3_IDENTITY_ENV,
TYPE_MULTI_TEXTURE_ADD3_1_1,
TYPE_MULTI_TEXTURE_ADD3_1_1_ENV,
TYPE_MULTI_TEXTURE_ADD3,
TYPE_MULTI_TEXTURE_ADD3_ENV,

Expand All @@ -68,6 +87,7 @@ typedef enum {
TYPE_BLEND2_ONE_MINUS_ALPHA_ENV,
TYPE_BLEND2_MIX_ALPHA,
TYPE_BLEND2_MIX_ALPHA_ENV,

TYPE_BLEND2_MIX_ONE_MINUS_ALPHA,
TYPE_BLEND2_MIX_ONE_MINUS_ALPHA_ENV,

Expand Down Expand Up @@ -109,18 +129,18 @@ typedef enum {
} Vk_Primitive_Topology;

typedef enum {
DEPTH_RANGE_NORMAL, // [0..1]
DEPTH_RANGE_ZERO, // [0..0]
DEPTH_RANGE_ONE, // [1..1]
DEPTH_RANGE_WEAPON, // [0..0.3]
DEPTH_RANGE_NORMAL, // [0..1]
DEPTH_RANGE_ZERO, // [0..0]
DEPTH_RANGE_ONE, // [1..1]
DEPTH_RANGE_WEAPON, // [0..0.3]
DEPTH_RANGE_COUNT
} Vk_Depth_Range;

typedef struct {
VkSamplerAddressMode address_mode; // clamp/repeat texture addressing mode
int gl_mag_filter; // GL_XXX mag filter
int gl_min_filter; // GL_XXX min filter
qboolean max_lod_1_0; // fixed 1.0 lod
int gl_mag_filter; // GL_XXX mag filter
int gl_min_filter; // GL_XXX min filter
qboolean max_lod_1_0; // fixed 1.0 lod
qboolean noAnisotropy;
} Vk_Sampler_Def;

Expand All @@ -139,10 +159,15 @@ typedef struct {
qboolean mirror;
Vk_Shadow_Phase shadow_phase;
Vk_Primitive_Topology primitives;
int fog_stage; // off, fog-in / fog-out
int line_width;
int fog_stage; // off, fog-in / fog-out
int abs_light;
int allow_discard;
int acff; // none, rgb, rgba, alpha
struct {
byte rgb;
byte alpha;
} color;
} Vk_Pipeline_Def;

typedef struct VK_Pipeline {
Expand All @@ -152,18 +177,23 @@ typedef struct VK_Pipeline {

// this structure must be in sync with shader uniforms!
typedef struct vkUniform_s {
// vertex shader reference
vec4_t eyePos;
vec4_t lightPos;
// vertex - fog parameters
vec4_t fogDistanceVector;
vec4_t fogDepthVector;
vec4_t fogEyeT;
// fragment shader reference
vec4_t lightColor; // rgb + 1/(r*r)
vec4_t fogColor;
// fragment - linear dynamic light
vec4_t lightVector;
// light/env parameters:
vec4_t eyePos; // vertex
union {
struct {
vec4_t pos; // vertex: light origin
vec4_t color; // fragment: rgb + 1/(r*r)
vec4_t vector; // fragment: linear dynamic light
} light;
struct {
vec4_t color[3]; // ent.color[3]
} ent;
};
// fog parameters:
vec4_t fogDistanceVector; // vertex
vec4_t fogDepthVector; // vertex
vec4_t fogEyeT; // vertex
vec4_t fogColor; // fragment
} vkUniform_t;

#define TESS_XYZ (1)
Expand All @@ -175,7 +205,10 @@ typedef struct vkUniform_s {
#define TESS_ST2 (64)
#define TESS_NNN (128)
#define TESS_VPOS (256) // uniform with eyePos
#define TESS_ENV (512) // mark shader stage with environment mapping
#define TESS_ENV (512) // mark shader stage with environment mapping
#define TESS_ENT0 (1024) // uniform with ent.color[0]
#define TESS_ENT1 (2048) // uniform with ent.color[1]
#define TESS_ENT2 (4096) // uniform with ent.color[2]
//
// Initialization.
//
Expand All @@ -188,7 +221,7 @@ void vk_initialize( void );
void vk_init_descriptors( void );

// Shutdown vulkan subsystem by releasing resources acquired by Vk_Instance.
void vk_shutdown( void );
void vk_shutdown( refShutdownCode_t code );

// Releases vulkan resources allocated during program execution.
// This effectively puts vulkan subsystem into initial state (the state we have after vk_initialize call).
Expand Down Expand Up @@ -289,9 +322,7 @@ typedef struct vk_tess_s {
// Vk_Instance contains engine-specific vulkan resources that persist entire renderer lifetime.
// This structure is initialized/deinitialized by vk_initialize/vk_shutdown functions correspondingly.
typedef struct {
VkInstance instance;
VkPhysicalDevice physical_device;
VkSurfaceKHR surface;
VkSurfaceFormatKHR base_format;
VkSurfaceFormatKHR present_format;

Expand Down Expand Up @@ -411,15 +442,18 @@ typedef struct {
struct {
struct {
VkShaderModule gen[3][2][2][2]; // tx[0,1,2], cl[0,1] env0[0,1] fog[0,1]
VkShaderModule light[2]; // fog[0,1]
VkShaderModule gen0_ident;
} vert;
VkShaderModule ident1[2][2][2]; // tx[0,1], env0[0,1] fog[0,1]
VkShaderModule fixed[2][2][2]; // tx[0,1], env0[0,1] fog[0,1]
VkShaderModule light[2]; // fog[0,1]
} vert;
struct {
VkShaderModule gen0_ident;
VkShaderModule gen0_df;
VkShaderModule gen[3][2][2]; // tx[0,1,2] cl[0,1] fog[0,1]
VkShaderModule light[2][2]; // linear[0,1] fog[0,1]
} frag;
VkShaderModule ident1[2][2]; // tx[0,1], fog[0,1]
VkShaderModule fixed[2][2]; // tx[0,1], fog[0,1]
VkShaderModule ent[1][2]; // tx[0], fog[0,1]
VkShaderModule light[2][2]; // linear[0,1] fog[0,1]
} frag;

VkShaderModule color_fs;
VkShaderModule color_vs;
Expand Down Expand Up @@ -497,10 +531,6 @@ typedef struct {
VkPipeline blur_pipeline[VK_NUM_BLOOM_PASSES*2]; // horizontal & vertical pairs
VkPipeline bloom_blend_pipeline;

#ifndef NDEBUG
VkDebugReportCallbackEXT debug_callback;
#endif

uint32_t frame_count;
qboolean active;
qboolean wideLines;
Expand Down
12 changes: 8 additions & 4 deletions src/renderervk/vk_vbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ static qboolean isStaticTCgen( const shaderStage_t *stage, int bundle )

static qboolean isStaticTCmod( const textureBundle_t *bundle )
{
texMod_t type;
int i;

for ( i = 0; i < bundle->numTexMods; i++ ) {
type = bundle->texMods[i].type;
if ( type != TMOD_NONE && type != TMOD_SCALE && type != TMOD_TRANSFORM && type != TMOD_SWAP ) {
return qfalse;
switch ( bundle->texMods[i].type ) {
case TMOD_NONE:
case TMOD_SCALE:
case TMOD_TRANSFORM:
case TMOD_SWAP:
break;
default:
return qfalse;
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cd4c1a2

Please sign in to comment.