Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e4c9e45
Extract sphere and cylinder mesh generation into shared graphics utility
laanwj Feb 7, 2026
5ee313e
Route ImGui calls through gr_screen function pointers
laanwj Feb 8, 2026
92ec438
Free bitmaps before destroying graphics backend
laanwj Feb 8, 2026
06fbe5c
Use float shader input instead of SCREEN_POS in gr_flash_internal
laanwj Feb 10, 2026
e96b814
Remove now-unused SCREEN_POS vertex format
laanwj Feb 10, 2026
4e34a0c
Add dds_block_size and dds_compressed_mip_size utilities
laanwj Feb 15, 2026
a0d8719
Add CAPABILITY_QUERIES_REUSABLE for GPU queries
laanwj Feb 16, 2026
e20e8ec
Fix gr_flip debug output ordering
laanwj Feb 16, 2026
c125e64
Fix gr_end_2d_matrix viewport for render-to-texture
laanwj Feb 16, 2026
f4fdc03
Fix undefined gl_ClipDistance and use uint for std140 bool
laanwj Feb 16, 2026
7aa8373
Add missing memcpy_if_trivial_else_error for `void *, const void*`
laanwj Feb 16, 2026
2ff55af
Extract shader preprocessor from OpenGL backends
laanwj Mar 7, 2026
669cd21
Add vendored Vulkan headers
laanwj Mar 7, 2026
b790001
Add vendored VMA headers
laanwj Mar 7, 2026
031f38b
Add vendored shaderc headers
laanwj Mar 7, 2026
0217afb
Add S3TC capability and use render system capabilities in ddsutils
laanwj Mar 8, 2026
8b334ec
Factor out shader type & variant tables from OpenGL
laanwj Mar 9, 2026
6e5add9
Add Vulkan rendering backend
laanwj Feb 16, 2026
86ab8d3
fixup: Unify forward-pass shadow code across OpenGL and Vulkan shaders
laanwj Mar 10, 2026
c2b3f59
fixup: Bind shadow map texture during Vulkan model rendering
laanwj Mar 10, 2026
32283e3
fixup: Enable cloak effect and lightshaft cockpit mask for Vulkan
laanwj Mar 10, 2026
9e4914d
fixup: Always write texture descriptor sets in one go
laanwj Mar 10, 2026
6c88507
fixup: Factor out format->aspect flags logic
laanwj Mar 10, 2026
2df56d8
fixup: modernize array use
laanwj Mar 11, 2026
1581cb4
fixup: factor out gbuffer renderpass creation
laanwj Mar 11, 2026
624bc66
fixup: factor out createGbufFramebuffer
laanwj Mar 11, 2026
eb25d17
fixup: Introduce constants for gbuf attachment # / pixel format
laanwj Mar 11, 2026
d32dd04
fixup: Descriptor binding constants
laanwj Mar 11, 2026
c69e0c7
fixup: factor out getFallbackUniformBufferInfo
laanwj Mar 11, 2026
2ab042f
fixup: introduce getFallbackTextureInfo{2D,Cube,2DArray,3D}
laanwj Mar 11, 2026
be6fc70
fixup: Remove loose-field writeUniformBuffer/writeTexture/writeStorag…
laanwj Mar 11, 2026
a2292ad
fixup: factor out MSAA barriers to function
laanwj Mar 11, 2026
a4f7096
fixup: Add constants {HDR,LDR,SHADOW_DEPTH}_COLOR_FORMAT
laanwj Mar 11, 2026
b6f432a
fixup: make texture overrides into DescriptorImageInfos instead of lo…
laanwj Mar 11, 2026
5e35712
fixup: Add flushTextures to flush GPU-side texture cache between levels
laanwj Mar 11, 2026
55765bc
fixup: Clang-tidy warnings
laanwj Mar 11, 2026
d1f78c0
fixup: DescriptorWriter refactor
laanwj Mar 12, 2026
104903c
fixup: factor out bindPendingUBOs logic
laanwj Mar 12, 2026
16c6c1f
fixup: reverse VulkanDescriptorManager::getUniformBlockBinding flow, …
laanwj Mar 12, 2026
a9b6c16
fixup: Uniform descriptor set descriptions
laanwj Mar 12, 2026
5f401eb
fixup: Don't build a vector just to return it in VulkanDescriptorManager
laanwj Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ci/linux/clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ fi
# branch
BASE_COMMIT=$(git merge-base $1 $2)

# Note: Manually passing in the Vulkan flags that are normally provided by cmake (but are not so, here), to ensure
# that the source files are checked with the actual configuration used.
echo "Running clang-tidy on changed files"
git diff -U0 --no-color "$BASE_COMMIT..$2" | \
$HERE/clang-tidy-diff.py -path "$(pwd)/build" -p1 \
-extra-arg="-DWITH_VULKAN" \
-extra-arg="-DVULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1" \
-extra-arg="-DVK_NO_PROTOTYPES" \
-regex '(code(?!((\/graphics\/shaders\/compiled)|(\/globalincs\/windebug)|(\/def_files\/data)))|freespace2|qtfred|test\/src|build|tools)\/.*\.(cpp|h)' \
-clang-tidy-binary /usr/bin/clang-tidy-16 -j$(nproc) -export-fixes "$(pwd)/clang-fixes.yaml"
6 changes: 5 additions & 1 deletion ci/linux/configure_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ fi

CMAKE_OPTIONS="$JOB_CMAKE_OPTIONS"
if [[ "$COMPILER" =~ ^clang.*$ ]]; then
# Force clang to silently allow -static-libstdc++ flag
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCLANG_USE_LIBCXX=ON"
# force clang to silently allow -static-libstdc++ flag
# Enable Vulkan for clang builds so the compilation database includes the
# bundled Vulkan headers. Without this, clang-tidy falls back to
# system-installed Vulkan headers which may be an incompatible version.
CMAKE_OPTIONS="$CMAKE_OPTIONS -DFSO_BUILD_WITH_VULKAN=ON"
fi

if [ ! "$CCACHE_PATH" = "" ]; then
Expand Down
14 changes: 4 additions & 10 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,10 @@ if (FSO_BUILD_WITH_OPENGL)
target_compile_definitions(code PUBLIC WITH_OPENGL)
endif()
if (FSO_BUILD_WITH_VULKAN)
find_package(Vulkan REQUIRED)
if (Vulkan_FOUND)
target_compile_definitions(code PUBLIC WITH_VULKAN)
target_link_libraries(code PRIVATE Vulkan::Vulkan)

target_compile_definitions(code PUBLIC WITH_VULKAN VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VK_NO_PROTOTYPES)
else()
message(WARNING "FSO_BUILD_WITH_VULKAN was set, but the package was unable to be found. Forcing OFF.")
set(FSO_BUILD_WITH_VULKAN OFF CACHE BOOL "Enable compilation of the Vulkan renderer" FORCE)
endif()
target_compile_definitions(code PUBLIC WITH_VULKAN VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VK_NO_PROTOTYPES)
target_link_libraries(code PUBLIC VulkanHeaders)
target_link_libraries(code PUBLIC ShadercHeaders)
target_link_libraries(code PUBLIC VulkanMemoryAllocator)
endif()

include(shaders.cmake)
Expand Down
14 changes: 4 additions & 10 deletions code/ddsutils/ddsutils.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@

#include "ddsutils/ddsutils.h"
#include "cfile/cfile.h"
#include "graphics/2d.h"
#include "osapi/osregistry.h"

#ifdef WITH_OPENGL
#include <glad/glad.h>
#else
static constexpr int GLAD_GL_EXT_texture_compression_s3tc = 0;
static constexpr int GLAD_GL_ARB_texture_compression_bptc = 0;
#endif

#define BCDEC_IMPLEMENTATION 1
PUSH_SUPPRESS_WARNINGS
#include "ddsutils/bcdec.h"
Expand Down Expand Up @@ -57,11 +51,11 @@ static bool conversion_needed(const DDS_HEADER &dds_header)
case FOURCC_DXT1:
case FOURCC_DXT3:
case FOURCC_DXT5:
return !GLAD_GL_EXT_texture_compression_s3tc;
return !gr_is_capable(gr_capability::CAPABILITY_S3TC);

case FOURCC_DX10:
// anything other than BC7 will end up invalid
return !GLAD_GL_ARB_texture_compression_bptc;
return !gr_is_capable(gr_capability::CAPABILITY_BPTC);

default:
break;
Expand Down Expand Up @@ -223,7 +217,7 @@ static size_t compute_dds_size(const DDS_HEADER &dds_header, bool converting = f

if (dds_header.ddspf.dwFlags & DDPF_FOURCC) {
// size of data block (4x4)
d_size += ((d_width + 3) / 4) * ((d_height + 3) / 4) * d_depth * ((dds_header.ddspf.dwFourCC == FOURCC_DXT1) ? 8 : 16);
d_size += dds_compressed_mip_size(d_width, d_height, (dds_header.ddspf.dwFourCC == FOURCC_DXT1) ? 8 : 16) * d_depth;
} else {
d_size += d_width * d_height * d_depth * (dds_header.ddspf.dwRGBBitCount / 8);
}
Expand Down
21 changes: 21 additions & 0 deletions code/ddsutils/ddsutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,27 @@ typedef struct {
} DDS_HEADER_DXT10;
#pragma pack()

// Block size in bytes for a 4x4 texel block of a compressed DDS format.
// comp_type is one of the DDS_DXT*/DDS_CUBEMAP_DXT* constants.
inline int dds_block_size(int comp_type) {
switch (comp_type) {
case DDS_DXT1:
case DDS_CUBEMAP_DXT1:
return 8;
case DDS_DXT3: case DDS_CUBEMAP_DXT3:
case DDS_DXT5: case DDS_CUBEMAP_DXT5:
case DDS_BC7:
return 16;
default:
return 0;
}
}

// Size in bytes of one mip level of a block-compressed texture.
inline size_t dds_compressed_mip_size(int w, int h, int block_size) {
return static_cast<size_t>(((w + 3) / 4) * ((h + 3) / 4) * block_size);
}

#define DDS_OFFSET 4+sizeof(DDS_HEADER) //place where the data starts -- should be 128
#define DX10_OFFSET DDS_OFFSET+sizeof(DDS_HEADER_DXT10) // Unless a DX10 header is present

Expand Down
26 changes: 26 additions & 0 deletions code/def_files/data/effects/batched-f.sdr
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@

#include "gamma.sdr"

#ifdef VULKAN
layout (location = 0) in vec4 fragTexCoord;
layout (location = 1) in vec4 fragColor;

layout (location = 0) out vec4 fragOut0;

layout (set = 1, binding = 1) uniform sampler2DArray baseMap;

layout (set = 2, binding = 0, std140) uniform genericData {
mat4 modelMatrix;

vec4 color;

vec4 clipEquation;

int baseMapIndex;
int alphaTexture;
int noTexturing;
int srgb;

float intensity;
float alphaThreshold;
uint clipEnabled;
};
#else
in vec4 fragTexCoord;
in vec4 fragColor;

Expand All @@ -12,6 +37,7 @@ layout (std140) uniform genericData {
vec4 color;
float intensity;
};
#endif

void main()
{
Expand Down
31 changes: 31 additions & 0 deletions code/def_files/data/effects/batched-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
#ifdef VULKAN
layout (location = 0) in vec4 vertPosition;
layout (location = 1) in vec4 vertColor;
layout (location = 2) in vec4 vertTexCoord;

layout (location = 0) out vec4 fragTexCoord;
layout (location = 1) out vec4 fragColor;

layout (set = 2, binding = 1, std140) uniform matrixData {
mat4 modelViewMatrix;
mat4 projMatrix;
};

layout (set = 2, binding = 0, std140) uniform genericData {
mat4 modelMatrix;

vec4 color;

vec4 clipEquation;

int baseMapIndex;
int alphaTexture;
int noTexturing;
int srgb;

float intensity;
float alphaThreshold;
uint clipEnabled;
};
#else
in vec4 vertPosition;
in vec4 vertTexCoord;
in vec4 vertColor;
Expand All @@ -14,6 +44,7 @@ layout (std140) uniform genericData {
vec4 color;
float intensity;
};
#endif

void main()
{
Expand Down
15 changes: 12 additions & 3 deletions code/def_files/data/effects/bloom-comp-f.sdr
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@

#ifdef VULKAN
layout(location = 0) in vec2 fragTexCoord;
layout(location = 0) out vec4 fragOut0;
layout(set = 1, binding = 1) uniform sampler2D bloomed;
#else
in vec4 fragTexCoord;

out vec4 fragOut0;

uniform sampler2D bloomed;
#endif

layout (std140) uniform genericData {
#ifdef VULKAN
layout(std140, set = 2, binding = 0)
#else
layout(std140)
#endif
uniform genericData {
float bloom_intensity;
int levels;
};
Expand Down
20 changes: 15 additions & 5 deletions code/def_files/data/effects/blur-f.sdr
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#ifdef VULKAN
layout(location = 0) in vec2 fragTexCoord;
layout(location = 0) out vec4 fragOut0;
layout(set = 1, binding = 1) uniform sampler2D tex;
#else
out vec4 fragOut0;

in vec4 fragTexCoord;

uniform sampler2D tex;
#endif

const float TapSize = 1.0;

layout (std140) uniform genericData {
#ifdef VULKAN
layout(set = 2, binding = 0, std140)
#else
layout(std140)
#endif
uniform genericData {
float texSize;
int level;
int pad[2];
};

const float TapSize = 1.0;

// Gaussian Blur
// 2 passes required
void main()
Expand Down
6 changes: 6 additions & 0 deletions code/def_files/data/effects/brightpass-f.sdr
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifdef VULKAN
layout(location = 0) in vec2 fragTexCoord;
layout(location = 0) out vec4 fragOut0;
layout(set = 1, binding = 1) uniform sampler2D tex;
#else
in vec4 fragTexCoord;
out vec4 fragOut0;
uniform sampler2D tex;
#endif
const float Luminance = 0.08;
const float fMiddleGray = 0.2;
const float fWhiteCutoff = 0.4;
Expand Down
9 changes: 7 additions & 2 deletions code/def_files/data/effects/copy-f.sdr
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#ifdef VULKAN
layout(location = 0) in vec2 fragTexCoord;
layout(location = 0) out vec4 fragOut0;
layout(set = 1, binding = 1) uniform sampler2D tex;
#else
in vec4 fragTexCoord;
out vec4 fragOut0;

#ifdef COPY_ARRAY
uniform sampler2DArray tex;
#else
uniform sampler2D tex;
#endif
#endif

void main()
{
#ifdef COPY_ARRAY
#if defined(COPY_ARRAY) && !defined(VULKAN)
fragOut0 = texture(tex, vec3(fragTexCoord.xy, 0));
#else
fragOut0 = texture(tex, fragTexCoord.xy);
Expand Down
Loading
Loading