Merge branch 'vulkan'

This commit is contained in:
Bill Currie 2021-03-23 12:31:58 +09:00
commit 5d9bf32d3c
514 changed files with 35390 additions and 8004 deletions

View File

@ -107,6 +107,27 @@ qcautodep = $(join $(addsuffix $(DEPDIR)/,$(dir $(basename $(1)))),$(addsuffix .
r_depfiles_remade=
pas_depfiles_remade=
V_GLSLANG = $(V_GLSLANG_@AM_V@)
V_GLSLANG_ = $(V_GLSLANG_@AM_DEFAULT_V@)
V_GLSLANG_0 = @echo " GLSLANG " $@;
V_GLSLANG_1 =
V_XXD = $(V_XXD_@AM_V@)
V_XXD_ = $(V_XXD_@AM_DEFAULT_V@)
V_XXD_0 = @echo " XXD " $@;
V_XXD_1 =
%.spv: %
@$(mkdir_p) $(builddir)/`dirname $@`
$(V_GLSLANG)(((($(GLSLANGVALIDATOR) -V $< -o $@; echo $$? >&3) | sed -e '1d' 1>&2) 3>&1) | (read xs; exit $$xs))
%.spvc: %
@$(mkdir_p) $(builddir)/`dirname $@`
$(V_GLSLANG)(((($(GLSLANGVALIDATOR) --vn `basename $< | tr . _` -V $< -o $@; echo $$? >&3) | sed -e '1d' 1>&2) 3>&1) | (read xs; exit $$xs))
shaderdir = @shaderdir@
shader_DATA =
include doc/Makemodule.am
include RPM/Makemodule.am
include debian/Makemodule.am
@ -122,6 +143,7 @@ include tools/Makemodule.am
include ruamoko/Makemodule.am
DISTCLEANFILES += $(r_depfiles_remade) $(pas_depfiles_remade)
CLEANFILES += $(shader_DATA)
$(r_depfiles_remade):
$(MKDIR_P) $(@D)

View File

@ -41,6 +41,7 @@ if test "x$HAVE_FBDEV" = xyes; then
CL_TARGETS="$CL_TARGETS FBDEV"
VID_TARGETS="$VID_TARGETS libs/video/targets/libQFfbdev.la"
QF_NEED(vid_render, [sw])
QF_NEED(render, [sw])
QF_NEED(models, [sw])
QF_NEED(alias, [sw])
QF_NEED(brush, [sw])
@ -71,7 +72,17 @@ if test "x$HAVE_X" = xyes; then
NQ_DESKTOP_DATA="$NQ_DESKTOP_DATA desktop/quakeforge-nq-x11.desktop"
CL_TARGETS="$CL_TARGETS X11"
VID_TARGETS="$VID_TARGETS libs/video/targets/libQFx11.la"
if test "$HAVE_VULKAN" = "yes"; then
QF_NEED(vid_render, [vulkan])
QF_NEED(render, [vulkan])
QF_NEED(models, [vulkan])
QF_NEED(alias, [vulkan])
QF_NEED(brush, [vulkan])
QF_NEED(iqm, [vulkan])
QF_NEED(sprite, [vulkan])
fi
QF_NEED(vid_render, [sw sw32 gl glsl])
QF_NEED(render, [sw sw32 gl glsl])
QF_NEED(models, [sw gl glsl])
QF_NEED(alias, [sw gl glsl])
QF_NEED(brush, [sw gl glsl])
@ -95,7 +106,16 @@ if test "x$HAVE_SDL" = xyes; then
NQ_DESKTOP_DATA="$NQ_DESKTOP_DATA desktop/quakeforge-nq-sdl.desktop"
CL_TARGETS="$CL_TARGETS SDL"
VID_TARGETS="$VID_TARGETS libs/video/targets/libQFsdl.la"
if test "$HAVE_VULKAN" = "yes"; then
QF_NEED(vid_render, [vulkan])
QF_NEED(render, [vulkan])
QF_NEED(alias, [vulkan])
QF_NEED(brush, [vulkan])
QF_NEED(iqm, [vulkan])
QF_NEED(sprite, [vulkan])
fi
QF_NEED(vid_render, [sw sw32 gl glsl])
QF_NEED(render, [sw sw32 gl glsl])
QF_NEED(models, [sw gl glsl])
QF_NEED(alias, [sw gl glsl])
QF_NEED(brush, [sw gl glsl])
@ -118,6 +138,7 @@ if test "x$HAVE_SVGA" = xyes; then
CL_TARGETS="$CL_TARGETS SVGAlib"
VID_TARGETS="$VID_TARGETS libs/video/targets/libQFsvga.la"
QF_NEED(vid_render, [sw])
QF_NEED(render, [sw])
QF_NEED(models, [sw])
QF_NEED(alias, [sw])
QF_NEED(brush, [sw])
@ -140,6 +161,7 @@ fi
# CL_TARGETS="$CL_TARGETS WGL"
# VID_TARGETS="$VID_TARGETS libs/video/targets/libQFwgl.la"
# QF_NEED(vid_render, [gl])
# QF_NEED(render, [gl])
# QF_NEED(models, [gl])
# QF_NEED(alias, [gl])
# QF_NEED(brush, [gl])
@ -245,13 +267,8 @@ fi
QF_NEED(top, [libs hw nq qtv qw])
QF_PROCESS_NEED_DIRS(tools,[bsp2img carne pak qfbsp qfcc qflight qflmp qfmodelgen qfspritegen qfvis wad wav])
QF_PROCESS_NEED_FUNC(tools,[bsp2img carne pak qfbsp qfcc qflight qflmp qfmodelgen qfspritegen qfvis wad wav], QF_NEED(top,tools))
QF_PROCESS_NEED_DIRS(libs,[util gamecode ruamoko gib audio image models video console net qw client])
QF_PROCESS_NEED_DIRS(ruamoko,[qwaq])
if test "$ENABLE_tools_qfcc" = "yes" -a "$ENABLE_tools_pak" = "yes"; then
QF_NEED(top, [ruamoko])
qfac_qfcc_include_qf="\$(qfcc_include_qf)"
@ -264,12 +281,14 @@ if test x"${top_need_libs}" = xyes; then
qfac_include_qf_glsl="\$(include_qf_glsl)"
qfac_include_qf_math="\$(include_qf_math)"
qfac_include_qf_plugin="\$(include_qf_plugin)"
qfac_include_qf_vulkan="\$(include_qf_vulkan)"
fi
QF_SUBST(qfac_include_qf)
QF_SUBST(qfac_include_qf_gl)
QF_SUBST(qfac_include_qf_glsl)
QF_SUBST(qfac_include_qf_math)
QF_SUBST(qfac_include_qf_plugin)
QF_SUBST(qfac_include_qf_vulkan)
progs_gz=
if test "$HAVE_ZLIB" = "yes"; then
@ -277,15 +296,13 @@ if test "$HAVE_ZLIB" = "yes"; then
fi
QF_SUBST(progs_gz)
QF_PROCESS_NEED_DIRS(top, [libs hw nq qtv qw tools ruamoko])
QF_PROCESS_NEED_LIBS(swrend, [asm])
QF_PROCESS_NEED_DIRS(vid_render, [gl glsl sw sw32])
QF_PROCESS_NEED_LIBS(models, [gl glsl sw], [libs/models])
QF_PROCESS_NEED_LIBS(alias, [gl glsl sw], [libs/models/alias])
QF_PROCESS_NEED_LIBS(brush, [gl glsl sw], [libs/models/brush])
QF_PROCESS_NEED_LIBS(iqm, [gl glsl sw], [libs/models/iqm])
QF_PROCESS_NEED_LIBS(sprite, [gl glsl sw], [libs/models/sprite])
QF_PROCESS_NEED_LIBS(render, [gl glsl sw sw32 vulkan], [libs/video/renderer])
QF_PROCESS_NEED_LIBS(models, [gl glsl sw vulkan], [libs/models])
QF_PROCESS_NEED_LIBS(alias, [gl glsl sw vulkan], [libs/models/alias])
QF_PROCESS_NEED_LIBS(brush, [gl glsl sw vulkan], [libs/models/brush])
QF_PROCESS_NEED_LIBS(iqm, [gl glsl sw vulkan], [libs/models/iqm])
QF_PROCESS_NEED_LIBS(sprite, [gl glsl sw vulkan], [libs/models/sprite])
QF_PROCESS_NEED_LIBS(vid, [common sdl svga x11], [libs/video/targets])
QF_PROCESS_NEED_LIBS(qw, [client common sdl server], [qw/source], a)
@ -330,7 +347,7 @@ if test "x$static_plugins" = xauto; then
fi
fi
if test "x$static_plugins" = xyes; then
QF_PROCESS_NEED_STATIC_PLUGINS(vid_render, [sw sw32 glsl gl], [libs/video/renderer])
QF_PROCESS_NEED_STATIC_PLUGINS(vid_render, [sw sw32 glsl gl vulkan], [libs/video/renderer])
QF_PROCESS_NEED_STATIC_PLUGINS(console, [server], [libs/console], [server])
QF_PROCESS_NEED_STATIC_PLUGINS(console, [client], [libs/console], [client])
@ -345,7 +362,7 @@ if test "x$static_plugins" = xyes; then
CDTYPE="$CDTYPE (static)"
fi
else
QF_PROCESS_NEED_PLUGINS(vid_render, [sw sw32 glsl gl], [libs/video/renderer])
QF_PROCESS_NEED_PLUGINS(vid_render, [sw sw32 glsl gl vulkan], [libs/video/renderer])
QF_PROCESS_NEED_PLUGINS(console, [server], [libs/console], [server])
QF_PROCESS_NEED_PLUGINS(console, [client], [libs/console], [client])
QF_PROCESS_NEED_PLUGINS(snd_output, [sdl mme sgi sun win dx oss alsa], [libs/audio/targets])

View File

@ -82,6 +82,11 @@ AC_ARG_ENABLE(optimize,
optimize=yes
)
QF_CC_OPTION(-mavx2)
dnl fma is not used as it is the equivalent of turning on
dnl -funsafe-math-optimizations
dnl QF_CC_OPTION(-mfma)
AC_MSG_CHECKING(for optimization)
if test "x$optimize" = xyes -a "x$leave_cflags_alone" != "xyes"; then
AC_MSG_RESULT(yes)
@ -218,6 +223,12 @@ QF_CC_OPTION(-Wsuggest-attribute=const)
QF_CC_OPTION(-Wsuggest-attribute=noreturn)
QF_CC_OPTION(-Wsuggest-attribute=format)
AC_ARG_ENABLE(coverage,
[ --enable-coverage Enable generation of data for gcov])
if test "x$enable_coverage" = xyes; then
QF_CC_OPTION(-fprofile-arcs -ftest-coverage)
fi
dnl QuakeForge uses lots of BCPL-style (//) comments, which can cause problems
dnl with many compilers that do not support the latest ISO standards. Well,
dnl that is our cover story -- the reality is that we like them and do not want
@ -245,8 +256,7 @@ if test "x$GCC" != xyes; then
fi
AC_ARG_ENABLE(Werror,
[ --disable-Werror Do not treat warnings as errors]
)
[ --disable-Werror Do not treat warnings as errors])
dnl We want warnings, lots of warnings...
dnl The help text should be INVERTED before release!
dnl when in git, this test defaults to ENABLED.

View File

@ -35,6 +35,25 @@ if test "x$ac_cv_func_dlopen" != "xyes"; then
fi
AC_SUBST(DL_LIBS)
if test "x$DL_LIBS" != "x"; then
AC_MSG_CHECKING([for RTLD_NOW])
AC_TRY_COMPILE(
[#include <dlfcn.h>],
[int foo = RTLD_NOW],
AC_DEFINE(HAVE_RTLD_NOW, 1, [Define if you have RTLD_NOW.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
)
AC_MSG_CHECKING([for RTLD_DEEPBIND])
AC_TRY_COMPILE(
[#include <dlfcn.h>],
[int foo = RTLD_DEEPBIND],
AC_DEFINE(HAVE_RTLD_DEEPBIND, 1, [Define if you have RTLD_DEEPBIND.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
)
fi
dnl Checks for stricmp/strcasecmp
#AC_CHECK_FUNC(strcasecmp,
# ,

View File

@ -98,6 +98,19 @@ eval expanded_plugindir="$expanded_plugindir"
AC_DEFINE_UNQUOTED(FS_PLUGINPATH, "$expanded_plugindir", [Define this to the path from which to load plugins])
AC_SUBST(plugindir)
SHADERDIR="\${libdir}/quakeforge/shaders"
if test "x$shaderdir" = "xauto" -o "x$shaderdir" = "xyes" -o "x$shaderdir" = "x"; then
shaderdir="$SHADERDIR"
elif test "x$shaderdir" = xno; then
shaderdir="."
else
SHADERDIR="$shaderdir"
fi
eval expanded_shaderdir="$shaderdir"
eval expanded_shaderdir="$expanded_shaderdir"
AC_DEFINE_UNQUOTED(FS_SHADERPATH, "$expanded_shaderdir", [Define this to the path from which to load shaders])
AC_SUBST(plugindir)
AC_ARG_WITH(gl-driver,
[ --with-gl-driver=NAME Name of OpenGL driver DLL/DSO],
gl_driver=$withval,

21
config.d/vulkan.m4 Normal file
View File

@ -0,0 +1,21 @@
dnl Check for vulkan support
AC_ARG_ENABLE(vulkan,
[ --disable-vulkan do not use Vulkan],
HAVE_VULKAN=$enable_vulkan, HAVE_VULKAN=auto)
if test "x$HAVE_VULKAN" != xno; then
save_CPPFLAGS="$CPPFLAGS"
AS_IF([test x"$VULKAN_SDK" != x], [
CPPFLAGS="$CPPFLAGS -I$VULKAN_SDK/include"
LDFLAGS="$LDFLAGS -L$VULKAN_SDK/lib"
glslangvalidator="$VULKAN_SDK/bin/glslangValidator"
], [glslangvalidator="glslangValidator"])
AC_CHECK_HEADER([vulkan/vulkan.h], [HAVE_VULKAN=yes], [HAVE_VULKAN=no])
CPPFLAGS="$save_CPPFLAGS"
fi
if test "x$HAVE_VULKAN" = xyes; then
AC_DEFINE([HAVE_VULKAN], [1], [Define if yhou have the Vulkan libs])
fi
AC_SUBST(VULKAN_LIBS)
AC_SUBST(GLSLANGVALIDATOR, [$glslangvalidator])
AM_CONDITIONAL(X11_VULKAN, test "x$HAVE_VULKAN" = "xyes")

View File

@ -63,6 +63,7 @@ m4_include(config.d/compression.m4)
m4_include(config.d/mgl.m4)
m4_include(config.d/fbdev.m4)
m4_include(config.d/svga.m4)
m4_include(config.d/vulkan.m4)
m4_include(config.d/x11.m4)
m4_include(config.d/sdl.m4)

View File

@ -76,5 +76,6 @@ doc/progs/vm-mem.eps: doc/progs/vm-mem.fig
doc/qtv/qwtv.svg: doc/qtv/qwtv.fig
doc/qtv/qwtv.eps: doc/qtv/qwtv.fig
doc: doc/quakeforge.dox.conf doc/progs/vm-mem.svg doc/progs/vm-mem.eps doc/qtv/qwtv.svg qtv/qwtv.eps ${DOX}
.PHONY: doc
doc: doc/quakeforge.dox.conf doc/progs/vm-mem.svg doc/progs/vm-mem.eps doc/qtv/qwtv.svg doc/qtv/qwtv.eps ${DOX}
doxygen doc/quakeforge.dox.conf

View File

@ -253,12 +253,6 @@ TAB_SIZE = 4
ALIASES = QF=QuakeForge
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
# will allow you to use the command class in the itcl::class meaning.
TCL_SUBST =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
@ -937,8 +931,8 @@ EXAMPLE_RECURSIVE = NO
# \image command).
IMAGE_PATH = @TOPSRC@/doc \
@builddir@/progs \
@builddir@/qtv
@builddir@/doc/progs \
@builddir@/doc/qtv
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
@ -1122,13 +1116,6 @@ CLANG_DATABASE_PATH =
ALPHABETICAL_INDEX = YES
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
# which the alphabetical index list will be split.
# Minimum value: 1, maximum value: 20, default value: 5.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
COLS_IN_ALPHA_INDEX = 4
# In case all classes in a project start with a common prefix, all classes will
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
# can be used to specify a prefix (or a list of prefixes) that should be ignored
@ -1756,7 +1743,7 @@ COMPACT_LATEX = YES
# The default value is: a4.
# This tag requires that the tag GENERATE_LATEX is set to YES.
PAPER_TYPE = a4wide
PAPER_TYPE = a4
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
# that should be included in the LaTeX output. The package can be specified just
@ -2144,7 +2131,6 @@ SEARCH_INCLUDES = YES
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH = @TOPSRC@/include \
@TOPSRC@/hw/include \
@TOPSRC@/nq/include \
@TOPSRC@/qw/include \
@TOPSRC@/qtv/include

View File

@ -471,11 +471,8 @@ SV_WriteFilterList (void)
static void
SV_Shutdown (void *data)
{
NET_Shutdown ();
// write filter list
SV_WriteFilterList ();
Con_Shutdown ();
}
static void

View File

@ -11,7 +11,6 @@ EXTRA_DIST += \
include/block16.h \
include/block8.h \
include/buildnum.h \
include/clview.h \
include/compat.h \
include/context_sdl.h \
include/context_x11.h \
@ -69,11 +68,18 @@ EXTRA_DIST += \
include/sv_console.h \
include/varrays.h \
include/vgamodes.h \
include/vid_gl.h \
include/vid_internal.h \
include/vid_sw.h \
include/vid_vulkan.h \
include/vregset.h \
include/winquake.h \
include/world.h \
include/client/effects.h \
include/client/entities.h \
include/client/temp_entities.h \
include/client/locs.h \
include/client/view.h \
include/qw/bothdefs.h \
include/qw/msg_backbuf.h \
include/qw/msg_ucmd.h \

View File

@ -50,6 +50,6 @@ void gl_lightmap_init (void);
void GL_BuildLightmaps (struct model_s **models, int num_models);
void R_BlendLightmaps (void);
void R_CalcLightmaps (void);
extern void (*R_BuildLightMap) (msurface_t *surf);
extern void (*R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
#endif // __QF_GL_lightmap_h

View File

@ -36,7 +36,7 @@
void glsl_lightmap_init (void);
void glsl_R_BuildLightmaps (struct model_s **models, int num_models);
void glsl_R_CalcLightmaps (void);
extern void (*glsl_R_BuildLightMap) (msurface_t *surf);
extern void (*glsl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
int glsl_R_LightmapTexture (void) __attribute__((pure));
void glsl_R_FlushLightmaps (void);

View File

@ -31,15 +31,6 @@
#include "QF/qtypes.h"
typedef struct scrap_s scrap_t;
typedef struct subpic_s {
const struct subpic_s * const next;
const scrap_t * const scrap;
const struct vrect_s * const rect;
const int tnum; ///< texture number
const int width; ///< requested width
const int height; ///< requested height
const float size; ///< size factor for tex coords (mult)
} subpic_t;
int GLSL_LoadQuakeTexture (const char *identifier, int width, int height,
byte *data);
@ -56,9 +47,11 @@ scrap_t *GLSL_CreateScrap (int size, int format, int linear);
void GLSL_DestroyScrap (scrap_t *scrap);
void GLSL_ScrapClear (scrap_t *scrap);
int GLSL_ScrapTexture (scrap_t *scrap) __attribute__((pure));
subpic_t *GLSL_ScrapSubpic (scrap_t *scrap, int width, int height); //XXX slow!
void GLSL_SubpicDelete (subpic_t *subpic); //XXX slow!
void GLSL_SubpicUpdate (subpic_t *subpic, byte *data, int batch);
//XXX slow!
struct subpic_s *GLSL_ScrapSubpic (scrap_t *scrap, int width, int height);
//XXX slow!
void GLSL_SubpicDelete (struct subpic_s *subpic);
void GLSL_SubpicUpdate (struct subpic_s *subpic, byte *data, int batch);
void GLSL_ScrapFlush (scrap_t *scrap);
#endif//__QF_GLSL_textures_h

View File

@ -25,7 +25,6 @@ include_qf = \
include/QF/keys.h \
include/QF/link.h \
include/QF/llist.h \
include/QF/locs.h \
include/QF/mathlib.h \
include/QF/mdfour.h \
include/QF/mersenne.h \
@ -37,6 +36,7 @@ include_qf = \
include/QF/pakfile.h \
include/QF/pcx.h \
include/QF/png.h \
include/QF/plist.h \
include/QF/plugin.h \
include/QF/pr_comp.h \
include/QF/pr_debug.h \
@ -46,7 +46,6 @@ include_qf = \
include/QF/qargs.h \
include/QF/qdefs.h \
include/QF/qendian.h \
include/QF/qfplist.h \
include/QF/qtypes.h \
include/QF/quakefs.h \
include/QF/quakeio.h \
@ -125,6 +124,22 @@ include_qf_plugin = \
include/QF/plugin/snd_render.h \
include/QF/plugin/vid_render.h
include_qf_vulkan = \
include/QF/Vulkan/buffer.h \
include/QF/Vulkan/command.h \
include/QF/Vulkan/cvars.h \
include/QF/Vulkan/descriptor.h \
include/QF/Vulkan/device.h \
include/QF/Vulkan/funclist.h \
include/QF/Vulkan/image.h \
include/QF/Vulkan/instance.h \
include/QF/Vulkan/memory.h \
include/QF/Vulkan/pipeline.h \
include/QF/Vulkan/qf_draw.h \
include/QF/Vulkan/qf_vid.h \
include/QF/Vulkan/renderpass.h \
include/QF/Vulkan/swapchain.h
# headers shared with ruamoko
qfcc_include_qf = include/QF/keys.h
@ -133,11 +148,13 @@ qf_gl_includedir = $(includedir)/QF/GL
qf_glsl_includedir = $(includedir)/QF/GLSL
qf_math_includedir = $(includedir)/QF/math
qf_plugin_includedir = $(includedir)/QF/plugin
qf_vulkan_includedir = $(includedir)/QF/vulkan
qf_include_HEADERS = @qfac_include_qf@
qf_gl_include_HEADERS = @qfac_include_qf_gl@
qf_glsl_include_HEADERS = @qfac_include_qf_glsl@
qf_math_include_HEADERS = @qfac_include_qf_math@
qf_plugin_include_HEADERS = @qfac_include_qf_plugin@
qf_vulkan_include_HEADERS = @qfac_include_qf_vulkan@
ruamoko_qf_includedir = $(ruamoko_includedir)/QF
ruamoko_qf_include_HEADERS = @qfac_qfcc_include_qf@
@ -148,4 +165,5 @@ EXTRA_HEADERS += \
$(include_qf_glsl) \
$(include_qf_math) \
$(include_qf_plugin) \
$(include_qf_vulkan) \
$(qfcc_include_qf)

View File

@ -0,0 +1,22 @@
#ifndef __QF_Vulkan_barrier_h
#define __QF_Vulkan_barrier_h
typedef struct {
VkPipelineStageFlags src;
VkPipelineStageFlags dst;
} qfv_pipelinestagepair_t;
//XXX Note: imageLayoutTransitionBarriers, imageLayoutTransitionStages and
// the enum must be kept in sync
enum {
qfv_LT_Undefined_to_TransferDst,
qfv_LT_TransferDst_to_ShaderReadOnly,
qfv_LT_ShaderReadOnly_to_TransferDst,
qfv_LT_Undefined_to_DepthStencil,
qfv_LT_Undefined_to_Color,
};
extern const VkImageMemoryBarrier imageLayoutTransitionBarriers[];
extern const qfv_pipelinestagepair_t imageLayoutTransitionStages[];
#endif//__QF_Vulkan_barrier_h

View File

@ -0,0 +1,48 @@
#ifndef __QF_Vulkan_buffer_h
#define __QF_Vulkan_buffer_h
#include "QF/darray.h"
typedef struct qfv_buffertransition_s {
VkBuffer buffer;
VkAccessFlags srcAccess;
VkAccessFlags dstAccess;
uint32_t srcQueueFamily;
uint32_t dstQueueFamily;
VkDeviceSize offset;
VkDeviceSize size;
} qfv_buffertransition_t;
typedef struct qfv_buffertransitionset_s
DARRAY_TYPE (qfv_buffertransition_t) qfv_buffertransitionset_t;
typedef struct qfv_bufferbarrierset_s
DARRAY_TYPE (VkBufferMemoryBarrier) qfv_bufferbarrierset_t;
typedef struct qfv_bufferset_s
DARRAY_TYPE (VkBuffer) qfv_bufferset_t;
#define QFV_AllocBufferSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_bufferset_t, num, allocator)
struct qfv_device_s;
VkBuffer QFV_CreateBuffer (struct qfv_device_s *device,
VkDeviceSize size,
VkBufferUsageFlags usage);
VkDeviceMemory QFV_AllocBufferMemory (struct qfv_device_s *device,
VkBuffer buffer,
VkMemoryPropertyFlags properties,
VkDeviceSize size, VkDeviceSize offset);
int QFV_BindBufferMemory (struct qfv_device_s *device,
VkBuffer buffer, VkDeviceMemory object,
VkDeviceSize offset);
qfv_bufferbarrierset_t *
QFV_CreateBufferTransitions (qfv_buffertransition_t *transitions,
int numTransitions);
VkBufferView QFV_CreateBufferView (struct qfv_device_s *device,
VkBuffer buffer, VkFormat format,
VkDeviceSize offset, VkDeviceSize size);
#endif//__QF_Vulkan_buffer_h

View File

@ -0,0 +1,47 @@
#ifndef __QF_Vulkan_command_h
#define __QF_Vulkan_command_h
#include "QF/darray.h"
typedef struct qfv_cmdbufferset_s
DARRAY_TYPE (VkCommandBuffer) qfv_cmdbufferset_t;
#define QFV_AllocCommandBufferSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_cmdbufferset_t, num, allocator)
typedef struct qfv_semaphoreset_s
DARRAY_TYPE (VkSemaphore) qfv_semaphoreset_t;
typedef struct qfv_fenceset_s
DARRAY_TYPE (VkFence) qfv_fenceset_t;
#define QFV_AllocFenceSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_fenceset_t, num, allocator)
typedef struct qfv_bufferimagecopy_s
DARRAY_TYPE (VkBufferImageCopy) qfv_bufferimagecopy_t;
#define QFV_AllocBufferImageCopy(num, allocator) \
DARRAY_ALLOCFIXED (qfv_bufferimagecopy_t, num, allocator)
struct qfv_queue_s;
struct qfv_device_s;
VkCommandPool QFV_CreateCommandPool (struct qfv_device_s *device,
uint32_t queueFamily,
int transient, int reset);
/** Allocate bufferset->size command buffers
*/
int QFV_AllocateCommandBuffers (struct qfv_device_s *device,
VkCommandPool pool, int secondary,
qfv_cmdbufferset_t *bufferset);
VkSemaphore QFV_CreateSemaphore (struct qfv_device_s *device);
VkFence QFV_CreateFence (struct qfv_device_s *device, int signaled);
int QFV_QueueSubmit (struct qfv_queue_s *queue,
qfv_semaphoreset_t *waitSemaphores,
VkPipelineStageFlags *stages,
qfv_cmdbufferset_t *buffers,
qfv_semaphoreset_t *signalSemaphores, VkFence fence);
int QFV_QueueWaitIdle (struct qfv_queue_s *queue);
#endif//__QF_Vulkan_command_h

View File

@ -0,0 +1,8 @@
#ifndef __QF_Vulkan_cvars_h
#define __QF_Vulkan_cvars_h
extern struct cvar_s *vulkan_use_validation;
extern struct cvar_s *vulkan_presentation_mode;
extern struct cvar_s *vulkan_frame_count;
#endif//__QF_Vulkan_cvars_h

115
include/QF/Vulkan/debug.h Normal file
View File

@ -0,0 +1,115 @@
#ifndef __QF_Vulkan_debug_h
#define __QF_Vulkan_debug_h
#define QFV_duCmdBeginLabel(device, cmd, name...)\
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdBeginDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkCmdBeginDebugUtilsLabelEXT (cmd, &label); \
} \
} while (0)
#define QFV_duCmdEndLabel(device, cmd) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdEndDebugUtilsLabelEXT) { \
dfunc->vkCmdEndDebugUtilsLabelEXT (cmd); \
} \
} while (0)
#define QFV_duCmdInsertLabel(device, cmd, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdInsertDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkCmdInsertDebugUtilsLabelEXT (cmd, &label); \
} \
} while (0)
#define QFV_duCreateMessenger(inst, severity, type, callback, data, messenger)\
do { \
if (inst->funcs->vkCreateDebugUtilsMessengerEXT) { \
VkDebugUtilsMessengerCreateInfoEXT createInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, 0, 0,\
severity, type, callback, data \
}; \
inst->funcs->vkCreateDebugUtilsMessengerEXT (inst, &createInfo, 0,\
messenger); \
} \
} while (0)
#define QFV_duDestroyMessenger(inst, messenger) \
do { \
if (inst->funcs->vkDestroyDebugUtilsMessengerEXT) { \
inst->funcs->vkDestroyDebugUtilsMessengerEXT (inst, messenger, 0);\
} \
} while (0)
#define QFV_duQueueBeginLabel(device, queue, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueBeginDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkQueueBeginDebugUtilsLabelEXT (queue, &label); \
} \
} while (0)
#define QFV_duQueueEndLabel(device, queue) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueEndDebugUtilsLabelEXT) { \
dfunc->vkQueueEndDebugUtilsLabelEXT (queue); \
} \
} while (0)
#define QFV_duQueueInsertLabel(device, queue, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueInsertDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkQueueInsertDebugUtilsLabelEXT (queue, &label); \
} \
} while (0)
#define QFV_duSetObjectName(device, type, handle, name) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkSetDebugUtilsObjectNameEXT) { \
VkDebugUtilsObjectNameInfoEXT nameInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, 0, \
type, (uint64_t) handle, name \
}; \
dfunc->vkSetDebugUtilsObjectNameEXT (device->dev, &nameInfo); \
} \
} while (0)
#define QFV_duSetObjectTag(device, type, handle, name, size, tag) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkSetDebugUtilsObjectTagEXT) { \
VkDebugUtilsObjectTagInfoEXT tagInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT, 0, \
type, handle, name, size, tag \
}; \
dfunc->vkSetDebugUtilsObjectTagEXT (device->dev, &tagInfo); \
} \
} while (0)
#define QFV_duSubmitMessage(inst, severity, types, data) \
do { \
if (inst->funcs->vkSubmitDebugUtilsMessageEXT) { \
inst->funcs->vkSubmitDebugUtilsMessageEXT (inst, severity, types, \
data); \
} \
} while (0)
#endif//__QF_Vulkan_debug_h

View File

@ -0,0 +1,62 @@
#ifndef __QF_Vulkan_descriptor_h
#define __QF_Vulkan_descriptor_h
#include "QF/darray.h"
typedef struct qfv_bindingset_s
DARRAY_TYPE (VkDescriptorSetLayoutBinding) qfv_bindingset_t;
typedef struct qfv_descriptorsetlayoutset_s
DARRAY_TYPE (VkDescriptorSetLayout) qfv_descriptorsetlayoutset_t;
#define QFV_AllocDescriptorSetLayoutSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_descriptorsetlayoutset_t, num, allocator)
typedef struct qfv_descriptorsets_s
DARRAY_TYPE (VkDescriptorSet) qfv_descriptorsets_t;
#define QFV_AllocDescriptorSets(num, allocator) \
DARRAY_ALLOCFIXED (qfv_descriptorsets_t, num, allocator)
typedef struct qfv_writedescriptorsets_s
DARRAY_TYPE (VkWriteDescriptorSet) qfv_writedescriptorsets_t;
#define QFV_AllocWriteDescriptorSets(num, allocator) \
DARRAY_ALLOCFIXED (qfv_writedescriptorsets_t, num, allocator)
typedef struct qfv_copydescriptorsets_s
DARRAY_TYPE (VkCopyDescriptorSet) qfv_copydescriptorsets_t;
#define QFV_AllocCopyDescriptorSets(num, allocator) \
DARRAY_ALLOCFIXED (qfv_descriptorsetlayoutset_t, num, allocator)
struct qfv_device_s;
VkSampler QFV_CreateSampler (struct qfv_device_s *device,
VkFilter magFilter, VkFilter minFilter,
VkSamplerMipmapMode mipmapMode,
VkSamplerAddressMode addressModeU,
VkSamplerAddressMode addressModeV,
VkSamplerAddressMode addressModeW,
float mipLodBias,
VkBool32 anisotryEnable, float maxAnisotropy,
VkBool32 compareEnable, VkCompareOp compareOp,
float minLod, float maxLod,
VkBorderColor borderColor,
VkBool32 unnormalizedCoordinates);
VkDescriptorSetLayout
QFV_CreateDescriptorSetLayout (struct qfv_device_s *device,
qfv_bindingset_t *bindings);
VkDescriptorPool
QFV_CreateDescriptorPool (struct qfv_device_s *device,
VkDescriptorPoolCreateFlags flags, uint32_t maxSets,
qfv_bindingset_t *bindings);
qfv_descriptorsets_t *
QFV_AllocateDescriptorSet (struct qfv_device_s *device,
VkDescriptorPool pool,
qfv_descriptorsetlayoutset_t *layouts);
#endif//__QF_Vulkan_descriptor_h

View File

@ -0,0 +1,39 @@
#ifndef __QF_Vulkan_device_h
#define __QF_Vulkan_device_h
typedef struct qfv_devfuncs_s {
#define DEVICE_LEVEL_VULKAN_FUNCTION(name) PFN_##name name;
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name,ext) PFN_##name name;
#include "QF/Vulkan/funclist.h"
} qfv_devfuncs_t;
typedef struct qfv_queue_s {
struct qfv_device_s *device;
int32_t queueFamily;
VkQueue queue;
} qfv_queue_t;
struct qfv_instance_s;
typedef struct qfv_device_s {
VkDevice dev;
struct qfv_physdev_s *physDev;
qfv_devfuncs_t *funcs;
qfv_queue_t queue;
struct strset_s *enabled_extensions;
int (*extension_enabled) (struct qfv_device_s *inst,
const char *ext);
} qfv_device_t;
struct vulkan_ctx_s;
qfv_device_t *QFV_CreateDevice (struct vulkan_ctx_s *ctx,
const char **extensions);
void QFV_DestroyDevice (qfv_device_t *device);
int QFV_DeviceWaitIdle (qfv_device_t *device);
VkFormat QFV_FindSupportedFormat (qfv_device_t *device, VkImageTiling tiling,
VkFormatFeatureFlags features,
int numCandidates,
const VkFormat *candidates);
#endif//__QF_Vulkan_device_h

237
include/QF/Vulkan/draw.h Normal file
View File

@ -0,0 +1,237 @@
/*
draw.h
Video buffer handling definitions and prototypes
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_draw_h
#define __QF_draw_h
/** \defgroup video Video Sub-sytem */
/** \defgroup video_renderer Renderer Sub-system
\ingroup video
*/
/** \defgroup video_renderer_draw Generic draw functions
\ingroup video_renderer
*/
///@{
#include "QF/wad.h"
extern byte *draw_chars;
/** Initialize the draw stuff.
*/
void Draw_Init (void);
/** Draws one 8*8 graphics character with 0 being transparent.
It can be clipped to the top of the screen to allow the console to be
smoothly scrolled off.
\param x horizontal location of the top left corner of the character.
\param y vertical location of the top left corner of the character.
\param ch 8 bit character to draw.
\note The character drawn is from the quake character set, which is
(by default) standard ascii for 0x20-0x7e (white). 0xa0-0xfe is
also standard ascii (brown). 0x01-0x1f and 0x80-0x9f are
various drawing characters, and 0x7f is a backwards arrow.
*/
void Draw_Character (int x, int y, unsigned ch);
/** Draws a character string to the screen.
No line wrapping is performed.
\param x horizontal location of the top left corner of the character.
\param y vertical location of the top left corner of the character.
\param str 8 bit character string to draw.
\note See Draw_Character() for character set description.
String is normal nul terminated C string.
*/
void Draw_String (int x, int y, const char *str);
/** Draws a character sub-string to the screen.
No line wrapping is performed.
\param x horizontal location of the top left corner of the character.
\param y vertical location of the top left corner of the character.
\param str 8 bit character string to draw.
\param count Maximum characters of the string to draw.
\note See Draw_Character() for character set description.
Draws up to \p count characters, or stops at the first nul
character.
*/
void Draw_nString (int x, int y, const char *str, int count);
/** Draws a character string to the screen.
No line wrapping is performed.
\param x horizontal location of the top left corner of the character.
\param y vertical location of the top left corner of the character.
\param str 8 bit character string to draw.
\note See Draw_Character() for character set description.
String is normal nul terminated C string.
Characters of the string are forced to have their high bit set
(ie, they will be in the range 0x80-0xff).
*/
void Draw_AltString (int x, int y, const char *str);
/** Draw the console background with various optional effects.
\param lines Vertical size in pixels of the console.
\param alpha Console transparency level (255 = opaque).
\note \p alpha is effective only in the OpenGL renderer. Effectively
255 (opaque) for the software renderer.
\c gl_conspin causes the background to spin.
\c gl_constretch causes the background to stretch rather than slide.
*/
void Draw_ConsoleBackground (int lines, byte alpha);
/** Draw a crosshair at the center of the screen.
\c crosshair specifies which crosshair (1 = '+', 2 = large 'x' shape,
3 = fancy '+' shape)
\c cl_crossx and \c cl_crossy offset the crosshair from the center of the
screen.
*/
void Draw_Crosshair (void);
/** Draw the specified crosshair on the screen.
\param ch crosshair to draw
\param x horizontal position of the center of the crosshair.
\param y vertical position of the center of the crosshair.
See Draw_Crosshair() for description of crosshair values.
*/
void Draw_CrosshairAt (int ch, int x, int y);
/** Clear a rectangle with a tiled background.
\param x horizontal position of the upper left corner of the rectangle
\param y horizontal position of the upper left corner of the rectangle
\param w width of the rectangle
\param h height of the rectangle
The background used is the "backtile" WAD lump.
*/
void Draw_TileClear (int x, int y, int w, int h);
/** Clear a rectangle with a solid color.
\param x horizontal position of the upper left corner of the rectangle
\param y horizontal position of the upper left corner of the rectangle
\param w width of the rectangle
\param h height of the rectangle
\param c 8 bit color index.
The color comes from the quake palette.
*/
void Draw_Fill (int x, int y, int w, int h, int c);
/** Draw a text box on the screen
\param x horizontal location of the upper left corner of the box
\param y vertical location of the upper left corner of the box
\param width horizontal size in character cells of the region
\param lines vertical size in character cells of the region
\param alpha transparency of the box
*/
void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
/** Darken the screen.
*/
void Draw_FadeScreen (void);
/** Shift the screen colors.
*/
void Draw_BlendScreen (quat_t color);
///@}
/** \defgroup video_renderer_draw_qpic QPic functions
\ingroup video_renderer_draw
*/
///@{
/** Load a qpic from the filesystem.
\param path path of the file within the quake filesystem
\param alpha transparency level of the pic.
\return pointer qpic data.
\note Up to MAX_CACHED_PICS qpics can be loaded at a time this way
*/
qpic_t *Draw_CachePic (const char *path, qboolean alpha);
/** Remove a qpic from the qpic cache.
This affects only those qpics that were loaded via Draw_CachePic.
\param path path of the file within the quake filesystem
*/
void Draw_UncachePic (const char *path);
/** Create a qpic from raw data.
\param width The width of the pic.
\param height The height of the pic.
\param data The raw data bytes. The system palette will be used for
colors.
\return pointer qpic data.
*/
qpic_t *Draw_MakePic (int width, int height, const byte *data);
/** Destroy a qpic created by Draw_MakePic.
\param pic The qpic to destory.
*/
void Draw_DestroyPic (qpic_t *pic);
/** Load a qpic from gfx.wad.
\param name name of the was lump to load
\return pointer qpic data.
*/
qpic_t *Draw_PicFromWad (const char *name);
/** Draw a qpic to the screen
\param x horizontal location of the upper left corner of the qpic
\param y vertical location of the upper left corner of the qpic
\param pic qpic to draw
*/
void Draw_Pic (int x, int y, qpic_t *pic);
/** Draw a qpic to the screen
\param x horizontal location of the upper left corner of the qpic
\param y vertical location of the upper left corner of the qpic
\param pic qpic to draw
*/
void Draw_Picf (float x, float y, qpic_t *pic);
/** Draw a sub-region of a qpic to the screan
\param x horizontal screen location of the upper left corner of the
sub-region
\param y vertical screen location of the upper left corner of the
sub-region
\param pic qpic to draw
\param srcx horizontal qpic location of the upper left corner of the
sub-region
\param srcy vertical qpic location of the upper left corner of the
sub-region
\param width horizontal size of the sub-region to be drawn
\param height vertical size of the sub-region to be drawn
*/
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
///@}
#endif//__QF_draw_h

View File

@ -0,0 +1,219 @@
#ifndef EXPORTED_VULKAN_FUNCTION
#define EXPORTED_VULKAN_FUNCTION(function)
#endif
EXPORTED_VULKAN_FUNCTION (vkGetInstanceProcAddr)
#undef EXPORTED_VULKAN_FUNCTION
#ifndef GLOBAL_LEVEL_VULKAN_FUNCTION
#define GLOBAL_LEVEL_VULKAN_FUNCTION(function)
#endif
GLOBAL_LEVEL_VULKAN_FUNCTION (vkEnumerateInstanceVersion)
GLOBAL_LEVEL_VULKAN_FUNCTION (vkEnumerateInstanceExtensionProperties)
GLOBAL_LEVEL_VULKAN_FUNCTION (vkEnumerateInstanceLayerProperties)
GLOBAL_LEVEL_VULKAN_FUNCTION (vkCreateInstance)
#undef GLOBAL_LEVEL_VULKAN_FUNCTION
#ifndef INSTANCE_LEVEL_VULKAN_FUNCTION
#define INSTANCE_LEVEL_VULKAN_FUNCTION(function)
#endif
INSTANCE_LEVEL_VULKAN_FUNCTION (vkEnumeratePhysicalDevices)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceProperties)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceFeatures)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceQueueFamilyProperties)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkCreateDevice)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetDeviceProcAddr)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkDestroyInstance)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkEnumerateDeviceLayerProperties)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkEnumerateDeviceExtensionProperties)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceMemoryProperties)
INSTANCE_LEVEL_VULKAN_FUNCTION (vkGetPhysicalDeviceFormatProperties)
#undef INSTANCE_LEVEL_VULKAN_FUNCTION
#ifndef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(function, extension)
#endif
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateDebugUtilsMessengerEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkDestroyDebugUtilsMessengerEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSubmitDebugUtilsMessageEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceSurfaceSupportKHR, VK_KHR_SURFACE_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceSurfacePresentModesKHR, VK_KHR_SURFACE_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceSurfaceCapabilitiesKHR, VK_KHR_SURFACE_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceSurfaceFormatsKHR, VK_KHR_SURFACE_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkDestroySurfaceKHR, VK_KHR_SURFACE_EXTENSION_NAME)
#undef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
#ifndef PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
#define PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION(function, extension)
#endif
#if defined(VK_USE_PLATFORM_XLIB_KHR)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceXlibPresentationSupportKHR,
VK_KHR_XLIB_SURFACE_EXTENSION_NAME)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateXlibSurfaceKHR,
VK_KHR_XLIB_SURFACE_EXTENSION_NAME)
#elif defined(VK_USE_PLATFORM_WIN32_KHR)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceWin32PresentationSupportKHR,
VK_KHR_WIN32_SURFACE_EXTENSION_NAME)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateWin32SurfaceKHR,
VK_KHR_WIN32_SURFACE_EXTENSION_NAME)
#elif defined(VK_USE_PLATFORM_XCB_KHR)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceXcbPresentationSupportKHR,
VK_KHR_XCB_SURFACE_EXTENSION_NAME)
PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateXcbSurfaceKHR,
VK_KHR_XCB_SURFACE_EXTENSION_NAME)
#endif
#undef PRESENTATION_VULKAN_FUNCTION_FROM_EXTENSION
#ifndef DEVICE_LEVEL_VULKAN_FUNCTION
#define DEVICE_LEVEL_VULKAN_FUNCTION(function)
#endif
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyDevice)
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetDeviceQueue)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateCommandPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkResetCommandPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateCommandBuffers)
DEVICE_LEVEL_VULKAN_FUNCTION (vkBeginCommandBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkEndCommandBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkResetCommandBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateSemaphore)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateFence)
DEVICE_LEVEL_VULKAN_FUNCTION (vkWaitForFences)
DEVICE_LEVEL_VULKAN_FUNCTION (vkResetFences)
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetFenceStatus)
DEVICE_LEVEL_VULKAN_FUNCTION (vkQueueSubmit)
DEVICE_LEVEL_VULKAN_FUNCTION (vkQueueWaitIdle)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDeviceWaitIdle)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyFence)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroySemaphore)
DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeCommandBuffers)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyCommandPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetBufferMemoryRequirements)
DEVICE_LEVEL_VULKAN_FUNCTION (vkBindBufferMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateBufferView)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyBufferView)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateImage)
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetImageMemoryRequirements)
DEVICE_LEVEL_VULKAN_FUNCTION (vkBindImageMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateImageView)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyImageView)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyImage)
DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkMapMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkUnmapMemory)
DEVICE_LEVEL_VULKAN_FUNCTION (vkFlushMappedMemoryRanges)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateSampler)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateDescriptorSetLayout)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateDescriptorPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkAllocateDescriptorSets)
DEVICE_LEVEL_VULKAN_FUNCTION (vkUpdateDescriptorSets)
DEVICE_LEVEL_VULKAN_FUNCTION (vkFreeDescriptorSets)
DEVICE_LEVEL_VULKAN_FUNCTION (vkResetDescriptorPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyDescriptorPool)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyDescriptorSetLayout)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroySampler)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateRenderPass)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateFramebuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyRenderPass)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyFramebuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateShaderModule)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyShaderModule)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreatePipelineCache)
DEVICE_LEVEL_VULKAN_FUNCTION (vkGetPipelineCacheData)
DEVICE_LEVEL_VULKAN_FUNCTION (vkMergePipelineCaches)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyPipelineCache)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreatePipelineLayout)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyPipelineLayout)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateGraphicsPipelines)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCreateComputePipelines)
DEVICE_LEVEL_VULKAN_FUNCTION (vkDestroyPipeline)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdPipelineBarrier)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdCopyBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdCopyBufferToImage)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdCopyImageToBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBlitImage)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBeginRenderPass)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdNextSubpass)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdEndRenderPass)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBindPipeline)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdClearColorImage)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdExecuteCommands)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdPushConstants)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdPushDescriptorSetKHR)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdSetViewport)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdSetScissor)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBindVertexBuffers)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBindIndexBuffer)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdBindDescriptorSets)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdDraw)
DEVICE_LEVEL_VULKAN_FUNCTION (vkCmdDrawIndexed)
#undef DEVICE_LEVEL_VULKAN_FUNCTION
#ifndef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(function, extension)
#endif
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateSwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkDestroySwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetSwapchainImagesKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkAcquireNextImageKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueuePresentKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdBeginDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdEndDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdInsertDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueBeginDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueEndDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueInsertDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSetDebugUtilsObjectNameEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSetDebugUtilsObjectTagEXT, 0)
#undef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION

96
include/QF/Vulkan/image.h Normal file
View File

@ -0,0 +1,96 @@
#ifndef __QF_Vulkan_image_h
#define __QF_Vulkan_image_h
#include "QF/darray.h"
typedef struct qfv_imageset_s
DARRAY_TYPE (VkImage) qfv_imageset_t;
#define QFV_AllocImages(num, allocator) \
DARRAY_ALLOCFIXED (qfv_imageset_t, num, allocator)
typedef struct qfv_imageviewset_s
DARRAY_TYPE (VkImageView) qfv_imageviewset_t;
#define QFV_AllocImageViews(num, allocator) \
DARRAY_ALLOCFIXED (qfv_imageviewset_t, num, allocator)
typedef struct qfv_imageresource_s {
struct qfv_device_s *device;
VkImage image;
VkDeviceMemory object;
VkImageView view;
} qfv_imageresource_t;
typedef struct qfv_imagetransition_s {
VkImage image;
VkAccessFlags srcAccess;
VkAccessFlags dstAccess;
VkImageLayout oldLayout;
VkImageLayout newLayout;
uint32_t srcQueueFamily;
uint32_t dstQueueFamily;
VkImageAspectFlags aspect;
} qfv_imagetransition_t;
typedef struct qfv_imagetransitionset_s
DARRAY_TYPE (qfv_imagetransition_t) qfv_imagetransitionset_t;
typedef struct qfv_imagebarrierset_s
DARRAY_TYPE (VkImageMemoryBarrier) qfv_imagebarrierset_t;
#define QFV_AllocImageBarrierSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_imagebarrierset_t, num, allocator)
struct qfv_device_s;
VkImage QFV_CreateImage (struct qfv_device_s *device, int cubemap,
VkImageType type,
VkFormat format,
VkExtent3D size,
uint32_t num_mipmaps,
uint32_t num_layers,
VkSampleCountFlags samples,
VkImageUsageFlags usage_scenarios);
VkDeviceMemory QFV_AllocImageMemory (struct qfv_device_s *device,
VkImage image,
VkMemoryPropertyFlags properties,
VkDeviceSize size, VkDeviceSize offset);
int QFV_BindImageMemory (struct qfv_device_s *device, VkImage image,
VkDeviceMemory object, VkDeviceSize offset);
qfv_imagebarrierset_t *
QFV_CreateImageTransitionSet (qfv_imagetransition_t *transitions,
int numTransitions);
VkImageView QFV_CreateImageView (struct qfv_device_s *device,
VkImage image, VkImageViewType type,
VkFormat format, VkImageAspectFlags aspect);
/** Generate all mipmaps for a given texture down to a 1x1 pixel.
*
* Uses the GPU blit command from one mip level to the next, thus the base mip
* level data must have already been transfered to the image and the image is
* expected to be in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL. This includes any
* array levels.
*
* \param device The device owning the command buffer.
* \param cmd The command buffer to which the barrier and blit commands
* will be written.
* \param image The image to be processed. All array layers of the base mip
* level must be initialized and in "transfer dst optimal"
* layout. All remaining mip levels must be in "undefined"
* oayout.
* \param mips The total number of mip levels of the processed image.
* \param width The pixel width of the base image.
* \param height The pixel height of the base image.
* \param layers The number of array layers in the mbase image.
*
* \note The processed image will be in "shader read only optimal" layout on
* completion.
*/
void QFV_GenerateMipMaps (struct qfv_device_s *device, VkCommandBuffer cmd,
VkImage image, unsigned mips,
unsigned width, unsigned height, unsigned layers);
int QFV_MipLevels (int width, int height) __attribute__((const));
#endif//__QF_Vulkan_image_h

View File

@ -0,0 +1,67 @@
/*
Copyright (C) 2019 Bill Currie <bill@taniwha.org>
Author: Bill Currie
Date: 2019/6/29
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_instance_h
#define __QF_Vulkan_instance_h
#include <vulkan/vulkan.h>
#include "QF/qtypes.h"
typedef struct qfv_instfuncs_s {
#define INSTANCE_LEVEL_VULKAN_FUNCTION(name) PFN_##name name;
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name,ext) PFN_##name name;
#include "QF/Vulkan/funclist.h"
} qfv_instfuncs_t;
typedef struct qfv_physdev_s {
struct qfv_instance_s *instance;
VkPhysicalDevice dev;
VkPhysicalDeviceProperties properties;
VkPhysicalDeviceMemoryProperties memory_properties;
} qfv_physdev_t;
typedef struct qfv_instance_s {
VkInstance instance;
qfv_instfuncs_t *funcs;
struct strset_s *enabled_extensions;
int (*extension_enabled) (struct qfv_instance_s *inst,
const char *ext);
VkDebugUtilsMessengerEXT debug_handle;
uint32_t numDevices;
qfv_physdev_t *devices;
} qfv_instance_t;
struct vulkan_ctx_s;
qfv_instance_t *QFV_CreateInstance (struct vulkan_ctx_s *ctx,
const char *appName,
uint32_t appVersion,
const char **layers,
const char **extensions);
void QFV_DestroyInstance (qfv_instance_t *instance);
VkSampleCountFlagBits QFV_GetMaxSampleCount (qfv_physdev_t *physdev);
#endif // __QF_Vulkan_instance_h

View File

@ -0,0 +1,22 @@
#ifndef __QF_Vulkan_memory_h
#define __QF_Vulkan_memory_h
#include "QF/darray.h"
typedef struct qfv_mappedmemrange_s {
VkDeviceMemory object;
VkDeviceSize offset;
VkDeviceSize size;
} qfv_mappedmemrange_t;
typedef struct qfv_mappedmemrangeset_s
DARRAY_TYPE (qfv_mappedmemrange_t) qfv_mappedmemrangeset_t;
struct qfv_device_s;
void *QFV_MapMemory (struct qfv_device_s *device, VkDeviceMemory object,
VkDeviceSize offset, VkDeviceSize size);
void QFV_FlushMemory (struct qfv_device_s *device,
qfv_mappedmemrangeset_t *ranges);
#endif//__QF_Vulkan_memory_h

View File

@ -0,0 +1,156 @@
#ifndef __QF_Vulkan_pipeline_h
#define __QF_Vulkan_pipeline_h
#include "QF/darray.h"
typedef struct qfv_pipelineshaderstateset_s
DARRAY_TYPE (VkPipelineShaderStageCreateInfo) qfv_pipelineshaderstateset_s;
#define QFV_AllocPipelineShaderStageSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_pipelineshaderstateset_s, num, allocator)
typedef struct qfv_vertexinputbindingset_s
DARRAY_TYPE (VkVertexInputBindingDescription) qfv_vertexinputbindingset_t;
#define QFV_AllocVertexInputBindingSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_vertexinputbindingset_t, num, allocator)
typedef struct qfv_vertexinputattributeset_s
DARRAY_TYPE (VkVertexInputAttributeDescription)
qfv_vertexinputattributeset_t;
#define QFV_AllocVertexInputAttributeSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_vertexinputattributeset_t, num, allocator)
typedef struct qfv_vertexinputstate_s {
qfv_vertexinputbindingset_t *bindings;
qfv_vertexinputattributeset_t *attributes;
} qfv_vertexinputstate_t;
typedef struct qfv_pipelineinputassembly_s {
VkPrimitiveTopology topology;
VkBool32 primativeRestartEnable;
} qfv_pipelineinputassembly_t;
typedef struct qfv_pipelinetessellation_s {
uint32_t patchControlPoints;
} qfv_pipelinetessellation_t;
typedef struct qfv_viewportset_s DARRAY_TYPE (VkViewport) qfv_viewportset_t;
#define QFV_AllocViewportSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_viewportset_t, num, allocator)
typedef struct qfv_scissorsset_s DARRAY_TYPE (VkRect2D) qfv_scissorsset_t;
#define QFV_AllocScissorsSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_scissorsset_t, num, allocator)
typedef struct qfv_viewportinfo_s {
qfv_viewportset_t *viewportset;
qfv_scissorsset_t *scissorsset;
} qfv_viewportinfo_t;
typedef struct qfv_pipelinerasterization_s {
VkBool32 depthClampEnable;
VkBool32 rasterizerDiscardEnable;
VkPolygonMode polygonMode;
VkCullModeFlags cullMode;
VkFrontFace frontFace;
VkBool32 depthBiasEnable;
float depthBiasConstantFactor;
float depthBiasClamp;
float depthBiasSlopeFactor;
float lineWidth;
} qfv_pipelinerasterization_t;
typedef struct qfv_pipelinemultisample_s {
VkSampleCountFlagBits rasterizationSamples;
VkBool32 sampleShadingEnable;
float minSampleShading;
const VkSampleMask *sampleMask;
VkBool32 alphaToCoverageEnable;
VkBool32 alphaToOneEnable;
} qfv_pipelinemultisample_t;
typedef struct qfv_pipelinedepthandstencil_s {
VkBool32 depthTestEnable;
VkBool32 depthWriteEnable;
VkCompareOp depthCompareOp;
VkBool32 depthBoundsTestEnable;
VkBool32 stencilTestEnable;
VkStencilOpState front;
VkStencilOpState back;
float minDepthBounds;
float maxDepthBounds;
} qfv_pipelinedepthandstencil_t;
typedef struct qfv_blendattachmentset_s
DARRAY_TYPE (VkPipelineColorBlendAttachmentState) qfv_blendattachmentset_t;
#define QFV_AllocBlendAttachmentSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_blendattachmentset_t, num, allocator)
typedef struct qfv_dynamicstateset_s
DARRAY_TYPE (VkDynamicState) qfv_dynamicstateset_t;
#define QFV_AllocDynamicStateSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_dynamicstateset_t, num, allocator)
typedef struct qfv_pushconstantrangeset_s
DARRAY_TYPE (VkPushConstantRange) qfv_pushconstantrangeset_t;
#define QFV_AllocPushConstantRangeSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_pushconstantrangeset_t, num, allocator)
typedef struct qfv_pipelineset_s DARRAY_TYPE (VkPipeline) qfv_pipelineset_t;
#define QFV_AllocPipelineSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_pipelineset_t, num, allocator)
typedef struct qfv_graphicspipelinecreateinfoset_s
DARRAY_TYPE (VkGraphicsPipelineCreateInfo)
qfv_graphicspipelinecreateinfoset_t;
#define QFV_AllocGraphicsPipelineCreateInfoSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_graphicspipelinecreateinfoset_t, num, allocator)
typedef struct qfv_computepipelinecreateinfoset_s
DARRAY_TYPE (VkComputePipelineCreateInfo)
qfv_computepipelinecreateinfoset_t;
#define QFV_AllocComputePipelineCreateInfoSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_computepipelinecreateinfoset_t, num, allocator)
typedef struct qfv_pipelinecacheset_s
DARRAY_TYPE (VkPipelineCache) qfv_pipelinecacheset_t;
#define QFV_AllocPipelineCacheSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_pipelinecacheset_t, num, allocator)
struct dstring_s;
VkPipelineCache QFV_CreatePipelineCache (struct qfv_device_s *device,
struct dstring_s *cacheData);
struct dstring_s *QFV_GetPipelineCacheData (struct qfv_device_s *device,
VkPipelineCache cache);
void QFV_MergePipelineCaches (struct qfv_device_s *device,
VkPipelineCache targetCache,
qfv_pipelinecacheset_t *sourceCaches);
struct qfv_descriptorsetlayoutset_s;
VkPipelineLayout
QFV_CreatePipelineLayout (struct qfv_device_s *device,
struct qfv_descriptorsetlayoutset_s *layouts,
qfv_pushconstantrangeset_t *pushConstants);
qfv_pipelineset_t *
QFV_CreateGraphicsPipelines (struct qfv_device_s *device,
VkPipelineCache cache,
qfv_graphicspipelinecreateinfoset_t *gpciSet);
qfv_pipelineset_t *
QFV_CreateComputePipelines (struct qfv_device_s *device,
VkPipelineCache cache,
qfv_computepipelinecreateinfoset_t *cpciSet);
void
QFV_DestroyPipeline (struct qfv_device_s *device, VkPipeline pipeline);
#endif//__QF_Vulkan_pipeline_h

View File

@ -0,0 +1,116 @@
/*
qf_alias.h
Vulkan specific alias model stuff
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/1/7
Date: 2021/1/18
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_alias_h
#define __QF_Vulkan_qf_alias_h
#include "QF/darray.h"
#include "QF/model.h"
#include "QF/modelgen.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/command.h"
typedef struct aliasvrt_s {
float vertex[4];
float normal[4];
} aliasvrt_t;
typedef struct aliasuv_s {
float u, v;
} aliasuv_t;
typedef struct qfv_alias_mesh_s {
VkBuffer vertex_buffer;
VkBuffer uv_buffer;
VkBuffer index_buffer;
VkDeviceMemory memory;
} qfv_alias_mesh_t;
typedef struct qfv_alias_skin_s {
VkDeviceMemory memory;
VkImage image;
VkImageView view;
byte colora[4];
byte colorb[4];
} qfv_alias_skin_t;
#define ALIAS_BUFFER_INFOS 1
#define ALIAS_IMAGE_INFOS 1
typedef enum {
QFV_aliasDepth,
QFV_aliasGBuffer,
QFV_aliasTranslucent,
QFV_aliasNumPasses
} QFV_AliasSubpass;
typedef struct aliasframe_s {
qfv_cmdbufferset_t cmdSet;
VkDescriptorBufferInfo bufferInfo[ALIAS_BUFFER_INFOS];
VkDescriptorImageInfo imageInfo[ALIAS_IMAGE_INFOS];
VkWriteDescriptorSet descriptors[ALIAS_BUFFER_INFOS + ALIAS_IMAGE_INFOS];
} aliasframe_t;
typedef struct aliasframeset_s
DARRAY_TYPE (aliasframe_t) aliasframeset_t;
typedef struct aliasctx_s {
aliasframeset_t frames;
VkPipeline depth;
VkPipeline gbuf;
VkPipelineLayout layout;
VkSampler sampler;
} aliasctx_t;
struct vulkan_ctx_s;
struct entity_s;
struct mod_alias_ctx_s;
void *Vulkan_Mod_LoadSkin (struct mod_alias_ctx_s *alias_ctx, byte *skin,
int skinsize, int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc,
struct vulkan_ctx_s *ctx);
void Vulkan_Mod_FinalizeAliasModel (struct mod_alias_ctx_s *alias_ctx,
struct vulkan_ctx_s *ctx);
void Vulkan_Mod_LoadExternalSkins (struct mod_alias_ctx_s *alias_ctx,
struct vulkan_ctx_s *ctx);
void Vulkan_Mod_MakeAliasModelDisplayLists (struct mod_alias_ctx_s *alias_ctx,
void *_m, int _s, int extra,
struct vulkan_ctx_s *ctx);
void Vulkan_AliasBegin (struct vulkan_ctx_s *ctx);
void Vulkan_DrawAlias (struct entity_s *ent, struct vulkan_ctx_s *ctx);
void Vulkan_AliasEnd (struct vulkan_ctx_s *ctx);
void Vulkan_Alias_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Alias_Shutdown (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_alias_h

173
include/QF/Vulkan/qf_bsp.h Normal file
View File

@ -0,0 +1,173 @@
/*
qf_bsp.h
Vulkan specific brush model stuff
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/1/7
Date: 2021/1/18
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_bsp_h
#define __QF_Vulkan_qf_bsp_h
#include "QF/darray.h"
#include "QF/model.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/command.h"
typedef struct bspvert_s {
quat_t vertex;
quat_t tlst;
} bspvert_t;
typedef struct elements_s {
struct elements_s *_next;
struct elements_s *next;
uint32_t first_index;
uint32_t index_count;
} elements_t;
typedef struct elechain_s {
struct elechain_s *_next;
struct elechain_s *next;
int index;
elements_t *elements;
vec_t *transform;
float *color;
} elechain_t;
typedef enum {
qfv_bsp_texture,
qfv_bsp_glowmap,
qfv_bsp_lightmap,
qfv_bsp_skysheet,
qfv_bsp_skycube,
} qfv_bsp_tex;
// view matrix
#define BSP_BUFFER_INFOS 1
// Texture, GlowMap, LightMap, SkySheet, SkyCube
#define BSP_IMAGE_INFOS 5
typedef enum {
QFV_bspDepth,
QFV_bspGBuffer,
QFV_bspSky,
QFV_bspTurb,
QFV_bspNumPasses
} QFV_BspSubpass;
typedef struct bspframe_s {
uint32_t *index_data; // pointer into mega-buffer for this frame (c)
uint32_t index_offset; // offset of index_data within mega-buffer (c)
uint32_t index_count; // number if indices queued (d)
qfv_cmdbufferset_t cmdSet;
VkDescriptorBufferInfo bufferInfo[BSP_BUFFER_INFOS];
VkDescriptorImageInfo imageInfo[BSP_IMAGE_INFOS];
VkWriteDescriptorSet descriptors[BSP_BUFFER_INFOS + BSP_IMAGE_INFOS];
} bspframe_t;
typedef struct fragconst_s {
quat_t fog;
float time;
} fragconst_t;
typedef struct bspframeset_s
DARRAY_TYPE (bspframe_t) bspframeset_t;
typedef struct texchainset_s
DARRAY_TYPE (struct vulktex_s *) texchainset_t;
typedef struct bspctx_s {
instsurf_t *waterchain;
instsurf_t **waterchain_tail;
instsurf_t *sky_chain;
instsurf_t **sky_chain_tail;
texchainset_t texture_chains;
// for world and non-instance models
instsurf_t *static_instsurfs;
instsurf_t **static_instsurfs_tail;
instsurf_t *free_static_instsurfs;
// for instance models
elechain_t *elechains;
elechain_t **elechains_tail;
elechain_t *free_elechains;
elements_t *elementss;
elements_t **elementss_tail;
elements_t *free_elementss;
instsurf_t *instsurfs;
instsurf_t **instsurfs_tail;
instsurf_t *free_instsurfs;
struct qfv_tex_s *default_skysheet;
struct qfv_tex_s *skysheet_tex;
struct qfv_tex_s *default_skybox;
struct qfv_tex_s *skybox_tex;
quat_t sky_rotation[2];
quat_t sky_velocity;
quat_t sky_fix;
double sky_time;
quat_t default_color;
quat_t last_color;
struct scrap_s *light_scrap;
struct qfv_stagebuf_s *light_stage;
struct bsppoly_s *polys;
VkSampler sampler;
VkDeviceMemory texture_memory;
VkPipeline depth;
VkPipeline gbuf;
VkPipeline sky;
VkPipeline turb;
VkPipelineLayout layout;
size_t vertex_buffer_size;
size_t index_buffer_size;
VkBuffer vertex_buffer;
VkDeviceMemory vertex_memory;
VkBuffer index_buffer;
VkDeviceMemory index_memory;
bspframeset_t frames;
} bspctx_t;
struct vulkan_ctx_s;
void Vulkan_ClearElements (struct vulkan_ctx_s *ctx);
void Vulkan_DrawWorld (struct vulkan_ctx_s *ctx);
void Vulkan_DrawSky (struct vulkan_ctx_s *ctx);
void Vulkan_RegisterTextures (model_t **models, int num_models,
struct vulkan_ctx_s *ctx);
void Vulkan_BuildDisplayLists (model_t **models, int num_models,
struct vulkan_ctx_s *ctx);
void Vulkan_Bsp_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Bsp_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_DrawWaterSurfaces (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_bsp_h

View File

@ -0,0 +1,62 @@
/*
qf_compose.h
Vulkan compose pass
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/2/24
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_compose_h
#define __QF_Vulkan_qf_compose_h
#include "QF/darray.h"
#include "QF/model.h"
#include "QF/modelgen.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/command.h"
#define COMPOSE_IMAGE_INFOS 2
typedef struct composeframe_s {
VkCommandBuffer cmd;
VkDescriptorImageInfo imageInfo[COMPOSE_IMAGE_INFOS];
VkWriteDescriptorSet descriptors[COMPOSE_IMAGE_INFOS];
} composeframe_t;
typedef struct composeframeset_s
DARRAY_TYPE (composeframe_t) composeframeset_t;
typedef struct composectx_s {
composeframeset_t frames;
VkPipeline pipeline;
VkPipelineLayout layout;
} composectx_t;
struct vulkan_ctx_s;
void Vulkan_Compose_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Compose_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Compose_Draw (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_compose_h

View File

@ -0,0 +1,74 @@
/*
qf_draw.h
vulkan specific draw function
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_draw_h
#define __QF_Vulkan_qf_draw_h
struct vulkan_ctx_s;
void Vulkan_Draw_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Character (int x, int y, unsigned ch,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_String (int x, int y, const char *str,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_nString (int x, int y, const char *str, int count,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_AltString (int x, int y, const char *str,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_ConsoleBackground (int lines, byte alpha,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Crosshair (struct vulkan_ctx_s *ctx);
void Vulkan_Draw_CrosshairAt (int ch, int x, int y, struct vulkan_ctx_s *ctx);
void Vulkan_Draw_TileClear (int x, int y, int w, int h,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Fill (int x, int y, int w, int h, int c,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_TextBox (int x, int y, int width, int lines, byte alpha,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_FadeScreen (struct vulkan_ctx_s *ctx);
void Vulkan_Draw_BlendScreen (quat_t color, struct vulkan_ctx_s *ctx);
qpic_t *Vulkan_Draw_CachePic (const char *path, qboolean alpha,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_UncachePic (const char *path, struct vulkan_ctx_s *ctx);
qpic_t *Vulkan_Draw_MakePic (int width, int height, const byte *data,
struct vulkan_ctx_s *ctx);
void Vulkan_Draw_DestroyPic (qpic_t *pic, struct vulkan_ctx_s *ctx);
qpic_t *Vulkan_Draw_PicFromWad (const char *name, struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Pic (int x, int y, qpic_t *pic, struct vulkan_ctx_s *ctx);
void Vulkan_Draw_Picf (float x, float y, qpic_t *pic, struct vulkan_ctx_s *ctx);
void Vulkan_Draw_SubPic(int x, int y, qpic_t *pic,
int srcx, int srcy, int width, int height,
struct vulkan_ctx_s *ctx);
void Vulkan_Set2D (struct vulkan_ctx_s *ctx);
void Vulkan_Set2DScaled (struct vulkan_ctx_s *ctx);
void Vulkan_End2D (struct vulkan_ctx_s *ctx);
void Vulkan_DrawReset (struct vulkan_ctx_s *ctx);
void Vulkan_FlushText (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_draw_h

View File

@ -0,0 +1,98 @@
/*
qf_lighting.h
Vulkan lighting pass
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/2/23
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_lighting_h
#define __QF_Vulkan_qf_lighting_h
#include "QF/darray.h"
#include "QF/model.h"
#include "QF/modelgen.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/command.h"
typedef struct qfv_light_s {
vec3_t color;
int data;
vec3_t position;
float radius;
vec3_t direction;
float cone;
} qfv_light_t;
typedef struct qfv_lightset_s DARRAY_TYPE (qfv_light_t) qfv_lightset_t;
typedef struct qfv_lightleafset_s DARRAY_TYPE (int) qfv_lightleafset_t;
typedef struct qfv_lightvisset_s DARRAY_TYPE (byte) qfv_lightvisset_t;
#define NUM_LIGHTS 256
#define NUM_STYLES 64
typedef struct qfv_light_buffer_s {
float intensity[NUM_STYLES + 3];
int lightCount;
qfv_light_t lights[NUM_LIGHTS] __attribute__((aligned(16)));
} qfv_light_buffer_t;
#define LIGHTING_BUFFER_INFOS 1
#define LIGHTING_IMAGE_INFOS 5
typedef struct lightingframe_s {
VkCommandBuffer cmd;
VkBuffer light_buffer;
VkDescriptorBufferInfo bufferInfo[LIGHTING_BUFFER_INFOS];
VkDescriptorImageInfo imageInfo[LIGHTING_IMAGE_INFOS];
VkWriteDescriptorSet descriptors[LIGHTING_BUFFER_INFOS
+ LIGHTING_IMAGE_INFOS];
// A fat PVS of leafs visible from visible leafs so hidden lights can
// illuminate the leafs visible to the player
byte pvs[MAP_PVS_BYTES];
struct mleaf_s *leaf; // the last leaf used to generate the pvs
qfv_lightvisset_t lightvis;
} lightingframe_t;
typedef struct lightingframeset_s
DARRAY_TYPE (lightingframe_t) lightingframeset_t;
typedef struct lightingctx_s {
lightingframeset_t frames;
VkPipeline pipeline;
VkPipelineLayout layout;
VkDeviceMemory light_memory;
qfv_lightset_t lights;
qfv_lightleafset_t lightleafs;
} lightingctx_t;
struct vulkan_ctx_s;
void Vulkan_Lighting_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Lighting_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Lighting_Draw (struct vulkan_ctx_s *ctx);
void Vulkan_LoadLights (model_t *model, const char *entity_data,
struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_lighting_h

View File

@ -0,0 +1,49 @@
/*
qf_lightmap.h
Vulkan lightmap stuff from the renderer.
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_lightmap_h
#define __QF_Vulkan_qf_lightmap_h
#define MAX_LIGHTMAPS 1024
#define BLOCK_WIDTH 64
#define BLOCK_HEIGHT 64
#include "QF/Vulkan/qf_vid.h"
struct vulkan_ctx_s;
struct model_s;
struct mod_brush_s;
struct msurface_s;
void Vulkan_lightmap_init (struct vulkan_ctx_s *ctx);
void Vulkan_BuildLightmaps (struct model_s **models, int num_models, struct vulkan_ctx_s *ctx);
void Vulkan_CalcLightmaps (struct vulkan_ctx_s *ctx);
void Vulkan_BuildLightMap (struct mod_brush_s *brush, struct msurface_s *surf, struct vulkan_ctx_s *ctx);
VkImageView Vulkan_LightmapImageView (struct vulkan_ctx_s *ctx) __attribute__((pure));
void Vulkan_FlushLightmaps (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_lightmap_h

View File

@ -0,0 +1,37 @@
/*
qf_main.h
Vulkan main stuff from the renderer.
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_main_h
#define __QF_Vulkan_qf_main_h
struct vulkan_ctx_s;
void Vulkan_NewMap (model_t *worldmodel, struct model_s **models,
int num_models, struct vulkan_ctx_s *ctx);
void Vulkan_RenderView (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_main_h

View File

@ -0,0 +1,44 @@
/*
qf_model.h
Vulkan specific model stuff
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/1/7
Date: 2021/1/19
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_qf_model_h
#define __QF_Vulkan_qf_model_h
#include "QF/darray.h"
#include "QF/model.h"
#include "QF/Vulkan/qf_vid.h"
typedef struct modelctx_s {
struct vulkan_ctx_s *ctx;
VkDeviceMemory texture_memory;
} modelctx_t;
#endif//__QF_Vulkan_qf_model_h

View File

@ -0,0 +1,16 @@
#ifndef __QF_Vulkan_qf_particles_h
#define __QF_Vulkan_qf_particles_h
#include "QF/image.h"
struct cvar_s;
struct vulkan_ctx_s;;
void Vulkan_ClearParticles (struct vulkan_ctx_s *ctx);
void Vulkan_InitParticles (struct vulkan_ctx_s *ctx);
void Vulkan_r_easter_eggs_f (struct cvar_s *var, struct vulkan_ctx_s *ctx);
void Vulkan_r_particles_style_f (struct cvar_s *var, struct vulkan_ctx_s *ctx);
void Vulkan_Particles_Init (struct vulkan_ctx_s *ctx);
void Vulkan_DrawParticles (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_particles_h

View File

@ -0,0 +1,23 @@
#ifndef __QF_Vulkan_qf_texture_h
#define __QF_Vulkan_qf_texture_h
#include "QF/image.h"
#include "QF/Vulkan/qf_vid.h"
typedef struct qfv_tex_s {
VkDeviceMemory memory;
size_t offset;
VkImage image;
VkImageView view;
} qfv_tex_t;
void Vulkan_ExpandPalette (byte *dst, const byte *src, const byte *palette,
int alpha, int count);
qfv_tex_t *Vulkan_LoadTex (struct vulkan_ctx_s *ctx, tex_t *tex, int mip,
const char *name);
VkImageView Vulkan_TexImageView (qfv_tex_t *tex) __attribute__((pure));
void Vulkan_UnloadTex (struct vulkan_ctx_s *ctx, qfv_tex_t *tex);
void Vulkan_Texture_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Texture_Shutdown (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_texture_h

View File

@ -0,0 +1,86 @@
/*
Vulkan/qf_vid.h
vulkan vid stuff from the renderer.
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_Vulkan_vid_h
#define __QF_Vulkan_vid_h
#include "QF/Vulkan/cvars.h"
#ifndef VK_NO_PROTOTYPES
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
//FIXME location
typedef enum {
QFV_passDepth, // geometry
QFV_passTranslucent, // geometry
QFV_passGBuffer, // geometry
QFV_passLighting, // single quad
QFV_passCompose, // single quad
QFV_NumPasses
} QFV_Subpass;
enum {
QFV_attachDepth,
QFV_attachColor,
QFV_attachEmission,
QFV_attachNormal,
QFV_attachPosition,
QFV_attachOpaque,
QFV_attachTranslucent,
QFV_attachSwapchain,
};
struct vulkan_ctx_s;
void Vulkan_DestroyFrames (struct vulkan_ctx_s *ctx);
void Vulkan_CreateFrames (struct vulkan_ctx_s *ctx);
void Vulkan_CreateFramebuffers (struct vulkan_ctx_s *ctx);
void Vulkan_DestroyFramebuffers (struct vulkan_ctx_s *ctx);
void Vulkan_CreateRenderPass (struct vulkan_ctx_s *ctx);
void Vulkan_DestroyRenderPass (struct vulkan_ctx_s *ctx);
void Vulkan_CreateMatrices (struct vulkan_ctx_s *ctx);
void Vulkan_DestroyMatrices (struct vulkan_ctx_s *ctx);
void Vulkan_CalcProjectionMatrices (struct vulkan_ctx_s *ctx, float aspect);
void Vulkan_CalcViewMatrix (struct vulkan_ctx_s *ctx);
void Vulkan_CreateSwapchain (struct vulkan_ctx_s *ctx);
void Vulkan_CreateDevice (struct vulkan_ctx_s *ctx);
void Vulkan_Init_Common (struct vulkan_ctx_s *ctx);
void Vulkan_Shutdown_Common (struct vulkan_ctx_s *ctx);
void Vulkan_CreateStagingBuffers (struct vulkan_ctx_s *ctx);
VkPipeline Vulkan_CreatePipeline (struct vulkan_ctx_s *ctx, const char *name);
VkDescriptorPool Vulkan_CreateDescriptorPool (struct vulkan_ctx_s *ctx,
const char *name);
VkPipelineLayout Vulkan_CreatePipelineLayout (struct vulkan_ctx_s *ctx,
const char *name);
VkSampler Vulkan_CreateSampler (struct vulkan_ctx_s *ctx, const char *name);
VkDescriptorSetLayout Vulkan_CreateDescriptorSetLayout(struct vulkan_ctx_s*ctx,
const char *name);
#endif // __QF_Vulkan_vid_h

View File

@ -0,0 +1,50 @@
#ifndef __QF_Vulkan_renderpass_h
#define __QF_Vulkan_renderpass_h
#include "QF/darray.h"
typedef struct qfv_attachmentdescription_s
DARRAY_TYPE (VkAttachmentDescription) qfv_attachmentdescription_t;
#define QFV_AllocAttachmentDescription(num, allocator) \
DARRAY_ALLOCFIXED (qfv_attachmentdescription_t, num, allocator)
typedef struct qfv_attachmentreference_s
DARRAY_TYPE (VkAttachmentReference) qfv_attachmentreference_t;
#define QFV_AllocAttachmentReference(num, allocator) \
DARRAY_ALLOCFIXED (qfv_attachmentreference_t, num, allocator)
typedef struct qfv_subpassparametersset_s
DARRAY_TYPE (VkSubpassDescription) qfv_subpassparametersset_t;
#define QFV_AllocSubpassParametersSet(num, allocator) \
DARRAY_ALLOCFIXED (qfv_subpassparametersset_t, num, allocator)
typedef struct qfv_subpassdependency_s
DARRAY_TYPE (VkSubpassDependency) qfv_subpassdependency_t;
#define QFV_AllocSubpassDependencies(num, allocator) \
DARRAY_ALLOCFIXED (qfv_subpassdependency_t, num, allocator)
typedef struct qfv_framebufferset_s
DARRAY_TYPE (VkFramebuffer) qfv_framebufferset_t;
#define QFV_AllocFrameBuffers(num, allocator) \
DARRAY_ALLOCFIXED (qfv_framebufferset_t, num, allocator)
struct qfv_device_s;
struct qfv_imageviewset_s;
VkRenderPass
QFV_CreateRenderPass (struct qfv_device_s *device,
qfv_attachmentdescription_t *attachments,
qfv_subpassparametersset_t *subpasses,
qfv_subpassdependency_t *dependencies);
VkFramebuffer
QFV_CreateFramebuffer (struct qfv_device_s *device,
VkRenderPass renderPass,
struct qfv_imageviewset_s *attachments,
VkExtent2D, uint32_t layers);
#endif//__QF_Vulkan_renderpass_h

25
include/QF/Vulkan/scrap.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef __QF_Vulkan_scrap_h
#define __QF_Vulkan_scrap_h
#include "QF/image.h"
typedef struct scrap_s scrap_t;
struct qfv_stagebuf_s;
struct qfv_device_s;
scrap_t *QFV_CreateScrap (struct qfv_device_s *device, const char *name,
int size, QFFormat format,
struct qfv_stagebuf_s *stage);
size_t QFV_ScrapSize (scrap_t *scrap) __attribute__((pure));
void QFV_ScrapClear (scrap_t *scrap);
void QFV_DestroyScrap (scrap_t *scrap);
VkImageView QFV_ScrapImageView (scrap_t *scrap) __attribute__((pure));
subpic_t *QFV_ScrapSubpic (scrap_t *scrap, int width, int height);
void QFV_SubpicDelete (subpic_t *subpic);
void *QFV_SubpicBatch (subpic_t *subpic, struct qfv_stagebuf_s *stage);
void QFV_ScrapFlush (scrap_t *scrap);
#endif//__QF_Vulkan_scrap_h

View File

@ -0,0 +1,14 @@
#ifndef __QF_Vulkan_shader_h
#define __QF_Vulkan_shader_h
struct qfv_device_s;
struct vulkan_ctx_s;
struct plitem_s;
struct parsectx_s;
VkShaderModule QFV_CreateShaderModule (struct qfv_device_s *device,
const char *path);
void QFV_DestroyShaderModule (struct qfv_device_s *device,
VkShaderModule module);
#endif//__QF_Vulkan_shader_h

View File

@ -0,0 +1,37 @@
#ifndef __QF_Vulkan_staging_h
#define __QF_Vulkan_staging_h
#include "QF/ringbuffer.h"
typedef struct qfv_packet_s {
struct qfv_stagebuf_s *stage; ///< staging buffer that owns this packet
VkCommandBuffer cmd;
VkFence fence;
size_t offset;
size_t length;
} qfv_packet_t;
typedef struct qfv_stagebuf_s {
struct qfv_device_s *device;
VkBuffer buffer;
VkDeviceMemory memory;
RING_BUFFER(qfv_packet_t, 4) packets; ///< packets for controlling access
size_t atom_mask; ///< for flush size rounding
size_t size; ///< actual size of the buffer
size_t end; ///< effective end of the buffer due to early wrap
size_t space_start;///< beginning of available space
size_t space_end; ///< end of available space
void *data;
} qfv_stagebuf_t;
qfv_stagebuf_t *QFV_CreateStagingBuffer (struct qfv_device_s *device,
const char *name, size_t size,
VkCommandPool cmdPool);
void QFV_DestroyStagingBuffer (qfv_stagebuf_t *stage);
void QFV_FlushStagingBuffer (qfv_stagebuf_t *stage, size_t offset, size_t size);
qfv_packet_t *QFV_PacketAcquire (qfv_stagebuf_t *stage);
void *QFV_PacketExtend (qfv_packet_t *packet, size_t size);
void QFV_PacketSubmit (qfv_packet_t *packet);
#endif//__QF_Vulkan_staging_h

View File

@ -0,0 +1,24 @@
#ifndef __QF_Vulkan_swapchain_h
#define __QF_Vulkan_swapchain_h
typedef struct qfv_swapchain_s {
struct qfv_device_s *device;
VkSurfaceKHR surface;
VkSwapchainKHR swapchain;
VkFormat format;
VkExtent2D extent;
int32_t numImages;
struct qfv_imageset_s *images;
struct qfv_imageviewset_s *imageViews;
} qfv_swapchain_t;
struct vulkan_ctx_s;
qfv_swapchain_t *QFV_CreateSwapchain (struct vulkan_ctx_s *ctx,
VkSwapchainKHR old_swapchain);
void QFV_DestroySwapchain (qfv_swapchain_t *swapchain);
struct qfv_semaphore_s;
struct qfv_fence_s;
int QFV_AcquireNextImage (qfv_swapchain_t *swapchain, VkSemaphore semaphore,
VkFence fence, uint32_t *imageIndex);
#endif//__QF_Vulkan_swapchain_h

View File

@ -42,6 +42,8 @@
#define MAX_MAP_FACES 65535 // format limit (u16)
#define MAX_MAP_MARKSURFACES 65535 // format limit (u16)
#define MAP_PVS_BYTES (MAX_MAP_LEAFS / 8)
//=============================================================================
#define BSPVERSION 29

View File

@ -35,7 +35,6 @@ void CDAudio_Play(int track, qboolean looping);
void CDAudio_Stop(void);
void CDAudio_Pause(void);
void CDAudio_Resume(void);
void CDAudio_Shutdown(void);
void CDAudio_Update(void);
#endif//__QF_cdaudio_h

143
include/QF/cexpr.h Normal file
View File

@ -0,0 +1,143 @@
/*
cexpr.h
Config expression parser. Or concurrent.
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_expr_h
#define __QF_expr_h
#include <stdlib.h>
struct exprval_s;
struct exprctx_s;
typedef struct binop_s {
int op;
struct exprtype_s *other;
struct exprtype_s *result;
void (*func) (const struct exprval_s *val1,
const struct exprval_s *val2,
struct exprval_s *result,
struct exprctx_s *context);
} binop_t;
typedef struct unop_s {
int op;
struct exprtype_s *result;
void (*func) (const struct exprval_s *val, struct exprval_s *result,
struct exprctx_s *context);
} unop_t;
typedef struct exprtype_s {
const char *name;
size_t size;
binop_t *binops;
unop_t *unops;
void *data;
} exprtype_t;
typedef struct exprval_s {
exprtype_t *type;
void *value;
} exprval_t;
typedef struct exprlist_s {
struct exprlist_s *next;
exprval_t *value;
} exprlist_t;
typedef struct exprsym_s {
const char *name;
exprtype_t *type;
void *value;
struct exprsym_s *next;
} exprsym_t;
typedef struct exprfunc_s {
exprtype_t *result;
int num_params;
exprtype_t **param_types;
void (*func) (const exprval_t **params, exprval_t *result,
struct exprctx_s *context);
} exprfunc_t;
typedef struct exprtab_s {
exprsym_t *symbols;
struct hashtab_s *tab;
} exprtab_t;
typedef struct exprctx_s {
exprval_t *result;
exprtab_t *symtab; // directly accessible symbols
exprtab_t *external_variables; // accessible via $id
struct memsuper_s *memsuper;
const struct plitem_s *item;
struct plitem_s *messages;
struct hashlink_s **hashlinks;
int errors;
} exprctx_t;
typedef struct exprenum_s {
exprtype_t *type;
exprtab_t *symtab;
} exprenum_t;
int cexpr_parse_enum (exprenum_t *enm, const char *str,
const exprctx_t *context, void *data);
binop_t *cexpr_find_cast (exprtype_t *dst_type, exprtype_t *src_type) __attribute__((pure));
exprval_t *cexpr_value (exprtype_t *type, exprctx_t *ctx);
exprval_t *cexpr_value_reference (exprtype_t *type, void *data, exprctx_t *ctx);
int cexpr_eval_string (const char *str, exprctx_t *context);
void cexpr_error(exprctx_t *ctx, const char *fmt, ...) __attribute__((format(printf,2,3)));
void cexpr_struct_getfield (const exprval_t *a, const exprval_t *b,
exprval_t *c, exprctx_t *ctx);
void cexpr_struct_pointer_getfield (const exprval_t *a, const exprval_t *b,
exprval_t *c, exprctx_t *ctx);
exprval_t *cexpr_cvar (const char *name, exprctx_t *ctx);
exprval_t *cexpr_cvar_struct (exprctx_t *ctx);
void cexpr_cast_plitem (const exprval_t *val1, const exprval_t *src,
exprval_t *result, exprctx_t *ctx);
void cexpr_init_symtab (exprtab_t *symtab, exprctx_t *ctx);
char *cexpr_yyget_text (void *scanner);
extern exprtype_t cexpr_int;
extern exprtype_t cexpr_uint;
extern exprtype_t cexpr_size_t;
extern exprtype_t cexpr_float;
extern exprtype_t cexpr_double;
extern exprtype_t cexpr_vector;
extern exprtype_t cexpr_quaternion;
extern exprtype_t cexpr_exprval;
extern exprtype_t cexpr_field;
extern exprtype_t cexpr_function;
extern exprtype_t cexpr_plitem;
extern binop_t cexpr_struct_binops[];
extern binop_t cexpr_struct_pointer_binops[];
#endif//__QF_expr_h

View File

@ -37,6 +37,7 @@
#include "QF/cbuf.h"
typedef void (*xcommand_t) (void);
typedef void (*xdatacmd_t) (void *data);
typedef enum {
src_client, // came in over a net connection as a clc_stringcmd
@ -48,6 +49,8 @@ typedef struct cmd_function_s {
struct cmd_function_s *next;
const char *name;
xcommand_t function;
xdatacmd_t datafunc;
void *data;
const char *description;
} cmd_function_t;
@ -56,7 +59,10 @@ extern cmd_source_t cmd_source;
void Cmd_Init_Hash (void);
void Cmd_Init (void);
int Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description);
int Cmd_AddCommand (const char *cmd_name, xcommand_t function,
const char *description);
int Cmd_AddDataCommand (const char *cmd_name, xdatacmd_t function,
void *data, const char *description);
int Cmd_RemoveCommand (const char *cmd_name);
qboolean Cmd_Exists (const char *cmd_name);

118
include/QF/cmem.h Normal file
View File

@ -0,0 +1,118 @@
/*
cmem.h
Cache-line aligned memory allocator
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_cmem_h
#define __QF_cmem_h
#include "QF/qtypes.h"
#define MEM_LINE_SIZE 64
#define MAX_CACHE_LINES 9
typedef struct memline_s {
/* chain of free line blocks for fast allocation
* chain begins in memsuper_t
*/
struct memline_s *free_next;
struct memline_s **free_prev;
/* chain of free line blocks within a membock for merging
* chain begins in memblock_t
*/
struct memline_s *block_next;
struct memline_s **block_prev;
size_t size;
/* owning block
*/
struct memblock_s *block;
size_t pad[2];
} memline_t;
typedef struct memsline_s {
struct memsline_s *next;
size_t size:2;
size_t list:4;
size_t prev:58; // memsline_t **
} memsline_t;
typedef struct memblock_s {
struct memblock_s *next;
struct memblock_s **prev;
/* The pointer to pass to free()
*/
void *mem;
memline_t *free_lines;
/* Size of memory region before block "header".
*
* Since large blocks are allocated with page-size alignment, odds are
* high that the there will be many cache lines "wasted" in the space
* between the address returned from aligned_alloc (to cache-line
* alignment) and the block itself. Setting them up as a pool makes the
* lines available for smaller allocations, thus reducing waste.
*/
size_t pre_size;
/* Size of memory region after block "header".
*
* Will be 0 for blocks that were allocated exclusively for small
* allocations, otherwise indicates the size of the allocated block.
*/
size_t post_size;
/* True if the post-header block is free to be reused.
*/
int post_free;
int pad;
size_t pre_allocated;
} memblock_t;
typedef struct memsuper_s {
size_t page_size;
size_t page_mask;
memblock_t *memblocks;
/* Allocated cache lines from which smaller blocks can be allocated.
*
* The index is the base-2 log minus 2 of the size of the elements in the
* cache line from which an element was last freed. Only 4-32 bytes are of
* interest because nothing smaller than 4 bytes (int/float) will be
* allocated, and 64 bytes and up consume entire cache lines.
*/
memsline_t *last_freed[4];
/* Free chache lines grouped by size.
*
* The index is the base-2 log of the MINIMUM number of cache lines
* available in each block. ie, blocks with 4, 5, 6 and 7 lines will all
* be in the third list (index 2). For 4k page sizes, only 6 lists are
* needed (32-63 lines) because a page can hold only 62 lines (1 for the
* control block and one to avoid a cache-line being on a page boundary).
* Having 9 (MAX_CACHE_LINES) lists allows page sizes up to 16kB.
*/
memline_t *free_lines[MAX_CACHE_LINES];
} memsuper_t;
memsuper_t *new_memsuper (void);
void delete_memsuper (memsuper_t *super);
void *cmemalloc (memsuper_t *super, size_t size);
void cmemfree (memsuper_t *super, void *mem);
#endif//__QF_cmem_h

View File

@ -119,7 +119,6 @@ void Con_BufferAddText (con_buffer_t *buf, const char *text);
// init/shutdown functions
void Con_Init (const char *plugin_name);
void Con_Shutdown (void);
void Con_ExecLine (const char *line);
void Con_ProcessInput (void);

View File

@ -28,8 +28,10 @@
*/
#ifndef __darray_h
#define __darray_h
#ifndef __QF_darray_h
#define __QF_darray_h
#include "QF/sys.h"
/** \defgroup darray Dynamic Arrays
\ingroup utils
@ -67,6 +69,8 @@
ele_type *a; \
}
#define DARRAY_STATIC_INIT(g) { .grow = g }
/** Allocate a fixed-size array using the given allocator
The allocated array is initilized to be ungrowable, and with both size
@ -88,6 +92,30 @@
ar; \
})
/** Allocate a fixed-size array using the given allocator
The allocated array is initilized to be ungrowable, and with both size
and maxSize set to the given size.
\param array_type Expression acceptable by typeof for determining the
type of the array.
\param array_size The size of the array.
\param alloc Allocator taking (obj, size) where obj is allocator
specific data (eg, a memory pool).
\param obj Additional data for the allocator.
*/
#define DARRAY_ALLOCFIXED_OBJ(array_type, array_size, alloc, obj) \
({ \
__auto_type s = (array_size); \
typeof (array_type) *ar = alloc ((obj), \
sizeof(*ar) \
+ s * sizeof (*ar->a)); \
ar->size = ar->maxSize = s; \
ar->grow = 0; \
ar->a = (typeof (ar->a)) (ar + 1); \
ar; \
})
/** Initialized the array.
The array will be initialized to be empty but with grow set to the
@ -121,9 +149,9 @@
#define DARRAY_CLEAR(array) \
do { \
__auto_type ar = (array); \
free (ar->a); \
ar->size = 0; \
if (ar->grow) { \
free (ar->a); \
ar->maxSize = 0; \
ar->a = 0; \
} \
@ -227,7 +255,7 @@
} \
DARRAY_RESIZE (ar, ar->size + sp); \
memmove (&ar->a[po + sp], &ar->a[po], \
(ar->size - po) * sizeof (*ar->a)); \
(ar->size - po - sp) * sizeof (*ar->a)); \
&ar->a[po]; \
})
@ -339,4 +367,4 @@
///@}
#endif//__darray_h
#endif//__QF_darray_h

124
include/QF/entity.h Normal file
View File

@ -0,0 +1,124 @@
/*
entity.h
Entity management
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/02/26
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_entity_h
#define __QF_entity_h
#include "QF/darray.h"
#include "QF/mathlib.h"
#include "QF/simd/vec4f.h"
#include "QF/simd/mat4f.h"
/** \defgroup entity Entity management
\ingroup utils
*/
///@{
typedef struct mat4fset_s DARRAY_TYPE (mat4f_t) mat4fset_t;
typedef struct vec4fset_s DARRAY_TYPE (vec4f_t) vec4fset_t;
typedef struct uint32set_s DARRAY_TYPE (uint32_t) uint32set_t;
typedef struct byteset_s DARRAY_TYPE (byte) byteset_t;
typedef struct stringset_s DARRAY_TYPE (char *) stringset_t;
typedef struct xformset_s DARRAY_TYPE (struct transform_s *) xformset_t;
typedef struct entityset_s DARRAY_TYPE (struct entity_s *) entityset_t;
#define null_transform (~0u)
typedef struct hierarchy_s {
xformset_t transform;
entityset_t entity;
uint32set_t childCount;
uint32set_t childIndex;
uint32set_t parentIndex;
stringset_t name;
uint32set_t tag;
byteset_t modified;
mat4fset_t localMatrix;
mat4fset_t localInverse;
mat4fset_t worldMatrix;
mat4fset_t worldInverse;
vec4fset_t localRotation;
vec4fset_t localScale;
vec4fset_t worldRotation;
vec4fset_t worldScale;
} hierarchy_t;
typedef struct transform_s {
hierarchy_t *hierarchy;
uint32_t index;
} transform_t;
transform_t *Transform_New (transform_t *parent);
void Transform_Delete (transform_t *transform);
transform_t *Transform_NewNamed (transform_t *parent, const char *name);
uint32_t Transform_ChildCount (const transform_t *transform) __attribute__((pure));
transform_t *Transform_GetChild (const transform_t *transform,
uint32_t childIndex) __attribute__((pure));
void Transform_SetParent (transform_t *transform, transform_t *parent);
transform_t *Transform_GetParent (const transform_t *transform) __attribute__((pure));
void Transform_SetName (transform_t *transform, const char *name);
const char *Transform_GetName (const transform_t *transform) __attribute__((pure));
void Transform_SetTag (transform_t *transform, uint32_t tag);
uint32_t Transform_GetTag (const transform_t *transform) __attribute__((pure));
void Transform_GetLocalMatrix (const transform_t *transform, mat4f_t mat);
void Transform_GetLocalInverse (const transform_t *transform, mat4f_t mat);
void Transform_GetWorldMatrix (const transform_t *transform, mat4f_t mat);
void Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat);
vec4f_t Transform_GetLocalPosition (const transform_t *transform) __attribute__((pure));
void Transform_SetLocalPosition (transform_t *transform, vec4f_t position);
vec4f_t Transform_GetLocalRotation (const transform_t *transform) __attribute__((pure));
void Transform_SetLocalRotation (transform_t *transform, vec4f_t rotation);
vec4f_t Transform_GetLocalScale (const transform_t *transform) __attribute__((pure));
void Transform_SetLocalScale (transform_t *transform, vec4f_t scale);
vec4f_t Transform_GetWorldPosition (const transform_t *transform) __attribute__((pure));
void Transform_SetWorldPosition (transform_t *transform, vec4f_t position);
vec4f_t Transform_GetWorldRotation (const transform_t *transform) __attribute__((pure));
void Transform_SetWorldRotation (transform_t *transform, vec4f_t rotation);
vec4f_t Transform_GetWorldScale (const transform_t *transform) __attribute__((pure));
void Transform_SetLocalTransform (transform_t *transform, vec4f_t scale,
vec4f_t rotation, vec4f_t position);
// NOTE: these use X: right, Y: forward, Z:up
// aslo, not guaranteed to be normalized or even orthogonal
vec4f_t Transform_Forward (const transform_t *transform) __attribute__((pure));
vec4f_t Transform_Right (const transform_t *transform) __attribute__((pure));
vec4f_t Transform_Up (const transform_t *transform) __attribute__((pure));
// no SetWorldScale because after rotations, non uniform scale becomes shear
hierarchy_t *Hierarchy_New (size_t grow, int createRoot);
hierarchy_t *Hierarchy_Copy (hierarchy_t *src);
void Hierarchy_Delete (hierarchy_t *hierarchy);
void Hierarchy_UpdateMatrices (hierarchy_t *hierarchy);
uint32_t Hierarchy_InsertHierarchy (hierarchy_t *dst, const hierarchy_t *src,
uint32_t dstParent, uint32_t srcRoot);
void Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index);
///@}
#endif//__QF_entity_h

View File

@ -46,7 +46,7 @@ typedef struct hashlink_s hashlink_t;
inserting or finding the element. First parameter is a pointer
to the element from which to extract the key, the second is
the user data pointer.
\param f a function to free the element. Only ever called from
\param f a function to free the element. Called from only
Hash_FlushTable and Hash_DelTable. The first parameter is the
element to be freed and the second is the user data pointer.
\param ud user data pointer. set to whatever you want, it will be passed

View File

@ -29,24 +29,28 @@
#ifndef __QF_image_h
#define __QF_image_h
#include "QF/quakeio.h"
#include "QF/qtypes.h"
typedef enum QFFormat {
tex_palette = 0,
tex_l = 0x1909, //GL_LUMINANCE
tex_a = 0x1906, //GL_ALPHA
tex_la = 2,
tex_rgb = 3,
tex_rgba = 4,
tex_frgba = 5,
} QFFormat;
// could not use texture_t as that is used for models.
typedef struct tex_s {
int width;
int height;
int format;
unsigned char *palette; // 0 = 32 bit, otherwise 8
unsigned char data[4]; // variable length
int width;
int height;
QFFormat format;
int loaded; // 0 if size info only, otherwise data loaded
byte *palette; // 0 = 32 bit, otherwise 8
byte *data;
} tex_t;
#define tex_palette 0
#define tex_l 0x1909 //GL_LUMINANCE
#define tex_a 0x1906 //GL_ALPHA
#define tex_la 2
#define tex_rgb 3
#define tex_rgba 4
tex_t *LoadImage (const char *imageFile);
tex_t *LoadImage (const char *imageFile, int load);
#endif//__QF_image_h

View File

@ -44,8 +44,6 @@ struct cvar_s;
void IN_Init (struct cbuf_s *cbuf);
void IN_Init_Cvars (void);
void IN_Shutdown (void);
void IN_ProcessEvents (void);
void IN_UpdateGrab (struct cvar_s *);

View File

@ -164,6 +164,7 @@ extern const vec_t *const quat_origin;
void QuatMult (const quat_t q1, const quat_t q2, quat_t out);
void QuatMultVec (const quat_t q, const vec3_t v, vec3_t out);
void QuatRotation (const vec3_t a, const vec3_t b, quat_t out);
void QuatInverse (const quat_t in, quat_t out);
void QuatExp (const quat_t a, quat_t b);
void QuatToMatrix (const quat_t q, vec_t *m, int homogenous, int vertical);

View File

@ -74,6 +74,18 @@ extern const vec_t *const vec3_origin;
(c)[1] = (a)[1] - (s) * (b)[1]; \
(c)[2] = (a)[2] - (s) * (b)[2]; \
} while (0)
#define VectorCompMultAdd(a,b,c,d) \
do { \
(d)[0] = (a)[0] + (b)[0] * (c)[0]; \
(d)[1] = (a)[1] + (b)[1] * (c)[1]; \
(d)[2] = (a)[2] + (b)[2] * (c)[2]; \
} while (0)
#define VectorCompMultSub(a,b,c,d) \
do { \
(d)[0] = (a)[0] - (b)[0] * (c)[0]; \
(d)[1] = (a)[1] - (b)[1] * (c)[1]; \
(d)[2] = (a)[2] - (b)[2] * (c)[2]; \
} while (0)
#define VectorLength(a) sqrt(DotProduct(a, a))
#define VectorScale(a,b,c) \
@ -164,6 +176,8 @@ extern const vec_t *const vec3_origin;
//For printf etc
#define VectorExpand(v) (v)[0], (v)[1], (v)[2]
//For scanf etc
#define VectorExpandAddr(v) &(v)[0], &(v)[1], &(v)[2]
/*
* VectorDistance, the distance between two points.

View File

@ -61,7 +61,6 @@ typedef struct efrag_s {
struct efrag_s *entnext;
} efrag_t;
// in memory representation ===================================================
// !!! if this is changed, it must be changed in asm_draw.h too !!!
@ -91,19 +90,13 @@ typedef struct instsurf_s {
typedef struct texture_s {
char *name;
unsigned int width, height;
int gl_texturenum;
int gl_fb_texturenum;
int sky_tex[2];
instsurf_t *tex_chain; // for gl_texsort drawing
instsurf_t **tex_chain_tail;
struct elechain_s *elechain;
struct elechain_s **elechain_tail;
unsigned width, height;
void *render; // renderer specific data
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
unsigned int offsets[MIPLEVELS]; // four mip maps stored
unsigned offsets[MIPLEVELS]; // four mip maps stored
} texture_t;
@ -159,7 +152,7 @@ typedef struct msurface_s {
int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped
glpoly_t *polys; // multiple if warped
instsurf_t *instsurf; ///< null if not part of world model/sub-model
instsurf_t *tinst; ///< for instance models
@ -186,8 +179,6 @@ typedef struct mnode_s {
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// node specific
plane_t *plane;
struct mnode_s *children[2];
@ -205,8 +196,6 @@ typedef struct mleaf_s {
float mins[3];
float maxs[3];
struct mnode_s *parent;
// leaf specific
byte *compressed_vis;
efrag_t *efrags;
@ -233,6 +222,61 @@ typedef struct hull_s {
int depth; ///< maximum depth of the tree
} hull_t;
typedef struct mod_brush_s {
int firstmodelsurface, nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
int numplanes;
plane_t *planes;
int numleafs; // number of visible leafs, not counting 0
mleaf_t *leafs;
int numvertexes;
mvertex_t *vertexes;
int numedges;
medge_t *edges;
int numnodes;
mnode_t *nodes;
int depth; ///< maximum depth of the tree
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int numclipnodes;
mclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
hull_t *hull_list[MAX_MAP_HULLS];
int numtextures;
texture_t **textures;
texture_t *skytexture;
byte *visdata;
byte *lightdata;
char *entities; //FIXME should not be here
mnode_t **node_parents;
mnode_t **leaf_parents;
unsigned int checksum;
unsigned int checksum2;
} mod_brush_t;
// SPRITE MODELS ==============================================================
// FIXME: shorten these?
@ -282,10 +326,10 @@ typedef struct {
} maliasframedesc_t;
typedef struct {
aliasskintype_t type;
int skin;
int texnum;
int fb_texnum;
aliasskintype_t type;
int skin;
int texnum;
int fb_texnum;
} maliasskindesc_t;
typedef struct {
@ -326,14 +370,6 @@ typedef struct {
maliasframedesc_t frames[1];
} aliashdr_t;
#define MAXALIASFRAMES 256
extern aliashdr_t *pheader;
extern stvert_t *stverts;
extern mtriangle_t *triangles;
extern trivertx_t *poseverts[MAXALIASFRAMES];
extern int aliasbboxmins[3];
extern int aliasbboxmaxs[3];
// Whole model ================================================================
typedef enum {mod_brush, mod_sprite, mod_alias, mod_iqm} modtype_t;
@ -349,6 +385,8 @@ typedef enum {mod_brush, mod_sprite, mod_alias, mod_iqm} modtype_t;
#define EF_GLOWTRAIL 4096 // glowcolor particle trail
typedef struct model_s {
//FIXME use pointers. needs care in bsp submodel loading
char path[MAX_QPATH];
char name[MAX_QPATH];
const struct vpath_s *vpath;// virtual path where this model was found
qboolean needload; // bmodels and sprites don't cache normally
@ -376,96 +414,38 @@ typedef struct model_s {
vec3_t clipmins, clipmaxs;
// brush model
int firstmodelsurface, nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
int numplanes;
plane_t *planes;
int numleafs; // number of visible leafs, not counting 0
mleaf_t *leafs;
int numvertexes;
mvertex_t *vertexes;
int numedges;
medge_t *edges;
int numnodes;
mnode_t *nodes;
int depth; ///< maximum depth of the tree
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int numclipnodes;
mclipnode_t *clipnodes;
int nummarksurfaces;
msurface_t **marksurfaces;
hull_t hulls[MAX_MAP_HULLS];
hull_t *hull_list[MAX_MAP_HULLS];
int numtextures;
texture_t **textures;
texture_t *skytexture;
byte *visdata;
byte *lightdata;
char *entities;
unsigned int checksum;
unsigned int checksum2;
//FIXME should be a pointer (submodels make things tricky)
mod_brush_t brush;
// additional model data
cache_user_t cache;
void (*clear) (struct model_s *m);
void (*clear) (struct model_s *m, void *data);
void *data;
} model_t;
// ============================================================================
extern float RadiusFromBounds (const vec3_t mins, const vec3_t maxs) __attribute__((pure));
void Mod_Init (void);
void Mod_Init_Cvars (void);
void Mod_ClearAll (void);
void Mod_Init (void);
void Mod_Init_Cvars (void);
void Mod_ClearAll (void);
model_t *Mod_ForName (const char *name, qboolean crash);
void *Mod_Extradata (model_t *mod); // handles caching
void Mod_TouchModel (const char *name);
void Mod_TouchModel (const char *name);
// brush specific
mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model) __attribute__((pure));
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
model_t *Mod_FindName (const char *name);
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
int Mod_Fullbright (byte * skin, int width, int height, const char *name);
byte *Mod_LeafPVS (const mleaf_t *leaf, const model_t *model);
void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame,
int extra);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame,
int extra);
// NOTE: the buffer pointed to by out must be at least MAP_PVS_BYTES in size
void Mod_LeafPVS_set (const mleaf_t *leaf, const model_t *model, byte defvis,
byte *out);
void Mod_LeafPVS_mix (const mleaf_t *leaf, const model_t *model, byte defvis,
byte *out);
void Mod_FindClipDepth (hull_t *hull);
void Mod_LoadBrushModel (model_t *mod, void *buffer);
void Mod_FloodFillSkin (byte * skin, int skinwidth, int skinheight);
void Mod_Print (void);
void Mod_Print (void);
extern struct cvar_s *gl_mesh_cache;
extern struct cvar_s *gl_subdivide_size;
extern struct cvar_s *gl_alias_render_tri;
extern struct cvar_s *gl_textures_external;
extern model_t *loadmodel;
extern char *loadname;
extern byte *mod_base;
extern byte mod_novis[MAX_MAP_LEAFS / 8];
extern int mod_lightmap_bytes;
#endif//__QF_model_h

View File

@ -71,10 +71,11 @@ pcx_t *EncodePCX (byte *data, int width, int height, int rowbytes,
\param f The file to read the texture from
\param convert If true, the texture is converted to RGB on load
\param pal The palette to apply during conversion
\param load If false, only the format and size info is loaded
\return A pointer to the texture.
\warning Uses Hunk_TempAlloc() to allocate the texture.
*/
struct tex_s *LoadPCX (QFile *f, qboolean convert, byte *pal);
struct tex_s *LoadPCX (QFile *f, qboolean convert, byte *pal, int load);
#endif//__QF_pcx_h

508
include/QF/plist.h Normal file
View File

@ -0,0 +1,508 @@
/*
plist.h
Property list management types and prototypes
Copyright (C) 2000 Jeff Teunissen <deek@d2dc.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_plist_h
#define __QF_plist_h
struct hashlink_s;
/** \defgroup plist Property lists
\ingroup utils
*/
///@{
#include "QF/qtypes.h"
/** The type of the property list item.
For further details, see \ref property-list.
*/
typedef enum {
QFDictionary, ///< The property list item represents a dictionary.
QFArray, ///< The property list item represents an array.
QFBinary, ///< The property list item represents arbitrary binary
///< data.
QFString, ///< The property list item represents a C string.
QFMultiType = (1 << 31) ///< if bit 31 is set, the type indicates a mask
///< of allowed types for plfield_t
} pltype_t;
/** Generic property list item.
All inspection and manipulation is to be done via the accessor functions.
*/
typedef struct plitem_s plitem_t;
struct plfield_s;
/** Custom parser for the field.
With this, custom parsing of any property list object type is
supported. For example, parsing of strings into numeric values,
converting binary objects to images, and deeper parsing of array and
dictionary objects.
If null, then the default parser for the object type is used:
* QFString: the point to the actual string. The string continues
to be owned by the string object.
* QFBinary: pointer to fixed-size DARRAY_TYPE(byte) (so size isn't
lost)
* QFArray: pointer to fixed-size DARRAY_TYPE(plitem_t *) with the
indivisual objects. The individual objects continue to be owned
by the array object.
* QFDictionary: pointer to the hashtab_t hash table used for the
dictionary object. The hash table continues to be owned by the
dictionary object.
\param field Pointer to this field item.
\param item The property list item being parsed into the field.
\param data Pointer to the field in the structure being parsed.
\param messages An array object the parser can use to store any
error messages. Messages should be strings, but no
checking is done: it is up to the top-level caller to
parse out the messages.
\param context Additional context data passed to the parser.
\return 0 for error, 1 for success. See \a PL_ParseDictionary.
*/
typedef int (*plparser_t) (const struct plfield_s *field,
const struct plitem_s *item,
void *data,
struct plitem_s *messages,
void *context);
/** A field to be parsed from a dictionary item.
something
*/
typedef struct plfield_s {
const char *name; ///< matched by dictionary key
size_t offset; ///< the offset of the field within the structure
pltype_t type; ///< the required type of the dictionary object
plparser_t parser; ///< custom parser function
void *data; ///< additional data for \a parser
} plfield_t;
typedef struct plelement_s {
pltype_t type; ///< the required type of the array elements
size_t stride; ///< the size of each element
void *(*alloc) (void *ctx, size_t size);///< allocator for array memory
plparser_t parser; ///< custom parser function
void *data; ///< additional data for \a parser
} plelement_t;
/** Create an in-memory representation of the contents of a property list.
\param string the saved plist, as read from a file.
\param hashlinks Hashlink chain to use when creating dictionaries (see
Hash_NewTable()). May be null.
\return Returns an object equivalent to the passed-in string.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_GetPropertyList (const char *string,
struct hashlink_s **hashlinks);
/** Create a property list string from the in-memory representation.
\param pl the in-memory representation
\return the text representation of the property list
\note You are responsible for freeing the returned string.
*/
char *PL_WritePropertyList (const plitem_t *pl);
/** Retrieve the type of an object.
\param item The object. Must not be null.
\return the type of the object
*/
pltype_t PL_Type (const plitem_t *item) __attribute__((pure));
/** Retrieve the line number of an object.
\param item The object. Must not be null.
\return the line number on which the object began, or 0 if not from a
string
*/
int PL_Line (const plitem_t *item) __attribute__((pure));
/** Retrieve the data size from a binary object.
\param binary The binary object
\return the size in bytes of the binary object 0 if \a binary isn't a
binary object (includes if \a binary is null).
*/
size_t PL_BinarySize (const plitem_t *binary) __attribute__((pure));
/** Retrieve the data from a binary object.
\param binary The binary object
\return pointer to the actual data or NULL if \b binary isn't a binary
object (includes if \a binary is null).
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
const void *PL_BinaryData (const plitem_t *binary) __attribute__((pure));
/** Retrieve a string from a string object.
\param string The string object
\return pointer to the actual string value or NULL if string isn't a
string (includes if \a string is null).
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
const char *PL_String (const plitem_t *string) __attribute__((pure));
/** Retrieve a value from a dictionary object.
\param dict The dictionary to retrieve a value from
\param key The unique key associated with the value
\return the value associated with the key, or NULL if not found or \a dict
isn't a dictionary (includes if \a dict is null).
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
plitem_t *PL_ObjectForKey (const plitem_t *dict, const char *key);
/** Remove a value from a dictionary object.
\param dict The Dictionary to remove the value from
\param key The unique key associated with the value to be removed
\return the value associated with the key, or NULL if not found or \a dict
isn't a dictionary (includes if \a dict is null).
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_RemoveObjectForKey (const plitem_t *dict, const char *key);
/** Retrieve a key from a dictionary object.
\param dict The dictionary to get the key from
\param index The index of the key
\return the key at the specified index, or NULL if index is out of range or
dict is not a dictionary (includes if \a dict is null).
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
const char *PL_KeyAtIndex (const plitem_t *dict, int index) __attribute__((pure));
/** Retrieve a value from an array object.
\param array The array to get the value from
\param index The index within the array to retrieve
\return the value at the specified index, or NULL if \a index is out of
range or \a array is not an array (includes in \a array is null).
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
plitem_t *PL_ObjectAtIndex (const plitem_t *array, int index) __attribute__((pure));
/** Retrieve a list of all keys in a dictionary.
\param dict The dictionary to list
\return an Array containing Strings or NULL if \a dict isn't a dictionary
(includes if \a dict is null).
\note You are responsible for freeing this array.
*/
plitem_t *PL_D_AllKeys (const plitem_t *dict);
/** Retrieve the number of keys in a dictionary.
\param dict The dictionary to get the number of keys of.
\return Returns the number of keys in the dictionary or 0 if \a dict isn't
a dictionary (includes if \a dict is null).
*/
int PL_D_NumKeys (const plitem_t *dict) __attribute__((pure));
/** Add a key/value pair to a dictionary.
\param dict The dictionary to which the key/value pair will be added
\param key The key of the key/value pair to be added to the dictionary
\param value The value of the key/value pair to be added to the dictionary
\return true on success, false on failure (\a dict is null or not a
dictionary)
\note the dictionary becomes the owner of the value.
*/
qboolean PL_D_AddObject (plitem_t *dict, const char *key, plitem_t *value);
/** Add an item to an array.
\param array The array to which the item will be added
\param item The item to be added to the array
\return true on success, false on failure (\a array is null or not an
array)
\note the array becomes the owner of the added item.
*/
qboolean PL_A_AddObject (plitem_t *array, plitem_t *item);
/** Retrieve the number of items in an array.
\param array The array from which to get the number of objects
\return number of objects in the array or 0 if \a array is null or not
an array.
*/
int PL_A_NumObjects (const plitem_t *array) __attribute__((pure));
/** Insert an item into an array before the specified location.
\param array The array to which the item will be added
\param item The item to be added to the array
\param index The location at which to insert the item into the array
\return true on success, false on failure (\a array is null or not an
array).
\note the array becomes the owner of the added item.
*/
qboolean PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int index);
/** Remove a value from an array object.
The array items will be shuffled to fill the resulting hole.
\param array The array from which to remove the value
\param index The index within the array to remove
\return the value associated with the index, or NULL if not found or array
is noll or an array.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_RemoveObjectAtIndex (plitem_t *array, int index);
/** Create a new dictionary object.
The dictionary will be empty.
\param hashlinks Hashlink chain to use when creating dictionaries (see
Hash_NewTable()). May be null.
\return the new dictionary object
*/
plitem_t *PL_NewDictionary (struct hashlink_s **hashlinks);
/** Create a new array object.
The array will be empty.
\return the new array object
*/
plitem_t *PL_NewArray (void);
/** Create a new data object from the given data.
Takes ownership of the given data.
\param data pointer to data buffer
\param size number of bytes in the buffer
\return the new dictionary object
\note The data will be freed via free() when the item is freed.
*/
plitem_t *PL_NewData (void *data, size_t size);
/** Create a new string object.
Makes a copy of the given string.
\param str C string to copy
\return the new dictionary object
*/
plitem_t *PL_NewString (const char *str);
/** Free a property list object.
This function takes care of freeing any referenced property list data, so
call it only on top-level objects. Safe to call with a null argument.
\param item the property list object to be freed
*/
void PL_Free (plitem_t *item);
int PL_CheckType (pltype_t field_type, pltype_t item_type) __attribute__((const));
void PL_TypeMismatch (plitem_t *messages, const plitem_t *item,
const char *name, pltype_t field_type,
pltype_t item_type);
/** Parse a dictionary object into a structure.
For each key in the dictionary, the corresponding field item is used to
determine how to parse the object associated with that key. Duplicate
field items are ignored: only the first item is used, and no checking is
done. Fields for which there is no key in the dictionary are also ignored,
and the destination is left unmodified. However, keys that have no
corresponding field are treated as errors and a suitable message is added
to the \a messages object.
When an error occurs (unknown key, incorrect item type (item type does not
match the type specified in the field item) or the field item's \a parser
returns 0), processing continues but the error result is returned.
Can be used recursively to parse deep hierarchies.
\param fields Array of field items describing the structure. Terminated
by a field item with a null \a name pointer.
\param dict The dictionary object to parse
\param data Pointer to the structure into which the data will be
parsed.
\param messages Array object supplied by the caller used for storing
messages. The messages may or may not indicate errors (its
contents are not checked). This function itself will add
only string objects.
If there are any errors, suitable messages will be found in
the \a messages object. However, just because there are no
errors doesn't mean that \a messages will remain empty as
a field's \a parser may add other messages. The standard
message format is "[line number]: [message]". If the line
number is 0, then the actual line is unknown (due to the
source item not being parsed from a file or string).
\param context Additional context data passed to the parser.
\return 0 if there are any errors, 1 if there are no errors.
*/
int PL_ParseStruct (const plfield_t *fields, const plitem_t *dict,
void *data, plitem_t *messages, void *context);
/** Parse an array object into a dynamic array (see darray.h).
For each object in the array, the field item is used to determine how to
parse the object. If the array is empty, the destination will be
initialized to an empty array.
When an error occurs (incorrect item type (item type does not match the
type specified in the element object) or the element object's \a parser
returns 0), processing continues but the error result is returned.
Can be used recursively to parse deep hierarchies.
\param field Pointer to a single field that has the field data pointer
set to reference a plelement_t object used to describe
the contents of the array.
\param array The array object to parse
\param data Pointer to the pointer to which the dynamic array will
be written. The dynamic array is allocated using
DARRAY_ALLOCFIXED_OBJ().
\param messages Array object supplied by the caller used for storing
messages. The messages may or may not indicate errors (its
contents are not checked). This function itself will add
only string objects.
If there are any errors, suitable messages will be found in
the \a messages object. However, just because there are no
errors doesn't mean that \a messages will remain empty as
a field's \a parser may add other messages. The standard
message format is "[line number]: [message]". If the line
number is 0, then the actual line is unknown (due to the
source item not being parsed from a file or string).
\param context Additional context data passed to the parser and allocator.
\return 0 if there are any errors, 1 if there are no errors.
*/
int PL_ParseArray (const plfield_t *field, const plitem_t *array,
void *data, plitem_t *messages, void *context);
/** Parse a dictionary object into a dynamic array (see darray.h).
This is useful when the dictionary object is meant to be a labeled list
rather than a representation of a structure.
For each object in the array, the field item is used to determine how to
parse the object. If the array is empty, the destination will be
initialized to an empty array.
When an error occurs (incorrect item type (item type does not match the
type specified in the element object) or the element object's \a parser
returns 0), processing continues but the error result is returned.
Can be used recursively to parse deep hierarchies.
\param field Pointer to a single field that has the field data pointer
set to reference a plelement_t object used to describe
the contents of the array.
\param dict The dict object to parse
\param data Pointer to the pointer to which the dynamic array will
be written. The dynamic array is allocated using
DARRAY_ALLOCFIXED_OBJ().
\param messages Array object supplied by the caller used for storing
messages. The messages may or may not indicate errors (its
contents are not checked). This function itself will add
only string objects.
If there are any errors, suitable messages will be found in
the \a messages object. However, just because there are no
errors doesn't mean that \a messages will remain empty as
a field's \a parser may add other messages. The standard
message format is "[line number]: [message]". If the line
number is 0, then the actual line is unknown (due to the
source item not being parsed from a file or string).
\param context Additional context data passed to the parser and allocator.
\return 0 if there are any errors, 1 if there are no errors.
*/
int PL_ParseLabeledArray (const plfield_t *field, const plitem_t *dict,
void *data, plitem_t *messages, void *context);
/** Parse a dictionary object into a hash table.
For each key in the dictionary, the element object is used to determine
how to parse the object associated with that key. Duplicate keys are an
error: they must be unique. A suitable message is added to the
\a messages object. If the dictionary object is empty, the destination
table is left unmodified.
When an error occurs (duplicate keys, incorrect type, or the element
object's \a parser returns 0), processing continues but the error
result is returned.
Can be used recursively to parse deep hierarchies.
Hash_Add() is used to add objects to the hash table, and Hash_Find() is
used to check for duplicates. Hash_Free() is used to free unused
objects. The means that the hash table is expected to use standard
objects with embedded keys (the parser is expected to put the key in the
object) and to have a free function.
The parser's data paramenter points to a pre-allocated block of memory
of the sized indicated by the element object's size field, using the
element object's alloc callback. The name field in the field paramenter
is set to the object's key and remains owned by the dictionary.
\param field Pointer to a single field that has the field data pointer
set to reference a plelement_t object used to describe
the contents of the dictionary.
\param dict The dictionary object to parse
\param data Pointer to the structure into which the data will be
parsed.
\param messages Array object supplied by the caller used for storing
messages. The messages may or may not indicate errors (its
contents are not checked). This function itself will add
only string objects.
If there are any errors, suitable messages will be found in
the \a messages object. However, just because there are no
errors doesn't mean that \a messages will remain empty as
a field's \a parser may add other messages. The standard
message format is "[line number]: [message]". If the line
number is 0, then the actual line is unknown (due to the
source item not being parsed from a file or string).
\param context Additional context data passed to the parser and allocator.
\return 0 if there are any errors, 1 if there are no errors.
*/
int PL_ParseSymtab (const plfield_t *field, const plitem_t *dict,
void *data, plitem_t *messages, void *context);
void __attribute__((format(printf,3,4)))
PL_Message (plitem_t *messages, const plitem_t *item, const char *fmt, ...);
///@}
#endif//__QF_plist_h

View File

@ -37,6 +37,8 @@ struct plitem_s;
struct cvar_s;
struct skin_s;
struct mod_alias_ctx_s;
/*
All video plugins must export these functions
*/
@ -80,23 +82,25 @@ typedef struct vid_particle_funcs_s {
} vid_particle_funcs_t;
typedef struct vid_model_funcs_s {
void (*Mod_LoadExternalTextures) (model_t *mod);
void (*Mod_LoadLighting) (bsp_t *bsp);
void (*Mod_SubdivideSurface) (msurface_t *fa);
void (*Mod_ProcessTexture) (texture_t *tx);
size_t texture_render_size;// size of renderer specific texture data
void (*Mod_LoadLighting) (model_t *mod, bsp_t *bsp);
void (*Mod_SubdivideSurface) (model_t *mod, msurface_t *fa);
void (*Mod_ProcessTexture) (model_t *mod, texture_t *tx);
void (*Mod_LoadIQM) (model_t *mod, void *buffer);
void (*Mod_LoadAliasModel) (model_t *mod, void *buffer,
cache_allocator_t allocator);
void (*Mod_LoadSpriteModel) (model_t *mod, void *buffer);
void (*Mod_MakeAliasModelDisplayLists) (model_t *m, aliashdr_t *hdr,
void (*Mod_MakeAliasModelDisplayLists) (struct mod_alias_ctx_s *alias_ctx,
void *_m, int _s, int extra);
void *(*Mod_LoadSkin) (byte *skin, int skinsize, int snum, int gnum,
void *(*Mod_LoadSkin) (struct mod_alias_ctx_s *alias_ctx, byte *skin,
int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void (*Mod_FinalizeAliasModel) (model_t *m, aliashdr_t *hdr);
void (*Mod_LoadExternalSkins) (model_t *mod);
void (*Mod_FinalizeAliasModel) (struct mod_alias_ctx_s *alias_ctx);
void (*Mod_LoadExternalSkins) (struct mod_alias_ctx_s *alias_ctx);
void (*Mod_IQMFinish) (model_t *mod);
int alias_cache;
void (*Mod_SpriteLoadTexture) (mspriteframe_t *pspriteframe, int framenum);
void (*Mod_SpriteLoadTexture) (model_t *mod, mspriteframe_t *pspriteframe,
int framenum);
struct skin_s *(*Skin_SetColormap) (struct skin_s *skin, int cmap);
struct skin_s *(*Skin_SetSkin) (struct skin_s *skin, int cmap,
@ -108,7 +112,6 @@ typedef struct vid_model_funcs_s {
} vid_model_funcs_t;
typedef struct vid_render_funcs_s {
void (*Draw_Init) (void);
void (*Draw_Character) (int x, int y, unsigned ch);
void (*Draw_String) (int x, int y, const char *str);
void (*Draw_nString) (int x, int y, const char *str, int count);
@ -131,9 +134,6 @@ typedef struct vid_render_funcs_s {
void (*Draw_SubPic) (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
// scr_funcs is a null terminated array
void (*SCR_UpdateScreen) (double realtime, SCR_Func scr_3dfunc,
SCR_Func *scr_funcs);
void (*SCR_DrawRam) (void);
void (*SCR_DrawTurtle) (void);
void (*SCR_DrawPause) (void);
@ -147,15 +147,17 @@ typedef struct vid_render_funcs_s {
void (*Fog_ParseWorldspawn) (struct plitem_s *worldspawn);
void (*R_Init) (void);
void (*R_RenderFrame) (SCR_Func scr_3dfunc, SCR_Func *scr_funcs);
void (*R_ClearState) (void);
void (*R_LoadSkys) (const char *);
void (*R_NewMap) (model_t *worldmodel, model_t **models, int num_models);
void (*R_AddEfrags) (entity_t *ent);
void (*R_AddEfrags) (mod_brush_t *brush, entity_t *ent);
void (*R_RemoveEfrags) (entity_t *ent);
void (*R_EnqueueEntity) (struct entity_s *ent); //FIXME should not be here
void (*R_LineGraph) (int x, int y, int *h_vals, int count);
dlight_t *(*R_AllocDlight) (int key);
entity_t *(*R_AllocEntity) (void);
void (*R_MaxDlightsCheck) (struct cvar_s *var);
void (*R_RenderView) (void);
void (*R_DecayLights) (double frametime);

View File

@ -33,7 +33,7 @@
#include "QF/quakefs.h"
struct tex_s *LoadPNG (QFile *infile);
struct tex_s *LoadPNG (QFile *infile, int load);
void WritePNG (const char *fileName, const byte *data, int width, int height);
void WritePNGqfs (const char *fileName, const byte *data,
int width, int height);

View File

@ -118,7 +118,7 @@ typedef struct pr_stashed_params_s {
alloca().
\param pr pointer to ::progs_t VM struct
\return Pointer to a newly allocated and initialized parameter
\return Pointer to a newly allocated and initialized parameter
stash that has the current parameters saved to it.
\hideinitializer
*/
@ -137,7 +137,7 @@ typedef struct pr_stashed_params_s {
\param pr pointer to ::progs_t VM struct
\param params location to save the parameters, must be of adequade size
to hold \a pr_argc * \a pr_param_size words in \a params
\return \a params Allows the likes of:
\return \a params Allows the likes of:
__auto_type params = PR_SaveParams (pr);
*/
pr_stashed_params_t *_PR_SaveParams (progs_t *pr, pr_stashed_params_t *params);
@ -298,13 +298,15 @@ void ED_PrintNum (progs_t *pr, pr_int_t ent);
// pr_parse.c
struct script_s;
struct plitem_s;
struct hashlink_s;
qboolean ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key,
const char *s);
struct plitem_s *ED_EntityDict (progs_t *pr, edict_t *ed);
struct plitem_s *ED_GlobalsDict (progs_t *pr);
void ED_InitGlobals (progs_t *pr, struct plitem_s *globals);
void ED_InitEntity (progs_t *pr, struct plitem_s *entity, edict_t *ent);
struct plitem_s *ED_ConvertToPlist (struct script_s *script, int nohack);
struct plitem_s *ED_ConvertToPlist (struct script_s *script, int nohack,
struct hashlink_s **hashlinks);
struct plitem_s *ED_Parse (progs_t *pr, const char *data);
void ED_LoadFromFile (progs_t *pr, const char *data);
void ED_EntityParseFunction (progs_t *pr);
@ -1530,46 +1532,50 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
/** Allocate a new resource from the resource map.
\param type The type of the resource. Must match the \c type parameter
used for PR_RESMAP.
\param map The resource map.
\return A pointer to the new resource, or null if no more could
be allocated.
*/
#define PR_RESNEW(type,map) \
type *t; \
\
if (!map._free) { \
int i, size; \
map._size++; \
size = map._size * sizeof (type *); \
map._map = realloc (map._map, size); \
if (!map._map) \
return 0; \
map._free = calloc (1024, sizeof (type)); \
if (!map._free) \
return 0; \
map._map[map._size - 1] = map._free; \
for (i = 0; i < 1023; i++) \
*(type **) &map._free[i] = &map._free[i + 1]; \
*(type **) &map._free[i] = 0; \
} \
t = map._free; \
map._free = *(type **) t; \
memset (t, 0, sizeof (type)); \
return t
#define PR_RESNEW_NC(map) \
({ \
if (!map._free) { \
int i, size; \
map._size++; \
size = map._size * sizeof (map._free); \
map._map = realloc (map._map, size); \
if (!map._map) \
return 0; \
map._free = malloc (1024 * sizeof (*map._free)); \
if (!map._free) \
return 0; \
map._map[map._size - 1] = map._free; \
for (i = 0; i < 1023; i++) \
*(typeof (map._free) *) &map._free[i] = &map._free[i + 1]; \
*(typeof (map._free) *) &map._free[i] = 0; \
} \
__auto_type t = map._free; \
map._free = *(typeof (map._free) *) t; \
t; \
})
#define PR_RESNEW(map) \
({ \
__auto_type t = PR_RESNEW_NC (map); \
memset (t, 0, sizeof (*map._free)); \
t; \
})
/** Free a resource returning it to the resource map.
\param type The type of the resource. Must match the \c type parameter
used for PR_RESMAP.
\param map The resource map.
\param t Pointer to the resource to be freed.
*/
#define PR_RESFREE(type,map,t) \
memset (t, 0, sizeof (type)); \
*(type **) t = map._free; \
map._free = t
#define PR_RESFREE(map,t) \
do { \
memset (t, 0, sizeof (*map._free)); \
*(typeof (map._free) *) t = map._free; \
map._free = t; \
} while (0)
/** Free all resources in the resource map.
@ -1578,24 +1584,24 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
A reset resource map is guaranteed to allocate elements sequentially.
\param type The type of the resource. Must match the \c type parameter
used for PR_RESMAP.
\param map The resource map.
*/
#define PR_RESRESET(type,map) \
unsigned i, j; \
if (!map._size) \
return; \
for (i = 0; i < map._size; i++) { \
map._free = map._map[i]; \
for (j = 0; j < 1023; j++) \
*(type **) &map._free[j] = &map._free[j + 1]; \
if (i < map._size - 1) \
*(type **) &map._free[j] = &map._map[i + 1][0]; \
else \
*(type **) &map._free[j] = 0; \
} \
map._free = map._map[0];
#define PR_RESRESET(map) \
do { \
unsigned i, j; \
if (!map._size) \
return; \
for (i = 0; i < map._size; i++) { \
map._free = map._map[i]; \
for (j = 0; j < 1023; j++) \
*(typeof (map._free) *) &map._free[j] = &map._free[j + 1]; \
if (i < map._size - 1) \
*(typeof (map._free) *) &map._free[j] = &map._map[i + 1][0];\
else \
*(typeof (map._free) *) &map._free[j] = 0; \
} \
map._free = map._map[0]; \
} while (0)
/** Retrieve a resource from the resource map using a handle.
@ -1604,12 +1610,14 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
\return A pointer to the resource, or NULL if the handle is
invalid.
*/
#define PR_RESGET(map,col) \
unsigned row = ~col / 1024; \
col = ~col % 1024; \
if (row >= map._size) \
return 0; \
return &map._map[row][col]
#define PR_RESGET(map,col) \
({ \
unsigned row = ~col / 1024; \
col = ~col % 1024; \
if (row >= map._size) \
return 0; \
&map._map[row][col]; \
})
/** Convert a resource pointer to a handle.
@ -1617,14 +1625,19 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
\param ptr The resource pointer.
\return The handle or 0 if the pointer is invalid.
*/
#define PR_RESINDEX(map,ptr) \
unsigned i; \
for (i = 0; i < map._size; i++) { \
long d = ptr - map._map[i]; \
if (d >= 0 && d < 1024) \
return ~(i * 1024 + d); \
} \
return 0
#define PR_RESINDEX(map,ptr) \
({ \
unsigned i; \
unsigned index = 0; \
for (i = 0; i < map._size; i++) { \
long d = ptr - map._map[i]; \
if (d >= 0 && d < 1024) { \
index = ~(i * 1024 + d); \
break; \
} \
} \
index; \
})
///@}
///@}
@ -1780,6 +1793,7 @@ struct progs_s {
///@{
struct hashtab_s *builtin_hash;
struct hashtab_s *builtin_num_hash;
struct biblock_s *builtin_blocks;
unsigned bi_next;
unsigned (*bi_map) (progs_t *pr, unsigned binum);
///@}

View File

@ -1,231 +0,0 @@
/*
qfplist.h
Property list management types and prototypes
Copyright (C) 2000 Jeff Teunissen <deek@d2dc.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_qfplist_h
#define __QF_qfplist_h
/** \defgroup qfplist Property lists
\ingroup utils
*/
///@{
#include "QF/qtypes.h"
/** The type of the property list item.
For further details, see \ref property-list.
*/
typedef enum {
QFDictionary, ///< The property list item represents a dictionary.
QFArray, ///< The property list item represents an array.
QFBinary, ///< The property list item represents arbitrary binary
///< data.
QFString ///< The property list item represents a C string.
} pltype_t;
/** Generic property list item.
All inspection and manipulation is to be done via the accessor functions.
*/
typedef struct plitem_s plitem_t;
/** Create an in-memory representation of the contents of a property list.
\param string the saved plist, as read from a file.
\return Returns an object equivalent to the passed-in string.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_GetPropertyList (const char *string);
/** Create a property list string from the in-memory representation.
\param pl the in-memory representation
\return the text representation of the property list
\note You are responsible for freeing the returned string.
*/
char *PL_WritePropertyList (plitem_t *pl);
/** Retrieve the type of an object.
\param item The object
\return the type of the object
*/
pltype_t PL_Type (plitem_t *item) __attribute__((pure));
/** Retrieve a string from a string object.
\param string The string object
\return pointer to the actual string value or NULL if string isn't a
string.
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
const char *PL_String (plitem_t *string) __attribute__((pure));
/** Retrieve a value from a dictionary object.
\param dict The dictionary to retrieve a value from
\param key The unique key associated with the value
\return the value associated with the key, or NULL if not found or dict
isn't a dictionary.
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
plitem_t *PL_ObjectForKey (plitem_t *dict, const char *key);
/** Remove a value from a dictionary object.
\param dict The Dictionary to remove the value from
\param key The unique key associated with the value to be removed
\return the value associated with the key, or NULL if not found or dict
isn't a dictionary.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_RemoveObjectForKey (plitem_t *dict, const char *key);
/** Retrieve a value from an array object.
\param array The array to get the value from
\param index The index within the array to retrieve
\return the value associated with the key, or NULL if not found or array
isn't an array.
\note You are NOT responsible for freeing the returned object. It will
be destroyed when its container is.
*/
plitem_t *PL_ObjectAtIndex (plitem_t *array, int index) __attribute__((pure));
/** Retrieve a list of all keys in a dictionary.
\param dict The dictionary to list
\return an Array containing Strings or NULL if dict isn't a dictionary
\note You are responsible for freeing this array.
*/
plitem_t *PL_D_AllKeys (plitem_t *dict);
/** Retrieve the number of keys in a dictionary.
\param dict The dictionary to get the number of keys of.
\return Returns the number of keys in the dictionary.
*/
int PL_D_NumKeys (plitem_t *dict) __attribute__((pure));
/** Add a key/value pair to a dictionary.
\param dict The dictionary to which the key/value pair will be added
\param key The key of the key/value pair to be added to the dictionary
\param value The value of the key/value pair to be added to the dictionary
\return true on success, false on failure
\note the dictionary becomes the owner of the value.
*/
qboolean PL_D_AddObject (plitem_t *dict, const char *key, plitem_t *value);
/** Add an item to an array.
\param array The array to which the item will be added
\param item The item to be added to the array
\return true on success, false on failure
\note the array becomes the owner of the added item.
*/
qboolean PL_A_AddObject (plitem_t *array, plitem_t *item);
/** Retrieve the number of items in an array.
\param array The array from which to get the number of objects
\return number of objects in the array
*/
int PL_A_NumObjects (plitem_t *array) __attribute__((pure));
/** Insert an item into an array before the specified location.
\param array The array to which the item will be added
\param item The item to be added to the array
\param index The location at which to insert the item into the array
\return true on success, false on failure
\note the array becomes the owner of the added item.
*/
qboolean PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int index);
/** Remove a value from an array object.
The array items will be shuffled to fill the resulting hole.
\param array The array from which to remove the value
\param index The index within the array to remove
\return the value associated with the index, or NULL if not found or array
isn't an array.
\note You are responsible for freeing the returned object.
*/
plitem_t *PL_RemoveObjectAtIndex (plitem_t *array, int index);
/** Create a new dictionary object.
The dictionary will be empty.
\return the new dictionary object
*/
plitem_t *PL_NewDictionary (void);
/** Create a new array object.
The array will be empty.
\return the new array object
*/
plitem_t *PL_NewArray (void);
/** Create a new data object from the given data.
Takes ownership of the given data.
\param data pointer to data buffer
\param size number of bytes in the buffer
\return the new dictionary object
\note The data will be freed via free() when the item is freed.
*/
plitem_t *PL_NewData (void *data, size_t size);
/** Create a new string object.
Makes a copy of the given string.
\param str C string to copy
\return the new dictionary object
*/
plitem_t *PL_NewString (const char *str);
/** Free a property list object.
This function takes care of freeing any referenced property list data, so
call it only on top-level objects.
\param item the property list object to be freed
*/
void PL_Free (plitem_t *item);
///@}
#endif//__QF_qfplist_h

View File

@ -32,6 +32,7 @@
#include "QF/model.h"
#include "QF/qdefs.h" // FIXME
#include "QF/vid.h"
#include "QF/simd/types.h"
typedef enum {
pt_static,
@ -55,6 +56,15 @@ typedef enum {
extern struct vid_render_funcs_s *r_funcs;
extern struct vid_render_data_s *r_data;
typedef struct subpic_s {
const struct subpic_s *const next;
const struct scrap_s *const scrap; ///< renderer specific type
const struct vrect_s *const rect;
const int width; ///< requested width
const int height; ///< requested height
const float size; ///< size factor for tex coords (mult)
} subpic_t;
// dynamic lights ===========================================================
typedef struct dlight_s
@ -81,47 +91,52 @@ typedef struct
//===============
typedef struct animation_s {
int frame;
float syncbase; // randomize time base for local animations
float frame_start_time;
float frame_interval;
int pose1;
int pose2;
float blend;
int nolerp; // don't lerp this frame (pose data invalid)
} animation_t;
typedef struct visibility_s {
struct entity_s *entity; // owning entity
struct efrag_s *efrag; // linked list of efrags
struct mnode_s *topnode; // bmodels, first world node that
// splits bmodel, or NULL if not split
// applies to other models, too
int visframe; // last frame this entity was
// found in an active leaf
int trivial_accept; // view clipping (frustum and depth)
} visibility_t;
typedef struct renderer_s {
struct model_s *model; // NULL = no model
struct skin_s *skin;
float colormod[4]; // color tint and alpha for model
int skinnum; // for Alias models
int fullbright;
float min_light;
mat4_t full_transform;
} renderer_t;
typedef struct entity_s {
struct entity_s *next;
struct entity_s *unext; //FIXME this shouldn't be here. for qw demos
vec3_t origin;
vec3_t old_origin;
vec3_t angles;
vec_t transform[4 * 4];
vec_t full_transform[4 * 4];
struct model_s *model; // NULL = no model
int frame;
int skinnum; // for Alias models
struct skin_s *skin;
float syncbase; // for client-side animations
struct efrag_s *efrag; // linked list of efrags
int visframe; // last frame this entity was
// found in an active leaf
float colormod[4]; // color tint and alpha for model
float scale; // size scaler of the model
int fullbright;
float min_light;
// FIXME: could turn these into a union
int trivial_accept;
struct mnode_s *topnode; // for bmodels, first world node that
// splits bmodel, or NULL if not split
// Animation interpolation
float frame_start_time;
float frame_interval;
int pose1;
int pose2;
struct model_s *pose_model; // no lerp if not the same as model
struct transform_s *transform;
animation_t animation;
visibility_t visibility;
renderer_t renderer;
int active;
//XXX FIXME XXX should not be here
vec4f_t old_origin;
} entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct
{
typedef struct {
vrect_t vrect; // subwindow in video for refresh
// FIXME: not need vrect next field here?
vrect_t aliasvrect; // scaled Alias version
@ -142,8 +157,9 @@ typedef struct
float xOrigin; // should probably always be 0.5
float yOrigin; // between be around 0.3 to 0.5
vec3_t vieworg;
vec3_t viewangles;
//FIXME was vec3_t, need to deal with asm (maybe? is it worth it?)
vec4f_t viewposition;
vec4f_t viewrotation;
float fov_x, fov_y;
@ -172,8 +188,8 @@ extern struct texture_s *r_notexture_mip;
extern entity_t r_worldentity;
void R_Init (void);
void R_LoadModule (void (*load_gl)(void),
void (*set_palette) (const byte *palette));
struct vid_internal_s;
void R_LoadModule (struct vid_internal_s *vid_internal);
struct progs_s;
void R_Progs_Init (struct progs_s *pr);

View File

@ -28,6 +28,16 @@
#ifndef __QF_ringbuffer_h
#define __QF_ringbuffer_h
/** Type declaration for a type-safe ring buffer.
*
* While not in itself thread-safe, the buffer is designed (and tested) to be
* used in a threaded environment using sutable locking mechanisms.
*
* \param type The type of data element stored in the ring buffer.
* \param size The number of objects in the ring buffer. Note that the
* actual capacity of the buffer is `size - 1` due to the
* way ring buffers work.
*/
#define RING_BUFFER(type, size) \
struct { \
type buffer[size]; \
@ -40,16 +50,46 @@
sizeof (rb->buffer) / sizeof (rb->buffer[0]); \
})
/** Return the amount of space available for writing in the ring buffer.
*
* Use this to know how much data can be written (RB_WRITE_DATA()) or acquired
* (RB_ACQUIRE()), or just to see if any space is available.
*
* \note Does NOT affect buffer state.
*
* \param ring_buffer The ring buffer to check for available space.
*/
#define RB_SPACE_AVAILABLE(ring_buffer) \
({ __auto_type rb = &(ring_buffer); \
(rb->tail + RB_buffer_size(rb) - rb->head - 1) % RB_buffer_size(rb);\
})
/** Return the number of objects available in the ring buffer.
*
* Use this to know how much data can be read (RB_READ_DATA()) or discarded
* (RB_RELEASE()), or just to see if any data is available.
*
* \note Does NOT affect buffer state.
*
* \param ring_buffer The ring buffer to check for available data.
*/
#define RB_DATA_AVAILABLE(ring_buffer) \
({ __auto_type rb = &(ring_buffer); \
(rb->head + RB_buffer_size (rb) - rb->tail) % RB_buffer_size (rb); \
})
/** Write \a count objects from \a data to the buffer, wrapping if necessary.
*
* \note Affects buffer state (advances the head).
*
* \note Does NOT check that the space is available. It is the caller's
* responsitiblity to do so using RB_SPACE_AVAILABLE().
*
* \param ring_buffer The ring buffer to which the data will be written.
* \param data Pointer to the data to be copied into the ring buffer.
* \param count unsigned int. The number of objects to copy from
* \a data
*/
#define RB_WRITE_DATA(ring_buffer, data, count) \
({ __auto_type rb = &(ring_buffer); \
const typeof (rb->buffer[0]) *d = (data); \
@ -66,6 +106,39 @@
memcpy (rb->buffer + h, d, c * sizeof (rb->buffer[0])); \
})
/** Acquire \a count objects from the buffer, wrapping if necessary.
*
* \note Affects buffer state (advances the head).
*
* \note Does NOT check that the space is available. It is the caller's
* responsitiblity to do so using RB_SPACE_AVAILABLE().
*
* \param ring_buffer The ring buffer to which the data will be written.
* \param count unsigned int. The number of objects to copy from
* \a data.
* \return Address of the first object acquired.
*/
#define RB_ACQUIRE(ring_buffer, count) \
({ __auto_type rb = &(ring_buffer); \
unsigned c = (count); \
unsigned h = rb->head; \
rb->head = (h + c) % RB_buffer_size (rb); \
&rb->buffer[h]; \
})
/** Read \a count objects from the buffer to \a data, wrapping if necessary.
*
* \note Affects buffer state (advances the tail).
*
* \note Does NOT check that the data is available. It is the caller's
* responsitiblity to do so using RB_DATA_AVAILABLE().
*
* \param ring_buffer The ring buffer from which the data will be read.
* \param data Pointer to the location into which data will be copied
* from the ring buffer.
* \param count unsigned int. The number of objects to copy from
* the buffer into \a data
*/
#define RB_READ_DATA(ring_buffer, data, count) \
({ __auto_type rb = &(ring_buffer); \
typeof (&rb->buffer[0]) d = (data); \
@ -83,18 +156,54 @@
rb->tail = (t + oc) % RB_buffer_size (rb); \
})
#define RB_DROP_DATA(ring_buffer, count) \
/** Discard \a count objects from the ring buffer.
*
* \note Affects buffer state (advances the tail).
*
* \note Does NOT check that the data is available. It is the caller's
* responsitiblity to do so using RB_DATA_AVAILABLE().
*
* \param ring_buffer The ring buffer from which the objects will be
* discarded.
* \param count The number of objects to discard.
*/
#define RB_RELEASE(ring_buffer, count) \
({ __auto_type rb = &(ring_buffer); \
unsigned c = (count); \
unsigned t = rb->tail; \
rb->tail = (t + c) % RB_buffer_size (rb); \
})
/** Access a single item from the buffer without affecting buffer state.
*
* \note Does NOT affect buffer state.
*
* \note Does NOT check that the data is available. It is the caller's
* responsitiblity to do so using RB_DATA_AVAILABLE().
*
* \param ring_buffer The ring buffer from which to access the object.
* \param ahead The tail-relative index of the object to access from
* the buffer. Valid range is 0 to
* `RB_DATA_AVAILABLE() - 1`
* \return Address of the accessed element
*/
#define RB_PEEK_DATA(ring_buffer, ahead) \
({ __auto_type rb = &(ring_buffer); \
rb->buffer[(rb->tail + ahead) % RB_buffer_size (rb)]; \
&rb->buffer[(rb->tail + ahead) % RB_buffer_size (rb)]; \
})
/** WRite a single item to the buffer without affecting buffer state.
*
* \note Does NOT affect buffer state.
*
* \note Does NOT check that the data is available. It is the caller's
* responsitiblity to do so using RB_DATA_AVAILABLE().
*
* \param ring_buffer The ring buffer from which to read the object.
* \param ahead The tail-relative index of the buffer object to write.
* Valid range is 0 to `RB_DATA_AVAILABLE() - 1`
* \param data The data to write to the buffer.
*/
#define RB_POKE_DATA(ring_buffer, ahead, data) \
({ __auto_type rb = &(ring_buffer); \
rb->buffer[(rb->tail + ahead) % RB_buffer_size (rb)] = (data); \

View File

@ -35,6 +35,9 @@ void SCR_Init_Cvars (void);
void SCR_Init (void);
typedef void (*SCR_Func)(void);
// scr_funcs is a null terminated array
void SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc,
SCR_Func *scr_funcs);
void SCR_SizeUp (void);
void SCR_SizeDown (void);

192
include/QF/simd/mat4f.h Normal file
View File

@ -0,0 +1,192 @@
/*
QF/simd/mat4f.h
Matrix functions for mat4f_t (ie, float precision)
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_simd_mat4f_h
#define __QF_simd_mat4f_h
#include <immintrin.h>
#include "QF/simd/types.h"
GNU89INLINE inline void maddf (mat4f_t c, const mat4f_t a, const mat4f_t b);
GNU89INLINE inline void msubf (mat4f_t c, const mat4f_t a, const mat4f_t b);
GNU89INLINE inline void mmulf (mat4f_t c, const mat4f_t a, const mat4f_t b);
GNU89INLINE inline vec4f_t mvmulf (const mat4f_t m, vec4f_t v) __attribute__((const));
GNU89INLINE inline vec4f_t m3vmulf (const mat4f_t m, vec4f_t v) __attribute__((const));
GNU89INLINE inline void mat4fidentity (mat4f_t m);
GNU89INLINE inline void mat4ftranspose (mat4f_t t, const mat4f_t m);
GNU89INLINE inline void mat4fquat (mat4f_t m, vec4f_t q);
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
maddf (mat4f_t c, const mat4f_t a, const mat4f_t b)
{
c[0] = a[0] + b[0];
c[1] = a[1] + b[1];
c[2] = a[2] + b[2];
c[3] = a[3] + b[3];
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
msubf (mat4f_t c, const mat4f_t a, const mat4f_t b)
{
c[0] = a[0] - b[0];
c[1] = a[1] - b[1];
c[2] = a[2] - b[2];
c[3] = a[3] - b[3];
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
mmulf (mat4f_t c, const mat4f_t a, const mat4f_t b)
{
c[0] = a[0] * b[0][0] + a[1] * b[0][1] + a[2] * b[0][2] + a[3] * b[0][3];
c[1] = a[0] * b[1][0] + a[1] * b[1][1] + a[2] * b[1][2] + a[3] * b[1][3];
c[2] = a[0] * b[2][0] + a[1] * b[2][1] + a[2] * b[2][2] + a[3] * b[2][3];
c[3] = a[0] * b[3][0] + a[1] * b[3][1] + a[2] * b[3][2] + a[3] * b[3][3];
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
mvmulf (const mat4f_t m, vec4f_t v)
{
return m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * v[3];
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
m3vmulf (const mat4f_t m, vec4f_t v)
{
vec4f_t w;
w = m[0] * v[0] + m[1] * v[1] + m[2] * v[2];
w[3] = v[3];
return w;
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
mat4fidentity (mat4f_t m)
{
m[0] = (vec4f_t) { 1, 0, 0, 0 };
m[1] = (vec4f_t) { 0, 1, 0, 0 };
m[2] = (vec4f_t) { 0, 0, 1, 0 };
m[3] = (vec4f_t) { 0, 0, 0, 1 };
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
mat4ftranspose (mat4f_t t, const mat4f_t m)
{
vec4f_t a = m[0];
vec4f_t b = m[1];
vec4f_t c = m[2];
vec4f_t d = m[3];
t[0] = (vec4f_t) { a[0], b[0], c[0], d[0] };
t[1] = (vec4f_t) { a[1], b[1], c[1], d[1] };
t[2] = (vec4f_t) { a[2], b[2], c[2], d[2] };
t[3] = (vec4f_t) { a[3], b[3], c[3], d[3] };
}
#ifndef IMPLEMENT_MAT4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
mat4fquat (mat4f_t m, vec4f_t q)
{
vec4f_t xq = q[0] * q;
vec4f_t yq = q[1] * q;
vec4f_t zq = q[2] * q;
vec4f_t wq = q[3] * q;
static const vec4i_t shuff103 = { 1, 0, 3, 2 };
static const vec4i_t shuff230 = { 2, 3, 0, 1 };
static const vec4i_t shuff321 = { 3, 2, 1, 0 };
#define p (0)
#define m (1u << 31)
static const vec4i_t mpm = { m, p, m, 0 };
static const vec4i_t pmm = { p, m, m, 0 };
static const vec4i_t mmp = { m, m, p, 0 };
static const vec4i_t mask = { ~0u, ~0u, ~0u, 0 };
#undef p
#undef m
{
vec4f_t a = xq;
vec4f_t b = _mm_xor_ps (__builtin_shuffle (yq, shuff103), (__m128) mpm);
vec4f_t c = _mm_xor_ps (__builtin_shuffle (zq, shuff230), (__m128) pmm);
vec4f_t d = _mm_xor_ps (__builtin_shuffle (wq, shuff321), (__m128) mmp);
m[0] = _mm_and_ps (a + b - c - d, (__m128) mask);
}
{
vec4f_t a = _mm_xor_ps (__builtin_shuffle (xq, shuff103), (__m128) mpm);
vec4f_t b = yq;
vec4f_t c = _mm_xor_ps (__builtin_shuffle (zq, shuff321), (__m128) mmp);
vec4f_t d = _mm_xor_ps (__builtin_shuffle (wq, shuff230), (__m128) pmm);
m[1] = _mm_and_ps (b + c - a - d, (__m128) mask);
}
{
vec4f_t a = _mm_xor_ps (__builtin_shuffle (xq, shuff230), (__m128) pmm);
vec4f_t b = _mm_xor_ps (__builtin_shuffle (yq, shuff321), (__m128) mmp);
vec4f_t c = zq;
vec4f_t d = _mm_xor_ps (__builtin_shuffle (wq, shuff103), (__m128) mpm);
m[2] = _mm_and_ps (a - b + c - d, (__m128) mask);
}
m[3] = (vec4f_t) { 0, 0, 0, 1 };
}
#endif//__QF_simd_mat4f_h

89
include/QF/simd/types.h Normal file
View File

@ -0,0 +1,89 @@
/*
QF/simd/types.h
Type definitions for QF SIMD values
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_simd_types_h
#define __QF_simd_types_h
#define VEC_TYPE(t,n) typedef t n __attribute__ ((vector_size (4*sizeof (t))))
/** Three element vector type for interfacing with compact data.
*
* This cannot be used directly by SIMD code and must be loaded and stored
* using load_vec3d() and store_vec3d() respectively.
*/
typedef double vec3d_t[3];
#ifdef __AVX__
/** Four element vector type for horizontal (AOS) vector data.
*
* This is used for both vectors (3D and 4D) and quaternions. 3D vectors
* are simply vec4d_t values with 0 in the 4th element.
*
* Also usable with vertical (SOA) code, in which case each vec4d_t represents
* a single component from four vectors, or a single row/column (depending on
* context) of an Nx4 or 4xN matrix.
*/
VEC_TYPE (double, vec4d_t);
/** Used mostly for __builtin_shuffle.
*/
VEC_TYPE (long, vec4l_t);
#endif
/** Three element vector type for interfacing with compact data.
*
* This cannot be used directly by SIMD code and must be loaded and stored
* using load_vec3f() and store_vec3f() respectively.
*/
typedef float vec3f_t[3];
/** Four element vector type for horizontal (AOS) vector data.
*
* This is used for both vectors (3D and 4D) and quaternions. 3D vectors
* are simply vec4f_t values with 0 in the 4th element.
*
* Also usable with vertical (SOA) code, in which case each vec4f_t represents
* a single component from four vectors, or a single row/column (depending on
* context) of an Nx4 or 4xN matrix.
*/
VEC_TYPE (float, vec4f_t);
/** Used mostly for __builtin_shuffle.
*/
VEC_TYPE (int, vec4i_t);
#define VEC4D_FMT "[%.17g, %.17g, %.17g, %.17g]"
#define VEC4L_FMT "[%ld, %ld, %ld, %ld]"
#define VEC4F_FMT "[%.9g, %.9g, %.9g, %.9g]"
#define VEC4I_FMT "[%d, %d, %d, %d]"
#define VEC4_EXP(v) (v)[0], (v)[1], (v)[2], (v)[3]
#define MAT4_ROW(m, r) (m)[0][r], (m)[1][r], (m)[2][r], (m)[3][r]
typedef vec4f_t mat4f_t[4];
typedef vec4i_t mat4i_t[4];
#endif//__QF_simd_types_h

294
include/QF/simd/vec4d.h Normal file
View File

@ -0,0 +1,294 @@
/*
QF/simd/vec4d.h
Vector functions for vec4d_t (ie, double precision)
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_simd_vec4d_h
#define __QF_simd_vec4d_h
#include <immintrin.h>
#include "QF/simd/types.h"
GNU89INLINE inline vec4d_t vsqrtd (vec4d_t v) __attribute__((const));
GNU89INLINE inline vec4d_t vceild (vec4d_t v) __attribute__((const));
GNU89INLINE inline vec4d_t vfloord (vec4d_t v) __attribute__((const));
GNU89INLINE inline vec4d_t vtruncd (vec4d_t v) __attribute__((const));
/** 3D vector cross product.
*
* The w (4th) component can be any value on input, and is guaranteed to be 0
* in the result. The result is not affected in any way by either vector's w
* componemnt
*/
GNU89INLINE inline vec4d_t crossd (vec4d_t a, vec4d_t b) __attribute__((const));
/** 4D vector dot product.
*
* The w component *IS* significant, but if it is 0 in either vector, then
* the result will be as for a 3D dot product.
*
* Note that the dot product is in all 4 of the return value's elements. This
* helps optimize vector math as the scalar is already pre-spread. If just the
* scalar is required, use result[0].
*/
GNU89INLINE inline vec4d_t dotd (vec4d_t a, vec4d_t b) __attribute__((const));
/** Quaternion product.
*
* The vector is interpreted as a quaternion instead of a regular 4D vector.
* The quaternion may be of any magnitude, so this is more generally useful.
* than if the quaternion was required to be unit length.
*/
GNU89INLINE inline vec4d_t qmuld (vec4d_t a, vec4d_t b) __attribute__((const));
/** Optimized quaterion-vector multiplication for vector rotation.
*
* \note This is the inverse of vqmulf
*
* If the vector's w component is not zero, then the result's w component
* is the cosine of the full rotation angle scaled by the vector's w component.
* The quaternion is assumed to be unit. If the quaternion is not unit, the
* vector will be scaled by the square of the quaternion's magnitude.
*/
GNU89INLINE inline vec4d_t qvmuld (vec4d_t q, vec4d_t v) __attribute__((const));
/** Optimized vector-quaterion multiplication for vector rotation.
*
* \note This is the inverse of qvmulf
*
* If the vector's w component is not zero, then the result's w component
* is the cosine of the full rotation angle scaled by the vector's w component.
* The quaternion is assumed to be unit. If the quaternion is not unit, the
* vector will be scaled by the square of the quaternion's magnitude.
*/
GNU89INLINE inline vec4d_t vqmuld (vec4d_t v, vec4d_t q) __attribute__((const));
/** Create the quaternion representing the shortest rotation from a to b.
*
* Both a and b are assumed to be 3D vectors (w components 0), but a resonable
* (but incorrect) result will still be produced if either a or b is a 4D
* vector. The rotation axis will be the same as if both vectors were 3D, but
* the magnitude of the rotation will be different.
*/
GNU89INLINE inline vec4d_t qrotd (vec4d_t a, vec4d_t b) __attribute__((const));
/** Return the conjugate of the quaternion.
*
* That is, [-x, -y, -z, w].
*/
GNU89INLINE inline vec4d_t qconjd (vec4d_t q) __attribute__((const));
GNU89INLINE inline vec4d_t loadvec3d (const double v3[]) __attribute__((pure, access(read_only, 1)));
GNU89INLINE inline void storevec3d (double v3[3], vec4d_t v4) __attribute__((access (write_only, 1)));
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
vsqrtd (vec4d_t v)
{
return _mm256_sqrt_pd (v);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
vceild (vec4d_t v)
{
return _mm256_ceil_pd (v);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
vfloord (vec4d_t v)
{
return _mm256_floor_pd (v);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
vtruncd (vec4d_t v)
{
return _mm256_round_pd (v, _MM_FROUND_TRUNC);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
crossd (vec4d_t a, vec4d_t b)
{
static const vec4l_t A = {1, 2, 0, 3};
vec4d_t c = a * __builtin_shuffle (b, A);
vec4d_t d = __builtin_shuffle (a, A) * b;
c = c - d;
return __builtin_shuffle(c, A);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
dotd (vec4d_t a, vec4d_t b)
{
vec4d_t c = a * b;
c = _mm256_hadd_pd (c, c);
static const vec4l_t A = {2, 3, 0, 1};
c += __builtin_shuffle(c, A);
return c;
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
qmuld (vec4d_t a, vec4d_t b)
{
// results in [2*as*bs, as*b + bs*a + a x b] ([scalar, vector] notation)
// doesn't seem to adversly affect precision
vec4d_t c = crossd (a, b) + a * b[3] + a[3] * b;
vec4d_t d = dotd (a, b);
// zero out the vector component of dot product so only the scalar remains
d = _mm256_permute2f128_pd (d, d, 0x18);
d = _mm256_permute4x64_pd (d, 0xc0);
return c - d;
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
qvmuld (vec4d_t q, vec4d_t v)
// ^^^ ^^^
{
double s = q[3];
// zero the scalar of the quaternion. Results in an extra operation, but
// avoids adding precision issues.
vec4d_t z = {};
q = _mm256_blend_pd (q, z, 0x08);
vec4d_t c = crossd (q, v);
vec4d_t qv = dotd (q, v); // q.w is 0 so v.w is irrelevant
vec4d_t qq = dotd (q, q);
// vvv
return (s * s - qq) * v + 2 * (qv * q + s * c);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
vqmuld (vec4d_t v, vec4d_t q)
// ^^^ ^^^
{
double s = q[3];
// zero the scalar of the quaternion. Results in an extra operation, but
// avoids adding precision issues.
vec4d_t z = {};
q = _mm256_blend_pd (q, z, 0x08);
vec4d_t c = crossd (q, v);
vec4d_t qv = dotd (q, v); // q.w is 0 so v.w is irrelevant
vec4d_t qq = dotd (q, q);
// vvv
return (s * s - qq) * v + 2 * (qv * q - s * c);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
qrotd (vec4d_t a, vec4d_t b)
{
vec4d_t ma = vsqrtd (dotd (a, a));
vec4d_t mb = vsqrtd (dotd (b, b));
vec4d_t den = 2 * ma * mb;
vec4d_t t = mb * a + ma * b;
vec4d_t mba_mab = vsqrtd (dotd (t, t));
vec4d_t q = crossd (a, b) / mba_mab;
q[3] = (mba_mab / den)[0];
return q;
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
qconjd (vec4d_t q)
{
const vec4l_t neg = { 1lu << 63, 1lu << 63, 1lu << 63, 0 };
return _mm256_xor_pd (q, (__m256d) neg);
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4d_t
loadvec3d (const double v3[])
{
vec4d_t v4 = {};
v4[0] = v3[0];
v4[1] = v3[1];
v4[2] = v3[2];
return v4;
}
#ifndef IMPLEMENT_VEC4D_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
storevec3d (double v3[3], vec4d_t v4)
{
v3[0] = v4[0];
v3[1] = v4[1];
v3[2] = v4[2];
}
#endif//__QF_simd_vec4d_h

328
include/QF/simd/vec4f.h Normal file
View File

@ -0,0 +1,328 @@
/*
QF/simd/vec4f.h
Vector functions for vec4f_t (ie, float precision)
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __QF_simd_vec4f_h
#define __QF_simd_vec4f_h
#include <immintrin.h>
#include "QF/simd/types.h"
GNU89INLINE inline vec4f_t vsqrtf (vec4f_t v) __attribute__((const));
GNU89INLINE inline vec4f_t vceilf (vec4f_t v) __attribute__((const));
GNU89INLINE inline vec4f_t vfloorf (vec4f_t v) __attribute__((const));
GNU89INLINE inline vec4f_t vtruncf (vec4f_t v) __attribute__((const));
/** 3D vector cross product.
*
* The w (4th) component can be any value on input, and is guaranteed to be 0
* in the result. The result is not affected in any way by either vector's w
* componemnt
*/
GNU89INLINE inline vec4f_t crossf (vec4f_t a, vec4f_t b) __attribute__((const));
/** 4D vector dot product.
*
* The w component *IS* significant, but if it is 0 in either vector, then
* the result will be as for a 3D dot product.
*
* Note that the dot product is in all 4 of the return value's elements. This
* helps optimize vector math as the scalar is already pre-spread. If just the
* scalar is required, use result[0].
*/
GNU89INLINE inline vec4f_t dotf (vec4f_t a, vec4f_t b) __attribute__((const));
/** Quaternion product.
*
* The vector is interpreted as a quaternion instead of a regular 4D vector.
* The quaternion may be of any magnitude, so this is more generally useful.
* than if the quaternion was required to be unit length.
*/
GNU89INLINE inline vec4f_t qmulf (vec4f_t a, vec4f_t b) __attribute__((const));
/** Optimized quaterion-vector multiplication for vector rotation.
*
* \note This is the inverse of vqmulf
*
* If the vector's w component is not zero, then the result's w component
* is the cosine of the full rotation angle scaled by the vector's w component.
* The quaternion is assumed to be unit.
*/
GNU89INLINE inline vec4f_t qvmulf (vec4f_t q, vec4f_t v) __attribute__((const));
/** Optimized vector-quaterion multiplication for vector rotation.
*
* \note This is the inverse of qvmulf
*
* If the vector's w component is not zero, then the result's w component
* is the cosine of the full rotation angle scaled by the vector's w component.
* The quaternion is assumed to be unit.
*/
GNU89INLINE inline vec4f_t vqmulf (vec4f_t v, vec4f_t q) __attribute__((const));
/** Create the quaternion representing the shortest rotation from a to b.
*
* Both a and b are assumed to be 3D vectors (w components 0), but a resonable
* (but incorrect) result will still be produced if either a or b is a 4D
* vector. The rotation axis will be the same as if both vectors were 3D, but
* the magnitude of the rotation will be different.
*/
GNU89INLINE inline vec4f_t qrotf (vec4f_t a, vec4f_t b) __attribute__((const));
/** Return the conjugate of the quaternion.
*
* That is, [-x, -y, -z, w].
*/
GNU89INLINE inline vec4f_t qconjf (vec4f_t q) __attribute__((const));
GNU89INLINE inline vec4f_t loadvec3f (const float v3[3]) __attribute__((pure, access(read_only, 1)));
GNU89INLINE inline void storevec3f (float v3[3], vec4f_t v4) __attribute__((access (write_only, 1)));
GNU89INLINE inline vec4f_t normalf (vec4f_t v) __attribute__((pure));
GNU89INLINE inline vec4f_t magnitudef (vec4f_t v) __attribute__((pure));
GNU89INLINE inline vec4f_t magnitude3f (vec4f_t v) __attribute__((pure));
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
vsqrtf (vec4f_t v)
{
return _mm_sqrt_ps (v);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
vceilf (vec4f_t v)
{
return _mm_ceil_ps (v);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
vfloorf (vec4f_t v)
{
return _mm_floor_ps (v);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
vtruncf (vec4f_t v)
{
return _mm_round_ps (v, _MM_FROUND_TRUNC);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
crossf (vec4f_t a, vec4f_t b)
{
static const vec4i_t A = {1, 2, 0, 3};
vec4f_t c = a * __builtin_shuffle (b, A) - __builtin_shuffle (a, A) * b;
return __builtin_shuffle(c, A);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
dotf (vec4f_t a, vec4f_t b)
{
vec4f_t c = a * b;
c = _mm_hadd_ps (c, c);
c = _mm_hadd_ps (c, c);
return c;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
qmulf (vec4f_t a, vec4f_t b)
{
// results in [2*as*bs, as*b + bs*a + a x b] ([scalar, vector] notation)
// doesn't seem to adversly affect precision
vec4f_t c = crossf (a, b) + a * b[3] + a[3] * b;
vec4f_t d = dotf (a, b);
// zero out the vector component of dot product so only the scalar remains
d = _mm_insert_ps (d, d, 0xf7);
return c - d;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
qvmulf (vec4f_t q, vec4f_t v)
{
float s = q[3];
// zero the scalar of the quaternion. Results in an extra operation, but
// avoids adding precision issues.
q = _mm_insert_ps (q, q, 0xf8);
vec4f_t c = crossf (q, v);
vec4f_t qv = dotf (q, v); // q.w is 0 so v.w is irrelevant
vec4f_t qq = dotf (q, q);
return (s * s - qq) * v + 2 * (qv * q + s * c);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
vqmulf (vec4f_t v, vec4f_t q)
{
float s = q[3];
// zero the scalar of the quaternion. Results in an extra operation, but
// avoids adding precision issues.
q = _mm_insert_ps (q, q, 0xf8);
vec4f_t c = crossf (q, v);
vec4f_t qv = dotf (q, v); // q.w is 0 so v.w is irrelevant
vec4f_t qq = dotf (q, q);
return (s * s - qq) * v + 2 * (qv * q - s * c);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
qrotf (vec4f_t a, vec4f_t b)
{
vec4f_t ma = vsqrtf (dotf (a, a));
vec4f_t mb = vsqrtf (dotf (b, b));
vec4f_t den = 2 * ma * mb;
vec4f_t t = mb * a + ma * b;
vec4f_t mba_mab = vsqrtf (dotf (t, t));
vec4f_t q = crossf (a, b) / mba_mab;
q[3] = (mba_mab / den)[0];
return q;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
qconjf (vec4f_t q)
{
const vec4i_t neg = { 1u << 31, 1u << 31, 1u << 31, 0 };
return _mm_xor_ps (q, (__m128) neg);
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
loadvec3f (const float v3[3])
{
vec4f_t v4;
// this had to be in asm otherwise gcc thinks v4 is only partially
// initialized, and gcc 10 does not use the zero flags when generating
// the code, resulting in a memory access to load a 0 into v4[3]
//
// The first instruction zeros v4[3] while loading v4[0]
asm ("\n\
vinsertps $0x08, %1, %0, %0 \n\
vinsertps $0x10, %2, %0, %0 \n\
vinsertps $0x20, %3, %0, %0 \n\
"
: "=v"(v4)
: "m"(v3[0]), "m"(v3[1]), "m"(v3[2]));
return v4;
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
void
storevec3f (float v3[3], vec4f_t v4)
{
v3[0] = v4[0];
v3[1] = v4[1];
v3[2] = v4[2];
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
normalf (vec4f_t v)
{
return v / vsqrtf (dotf (v, v));
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
magnitudef (vec4f_t v)
{
return vsqrtf (dotf (v, v));
}
#ifndef IMPLEMENT_VEC4F_Funcs
GNU89INLINE inline
#else
VISIBLE
#endif
vec4f_t
magnitude3f (vec4f_t v)
{
v[3] = 0;
return vsqrtf (dotf (v, v));
}
#endif//__QF_simd_vec4f_h

View File

@ -83,6 +83,7 @@ double Sys_DoubleTime (void);
void Sys_TimeOfDay(date_t *date);
void Sys_MaskPrintf (int mask, const char *fmt, ...) __attribute__((format(printf,2,3)));
// remember to update developer_flags in cvar.c
#define SYS_DEV (1|0)
#define SYS_WARN (1|2) // bit 0 so developer 1 will pick it up
#define SYS_VID (1|4)
@ -97,6 +98,7 @@ void Sys_MaskPrintf (int mask, const char *fmt, ...) __attribute__((format(print
#define SYS_GLSL (1|2048)
#define SYS_SKIN (1|4096)
#define SYS_MODEL (1|8192)
#define SYS_VULKAN (1|16384)
int Sys_CheckInput (int idle, int net_socket);
const char *Sys_ConsoleInput (void);
@ -120,7 +122,8 @@ void Sys_Init_Cvars (void);
// memory protection
//
void Sys_MakeCodeWriteable (uintptr_t startaddr, size_t length);
void Sys_PageIn (void *ptr, int size);
void Sys_PageIn (void *ptr, size_t size);
void *Sys_Alloc (size_t size);
//
// system IO

View File

@ -67,7 +67,7 @@ typedef struct _TargaHeader {
# endif
#endif
struct tex_s *LoadTGA (QFile *fin);
struct tex_s *LoadTGA (QFile *fin, int load);
void WriteTGAfile (const char *tganame, byte *data, int width, int height);
#endif//__QF_tga_h

View File

@ -34,9 +34,60 @@
*/
///@{
// does a varargs printf into a temp buffer
char *va(const char *format, ...) __attribute__((format(printf,1,2)));
// does a varargs printf into a malloced buffer
/** Opaque context for va so it can have per-thread data.
*/
typedef struct va_ctx_s va_ctx_t;
/** Create a va context with the specified number of buffers.
*
* Having multiple buffers allows va to be used in short chains.
*
* \param buffers The number of buffers to create in the context. va() will
* cycle through the buffers for each call.
* \return Pointer to the context. Pass to va() for thread-safe usage.
*/
va_ctx_t *va_create_context (int buffers);
/** Destroy a va context.
*
* \param ctx The context to be destroyed. Must have been created by
* va_create_context().
* \note Any pointers to strings returned by va() using the context
* referenced by \a ctx will become invalid as the backing
* memory for the strings will have been freed.
*/
void va_destroy_context (va_ctx_t *ctx);
/** Does a varargs printf into a private buffer.
*
* \param ctx Context used for storing the private buffer such that va
* can be used in a multi-threaded environment. If null then
* a static context is used, in which case va is NOT
* thread-safe.
* \param format Standard printf() format string.
* \return Pointer to the beginning of the output string. The memory
* for the returned string is owned by the context pointed to
* by \a ctx.
* \note The static context is created with 4 buffers, so va (0,...)
* can be used to produce mildly complex output (eg, 3 calls
* to va sent to a 4th) with a reduced risk of strings being
* trampled.
*/
char *va(va_ctx_t *ctx, const char *format, ...) __attribute__((format(printf,2,3)));
/** Does a varargs printf into a malloced buffer.
*
* Combines the effect of strdup and sprintf, but in a safe manner. Essentially
* the equivalent of strdup (va (ctx, format, ...));
*
* \param format Standard printf() format string.
* \return Pointer to the beginning of the output string. The caller
* is responsible for freeing the memory holding the string.
* \note As nva() creates a new buffer every time it is called, it
* is thread-safe and there is no risk of the string being
* trampled. In addition, it does not use va(), so combining
* nva() with va() is safe.
*/
char *nva(const char *format, ...) __attribute__((format(printf,1,2)));
///@}

View File

@ -43,6 +43,7 @@ typedef struct {
byte *gammatable; // 256
byte *basepal; // 256 * 3
byte *palette; // 256 * 3
byte *palette32; // 256 * 4 includes alpha
byte *colormap8; // 256 * VID_GRADES size
unsigned short *colormap16; // 256 * VID_GRADES size
unsigned int *colormap32; // 256 * VID_GRADES size
@ -61,17 +62,7 @@ typedef struct {
int conheight;
byte *direct; // direct drawing to framebuffer, if not
// NULL
int (*surf_cache_size)(int width, int height);
void (*flush_caches)(void);
void (*init_caches)(void *cache, int size);
void (*do_screen_buffer)(void);
void (*set_palette)(const byte *palette);
// gl stuff
void (*load_gl)(void);
void (*init_gl)(void);
void *(*get_proc_address)(const char *name, qboolean crit);
void (*end_rendering)(void);
struct vid_internal_s *vid_internal;
} viddef_t;
#define viddef (*r_data->vid)
@ -86,7 +77,7 @@ void VID_Init_Cvars (void);
// the palette data will go away after the call, so it must be copied off if
// the video driver will need it again
void VID_Init (byte *palette, byte *colormap);
void VID_Shutdown (void);
void VID_SetCaption (const char *text);
void VID_ClearMemory (void);
#endif//__QF_vid_h

View File

@ -105,6 +105,7 @@ void Z_SetError (memzone_t *zone, void (*err) (void *data, const char *msg),
void *data);
void Z_CheckPointer (const memzone_t *zone, const void *ptr, int size);
void Hunk_Print (qboolean all);
void *Hunk_Alloc (int size); // returns 0 filled memory
void *Hunk_AllocName (int size, const char *name);
int Hunk_LowMark (void) __attribute__((pure));

47
include/client/effects.h Normal file
View File

@ -0,0 +1,47 @@
/*
effects.h
Effect management
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/3/11
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __client_effects_h
#define __client_effects_h
#include "QF/simd/types.h"
struct entity_s;
struct entity_state_s;
void CL_NewDlight (int key, vec4f_t org, int effects, byte glow_size,
byte glow_color, double time);
void CL_ModelEffects (struct entity_s *ent, int num, int glow_color,
double time);
void CL_EntityEffects (int num, struct entity_s *ent,
struct entity_state_s *state, double time);
void CL_MuzzleFlash (vec4f_t position, vec4f_t fv, float zoffset, int num,
double time);
#endif//__client_effects_h

View File

@ -32,6 +32,7 @@
#define __client_entities_h
#include "QF/qtypes.h"
#include "QF/simd/types.h"
// entity_state_t is the information conveyed from the server
// in an update message
@ -39,10 +40,12 @@ typedef struct entity_state_s {
int number; // edict index
unsigned flags; // nolerp, etc
vec3_t origin;
vec4f_t origin;
vec4f_t velocity;
vec3_t angles;
unsigned short modelindex;
unsigned short frame;
uint16_t modelindex;
uint16_t frame;
int weaponframe;
int effects;
byte colormap;
byte skinnum;
@ -67,4 +70,8 @@ extern entstates_t qw_entstates;
extern vec3_t ent_colormod[256];
struct entity_s;
void CL_TransformEntity (struct entity_s *ent, float scale,
const vec3_t angles, vec4f_t position);
#endif//__client_entities_h

View File

@ -29,22 +29,24 @@
#define __QF_locs_h
#include "QF/qtypes.h"
#include "QF/simd/types.h"
typedef struct
{
vec3_t loc;
char *name;
vec4f_t loc;
char *name;
} location_t;
location_t *locs_find(const vec3_t target) __attribute__((pure));
void locs_add (const vec3_t location, const char *name);
void locs_del (const vec3_t loc);
void locs_edit (const vec3_t loc, const char *desc);
location_t *locs_find(vec4f_t target) __attribute__((pure));
void locs_add (vec4f_t location, const char *name);
void locs_del (vec4f_t loc);
void locs_edit (vec4f_t loc, const char *desc);
void locs_load(const char *filename);
void locs_mark (const vec3_t loc, const char *desc);
int locs_nearest (const vec3_t loc) __attribute__((pure));
void locs_mark (vec4f_t loc, const char *desc);
int locs_nearest (vec4f_t loc) __attribute__((pure));
void locs_reset (void);
void locs_save (const char *filename, qboolean gz);
void map_to_loc (const char *mapname, char *filename);
void locs_draw (vec4f_t simorg);
#endif//__QF_locs_h

View File

@ -0,0 +1,119 @@
/*
temp_entities.h
Temporary entity management
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/3/10
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __client_temp_entities_h
#define __client_temp_entities_h
#include "QF/simd/vec4f.h"
typedef enum TE_Effect {
TE_NoEffect, // for invalid nq/qw -> qf mapping
TE_Beam, // grappling hook beam
TE_Blood, // bullet hitting body
TE_Explosion, // rocket explosion
TE_Explosion2, // color mapped explosion
TE_Explosion3, // Nehahra colored light explosion
TE_Gunshot1, // NQ gunshot (20 particles)
TE_Gunshot2, // QW gunshot (has particle count)
TE_KnightSpike, // spike hitting wall
TE_LavaSplash,
TE_Lightning1, // lightning bolts
TE_Lightning2, // lightning bolts
TE_Lightning3, // lightning bolts
TE_Lightning4, // Nehahra lightning
TE_LightningBlood, // lightning hitting body
TE_Spike, // spike hitting wall
TE_SuperSpike, // super spike hitting wall
TE_TarExplosion, // tarbaby explosion
TE_Teleport,
TE_WizSpike, // spike hitting wall
} TE_Effect;
typedef enum TE_nqEffect {
TE_nqSpike,
TE_nqSuperSpike,
TE_nqGunshot,
TE_nqExplosion,
TE_nqTarExplosion,
TE_nqLightning1,
TE_nqLightning2,
TE_nqWizSpike,
TE_nqKnightSpike,
TE_nqLightning3,
TE_nqLavaSplash,
TE_nqTeleport,
TE_nqExplosion2,
TE_nqBeam,
TE_nqExplosion3 = 16,
TE_nqLightning4,
} TE_nqEffect;
typedef enum TE_qwEffect {
TE_qwSpike,
TE_qwSuperSpike,
TE_qwGunshot,
TE_qwExplosion,
TE_qwTarExplosion,
TE_qwLightning1,
TE_qwLightning2,
TE_qwWizSpike,
TE_qwKnightSpike,
TE_qwLightning3,
TE_qwLavaSplash,
TE_qwTeleport,
TE_qwBlood,
TE_qwLightningBlood,
TE_qwExplosion2 = 16,
TE_qwBeam,
} TE_qwEffect;
//FIXME find a better way to get this info from the parser
typedef struct TEntContext_s {
vec4f_t simorg;
struct model_s *worldModel;
int playerEntity;
} TEntContext_t;
struct msg_s;
struct entity_s;
void CL_TEnts_Init (void);
void CL_Init_Entity (struct entity_s *ent);
void CL_ClearTEnts (void);
void CL_UpdateTEnts (double time, TEntContext_t *ctx);
void CL_ParseTEnt_nq (struct msg_s *net_message, double time,
TEntContext_t *ctx);
void CL_ParseTEnt_qw (struct msg_s *net_message, double time,
TEntContext_t *ctx);
void CL_ParseParticleEffect (struct msg_s *net_message);
void CL_ClearProjectiles (void);
void CL_ParseProjectiles (struct msg_s *net_message, qboolean nail2,
TEntContext_t *ctx);
#endif//__client_temp_entities_h

View File

@ -1,5 +1,5 @@
/*
clview.h
view.h
(description)
@ -26,28 +26,39 @@
*/
// view.h
#ifndef __clview_h_
#define __clview_h_
#ifndef __client_view_h_
#define __client_view_h_
#include "QF/mathlib.h"
#include "QF/simd/types.h"
#define INFO_CSHIFT_BONUS (1 << 0)
#define INFO_CSHIFT_CONTENTS (1 << 1)
#define INFO_CSHIFT_DAMAGE (1 << 2)
#define INFO_CSHIFT_POWERUP (1 << 3)
typedef struct viewstate_s {
vec4f_t movecmd;
vec4f_t velocity;
vec4f_t origin;
vec3_t angles;
int weaponframe;
int onground; // -1 when in air
uint32_t flags;
float frametime;
vec4f_t punchangle;
} viewstate_t;
#define VF_DEAD 1
#define VF_GIB 2
void V_Init (void);
void V_Init_Cvars (void);
void V_RenderView (void);
float V_CalcRoll (const vec3_t angles, const vec3_t velocity);
void V_UpdatePalette (void);
float V_CalcRoll (const vec3_t angles, vec4f_t velocity);
void V_StartPitchDrift (void);
void V_StopPitchDrift (void);
void V_RenderView (void);
void V_UpdatePalette (void);
void V_Register (void);
void V_SetContentsColor (int contents);
void V_CalcBlend (void);
#endif // __clview_h_
#endif // __client_view_h_

View File

@ -30,7 +30,19 @@
#ifndef __context_sdl_h_
#define __context_sdl_h_
#include <SDL.h>
extern SDL_Surface *sdl_screen;
void VID_SDL_GammaCheck (void);
void SDL_Init_Cvars (void);
struct gl_ctx_s *SDL_GL_Context (void);
void SDL_GL_Init_Cvars (void);
struct sw_ctx_s *SDL_SW_Context (void);
void SDL_SW_Init_Cvars (void);
extern uint32_t sdl_flags;
#endif // __context_sdl_h_

View File

@ -77,4 +77,13 @@ void X11_SaveMouseAcceleration (void);
void X11_RemoveMouseAcceleration (void);
void X11_RestoreMouseAcceleration (void);
struct gl_ctx_s *X11_GL_Context (void);
void X11_GL_Init_Cvars (void);
struct sw_ctx_s *X11_SW_Context (void);
void X11_SW_Init_Cvars (void);
struct vulkan_ctx_s *X11_Vulkan_Context (void);
void X11_Vulkan_Init_Cvars (void);
#endif // __context_x11_h_

View File

@ -1,55 +1,90 @@
#ifndef __mod_internal_h
#define __mod_internal_h
#include "QF/darray.h"
#include "QF/iqm.h"
#include "QF/model.h"
#include "QF/skin.h"
#include "QF/plugin/vid_render.h"
typedef struct stvertset_s DARRAY_TYPE (stvert_t) stvertset_t;
typedef struct mtriangleset_s DARRAY_TYPE (mtriangle_t) mtriangleset_t;
typedef struct trivertxset_s DARRAY_TYPE (trivertx_t *) trivertxset_t;
typedef struct mod_alias_ctx_s {
aliashdr_t *header;
model_t *mod;
stvertset_t stverts;
mtriangleset_t triangles;
trivertxset_t poseverts;
int aliasbboxmins[3];
int aliasbboxmaxs[3];
} mod_alias_ctx_t;
int Mod_CalcFullbright (const byte *in, byte *out, int pixels);
void Mod_ClearFullbright (const byte *in, byte *out, int pixels);
void Mod_FloodFillSkin (byte *skin, int skinwidth, int skinheight);
//FIXME gl specific. rewrite to use above
int Mod_Fullbright (byte * skin, int width, int height, const char *name);
void Mod_LoadBrushModel (model_t *mod, void *buffer);
void Mod_FindClipDepth (hull_t *hull);
model_t *Mod_FindName (const char *name);
float RadiusFromBounds (const vec3_t mins, const vec3_t maxs) __attribute__((pure));
struct vulkan_ctx_s;
extern vid_model_funcs_t *m_funcs;
void gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
void gl_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx, void *_m,
int _s, int extra);
void *gl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void gl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void gl_Mod_LoadExternalSkins (model_t *mod);
void *gl_Mod_LoadSkin (mod_alias_ctx_t *alias_ctx, byte *skin, int skinsize,
int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc);
void gl_Mod_FinalizeAliasModel (mod_alias_ctx_t *alias_ctx);
void gl_Mod_LoadExternalSkins (mod_alias_ctx_t *alias_ctx);
void gl_Mod_IQMFinish (model_t *mod);
void glsl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr,
void glsl_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx,
void *_m, int _s, int extra);
void *glsl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void glsl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void glsl_Mod_LoadExternalSkins (model_t *mod);
void *glsl_Mod_LoadSkin (mod_alias_ctx_t *alias_ctx, byte *skin, int skinsize,
int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc);
void glsl_Mod_FinalizeAliasModel (mod_alias_ctx_t *alias_ctx);
void glsl_Mod_LoadExternalSkins (mod_alias_ctx_t *alias_ctx);
void glsl_Mod_IQMFinish (model_t *mod);
void sw_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
void sw_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx, void *_m,
int _s, int extra);
void *sw_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void sw_Mod_LoadExternalSkins (model_t *mod);
void *sw_Mod_LoadSkin (mod_alias_ctx_t *alias_ctx, byte *skin, int skinsize,
int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc);
void sw_Mod_IQMFinish (model_t *mod);
void gl_Mod_LoadExternalTextures (model_t *mod);
void gl_Mod_LoadLighting (bsp_t *bsp);
void gl_Mod_SubdivideSurface (msurface_t *fa);
void gl_Mod_ProcessTexture(texture_t *tx);
void gl_Mod_LoadLighting (model_t *mod, bsp_t *bsp);
void gl_Mod_SubdivideSurface (model_t *mod, msurface_t *fa);
void gl_Mod_ProcessTexture (model_t *mod, texture_t *tx);
void glsl_Mod_LoadExternalTextures (model_t *mod);
void glsl_Mod_LoadLighting (bsp_t *bsp);
void glsl_Mod_SubdivideSurface (msurface_t *fa);
void glsl_Mod_ProcessTexture(texture_t *tx);
void glsl_Mod_LoadLighting (model_t *mod, bsp_t *bsp);
void glsl_Mod_ProcessTexture (model_t *mod, texture_t *tx);
void sw_Mod_LoadExternalTextures (model_t *mod);
void sw_Mod_LoadLighting (bsp_t *bsp);
void sw_Mod_SubdivideSurface (msurface_t *fa);
void sw_Mod_ProcessTexture(texture_t *tx);
void sw_Mod_LoadLighting (model_t *mod, bsp_t *bsp);
void gl_Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
void glsl_Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
void sw_Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
void Vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp,
struct vulkan_ctx_s *ctx);
void Vulkan_Mod_SubdivideSurface (model_t *mod, msurface_t *fa,
struct vulkan_ctx_s *ctx);
void Vulkan_Mod_ProcessTexture (model_t *mod, texture_t *tx,
struct vulkan_ctx_s *ctx);
void gl_Mod_SpriteLoadTexture (model_t *mod, mspriteframe_t *pspriteframe,
int framenum);
void glsl_Mod_SpriteLoadTexture (model_t *mod, mspriteframe_t *pspriteframe,
int framenum);
void sw_Mod_SpriteLoadTexture (model_t *mod, mspriteframe_t *pspriteframe,
int framenum);
void Mod_LoadIQM (model_t *mod, void *buffer);
void Mod_FreeIQM (iqm_t *iqm);
@ -62,6 +97,10 @@ void Skin_Init (void);
skin_t *Skin_SetColormap (skin_t *skin, int cmap);
skin_t *Skin_SetSkin (skin_t *skin, int cmap, const char *skinname);
void Skin_SetTranslation (int cmap, int top, int bottom);
int Skin_CalcTopColors (const byte *in, byte *out, int pixels);
int Skin_CalcBottomColors (const byte *in, byte *out, int pixels);
void Skin_ClearTopColors (const byte *in, byte *out, int pixels);
void Skin_ClearBottomColors (const byte *in, byte *out, int pixels);
void sw_Skin_SetupSkin (skin_t *skin, int cmap);
void sw_Skin_ProcessTranslation (int cmap, const byte *translation);

View File

@ -90,10 +90,6 @@ extern struct cvar_s *net_packetlog;
*/
void NET_Init (int port);
/** Shutdown the UDP network interface.
*/
void NET_Shutdown (void);
/** Read a single packet from the network into net_message.
\return True if successfully read, otherwise false.

View File

@ -273,10 +273,6 @@ extern int net_activeconnections;
*/
void NET_Init (void);
/** Shutdown the networking sub-system.
*/
void NET_Shutdown (void);
/** Check for new connections.
\return Pointer to the qsocket for the new connection if there

View File

@ -320,26 +320,9 @@ typedef struct usercmd_s {
} usercmd_t;
typedef struct plent_state_s {
int number;
unsigned int flags;
vec3_t origin;
entity_state_t es;
usercmd_t cmd;
vec3_t velocity;
int modelindex;
int frame;
int skinnum;
int effects;
int weaponframe;
byte msec;
// QSG 2
byte alpha;
byte scale;
byte glow_size;
byte glow_color;
byte colormod;
} plent_state_t;
typedef struct {

View File

@ -16,7 +16,6 @@ extern quat_t crosshair_color;
extern struct cvar_s *d_mipcap;
extern struct cvar_s *d_mipscale;
extern struct cvar_s *gl_driver;
extern struct cvar_s *gl_affinemodels;
extern struct cvar_s *gl_anisotropy;
extern struct cvar_s *gl_clear;

View File

@ -49,12 +49,6 @@ void R_PushDlights (const vec3_t entorigin);
struct cvar_s;
void R_MaxDlightsCheck (struct cvar_s *var);
void R_Particles_Init_Cvars (void);
void R_Particle_New (ptype_t type, int texnum, const vec3_t org, float scale,
const vec3_t vel, float die, int color, float alpha,
float ramp);
void R_Particle_NewRandom (ptype_t type, int texnum, const vec3_t org,
int org_fuzz, float scale, int vel_fuzz, float die,
int color, float alpha, float ramp);
void R_InitBubble (void);
void R_InitParticles (void);

View File

@ -9,6 +9,34 @@
#include "r_screen.h"
#include "r_shared.h"
typedef struct gltex_s {
texture_t *texture;
int gl_texturenum;
int gl_fb_texturenum;
instsurf_t *tex_chain; // for gl_texsort drawing
instsurf_t **tex_chain_tail;
} gltex_t;
typedef struct glsltex_s {
texture_t *texture;
int gl_texturenum;
int sky_tex[2];
instsurf_t *tex_chain; // for gl_texsort drawing
instsurf_t **tex_chain_tail;
struct elechain_s *elechain;
struct elechain_s **elechain_tail;
} glsltex_t;
typedef struct vulktex_s {
texture_t *texture;
instsurf_t *tex_chain; // for gl_texsort drawing
instsurf_t **tex_chain_tail;
struct elechain_s *elechain;
struct elechain_s **elechain_tail;
struct qfv_tex_s *tex;
struct qfv_tex_s *glow;
} vulktex_t;
extern viddef_t vid; // global video state
extern vid_render_data_t vid_render_data;
@ -16,6 +44,7 @@ extern vid_render_funcs_t gl_vid_render_funcs;
extern vid_render_funcs_t glsl_vid_render_funcs;
extern vid_render_funcs_t sw_vid_render_funcs;
extern vid_render_funcs_t sw32_vid_render_funcs;
extern vid_render_funcs_t vulkan_vid_render_funcs;
extern vid_render_funcs_t *vid_render_funcs;
#define vr_data vid_render_data
@ -31,7 +60,7 @@ void Fog_Update (float density, float red, float green, float blue,
struct plitem_s;
void Fog_ParseWorldspawn (struct plitem_s *worldspawn);
float *Fog_GetColor (void);
void Fog_GetColor (quat_t fogcolor);
float Fog_GetDensity (void) __attribute__((pure));
void Fog_SetupFrame (void);
void Fog_EnableGFog (void);
@ -44,7 +73,7 @@ void gl_R_Init (void);
void glsl_R_Init (void);
void sw_R_Init (void);
void sw32_R_Init (void);
void R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs);
void R_Init_Cvars (void);
void R_InitEfrags (void);
void R_ClearState (void);
@ -54,7 +83,7 @@ void R_RenderView (void); // must set r_refdef first
void R_ViewChanged (float aspect); // must set r_refdef first
// called whenever r_refdef or vid change
void R_AddEfrags (entity_t *ent);
void R_AddEfrags (mod_brush_t *, entity_t *ent);
void R_RemoveEfrags (entity_t *ent);
void R_NewMap (model_t *worldmodel, model_t **models, int num_models);

View File

@ -33,6 +33,8 @@
#include "QF/model.h"
#include "QF/render.h"
#include "QF/vid.h"
#include "QF/simd/mat4f.h"
#include "QF/simd/vec4f.h"
#include "r_shared.h"
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
@ -136,8 +138,8 @@ extern qboolean r_cache_thrash; // set if thrashing the surface cache
extern qboolean insubmodel;
extern vec3_t r_worldmodelorg;
extern mat4_t glsl_projection;
extern mat4_t glsl_view;
extern mat4f_t glsl_projection;
extern mat4f_t glsl_view;
void R_SetFrustum (void);
@ -180,8 +182,9 @@ void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist);
void R_StepActiveU (edge_t *pedge);
void R_RemoveEdges (edge_t *pedge);
void R_AddTexture (texture_t *tex);
struct vulkan_ctx_s;
void R_ClearTextures (void);
void R_InitSurfaceChains (model_t *model);
void R_InitSurfaceChains (mod_brush_t *brush);
extern void R_Surf8Start (void);
extern void R_Surf8End (void);
@ -302,17 +305,18 @@ void R_ZGraph (void);
void R_PrintAliasStats (void);
void R_PrintTimes (void);
void R_AnimateLight (void);
int R_LightPoint (const vec3_t p);
int R_LightPoint (mod_brush_t *brush, const vec3_t p);
void R_SetupFrame (void);
void R_cshift_f (void);
void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1);
void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip);
void R_RecursiveMarkLights (const vec3_t lightorigin, struct dlight_s *light,
int bit, mnode_t *node);
void R_RecursiveMarkLights (mod_brush_t *brush, const vec3_t lightorigin,
struct dlight_s *light, int bit, mnode_t *node);
void R_MarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit,
model_t *model);
void R_LoadSkys (const char *);
//void Vulkan_R_LoadSkys (const char *, struct vulkan_ctx_s *ctx);
void R_LowFPPrecision (void);
void R_HighFPPrecision (void);
@ -346,7 +350,12 @@ extern byte crosshair_data[];
#define CROSSHAIR_TILEY 2
#define CROSSHAIR_COUNT (CROSSHAIR_TILEX * CROSSHAIR_TILEY)
//NOTE: This is packed 8x8 bitmap data, one byte per scanline, 8 scanlines
////per character. Also, it is NOT the quake font, but the IBM charset.
extern byte font8x8_data[];
struct qpic_s *Draw_CrosshairPic (void);
struct qpic_s *Draw_Font8x8Pic (void);
struct tex_s *R_DotParticleTexture (void);
struct tex_s *R_SparkParticleTexture (void);

49
include/r_scrap.h Normal file
View File

@ -0,0 +1,49 @@
/*
r_scrap.h
Renderer agnostic scrap management
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2021/1/12
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef __r_scrap_h
#define __r_scrap_h
typedef struct rscrap_s {
struct vrect_s *free_rects; ///< linked list of free areas
struct vrect_s *rects; ///< linked list of allocated rects
int width; ///< overall width of scrap
int height; ///< overall height of scrap
} rscrap_t;
void R_ScrapInit (rscrap_t *scrap, int width, int height);
void R_ScrapDelete (rscrap_t *scrap);
struct vrect_s *R_ScrapAlloc (rscrap_t *scrap, int width, int height);
void R_ScrapFree (rscrap_t *scrap, struct vrect_s *rect);
void R_ScrapClear (rscrap_t *scrap);
size_t R_ScrapArea (rscrap_t *scrap) __attribute__((pure));
void R_ScrapDump (rscrap_t *scrap);
#endif//__r_scrap_h

View File

@ -64,8 +64,6 @@ extern struct qpic_s *scr_turtle;
extern int clearconsole;
extern int clearnotify;
extern viddef_t vid; // global video state
extern vrect_t *pconupdate;
extern vrect_t scr_vrect;

View File

@ -58,7 +58,8 @@ typedef struct sfxstream_s sfxstream_t;
\param buffer sound data
\param count number of frames to paint
*/
typedef void sfxpaint_t (int, channel_t *, float *, unsigned);
typedef void sfxpaint_t (int offset, channel_t *ch, float *buffer,
unsigned count);
/** Represent a sound sample in the mixer.
*/

20
include/vid_gl.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef __vid_gl_h
#define __vid_gl_h
// GLXContext is a pointer to opaque data
typedef struct __GLXcontextRec *GLXContext;
typedef struct gl_ctx_s {
GLXContext context;
void (*load_gl) (void);
void (*choose_visual) (struct gl_ctx_s *ctx);
void (*create_context) (struct gl_ctx_s *ctx);
void (*init_gl) (void);
void *(*get_proc_address) (const char *name, qboolean crit);
void (*end_rendering) (void);
} gl_ctx_t;
extern gl_ctx_t *gl_ctx;
extern gl_ctx_t *glsl_ctx;
#endif//__vid_gl_h

View File

@ -4,6 +4,21 @@
#include "QF/vid.h"
#include "QF/plugin/vid_render.h"
typedef struct vid_internal_s {
int (*surf_cache_size) (int width, int height);
void (*flush_caches) (void);
void (*init_caches) (void *cache, int size);
void (*do_screen_buffer) (void);
void (*set_palette) (const byte *palette);
void (*choose_visual) (void);
void (*create_context) (void);
struct gl_ctx_s *(*gl_context) (void);
struct sw_ctx_s *(*sw_context) (void);
struct vulkan_ctx_s *(*vulkan_context) (void);
} vid_internal_t;
extern struct cvar_s *vid_fullscreen;
extern struct cvar_s *vid_system_gamma;
extern struct cvar_s *vid_gamma;
@ -16,11 +31,9 @@ void VID_InitGamma (unsigned char *);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);
void VID_Update (vrect_t *rects);
void VID_LockBuffer (void);
void VID_UnlockBuffer (void);
void VID_InitBuffers (void);
void VID_MakeColormaps (void);
#endif//__vid_internal_h

18
include/vid_sw.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __vid_sw_h
#define __vid_sw_h
// GLXContext is a pointer to opaque data
typedef struct __GLXcontextRec *GLXContext;
struct vrect_s;
typedef struct sw_ctx_s {
GLXContext context;
void (*choose_visual) (struct sw_ctx_s *ctx);
void (*create_context) (struct sw_ctx_s *ctx);
void (*set_palette) (const byte *palette);
void (*update) (struct vrect_s *rects);
} sw_ctx_t;
extern sw_ctx_t *sw_ctx;
extern sw_ctx_t *sw32_ctx;
#endif//__vid_sw_h

108
include/vid_vulkan.h Normal file
View File

@ -0,0 +1,108 @@
#ifndef __vid_vulkan_h
#define __vid_vulkan_h
#ifndef VK_NO_PROTOTYPES
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
#include "QF/darray.h"
typedef struct vulkan_frame_s {
VkFramebuffer framebuffer;
VkFence fence;
VkSemaphore imageAvailableSemaphore;
VkSemaphore renderDoneSemaphore;
VkCommandBuffer cmdBuffer;
int cmdSetCount;
struct qfv_cmdbufferset_s *cmdSets;
} vulkan_frame_t;
typedef struct vulkan_matrices_s {
VkBuffer buffer_2d;
VkBuffer buffer_3d;
VkDeviceMemory memory;
float *projection_2d;
float *projection_3d;
float *view_3d;
float *sky_3d;
} vulkan_matrices_t;
typedef struct vulkan_frameset_s
DARRAY_TYPE (vulkan_frame_t) vulkan_frameset_t;
typedef struct clearvalueset_s
DARRAY_TYPE (VkClearValue) clearvalueset_t;
typedef struct vulkan_ctx_s {
void (*load_vulkan) (struct vulkan_ctx_s *ctx);
void (*unload_vulkan) (struct vulkan_ctx_s *ctx);
const char **required_extensions;
struct vulkan_presentation_s *presentation;
int (*get_presentation_support) (struct vulkan_ctx_s *ctx,
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex);
void (*choose_visual) (struct vulkan_ctx_s *ctx);
void (*create_window) (struct vulkan_ctx_s *ctx);
VkSurfaceKHR (*create_surface) (struct vulkan_ctx_s *ctx);
struct va_ctx_s *va_ctx;
struct qfv_instance_s *instance;
struct qfv_device_s *device;
struct qfv_swapchain_s *swapchain;
VkSampleCountFlagBits msaaSamples; // FIXME not here?
struct hashlink_s *hashlinks; //FIXME want per thread
VkSurfaceKHR surface; //FIXME surface = window, so "contains" swapchain
struct plitem_s *pipelineDef;
struct plitem_s *renderpassDef;
VkRenderPass renderpass;
clearvalueset_t *clearValues;
struct qfv_imageset_s *attachment_images;
struct qfv_imageviewset_s *attachment_views;
VkDeviceMemory attachmentMemory;
uint32_t swapImageIndex;
struct qfv_framebufferset_s *framebuffers;
struct hashtab_s *shaderModules;
struct hashtab_s *setLayouts;
struct hashtab_s *pipelineLayouts;
struct hashtab_s *descriptorPools;
struct hashtab_s *samplers;
struct hashtab_s *images;
struct hashtab_s *imageViews;
struct hashtab_s *renderpasses;
struct aliasctx_s *alias_context;
struct bspctx_s *bsp_context;
struct drawctx_s *draw_context;
struct lightingctx_s *lighting_context;
struct composectx_s *compose_context;
VkBuffer quad_buffer;
VkDeviceMemory quad_memory;
VkCommandPool cmdpool;
VkCommandBuffer cmdbuffer;
VkFence fence; // for ctx->cmdbuffer only
struct qfv_stagebuf_s *staging;
VkPipeline pipeline;
size_t curFrame;
vulkan_frameset_t frames;
struct qfv_tex_s *default_black;
struct qfv_tex_s *default_white;
struct qfv_tex_s *default_magenta;
// projection and view matrices (model is push constant)
vulkan_matrices_t matrices;
#define EXPORTED_VULKAN_FUNCTION(fname) PFN_##fname fname;
#define GLOBAL_LEVEL_VULKAN_FUNCTION(fname) PFN_##fname fname;
#include "QF/Vulkan/funclist.h"
} vulkan_ctx_t;
#endif//__vid_vulkan_h

View File

@ -7,6 +7,7 @@ include libs/image/Makemodule.am
include libs/models/Makemodule.am
include libs/video/Makemodule.am
include libs/console/Makemodule.am
include libs/entity/Makemodule.am
include libs/net/Makemodule.am
include libs/client/Makemodule.am

View File

@ -69,8 +69,8 @@ CDAudio_Resume (void)
cdmodule->functions->cd->pCDAudio_Resume ();
}
VISIBLE void
CDAudio_Shutdown (void)
static void
CDAudio_shutdown (void *data)
{
if (cdmodule)
cdmodule->functions->general->p_Shutdown ();
@ -93,6 +93,8 @@ CD_f (void)
VISIBLE int
CDAudio_Init (void)
{
Sys_RegisterShutdown (CDAudio_shutdown, 0);
PI_RegisterPlugins (cd_plugin_list);
cd_plugin = Cvar_Get ("cd_plugin", CD_DEFAULT, CVAR_ROM, NULL,
"CD Plugin to use");

Some files were not shown because too many files have changed in this diff Show More