Add the vkQuake2 Vulkan renderer ported to YQ2.

This was first developed in a feature branch in the main yquake2 repo.
It was merged into master in early 2021, but the experiences of the
following month showed that it is not ready for prime time. There're
glitches with 3rd party assets, restarts are still shaky, etc. Having
the code in a separate repo allows us to:

  * Release Vulkan independent if YQ2.
  * Give commit access to contributors interested in Vulkan.

This code is the same as in yquake/yquake2 ecdf912713eef55d6c5d5a772259b44e3fc232c4.
This commit is contained in:
Yamagi 2021-05-25 15:29:22 +02:00
parent 6d795b68a2
commit 4b536019c3
95 changed files with 37267 additions and 0 deletions

396
LICENSE Normal file
View file

@ -0,0 +1,396 @@
The Yamagi Quake II Vulkan renderer lib is based upon vkQuake2 and
ontains software developed by multiple individuals, projects and
organisations. Following is a list of this software and copys of each
license:
- Quake II
- stb_image.h, stb_image_write.h
===============================================================================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
===============================================================================
stb single-file public domain libraries
(stb_image.h, stb_image_resize.h)
https://github.com/nothings/stb/
Dual-Licensed: Public Domain (Unlicense) or MIT License:
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
===============================================================================

362
Makefile Normal file
View file

@ -0,0 +1,362 @@
# ----------------------------------------------------- #
# Makefile for the Vulkan renderer lib for Quake II #
# #
# Just type "make" to compile the #
# - Vulkan renderer lib (ref_vk.so / rev_vk.dll) #
# #
# Dependencies: #
# - SDL2 #
# - Vulkan headers #
# #
# Platforms: #
# - FreeBSD #
# - Linux #
# - Mac OS X #
# - OpenBSD #
# - Windows #
# ----------------------------------------------------- #
# Detect the OS
ifdef SystemRoot
YQ2_OSTYPE ?= Windows
else
YQ2_OSTYPE ?= $(shell uname -s)
endif
# Special case for MinGW
ifneq (,$(findstring MINGW,$(YQ2_OSTYPE)))
YQ2_OSTYPE := Windows
endif
# Detect the architecture
ifeq ($(YQ2_OSTYPE), Windows)
ifdef MINGW_CHOST
ifeq ($(MINGW_CHOST), x86_64-w64-mingw32)
YQ2_ARCH ?= x86_64
else # i686-w64-mingw32
YQ2_ARCH ?= i386
endif
else # windows, but MINGW_CHOST not defined
ifdef PROCESSOR_ARCHITEW6432
# 64 bit Windows
YQ2_ARCH ?= $(PROCESSOR_ARCHITEW6432)
else
# 32 bit Windows
YQ2_ARCH ?= $(PROCESSOR_ARCHITECTURE)
endif
endif # windows but MINGW_CHOST not defined
else
# Normalize some abiguous YQ2_ARCH strings
YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
endif
# On Windows / MinGW $(CC) is undefined by default.
ifeq ($(YQ2_OSTYPE),Windows)
CC ?= gcc
endif
# Detect the compiler
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang
COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
else ifeq ($(shell $(CC) -v 2>&1 | grep -c -E "(gcc version|gcc-Version)"), 1)
COMPILER := gcc
COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
else
COMPILER := unknown
endif
# ASAN includes DEBUG
ifdef ASAN
DEBUG=1
endif
# UBSAN includes DEBUG
ifdef UBSAN
DEBUG=1
endif
# ----------
# Base CFLAGS. These may be overridden by the environment.
# Highest supported optimizations are -O2, higher levels
# will likely break this crappy code.
ifdef DEBUG
CFLAGS ?= -O0 -g -Wall -pipe
ifdef ASAN
CFLAGS += -fsanitize=address
endif
ifdef UBSAN
CFLAGS += -fsanitize=undefined
endif
else
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
endif
# Always needed are:
# -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible
# to get it there...
# -fwrapv for defined integer wrapping. MSVC6 did this
# and the game code requires it.
# -fvisibility=hidden to keep symbols hidden. This is
# mostly best practice and not really necessary.
override CFLAGS += -std=gnu99 -fno-strict-aliasing -fwrapv -fvisibility=hidden
# -MMD to generate header dependencies. Unsupported by
# the Clang shipped with OS X.
ifneq ($(YQ2_OSTYPE), Darwin)
override CFLAGS += -MMD
endif
# OS X architecture.
ifeq ($(YQ2_OSTYPE), Darwin)
override CFLAGS += -arch $(YQ2_ARCH)
endif
# ----------
# Switch of some annoying warnings.
ifeq ($(COMPILER), clang)
# -Wno-missing-braces because otherwise clang complains
# about totally valid 'vec3_t bla = {0}' constructs.
CFLAGS += -Wno-missing-braces
else ifeq ($(COMPILER), gcc)
# GCC 8.0 or higher.
ifeq ($(shell test $(COMPILERVER) -ge 80000; echo $$?),0)
# -Wno-format-truncation and -Wno-format-overflow
# because GCC spams about 50 false positives.
CFLAGS += -Wno-format-truncation -Wno-format-overflow
endif
endif
# ----------
# Defines the operating system and architecture
override CFLAGS += -DYQ2OSTYPE=\"$(YQ2_OSTYPE)\" -DYQ2ARCH=\"$(YQ2_ARCH)\"
# ----------
# For reproduceable builds, look here for details:
# https://reproducible-builds.org/specs/source-date-epoch/
ifdef SOURCE_DATE_EPOCH
CFLAGS += -DBUILD_DATE=\"$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +"%b %_d %Y" | sed -e 's/ /\\ /g')\"
endif
# ----------
# Using the default x87 float math on 32bit x86 causes rounding trouble
# -ffloat-store could work around that, but the better solution is to
# just enforce SSE - every x86 CPU since Pentium3 supports that
# and this should even improve the performance on old CPUs
ifeq ($(YQ2_ARCH), i386)
override CFLAGS += -msse -mfpmath=sse
endif
# Force SSE math on x86_64. All sane compilers should do this
# anyway, just to protect us from broken Linux distros.
ifeq ($(YQ2_ARCH), x86_64)
override CFLAGS += -mfpmath=sse
endif
# ----------
# Extra CFLAGS for SDL.
SDLCFLAGS := $(shell sdl2-config --cflags)
# ----------
# Base include path.
ifeq ($(YQ2_OSTYPE),Linux)
INCLUDE ?= -I/usr/include
else ifeq ($(YQ2_OSTYPE),FreeBSD)
INCLUDE ?= -I/usr/local/include
else ifeq ($(YQ2_OSTYPE),NetBSD)
INCLUDE ?= -I/usr/X11R7/include -I/usr/pkg/include
else ifeq ($(YQ2_OSTYPE),OpenBSD)
INCLUDE ?= -I/usr/local/include
else ifeq ($(YQ2_OSTYPE),Windows)
INCLUDE ?= -I/usr/include
endif
# ----------
# Base LDFLAGS. This is just the library path.
ifeq ($(YQ2_OSTYPE),Linux)
LDFLAGS ?= -L/usr/lib
else ifeq ($(YQ2_OSTYPE),FreeBSD)
LDFLAGS ?= -L/usr/local/lib
else ifeq ($(YQ2_OSTYPE),NetBSD)
LDFLAGS ?= -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
else ifeq ($(YQ2_OSTYPE),OpenBSD)
LDFLAGS ?= -L/usr/local/lib
else ifeq ($(YQ2_OSTYPE),Windows)
LDFLAGS ?= -L/usr/lib
endif
# Link address sanitizer if requested.
ifdef ASAN
LDFLAGS += -fsanitize=address
endif
# Link undefined behavior sanitizer if requested.
ifdef UBSAN
LDFLAGS += -fsanitize=undefined
endif
# Required libraries.
ifeq ($(YQ2_OSTYPE),Linux)
override LDFLAGS += -lm -ldl -rdynamic
else ifeq ($(YQ2_OSTYPE),FreeBSD)
override LDFLAGS += -lm
else ifeq ($(YQ2_OSTYPE),NetBSD)
override LDFLAGS += -lm
else ifeq ($(YQ2_OSTYPE),OpenBSD)
override LDFLAGS += -lm
else ifeq ($(YQ2_OSTYPE),Windows)
override LDFLAGS += -lws2_32 -lwinmm -static-libgcc
else ifeq ($(YQ2_OSTYPE), Darwin)
override LDFLAGS += -arch $(YQ2_ARCH)
else ifeq ($(YQ2_OSTYPE), Haiku)
override LDFLAGS += -lm
endif
ifneq ($(YQ2_OSTYPE), Darwin)
ifneq ($(YQ2_OSTYPE), OpenBSD)
# For some reason the OSX & OpenBSD
# linker doesn't support this...
override LDFLAGS += -Wl,--no-undefined
endif
endif
# It's a shared library.
override LDFLAGS += -shared
# ----------
# Extra LDFLAGS for SDL
ifeq ($(YQ2_OSTYPE), Darwin)
SDLLDFLAGS := -lSDL2
else # not Darwin
SDLLDFLAGS := $(shell sdl2-config --libs)
endif # Darwin
# The renderer libs don't need libSDL2main, libmingw32 or -mwindows.
ifeq ($(YQ2_OSTYPE), Windows)
DLL_SDLLDFLAGS = $(subst -mwindows,,$(subst -lmingw32,,$(subst -lSDL2main,,$(SDLLDFLAGS))))
endif
# ----------
# When make is invoked by "make VERBOSE=1" print
# the compiler and linker commands.
ifdef VERBOSE
Q :=
else
Q := @
endif
# ----------
# Phony targets
.PHONY : all clean xatrix
# ----------
# Builds everything
all: ref_vk
# ----------
# Cleanup
clean:
@echo "===> CLEAN"
${Q}rm -Rf build release
# ----------
ifeq ($(YQ2_OSTYPE), Windows)
ref_vk:
@echo "===> Building ref_vk.dll"
${Q}mkdir -p release
$(MAKE) release/ref_vk.dll
else
ref_vk:
@echo "===> Building ref_vk.so"
${Q}mkdir -p release
$(MAKE) release/ref_vk.so
release/ref_vk.so : CFLAGS += -fPIC
endif
build/%.o: %.c
@echo "===> CC $<"
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $<
# ----------
REFVK_OBJS_ := \
src/vk/vk_buffer.o \
src/vk/vk_cmd.o \
src/vk/vk_common.o \
src/vk/vk_device.o \
src/vk/vk_draw.o \
src/vk/vk_image.o \
src/vk/vk_light.o \
src/vk/vk_mesh.o \
src/vk/vk_model.o \
src/vk/vk_pipeline.o \
src/vk/vk_rmain.o \
src/vk/vk_rmisc.o \
src/vk/vk_rsurf.o \
src/vk/vk_shaders.o \
src/vk/vk_swapchain.o \
src/vk/vk_validation.o \
src/vk/vk_warp.o \
src/vk/vk_util.o \
src/vk/volk/volk.o \
src/files/pcx.o \
src/files/stb.o \
src/files/wal.o \
src/files/pvs.o \
src/common/shared.o \
src/common/md4.o
ifeq ($(YQ2_OSTYPE), Windows)
REFVK_OBJS_ += \
src/backends/hunk_windows.o
else # not Windows
REFVK_OBJS_ += \
src/backends/hunk_unix.o
endif
# ----------
# Rewrite pathes to our object directory
REFVK_OBJS = $(patsubst %,build/%,$(REFVK_OBJS_))
# ----------
# Generate header dependencies
REFVK_DEPS= $(REFVK_OBJS:.o=.d)
# ----------
# Suck header dependencies in
-include $(REFVK_DEPS)
# ----------
# release/ref_vk.so
ifeq ($(YQ2_OSTYPE), Windows)
release/ref_vk.dll : $(REFVK_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(REFVK_OBJS) $(LDFLAGS) $(DLL_SDLLDFLAGS) -o $@
else
release/ref_vk.so : $(REFVK_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(REFVK_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
endif
# ----------

111
README.md Normal file
View file

@ -0,0 +1,111 @@
# Vulkan Renderer Library for Yamagi Quake II
This is the vkQuake2 vulkan renderer library ported to Yamagi Quake II.
## Compilation
You'll need:
* clang or gcc
* GNU Make
* SDL2 with `sdl2-config`.
* vulkan-headers.
Type `make` to compile the library. If the compilation is successfull,
the library can be found under *release/ref_vk.dll* (Windows) or
*release/ref_vk.so* (unixoid systems).
## Usage
Copy the library next to your Yamagi Quake II executable. You can select
Vulkan through the video menu or by cvar with `vid_renderer vk` followed
by a `vid_restart`.
## Console Variables
* **vk_validation**: Toggle validation layers:
* `0` - disabled (default in Release)
* `1` - only errors and warnings
* `2` - best-practices validation
* **vk_strings**: Print some basic Vulkan/GPU information.
* **vk_mem**: Print dynamic vertex/index/uniform/triangle fan buffer
memory usage statistics.
* **vk_device**: Specify index of the preferred Vulkan device on systems
with multiple GPUs:
* `-1` - prefer first DISCRETE\_GPU (default)
* `0..n` - use device #n (full list of devices is returned by
`vk_strings` command)
* **vk_sampleshading**: Toggle sample shading for MSAA. (default: `1`)
* **vk_flashblend**: Toggle the blending of lights onto the environment.
(default: `0`)
* **vk_polyblend**: Blend fullscreen effects: blood, powerups etc.
(default: `1`)
* **vk_skymip**: Toggle the usage of mipmap information for the sky
graphics. (default: `0`)
* **vk_finish**: Inserts a `vkDeviceWaitIdle()` call on frame render
start (default: `0`). Don't use this, it's there just for the sake of
having a `gl_finish` equivalent!
* **vk_custom_particles**: Toggle particles type:
* `0` - textured triangles for particle rendering
* `1` - between using POINT\_LIST (default)
* `2` - textured square for particle rendering
* **vk_particle_size**: Rendered particle size. (default: `40`)
* **vk_particle_att_a**: Intensity of the particle A attribute.
(default: `0.01`)
* **vk_particle_att_b**: Intensity of the particle B attribute.
(default: `0`)
* **vk_particle_att_c**: Intensity of the particle C attribute.
(default: `0.01`)
* **vk_particle_min_size**: The minimum size of a rendered particle.
(default: `2`)
* **vk_particle_max_size**: The maximum size of a rendered particle.
(default: `40`)
* **vk_picmip**: Shrink factor for the textures. (default: `0`)
* **vk_pixel_size**: Pixel size when rendering the world, used to simulate
lower screen resolutions. The value represents the length, in pixels, of the
side of each pixel block. For example, with size 2 pixels are 2x2 squares,
and at 1600x1200 the image is effectively an upscaled 800x600 image.
(default: `1`)
* **vk_dynamic**: Use dynamic lighting. (default: `1`)
* **vk_showtris**: Display mesh triangles. (default: `0`)
* **vk_lightmap**: Display lightmaps. (default: `0`)
* **vk_postprocess**: Toggle additional color/gamma correction.
(default: `1`)
* **vk_mip_nearfilter**: Use nearest-neighbor filtering for mipmaps.
(default: `0`)
* **vk_texturemode**: Change current texture filtering mode:
* `VK_NEAREST` - nearest-neighbor interpolation, no mipmaps
* `VK_LINEAR` - linear interpolation, no mipmaps
* `VK_MIPMAP_NEAREST` - nearest-neighbor interpolation with mipmaps
* `VK_MIPMAP_LINEAR` - linear interpolation with mipmaps (default)
* **vk_lmaptexturemode**: Same as `vk_texturemode` but applied to
lightmap textures.
* **vk_underwater**: Warp the scene if underwater. Set to `0` to disable
the effect. Defaults to `1`.

24
shaders/basic.frag Normal file
View file

@ -0,0 +1,24 @@
#version 450
layout(push_constant) uniform PushConstant
{
// vertex shader has 'mat4 vpMatrix;' at begin.
layout(offset = 68) float gamma;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(location = 0) in vec2 texCoord;
layout(location = 1) in vec4 color;
layout(location = 2) in float aTreshold;
layout(location = 0) out vec4 fragmentColor;
void main()
{
fragmentColor = texture(sTexture, texCoord) * color;
if(fragmentColor.a < aTreshold)
discard;
fragmentColor = vec4(pow(fragmentColor.rgb, vec3(pc.gamma)), fragmentColor.a);
}

30
shaders/basic.vert Normal file
View file

@ -0,0 +1,30 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
// normalized offset and scale
layout(set = 1, binding = 0) uniform imageTransform
{
vec2 offset;
vec2 scale;
vec2 uvOffset;
vec2 uvScale;
} it;
layout(location = 0) in vec2 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
vec2 vPos = inVertex.xy * it.scale - (vec2(1.0) - it.scale);
gl_Position = vec4(vPos + it.offset * 2.0, 0.0, 1.0);
texCoord = inTexCoord.xy * it.uvScale + it.uvOffset;
color = vec4(1.0, 1.0, 1.0, 1.0);
aTreshold = 0.666;
}

View file

@ -0,0 +1,10 @@
#version 450
layout(location = 0) in vec4 color;
layout(location = 0) out vec4 fragmentColor;
void main()
{
fragmentColor = color;
}

View file

@ -0,0 +1,24 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
// normalized offset and scale
layout(set = 0, binding = 0) uniform imageTransform
{
vec2 offset;
vec2 scale;
vec4 color;
} it;
layout(location = 0) in vec2 inVertex;
layout(location = 0) out vec4 color;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
vec2 vPos = inVertex.xy * it.scale - (vec2(1.0) - it.scale);
gl_Position = vec4(vPos + it.offset * 2.0, 0.0, 1.0);
color = it.color;
}

25
shaders/beam.vert Normal file
View file

@ -0,0 +1,25 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(push_constant) uniform PushConstant
{
mat4 mvpMatrix;
} pc;
layout(binding = 0) uniform UniformBufferObject
{
vec4 color;
} ubo;
layout(location = 0) out vec4 color;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
color = ubo.color;
}

21
shaders/d_light.vert Normal file
View file

@ -0,0 +1,21 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec3 inColor;
layout(binding = 0) uniform UniformBufferObject
{
mat4 mvpMatrix;
} ubo;
layout(location = 0) out vec4 color;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = ubo.mvpMatrix * vec4(inVertex, 1.0);
color = vec4(inColor, 1.0);
}

17
shaders/model.frag Normal file
View file

@ -0,0 +1,17 @@
#version 450
layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(location = 0) in vec4 color;
layout(location = 1) in vec2 texCoord;
layout(location = 2) in flat int textured;
layout(location = 0) out vec4 fragmentColor;
void main()
{
if(textured != 0)
fragmentColor = texture(sTexture, texCoord) * clamp(color, 0.0, 1.0);
else
fragmentColor = color;
}

32
shaders/model.vert Normal file
View file

@ -0,0 +1,32 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec4 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(set = 1, binding = 0) uniform UniformBufferObject
{
mat4 model;
int textured;
} ubo;
layout(location = 0) out vec4 color;
layout(location = 1) out vec2 texCoord;
layout(location = 2) out int textured;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
color = inColor;
texCoord = inTexCoord;
textured = ubo.textured;
}

26
shaders/nullmodel.vert Normal file
View file

@ -0,0 +1,26 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec3 inColor;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(binding = 0) uniform UniformBufferObject
{
mat4 model;
} ubo;
layout(location = 0) out vec4 color;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
color = vec4(inColor, 1.0);
}

26
shaders/particle.vert Normal file
View file

@ -0,0 +1,26 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec4 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 mvpMatrix;
} pc;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
texCoord = inTexCoord;
color = inColor;
aTreshold = 0.5;
}

View file

@ -0,0 +1,14 @@
#version 450
layout(location = 0) in vec4 color;
layout(location = 0) out vec4 fragmentColor;
void main()
{
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
if(dot(cxy, cxy) > 1.0)
discard;
fragmentColor = color;
}

View file

@ -0,0 +1,37 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec4 inColor;
layout(push_constant) uniform PushConstant
{
mat4 mvpMatrix;
} pc;
layout(binding = 0) uniform UniformBufferObject
{
float pointSize;
float pointScale;
float minPointSize;
float maxPointSize;
float att_a;
float att_b;
float att_c;
} ubo;
layout(location = 0) out vec4 color;
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
void main() {
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
float dist_atten = ubo.pointScale / (ubo.att_a + ubo.att_b * gl_Position.w + ubo.att_c * gl_Position.w * gl_Position.w);
gl_PointSize = clamp(ubo.pointScale * ubo.pointSize * sqrt(dist_atten), ubo.minPointSize, ubo.maxPointSize);
color = inColor;
}

30
shaders/polygon.vert Normal file
View file

@ -0,0 +1,30 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 mvpMatrix;
} pc;
layout(set = 1, binding = 0) uniform UniformBufferObject
{
vec4 color;
} ubo;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
texCoord = inTexCoord;
color = ubo.color;
aTreshold = 0.0;
}

17
shaders/polygon_lmap.frag Normal file
View file

@ -0,0 +1,17 @@
#version 450
layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(set = 2, binding = 0) uniform sampler2D sLightmap;
layout(location = 0) in vec2 texCoord;
layout(location = 1) in vec2 texCoordLmap;
layout(location = 2) in float viewLightmaps;
layout(location = 0) out vec4 fragmentColor;
void main()
{
vec4 color = texture(sTexture, texCoord);
vec4 light = texture(sLightmap, texCoordLmap);
fragmentColor = (1.0 - viewLightmaps) * color * light + viewLightmaps * light;
}

32
shaders/polygon_lmap.vert Normal file
View file

@ -0,0 +1,32 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(location = 2) in vec2 inTexCoordLmap;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(set = 1, binding = 0) uniform UniformBufferObject
{
mat4 model;
float viewLightmaps;
} ubo;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec2 texCoordLmap;
layout(location = 2) out float viewLightmaps;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
texCoord = inTexCoord;
texCoordLmap = inTexCoordLmap;
viewLightmaps = ubo.viewLightmaps;
}

34
shaders/polygon_warp.vert Normal file
View file

@ -0,0 +1,34 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(set = 1, binding = 0) uniform UniformBufferObject
{
mat4 model;
vec4 color;
float time;
float scroll;
} ubo;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
texCoord = inTexCoord + vec2(sin(2.0 * ubo.time + inTexCoord.y * 3.28), sin(2.0 * ubo.time + inTexCoord.x * 3.28)) * 0.05;
texCoord.x += ubo.scroll;
color = ubo.color;
aTreshold = 0.0;
}

33
shaders/postprocess.frag Normal file
View file

@ -0,0 +1,33 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(push_constant) uniform PushConstant
{
layout(offset = 68) float postprocess;
layout(offset = 72) float gamma;
layout(offset = 76) float scrWidth;
layout(offset = 80) float scrHeight;
layout(offset = 84) float offsetX;
layout(offset = 88) float offsetY;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragmentColor;
void main()
{
vec2 unnormTexCoord = texCoord * vec2(pc.scrWidth, pc.scrHeight) + vec2(pc.offsetX, pc.offsetY);
// apply any additional world-only postprocessing effects here (if enabled)
if (pc.postprocess > 0.0)
{
//gamma + color intensity bump
fragmentColor = vec4(pow(textureLod(sTexture, unnormTexCoord, 0.0).rgb * 1.5, vec3(pc.gamma)), 1.0);
}
else
{
fragmentColor = textureLod(sTexture, unnormTexCoord, 0.0);
}
}

17
shaders/postprocess.vert Normal file
View file

@ -0,0 +1,17 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
// rendering a fullscreen quad (which is actually just a huge triangle)
// source: https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/
out gl_PerVertex {
vec4 gl_Position;
};
layout(location = 0) out vec2 texCoord;
void main()
{
texCoord = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(texCoord * 2.0f + -1.0f, 0.0f, 1.0f);
}

25
shaders/shaders.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
glslangValidator --variable-name basic_vert_spv -V basic.vert -o ../src/vk/spirv/basic_vert.c
glslangValidator --variable-name basic_frag_spv -V basic.frag -o ../src/vk/spirv/basic_frag.c
glslangValidator --variable-name basic_color_quad_vert_spv -V basic_color_quad.vert -o ../src/vk/spirv/basic_color_quad_vert.c
glslangValidator --variable-name basic_color_quad_frag_spv -V basic_color_quad.frag -o ../src/vk/spirv/basic_color_quad_frag.c
glslangValidator --variable-name model_vert_spv -V model.vert -o ../src/vk/spirv/model_vert.c
glslangValidator --variable-name model_frag_spv -V model.frag -o ../src/vk/spirv/model_frag.c
glslangValidator --variable-name nullmodel_vert_spv -V nullmodel.vert -o ../src/vk/spirv/nullmodel_vert.c
glslangValidator --variable-name particle_vert_spv -V particle.vert -o ../src/vk/spirv/particle_vert.c
glslangValidator --variable-name point_particle_vert_spv -V point_particle.vert -o ../src/vk/spirv/point_particle_vert.c
glslangValidator --variable-name point_particle_frag_spv -V point_particle.frag -o ../src/vk/spirv/point_particle_frag.c
glslangValidator --variable-name sprite_vert_spv -V sprite.vert -o ../src/vk/spirv/sprite_vert.c
glslangValidator --variable-name beam_vert_spv -V beam.vert -o ../src/vk/spirv/beam_vert.c
glslangValidator --variable-name skybox_vert_spv -V skybox.vert -o ../src/vk/spirv/skybox_vert.c
glslangValidator --variable-name d_light_vert_spv -V d_light.vert -o ../src/vk/spirv/d_light_vert.c
glslangValidator --variable-name polygon_vert_spv -V polygon.vert -o ../src/vk/spirv/polygon_vert.c
glslangValidator --variable-name polygon_lmap_vert_spv -V polygon_lmap.vert -o ../src/vk/spirv/polygon_lmap_vert.c
glslangValidator --variable-name polygon_lmap_frag_spv -V polygon_lmap.frag -o ../src/vk/spirv/polygon_lmap_frag.c
glslangValidator --variable-name polygon_warp_vert_spv -V polygon_warp.vert -o ../src/vk/spirv/polygon_warp_vert.c
glslangValidator --variable-name shadows_vert_spv -V shadows.vert -o ../src/vk/spirv/shadows_vert.c
glslangValidator --variable-name postprocess_vert_spv -V postprocess.vert -o ../src/vk/spirv/postprocess_vert.c
glslangValidator --variable-name postprocess_frag_spv -V postprocess.frag -o ../src/vk/spirv/postprocess_frag.c
glslangValidator --variable-name world_warp_vert_spv -V world_warp.vert -o ../src/vk/spirv/world_warp_vert.c
glslangValidator --variable-name world_warp_frag_spv -V world_warp.frag -o ../src/vk/spirv/world_warp_frag.c

24
shaders/shadows.vert Normal file
View file

@ -0,0 +1,24 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 0) out vec4 color;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(binding = 0) uniform UniformBufferObject
{
mat4 model;
} ubo;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
color = vec4(0.0, 0.0, 0.0, 0.5);
}

30
shaders/skybox.vert Normal file
View file

@ -0,0 +1,30 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 vpMatrix;
} pc;
layout(set = 1, binding = 0) uniform UniformBufferObject
{
mat4 model;
} ubo;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0);
texCoord = inTexCoord;
color = vec4(1.0, 1.0, 1.0, 1.0);
aTreshold = 0.0;
}

26
shaders/sprite.vert Normal file
View file

@ -0,0 +1,26 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inVertex;
layout(location = 1) in vec2 inTexCoord;
layout(push_constant) uniform PushConstant
{
mat4 mvpMatrix;
float alpha;
} pc;
layout(location = 0) out vec2 texCoord;
layout(location = 1) out vec4 color;
layout(location = 2) out float aTreshold;
out gl_PerVertex {
vec4 gl_Position;
};
void main() {
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
texCoord = inTexCoord;
color = vec4(1.0, 1.0, 1.0, pc.alpha);
aTreshold = 0.0666;
}

55
shaders/world_warp.frag Normal file
View file

@ -0,0 +1,55 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
// Underwater screen warp effect similar to what software renderer provides.
// Pixel size to simulate lower screen resolutions is used to restore world to full screen size.
layout(push_constant) uniform PushConstant
{
layout(offset = 68) float time;
layout(offset = 72) float scale;
layout(offset = 76) float scrWidth;
layout(offset = 80) float scrHeight;
layout(offset = 84) float offsetX;
layout(offset = 88) float offsetY;
layout(offset = 92) float pixelSize;
layout(offset = 96) float refdefX;
layout(offset = 100) float refdefY;
layout(offset = 104) float refdefWidth;
layout(offset = 108) float refdefHeight;
} pc;
layout(set = 0, binding = 0) uniform sampler2D sTexture;
layout(location = 0) out vec4 fragmentColor;
#define PI 3.1415
void main()
{
vec2 scrSize = vec2(pc.scrWidth, pc.scrHeight);
vec2 fragCoord = (gl_FragCoord.xy - vec2(pc.offsetX, pc.offsetY));
vec2 uv = fragCoord / scrSize;
float xMin = pc.refdefX;
float xMax = pc.refdefX + pc.refdefWidth;
float yMin = pc.refdefY;
float yMax = pc.refdefY + pc.refdefHeight;
if (pc.time > 0 && fragCoord.x > xMin && fragCoord.x < xMax && fragCoord.y > yMin && fragCoord.y < yMax)
{
float sx = pc.scale - abs(pc.scrWidth / 2.0 - fragCoord.x) * 2.0 / pc.scrWidth;
float sy = pc.scale - abs(pc.scrHeight / 2.0 - fragCoord.y) * 2.0 / pc.scrHeight;
float xShift = 2.0 * pc.time + uv.y * PI * 10;
float yShift = 2.0 * pc.time + uv.x * PI * 10;
vec2 distortion = vec2(sin(xShift) * sx, sin(yShift) * sy) * 0.00666;
uv += distortion;
}
uv /= pc.pixelSize;
uv = clamp(uv * scrSize, vec2(0.0, 0.0), scrSize - vec2(0.5, 0.5));
fragmentColor = textureLod(sTexture, uv, 0.0);
}

17
shaders/world_warp.vert Normal file
View file

@ -0,0 +1,17 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
out gl_PerVertex {
vec4 gl_Position;
};
void main()
{
vec4 positions[3] = {
vec4(-1.0f, -1.0f, 0.0f, 1.0f),
vec4(3.0f, -1.0f, 0.0f, 1.0f),
vec4(-1.0f, 3.0f, 0.0f, 1.0f)
};
gl_Position = positions[gl_VertexIndex % 3];
}

173
src/backends/hunk_unix.c Normal file
View file

@ -0,0 +1,173 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* This file implements the low level part of the Hunk_* memory system
*
* =======================================================================
*/
/* For mremap() - must be before sys/mman.h include! */
#if defined(__linux__) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
#include <sys/mman.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include "../common/header/common.h"
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <machine/param.h>
#define MAP_ANONYMOUS MAP_ANON
#endif
#if defined(__APPLE__)
#include <sys/types.h>
#define MAP_ANONYMOUS MAP_ANON
#endif
byte *membase;
size_t maxhunksize;
size_t curhunksize;
void *
Hunk_Begin(int maxsize)
{
/* reserve a huge chunk of memory, but don't commit any yet */
/* plus 32 bytes for cacheline */
maxhunksize = maxsize + sizeof(size_t) + 32;
curhunksize = 0;
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
int prot = PROT_READ | PROT_WRITE;
#if defined(MAP_ALIGNED_SUPER)
const size_t hgpagesize = 1UL<<21;
size_t page_size = sysconf(_SC_PAGESIZE);
/* Archs supported has 2MB for super pages size */
if (maxhunksize >= hgpagesize)
{
maxhunksize = (maxhunksize & ~(page_size-1)) + page_size;
flags |= MAP_ALIGNED_SUPER;
}
#endif
#if defined(PROT_MAX)
/* For now it is FreeBSD exclusif but could possibly be extended
to other like DFBSD for example */
prot |= PROT_MAX(prot);
#endif
membase = mmap(0, maxhunksize, prot,
flags, -1, 0);
if ((membase == NULL) || (membase == (byte *)-1))
{
Sys_Error("unable to virtual allocate %d bytes", maxsize);
}
*((size_t *)membase) = curhunksize;
return membase + sizeof(size_t);
}
void *
Hunk_Alloc(int size)
{
byte *buf;
/* round to cacheline */
size = (size + 31) & ~31;
if (curhunksize + size > maxhunksize)
{
Sys_Error("Hunk_Alloc overflow");
}
buf = membase + sizeof(size_t) + curhunksize;
curhunksize += size;
return buf;
}
int
Hunk_End(void)
{
byte *n = NULL;
#if defined(__linux__)
n = (byte *)mremap(membase, maxhunksize, curhunksize + sizeof(size_t), 0);
#elif defined(__NetBSD__)
n = (byte *)mremap(membase, maxhunksize, NULL, curhunksize + sizeof(size_t), 0);
#else
#ifndef round_page
size_t page_size = sysconf(_SC_PAGESIZE);
#define round_page(x) ((((size_t)(x)) + page_size-1) & ~(page_size-1))
#endif
size_t old_size = round_page(maxhunksize);
size_t new_size = round_page(curhunksize + sizeof(size_t));
if (new_size > old_size)
{
/* Can never happen. If it happens something's very wrong. */
n = 0;
}
else if (new_size < old_size)
{
/* Hunk is to big, we need to shrink it. */
n = munmap(membase + new_size, old_size - new_size) + membase;
}
else
{
/* No change necessary. */
n = membase;
}
#endif
if (n != membase)
{
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
}
*((size_t *)membase) = curhunksize + sizeof(size_t);
return curhunksize;
}
void
Hunk_Free(void *base)
{
if (base)
{
byte *m;
m = ((byte *)base) - sizeof(size_t);
if (munmap(m, *((size_t *)m)))
{
Sys_Error("Hunk_Free: munmap failed (%d)", errno);
}
}
}

View file

@ -0,0 +1,97 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Memory handling functions.
*
* =======================================================================
*/
#include <windows.h>
#include "../common/header/common.h"
byte *membase;
int hunkcount;
size_t hunkmaxsize;
size_t cursize;
void *
Hunk_Begin(int maxsize)
{
/* reserve a huge chunk of memory, but don't commit any yet */
/* plus 32 bytes for cacheline */
hunkmaxsize = maxsize + sizeof(size_t) + 32;
cursize = 0;
membase = VirtualAlloc(NULL, hunkmaxsize, MEM_RESERVE, PAGE_NOACCESS);
if (!membase)
{
Sys_Error("VirtualAlloc reserve failed");
}
return (void *)membase;
}
void *
Hunk_Alloc(int size)
{
void *buf;
/* round to cacheline */
size = (size + 31) & ~31;
/* commit pages as needed */
buf = VirtualAlloc(membase, cursize + size, MEM_COMMIT, PAGE_READWRITE);
if (!buf)
{
Sys_Error("VirtualAlloc commit failed.\n");
}
cursize += size;
if (cursize > hunkmaxsize)
{
Sys_Error("Hunk_Alloc overflow");
}
return (void *)(membase + cursize - size);
}
int
Hunk_End(void)
{
hunkcount++;
return cursize;
}
void
Hunk_Free(void *base)
{
if (base)
{
VirtualFree(base, 0, MEM_RELEASE);
}
hunkcount--;
}

840
src/common/header/common.h Normal file
View file

@ -0,0 +1,840 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Prototypes witch are shared between the client, the server and the
* game. This is the main game API, changes here will most likely
* requiere changes to the game ddl.
*
* =======================================================================
*/
#ifndef CO_COMMON_H
#define CO_COMMON_H
#include "shared.h"
#include "crc.h"
#define YQ2VERSION "8.00pre"
#define BASEDIRNAME "baseq2"
#ifndef YQ2OSTYPE
#error YQ2OSTYPE should be defined by the build system
#endif
#ifndef YQ2ARCH
#error YQ2ARCH should be defined by the build system
#endif
#ifndef BUILD_DATE
#define BUILD_DATE __DATE__
#endif
#ifdef _WIN32
#define CFGDIR "YamagiQ2"
#else
#define CFGDIR ".yq2"
#endif
/* ================================================================== */
typedef struct sizebuf_s
{
qboolean allowoverflow; /* if false, do a Com_Error */
qboolean overflowed; /* set to true if the buffer size failed */
byte *data;
int maxsize;
int cursize;
int readcount;
} sizebuf_t;
void SZ_Init(sizebuf_t *buf, byte *data, int length);
void SZ_Clear(sizebuf_t *buf);
void *SZ_GetSpace(sizebuf_t *buf, int length);
void SZ_Write(sizebuf_t *buf, void *data, int length);
void SZ_Print(sizebuf_t *buf, char *data); /* strcats onto the sizebuf */
/* ================================================================== */
struct usercmd_s;
struct entity_state_s;
void MSG_WriteChar(sizebuf_t *sb, int c);
void MSG_WriteByte(sizebuf_t *sb, int c);
void MSG_WriteShort(sizebuf_t *sb, int c);
void MSG_WriteLong(sizebuf_t *sb, int c);
void MSG_WriteFloat(sizebuf_t *sb, float f);
void MSG_WriteString(sizebuf_t *sb, char *s);
void MSG_WriteCoord(sizebuf_t *sb, float f);
void MSG_WritePos(sizebuf_t *sb, vec3_t pos);
void MSG_WriteAngle(sizebuf_t *sb, float f);
void MSG_WriteAngle16(sizebuf_t *sb, float f);
void MSG_WriteDeltaUsercmd(sizebuf_t *sb, struct usercmd_s *from,
struct usercmd_s *cmd);
void MSG_WriteDeltaEntity(struct entity_state_s *from,
struct entity_state_s *to, sizebuf_t *msg,
qboolean force, qboolean newentity);
void MSG_WriteDir(sizebuf_t *sb, vec3_t vector);
void MSG_BeginReading(sizebuf_t *sb);
int MSG_ReadChar(sizebuf_t *sb);
int MSG_ReadByte(sizebuf_t *sb);
int MSG_ReadShort(sizebuf_t *sb);
int MSG_ReadLong(sizebuf_t *sb);
float MSG_ReadFloat(sizebuf_t *sb);
char *MSG_ReadString(sizebuf_t *sb);
char *MSG_ReadStringLine(sizebuf_t *sb);
float MSG_ReadCoord(sizebuf_t *sb);
void MSG_ReadPos(sizebuf_t *sb, vec3_t pos);
float MSG_ReadAngle(sizebuf_t *sb);
float MSG_ReadAngle16(sizebuf_t *sb);
void MSG_ReadDeltaUsercmd(sizebuf_t *sb,
struct usercmd_s *from,
struct usercmd_s *cmd);
void MSG_ReadDir(sizebuf_t *sb, vec3_t vector);
void MSG_ReadData(sizebuf_t *sb, void *buffer, int size);
/* ================================================================== */
extern qboolean bigendien;
extern short BigShort(short l);
extern short LittleShort(short l);
extern int BigLong(int l);
extern int LittleLong(int l);
extern float BigFloat(float l);
extern float LittleFloat(float l);
/* ================================================================== */
int COM_Argc(void);
char *COM_Argv(int arg); /* range and null checked */
void COM_ClearArgv(int arg);
int COM_CheckParm(char *parm);
void COM_AddParm(char *parm);
void COM_Init(void);
void COM_InitArgv(int argc, char **argv);
char *CopyString(char *in);
/* ================================================================== */
void Info_Print(char *s);
/* PROTOCOL */
#define PROTOCOL_VERSION 34
/* ========================================= */
#define PORT_MASTER 27900
#define PORT_CLIENT 27901
#define PORT_SERVER 27910
/* ========================================= */
#define UPDATE_BACKUP 16 /* copies of entity_state_t to keep buffered */
#define UPDATE_MASK (UPDATE_BACKUP - 1)
/* server to client */
enum svc_ops_e
{
svc_bad,
/* these ops are known to the game dll */
svc_muzzleflash,
svc_muzzleflash2,
svc_temp_entity,
svc_layout,
svc_inventory,
/* the rest are private to the client and server */
svc_nop,
svc_disconnect,
svc_reconnect,
svc_sound, /* <see code> */
svc_print, /* [byte] id [string] null terminated string */
svc_stufftext, /* [string] stuffed into client's console buffer, should be \n terminated */
svc_serverdata, /* [long] protocol ... */
svc_configstring, /* [short] [string] */
svc_spawnbaseline,
svc_centerprint, /* [string] to put in center of the screen */
svc_download, /* [short] size [size bytes] */
svc_playerinfo, /* variable */
svc_packetentities, /* [...] */
svc_deltapacketentities, /* [...] */
svc_frame
};
/* ============================================== */
/* client to server */
enum clc_ops_e
{
clc_bad,
clc_nop,
clc_move, /* [[usercmd_t] */
clc_userinfo, /* [[userinfo string] */
clc_stringcmd /* [string] message */
};
/* ============================================== */
/* plyer_state_t communication */
#define PS_M_TYPE (1 << 0)
#define PS_M_ORIGIN (1 << 1)
#define PS_M_VELOCITY (1 << 2)
#define PS_M_TIME (1 << 3)
#define PS_M_FLAGS (1 << 4)
#define PS_M_GRAVITY (1 << 5)
#define PS_M_DELTA_ANGLES (1 << 6)
#define PS_VIEWOFFSET (1 << 7)
#define PS_VIEWANGLES (1 << 8)
#define PS_KICKANGLES (1 << 9)
#define PS_BLEND (1 << 10)
#define PS_FOV (1 << 11)
#define PS_WEAPONINDEX (1 << 12)
#define PS_WEAPONFRAME (1 << 13)
#define PS_RDFLAGS (1 << 14)
/*============================================== */
/* user_cmd_t communication */
/* ms and light always sent, the others are optional */
#define CM_ANGLE1 (1 << 0)
#define CM_ANGLE2 (1 << 1)
#define CM_ANGLE3 (1 << 2)
#define CM_FORWARD (1 << 3)
#define CM_SIDE (1 << 4)
#define CM_UP (1 << 5)
#define CM_BUTTONS (1 << 6)
#define CM_IMPULSE (1 << 7)
/*============================================== */
/* a sound without an ent or pos will be a local only sound */
#define SND_VOLUME (1 << 0) /* a byte */
#define SND_ATTENUATION (1 << 1) /* a byte */
#define SND_POS (1 << 2) /* three coordinates */
#define SND_ENT (1 << 3) /* a short 0-2: channel, 3-12: entity */
#define SND_OFFSET (1 << 4) /* a byte, msec offset from frame start */
#define DEFAULT_SOUND_PACKET_VOLUME 1.0
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
/*============================================== */
/* entity_state_t communication */
/* try to pack the common update flags into the first byte */
#define U_ORIGIN1 (1 << 0)
#define U_ORIGIN2 (1 << 1)
#define U_ANGLE2 (1 << 2)
#define U_ANGLE3 (1 << 3)
#define U_FRAME8 (1 << 4) /* frame is a byte */
#define U_EVENT (1 << 5)
#define U_REMOVE (1 << 6) /* REMOVE this entity, don't add it */
#define U_MOREBITS1 (1 << 7) /* read one additional byte */
/* second byte */
#define U_NUMBER16 (1 << 8) /* NUMBER8 is implicit if not set */
#define U_ORIGIN3 (1 << 9)
#define U_ANGLE1 (1 << 10)
#define U_MODEL (1 << 11)
#define U_RENDERFX8 (1 << 12) /* fullbright, etc */
#define U_EFFECTS8 (1 << 14) /* autorotate, trails, etc */
#define U_MOREBITS2 (1 << 15) /* read one additional byte */
/* third byte */
#define U_SKIN8 (1 << 16)
#define U_FRAME16 (1 << 17) /* frame is a short */
#define U_RENDERFX16 (1 << 18) /* 8 + 16 = 32 */
#define U_EFFECTS16 (1 << 19) /* 8 + 16 = 32 */
#define U_MODEL2 (1 << 20) /* weapons, flags, etc */
#define U_MODEL3 (1 << 21)
#define U_MODEL4 (1 << 22)
#define U_MOREBITS3 (1 << 23) /* read one additional byte */
/* fourth byte */
#define U_OLDORIGIN (1 << 24)
#define U_SKIN16 (1 << 25)
#define U_SOUND (1 << 26)
#define U_SOLID (1 << 27)
/* CMD - Command text buffering and command execution */
/*
* Any number of commands can be added in a frame, from several different
* sources. Most commands come from either keybindings or console line
* input, but remote servers can also send across commands and entire text
* files can be execed.
*
* The + command line options are also added to the command buffer.
*
* The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute
* ();
*/
#define EXEC_NOW 0 /* don't return until completed */
#define EXEC_INSERT 1 /* insert at current position, but don't run yet */
#define EXEC_APPEND 2 /* add to end of the command buffer */
void Cbuf_Init(void);
/* allocates an initial text buffer that will grow as needed */
void Cbuf_AddText(char *text);
/* as new commands are generated from the console or keybindings, */
/* the text is added to the end of the command buffer. */
void Cbuf_InsertText(char *text);
/* when a command wants to issue other commands immediately, the text is */
/* inserted at the beginning of the buffer, before any remaining unexecuted */
/* commands. */
void Cbuf_ExecuteText(int exec_when, char *text);
/* this can be used in place of either Cbuf_AddText or Cbuf_InsertText */
void Cbuf_AddEarlyCommands(qboolean clear);
/* adds all the +set commands from the command line */
qboolean Cbuf_AddLateCommands(void);
/* adds all the remaining + commands from the command line */
/* Returns true if any late commands were added, which */
/* will keep the demoloop from immediately starting */
void Cbuf_Execute(void);
/* Pulls off \n terminated lines of text from the command buffer and sends */
/* them through Cmd_ExecuteString. Stops when the buffer is empty. */
/* Normally called once per frame, but may be explicitly invoked. */
/* Do not call inside a command function! */
void Cbuf_CopyToDefer(void);
void Cbuf_InsertFromDefer(void);
/* These two functions are used to defer any pending commands while a map */
/* is being loaded */
/*=================================================================== */
/*
* Command execution takes a null terminated string, breaks it into tokens,
* then searches for a command or variable that matches the first token.
*/
typedef void (*xcommand_t)(void);
void Cmd_Init(void);
void Cmd_AddCommand(char *cmd_name, xcommand_t function);
/* called by the init functions of other parts of the program to */
/* register commands and functions to call for them. */
/* The cmd_name is referenced later, so it should not be in temp memory */
/* if function is NULL, the command will be forwarded to the server */
/* as a clc_stringcmd instead of executed locally */
void Cmd_RemoveCommand(char *cmd_name);
qboolean Cmd_Exists(char *cmd_name);
/* used by the cvar code to check for cvar / command name overlap */
char *Cmd_CompleteCommand(char *partial);
char *Cmd_CompleteMapCommand(char *partial);
/* attempts to match a partial command for automatic command line completion */
/* returns NULL if nothing fits */
int Cmd_Argc(void);
char *Cmd_Argv(int arg);
char *Cmd_Args(void);
/* The functions that execute commands get their parameters with these */
/* functions. Cmd_Argv () will return an empty string, not a NULL */
/* if arg > argc, so string operations are always safe. */
void Cmd_TokenizeString(char *text, qboolean macroExpand);
/* Takes a null terminated string. Does not need to be /n terminated. */
/* breaks the string up into arg tokens. */
void Cmd_ExecuteString(char *text);
/* Parses a single line of text into arguments and tries to execute it */
/* as if it was typed at the console */
void Cmd_ForwardToServer(void);
/* adds the current command line as a clc_stringcmd to the client message. */
/* things like godmode, noclip, etc, are commands directed to the server, */
/* so when they are typed in at the console, they will need to be forwarded. */
/* CVAR */
/*
* cvar_t variables are used to hold scalar or string variables that can be
* changed or displayed at the console or prog code as well as accessed
* directly in C code.
*
* The user can access cvars from the console in three ways:
* r_draworder prints the current value
* r_draworder 0 sets the current value to 0
* set r_draworder 0 as above, but creates the cvar if not present
* Cvars are restricted from having the same names as commands to keep this
* interface from being ambiguous.
*/
extern cvar_t *cvar_vars;
cvar_t *Cvar_Get(char *var_name, char *value, int flags);
/* creates the variable if it doesn't exist, or returns the existing one */
/* if it exists, the value will not be changed, but flags will be ORed in */
/* that allows variables to be unarchived without needing bitflags */
cvar_t *Cvar_Set(char *var_name, char *value);
/* will create the variable if it doesn't exist */
cvar_t *Cvar_ForceSet(char *var_name, char *value);
/* will set the variable even if NOSET or LATCH */
cvar_t *Cvar_FullSet(char *var_name, char *value, int flags);
void Cvar_SetValue(char *var_name, float value);
/* expands value to a string and calls Cvar_Set */
float Cvar_VariableValue(char *var_name);
/* returns 0 if not defined or non numeric */
const char *Cvar_VariableString(const char *var_name);
/* returns an empty string if not defined */
char *Cvar_CompleteVariable(char *partial);
/* attempts to match a partial variable name for command line completion */
/* returns NULL if nothing fits */
void Cvar_GetLatchedVars(void);
/* any CVAR_LATCHED variables that have been set will now take effect */
qboolean Cvar_Command(void);
/* called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known */
/* command. Returns true if the command was a variable reference that */
/* was handled. (print or change) */
void Cvar_WriteVariables(char *path);
/* appends lines containing "set variable value" for all variables */
/* with the archive flag set to true. */
void Cvar_Init(void);
void Cvar_Fini(void);
char *Cvar_Userinfo(void);
/* returns an info string containing all the CVAR_USERINFO cvars */
char *Cvar_Serverinfo(void);
/* returns an info string containing all the CVAR_SERVERINFO cvars */
extern qboolean userinfo_modified;
/* this is set each time a CVAR_USERINFO variable is changed */
/* so that the client knows to send it to the server */
/* NET */
#define PORT_ANY -1
#define MAX_MSGLEN 1400 /* max length of a message */
#define PACKET_HEADER 10 /* two ints and a short */
typedef enum
{
NA_LOOPBACK,
NA_BROADCAST,
NA_IP,
NA_IPX,
NA_BROADCAST_IPX,
NA_IP6,
NA_MULTICAST6
} netadrtype_t;
typedef enum {NS_CLIENT, NS_SERVER} netsrc_t;
typedef struct
{
netadrtype_t type;
byte ip[16];
unsigned int scope_id;
byte ipx[10];
unsigned short port;
} netadr_t;
void NET_Init(void);
void NET_Shutdown(void);
void NET_Config(qboolean multiplayer);
qboolean NET_GetPacket(netsrc_t sock, netadr_t *net_from,
sizebuf_t *net_message);
void NET_SendPacket(netsrc_t sock, int length, void *data, netadr_t to);
qboolean NET_CompareAdr(netadr_t a, netadr_t b);
qboolean NET_CompareBaseAdr(netadr_t a, netadr_t b);
qboolean NET_IsLocalAddress(netadr_t adr);
char *NET_AdrToString(netadr_t a);
qboolean NET_StringToAdr(const char *s, netadr_t *a);
void NET_Sleep(int msec);
/*=================================================================== */
#define OLD_AVG 0.99
#define MAX_LATENT 32
typedef struct
{
qboolean fatal_error;
netsrc_t sock;
int dropped; /* between last packet and previous */
int last_received; /* for timeouts */
int last_sent; /* for retransmits */
netadr_t remote_address;
int qport; /* qport value to write when transmitting */
/* sequencing variables */
int incoming_sequence;
int incoming_acknowledged;
int incoming_reliable_acknowledged; /* single bit */
int incoming_reliable_sequence; /* single bit, maintained local */
int outgoing_sequence;
int reliable_sequence; /* single bit */
int last_reliable_sequence; /* sequence number of last send */
/* reliable staging and holding areas */
sizebuf_t message; /* writing buffer to send to server */
byte message_buf[MAX_MSGLEN - 16]; /* leave space for header */
/* message is copied to this buffer when it is first transfered */
int reliable_length;
byte reliable_buf[MAX_MSGLEN - 16]; /* unacked reliable message */
} netchan_t;
extern netadr_t net_from;
extern sizebuf_t net_message;
extern byte net_message_buffer[MAX_MSGLEN];
void Netchan_Init(void);
void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport);
qboolean Netchan_NeedReliable(netchan_t *chan);
void Netchan_Transmit(netchan_t *chan, int length, byte *data);
void Netchan_OutOfBand(int net_socket, netadr_t adr, int length, byte *data);
void Netchan_OutOfBandPrint(int net_socket, netadr_t adr, char *format, ...);
qboolean Netchan_Process(netchan_t *chan, sizebuf_t *msg);
qboolean Netchan_CanReliable(netchan_t *chan);
/* CMODEL */
#include "files.h"
cmodel_t *CM_LoadMap(char *name, qboolean clientload, unsigned *checksum);
cmodel_t *CM_InlineModel(char *name); /* *1, *2, etc */
int CM_NumClusters(void);
int CM_NumInlineModels(void);
char *CM_EntityString(void);
/* creates a clipping hull for an arbitrary box */
int CM_HeadnodeForBox(vec3_t mins, vec3_t maxs);
/* returns an ORed contents mask */
int CM_PointContents(vec3_t p, int headnode);
int CM_TransformedPointContents(vec3_t p, int headnode,
vec3_t origin, vec3_t angles);
trace_t CM_BoxTrace(vec3_t start, vec3_t end, vec3_t mins,
vec3_t maxs, int headnode, int brushmask);
trace_t CM_TransformedBoxTrace(vec3_t start, vec3_t end,
vec3_t mins, vec3_t maxs, int headnode,
int brushmask, vec3_t origin, vec3_t angles);
byte *CM_ClusterPVS(int cluster);
byte *CM_ClusterPHS(int cluster);
int CM_PointLeafnum(vec3_t p);
/* call with topnode set to the headnode, returns with topnode */
/* set to the first node that splits the box */
int CM_BoxLeafnums(vec3_t mins, vec3_t maxs, int *list,
int listsize, int *topnode);
int CM_LeafContents(int leafnum);
int CM_LeafCluster(int leafnum);
int CM_LeafArea(int leafnum);
void CM_SetAreaPortalState(int portalnum, qboolean open);
qboolean CM_AreasConnected(int area1, int area2);
int CM_WriteAreaBits(byte *buffer, int area);
qboolean CM_HeadnodeVisible(int headnode, byte *visbits);
void CM_WritePortalState(FILE *f);
/* PLAYER MOVEMENT CODE */
extern float pm_airaccelerate;
void Pmove(pmove_t *pmove);
/* FILESYSTEM */
#define SFF_INPACK 0x20
typedef int fileHandle_t;
typedef enum
{
FS_READ,
FS_WRITE,
FS_APPEND
} fsMode_t;
typedef enum
{
FS_SEEK_CUR,
FS_SEEK_SET,
FS_SEEK_END
} fsOrigin_t;
typedef enum
{
FS_SEARCH_PATH_EXTENSION,
FS_SEARCH_BY_FILTER,
FS_SEARCH_FULL_PATH
} fsSearchType_t;
void FS_DPrintf(const char *format, ...);
int FS_FOpenFile(const char *name, fileHandle_t *f, qboolean gamedir_only);
void FS_FCloseFile(fileHandle_t f);
int FS_Read(void *buffer, int size, fileHandle_t f);
int FS_FRead(void *buffer, int size, int count, fileHandle_t f);
// returns the filename used to open f, but (if opened from pack) in correct case
// returns NULL if f is no valid handle
const char* FS_GetFilenameForHandle(fileHandle_t f);
char **FS_ListFiles(char *findname, int *numfiles,
unsigned musthave, unsigned canthave);
char **FS_ListFiles2(char *findname, int *numfiles,
unsigned musthave, unsigned canthave);
void FS_FreeList(char **list, int nfiles);
void FS_InitFilesystem(void);
void FS_BuildGameSpecificSearchPath(char *dir);
char *FS_Gamedir(void);
char *FS_NextPath(char *prevpath);
int FS_LoadFile(char *path, void **buffer);
qboolean FS_FileInGamedir(const char *file);
qboolean FS_AddPAKFromGamedir(const char *pak);
const char* FS_GetNextRawPath(const char* lastRawPath);
char **FS_ListMods(int *nummods);
/* a null buffer will just return the file length without loading */
/* a -1 length is not present */
/* properly handles partial reads */
void FS_FreeFile(void *buffer);
void FS_CreatePath(char *path);
/* MISC */
#define ERR_FATAL 0 /* exit the entire game with a popup window */
#define ERR_DROP 1 /* print to console and disconnect from game */
#define ERR_QUIT 2 /* not an error, just a normal exit */
#define EXEC_NOW 0 /* don't return until completed */
#define EXEC_INSERT 1 /* insert at current position, but don't run yet */
#define EXEC_APPEND 2 /* add to end of the command buffer */
#define PRINT_ALL 0
#define PRINT_DEVELOPER 1 /* only print when "developer 1" */
void Com_BeginRedirect(int target, char *buffer, int buffersize, void (*flush)(int, char *));
void Com_EndRedirect(void);
void Com_Printf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void Com_DPrintf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */
void Com_MDPrintf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
YQ2_ATTR_NORETURN void Com_Error(int code, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
YQ2_ATTR_NORETURN void Com_Quit(void);
/* Ugly work around for unsupported
* format specifiers unter mingw. */
#ifdef WIN32
#define YQ2_COM_PRId64 "%I64d"
#define YQ2_COM_PRIdS "%Id"
#else
#define YQ2_COM_PRId64 "%ld"
#define YQ2_COM_PRIdS "%zd"
#endif
// terminate yq2 (with Com_Error()) if VAR is NULL (after malloc() or similar)
// and print message about it
#define YQ2_COM_CHECK_OOM(VAR, ALLOC_FN_NAME, ALLOC_SIZE) \
if(VAR == NULL) { \
Com_Error(ERR_FATAL, "%s for " YQ2_COM_PRIdS " bytes failed in %s() (%s == NULL)! Out of Memory?!\n", \
ALLOC_FN_NAME, (size_t)ALLOC_SIZE, __func__, #VAR); }
int Com_ServerState(void); /* this should have just been a cvar... */
void Com_SetServerState(int state);
unsigned Com_BlockChecksum(void *buffer, int length);
byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence);
extern cvar_t *developer;
extern cvar_t *modder;
extern cvar_t *dedicated;
extern cvar_t *host_speeds;
extern cvar_t *log_stats;
/* External entity files. */
extern cvar_t *sv_entfile;
/* Hack for portable client */
extern qboolean is_portable;
/* Hack for external datadir */
extern char datadir[MAX_OSPATH];
/* Hack for external datadir */
extern char cfgdir[MAX_OSPATH];
/* Hack for working 'game' cmd */
extern char userGivenGame[MAX_QPATH];
extern char **mapnames;
extern int nummaps;
extern FILE *log_stats_file;
/* host_speeds times */
extern int time_before_game;
extern int time_after_game;
extern int time_before_ref;
extern int time_after_ref;
void Z_Free(void *ptr);
void *Z_Malloc(int size); /* returns 0 filled memory */
void *Z_TagMalloc(int size, int tag);
void Z_FreeTags(int tag);
void Qcommon_Init(int argc, char **argv);
void Qcommon_ExecConfigs(qboolean addEarlyCmds);
const char* Qcommon_GetInitialGame(void);
void Qcommon_Frame(int msec);
void Qcommon_Shutdown(void);
#define NUMVERTEXNORMALS 162
extern vec3_t bytedirs[NUMVERTEXNORMALS];
/* this is in the client code, but can be used for debugging from server */
void SCR_DebugGraph(float value, int color);
/* CLIENT / SERVER SYSTEMS */
void CL_Init(void);
void CL_Drop(void);
void CL_Shutdown(void);
void CL_Frame(int packetdelta, int renderdelta, int timedelta, qboolean packetframe, qboolean renderframe);
void Con_Print(char *text);
void SCR_BeginLoadingPlaque(void);
void SV_Init(void);
void SV_Shutdown(char *finalmsg, qboolean reconnect);
void SV_Frame(int usec);
/* ======================================================================= */
// Platform specific functions.
// system.c
char *Sys_ConsoleInput(void);
void Sys_ConsoleOutput(char *string);
YQ2_ATTR_NORETURN void Sys_Error(char *error, ...);
YQ2_ATTR_NORETURN void Sys_Quit(void);
void Sys_Init(void);
char *Sys_GetHomeDir(void);
void Sys_Remove(const char *path);
int Sys_Rename(const char *from, const char *to);
void Sys_RemoveDir(const char *path);
long long Sys_Microseconds(void);
void Sys_Nanosleep(int);
void *Sys_GetProcAddress(void *handle, const char *sym);
void Sys_FreeLibrary(void *handle);
void *Sys_LoadLibrary(const char *path, const char *sym, void **handle);
void *Sys_GetGameAPI(void *parms);
void Sys_UnloadGame(void);
void Sys_GetWorkDir(char *buffer, size_t len);
qboolean Sys_SetWorkDir(char *path);
void Sys_Realpath(const char *in, char *out, size_t size);
// Windows only (system.c)
#ifdef _WIN32
void Sys_RedirectStdout(void);
void Sys_SetHighDPIMode(void);
#endif
// misc.c
const char *Sys_GetBinaryDir(void);
void Sys_SetupFPU(void);
/* ======================================================================= */
#endif

33
src/common/header/crc.h Normal file
View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Corresponding header for crc.c
*
* =======================================================================
*/
#ifndef CO_CRC_H
#define CO_CRC_H
void CRC_Init(unsigned short *crcvalue);
unsigned short CRC_Block(byte *start, int count);
#endif

453
src/common/header/files.h Normal file
View file

@ -0,0 +1,453 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* The prototypes for most file formats used by Quake II
*
* =======================================================================
*/
#ifndef CO_FILES_H
#define CO_FILES_H
/* The .pak files are just a linear collapse of a directory tree */
#define IDPAKHEADER (('K' << 24) + ('C' << 16) + ('A' << 8) + 'P')
typedef struct
{
char name[56];
int filepos, filelen;
} dpackfile_t;
typedef struct
{
int ident; /* == IDPAKHEADER */
int dirofs;
int dirlen;
} dpackheader_t;
#define MAX_FILES_IN_PACK 4096
/* PCX files are used for as many images as possible */
typedef struct
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
unsigned short xmin, ymin, xmax, ymax;
unsigned short hres, vres;
unsigned char palette[48];
char reserved;
char color_planes;
unsigned short bytes_per_line;
unsigned short palette_type;
char filler[58];
unsigned char data; /* unbounded */
} pcx_t;
/* .MD2 triangle model file format */
#define IDALIASHEADER (('2' << 24) + ('P' << 16) + ('D' << 8) + 'I')
#define ALIAS_VERSION 8
#define MAX_TRIANGLES 4096
#define MAX_VERTS 2048
#define MAX_FRAMES 512
#define MAX_MD2SKINS 32
#define MAX_SKINNAME 64
typedef struct
{
short s;
short t;
} dstvert_t;
typedef struct
{
short index_xyz[3];
short index_st[3];
} dtriangle_t;
typedef struct
{
byte v[3]; /* scaled byte to fit in frame mins/maxs */
byte lightnormalindex;
} dtrivertx_t;
#define DTRIVERTX_V0 0
#define DTRIVERTX_V1 1
#define DTRIVERTX_V2 2
#define DTRIVERTX_LNI 3
#define DTRIVERTX_SIZE 4
typedef struct
{
float scale[3]; /* multiply byte verts by this */
float translate[3]; /* then add this */
char name[16]; /* frame name from grabbing */
dtrivertx_t verts[1]; /* variable sized */
} daliasframe_t;
/* the glcmd format:
* - a positive integer starts a tristrip command, followed by that many
* vertex structures.
* - a negative integer starts a trifan command, followed by -x vertexes
* a zero indicates the end of the command list.
* - a vertex consists of a floating point s, a floating point t,
* and an integer vertex index. */
typedef struct
{
int ident;
int version;
int skinwidth;
int skinheight;
int framesize; /* byte size of each frame */
int num_skins;
int num_xyz;
int num_st; /* greater than num_xyz for seams */
int num_tris;
int num_glcmds; /* dwords in strip/fan command list */
int num_frames;
int ofs_skins; /* each skin is a MAX_SKINNAME string */
int ofs_st; /* byte offset from start for stverts */
int ofs_tris; /* offset for dtriangles */
int ofs_frames; /* offset for first frame */
int ofs_glcmds;
int ofs_end; /* end of file */
} dmdl_t;
/* .SP2 sprite file format */
#define IDSPRITEHEADER (('2' << 24) + ('S' << 16) + ('D' << 8) + 'I') /* little-endian "IDS2" */
#define SPRITE_VERSION 2
typedef struct
{
int width, height;
int origin_x, origin_y; /* raster coordinates inside pic */
char name[MAX_SKINNAME]; /* name of pcx file */
} dsprframe_t;
typedef struct
{
int ident;
int version;
int numframes;
dsprframe_t frames[1]; /* variable sized */
} dsprite_t;
/* .WAL texture file format */
#define MIPLEVELS 4
typedef struct miptex_s
{
char name[32];
unsigned width, height;
unsigned offsets[MIPLEVELS]; /* four mip maps stored */
char animname[32]; /* next frame in animation chain */
int flags;
int contents;
int value;
} miptex_t;
/* .M8 texture file format */
#define M8_MIP_LEVELS 16
#define M8_VERSION 0x2
typedef struct {
unsigned char r;
unsigned char g;
unsigned char b;
} rgb_t;
typedef struct m8tex_s
{
unsigned version;
char name[32];
unsigned width[M8_MIP_LEVELS];
unsigned height[M8_MIP_LEVELS];
unsigned offsets[M8_MIP_LEVELS]; /* 16 mip maps stored */
char animname[32]; /* next frame in animation chain */
rgb_t palette[256];
int flags;
int contents;
int value;
} m8tex_t;
/* .BSP file format */
#define IDBSPHEADER (('P' << 24) + ('S' << 16) + ('B' << 8) + 'I') /* little-endian "IBSP" */
#define BSPVERSION 38
/* upper design bounds: leaffaces, leafbrushes, planes, and
* verts are still bounded by 16 bit short limits */
#define MAX_MAP_MODELS 1024
#define MAX_MAP_BRUSHES 8192
#define MAX_MAP_ENTITIES 2048
#define MAX_MAP_ENTSTRING 0x40000
#define MAX_MAP_TEXINFO 8192
#define MAX_MAP_AREAS 256
#define MAX_MAP_AREAPORTALS 1024
#define MAX_MAP_PLANES 65536
#define MAX_MAP_NODES 65536
#define MAX_MAP_BRUSHSIDES 65536
#define MAX_MAP_LEAFS 65536
#define MAX_MAP_VERTS 65536
#define MAX_MAP_FACES 65536
#define MAX_MAP_LEAFFACES 65536
#define MAX_MAP_LEAFBRUSHES 65536
#define MAX_MAP_PORTALS 65536
#define MAX_MAP_EDGES 128000
#define MAX_MAP_SURFEDGES 256000
#define MAX_MAP_LIGHTING 0x200000
#define MAX_MAP_VISIBILITY 0x100000
/* key / value pair sizes */
#define MAX_KEY 32
#define MAX_VALUE 1024
/* ================================================================== */
typedef struct
{
int fileofs, filelen;
} lump_t;
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_VERTEXES 2
#define LUMP_VISIBILITY 3
#define LUMP_NODES 4
#define LUMP_TEXINFO 5
#define LUMP_FACES 6
#define LUMP_LIGHTING 7
#define LUMP_LEAFS 8
#define LUMP_LEAFFACES 9
#define LUMP_LEAFBRUSHES 10
#define LUMP_EDGES 11
#define LUMP_SURFEDGES 12
#define LUMP_MODELS 13
#define LUMP_BRUSHES 14
#define LUMP_BRUSHSIDES 15
#define LUMP_POP 16
#define LUMP_AREAS 17
#define LUMP_AREAPORTALS 18
#define HEADER_LUMPS 19
typedef struct
{
int ident;
int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct
{
float mins[3], maxs[3];
float origin[3]; /* for sounds or lights */
int headnode;
int firstface, numfaces; /* submodels just draw faces without
walking the bsp tree */
} dmodel_t;
typedef struct
{
float point[3];
} dvertex_t;
/* 0-2 are axial planes */
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
/* 3-5 are non-axial planes snapped to the nearest */
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
/* planes (x&~1) and (x&~1)+1 are always opposites */
typedef struct
{
float normal[3];
float dist;
int type; /* PLANE_X - PLANE_ANYZ */
} dplane_t;
/* contents flags are seperate bits
* - given brush can contribute multiple content bits
* - multiple brushes can be in a single leaf */
/* lower bits are stronger, and will eat weaker brushes completely */
#define CONTENTS_SOLID 1 /* an eye is never valid in a solid */
#define CONTENTS_WINDOW 2 /* translucent, but not watery */
#define CONTENTS_AUX 4
#define CONTENTS_LAVA 8
#define CONTENTS_SLIME 16
#define CONTENTS_WATER 32
#define CONTENTS_MIST 64
#define LAST_VISIBLE_CONTENTS 64
/* remaining contents are non-visible, and don't eat brushes */
#define CONTENTS_AREAPORTAL 0x8000
#define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000
/* currents can be added to any other contents, and may be mixed */
#define CONTENTS_CURRENT_0 0x40000
#define CONTENTS_CURRENT_90 0x80000
#define CONTENTS_CURRENT_180 0x100000
#define CONTENTS_CURRENT_270 0x200000
#define CONTENTS_CURRENT_UP 0x400000
#define CONTENTS_CURRENT_DOWN 0x800000
#define CONTENTS_ORIGIN 0x1000000 /* removed before bsping an entity */
#define CONTENTS_MONSTER 0x2000000 /* should never be on a brush, only in game */
#define CONTENTS_DEADMONSTER 0x4000000
#define CONTENTS_DETAIL 0x8000000 /* brushes to be added after vis leafs */
#define CONTENTS_TRANSLUCENT 0x10000000 /* auto set if any surface has trans */
#define CONTENTS_LADDER 0x20000000
#define SURF_LIGHT 0x1 /* value will hold the light strength */
#define SURF_SLICK 0x2 /* effects game physics */
#define SURF_SKY 0x4 /* don't draw, but add to skybox */
#define SURF_WARP 0x8 /* turbulent water warp */
#define SURF_TRANS33 0x10
#define SURF_TRANS66 0x20
#define SURF_FLOWING 0x40 /* scroll towards angle */
#define SURF_NODRAW 0x80 /* don't bother referencing the texture */
typedef struct
{
int planenum;
int children[2]; /* negative numbers are -(leafs+1), not nodes */
short mins[3]; /* for frustom culling */
short maxs[3];
unsigned short firstface;
unsigned short numfaces; /* counting both sides */
} dnode_t;
typedef struct texinfo_s
{
float vecs[2][4]; /* [s/t][xyz offset] */
int flags; /* miptex flags + overrides light emission, etc */
int value;
char texture[32]; /* texture name (textures*.wal) */
int nexttexinfo; /* for animations, -1 = end of chain */
} texinfo_t;
/* note that edge 0 is never used, because negative edge
nums are used for counterclockwise use of the edge in
a face */
typedef struct
{
unsigned short v[2]; /* vertex numbers */
} dedge_t;
#define MAXLIGHTMAPS 4
typedef struct
{
unsigned short planenum;
short side;
int firstedge; /* we must support > 64k edges */
short numedges;
short texinfo;
/* lighting info */
byte styles[MAXLIGHTMAPS];
int lightofs; /* start of [numstyles*surfsize] samples */
} dface_t;
typedef struct
{
int contents; /* OR of all brushes (not needed?) */
short cluster;
short area;
short mins[3]; /* for frustum culling */
short maxs[3];
unsigned short firstleafface;
unsigned short numleaffaces;
unsigned short firstleafbrush;
unsigned short numleafbrushes;
} dleaf_t;
typedef struct
{
unsigned short planenum; /* facing out of the leaf */
short texinfo;
} dbrushside_t;
typedef struct
{
int firstside;
int numsides;
int contents;
} dbrush_t;
#define ANGLE_UP -1
#define ANGLE_DOWN -2
/* the visibility lump consists of a header with a count, then
* byte offsets for the PVS and PHS of each cluster, then the raw
* compressed bit vectors */
#define DVIS_PVS 0
#define DVIS_PHS 1
typedef struct
{
int numclusters;
int bitofs[8][2]; /* bitofs[numclusters][2] */
} dvis_t;
/* each area has a list of portals that lead into other areas
* when portals are closed, other areas may not be visible or
* hearable even if the vis info says that it should be */
typedef struct
{
int portalnum;
int otherarea;
} dareaportal_t;
typedef struct
{
int numareaportals;
int firstareaportal;
} darea_t;
#endif

283
src/common/header/ref_api.h Normal file
View file

@ -0,0 +1,283 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* =======================================================================
*
* ABI between client and refresher
*
* =======================================================================
*/
#ifndef CL_REF_H
#define CL_REF_H
#include "common.h"
#include "vid.h"
#define MAX_DLIGHTS 32
#define MAX_ENTITIES 128
#define MAX_PARTICLES 4096
#define MAX_LIGHTSTYLES 256
#define POWERSUIT_SCALE 4.0F
#define SHELL_RED_COLOR 0xF2
#define SHELL_GREEN_COLOR 0xD0
#define SHELL_BLUE_COLOR 0xF3
#define SHELL_RG_COLOR 0xDC
#define SHELL_RB_COLOR 0x68
#define SHELL_BG_COLOR 0x78
#define SHELL_DOUBLE_COLOR 0xDF
#define SHELL_HALF_DAM_COLOR 0x90
#define SHELL_CYAN_COLOR 0x72
#define SHELL_WHITE_COLOR 0xD7
#define ENTITY_FLAGS 68
typedef struct entity_s {
struct model_s *model; /* opaque type outside refresh */
float angles[3];
/* most recent data */
float origin[3]; /* also used as RF_BEAM's "from" */
int frame; /* also used as RF_BEAM's diameter */
/* previous data for lerping */
float oldorigin[3]; /* also used as RF_BEAM's "to" */
int oldframe;
/* misc */
float backlerp; /* 0.0 = current, 1.0 = old */
int skinnum; /* also used as RF_BEAM's palette index */
int lightstyle; /* for flashing entities */
float alpha; /* ignore if RF_TRANSLUCENT isn't set */
struct image_s *skin; /* NULL for inline skin */
int flags;
} entity_t;
typedef struct {
vec3_t origin;
vec3_t color;
float intensity;
} dlight_t;
typedef struct {
vec3_t origin;
int color;
float alpha;
} particle_t;
typedef struct {
float rgb[3]; /* 0.0 - 2.0 */
float white; /* r+g+b */
} lightstyle_t;
typedef struct {
int x, y, width, height; /* in virtual screen coordinates */
float fov_x, fov_y;
float vieworg[3];
float viewangles[3];
float blend[4]; /* rgba 0-1 full screen blend */
float time; /* time is used to auto animate */
int rdflags; /* RDF_UNDERWATER, etc */
byte *areabits; /* if not NULL, only areas with set bits will be drawn */
lightstyle_t *lightstyles; /* [MAX_LIGHTSTYLES] */
int num_entities;
entity_t *entities;
int num_dlights; // <= 32 (MAX_DLIGHTS)
dlight_t *dlights;
int num_particles;
particle_t *particles;
} refdef_t;
// Renderer restart type.
typedef enum {
RESTART_UNDEF,
RESTART_NO,
RESTART_FULL,
RESTART_PARTIAL
} ref_restart_t;
// FIXME: bump API_VERSION?
#define API_VERSION 5
#define EXPORT
#define IMPORT
//
// these are the functions exported by the refresh module
//
typedef struct
{
// if api_version is different, the dll cannot be used
int api_version;
// called when the library is loaded
qboolean (EXPORT *Init) (void);
// called before the library is unloaded
void (EXPORT *Shutdown) (void);
// called by GLimp_InitGraphics() before creating window,
// returns flags for SDL window creation, returns -1 on error
int (EXPORT *PrepareForWindow)(void);
// called by GLimp_InitGraphics() *after* creating window,
// passing the SDL_Window* (void* so we don't spill SDL.h here)
// (or SDL_Surface* for SDL1.2, another reason to use void*)
// returns true (1) on success
int (EXPORT *InitContext)(void* sdl_window);
// shuts down rendering (OpenGL) context.
void (EXPORT *ShutdownContext)(void);
// returns true if vsync is active, else false
qboolean (EXPORT *IsVSyncActive)(void);
// All data that will be used in a level should be
// registered before rendering any frames to prevent disk hits,
// but they can still be registered at a later time
// if necessary.
//
// EndRegistration will free any remaining data that wasn't registered.
// Any model_s or skin_s pointers from before the BeginRegistration
// are no longer valid after EndRegistration.
//
// Skins and images need to be differentiated, because skins
// are flood filled to eliminate mip map edge errors, and pics have
// an implicit "pics/" prepended to the name. (a pic name that starts with a
// slash will not use the "pics/" prefix or the ".pcx" postfix)
void (EXPORT *BeginRegistration) (char *map);
struct model_s * (EXPORT *RegisterModel) (char *name);
struct image_s * (EXPORT *RegisterSkin) (char *name);
void (EXPORT *SetSky) (char *name, float rotate, vec3_t axis);
void (EXPORT *EndRegistration) (void);
void (EXPORT *RenderFrame) (refdef_t *fd);
struct image_s * (EXPORT *DrawFindPic)(char *name);
void (EXPORT *DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
void (EXPORT *DrawPicScaled) (int x, int y, char *pic, float factor);
void (EXPORT *DrawStretchPic) (int x, int y, int w, int h, char *name);
void (EXPORT *DrawCharScaled)(int x, int y, int num, float scale);
void (EXPORT *DrawTileClear) (int x, int y, int w, int h, char *name);
void (EXPORT *DrawFill) (int x, int y, int w, int h, int c);
void (EXPORT *DrawFadeScreen) (void);
// Draw images for cinematic rendering (which can have a different palette). Note that calls
void (EXPORT *DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
/*
** video mode and refresh state management entry points
*/
void (EXPORT *SetPalette)( const unsigned char *palette); // NULL = game palette
void (EXPORT *BeginFrame)( float camera_separation );
void (EXPORT *EndFrame) (void);
qboolean (EXPORT *EndWorldRenderpass) (void); // finish world rendering, apply postprocess and switch to UI render pass
//void (EXPORT *AppActivate)( qboolean activate );
} refexport_t;
typedef struct
{
YQ2_ATTR_NORETURN_FUNCPTR void (IMPORT *Sys_Error) (int err_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
void (IMPORT *Cmd_AddCommand) (char *name, void(*cmd)(void));
void (IMPORT *Cmd_RemoveCommand) (char *name);
int (IMPORT *Cmd_Argc) (void);
char *(IMPORT *Cmd_Argv) (int i);
void (IMPORT *Cmd_ExecuteText) (int exec_when, char *text);
void (IMPORT *Com_VPrintf) (int print_level, const char *fmt, va_list argptr);
// files will be memory mapped read only
// the returned buffer may be part of a larger pak file,
// or a discrete file from anywhere in the quake search path
// a -1 return means the file does not exist
// NULL can be passed for buf to just determine existance
int (IMPORT *FS_LoadFile) (char *name, void **buf);
void (IMPORT *FS_FreeFile) (void *buf);
// gamedir will be the current directory that generated
// files should be stored to, ie: "f:\quake\id1"
char *(IMPORT *FS_Gamedir) (void);
cvar_t *(IMPORT *Cvar_Get) (char *name, char *value, int flags);
cvar_t *(IMPORT *Cvar_Set) (char *name, char *value);
void (IMPORT *Cvar_SetValue) (char *name, float value);
qboolean (IMPORT *Vid_GetModeInfo)(int *width, int *height, int mode);
void (IMPORT *Vid_MenuInit)( void );
// called with image data of width*height pixel which comp bytes per pixel (must be 3 or 4 for RGB or RGBA)
// expects the pixels data to be row-wise, starting at top left
void (IMPORT *Vid_WriteScreenshot)( int width, int height, int comp, const void* data );
qboolean (IMPORT *GLimp_InitGraphics)(int fullscreen, int *pwidth, int *pheight);
qboolean (IMPORT *GLimp_GetDesktopMode)(int *pwidth, int *pheight);
void (IMPORT *Vid_RequestRestart)(ref_restart_t rs);
} refimport_t;
// this is the only function actually exported at the linker level
typedef refexport_t (EXPORT *GetRefAPI_t) (refimport_t);
// FIXME: #ifdef client/ref around this
extern refexport_t re;
extern refimport_t ri;
/*
* Refresh API
*/
void R_BeginRegistration(char *map);
void R_Clear(void);
struct model_s *R_RegisterModel(char *name);
struct image_s *R_RegisterSkin(char *name);
void R_SetSky(char *name, float rotate, vec3_t axis);
void R_EndRegistration(void);
struct image_s *Draw_FindPic(char *name);
void R_RenderFrame(refdef_t *fd);
void Draw_GetPicSize(int *w, int *h, char *name);
void Draw_StretchPic(int x, int y, int w, int h, char *name);
void Draw_PicScaled(int x, int y, char *pic, float factor);
void Draw_CharScaled(int x, int y, int num, float scale);
void Draw_TileClear(int x, int y, int w, int h, char *name);
void Draw_Fill(int x, int y, int w, int h, int c);
void Draw_FadeScreen(void);
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data);
//int R_Init(void *hinstance, void *hWnd);
//void R_Shutdown(void);
void R_SetPalette(const unsigned char *palette);
void R_BeginFrame(float camera_separation);
qboolean R_EndWorldRenderpass(void);
void R_EndFrame(void);
#endif

View file

@ -0,0 +1,78 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Header shared between different refreshers (but not with client)
*
* =======================================================================
*/
#ifndef SRC_CLIENT_REFRESH_REF_SHARED_H_
#define SRC_CLIENT_REFRESH_REF_SHARED_H_
#include "ref_api.h"
/*
* skins will be outline flood filled and mip mapped
* pics and sprites with alpha will be outline flood filled
* pic won't be mip mapped
*
* model skin
* sprite frame
* wall texture
* pic
*/
typedef enum
{
it_skin,
it_sprite,
it_wall,
it_pic,
it_sky
} imagetype_t;
typedef enum
{
mod_bad,
mod_brush,
mod_sprite,
mod_alias
} modtype_t;
#define MAX_LBM_HEIGHT 480
extern void R_Printf(int level, const char* msg, ...) __attribute__ ((format (printf, 2, 3)));
extern void LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height);
extern void GetPCXInfo(char *filename, int *width, int *height);
extern qboolean LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height);
extern qboolean ResizeSTB(byte *input_pixels, int input_width, int input_height,
byte *output_pixels, int output_width, int output_height);
extern void SmoothColorImage(unsigned *dst, size_t size, size_t rstep);
extern void scale2x(byte *src, byte *dst, int width, int height);
extern void scale3x(byte *src, byte *dst, int width, int height);
extern void GetWalInfo(char *name, int *width, int *height);
extern void GetM8Info(char *name, int *width, int *height);
extern float Mod_RadiusFromBounds(const vec3_t mins, const vec3_t maxs);
extern byte* Mod_DecompressVis(byte *in, int row);
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */

1189
src/common/header/shared.h Normal file

File diff suppressed because it is too large Load diff

69
src/common/header/vid.h Normal file
View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* =======================================================================
*
* API between client and renderer.
*
* =======================================================================
*/
#ifndef CL_VID_H
#define CL_VID_H
#include "common.h"
// FIXME: Remove it, it's unused.
typedef struct vrect_s {
int x,y,width,height;
} vrect_t;
// Hold the video state.
typedef struct {
int height;
int width;
} viddef_t;
// Global video state.
extern viddef_t viddef;
// Generic stuff.
void VID_Init(void);
void VID_Shutdown(void);
void VID_CheckChanges(void);
void VID_MenuInit(void);
void VID_MenuDraw(void);
const char *VID_MenuKey(int);
// Stuff provided by platform backend.
extern int glimp_refreshRate;
const char **GLimp_GetDisplayIndices(void);
int GLimp_GetWindowDisplayIndex(void);
int GLimp_GetNumVideoDisplays(void);
qboolean GLimp_Init(void);
void GLimp_Shutdown(void);
qboolean GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight);
void GLimp_ShutdownGraphics(void);
void GLimp_GrabInput(qboolean grab);
int GLimp_GetRefreshRate(void);
qboolean GLimp_GetDesktopMode(int *pwidth, int *pheight);
#endif

224
src/common/md4.c Normal file
View file

@ -0,0 +1,224 @@
/*
* Public Domain C source implementation of RFC 1320
* - The MD4 Message-Digest Algorithm -
*
* http://www.faqs.org/rfcs/rfc1320.html
* by Steven Fuller
*/
#include <inttypes.h>
#define ROTATELEFT32(x, s) (((x) << (s)) | ((x) >> (32 - (s))))
#define F(X, Y, Z) (((X)&(Y)) | ((~X) & (Z)))
#define G(X, Y, Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
#define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
#define S(a, b, c, d, k, s) \
{ \
a += (F((b), (c), (d)) + X[(k)]); \
a = ROTATELEFT32(a, s); \
}
#define T(a, b, c, d, k, s) \
{ \
a += (G((b), (c), (d)) + X[(k)] + 0x5A827999); \
a = ROTATELEFT32(a, s); \
}
#define U(a, b, c, d, k, s) \
{ \
a += (H((b), (c), (d)) + X[(k)] + 0x6ED9EBA1); \
a = ROTATELEFT32(a, s); \
}
static uint32_t X[16];
static uint32_t A, AA;
static uint32_t B, BB;
static uint32_t C, CC;
static uint32_t D, DD;
static void
DoMD4()
{
AA = A;
BB = B;
CC = C;
DD = D;
S(A, B, C, D, 0, 3);
S(D, A, B, C, 1, 7);
S(C, D, A, B, 2, 11);
S(B, C, D, A, 3, 19);
S(A, B, C, D, 4, 3);
S(D, A, B, C, 5, 7);
S(C, D, A, B, 6, 11);
S(B, C, D, A, 7, 19);
S(A, B, C, D, 8, 3);
S(D, A, B, C, 9, 7);
S(C, D, A, B, 10, 11);
S(B, C, D, A, 11, 19);
S(A, B, C, D, 12, 3);
S(D, A, B, C, 13, 7);
S(C, D, A, B, 14, 11);
S(B, C, D, A, 15, 19);
T(A, B, C, D, 0, 3);
T(D, A, B, C, 4, 5);
T(C, D, A, B, 8, 9);
T(B, C, D, A, 12, 13);
T(A, B, C, D, 1, 3);
T(D, A, B, C, 5, 5);
T(C, D, A, B, 9, 9);
T(B, C, D, A, 13, 13);
T(A, B, C, D, 2, 3);
T(D, A, B, C, 6, 5);
T(C, D, A, B, 10, 9);
T(B, C, D, A, 14, 13);
T(A, B, C, D, 3, 3);
T(D, A, B, C, 7, 5);
T(C, D, A, B, 11, 9);
T(B, C, D, A, 15, 13);
U(A, B, C, D, 0, 3);
U(D, A, B, C, 8, 9);
U(C, D, A, B, 4, 11);
U(B, C, D, A, 12, 15);
U(A, B, C, D, 2, 3);
U(D, A, B, C, 10, 9);
U(C, D, A, B, 6, 11);
U(B, C, D, A, 14, 15);
U(A, B, C, D, 1, 3);
U(D, A, B, C, 9, 9);
U(C, D, A, B, 5, 11);
U(B, C, D, A, 13, 15);
U(A, B, C, D, 3, 3);
U(D, A, B, C, 11, 9);
U(C, D, A, B, 7, 11);
U(B, C, D, A, 15, 15);
A += AA;
B += BB;
C += CC;
D += DD;
}
static void
PerformMD4(const unsigned char *buf, int length, unsigned char *digest)
{
int len = length / 64; /* number of full blocks */
int rem = length % 64; /* number of left over bytes */
int i, j;
const unsigned char *ptr = buf;
/* initialize the MD buffer */
A = 0x67452301;
B = 0xEFCDAB89;
C = 0x98BADCFE;
D = 0x10325476;
for (i = 0; i < len; i++)
{
for (j = 0; j < 16; j++)
{
X[j] = ((ptr[0] << 0) | (ptr[1] << 8) |
(ptr[2] << 16) | (ptr[3] << 24));
ptr += 4;
}
DoMD4();
}
i = rem / 4;
for (j = 0; j < i; j++)
{
X[j] = ((ptr[0] << 0) | (ptr[1] << 8) |
(ptr[2] << 16) | (ptr[3] << 24));
ptr += 4;
}
switch (rem % 4)
{
case 0:
X[j] = 0x80U;
break;
case 1:
X[j] = ((ptr[0] << 0) | ((0x80U) << 8));
break;
case 2:
X[j] = ((ptr[0] << 0) | (ptr[1] << 8) | ((0x80U) << 16));
break;
case 3:
X[j] =
((ptr[0] <<
0) | (ptr[1] << 8) | (ptr[2] << 16) | ((0x80U) << 24));
break;
}
j++;
if (j > 14)
{
for ( ; j < 16; j++)
{
X[j] = 0;
}
DoMD4();
j = 0;
}
for ( ; j < 14; j++)
{
X[j] = 0;
}
X[14] = (length & 0x1FFFFFFF) << 3;
X[15] = (length & ~0x1FFFFFFF) >> 29;
DoMD4();
digest[0] = (A & 0x000000FF) >> 0;
digest[1] = (A & 0x0000FF00) >> 8;
digest[2] = (A & 0x00FF0000) >> 16;
digest[3] = (A & 0xFF000000) >> 24;
digest[4] = (B & 0x000000FF) >> 0;
digest[5] = (B & 0x0000FF00) >> 8;
digest[6] = (B & 0x00FF0000) >> 16;
digest[7] = (B & 0xFF000000) >> 24;
digest[8] = (C & 0x000000FF) >> 0;
digest[9] = (C & 0x0000FF00) >> 8;
digest[10] = (C & 0x00FF0000) >> 16;
digest[11] = (C & 0xFF000000) >> 24;
digest[12] = (D & 0x000000FF) >> 0;
digest[13] = (D & 0x0000FF00) >> 8;
digest[14] = (D & 0x00FF0000) >> 16;
digest[15] = (D & 0xFF000000) >> 24;
A = AA = 0;
B = BB = 0;
C = CC = 0;
D = DD = 0;
for (j = 0; j < 16; j++)
{
X[j] = 0;
}
}
unsigned
Com_BlockChecksum(void *buffer, int length)
{
uint32_t digest[4];
unsigned val;
PerformMD4((unsigned char *)buffer, length, (unsigned char *)digest);
val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
return val;
}

1419
src/common/shared.c Normal file

File diff suppressed because it is too large Load diff

188
src/constants/anorms.h Normal file
View file

@ -0,0 +1,188 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Precalculates anormal values
*
* =======================================================================
*/
{ -0.525731, 0.000000, 0.850651 },
{ -0.442863, 0.238856, 0.864188 },
{ -0.295242, 0.000000, 0.955423 },
{ -0.309017, 0.500000, 0.809017 },
{ -0.162460, 0.262866, 0.951056 },
{ 0.000000, 0.000000, 1.000000 },
{ 0.000000, 0.850651, 0.525731 },
{ -0.147621, 0.716567, 0.681718 },
{ 0.147621, 0.716567, 0.681718 },
{ 0.000000, 0.525731, 0.850651 },
{ 0.309017, 0.500000, 0.809017 },
{ 0.525731, 0.000000, 0.850651 },
{ 0.295242, 0.000000, 0.955423 },
{ 0.442863, 0.238856, 0.864188 },
{ 0.162460, 0.262866, 0.951056 },
{ -0.681718, 0.147621, 0.716567 },
{ -0.809017, 0.309017, 0.500000 },
{ -0.587785, 0.425325, 0.688191 },
{ -0.850651, 0.525731, 0.000000 },
{ -0.864188, 0.442863, 0.238856 },
{ -0.716567, 0.681718, 0.147621 },
{ -0.688191, 0.587785, 0.425325 },
{ -0.500000, 0.809017, 0.309017 },
{ -0.238856, 0.864188, 0.442863 },
{ -0.425325, 0.688191, 0.587785 },
{ -0.716567, 0.681718, -0.147621 },
{ -0.500000, 0.809017, -0.309017 },
{ -0.525731, 0.850651, 0.000000 },
{ 0.000000, 0.850651, -0.525731 },
{ -0.238856, 0.864188, -0.442863 },
{ 0.000000, 0.955423, -0.295242 },
{ -0.262866, 0.951056, -0.162460 },
{ 0.000000, 1.000000, 0.000000 },
{ 0.000000, 0.955423, 0.295242 },
{ -0.262866, 0.951056, 0.162460 },
{ 0.238856, 0.864188, 0.442863 },
{ 0.262866, 0.951056, 0.162460 },
{ 0.500000, 0.809017, 0.309017 },
{ 0.238856, 0.864188, -0.442863 },
{ 0.262866, 0.951056, -0.162460 },
{ 0.500000, 0.809017, -0.309017 },
{ 0.850651, 0.525731, 0.000000 },
{ 0.716567, 0.681718, 0.147621 },
{ 0.716567, 0.681718, -0.147621 },
{ 0.525731, 0.850651, 0.000000 },
{ 0.425325, 0.688191, 0.587785 },
{ 0.864188, 0.442863, 0.238856 },
{ 0.688191, 0.587785, 0.425325 },
{ 0.809017, 0.309017, 0.500000 },
{ 0.681718, 0.147621, 0.716567 },
{ 0.587785, 0.425325, 0.688191 },
{ 0.955423, 0.295242, 0.000000 },
{ 1.000000, 0.000000, 0.000000 },
{ 0.951056, 0.162460, 0.262866 },
{ 0.850651, -0.525731, 0.000000 },
{ 0.955423, -0.295242, 0.000000 },
{ 0.864188, -0.442863, 0.238856 },
{ 0.951056, -0.162460, 0.262866 },
{ 0.809017, -0.309017, 0.500000 },
{ 0.681718, -0.147621, 0.716567 },
{ 0.850651, 0.000000, 0.525731 },
{ 0.864188, 0.442863, -0.238856 },
{ 0.809017, 0.309017, -0.500000 },
{ 0.951056, 0.162460, -0.262866 },
{ 0.525731, 0.000000, -0.850651 },
{ 0.681718, 0.147621, -0.716567 },
{ 0.681718, -0.147621, -0.716567 },
{ 0.850651, 0.000000, -0.525731 },
{ 0.809017, -0.309017, -0.500000 },
{ 0.864188, -0.442863, -0.238856 },
{ 0.951056, -0.162460, -0.262866 },
{ 0.147621, 0.716567, -0.681718 },
{ 0.309017, 0.500000, -0.809017 },
{ 0.425325, 0.688191, -0.587785 },
{ 0.442863, 0.238856, -0.864188 },
{ 0.587785, 0.425325, -0.688191 },
{ 0.688191, 0.587785, -0.425325 },
{ -0.147621, 0.716567, -0.681718 },
{ -0.309017, 0.500000, -0.809017 },
{ 0.000000, 0.525731, -0.850651 },
{ -0.525731, 0.000000, -0.850651 },
{ -0.442863, 0.238856, -0.864188 },
{ -0.295242, 0.000000, -0.955423 },
{ -0.162460, 0.262866, -0.951056 },
{ 0.000000, 0.000000, -1.000000 },
{ 0.295242, 0.000000, -0.955423 },
{ 0.162460, 0.262866, -0.951056 },
{ -0.442863, -0.238856, -0.864188 },
{ -0.309017, -0.500000, -0.809017 },
{ -0.162460, -0.262866, -0.951056 },
{ 0.000000, -0.850651, -0.525731 },
{ -0.147621, -0.716567, -0.681718 },
{ 0.147621, -0.716567, -0.681718 },
{ 0.000000, -0.525731, -0.850651 },
{ 0.309017, -0.500000, -0.809017 },
{ 0.442863, -0.238856, -0.864188 },
{ 0.162460, -0.262866, -0.951056 },
{ 0.238856, -0.864188, -0.442863 },
{ 0.500000, -0.809017, -0.309017 },
{ 0.425325, -0.688191, -0.587785 },
{ 0.716567, -0.681718, -0.147621 },
{ 0.688191, -0.587785, -0.425325 },
{ 0.587785, -0.425325, -0.688191 },
{ 0.000000, -0.955423, -0.295242 },
{ 0.000000, -1.000000, 0.000000 },
{ 0.262866, -0.951056, -0.162460 },
{ 0.000000, -0.850651, 0.525731 },
{ 0.000000, -0.955423, 0.295242 },
{ 0.238856, -0.864188, 0.442863 },
{ 0.262866, -0.951056, 0.162460 },
{ 0.500000, -0.809017, 0.309017 },
{ 0.716567, -0.681718, 0.147621 },
{ 0.525731, -0.850651, 0.000000 },
{ -0.238856, -0.864188, -0.442863 },
{ -0.500000, -0.809017, -0.309017 },
{ -0.262866, -0.951056, -0.162460 },
{ -0.850651, -0.525731, 0.000000 },
{ -0.716567, -0.681718, -0.147621 },
{ -0.716567, -0.681718, 0.147621 },
{ -0.525731, -0.850651, 0.000000 },
{ -0.500000, -0.809017, 0.309017 },
{ -0.238856, -0.864188, 0.442863 },
{ -0.262866, -0.951056, 0.162460 },
{ -0.864188, -0.442863, 0.238856 },
{ -0.809017, -0.309017, 0.500000 },
{ -0.688191, -0.587785, 0.425325 },
{ -0.681718, -0.147621, 0.716567 },
{ -0.442863, -0.238856, 0.864188 },
{ -0.587785, -0.425325, 0.688191 },
{ -0.309017, -0.500000, 0.809017 },
{ -0.147621, -0.716567, 0.681718 },
{ -0.425325, -0.688191, 0.587785 },
{ -0.162460, -0.262866, 0.951056 },
{ 0.442863, -0.238856, 0.864188 },
{ 0.162460, -0.262866, 0.951056 },
{ 0.309017, -0.500000, 0.809017 },
{ 0.147621, -0.716567, 0.681718 },
{ 0.000000, -0.525731, 0.850651 },
{ 0.425325, -0.688191, 0.587785 },
{ 0.587785, -0.425325, 0.688191 },
{ 0.688191, -0.587785, 0.425325 },
{ -0.955423, 0.295242, 0.000000 },
{ -0.951056, 0.162460, 0.262866 },
{ -1.000000, 0.000000, 0.000000 },
{ -0.850651, 0.000000, 0.525731 },
{ -0.955423, -0.295242, 0.000000 },
{ -0.951056, -0.162460, 0.262866 },
{ -0.864188, 0.442863, -0.238856 },
{ -0.951056, 0.162460, -0.262866 },
{ -0.809017, 0.309017, -0.500000 },
{ -0.864188, -0.442863, -0.238856 },
{ -0.951056, -0.162460, -0.262866 },
{ -0.809017, -0.309017, -0.500000 },
{ -0.681718, 0.147621, -0.716567 },
{ -0.681718, -0.147621, -0.716567 },
{ -0.850651, 0.000000, -0.525731 },
{ -0.688191, 0.587785, -0.425325 },
{ -0.587785, 0.425325, -0.688191 },
{ -0.425325, 0.688191, -0.587785 },
{ -0.425325, -0.688191, -0.587785 },
{ -0.587785, -0.425325, -0.688191 },
{ -0.688191, -0.587785, -0.425325 },

236
src/constants/anormtab.h Normal file
View file

@ -0,0 +1,236 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Precalculated anormal tabulations
*
* =======================================================================
*/
{ 1.23, 1.30, 1.47, 1.35, 1.56, 1.71, 1.37, 1.38, 1.59, 1.60, 1.79, 1.97, 1.88, 1.92, 1.79, 1.02, 0.93, 1.07, 0.82, 0.87,
0.88, 0.94, 0.96, 1.14, 1.11, 0.82, 0.83, 0.89, 0.89, 0.86, 0.94, 0.91, 1.00, 1.21, 0.98, 1.48, 1.30, 1.57, 0.96, 1.07,
1.14, 1.60, 1.61, 1.40, 1.37, 1.72, 1.78, 1.79, 1.93, 1.99, 1.90, 1.68, 1.71, 1.86, 1.60, 1.68, 1.78, 1.86, 1.93, 1.99,
1.97, 1.44, 1.22, 1.49, 0.93, 0.99, 0.99, 1.23, 1.22, 1.44, 1.49, 0.89, 0.89, 0.97, 0.91, 0.98, 1.19, 0.82, 0.76, 0.82,
0.71, 0.72, 0.73, 0.76, 0.79, 0.86, 0.83, 0.72, 0.76, 0.76, 0.89, 0.82, 0.89, 0.82, 0.89, 0.91, 0.83, 0.96, 1.14, 0.97,
1.40, 1.19, 0.98, 0.94, 1.00, 1.07, 1.37, 1.21, 1.48, 1.30, 1.57, 1.61, 1.37, 0.86, 0.83, 0.91, 0.82, 0.82, 0.88, 0.89,
0.96, 1.14, 0.98, 0.87, 0.93, 0.94, 1.02, 1.30, 1.07, 1.35, 1.38, 1.11, 1.56, 1.92, 1.79, 1.79, 1.59, 1.60, 1.72, 1.90,
1.79, 0.80, 0.85, 0.79, 0.93, 0.80, 0.85, 0.77, 0.74, 0.72, 0.77, 0.74, 0.72, 0.70, 0.70, 0.71, 0.76, 0.73, 0.79, 0.79,
0.73, 0.76, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.26, 1.26, 1.48, 1.23, 1.50, 1.71, 1.14, 1.19, 1.38, 1.46, 1.64, 1.94, 1.87, 1.84, 1.71, 1.02, 0.92, 1.00, 0.79, 0.85,
0.84, 0.91, 0.90, 0.98, 0.99, 0.77, 0.77, 0.83, 0.82, 0.79, 0.86, 0.84, 0.92, 0.99, 0.91, 1.24, 1.03, 1.33, 0.88, 0.94,
0.97, 1.41, 1.39, 1.18, 1.11, 1.51, 1.61, 1.59, 1.80, 1.91, 1.76, 1.54, 1.65, 1.76, 1.70, 1.70, 1.85, 1.85, 1.97, 1.99,
1.93, 1.28, 1.09, 1.39, 0.92, 0.97, 0.99, 1.18, 1.26, 1.52, 1.48, 0.83, 0.85, 0.90, 0.88, 0.93, 1.00, 0.77, 0.73, 0.78,
0.72, 0.71, 0.74, 0.75, 0.79, 0.86, 0.81, 0.75, 0.81, 0.79, 0.96, 0.88, 0.94, 0.86, 0.93, 0.92, 0.85, 1.08, 1.33, 1.05,
1.55, 1.31, 1.01, 1.05, 1.27, 1.31, 1.60, 1.47, 1.70, 1.54, 1.76, 1.76, 1.57, 0.93, 0.90, 0.99, 0.88, 0.88, 0.95, 0.97,
1.11, 1.39, 1.20, 0.92, 0.97, 1.01, 1.10, 1.39, 1.22, 1.51, 1.58, 1.32, 1.64, 1.97, 1.85, 1.91, 1.77, 1.74, 1.88, 1.99,
1.91, 0.79, 0.86, 0.80, 0.94, 0.84, 0.88, 0.74, 0.74, 0.71, 0.82, 0.77, 0.76, 0.70, 0.73, 0.72, 0.73, 0.70, 0.74, 0.85,
0.77, 0.82, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.34, 1.27, 1.53, 1.17, 1.46, 1.71, 0.98, 1.05, 1.20, 1.34, 1.48, 1.86, 1.82, 1.71, 1.62, 1.09, 0.94, 0.99, 0.79, 0.85,
0.82, 0.90, 0.87, 0.93, 0.96, 0.76, 0.74, 0.79, 0.76, 0.74, 0.79, 0.78, 0.85, 0.92, 0.85, 1.00, 0.93, 1.06, 0.81, 0.86,
0.89, 1.16, 1.12, 0.97, 0.95, 1.28, 1.38, 1.35, 1.60, 1.77, 1.57, 1.33, 1.50, 1.58, 1.69, 1.63, 1.82, 1.74, 1.91, 1.92,
1.80, 1.04, 0.97, 1.21, 0.90, 0.93, 0.97, 1.05, 1.21, 1.48, 1.37, 0.77, 0.80, 0.84, 0.85, 0.88, 0.92, 0.73, 0.71, 0.74,
0.74, 0.71, 0.75, 0.73, 0.79, 0.84, 0.78, 0.79, 0.86, 0.81, 1.05, 0.94, 0.99, 0.90, 0.95, 0.92, 0.86, 1.24, 1.44, 1.14,
1.59, 1.34, 1.02, 1.27, 1.50, 1.49, 1.80, 1.69, 1.86, 1.72, 1.87, 1.80, 1.69, 1.00, 0.98, 1.23, 0.95, 0.96, 1.09, 1.16,
1.37, 1.63, 1.46, 0.99, 1.10, 1.25, 1.24, 1.51, 1.41, 1.67, 1.77, 1.55, 1.72, 1.95, 1.89, 1.98, 1.91, 1.86, 1.97, 1.99,
1.94, 0.81, 0.89, 0.85, 0.98, 0.90, 0.94, 0.75, 0.78, 0.73, 0.89, 0.83, 0.82, 0.72, 0.77, 0.76, 0.72, 0.70, 0.71, 0.91,
0.83, 0.89, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.46, 1.34, 1.60, 1.16, 1.46, 1.71, 0.94, 0.99, 1.05, 1.26, 1.33, 1.74, 1.76, 1.57, 1.54, 1.23, 0.98, 1.05, 0.83, 0.89,
0.84, 0.92, 0.87, 0.91, 0.96, 0.78, 0.74, 0.79, 0.72, 0.72, 0.75, 0.76, 0.80, 0.88, 0.83, 0.94, 0.87, 0.95, 0.76, 0.80,
0.82, 0.97, 0.96, 0.89, 0.88, 1.08, 1.11, 1.10, 1.37, 1.59, 1.37, 1.07, 1.27, 1.34, 1.57, 1.45, 1.69, 1.55, 1.77, 1.79,
1.60, 0.93, 0.90, 0.99, 0.86, 0.87, 0.93, 0.96, 1.07, 1.35, 1.18, 0.73, 0.76, 0.77, 0.81, 0.82, 0.85, 0.70, 0.71, 0.72,
0.78, 0.73, 0.77, 0.73, 0.79, 0.82, 0.76, 0.83, 0.90, 0.84, 1.18, 0.98, 1.03, 0.92, 0.95, 0.90, 0.86, 1.32, 1.45, 1.15,
1.53, 1.27, 0.99, 1.42, 1.65, 1.58, 1.93, 1.83, 1.94, 1.81, 1.88, 1.74, 1.70, 1.19, 1.17, 1.44, 1.11, 1.15, 1.36, 1.41,
1.61, 1.81, 1.67, 1.22, 1.34, 1.50, 1.42, 1.65, 1.61, 1.82, 1.91, 1.75, 1.80, 1.89, 1.89, 1.98, 1.99, 1.94, 1.98, 1.92,
1.87, 0.86, 0.95, 0.92, 1.14, 0.98, 1.03, 0.79, 0.84, 0.77, 0.97, 0.90, 0.89, 0.76, 0.82, 0.82, 0.74, 0.72, 0.71, 0.98,
0.89, 0.97, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.60, 1.44, 1.68, 1.22, 1.49, 1.71, 0.93, 0.99, 0.99, 1.23, 1.22, 1.60, 1.68, 1.44, 1.49, 1.40, 1.14, 1.19, 0.89, 0.96,
0.89, 0.97, 0.89, 0.91, 0.98, 0.82, 0.76, 0.82, 0.71, 0.72, 0.73, 0.76, 0.79, 0.86, 0.83, 0.91, 0.83, 0.89, 0.72, 0.76,
0.76, 0.89, 0.89, 0.82, 0.82, 0.98, 0.96, 0.97, 1.14, 1.40, 1.19, 0.94, 1.00, 1.07, 1.37, 1.21, 1.48, 1.30, 1.57, 1.61,
1.37, 0.86, 0.83, 0.91, 0.82, 0.82, 0.88, 0.89, 0.96, 1.14, 0.98, 0.70, 0.72, 0.73, 0.77, 0.76, 0.79, 0.70, 0.72, 0.71,
0.82, 0.77, 0.80, 0.74, 0.79, 0.80, 0.74, 0.87, 0.93, 0.85, 1.23, 1.02, 1.02, 0.93, 0.93, 0.87, 0.85, 1.30, 1.35, 1.07,
1.38, 1.11, 0.94, 1.47, 1.71, 1.56, 1.97, 1.88, 1.92, 1.79, 1.79, 1.59, 1.60, 1.30, 1.35, 1.56, 1.37, 1.38, 1.59, 1.60,
1.79, 1.92, 1.79, 1.48, 1.57, 1.72, 1.61, 1.78, 1.79, 1.93, 1.99, 1.90, 1.86, 1.78, 1.86, 1.93, 1.99, 1.97, 1.90, 1.79,
1.72, 0.94, 1.07, 1.00, 1.37, 1.21, 1.30, 0.86, 0.91, 0.83, 1.14, 0.98, 0.96, 0.82, 0.88, 0.89, 0.79, 0.76, 0.73, 1.07,
0.94, 1.11, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.74, 1.57, 1.76, 1.33, 1.54, 1.71, 0.94, 1.05, 0.99, 1.26, 1.16, 1.46, 1.60, 1.34, 1.46, 1.59, 1.37, 1.37, 0.97, 1.11,
0.96, 1.10, 0.95, 0.94, 1.08, 0.89, 0.82, 0.88, 0.72, 0.76, 0.75, 0.80, 0.80, 0.88, 0.87, 0.91, 0.83, 0.87, 0.72, 0.76,
0.74, 0.83, 0.84, 0.78, 0.79, 0.96, 0.89, 0.92, 0.98, 1.23, 1.05, 0.86, 0.92, 0.95, 1.11, 0.98, 1.22, 1.03, 1.34, 1.42,
1.14, 0.79, 0.77, 0.84, 0.78, 0.76, 0.82, 0.82, 0.89, 0.97, 0.90, 0.70, 0.71, 0.71, 0.73, 0.72, 0.74, 0.73, 0.76, 0.72,
0.86, 0.81, 0.82, 0.76, 0.79, 0.77, 0.73, 0.90, 0.95, 0.86, 1.18, 1.03, 0.98, 0.92, 0.90, 0.83, 0.84, 1.19, 1.17, 0.98,
1.15, 0.97, 0.89, 1.42, 1.65, 1.44, 1.93, 1.83, 1.81, 1.67, 1.61, 1.36, 1.41, 1.32, 1.45, 1.58, 1.57, 1.53, 1.74, 1.70,
1.88, 1.94, 1.81, 1.69, 1.77, 1.87, 1.79, 1.89, 1.92, 1.98, 1.99, 1.98, 1.89, 1.65, 1.80, 1.82, 1.91, 1.94, 1.75, 1.61,
1.50, 1.07, 1.34, 1.27, 1.60, 1.45, 1.55, 0.93, 0.99, 0.90, 1.35, 1.18, 1.07, 0.87, 0.93, 0.96, 0.85, 0.82, 0.77, 1.15,
0.99, 1.27, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.86, 1.71, 1.82, 1.48, 1.62, 1.71, 0.98, 1.20, 1.05, 1.34, 1.17, 1.34, 1.53, 1.27, 1.46, 1.77, 1.60, 1.57, 1.16, 1.38,
1.12, 1.35, 1.06, 1.00, 1.28, 0.97, 0.89, 0.95, 0.76, 0.81, 0.79, 0.86, 0.85, 0.92, 0.93, 0.93, 0.85, 0.87, 0.74, 0.78,
0.74, 0.79, 0.82, 0.76, 0.79, 0.96, 0.85, 0.90, 0.94, 1.09, 0.99, 0.81, 0.85, 0.89, 0.95, 0.90, 0.99, 0.94, 1.10, 1.24,
0.98, 0.75, 0.73, 0.78, 0.74, 0.72, 0.77, 0.76, 0.82, 0.89, 0.83, 0.73, 0.71, 0.71, 0.71, 0.70, 0.72, 0.77, 0.80, 0.74,
0.90, 0.85, 0.84, 0.78, 0.79, 0.75, 0.73, 0.92, 0.95, 0.86, 1.05, 0.99, 0.94, 0.90, 0.86, 0.79, 0.81, 1.00, 0.98, 0.91,
0.96, 0.89, 0.83, 1.27, 1.50, 1.23, 1.80, 1.69, 1.63, 1.46, 1.37, 1.09, 1.16, 1.24, 1.44, 1.49, 1.69, 1.59, 1.80, 1.69,
1.87, 1.86, 1.72, 1.82, 1.91, 1.94, 1.92, 1.95, 1.99, 1.98, 1.91, 1.97, 1.89, 1.51, 1.72, 1.67, 1.77, 1.86, 1.55, 1.41,
1.25, 1.33, 1.58, 1.50, 1.80, 1.63, 1.74, 1.04, 1.21, 0.97, 1.48, 1.37, 1.21, 0.93, 0.97, 1.05, 0.92, 0.88, 0.84, 1.14,
1.02, 1.34, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.94, 1.84, 1.87, 1.64, 1.71, 1.71, 1.14, 1.38, 1.19, 1.46, 1.23, 1.26, 1.48, 1.26, 1.50, 1.91, 1.80, 1.76, 1.41, 1.61,
1.39, 1.59, 1.33, 1.24, 1.51, 1.18, 0.97, 1.11, 0.82, 0.88, 0.86, 0.94, 0.92, 0.99, 1.03, 0.98, 0.91, 0.90, 0.79, 0.84,
0.77, 0.79, 0.84, 0.77, 0.83, 0.99, 0.85, 0.91, 0.92, 1.02, 1.00, 0.79, 0.80, 0.86, 0.88, 0.84, 0.92, 0.88, 0.97, 1.10,
0.94, 0.74, 0.71, 0.74, 0.72, 0.70, 0.73, 0.72, 0.76, 0.82, 0.77, 0.77, 0.73, 0.74, 0.71, 0.70, 0.73, 0.83, 0.85, 0.78,
0.92, 0.88, 0.86, 0.81, 0.79, 0.74, 0.75, 0.92, 0.93, 0.85, 0.96, 0.94, 0.88, 0.86, 0.81, 0.75, 0.79, 0.93, 0.90, 0.85,
0.88, 0.82, 0.77, 1.05, 1.27, 0.99, 1.60, 1.47, 1.39, 1.20, 1.11, 0.95, 0.97, 1.08, 1.33, 1.31, 1.70, 1.55, 1.76, 1.57,
1.76, 1.70, 1.54, 1.85, 1.97, 1.91, 1.99, 1.97, 1.99, 1.91, 1.77, 1.88, 1.85, 1.39, 1.64, 1.51, 1.58, 1.74, 1.32, 1.22,
1.01, 1.54, 1.76, 1.65, 1.93, 1.70, 1.85, 1.28, 1.39, 1.09, 1.52, 1.48, 1.26, 0.97, 0.99, 1.18, 1.00, 0.93, 0.90, 1.05,
1.01, 1.31, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.97, 1.92, 1.88, 1.79, 1.79, 1.71, 1.37, 1.59, 1.38, 1.60, 1.35, 1.23, 1.47, 1.30, 1.56, 1.99, 1.93, 1.90, 1.60, 1.78,
1.61, 1.79, 1.57, 1.48, 1.72, 1.40, 1.14, 1.37, 0.89, 0.96, 0.94, 1.07, 1.00, 1.21, 1.30, 1.14, 0.98, 0.96, 0.86, 0.91,
0.83, 0.82, 0.88, 0.82, 0.89, 1.11, 0.87, 0.94, 0.93, 1.02, 1.07, 0.80, 0.79, 0.85, 0.82, 0.80, 0.87, 0.85, 0.93, 1.02,
0.93, 0.77, 0.72, 0.74, 0.71, 0.70, 0.70, 0.71, 0.72, 0.77, 0.74, 0.82, 0.76, 0.79, 0.72, 0.73, 0.76, 0.89, 0.89, 0.82,
0.93, 0.91, 0.86, 0.83, 0.79, 0.73, 0.76, 0.91, 0.89, 0.83, 0.89, 0.89, 0.82, 0.82, 0.76, 0.72, 0.76, 0.86, 0.83, 0.79,
0.82, 0.76, 0.73, 0.94, 1.00, 0.91, 1.37, 1.21, 1.14, 0.98, 0.96, 0.88, 0.89, 0.96, 1.14, 1.07, 1.60, 1.40, 1.61, 1.37,
1.57, 1.48, 1.30, 1.78, 1.93, 1.79, 1.99, 1.92, 1.90, 1.79, 1.59, 1.72, 1.79, 1.30, 1.56, 1.35, 1.38, 1.60, 1.11, 1.07,
0.94, 1.68, 1.86, 1.71, 1.97, 1.68, 1.86, 1.44, 1.49, 1.22, 1.44, 1.49, 1.22, 0.99, 0.99, 1.23, 1.19, 0.98, 0.97, 0.97,
0.98, 1.19, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.94, 1.97, 1.87, 1.91, 1.85, 1.71, 1.60, 1.77, 1.58, 1.74, 1.51, 1.26, 1.48, 1.39, 1.64, 1.99, 1.97, 1.99, 1.70, 1.85,
1.76, 1.91, 1.76, 1.70, 1.88, 1.55, 1.33, 1.57, 0.96, 1.08, 1.05, 1.31, 1.27, 1.47, 1.54, 1.39, 1.20, 1.11, 0.93, 0.99,
0.90, 0.88, 0.95, 0.88, 0.97, 1.32, 0.92, 1.01, 0.97, 1.10, 1.22, 0.84, 0.80, 0.88, 0.79, 0.79, 0.85, 0.86, 0.92, 1.02,
0.94, 0.82, 0.76, 0.77, 0.72, 0.73, 0.70, 0.72, 0.71, 0.74, 0.74, 0.88, 0.81, 0.85, 0.75, 0.77, 0.82, 0.94, 0.93, 0.86,
0.92, 0.92, 0.86, 0.85, 0.79, 0.74, 0.79, 0.88, 0.85, 0.81, 0.82, 0.83, 0.77, 0.78, 0.73, 0.71, 0.75, 0.79, 0.77, 0.74,
0.77, 0.73, 0.70, 0.86, 0.92, 0.84, 1.14, 0.99, 0.98, 0.91, 0.90, 0.84, 0.83, 0.88, 0.97, 0.94, 1.41, 1.18, 1.39, 1.11,
1.33, 1.24, 1.03, 1.61, 1.80, 1.59, 1.91, 1.84, 1.76, 1.64, 1.38, 1.51, 1.71, 1.26, 1.50, 1.23, 1.19, 1.46, 0.99, 1.00,
0.91, 1.70, 1.85, 1.65, 1.93, 1.54, 1.76, 1.52, 1.48, 1.26, 1.28, 1.39, 1.09, 0.99, 0.97, 1.18, 1.31, 1.01, 1.05, 0.90,
0.93, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.86, 1.95, 1.82, 1.98, 1.89, 1.71, 1.80, 1.91, 1.77, 1.86, 1.67, 1.34, 1.53, 1.51, 1.72, 1.92, 1.91, 1.99, 1.69, 1.82,
1.80, 1.94, 1.87, 1.86, 1.97, 1.59, 1.44, 1.69, 1.05, 1.24, 1.27, 1.49, 1.50, 1.69, 1.72, 1.63, 1.46, 1.37, 1.00, 1.23,
0.98, 0.95, 1.09, 0.96, 1.16, 1.55, 0.99, 1.25, 1.10, 1.24, 1.41, 0.90, 0.85, 0.94, 0.79, 0.81, 0.85, 0.89, 0.94, 1.09,
0.98, 0.89, 0.82, 0.83, 0.74, 0.77, 0.72, 0.76, 0.73, 0.75, 0.78, 0.94, 0.86, 0.91, 0.79, 0.83, 0.89, 0.99, 0.95, 0.90,
0.90, 0.92, 0.84, 0.86, 0.79, 0.75, 0.81, 0.85, 0.80, 0.78, 0.76, 0.77, 0.73, 0.74, 0.71, 0.71, 0.73, 0.74, 0.74, 0.71,
0.76, 0.72, 0.70, 0.79, 0.85, 0.78, 0.98, 0.92, 0.93, 0.85, 0.87, 0.82, 0.79, 0.81, 0.89, 0.86, 1.16, 0.97, 1.12, 0.95,
1.06, 1.00, 0.93, 1.38, 1.60, 1.35, 1.77, 1.71, 1.57, 1.48, 1.20, 1.28, 1.62, 1.27, 1.46, 1.17, 1.05, 1.34, 0.96, 0.99,
0.90, 1.63, 1.74, 1.50, 1.80, 1.33, 1.58, 1.48, 1.37, 1.21, 1.04, 1.21, 0.97, 0.97, 0.93, 1.05, 1.34, 1.02, 1.14, 0.84,
0.88, 0.92, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.74, 1.89, 1.76, 1.98, 1.89, 1.71, 1.93, 1.99, 1.91, 1.94, 1.82, 1.46, 1.60, 1.65, 1.80, 1.79, 1.77, 1.92, 1.57, 1.69,
1.74, 1.87, 1.88, 1.94, 1.98, 1.53, 1.45, 1.70, 1.18, 1.32, 1.42, 1.58, 1.65, 1.83, 1.81, 1.81, 1.67, 1.61, 1.19, 1.44,
1.17, 1.11, 1.36, 1.15, 1.41, 1.75, 1.22, 1.50, 1.34, 1.42, 1.61, 0.98, 0.92, 1.03, 0.83, 0.86, 0.89, 0.95, 0.98, 1.23,
1.14, 0.97, 0.89, 0.90, 0.78, 0.82, 0.76, 0.82, 0.77, 0.79, 0.84, 0.98, 0.90, 0.98, 0.83, 0.89, 0.97, 1.03, 0.95, 0.92,
0.86, 0.90, 0.82, 0.86, 0.79, 0.77, 0.84, 0.81, 0.76, 0.76, 0.72, 0.73, 0.70, 0.72, 0.71, 0.73, 0.73, 0.72, 0.74, 0.71,
0.78, 0.74, 0.72, 0.75, 0.80, 0.76, 0.94, 0.88, 0.91, 0.83, 0.87, 0.84, 0.79, 0.76, 0.82, 0.80, 0.97, 0.89, 0.96, 0.88,
0.95, 0.94, 0.87, 1.11, 1.37, 1.10, 1.59, 1.57, 1.37, 1.33, 1.05, 1.08, 1.54, 1.34, 1.46, 1.16, 0.99, 1.26, 0.96, 1.05,
0.92, 1.45, 1.55, 1.27, 1.60, 1.07, 1.34, 1.35, 1.18, 1.07, 0.93, 0.99, 0.90, 0.93, 0.87, 0.96, 1.27, 0.99, 1.15, 0.77,
0.82, 0.85, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.60, 1.78, 1.68, 1.93, 1.86, 1.71, 1.97, 1.99, 1.99, 1.97, 1.93, 1.60, 1.68, 1.78, 1.86, 1.61, 1.57, 1.79, 1.37, 1.48,
1.59, 1.72, 1.79, 1.92, 1.90, 1.38, 1.35, 1.60, 1.23, 1.30, 1.47, 1.56, 1.71, 1.88, 1.79, 1.92, 1.79, 1.79, 1.30, 1.56,
1.35, 1.37, 1.59, 1.38, 1.60, 1.90, 1.48, 1.72, 1.57, 1.61, 1.79, 1.21, 1.00, 1.30, 0.89, 0.94, 0.96, 1.07, 1.14, 1.40,
1.37, 1.14, 0.96, 0.98, 0.82, 0.88, 0.82, 0.89, 0.83, 0.86, 0.91, 1.02, 0.93, 1.07, 0.87, 0.94, 1.11, 1.02, 0.93, 0.93,
0.82, 0.87, 0.80, 0.85, 0.79, 0.80, 0.85, 0.77, 0.72, 0.74, 0.71, 0.70, 0.70, 0.71, 0.72, 0.77, 0.74, 0.72, 0.76, 0.73,
0.82, 0.79, 0.76, 0.73, 0.79, 0.76, 0.93, 0.86, 0.91, 0.83, 0.89, 0.89, 0.82, 0.72, 0.76, 0.76, 0.89, 0.82, 0.89, 0.82,
0.89, 0.91, 0.83, 0.96, 1.14, 0.97, 1.40, 1.44, 1.19, 1.22, 0.99, 0.98, 1.49, 1.44, 1.49, 1.22, 0.99, 1.23, 0.98, 1.19,
0.97, 1.21, 1.30, 1.00, 1.37, 0.94, 1.07, 1.14, 0.98, 0.96, 0.86, 0.91, 0.83, 0.88, 0.82, 0.89, 1.11, 0.94, 1.07, 0.73,
0.76, 0.79, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.46, 1.65, 1.60, 1.82, 1.80, 1.71, 1.93, 1.91, 1.99, 1.94, 1.98, 1.74, 1.76, 1.89, 1.89, 1.42, 1.34, 1.61, 1.11, 1.22,
1.36, 1.50, 1.61, 1.81, 1.75, 1.15, 1.17, 1.41, 1.18, 1.19, 1.42, 1.44, 1.65, 1.83, 1.67, 1.94, 1.81, 1.88, 1.32, 1.58,
1.45, 1.57, 1.74, 1.53, 1.70, 1.98, 1.69, 1.87, 1.77, 1.79, 1.92, 1.45, 1.27, 1.55, 0.97, 1.07, 1.11, 1.34, 1.37, 1.59,
1.60, 1.35, 1.07, 1.18, 0.86, 0.93, 0.87, 0.96, 0.90, 0.93, 0.99, 1.03, 0.95, 1.15, 0.90, 0.99, 1.27, 0.98, 0.90, 0.92,
0.78, 0.83, 0.77, 0.84, 0.79, 0.82, 0.86, 0.73, 0.71, 0.73, 0.72, 0.70, 0.73, 0.72, 0.76, 0.81, 0.76, 0.76, 0.82, 0.77,
0.89, 0.85, 0.82, 0.75, 0.80, 0.80, 0.94, 0.88, 0.94, 0.87, 0.95, 0.96, 0.88, 0.72, 0.74, 0.76, 0.83, 0.78, 0.84, 0.79,
0.87, 0.91, 0.83, 0.89, 0.98, 0.92, 1.23, 1.34, 1.05, 1.16, 0.99, 0.96, 1.46, 1.57, 1.54, 1.33, 1.05, 1.26, 1.08, 1.37,
1.10, 0.98, 1.03, 0.92, 1.14, 0.86, 0.95, 0.97, 0.90, 0.89, 0.79, 0.84, 0.77, 0.82, 0.76, 0.82, 0.97, 0.89, 0.98, 0.71,
0.72, 0.74, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.34, 1.51, 1.53, 1.67, 1.72, 1.71, 1.80, 1.77, 1.91, 1.86, 1.98, 1.86, 1.82, 1.95, 1.89, 1.24, 1.10, 1.41, 0.95, 0.99,
1.09, 1.25, 1.37, 1.63, 1.55, 0.96, 0.98, 1.16, 1.05, 1.00, 1.27, 1.23, 1.50, 1.69, 1.46, 1.86, 1.72, 1.87, 1.24, 1.49,
1.44, 1.69, 1.80, 1.59, 1.69, 1.97, 1.82, 1.94, 1.91, 1.92, 1.99, 1.63, 1.50, 1.74, 1.16, 1.33, 1.38, 1.58, 1.60, 1.77,
1.80, 1.48, 1.21, 1.37, 0.90, 0.97, 0.93, 1.05, 0.97, 1.04, 1.21, 0.99, 0.95, 1.14, 0.92, 1.02, 1.34, 0.94, 0.86, 0.90,
0.74, 0.79, 0.75, 0.81, 0.79, 0.84, 0.86, 0.71, 0.71, 0.73, 0.76, 0.73, 0.77, 0.74, 0.80, 0.85, 0.78, 0.81, 0.89, 0.84,
0.97, 0.92, 0.88, 0.79, 0.85, 0.86, 0.98, 0.92, 1.00, 0.93, 1.06, 1.12, 0.95, 0.74, 0.74, 0.78, 0.79, 0.76, 0.82, 0.79,
0.87, 0.93, 0.85, 0.85, 0.94, 0.90, 1.09, 1.27, 0.99, 1.17, 1.05, 0.96, 1.46, 1.71, 1.62, 1.48, 1.20, 1.34, 1.28, 1.57,
1.35, 0.90, 0.94, 0.85, 0.98, 0.81, 0.89, 0.89, 0.83, 0.82, 0.75, 0.78, 0.73, 0.77, 0.72, 0.76, 0.89, 0.83, 0.91, 0.71,
0.70, 0.72, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 },
{ 1.26, 1.39, 1.48, 1.51, 1.64, 1.71, 1.60, 1.58, 1.77, 1.74, 1.91, 1.94, 1.87, 1.97, 1.85, 1.10, 0.97, 1.22, 0.88, 0.92,
0.95, 1.01, 1.11, 1.39, 1.32, 0.88, 0.90, 0.97, 0.96, 0.93, 1.05, 0.99, 1.27, 1.47, 1.20, 1.70, 1.54, 1.76, 1.08, 1.31,
1.33, 1.70, 1.76, 1.55, 1.57, 1.88, 1.85, 1.91, 1.97, 1.99, 1.99, 1.70, 1.65, 1.85, 1.41, 1.54, 1.61, 1.76, 1.80, 1.91,
1.93, 1.52, 1.26, 1.48, 0.92, 0.99, 0.97, 1.18, 1.09, 1.28, 1.39, 0.94, 0.93, 1.05, 0.92, 1.01, 1.31, 0.88, 0.81, 0.86,
0.72, 0.75, 0.74, 0.79, 0.79, 0.86, 0.85, 0.71, 0.73, 0.75, 0.82, 0.77, 0.83, 0.78, 0.85, 0.88, 0.81, 0.88, 0.97, 0.90,
1.18, 1.00, 0.93, 0.86, 0.92, 0.94, 1.14, 0.99, 1.24, 1.03, 1.33, 1.39, 1.11, 0.79, 0.77, 0.84, 0.79, 0.77, 0.84, 0.83,
0.90, 0.98, 0.91, 0.85, 0.92, 0.91, 1.02, 1.26, 1.00, 1.23, 1.19, 0.99, 1.50, 1.84, 1.71, 1.64, 1.38, 1.46, 1.51, 1.76,
1.59, 0.84, 0.88, 0.80, 0.94, 0.79, 0.86, 0.82, 0.77, 0.76, 0.74, 0.74, 0.71, 0.73, 0.70, 0.72, 0.82, 0.77, 0.85, 0.74,
0.70, 0.73, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 }

72
src/constants/warpsin.h Normal file
View file

@ -0,0 +1,72 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* Precalculated sinus warps
*
* =======================================================================
*/
#if 0
// In case you wonder how these were generated/what they mean:
for (int i = 0; i < 256; i++) {
r_turbsin[i] = 8.0 * sin( (float)i / TURBSCALE ); // TURBSCALE = 256.0 / (2.0 * M_PI)
}
// so r_turbsin[i] is 8 * sin( i/TURBSCALE );
// however, the values are multiplied with 0.5 in RI_Init()
// so what's actually used is 4 * sin(i/TURBSCALE)
// in R_EmitWaterPolys() something like
s = os + r_turbsin [ (int) ( ( ot * 0.125 + r_newrefdef.time ) * TURBSCALE ) & 255 ];
// is used; which should (except for rounding errors from lookup table) be equivalent to
s = os + 4.0*sin( ot*0.125 + r_newrefdef.time );
#endif // 0
0, 0.19633, 0.392541, 0.588517, 0.784137, 0.979285, 1.17384, 1.3677,
1.56072, 1.75281, 1.94384, 2.1337, 2.32228, 2.50945, 2.69512, 2.87916,
3.06147, 3.24193, 3.42044, 3.59689, 3.77117, 3.94319, 4.11282, 4.27998,
4.44456, 4.60647, 4.76559, 4.92185, 5.07515, 5.22538, 5.37247, 5.51632,
5.65685, 5.79398, 5.92761, 6.05767, 6.18408, 6.30677, 6.42566, 6.54068,
6.65176, 6.75883, 6.86183, 6.9607, 7.05537, 7.14579, 7.23191, 7.31368,
7.39104, 7.46394, 7.53235, 7.59623, 7.65552, 7.71021, 7.76025, 7.80562,
7.84628, 7.88222, 7.91341, 7.93984, 7.96148, 7.97832, 7.99036, 7.99759,
8, 7.99759, 7.99036, 7.97832, 7.96148, 7.93984, 7.91341, 7.88222,
7.84628, 7.80562, 7.76025, 7.71021, 7.65552, 7.59623, 7.53235, 7.46394,
7.39104, 7.31368, 7.23191, 7.14579, 7.05537, 6.9607, 6.86183, 6.75883,
6.65176, 6.54068, 6.42566, 6.30677, 6.18408, 6.05767, 5.92761, 5.79398,
5.65685, 5.51632, 5.37247, 5.22538, 5.07515, 4.92185, 4.76559, 4.60647,
4.44456, 4.27998, 4.11282, 3.94319, 3.77117, 3.59689, 3.42044, 3.24193,
3.06147, 2.87916, 2.69512, 2.50945, 2.32228, 2.1337, 1.94384, 1.75281,
1.56072, 1.3677, 1.17384, 0.979285, 0.784137, 0.588517, 0.392541, 0.19633,
9.79717e-16, -0.19633, -0.392541, -0.588517, -0.784137, -0.979285, -1.17384, -1.3677,
-1.56072, -1.75281, -1.94384, -2.1337, -2.32228, -2.50945, -2.69512, -2.87916,
-3.06147, -3.24193, -3.42044, -3.59689, -3.77117, -3.94319, -4.11282, -4.27998,
-4.44456, -4.60647, -4.76559, -4.92185, -5.07515, -5.22538, -5.37247, -5.51632,
-5.65685, -5.79398, -5.92761, -6.05767, -6.18408, -6.30677, -6.42566, -6.54068,
-6.65176, -6.75883, -6.86183, -6.9607, -7.05537, -7.14579, -7.23191, -7.31368,
-7.39104, -7.46394, -7.53235, -7.59623, -7.65552, -7.71021, -7.76025, -7.80562,
-7.84628, -7.88222, -7.91341, -7.93984, -7.96148, -7.97832, -7.99036, -7.99759,
-8, -7.99759, -7.99036, -7.97832, -7.96148, -7.93984, -7.91341, -7.88222,
-7.84628, -7.80562, -7.76025, -7.71021, -7.65552, -7.59623, -7.53235, -7.46394,
-7.39104, -7.31368, -7.23191, -7.14579, -7.05537, -6.9607, -6.86183, -6.75883,
-6.65176, -6.54068, -6.42566, -6.30677, -6.18408, -6.05767, -5.92761, -5.79398,
-5.65685, -5.51632, -5.37247, -5.22538, -5.07515, -4.92185, -4.76559, -4.60647,
-4.44456, -4.27998, -4.11282, -3.94319, -3.77117, -3.59689, -3.42044, -3.24193,
-3.06147, -2.87916, -2.69512, -2.50945, -2.32228, -2.1337, -1.94384, -1.75281,
-1.56072, -1.3677, -1.17384, -0.979285, -0.784137, -0.588517, -0.392541, -0.19633,

317
src/files/pcx.c Normal file
View file

@ -0,0 +1,317 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* The PCX file format
*
* =======================================================================
*/
#include "../common/header/ref_shared.h"
// Fix Jennell Jaquays' name in the Quitscreen
// this is 98x11 pixels, each value an index
// into the standard baseq2/pak0/pics/quit.pcx colormap
static unsigned char quitscreenfix[] = {
191,191,191,47,28,39,4,4,39,1,47,28,47,28,29,1,
28,28,47,31,31,1,29,31,1,28,47,47,47,47,29,28,
47,31,30,28,40,40,4,28,28,40,39,40,29,102,102,245,
28,39,4,4,39,103,40,40,1,1,102,94,47,47,1,94,
94,94,94,47,102,245,103,103,103,47,1,102,1,102,29,29,
29,29,47,28,245,31,31,31,47,1,28,1,28,47,1,102, 102,102,
191,191,142,47,4,8,8,8,8,4,47,28,1,28,29,28,
29,29,31,1,47,245,47,47,28,28,31,47,28,1,31,1,
1,245,47,39,8,8,8,40,39,8,8,8,39,1,1,47,
4,8,8,8,8,4,47,29,28,31,28,28,29,28,28,28,
29,28,31,28,47,29,1,28,31,47,1,28,1,1,29,29,
29,47,28,1,28,28,245,28,28,28,28,47,29,28,47,102,102,103,
191,191,142,31,29,36,8,8,36,31,40,39,40,4,1,1,
39,40,39,40,40,31,28,40,40,4,39,40,28,47,31,40,
39,40,4,1,36,8,8,4,47,36,8,8,39,1,1,1,
29,36,8,8,36,4,4,39,40,4,47,1,47,40,40,39,
39,40,28,40,40,47,45,39,40,28,4,39,40,4,39,1,
28,4,40,28,28,4,39,28,47,40,40,39,40,39,28,28,1,103,
1,142,29,142,28,39,8,8,36,36,8,8,8,8,36,1,
8,8,8,8,8,36,39,8,8,8,8,8,36,40,36,8,
8,8,8,36,40,8,8,40,1,4,8,8,40,1,1,31,
28,39,8,8,36,8,8,8,8,8,36,31,36,8,8,8,
8,8,36,8,8,4,40,8,8,36,8,8,8,8,8,36,
40,8,8,40,39,8,8,40,36,8,8,8,8,8,39,29,28,29,
103,191,142,47,28,40,8,8,40,8,8,33,33,8,8,36,
8,8,36,36,8,8,36,8,8,36,36,8,8,36,8,8,
33,33,8,8,36,8,8,4,47,40,8,8,39,47,28,245,
28,40,8,8,40,40,36,36,33,8,8,36,8,8,36,36,
8,8,36,8,8,40,40,8,8,40,4,36,36,33,8,8,
36,8,8,39,39,8,8,36,8,8,33,36,36,39,28,1,47,28,
103,246,1,47,1,39,8,8,40,8,8,8,8,8,8,36,
8,8,4,40,8,8,36,8,8,40,4,8,8,36,8,8,
8,8,8,8,36,8,8,40,29,39,8,8,39,1,1,47,
1,39,8,8,40,36,8,8,8,8,8,36,8,8,4,40,
8,8,36,8,8,40,39,8,8,40,36,8,8,8,8,8,
36,8,8,39,40,8,8,40,36,8,8,8,8,36,28,1,1,29,
103,47,40,40,4,36,8,8,36,8,8,33,36,36,36,4,
8,8,39,4,8,8,36,8,8,4,40,8,8,36,8,8,
33,36,36,36,36,8,8,40,31,40,8,8,40,47,40,40,
4,36,8,8,36,8,8,33,33,8,8,36,8,8,36,36,
8,8,36,8,8,36,36,8,8,36,8,8,33,33,8,8,
36,8,8,36,36,8,8,4,39,36,36,33,8,8,4,40,4,31,
191,40,8,8,8,8,8,36,29,36,8,8,8,8,8,40,
8,8,40,4,8,8,36,8,8,40,39,8,8,39,36,8,
8,8,8,8,39,8,8,39,45,4,8,8,40,40,8,8,
8,8,8,36,29,36,8,8,8,8,8,40,36,8,8,8,
8,8,40,36,8,8,8,8,8,40,36,8,8,8,8,8,
40,36,8,8,8,8,8,36,8,8,8,8,8,36,4,8,8,4,
47,45,40,39,40,39,39,245,246,1,40,40,40,39,4,47,
40,4,28,29,39,40,30,39,39,1,28,40,4,28,1,40,
40,40,39,4,29,40,39,1,1,1,4,4,47,45,40,39,
40,39,39,245,246,29,39,40,40,40,4,47,28,39,39,36,
8,8,4,1,39,40,4,40,40,1,29,4,39,4,40,39,
1,39,36,36,33,8,8,4,39,4,39,4,40,47,36,8,8,40,
1,28,47,28,28,29,1,28,47,28,31,28,28,27,47,28,
45,246,30,28,245,29,47,47,29,30,28,47,27,1,246,47,
47,47,1,28,47,28,47,1,47,47,1,29,29,47,47,28,
28,29,1,47,1,47,47,28,31,47,47,31,47,47,47,4,
8,8,39,245,1,47,28,245,28,47,31,28,47,28,28,28,
40,8,8,8,8,8,36,47,28,1,246,47,1,40,8,8,36,1,
47,1,102,1,102,102,47,94,94,102,47,47,102,102,102,102,
94,1,94,47,102,1,102,47,30,30,102,27,47,102,94,1,
102,47,1,94,102,103,1,102,103,103,47,47,47,29,1,29,
28,28,29,28,1,47,28,31,29,1,47,29,28,1,1,47,
4,39,1,47,47,1,28,28,28,47,1,28,45,28,47,47,
1,40,4,4,40,4,29,28,31,45,47,28,47,47,4,40,28,28
};
static void
fixQuitScreen(byte* px)
{
// overwrite 11 lines, 98 pixels each, from quitscreenfix[]
// starting at line 140, column 188
// quitscreen is 320x240 px
int r, qsIdx = 0;
px += 140*320; // go to line 140
px += 188; // to colum 188
for(r=0; r<11; ++r)
{
memcpy(px, quitscreenfix+qsIdx, 98);
qsIdx += 98;
px += 320;
}
}
void
LoadPCX(char *origname, byte **pic, byte **palette, int *width, int *height)
{
byte *raw;
pcx_t *pcx;
int x, y;
int len, full_size;
int pcx_width, pcx_height;
qboolean image_issues = false;
int dataByte, runLength;
byte *out, *pix;
char filename[256];
Q_strlcpy(filename, origname, sizeof(filename));
/* Add the extension */
if (strcmp(COM_FileExtension(filename), "pcx"))
{
Q_strlcat(filename, ".pcx", sizeof(filename));
}
*pic = NULL;
if (palette)
{
*palette = NULL;
}
/* load the file */
len = ri.FS_LoadFile(filename, (void **)&raw);
if (!raw || len < sizeof(pcx_t))
{
R_Printf(PRINT_DEVELOPER, "Bad pcx file %s\n", filename);
return;
}
/* parse the PCX file */
pcx = (pcx_t *)raw;
pcx->xmin = LittleShort(pcx->xmin);
pcx->ymin = LittleShort(pcx->ymin);
pcx->xmax = LittleShort(pcx->xmax);
pcx->ymax = LittleShort(pcx->ymax);
pcx->hres = LittleShort(pcx->hres);
pcx->vres = LittleShort(pcx->vres);
pcx->bytes_per_line = LittleShort(pcx->bytes_per_line);
pcx->palette_type = LittleShort(pcx->palette_type);
raw = &pcx->data;
pcx_width = pcx->xmax - pcx->xmin;
pcx_height = pcx->ymax - pcx->ymin;
if ((pcx->manufacturer != 0x0a) || (pcx->version != 5) ||
(pcx->encoding != 1) || (pcx->bits_per_pixel != 8) ||
(pcx_width >= 4096) || (pcx_height >= 4096))
{
R_Printf(PRINT_ALL, "Bad pcx file %s\n", filename);
ri.FS_FreeFile(pcx);
return;
}
full_size = (pcx_height + 1) * (pcx_width + 1);
out = malloc(full_size);
if (!out)
{
R_Printf(PRINT_ALL, "Can't allocate\n");
ri.FS_FreeFile(pcx);
return;
}
*pic = out;
pix = out;
if (palette)
{
*palette = malloc(768);
if (!(*palette))
{
R_Printf(PRINT_ALL, "Can't allocate\n");
free(out);
ri.FS_FreeFile(pcx);
return;
}
if (len > 768)
{
memcpy(*palette, (byte *)pcx + len - 768, 768);
}
else
{
image_issues = true;
}
}
if (width)
{
*width = pcx_width + 1;
}
if (height)
{
*height = pcx_height + 1;
}
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
{
for (x = 0; x <= pcx_width; )
{
if (raw - (byte *)pcx > len)
{
// no place for read
image_issues = true;
x = pcx_width;
break;
}
dataByte = *raw++;
if ((dataByte & 0xC0) == 0xC0)
{
runLength = dataByte & 0x3F;
if (raw - (byte *)pcx > len)
{
// no place for read
image_issues = true;
x = pcx_width;
break;
}
dataByte = *raw++;
}
else
{
runLength = 1;
}
while (runLength-- > 0)
{
if ((*pic + full_size) <= (pix + x))
{
// no place for write
image_issues = true;
x += runLength;
runLength = 0;
}
else
{
pix[x++] = dataByte;
}
}
}
}
if (raw - (byte *)pcx > len)
{
R_Printf(PRINT_DEVELOPER, "PCX file %s was malformed", filename);
free(*pic);
*pic = NULL;
}
else if(pcx_width == 319 && pcx_height == 239
&& Q_strcasecmp(origname, "pics/quit.pcx") == 0
&& Com_BlockChecksum(pcx, len) == 3329419434u)
{
// it's the quit screen, and the baseq2 one (identified by checksum)
// so fix it
fixQuitScreen(*pic);
}
if (image_issues)
{
R_Printf(PRINT_ALL, "PCX file %s has possible size issues.\n", filename);
}
ri.FS_FreeFile(pcx);
}
void
GetPCXInfo(char *filename, int *width, int *height)
{
pcx_t *pcx;
byte *raw;
ri.FS_LoadFile(filename, (void **)&raw);
if (!raw)
{
return;
}
pcx = (pcx_t *)raw;
*width = pcx->xmax + 1;
*height = pcx->ymax + 1;
ri.FS_FreeFile(raw);
return;
}

90
src/files/pvs.c Normal file
View file

@ -0,0 +1,90 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* The PVS Decompress
*
* =======================================================================
*/
#include "../common/header/ref_shared.h"
/*
===================
Mod_DecompressVis
===================
*/
byte *
Mod_DecompressVis(byte *in, int row)
{
YQ2_ALIGNAS_TYPE(int) static byte decompressed[MAX_MAP_LEAFS / 8];
int c;
byte *out;
out = decompressed;
if (!in)
{
/* no vis info, so make all visible */
while (row)
{
*out++ = 0xff;
row--;
}
return decompressed;
}
do
{
if (*in)
{
*out++ = *in++;
continue;
}
c = in[1];
in += 2;
while (c)
{
*out++ = 0;
c--;
}
}
while (out - decompressed < row);
return decompressed;
}
float
Mod_RadiusFromBounds(const vec3_t mins, const vec3_t maxs)
{
int i;
vec3_t corner;
for (i = 0; i < 3; i++)
{
corner[i] = fabs(mins[i]) > fabs(maxs[i]) ? fabs(mins[i]) : fabs(maxs[i]);
}
return VectorLength(corner);
}

425
src/files/stb.c Normal file
View file

@ -0,0 +1,425 @@
/*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (C) 2015 Daniel Gibson
*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* File formats supported by stb_image, for now only tga, png, jpg
* See also https://github.com/nothings/stb
*
* =======================================================================
*/
#include <stdlib.h>
#include "../common/header/ref_shared.h"
// don't need HDR stuff
#define STBI_NO_LINEAR
#define STBI_NO_HDR
// make sure STB_image uses standard malloc(), as we'll use standard free() to deallocate
#define STBI_MALLOC(sz) malloc(sz)
#define STBI_REALLOC(p,sz) realloc(p,sz)
#define STBI_FREE(p) free(p)
// include implementation part of stb_image into this file
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
// include resize implementation
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h"
/*
* origname: the filename to be opened, might be without extension
* type: extension of the type we wanna open ("jpg", "png" or "tga")
* pic: pointer RGBA pixel data will be assigned to
*/
qboolean
LoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height)
{
char filename[256];
Q_strlcpy(filename, origname, sizeof(filename));
/* Add the extension */
if (strcmp(COM_FileExtension(filename), type) != 0)
{
Q_strlcat(filename, ".", sizeof(filename));
Q_strlcat(filename, type, sizeof(filename));
}
*pic = NULL;
byte* rawdata = NULL;
int rawsize = ri.FS_LoadFile(filename, (void **)&rawdata);
if (rawdata == NULL)
{
return false;
}
int w, h, bytesPerPixel;
byte* data = NULL;
data = stbi_load_from_memory(rawdata, rawsize, &w, &h, &bytesPerPixel, STBI_rgb_alpha);
if (data == NULL)
{
R_Printf(PRINT_ALL, "%s couldn't load data from %s: %s!\n", __func__, filename, stbi_failure_reason());
ri.FS_FreeFile(rawdata);
return false;
}
ri.FS_FreeFile(rawdata);
R_Printf(PRINT_DEVELOPER, "%s() loaded: %s\n", __func__, filename);
*pic = data;
*width = w;
*height = h;
return true;
}
qboolean
ResizeSTB(byte *input_pixels, int input_width, int input_height,
byte *output_pixels, int output_width, int output_height)
{
if (stbir_resize_uint8(input_pixels, input_width, input_height, 0,
output_pixels, output_width, output_height, 0, 4))
return true;
return false;
}
// We have 16 color palette, 256 / 16 should be enough
#define COLOR_DISTANCE 16
void
SmoothColorImage(unsigned *dst, size_t size, size_t rstep)
{
unsigned *full_size;
unsigned last_color;
unsigned *last_diff;
// maximum step for apply
if (rstep < 2)
{
return;
}
// step one pixel back as with check one pixel more
full_size = dst + size - rstep - 1;
last_diff = dst;
last_color = *dst;
// skip current point
dst ++;
while (dst < full_size)
{
if (last_color != *dst)
{
int step = dst - last_diff;
if (step > 1)
{
int a_beg, b_beg, c_beg, d_beg;
int a_end, b_end, c_end, d_end;
int a_step, b_step, c_step, d_step;
int k;
// minimize effect size to rstep
if (step > rstep)
{
// change place for start effect
last_diff += (step - rstep);
step = rstep;
}
// compare next pixels
for(k = 1; k <= step; k ++)
{
if (dst[k] != dst[0])
{
break;
}
}
// step back as pixel different after previous step
k --;
// mirror steps
if (k < step)
{
// R_Printf(PRINT_ALL, "%s %d -> %d\n", __func__, k, step);
// change place for start effect
last_diff += (step - k);
step = k;
}
// update step to correct value
step += k;
dst += k;
// get colors
a_beg = (last_color >> 0 ) & 0xff;
b_beg = (last_color >> 8 ) & 0xff;
c_beg = (last_color >> 16) & 0xff;
d_beg = (last_color >> 24) & 0xff;
a_end = (*dst >> 0 ) & 0xff;
b_end = (*dst >> 8 ) & 0xff;
c_end = (*dst >> 16) & 0xff;
d_end = (*dst >> 24) & 0xff;
a_step = a_end - a_beg;
b_step = b_end - b_beg;
c_step = c_end - c_beg;
d_step = d_end - d_beg;
if ((abs(a_step) <= COLOR_DISTANCE) &&
(abs(b_step) <= COLOR_DISTANCE) &&
(abs(c_step) <= COLOR_DISTANCE) &&
(abs(d_step) <= COLOR_DISTANCE) &&
step > 0)
{
// generate color change steps
a_step = (a_step << 16) / step;
b_step = (b_step << 16) / step;
c_step = (c_step << 16) / step;
d_step = (d_step << 16) / step;
// apply color changes
for (k=0; k < step; k++)
{
*last_diff = (((a_beg + ((a_step * k) >> 16)) << 0) & 0x000000ff) |
(((b_beg + ((b_step * k) >> 16)) << 8) & 0x0000ff00) |
(((c_beg + ((c_step * k) >> 16)) << 16) & 0x00ff0000) |
(((d_beg + ((d_step * k) >> 16)) << 24) & 0xff000000);
last_diff++;
}
}
}
last_color = *dst;
last_diff = dst;
}
dst ++;
}
}
/* https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms */
void
scale2x(byte *src, byte *dst, int width, int height)
{
/*
EPX/Scale2×/AdvMAME2×
x A x
C P B -> 1 2
x D x 3 4
1=P; 2=P; 3=P; 4=P;
IF C==A AND C!=D AND A!=B => 1=A
IF A==B AND A!=C AND B!=D => 2=B
IF D==C AND D!=B AND C!=A => 3=C
IF B==D AND B!=A AND D!=C => 4=D
*/
{
byte *in_buff = src;
byte *out_buff = dst;
byte *out_buff_full = dst + ((width * height) << 2);
while (out_buff < out_buff_full)
{
int x;
for (x = 0; x < width; x ++)
{
// copy one source byte to two destinatuion bytes
*out_buff = *in_buff;
out_buff ++;
*out_buff = *in_buff;
out_buff ++;
// next source pixel
in_buff ++;
}
// copy last line one more time
memcpy(out_buff, out_buff - (width << 1), width << 1);
out_buff += width << 1;
}
}
{
int y, h, w;
h = height - 1;
w = width - 1;
for (y = 0; y < height; y ++)
{
int x;
for (x = 0; x < width; x ++)
{
byte a, b, c, d, p;
p = src[(width * (y )) + (x )];
a = (y > 0) ? src[(width * (y - 1)) + (x )] : p;
b = (x < w) ? src[(width * (y )) + (x + 1)] : p;
c = (x > 0) ? src[(width * (y )) + (x - 1)] : p;
d = (y < h) ? src[(width * (y + 1)) + (x )] : p;
if ((c == a) && (c != d) && (a != b))
{
dst[(2 * width * ((y * 2) )) + ((x * 2) )] = a;
}
if ((a == b) && (a != c) && (b != d))
{
dst[(2 * width * ((y * 2) )) + ((x * 2) + 1)] = b;
}
if ((d == c) && (d != b) && (c != a))
{
dst[(2 * width * ((y * 2) + 1)) + ((x * 2) )] = c;
}
if ((b == d) && (b != a) && (d != c))
{
dst[(2 * width * ((y * 2) + 1)) + ((x * 2) + 1)] = d;
}
}
}
}
}
void
scale3x(byte *src, byte *dst, int width, int height)
{
/*
Scale3×/AdvMAME3× and ScaleFX
A B C 1 2 3
D E F -> 4 5 6
G H I 7 8 9
1=E; 2=E; 3=E; 4=E; 5=E; 6=E; 7=E; 8=E; 9=E;
IF D==B AND D!=H AND B!=F => 1=D
IF (D==B AND D!=H AND B!=F AND E!=C) OR (B==F AND B!=D AND F!=H AND E!=A) => 2=B
IF B==F AND B!=D AND F!=H => 3=F
IF (H==D AND H!=F AND D!=B AND E!=A) OR (D==B AND D!=H AND B!=F AND E!=G) => 4=D
5=E
IF (B==F AND B!=D AND F!=H AND E!=I) OR (F==H AND F!=B AND H!=D AND E!=C) => 6=F
IF H==D AND H!=F AND D!=B => 7=D
IF (F==H AND F!=B AND H!=D AND E!=G) OR (H==D AND H!=F AND D!=B AND E!=I) => 8=H
IF F==H AND F!=B AND H!=D => 9=F
*/
{
byte *in_buff = src;
byte *out_buff = dst;
byte *out_buff_full = dst + ((width * height) * 9);
while (out_buff < out_buff_full)
{
int x;
for (x = 0; x < width; x ++)
{
// copy one source byte to two destinatuion bytes
*out_buff = *in_buff;
out_buff ++;
*out_buff = *in_buff;
out_buff ++;
*out_buff = *in_buff;
out_buff ++;
// next source pixel
in_buff ++;
}
// copy last line one more time
memcpy(out_buff, out_buff - (width * 3), width * 3);
out_buff += width * 3;
// copy last line one more time
memcpy(out_buff, out_buff - (width * 3), width * 3);
out_buff += width * 3;
}
}
{
int y, z, w;
z = height - 1;
w = width - 1;
for (y = 0; y < height; y ++)
{
int x;
for (x = 0; x < width; x ++)
{
byte a, b, c, d, e, f, g, h, i;
e = src[(width * y) + x];
a = ((y > 0) && (x > 0)) ? src[(width * (y - 1)) + (x - 1)] : e;
b = ((y > 0) && (x )) ? src[(width * (y - 1)) + (x )] : e;
c = ((y > 0) && (x < w)) ? src[(width * (y - 1)) + (x + 1)] : e;
d = ( (x > 0)) ? src[(width * (y )) + (x - 1)] : e;
f = ( (x < w)) ? src[(width * (y )) + (x + 1)] : e;
g = ((y < z) && (x > 0)) ? src[(width * (y + 1)) + (x - 1)] : e;
h = ((y < z) && (x )) ? src[(width * (y + 1)) + (x )] : e;
i = ((y < z) && (x < w)) ? src[(width * (y + 1)) + (x + 1)] : e;
if ((d == b) && (d != h) && (b != f))
{
dst[(3 * width * ((y * 3) )) + ((x * 3) )] = d;
}
if (((d == b) && (d != h) && (b != f) && (e != c)) ||
((b == f) && (b != d) && (f != h) && (e != a)))
{
dst[(3 * width * ((y * 3) )) + ((x * 3) + 1)] = b;
}
if ((b == f) && (b != d) && (f != h))
{
dst[(3 * width * ((y * 3) )) + ((x * 3) + 2)] = f;
}
if (((h == d) && (h != f) && (d != b) && (e != a)) ||
((d == b) && (d != h) && (b != f) && (e != g)))
{
dst[(3 * width * ((y * 3) + 1)) + ((x * 3) )] = d;
}
if (((b == f) && (b != d) && (f != h) && (e != i)) ||
((f == h) && (f != b) && (h != d) && (e != c)))
{
dst[(3 * width * ((y * 3) + 1)) + ((x * 3) + 2)] = f;
}
if ((h == d) && (h != f) && (d != b))
{
dst[(3 * width * ((y * 3) + 2)) + ((x * 3) )] = d;
}
if (((f == h) && (f != b) && (h != d) && (e != g)) ||
((h == d) && (h != f) && (d != b) && (e != i)))
{
dst[(3 * width * ((y * 3) + 2)) + ((x * 3) + 1)] = h;
}
if ((f == h) && (f != b) && (h != d))
{
dst[(3 * width * ((y * 3) + 2)) + ((x * 3) + 2)] = f;
}
}
}
}
}

7559
src/files/stb_image.h Normal file

File diff suppressed because it is too large Load diff

2630
src/files/stb_image_resize.h Normal file

File diff suppressed because it is too large Load diff

86
src/files/wal.c Normal file
View file

@ -0,0 +1,86 @@
/*
* Copyright (C) 1997-2001 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* =======================================================================
*
* The Wal image format
*
* =======================================================================
*/
#include "../common/header/ref_shared.h"
/*
* NOTE: LoadWal() is in *_image.c because it needs the renderer-specific image_t
*/
void
GetWalInfo(char *name, int *width, int *height)
{
miptex_t *mt;
int size;
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
return;
}
if (size < sizeof(miptex_t))
{
ri.FS_FreeFile((void *)mt);
return;
}
*width = LittleLong(mt->width);
*height = LittleLong(mt->height);
ri.FS_FreeFile((void *)mt);
return;
}
void
GetM8Info(char *name, int *width, int *height)
{
m8tex_t *mt;
int size;
size = ri.FS_LoadFile(name, (void **)&mt);
if (!mt)
{
return;
}
if (size < sizeof(m8tex_t) || LittleLong (mt->version) != M8_VERSION)
{
ri.FS_FreeFile((void *)mt);
return;
}
*width = LittleLong(mt->width[0]);
*height = LittleLong(mt->height[0]);
ri.FS_FreeFile((void *)mt);
return;
}

331
src/vk/header/local.h Normal file
View file

@ -0,0 +1,331 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __VK_LOCAL_H__
#define __VK_LOCAL_H__
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>
#include "../../common/header/ref_shared.h"
#include "../volk/volk.h"
#include "qvk.h"
// verify if VkResult is VK_SUCCESS
#define VK_VERIFY(x) { \
VkResult res = (x); \
if(res != VK_SUCCESS) { \
R_Printf(PRINT_ALL, "%s:%d: VkResult verification failed: %s\n", \
__func__, __LINE__, QVk_GetError(res)); \
} \
}
// up / down
#define PITCH 0
// left / right
#define YAW 1
// fall over
#define ROLL 2
extern viddef_t vid;
typedef struct image_s
{
char name[MAX_QPATH]; // game path, including extension
imagetype_t type;
int width, height; // source image
int upload_width, upload_height; // after power of two and picmip
int registration_sequence; // 0 = free
struct msurface_s *texturechain; // for sort-by-texture world drawing
qvktexture_t vk_texture; // Vulkan texture handle
} image_t;
#define MAX_VKTEXTURES 1024
//===================================================================
typedef enum
{
rserr_ok,
rserr_invalid_fullscreen,
rserr_invalid_mode,
rserr_unknown
} rserr_t;
#include "model.h"
#define MAX_LBM_HEIGHT 480
#define BACKFACE_EPSILON 0.01
//====================================================
extern image_t vktextures[MAX_VKTEXTURES];
extern int numvktextures;
extern image_t *r_notexture;
extern image_t *r_particletexture;
extern image_t *r_squaretexture;
extern int r_visframecount;
extern int r_framecount;
extern cplane_t frustum[4];
extern int c_brush_polys, c_alias_polys;
//
// view origin
//
extern vec3_t vup;
extern vec3_t vpn;
extern vec3_t vright;
extern vec3_t r_origin;
//
// screen size info
//
extern refdef_t r_newrefdef;
extern int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
extern cvar_t *r_lefthand;
extern cvar_t *r_drawworld;
extern cvar_t *r_novis;
extern cvar_t *r_lerpmodels;
extern cvar_t *r_lockpvs;
extern cvar_t *r_modulate;
extern cvar_t *r_vsync;
extern cvar_t *r_clear;
extern cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level
extern cvar_t *r_gunfov;
extern cvar_t *r_farsee;
extern cvar_t *vk_overbrightbits;
extern cvar_t *vk_validation;
extern cvar_t *vk_picmip;
extern cvar_t *vk_skymip;
extern cvar_t *vk_flashblend;
extern cvar_t *vk_finish;
extern cvar_t *vk_shadows;
extern cvar_t *vk_dynamic;
extern cvar_t *vk_msaa;
extern cvar_t *vk_showtris;
extern cvar_t *vk_lightmap;
extern cvar_t *vk_texturemode;
extern cvar_t *vk_lmaptexturemode;
extern cvar_t *vk_aniso;
extern cvar_t *vk_sampleshading;
extern cvar_t *vk_device_idx;
extern cvar_t *vk_retexturing;
extern cvar_t *vk_nolerp_list;
extern cvar_t *vk_pixel_size;
extern cvar_t *r_fixsurfsky;
extern cvar_t *vid_fullscreen;
extern cvar_t *vid_gamma;
extern int c_visible_lightmaps;
extern int c_visible_textures;
extern float r_viewproj_matrix[16];
void R_LightPoint (vec3_t p, vec3_t color, entity_t *currententity);
void R_PushDlights (void);
//====================================================================
extern model_t *r_worldmodel;
extern unsigned d_8to24table[256];
extern int registration_sequence;
extern qvksampler_t vk_current_sampler;
extern qvksampler_t vk_current_lmap_sampler;
void RE_Shutdown( void );
void Vk_ScreenShot_f (void);
void R_DrawAliasModel (entity_t *currententity, model_t *currentmodel);
void R_DrawBrushModel (entity_t *currententity, model_t *currentmodel);
void R_DrawSpriteModel (entity_t *currententity, model_t *currentmodel);
void R_DrawBeam (entity_t *currententity);
void R_DrawWorld (void);
void R_RenderDlights (void);
void R_DrawAlphaSurfaces (void);
void RE_InitParticleTexture (void);
void Draw_InitLocal (void);
void Vk_SubdivideSurface (msurface_t *fa, model_t *loadmodel);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
void R_RotateForEntity (entity_t *e, float *mvMatrix);
void R_MarkLeaves (void);
void EmitWaterPolys (msurface_t *fa, image_t *texture,
float *modelMatrix, float *color,
qboolean solid_surface);
void R_AddSkySurface (msurface_t *fa);
void R_ClearSkyBox (void);
void R_DrawSkyBox (void);
void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
struct image_s *RE_Draw_FindPic (char *name);
void RE_Draw_GetPicSize (int *w, int *h, char *name);
void RE_Draw_PicScaled (int x, int y, char *name, float scale);
void RE_Draw_StretchPic (int x, int y, int w, int h, char *name);
void RE_Draw_CharScaled (int x, int y, int num, float scale);
void RE_Draw_TileClear (int x, int y, int w, int h, char *name);
void RE_Draw_Fill (int x, int y, int w, int h, int c);
void RE_Draw_FadeScreen (void);
void RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
qboolean RE_EndWorldRenderpass( void );
struct image_s *RE_RegisterSkin (char *name);
void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height);
image_t *Vk_LoadPic(char *name, byte *pic, int width, int realwidth,
int height, int realheight, imagetype_t type,
int bits);
image_t *Vk_FindImage (char *name, imagetype_t type);
void Vk_TextureMode( char *string );
void Vk_LmapTextureMode( char *string );
void Vk_ImageList_f (void);
void Vk_BuildPolygonFromSurface(msurface_t *fa, model_t *currentmodel);
void Vk_CreateSurfaceLightmap (msurface_t *surf);
void Vk_EndBuildingLightmaps (void);
void Vk_BeginBuildingLightmaps (model_t *m);
void Vk_InitImages (void);
void Vk_ShutdownImages (void);
void Vk_FreeUnusedImages (void);
qboolean Vk_ImageHasFreeSpace(void);
void RE_BeginRegistration (char *model);
struct model_s *RE_RegisterModel (char *name);
struct image_s *RE_RegisterSkin (char *name);
void RE_SetSky (char *name, float rotate, vec3_t axis);
void RE_EndRegistration (void);
void Mat_Identity(float *matrix);
void Mat_Mul(float *m1, float *m2, float *res);
void Mat_Translate(float *matrix, float x, float y, float z);
void Mat_Rotate(float *matrix, float deg, float x, float y, float z);
void Mat_Scale(float *matrix, float x, float y, float z);
void Mat_Perspective(float *matrix, float *correction_matrix, float fovy, float aspect, float zNear, float zFar);
void Mat_Ortho(float *matrix, float left, float right, float bottom, float top, float zNear, float zFar);
typedef struct
{
uint32_t vk_version;
const char *vendor_name;
const char *device_type;
const char *present_mode;
const char *supported_present_modes[256];
const char *extensions[256];
const char *layers[256];
uint32_t vertex_buffer_usage;
uint32_t vertex_buffer_max_usage;
uint32_t vertex_buffer_size;
uint32_t index_buffer_usage;
uint32_t index_buffer_max_usage;
uint32_t index_buffer_size;
uint32_t uniform_buffer_usage;
uint32_t uniform_buffer_max_usage;
uint32_t uniform_buffer_size;
uint32_t triangle_index_usage;
uint32_t triangle_index_max_usage;
uint32_t triangle_index_count;
} vkconfig_t;
#define MAX_LIGHTMAPS 128
#define DYNLIGHTMAP_OFFSET MAX_LIGHTMAPS
typedef struct
{
float inverse_intensity;
qboolean fullscreen;
int prev_mode;
unsigned char *d_16to8table;
qvktexture_t lightmap_textures[MAX_LIGHTMAPS*2];
int currenttextures[2];
int currenttmu;
float camera_separation;
qboolean stereo_enabled;
VkPipeline current_pipeline;
qvkrenderpasstype_t current_renderpass;
} vkstate_t;
extern vkconfig_t vk_config;
extern vkstate_t vk_state;
/*
====================================================================
IMPORTED FUNCTIONS
====================================================================
*/
extern refimport_t ri;
/*
====================================================================
IMPLEMENTATION SPECIFIC FUNCTIONS
====================================================================
*/
qboolean Vkimp_CreateSurface(SDL_Window *window);
// buffers reallocate
typedef struct {
float vertex[3];
float texCoord[2];
} polyvert_t;
typedef struct {
float vertex[3];
float texCoord[2];
float texCoordLmap[2];
} lmappolyvert_t;
extern polyvert_t *verts_buffer;
extern lmappolyvert_t *lmappolyverts_buffer;
void Mesh_Init (void);
void Mesh_Free (void);
int Mesh_VertsRealloc(int count);
#endif

254
src/vk/header/model.h Normal file
View file

@ -0,0 +1,254 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __VK_MODEL_H__
#define __VK_MODEL_H__
/*
d*_t structures are on-disk representations
m*_t structures are in-memory
*/
/*
==============================================================================
BRUSH MODELS
==============================================================================
*/
//
// in memory representation
//
typedef struct
{
vec3_t position;
} mvertex_t;
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SIDE_ON 2
#define SURF_PLANEBACK 2
#define SURF_DRAWSKY 4
#define SURF_DRAWTURB 0x10
#define SURF_DRAWBACKGROUND 0x40
#define SURF_UNDERWATER 0x80
typedef struct
{
unsigned short v[2];
unsigned int cachededgeoffset;
} medge_t;
typedef struct mtexinfo_s
{
float vecs[2][4];
int flags;
int numframes;
struct mtexinfo_s *next; // animation chain
image_t *image;
} mtexinfo_t;
#define VERTEXSIZE 7
typedef struct vkpoly_s
{
struct vkpoly_s *next;
struct vkpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER (not needed anymore?)
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} vkpoly_t;
typedef struct msurface_s
{
int visframe; // should be drawn when node is crossed
cplane_t *plane;
int flags;
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
short texturemins[2];
short extents[2];
int light_s, light_t; // gl lightmap coordinates
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
vkpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
struct msurface_s *lightmapchain;
mtexinfo_t *texinfo;
// lighting info
int dlightframe;
int dlightbits;
int lightmaptexturenum;
byte styles[MAXLIGHTMAPS];
float cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
byte *samples; // [numstyles*surfsize]
} msurface_t;
typedef struct mnode_s
{
// common with leaf
int contents; // -1, to differentiate from leafs
int visframe; // node needs to be traversed if current
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// node specific
cplane_t *plane;
struct mnode_s *children[2];
unsigned short firstsurface;
unsigned short numsurfaces;
} mnode_t;
typedef struct mleaf_s
{
// common with node
int contents; // wil be a negative contents number
int visframe; // node needs to be traversed if current
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// leaf specific
int cluster;
int area;
msurface_t **firstmarksurface;
int nummarksurfaces;
} mleaf_t;
//===================================================================
//
// Whole model
//
typedef struct model_s
{
char name[MAX_QPATH];
int registration_sequence;
modtype_t type;
int numframes;
int flags;
//
// volume occupied by the model graphics
//
vec3_t mins, maxs;
float radius;
//
// solid volume for clipping
//
qboolean clipbox;
vec3_t clipmins, clipmaxs;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
int lightmap; // only for submodels
int numsubmodels;
struct model_s *submodels;
int numplanes;
cplane_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;
int firstnode;
mnode_t *nodes;
int numtexinfo;
mtexinfo_t *texinfo;
int numsurfaces;
msurface_t *surfaces;
int numsurfedges;
int *surfedges;
int nummarksurfaces;
msurface_t **marksurfaces;
dvis_t *vis;
byte *lightdata;
// for alias models and skins
image_t *skins[MAX_MD2SKINS];
int extradatasize;
void *extradata;
// submodules
vec3_t origin; // for sounds or lights
} model_t;
//============================================================================
void Mod_Init (void);
mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
byte *Mod_ClusterPVS (int cluster, model_t *model);
void Mod_Modellist_f (void);
void *Hunk_Begin (int maxsize);
void *Hunk_Alloc (int size);
int Hunk_End (void);
void Hunk_Free (void *base);
void Mod_FreeAll (void);
void Mod_FreeModelsKnown (void);
#endif

326
src/vk/header/qvk.h Normal file
View file

@ -0,0 +1,326 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
** QVK.H
*/
#ifndef __QVK_H__
#define __QVK_H__
#ifdef _WIN32
# include <windows.h>
#endif
#include "local.h"
#include "util.h"
#include "shaders.h"
// Vulkan device
typedef struct
{
VkPhysicalDevice physical;
VkDevice logical;
VkPhysicalDeviceMemoryProperties mem_properties;
VkPhysicalDeviceProperties properties;
VkPhysicalDeviceFeatures features;
VkQueue gfxQueue;
VkQueue presentQueue;
VkQueue transferQueue;
int gfxFamilyIndex;
int presentFamilyIndex;
int transferFamilyIndex;
qboolean screenshotSupported;
} qvkdevice_t;
// Vulkan swapchain
typedef struct
{
VkSwapchainKHR sc;
VkFormat format;
VkPresentModeKHR presentMode;
VkExtent2D extent;
VkImage *images;
int imageCount;
} qvkswapchain_t;
// available sampler types
typedef enum
{
S_NEAREST = 0,
S_LINEAR = 1,
S_MIPMAP_NEAREST = 2,
S_MIPMAP_LINEAR = 3,
S_NEAREST_UNNORMALIZED = 4,
S_SAMPLER_CNT = 5
} qvksampler_t;
#define NUM_SAMPLERS (S_SAMPLER_CNT * 2)
// texture object
typedef struct
{
ImageResource_t resource;
VkImageView imageView;
VkSharingMode sharingMode;
VkSampleCountFlagBits sampleCount;
VkFormat format;
VkDescriptorSet descriptorSet;
uint32_t mipLevels;
qboolean clampToEdge;
} qvktexture_t;
#define QVVKTEXTURE_INIT { \
.resource = { \
.image = VK_NULL_HANDLE, \
.memory = VK_NULL_HANDLE, \
.size = 0, \
}, \
.imageView = VK_NULL_HANDLE, \
.sharingMode = VK_SHARING_MODE_MAX_ENUM, \
.sampleCount = VK_SAMPLE_COUNT_1_BIT, \
.format = VK_FORMAT_R8G8B8A8_UNORM, \
.descriptorSet = VK_NULL_HANDLE, \
.mipLevels = 1, \
}
#define QVVKTEXTURE_CLEAR(i) { \
(i).resource.image = VK_NULL_HANDLE; \
(i).resource.memory = VK_NULL_HANDLE; \
(i).resource.size = 0; \
(i).imageView = VK_NULL_HANDLE; \
(i).sharingMode = VK_SHARING_MODE_MAX_ENUM; \
(i).sampleCount = VK_SAMPLE_COUNT_1_BIT; \
(i).format = VK_FORMAT_R8G8B8A8_UNORM; \
(i).mipLevels = 1; \
}
// Vulkan renderpass
typedef struct
{
VkRenderPass rp;
VkAttachmentLoadOp colorLoadOp;
VkSampleCountFlagBits sampleCount;
} qvkrenderpass_t;
// Vulkan buffer
typedef struct
{
VkDeviceSize currentOffset;
BufferResource_t resource;
void *pMappedData;
} qvkbuffer_t;
// Vulkan staging buffer
typedef struct
{
VkDeviceSize currentOffset;
VkCommandBuffer cmdBuffer;
VkFence fence;
qboolean submitted;
BufferResource_t resource;
void *pMappedData;
} qvkstagingbuffer_t;
// Vulkan buffer options
typedef struct
{
VkBufferUsageFlags usage;
VkMemoryPropertyFlags reqMemFlags;
VkMemoryPropertyFlags prefMemFlags;
} qvkbufferopts_t;
// Vulkan pipeline
typedef struct
{
VkPipelineLayout layout;
VkPipeline pl;
VkPipelineCreateFlags flags;
VkCullModeFlags cullMode;
VkPrimitiveTopology topology;
VkPipelineColorBlendAttachmentState blendOpts;
VkBool32 depthTestEnable;
VkBool32 depthWriteEnable;
} qvkpipeline_t;
// Vulkan shader
typedef struct
{
VkPipelineShaderStageCreateInfo createInfo;
VkShaderModule module;
} qvkshader_t;
#define QVKPIPELINE_INIT { \
.layout = VK_NULL_HANDLE, \
.pl = VK_NULL_HANDLE, \
.flags = 0, \
.cullMode = VK_CULL_MODE_BACK_BIT, \
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, \
.blendOpts = { \
.blendEnable = VK_FALSE, \
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA, \
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, \
.colorBlendOp = VK_BLEND_OP_ADD, \
.srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA, \
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, \
.alphaBlendOp = VK_BLEND_OP_ADD, \
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT \
}, \
.depthTestEnable = VK_TRUE, \
.depthWriteEnable = VK_TRUE \
}
// renderpass type
typedef enum
{
RP_WORLD = 0, // renders game world to offscreen buffer
RP_UI = 1, // render UI elements and game console
RP_WORLD_WARP = 2, // perform postprocessing on RP_WORLD (underwater screen warp)
RP_COUNT = 3
} qvkrenderpasstype_t;
// Vulkan constants: command and dynamic buffer count
#define NUM_CMDBUFFERS 2
#define NUM_DYNBUFFERS 2
// Vulkan instance
extern VkInstance vk_instance;
// Vulkan surface
extern VkSurfaceKHR vk_surface;
// Vulkan device
extern qvkdevice_t vk_device;
// Vulkan swapchain
extern qvkswapchain_t vk_swapchain;
// Vulkan command buffer currently in use
extern VkCommandBuffer vk_activeCmdbuffer;
// Vulkan command pools
extern VkCommandPool vk_commandPool[NUM_CMDBUFFERS];
extern VkCommandPool vk_transferCommandPool;
// Vulkan descriptor pool
extern VkDescriptorPool vk_descriptorPool;
// viewport/scissor
extern VkViewport vk_viewport;
extern VkRect2D vk_scissor;
// Vulkan descriptor sets
extern VkDescriptorSetLayout vk_samplerDescSetLayout;
// *** pipelines ***
extern qvkpipeline_t vk_drawTexQuadPipeline[RP_COUNT];
extern qvkpipeline_t vk_drawColorQuadPipeline[RP_COUNT];
extern qvkpipeline_t vk_drawModelPipelineFan[RP_COUNT];
extern qvkpipeline_t vk_drawNoDepthModelPipelineFan;
extern qvkpipeline_t vk_drawLefthandModelPipelineFan;
extern qvkpipeline_t vk_drawNullModelPipeline;
extern qvkpipeline_t vk_drawParticlesPipeline;
extern qvkpipeline_t vk_drawPointParticlesPipeline;
extern qvkpipeline_t vk_drawSpritePipeline;
extern qvkpipeline_t vk_drawPolyPipeline;
extern qvkpipeline_t vk_drawPolyLmapPipeline;
extern qvkpipeline_t vk_drawPolyWarpPipeline;
extern qvkpipeline_t vk_drawPolySolidWarpPipeline;
extern qvkpipeline_t vk_drawBeamPipeline;
extern qvkpipeline_t vk_drawSkyboxPipeline;
extern qvkpipeline_t vk_drawDLightPipeline;
extern qvkpipeline_t vk_showTrisPipeline;
extern qvkpipeline_t vk_shadowsPipelineFan;
extern qvkpipeline_t vk_worldWarpPipeline;
extern qvkpipeline_t vk_postprocessPipeline;
// color buffer containing main game/world view
extern qvktexture_t vk_colorbuffer;
// color buffer with postprocessed game view
extern qvktexture_t vk_colorbufferWarp;
// indicator if the frame is currently being rendered
extern qboolean vk_frameStarted;
// Indicates if the renderer needs to be restarted.
extern qboolean vk_restartNeeded;
// is QVk initialized?
extern qboolean vk_initialized;
// function pointers
extern PFN_vkCreateDebugUtilsMessengerEXT qvkCreateDebugUtilsMessengerEXT;
extern PFN_vkDestroyDebugUtilsMessengerEXT qvkDestroyDebugUtilsMessengerEXT;
extern PFN_vkSetDebugUtilsObjectNameEXT qvkSetDebugUtilsObjectNameEXT;
extern PFN_vkSetDebugUtilsObjectTagEXT qvkSetDebugUtilsObjectTagEXT;
extern PFN_vkCmdBeginDebugUtilsLabelEXT qvkCmdBeginDebugUtilsLabelEXT;
extern PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT;
extern PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT;
// The Interface Functions (tm)
void QVk_SetWindow(SDL_Window*);
qboolean QVk_Init(void);
void QVk_PostInit(void);
void QVk_WaitAndShutdownAll(void);
void QVk_Shutdown(void);
void QVk_Restart(void);
void QVk_CreateValidationLayers(void);
void QVk_DestroyValidationLayers(void);
qboolean QVk_CreateDevice(int preferredDeviceIdx);
VkResult QVk_CreateSwapchain(void);
VkFormat QVk_FindDepthFormat(void);
VkResult QVk_CreateCommandPool(VkCommandPool *commandPool, uint32_t queueFamilyIndex);
VkResult QVk_CreateImageView(const VkImage *image, VkImageAspectFlags aspectFlags, VkImageView *imageView, VkFormat format, uint32_t mipLevels);
VkResult QVk_CreateImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, qvktexture_t *texture);
void QVk_CreateDepthBuffer(VkSampleCountFlagBits sampleCount, qvktexture_t *depthBuffer);
void QVk_CreateColorBuffer(VkSampleCountFlagBits sampleCount, qvktexture_t *colorBuffer, int extraFlags);
void QVk_CreateTexture(qvktexture_t *texture, const unsigned char *data, uint32_t width, uint32_t height, qvksampler_t samplerType, qboolean clampToEdge);
void QVk_UpdateTextureData(qvktexture_t *texture, const unsigned char *data, uint32_t offset_x, uint32_t offset_y, uint32_t width, uint32_t height);
VkSampler QVk_UpdateTextureSampler(qvktexture_t *texture, qvksampler_t samplerType, qboolean clampToEdge);
void QVk_ReadPixels(uint8_t *dstBuffer, const VkOffset2D *offset, const VkExtent2D *extent);
VkResult QVk_BeginCommand(const VkCommandBuffer *commandBuffer);
void QVk_SubmitCommand(const VkCommandBuffer *commandBuffer, const VkQueue *queue);
VkCommandBuffer QVk_CreateCommandBuffer(const VkCommandPool *commandPool, VkCommandBufferLevel level);
const char* QVk_GetError(VkResult errorCode);
VkResult QVk_BeginFrame(const VkViewport* viewport, const VkRect2D* scissor);
VkResult QVk_EndFrame(qboolean force);
void QVk_BeginRenderpass(qvkrenderpasstype_t rpType);
void QVk_FreeStagingBuffer(qvkstagingbuffer_t *buffer);
VkResult QVk_CreateBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, const qvkbufferopts_t options);
void QVk_FreeBuffer(qvkbuffer_t *buffer);
VkResult QVk_CreateStagingBuffer(VkDeviceSize size, qvkstagingbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
VkResult QVk_CreateUniformBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
void QVk_CreateVertexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
void QVk_CreateIndexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
qvkshader_t QVk_CreateShader(const uint32_t *shaderSrc, size_t shaderCodeSize, VkShaderStageFlagBits shaderStage);
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount);
void QVk_DestroyPipeline(qvkpipeline_t *pipeline);
uint8_t* QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset);
uint8_t* QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet);
uint8_t* QVk_GetStagingBuffer(VkDeviceSize size, int alignment, VkCommandBuffer *cmdBuffer, VkBuffer *buffer, uint32_t *dstOffset);
VkBuffer QVk_GetTriangleFanIbo(VkDeviceSize indexCount);
VkBuffer QVk_GetTriangleStripIbo(VkDeviceSize indexCount);
void QVk_DrawColorRect(float *ubo, VkDeviceSize uboSize, qvkrenderpasstype_t rpType);
void QVk_DrawTexRect(const float *ubo, VkDeviceSize uboSize, qvktexture_t *texture);
void QVk_BindPipeline(qvkpipeline_t *pipeline);
void QVk_SubmitStagingBuffers(void);
void Qvk_MemoryBarrier(VkCommandBuffer cmdBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask);
qboolean QVk_CheckExtent(void);
// debug label related functions
void QVk_DebugSetObjectName(uint64_t obj, VkObjectType objType, const char *objName);
void QVk_DebugSetObjectTag(uint64_t obj, VkObjectType objType, uint64_t tagName, size_t tagSize, const void *tagData);
void QVk_DebugLabelBegin(const VkCommandBuffer *cmdBuffer, const char *labelName, const float r, const float g, const float b);
void QVk_DebugLabelEnd(const VkCommandBuffer *cmdBuffer);
void QVk_DebugLabelInsert(const VkCommandBuffer *cmdBuffer, const char *labelName, const float r, const float g, const float b);
#endif

115
src/vk/header/shaders.h Normal file
View file

@ -0,0 +1,115 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//
// game shaders, compiled offline
//
#ifndef __VK_SHADERS_H__
#define __VK_SHADERS_H__
#include <stdint.h>
#include <stddef.h>
// textured quad (alpha)
extern const uint32_t basic_vert_spv[];
extern const size_t basic_vert_size;
extern const uint32_t basic_frag_spv[];
extern const size_t basic_frag_size;
// colored quad (alpha)
extern const uint32_t basic_color_quad_vert_spv[];
extern const size_t basic_color_quad_vert_size;
extern const uint32_t basic_color_quad_frag_spv[];
extern const size_t basic_color_quad_frag_size;
// textured model
extern const uint32_t model_vert_spv[];
extern const size_t model_vert_size;
extern const uint32_t model_frag_spv[];
extern const size_t model_frag_size;
// null model
extern const uint32_t nullmodel_vert_spv[];
extern const size_t nullmodel_vert_size;
// particle (texture)
extern const uint32_t particle_vert_spv[];
extern const size_t particle_vert_size;
// particle (point)
extern const uint32_t point_particle_vert_spv[];
extern const size_t point_particle_vert_size;
extern const uint32_t point_particle_frag_spv[];
extern const size_t point_particle_frag_size;
// sprite model
extern const uint32_t sprite_vert_spv[];
extern const size_t sprite_vert_size;
// beam
extern const uint32_t beam_vert_spv[];
extern const size_t beam_vert_size;
// skybox
extern const uint32_t skybox_vert_spv[];
extern const size_t skybox_vert_size;
// dynamic lights
extern const uint32_t d_light_vert_spv[];
extern const size_t d_light_vert_size;
// textured, alpha blended polygon
extern const uint32_t polygon_vert_spv[];
extern const size_t polygon_vert_size;
// textured, lightmapped polygon
extern const uint32_t polygon_lmap_vert_spv[];
extern const size_t polygon_lmap_vert_size;
extern const uint32_t polygon_lmap_frag_spv[];
extern const size_t polygon_lmap_frag_size;
// warped polygon (liquids)
extern const uint32_t polygon_warp_vert_spv[];
extern const size_t polygon_warp_vert_size;
// entity shadows
extern const uint32_t shadows_vert_spv[];
extern const size_t shadows_vert_size;
// postprocess
extern const uint32_t postprocess_vert_spv[];
extern const size_t postprocess_vert_size;
extern const uint32_t postprocess_frag_spv[];
extern const size_t postprocess_frag_size;
// underwater vision warp
extern const uint32_t world_warp_vert_spv[];
extern const size_t world_warp_vert_size;
extern const uint32_t world_warp_frag_spv[];
extern const size_t world_warp_frag_size;
#endif

71
src/vk/header/util.h Normal file
View file

@ -0,0 +1,71 @@
/*
Copyright (C) 2018 Christoph Schied
Copyright (C) 2020 Denis Pauk
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 the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __VK_UTIL_H__
#define __VK_UTIL_H__
#include "../volk/volk.h"
#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
typedef struct BufferResource_s {
VkBuffer buffer;
// shared memory used for buffer
VkDeviceMemory memory;
// image size
VkDeviceSize size;
// posision in shared memory
VkDeviceSize offset;
// is mapped?
VkBool32 is_mapped;
} BufferResource_t;
typedef struct ImageResource_s {
VkImage image;
// shared memory used for image
VkDeviceMemory memory;
// image size
VkDeviceSize size;
// posision in shared memory
VkDeviceSize offset;
} ImageResource_t;
VkResult buffer_create(BufferResource_t *buf,
VkBufferCreateInfo buf_create_info,
VkMemoryPropertyFlags mem_properties,
VkMemoryPropertyFlags mem_preferences);
VkResult buffer_destroy(BufferResource_t *buf);
void buffer_unmap(BufferResource_t *buf);
void *buffer_map(BufferResource_t *buf);
VkResult buffer_flush(BufferResource_t *buf);
VkResult buffer_invalidate(BufferResource_t *buf);
VkResult image_create(ImageResource_t *img,
VkImageCreateInfo img_create_info,
VkMemoryPropertyFlags mem_properties,
VkMemoryPropertyFlags mem_preferences);
VkResult image_destroy(ImageResource_t *img);
void vulkan_memory_init(void);
void vulkan_memory_types_show(void);
void vulkan_memory_free_unused(void);
void vulkan_memory_delete(void);
#endif /*__VK_UTIL_H__*/

View file

@ -0,0 +1,16 @@
// 8.13.3559
#pragma once
const uint32_t basic_color_quad_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000000d,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00030010,
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00060005,0x00000009,0x67617266,0x746e656d,0x6f6c6f43,0x00000072,0x00040005,
0x0000000b,0x6f6c6f63,0x00000072,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,
0x0000000b,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,
0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040020,
0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x00000007,
0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x000100fd,0x00010038
};

View file

@ -0,0 +1,48 @@
// 8.13.3559
#pragma once
const uint32_t basic_color_quad_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000032,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000001f,0x0000002d,
0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,
0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00040005,0x00000009,0x736f5076,0x00000000,0x00050005,0x0000000b,0x65566e69,0x78657472,
0x00000000,0x00060005,0x0000000e,0x67616d69,0x61725465,0x6f66736e,0x00006d72,0x00050006,
0x0000000e,0x00000000,0x7366666f,0x00007465,0x00050006,0x0000000e,0x00000001,0x6c616373,
0x00000065,0x00050006,0x0000000e,0x00000002,0x6f6c6f63,0x00000072,0x00030005,0x00000010,
0x00007469,0x00060005,0x0000001d,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,
0x0000001d,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001f,0x00000000,
0x00040005,0x0000002d,0x6f6c6f63,0x00000072,0x00040047,0x0000000b,0x0000001e,0x00000000,
0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000e,0x00000001,
0x00000023,0x00000008,0x00050048,0x0000000e,0x00000002,0x00000023,0x00000010,0x00030047,
0x0000000e,0x00000002,0x00040047,0x00000010,0x00000022,0x00000000,0x00040047,0x00000010,
0x00000021,0x00000000,0x00050048,0x0000001d,0x00000000,0x0000000b,0x00000000,0x00030047,
0x0000001d,0x00000002,0x00040047,0x0000002d,0x0000001e,0x00000000,0x00020013,0x00000002,
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040020,0x0000000a,
0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00040017,0x0000000d,
0x00000006,0x00000004,0x0005001e,0x0000000e,0x00000007,0x00000007,0x0000000d,0x00040020,
0x0000000f,0x00000002,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000002,0x00040015,
0x00000011,0x00000020,0x00000001,0x0004002b,0x00000011,0x00000012,0x00000001,0x00040020,
0x00000013,0x00000002,0x00000007,0x0004002b,0x00000006,0x00000017,0x3f800000,0x0005002c,
0x00000007,0x00000018,0x00000017,0x00000017,0x0003001e,0x0000001d,0x0000000d,0x00040020,
0x0000001e,0x00000003,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000003,0x0004002b,
0x00000011,0x00000020,0x00000000,0x0004002b,0x00000006,0x00000024,0x40000000,0x0004002b,
0x00000006,0x00000027,0x00000000,0x00040020,0x0000002b,0x00000003,0x0000000d,0x0004003b,
0x0000002b,0x0000002d,0x00000003,0x0004002b,0x00000011,0x0000002e,0x00000002,0x00040020,
0x0000002f,0x00000002,0x0000000d,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003d,0x00000007,
0x0000000c,0x0000000b,0x00050041,0x00000013,0x00000014,0x00000010,0x00000012,0x0004003d,
0x00000007,0x00000015,0x00000014,0x00050085,0x00000007,0x00000016,0x0000000c,0x00000015,
0x00050041,0x00000013,0x00000019,0x00000010,0x00000012,0x0004003d,0x00000007,0x0000001a,
0x00000019,0x00050083,0x00000007,0x0000001b,0x00000018,0x0000001a,0x00050083,0x00000007,
0x0000001c,0x00000016,0x0000001b,0x0003003e,0x00000009,0x0000001c,0x0004003d,0x00000007,
0x00000021,0x00000009,0x00050041,0x00000013,0x00000022,0x00000010,0x00000020,0x0004003d,
0x00000007,0x00000023,0x00000022,0x0005008e,0x00000007,0x00000025,0x00000023,0x00000024,
0x00050081,0x00000007,0x00000026,0x00000021,0x00000025,0x00050051,0x00000006,0x00000028,
0x00000026,0x00000000,0x00050051,0x00000006,0x00000029,0x00000026,0x00000001,0x00070050,
0x0000000d,0x0000002a,0x00000028,0x00000029,0x00000027,0x00000017,0x00050041,0x0000002b,
0x0000002c,0x0000001f,0x00000020,0x0003003e,0x0000002c,0x0000002a,0x00050041,0x0000002f,
0x00000030,0x00000010,0x0000002e,0x0004003d,0x0000000d,0x00000031,0x00000030,0x0003003e,
0x0000002d,0x00000031,0x000100fd,0x00010038
};

48
src/vk/spirv/basic_frag.c Normal file
View file

@ -0,0 +1,48 @@
// 8.13.3559
#pragma once
const uint32_t basic_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000038,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000011,0x00000015,
0x0000001e,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000009,0x67617266,0x746e656d,0x6f6c6f43,
0x00000072,0x00050005,0x0000000d,0x78655473,0x65727574,0x00000000,0x00050005,0x00000011,
0x43786574,0x64726f6f,0x00000000,0x00040005,0x00000015,0x6f6c6f63,0x00000072,0x00050005,
0x0000001e,0x65725461,0x6c6f6873,0x00000064,0x00060005,0x00000028,0x68737550,0x736e6f43,
0x746e6174,0x00000000,0x00050006,0x00000028,0x00000000,0x6d6d6167,0x00000061,0x00030005,
0x0000002a,0x00006370,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,
0x00000022,0x00000000,0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,
0x0000001e,0x00000000,0x00040047,0x00000015,0x0000001e,0x00000001,0x00040047,0x0000001e,
0x0000001e,0x00000002,0x00050048,0x00000028,0x00000000,0x00000023,0x00000044,0x00030047,
0x00000028,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,
0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00090019,0x0000000a,
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,
0x0000000b,0x0000000a,0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,
0x0000000d,0x00000000,0x00040017,0x0000000f,0x00000006,0x00000002,0x00040020,0x00000010,
0x00000001,0x0000000f,0x0004003b,0x00000010,0x00000011,0x00000001,0x00040020,0x00000014,
0x00000001,0x00000007,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040015,0x00000018,
0x00000020,0x00000000,0x0004002b,0x00000018,0x00000019,0x00000003,0x00040020,0x0000001a,
0x00000003,0x00000006,0x00040020,0x0000001d,0x00000001,0x00000006,0x0004003b,0x0000001d,
0x0000001e,0x00000001,0x00020014,0x00000020,0x00040017,0x00000025,0x00000006,0x00000003,
0x0003001e,0x00000028,0x00000006,0x00040020,0x00000029,0x00000009,0x00000028,0x0004003b,
0x00000029,0x0000002a,0x00000009,0x00040015,0x0000002b,0x00000020,0x00000001,0x0004002b,
0x0000002b,0x0000002c,0x00000000,0x00040020,0x0000002d,0x00000009,0x00000006,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x0000000b,
0x0000000e,0x0000000d,0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,
0x00000013,0x0000000e,0x00000012,0x0004003d,0x00000007,0x00000016,0x00000015,0x00050085,
0x00000007,0x00000017,0x00000013,0x00000016,0x0003003e,0x00000009,0x00000017,0x00050041,
0x0000001a,0x0000001b,0x00000009,0x00000019,0x0004003d,0x00000006,0x0000001c,0x0000001b,
0x0004003d,0x00000006,0x0000001f,0x0000001e,0x000500b8,0x00000020,0x00000021,0x0000001c,
0x0000001f,0x000300f7,0x00000023,0x00000000,0x000400fa,0x00000021,0x00000022,0x00000023,
0x000200f8,0x00000022,0x000100fc,0x000200f8,0x00000023,0x0004003d,0x00000007,0x00000026,
0x00000009,0x0008004f,0x00000025,0x00000027,0x00000026,0x00000026,0x00000000,0x00000001,
0x00000002,0x00050041,0x0000002d,0x0000002e,0x0000002a,0x0000002c,0x0004003d,0x00000006,
0x0000002f,0x0000002e,0x00060050,0x00000025,0x00000030,0x0000002f,0x0000002f,0x0000002f,
0x0007000c,0x00000025,0x00000031,0x00000001,0x0000001a,0x00000027,0x00000030,0x00050041,
0x0000001a,0x00000032,0x00000009,0x00000019,0x0004003d,0x00000006,0x00000033,0x00000032,
0x00050051,0x00000006,0x00000034,0x00000031,0x00000000,0x00050051,0x00000006,0x00000035,
0x00000031,0x00000001,0x00050051,0x00000006,0x00000036,0x00000031,0x00000002,0x00070050,
0x00000007,0x00000037,0x00000034,0x00000035,0x00000036,0x00000033,0x0003003e,0x00000009,
0x00000037,0x000100fd,0x00010038
};

61
src/vk/spirv/basic_vert.c Normal file
View file

@ -0,0 +1,61 @@
// 8.13.3559
#pragma once
const uint32_t basic_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000003e,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000001f,0x0000002e,
0x0000002f,0x00000039,0x0000003c,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00040005,0x00000009,0x736f5076,0x00000000,0x00050005,
0x0000000b,0x65566e69,0x78657472,0x00000000,0x00060005,0x0000000d,0x67616d69,0x61725465,
0x6f66736e,0x00006d72,0x00050006,0x0000000d,0x00000000,0x7366666f,0x00007465,0x00050006,
0x0000000d,0x00000001,0x6c616373,0x00000065,0x00060006,0x0000000d,0x00000002,0x664f7675,
0x74657366,0x00000000,0x00050006,0x0000000d,0x00000003,0x63537675,0x00656c61,0x00030005,
0x0000000f,0x00007469,0x00060005,0x0000001d,0x505f6c67,0x65567265,0x78657472,0x00000000,
0x00060006,0x0000001d,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001f,
0x00000000,0x00050005,0x0000002e,0x43786574,0x64726f6f,0x00000000,0x00050005,0x0000002f,
0x65546e69,0x6f6f4378,0x00006472,0x00040005,0x00000039,0x6f6c6f63,0x00000072,0x00050005,
0x0000003c,0x65725461,0x6c6f6873,0x00000064,0x00040047,0x0000000b,0x0000001e,0x00000000,
0x00050048,0x0000000d,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000d,0x00000001,
0x00000023,0x00000008,0x00050048,0x0000000d,0x00000002,0x00000023,0x00000010,0x00050048,
0x0000000d,0x00000003,0x00000023,0x00000018,0x00030047,0x0000000d,0x00000002,0x00040047,
0x0000000f,0x00000022,0x00000001,0x00040047,0x0000000f,0x00000021,0x00000000,0x00050048,
0x0000001d,0x00000000,0x0000000b,0x00000000,0x00030047,0x0000001d,0x00000002,0x00040047,
0x0000002e,0x0000001e,0x00000000,0x00040047,0x0000002f,0x0000001e,0x00000001,0x00040047,
0x00000039,0x0000001e,0x00000001,0x00040047,0x0000003c,0x0000001e,0x00000002,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,
0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040020,
0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x0006001e,
0x0000000d,0x00000007,0x00000007,0x00000007,0x00000007,0x00040020,0x0000000e,0x00000002,
0x0000000d,0x0004003b,0x0000000e,0x0000000f,0x00000002,0x00040015,0x00000010,0x00000020,
0x00000001,0x0004002b,0x00000010,0x00000011,0x00000001,0x00040020,0x00000012,0x00000002,
0x00000007,0x0004002b,0x00000006,0x00000016,0x3f800000,0x0005002c,0x00000007,0x00000017,
0x00000016,0x00000016,0x00040017,0x0000001c,0x00000006,0x00000004,0x0003001e,0x0000001d,
0x0000001c,0x00040020,0x0000001e,0x00000003,0x0000001d,0x0004003b,0x0000001e,0x0000001f,
0x00000003,0x0004002b,0x00000010,0x00000020,0x00000000,0x0004002b,0x00000006,0x00000024,
0x40000000,0x0004002b,0x00000006,0x00000027,0x00000000,0x00040020,0x0000002b,0x00000003,
0x0000001c,0x00040020,0x0000002d,0x00000003,0x00000007,0x0004003b,0x0000002d,0x0000002e,
0x00000003,0x0004003b,0x0000000a,0x0000002f,0x00000001,0x0004002b,0x00000010,0x00000031,
0x00000003,0x0004002b,0x00000010,0x00000035,0x00000002,0x0004003b,0x0000002b,0x00000039,
0x00000003,0x0007002c,0x0000001c,0x0000003a,0x00000016,0x00000016,0x00000016,0x00000016,
0x00040020,0x0000003b,0x00000003,0x00000006,0x0004003b,0x0000003b,0x0000003c,0x00000003,
0x0004002b,0x00000006,0x0000003d,0x3f2a7efa,0x00050036,0x00000002,0x00000004,0x00000000,
0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003d,
0x00000007,0x0000000c,0x0000000b,0x00050041,0x00000012,0x00000013,0x0000000f,0x00000011,
0x0004003d,0x00000007,0x00000014,0x00000013,0x00050085,0x00000007,0x00000015,0x0000000c,
0x00000014,0x00050041,0x00000012,0x00000018,0x0000000f,0x00000011,0x0004003d,0x00000007,
0x00000019,0x00000018,0x00050083,0x00000007,0x0000001a,0x00000017,0x00000019,0x00050083,
0x00000007,0x0000001b,0x00000015,0x0000001a,0x0003003e,0x00000009,0x0000001b,0x0004003d,
0x00000007,0x00000021,0x00000009,0x00050041,0x00000012,0x00000022,0x0000000f,0x00000020,
0x0004003d,0x00000007,0x00000023,0x00000022,0x0005008e,0x00000007,0x00000025,0x00000023,
0x00000024,0x00050081,0x00000007,0x00000026,0x00000021,0x00000025,0x00050051,0x00000006,
0x00000028,0x00000026,0x00000000,0x00050051,0x00000006,0x00000029,0x00000026,0x00000001,
0x00070050,0x0000001c,0x0000002a,0x00000028,0x00000029,0x00000027,0x00000016,0x00050041,
0x0000002b,0x0000002c,0x0000001f,0x00000020,0x0003003e,0x0000002c,0x0000002a,0x0004003d,
0x00000007,0x00000030,0x0000002f,0x00050041,0x00000012,0x00000032,0x0000000f,0x00000031,
0x0004003d,0x00000007,0x00000033,0x00000032,0x00050085,0x00000007,0x00000034,0x00000030,
0x00000033,0x00050041,0x00000012,0x00000036,0x0000000f,0x00000035,0x0004003d,0x00000007,
0x00000037,0x00000036,0x00050081,0x00000007,0x00000038,0x00000034,0x00000037,0x0003003e,
0x0000002e,0x00000038,0x0003003e,0x00000039,0x0000003a,0x0003003e,0x0000003c,0x0000003d,
0x000100fd,0x00010038
};

42
src/vk/spirv/beam_vert.c Normal file
View file

@ -0,0 +1,42 @@
// 8.13.3559
#pragma once
const uint32_t beam_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000027,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000020,
0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,
0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000008,
0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000000a,0x00000000,0x00060005,
0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,0x00060006,0x0000000e,0x00000000,
0x4d70766d,0x69727461,0x00000078,0x00030005,0x00000010,0x00006370,0x00050005,0x00000016,
0x65566e69,0x78657472,0x00000000,0x00040005,0x00000020,0x6f6c6f63,0x00000072,0x00070005,
0x00000021,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,0x00050006,0x00000021,
0x00000000,0x6f6c6f63,0x00000072,0x00030005,0x00000023,0x006f6275,0x00050048,0x00000008,
0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,
0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,
0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,0x00040047,
0x00000016,0x0000001e,0x00000000,0x00040047,0x00000020,0x0000001e,0x00000000,0x00050048,
0x00000021,0x00000000,0x00000023,0x00000000,0x00030047,0x00000021,0x00000002,0x00040047,
0x00000023,0x00000022,0x00000000,0x00040047,0x00000023,0x00000021,0x00000000,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,
0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,
0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,
0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,
0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,
0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,
0x0000000d,0x00040017,0x00000014,0x00000006,0x00000003,0x00040020,0x00000015,0x00000001,
0x00000014,0x0004003b,0x00000015,0x00000016,0x00000001,0x0004002b,0x00000006,0x00000018,
0x3f800000,0x00040020,0x0000001e,0x00000003,0x00000007,0x0004003b,0x0000001e,0x00000020,
0x00000003,0x0003001e,0x00000021,0x00000007,0x00040020,0x00000022,0x00000002,0x00000021,
0x0004003b,0x00000022,0x00000023,0x00000002,0x00040020,0x00000024,0x00000002,0x00000007,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,
0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,0x00000017,
0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,0x00000006,
0x0000001b,0x00000017,0x00000002,0x00070050,0x00000007,0x0000001c,0x00000019,0x0000001a,
0x0000001b,0x00000018,0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,0x00050041,
0x0000001e,0x0000001f,0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,0x00050041,
0x00000024,0x00000025,0x00000023,0x0000000c,0x0004003d,0x00000007,0x00000026,0x00000025,
0x0003003e,0x00000020,0x00000026,0x000100fd,0x00010038
};

View file

@ -0,0 +1,41 @@
// 8.13.3559
#pragma once
const uint32_t d_light_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000027,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000020,
0x00000021,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,
0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,
0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000000a,0x00000000,
0x00070005,0x0000000e,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,0x00060006,
0x0000000e,0x00000000,0x4d70766d,0x69727461,0x00000078,0x00030005,0x00000010,0x006f6275,
0x00050005,0x00000016,0x65566e69,0x78657472,0x00000000,0x00040005,0x00000020,0x6f6c6f63,
0x00000072,0x00040005,0x00000021,0x6f436e69,0x00726f6c,0x00050048,0x00000008,0x00000000,
0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,0x00000000,
0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000e,
0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,0x00040047,0x00000010,
0x00000022,0x00000000,0x00040047,0x00000010,0x00000021,0x00000000,0x00040047,0x00000016,
0x0000001e,0x00000000,0x00040047,0x00000020,0x0000001e,0x00000000,0x00040047,0x00000021,
0x0000001e,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,
0x00000007,0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,
0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,
0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,
0x00040020,0x0000000f,0x00000002,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000002,
0x00040020,0x00000011,0x00000002,0x0000000d,0x00040017,0x00000014,0x00000006,0x00000003,
0x00040020,0x00000015,0x00000001,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000001,
0x0004002b,0x00000006,0x00000018,0x3f800000,0x00040020,0x0000001e,0x00000003,0x00000007,
0x0004003b,0x0000001e,0x00000020,0x00000003,0x0004003b,0x00000015,0x00000021,0x00000001,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,
0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,0x00000017,
0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,0x00000006,
0x0000001b,0x00000017,0x00000002,0x00070050,0x00000007,0x0000001c,0x00000019,0x0000001a,
0x0000001b,0x00000018,0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,0x00050041,
0x0000001e,0x0000001f,0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,0x0004003d,
0x00000014,0x00000022,0x00000021,0x00050051,0x00000006,0x00000023,0x00000022,0x00000000,
0x00050051,0x00000006,0x00000024,0x00000022,0x00000001,0x00050051,0x00000006,0x00000025,
0x00000022,0x00000002,0x00070050,0x00000007,0x00000026,0x00000023,0x00000024,0x00000025,
0x00000018,0x0003003e,0x00000020,0x00000026,0x000100fd,0x00010038
};

37
src/vk/spirv/model_frag.c Normal file
View file

@ -0,0 +1,37 @@
// 8.13.3559
#pragma once
const uint32_t model_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000028,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000008,0x00000012,0x0000001a,
0x0000001e,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000008,0x74786574,0x64657275,0x00000000,
0x00060005,0x00000012,0x67617266,0x746e656d,0x6f6c6f43,0x00000072,0x00050005,0x00000016,
0x78655473,0x65727574,0x00000000,0x00050005,0x0000001a,0x43786574,0x64726f6f,0x00000000,
0x00040005,0x0000001e,0x6f6c6f63,0x00000072,0x00030047,0x00000008,0x0000000e,0x00040047,
0x00000008,0x0000001e,0x00000002,0x00040047,0x00000012,0x0000001e,0x00000000,0x00040047,
0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,0x00000000,0x00040047,
0x0000001a,0x0000001e,0x00000001,0x00040047,0x0000001e,0x0000001e,0x00000000,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,
0x00040020,0x00000007,0x00000001,0x00000006,0x0004003b,0x00000007,0x00000008,0x00000001,
0x0004002b,0x00000006,0x0000000a,0x00000000,0x00020014,0x0000000b,0x00030016,0x0000000f,
0x00000020,0x00040017,0x00000010,0x0000000f,0x00000004,0x00040020,0x00000011,0x00000003,
0x00000010,0x0004003b,0x00000011,0x00000012,0x00000003,0x00090019,0x00000013,0x0000000f,
0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000014,
0x00000013,0x00040020,0x00000015,0x00000000,0x00000014,0x0004003b,0x00000015,0x00000016,
0x00000000,0x00040017,0x00000018,0x0000000f,0x00000002,0x00040020,0x00000019,0x00000001,
0x00000018,0x0004003b,0x00000019,0x0000001a,0x00000001,0x00040020,0x0000001d,0x00000001,
0x00000010,0x0004003b,0x0000001d,0x0000001e,0x00000001,0x0004002b,0x0000000f,0x00000020,
0x00000000,0x0004002b,0x0000000f,0x00000021,0x3f800000,0x00050036,0x00000002,0x00000004,
0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x00000006,0x00000009,0x00000008,
0x000500ab,0x0000000b,0x0000000c,0x00000009,0x0000000a,0x000300f7,0x0000000e,0x00000000,
0x000400fa,0x0000000c,0x0000000d,0x00000026,0x000200f8,0x0000000d,0x0004003d,0x00000014,
0x00000017,0x00000016,0x0004003d,0x00000018,0x0000001b,0x0000001a,0x00050057,0x00000010,
0x0000001c,0x00000017,0x0000001b,0x0004003d,0x00000010,0x0000001f,0x0000001e,0x00070050,
0x00000010,0x00000022,0x00000020,0x00000020,0x00000020,0x00000020,0x00070050,0x00000010,
0x00000023,0x00000021,0x00000021,0x00000021,0x00000021,0x0008000c,0x00000010,0x00000024,
0x00000001,0x0000002b,0x0000001f,0x00000022,0x00000023,0x00050085,0x00000010,0x00000025,
0x0000001c,0x00000024,0x0003003e,0x00000012,0x00000025,0x000200f9,0x0000000e,0x000200f8,
0x00000026,0x0004003d,0x00000010,0x00000027,0x0000001e,0x0003003e,0x00000012,0x00000027,
0x000200f9,0x0000000e,0x000200f8,0x0000000e,0x000100fd,0x00010038
};

59
src/vk/spirv/model_vert.c Normal file
View file

@ -0,0 +1,59 @@
// 8.13.3559
#pragma once
const uint32_t model_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000037,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000c000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000027,
0x00000029,0x0000002d,0x0000002f,0x00000032,0x00030003,0x00000002,0x000001c2,0x00090004,
0x415f4c47,0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,
0x78657472,0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,
0x00030005,0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,
0x00000000,0x00060006,0x0000000e,0x00000000,0x614d7076,0x78697274,0x00000000,0x00030005,
0x00000010,0x00006370,0x00070005,0x00000014,0x66696e55,0x426d726f,0x65666675,0x6a624f72,
0x00746365,0x00050006,0x00000014,0x00000000,0x65646f6d,0x0000006c,0x00060006,0x00000014,
0x00000001,0x74786574,0x64657275,0x00000000,0x00030005,0x00000016,0x006f6275,0x00050005,
0x0000001d,0x65566e69,0x78657472,0x00000000,0x00040005,0x00000027,0x6f6c6f63,0x00000072,
0x00040005,0x00000029,0x6f436e69,0x00726f6c,0x00050005,0x0000002d,0x43786574,0x64726f6f,
0x00000000,0x00050005,0x0000002f,0x65546e69,0x6f6f4378,0x00006472,0x00050005,0x00000032,
0x74786574,0x64657275,0x00000000,0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,
0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,
0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,
0x00000010,0x00030047,0x0000000e,0x00000002,0x00040048,0x00000014,0x00000000,0x00000005,
0x00050048,0x00000014,0x00000000,0x00000023,0x00000000,0x00050048,0x00000014,0x00000000,
0x00000007,0x00000010,0x00050048,0x00000014,0x00000001,0x00000023,0x00000040,0x00030047,
0x00000014,0x00000002,0x00040047,0x00000016,0x00000022,0x00000001,0x00040047,0x00000016,
0x00000021,0x00000000,0x00040047,0x0000001d,0x0000001e,0x00000000,0x00040047,0x00000027,
0x0000001e,0x00000000,0x00040047,0x00000029,0x0000001e,0x00000001,0x00040047,0x0000002d,
0x0000001e,0x00000001,0x00040047,0x0000002f,0x0000001e,0x00000002,0x00040047,0x00000032,
0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,
0x00000007,0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,
0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,
0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,
0x00040020,0x0000000f,0x00000009,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,
0x00040020,0x00000011,0x00000009,0x0000000d,0x0004001e,0x00000014,0x0000000d,0x0000000b,
0x00040020,0x00000015,0x00000002,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000002,
0x00040020,0x00000017,0x00000002,0x0000000d,0x00040017,0x0000001b,0x00000006,0x00000003,
0x00040020,0x0000001c,0x00000001,0x0000001b,0x0004003b,0x0000001c,0x0000001d,0x00000001,
0x0004002b,0x00000006,0x0000001f,0x3f800000,0x00040020,0x00000025,0x00000003,0x00000007,
0x0004003b,0x00000025,0x00000027,0x00000003,0x00040020,0x00000028,0x00000001,0x00000007,
0x0004003b,0x00000028,0x00000029,0x00000001,0x00040017,0x0000002b,0x00000006,0x00000002,
0x00040020,0x0000002c,0x00000003,0x0000002b,0x0004003b,0x0000002c,0x0000002d,0x00000003,
0x00040020,0x0000002e,0x00000001,0x0000002b,0x0004003b,0x0000002e,0x0000002f,0x00000001,
0x00040020,0x00000031,0x00000003,0x0000000b,0x0004003b,0x00000031,0x00000032,0x00000003,
0x0004002b,0x0000000b,0x00000033,0x00000001,0x00040020,0x00000034,0x00000002,0x0000000b,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,
0x00050041,0x00000017,0x00000018,0x00000016,0x0000000c,0x0004003d,0x0000000d,0x00000019,
0x00000018,0x00050092,0x0000000d,0x0000001a,0x00000013,0x00000019,0x0004003d,0x0000001b,
0x0000001e,0x0000001d,0x00050051,0x00000006,0x00000020,0x0000001e,0x00000000,0x00050051,
0x00000006,0x00000021,0x0000001e,0x00000001,0x00050051,0x00000006,0x00000022,0x0000001e,
0x00000002,0x00070050,0x00000007,0x00000023,0x00000020,0x00000021,0x00000022,0x0000001f,
0x00050091,0x00000007,0x00000024,0x0000001a,0x00000023,0x00050041,0x00000025,0x00000026,
0x0000000a,0x0000000c,0x0003003e,0x00000026,0x00000024,0x0004003d,0x00000007,0x0000002a,
0x00000029,0x0003003e,0x00000027,0x0000002a,0x0004003d,0x0000002b,0x00000030,0x0000002f,
0x0003003e,0x0000002d,0x00000030,0x00050041,0x00000034,0x00000035,0x00000016,0x00000033,
0x0004003d,0x0000000b,0x00000036,0x00000035,0x0003003e,0x00000032,0x00000036,0x000100fd,
0x00010038
};

View file

@ -0,0 +1,49 @@
// 8.13.3559
#pragma once
const uint32_t nullmodel_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000027,
0x00000028,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,
0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,
0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000000a,0x00000000,
0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,0x00060006,0x0000000e,
0x00000000,0x614d7076,0x78697274,0x00000000,0x00030005,0x00000010,0x00006370,0x00070005,
0x00000014,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,0x00050006,0x00000014,
0x00000000,0x65646f6d,0x0000006c,0x00030005,0x00000016,0x006f6275,0x00050005,0x0000001d,
0x65566e69,0x78657472,0x00000000,0x00040005,0x00000027,0x6f6c6f63,0x00000072,0x00040005,
0x00000028,0x6f436e69,0x00726f6c,0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,
0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,
0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,
0x00000010,0x00030047,0x0000000e,0x00000002,0x00040048,0x00000014,0x00000000,0x00000005,
0x00050048,0x00000014,0x00000000,0x00000023,0x00000000,0x00050048,0x00000014,0x00000000,
0x00000007,0x00000010,0x00030047,0x00000014,0x00000002,0x00040047,0x00000016,0x00000022,
0x00000000,0x00040047,0x00000016,0x00000021,0x00000000,0x00040047,0x0000001d,0x0000001e,
0x00000000,0x00040047,0x00000027,0x0000001e,0x00000000,0x00040047,0x00000028,0x0000001e,
0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,
0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,
0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,
0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,
0x0000000f,0x00000009,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,
0x00000011,0x00000009,0x0000000d,0x0003001e,0x00000014,0x0000000d,0x00040020,0x00000015,
0x00000002,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000002,0x00040020,0x00000017,
0x00000002,0x0000000d,0x00040017,0x0000001b,0x00000006,0x00000003,0x00040020,0x0000001c,
0x00000001,0x0000001b,0x0004003b,0x0000001c,0x0000001d,0x00000001,0x0004002b,0x00000006,
0x0000001f,0x3f800000,0x00040020,0x00000025,0x00000003,0x00000007,0x0004003b,0x00000025,
0x00000027,0x00000003,0x0004003b,0x0000001c,0x00000028,0x00000001,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000011,0x00000012,
0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,0x00050041,0x00000017,
0x00000018,0x00000016,0x0000000c,0x0004003d,0x0000000d,0x00000019,0x00000018,0x00050092,
0x0000000d,0x0000001a,0x00000013,0x00000019,0x0004003d,0x0000001b,0x0000001e,0x0000001d,
0x00050051,0x00000006,0x00000020,0x0000001e,0x00000000,0x00050051,0x00000006,0x00000021,
0x0000001e,0x00000001,0x00050051,0x00000006,0x00000022,0x0000001e,0x00000002,0x00070050,
0x00000007,0x00000023,0x00000020,0x00000021,0x00000022,0x0000001f,0x00050091,0x00000007,
0x00000024,0x0000001a,0x00000023,0x00050041,0x00000025,0x00000026,0x0000000a,0x0000000c,
0x0003003e,0x00000026,0x00000024,0x0004003d,0x0000001b,0x00000029,0x00000028,0x00050051,
0x00000006,0x0000002a,0x00000029,0x00000000,0x00050051,0x00000006,0x0000002b,0x00000029,
0x00000001,0x00050051,0x00000006,0x0000002c,0x00000029,0x00000002,0x00070050,0x00000007,
0x0000002d,0x0000002a,0x0000002b,0x0000002c,0x0000001f,0x0003003e,0x00000027,0x0000002d,
0x000100fd,0x00010038
};

View file

@ -0,0 +1,47 @@
// 8.13.3743
#pragma once
const uint32_t particle_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000002d,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000c000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000022,
0x00000024,0x00000026,0x00000028,0x0000002b,0x00030003,0x00000002,0x000001c2,0x00090004,
0x415f4c47,0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,
0x78657472,0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,
0x00030005,0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,
0x00000000,0x00060006,0x0000000e,0x00000000,0x4d70766d,0x69727461,0x00000078,0x00030005,
0x00000010,0x00006370,0x00050005,0x00000016,0x65566e69,0x78657472,0x00000000,0x00050005,
0x00000022,0x43786574,0x64726f6f,0x00000000,0x00050005,0x00000024,0x65546e69,0x6f6f4378,
0x00006472,0x00040005,0x00000026,0x6f6c6f63,0x00000072,0x00040005,0x00000028,0x6f436e69,
0x00726f6c,0x00050005,0x0000002b,0x65725461,0x6c6f6873,0x00000064,0x00050048,0x00000008,
0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,
0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,
0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,0x00040047,
0x00000016,0x0000001e,0x00000000,0x00040047,0x00000022,0x0000001e,0x00000000,0x00040047,
0x00000024,0x0000001e,0x00000002,0x00040047,0x00000026,0x0000001e,0x00000001,0x00040047,
0x00000028,0x0000001e,0x00000001,0x00040047,0x0000002b,0x0000001e,0x00000002,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,
0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,
0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,
0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,
0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,
0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,
0x0000000d,0x00040017,0x00000014,0x00000006,0x00000003,0x00040020,0x00000015,0x00000001,
0x00000014,0x0004003b,0x00000015,0x00000016,0x00000001,0x0004002b,0x00000006,0x00000018,
0x3f800000,0x00040020,0x0000001e,0x00000003,0x00000007,0x00040017,0x00000020,0x00000006,
0x00000002,0x00040020,0x00000021,0x00000003,0x00000020,0x0004003b,0x00000021,0x00000022,
0x00000003,0x00040020,0x00000023,0x00000001,0x00000020,0x0004003b,0x00000023,0x00000024,
0x00000001,0x0004003b,0x0000001e,0x00000026,0x00000003,0x00040020,0x00000027,0x00000001,
0x00000007,0x0004003b,0x00000027,0x00000028,0x00000001,0x00040020,0x0000002a,0x00000003,
0x00000006,0x0004003b,0x0000002a,0x0000002b,0x00000003,0x0004002b,0x00000006,0x0000002c,
0x3f000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
0x00050041,0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,
0x00000012,0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,
0x00000017,0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,
0x00000006,0x0000001b,0x00000017,0x00000002,0x00070050,0x00000007,0x0000001c,0x00000019,
0x0000001a,0x0000001b,0x00000018,0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,
0x00050041,0x0000001e,0x0000001f,0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,
0x0004003d,0x00000020,0x00000025,0x00000024,0x0003003e,0x00000022,0x00000025,0x0004003d,
0x00000007,0x00000029,0x00000028,0x0003003e,0x00000026,0x00000029,0x0003003e,0x0000002b,
0x0000002c,0x000100fd,0x00010038
};

View file

@ -0,0 +1,28 @@
// 8.13.3559
#pragma once
const uint32_t point_particle_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000020,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x0000001c,0x0000001e,
0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,
0x6e69616d,0x00000000,0x00030005,0x00000009,0x00797863,0x00060005,0x0000000c,0x505f6c67,
0x746e696f,0x726f6f43,0x00000064,0x00060005,0x0000001c,0x67617266,0x746e656d,0x6f6c6f43,
0x00000072,0x00040005,0x0000001e,0x6f6c6f63,0x00000072,0x00040047,0x0000000c,0x0000000b,
0x00000010,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00040047,0x0000001e,0x0000001e,
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,
0x00000007,0x0004002b,0x00000006,0x0000000a,0x40000000,0x00040020,0x0000000b,0x00000001,
0x00000007,0x0004003b,0x0000000b,0x0000000c,0x00000001,0x0004002b,0x00000006,0x0000000f,
0x3f800000,0x00020014,0x00000015,0x00040017,0x0000001a,0x00000006,0x00000004,0x00040020,
0x0000001b,0x00000003,0x0000001a,0x0004003b,0x0000001b,0x0000001c,0x00000003,0x00040020,
0x0000001d,0x00000001,0x0000001a,0x0004003b,0x0000001d,0x0000001e,0x00000001,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,
0x00000009,0x00000007,0x0004003d,0x00000007,0x0000000d,0x0000000c,0x0005008e,0x00000007,
0x0000000e,0x0000000d,0x0000000a,0x00050050,0x00000007,0x00000010,0x0000000f,0x0000000f,
0x00050083,0x00000007,0x00000011,0x0000000e,0x00000010,0x0003003e,0x00000009,0x00000011,
0x0004003d,0x00000007,0x00000012,0x00000009,0x0004003d,0x00000007,0x00000013,0x00000009,
0x00050094,0x00000006,0x00000014,0x00000012,0x00000013,0x000500ba,0x00000015,0x00000016,
0x00000014,0x0000000f,0x000300f7,0x00000018,0x00000000,0x000400fa,0x00000016,0x00000017,
0x00000018,0x000200f8,0x00000017,0x000100fc,0x000200f8,0x00000018,0x0004003d,0x0000001a,
0x0000001f,0x0000001e,0x0003003e,0x0000001c,0x0000001f,0x000100fd,0x00010038
};

View file

@ -0,0 +1,82 @@
// 8.13.3559
#pragma once
const uint32_t point_particle_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000055,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000051,
0x00000053,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,
0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,
0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x00000008,0x00000001,
0x505f6c67,0x746e696f,0x657a6953,0x00000000,0x00030005,0x0000000a,0x00000000,0x00060005,
0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,0x00060006,0x0000000e,0x00000000,
0x4d70766d,0x69727461,0x00000078,0x00030005,0x00000010,0x00006370,0x00050005,0x00000016,
0x65566e69,0x78657472,0x00000000,0x00050005,0x00000021,0x74736964,0x7474615f,0x00006e65,
0x00070005,0x00000022,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,0x00060006,
0x00000022,0x00000000,0x6e696f70,0x7a695374,0x00000065,0x00060006,0x00000022,0x00000001,
0x6e696f70,0x61635374,0x0000656c,0x00070006,0x00000022,0x00000002,0x506e696d,0x746e696f,
0x657a6953,0x00000000,0x00070006,0x00000022,0x00000003,0x5078616d,0x746e696f,0x657a6953,
0x00000000,0x00050006,0x00000022,0x00000004,0x5f747461,0x00000061,0x00050006,0x00000022,
0x00000005,0x5f747461,0x00000062,0x00050006,0x00000022,0x00000006,0x5f747461,0x00000063,
0x00030005,0x00000024,0x006f6275,0x00040005,0x00000051,0x6f6c6f63,0x00000072,0x00040005,
0x00000053,0x6f436e69,0x00726f6c,0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,
0x00050048,0x00000008,0x00000001,0x0000000b,0x00000001,0x00030047,0x00000008,0x00000002,
0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,
0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,
0x00000002,0x00040047,0x00000016,0x0000001e,0x00000000,0x00050048,0x00000022,0x00000000,
0x00000023,0x00000000,0x00050048,0x00000022,0x00000001,0x00000023,0x00000004,0x00050048,
0x00000022,0x00000002,0x00000023,0x00000008,0x00050048,0x00000022,0x00000003,0x00000023,
0x0000000c,0x00050048,0x00000022,0x00000004,0x00000023,0x00000010,0x00050048,0x00000022,
0x00000005,0x00000023,0x00000014,0x00050048,0x00000022,0x00000006,0x00000023,0x00000018,
0x00030047,0x00000022,0x00000002,0x00040047,0x00000024,0x00000022,0x00000000,0x00040047,
0x00000024,0x00000021,0x00000000,0x00040047,0x00000051,0x0000001e,0x00000000,0x00040047,
0x00000053,0x0000001e,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x0004001e,
0x00000008,0x00000007,0x00000006,0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,
0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,
0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,
0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,0x0000000e,0x0004003b,0x0000000f,
0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,0x0000000d,0x00040017,0x00000014,
0x00000006,0x00000003,0x00040020,0x00000015,0x00000001,0x00000014,0x0004003b,0x00000015,
0x00000016,0x00000001,0x0004002b,0x00000006,0x00000018,0x3f800000,0x00040020,0x0000001e,
0x00000003,0x00000007,0x00040020,0x00000020,0x00000007,0x00000006,0x0009001e,0x00000022,
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,
0x00000023,0x00000002,0x00000022,0x0004003b,0x00000023,0x00000024,0x00000002,0x0004002b,
0x0000000b,0x00000025,0x00000001,0x00040020,0x00000026,0x00000002,0x00000006,0x0004002b,
0x0000000b,0x00000029,0x00000004,0x0004002b,0x0000000b,0x0000002c,0x00000005,0x00040015,
0x0000002f,0x00000020,0x00000000,0x0004002b,0x0000002f,0x00000030,0x00000003,0x00040020,
0x00000031,0x00000003,0x00000006,0x0004002b,0x0000000b,0x00000036,0x00000006,0x0004002b,
0x0000000b,0x00000049,0x00000002,0x0004002b,0x0000000b,0x0000004c,0x00000003,0x0004003b,
0x0000001e,0x00000051,0x00000003,0x00040020,0x00000052,0x00000001,0x00000007,0x0004003b,
0x00000052,0x00000053,0x00000001,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
0x000200f8,0x00000005,0x0004003b,0x00000020,0x00000021,0x00000007,0x00050041,0x00000011,
0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,0x0004003d,
0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,0x00000017,0x00000000,
0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,0x00000006,0x0000001b,
0x00000017,0x00000002,0x00070050,0x00000007,0x0000001c,0x00000019,0x0000001a,0x0000001b,
0x00000018,0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,0x00050041,0x0000001e,
0x0000001f,0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,0x00050041,0x00000026,
0x00000027,0x00000024,0x00000025,0x0004003d,0x00000006,0x00000028,0x00000027,0x00050041,
0x00000026,0x0000002a,0x00000024,0x00000029,0x0004003d,0x00000006,0x0000002b,0x0000002a,
0x00050041,0x00000026,0x0000002d,0x00000024,0x0000002c,0x0004003d,0x00000006,0x0000002e,
0x0000002d,0x00060041,0x00000031,0x00000032,0x0000000a,0x0000000c,0x00000030,0x0004003d,
0x00000006,0x00000033,0x00000032,0x00050085,0x00000006,0x00000034,0x0000002e,0x00000033,
0x00050081,0x00000006,0x00000035,0x0000002b,0x00000034,0x00050041,0x00000026,0x00000037,
0x00000024,0x00000036,0x0004003d,0x00000006,0x00000038,0x00000037,0x00060041,0x00000031,
0x00000039,0x0000000a,0x0000000c,0x00000030,0x0004003d,0x00000006,0x0000003a,0x00000039,
0x00050085,0x00000006,0x0000003b,0x00000038,0x0000003a,0x00060041,0x00000031,0x0000003c,
0x0000000a,0x0000000c,0x00000030,0x0004003d,0x00000006,0x0000003d,0x0000003c,0x00050085,
0x00000006,0x0000003e,0x0000003b,0x0000003d,0x00050081,0x00000006,0x0000003f,0x00000035,
0x0000003e,0x00050088,0x00000006,0x00000040,0x00000028,0x0000003f,0x0003003e,0x00000021,
0x00000040,0x00050041,0x00000026,0x00000041,0x00000024,0x00000025,0x0004003d,0x00000006,
0x00000042,0x00000041,0x00050041,0x00000026,0x00000043,0x00000024,0x0000000c,0x0004003d,
0x00000006,0x00000044,0x00000043,0x00050085,0x00000006,0x00000045,0x00000042,0x00000044,
0x0004003d,0x00000006,0x00000046,0x00000021,0x0006000c,0x00000006,0x00000047,0x00000001,
0x0000001f,0x00000046,0x00050085,0x00000006,0x00000048,0x00000045,0x00000047,0x00050041,
0x00000026,0x0000004a,0x00000024,0x00000049,0x0004003d,0x00000006,0x0000004b,0x0000004a,
0x00050041,0x00000026,0x0000004d,0x00000024,0x0000004c,0x0004003d,0x00000006,0x0000004e,
0x0000004d,0x0008000c,0x00000006,0x0000004f,0x00000001,0x0000002b,0x00000048,0x0000004b,
0x0000004e,0x00050041,0x00000031,0x00000050,0x0000000a,0x00000025,0x0003003e,0x00000050,
0x0000004f,0x0004003d,0x00000007,0x00000054,0x00000053,0x0003003e,0x00000051,0x00000054,
0x000100fd,0x00010038
};

View file

@ -0,0 +1,40 @@
// 8.13.3559
#pragma once
const uint32_t polygon_lmap_frag_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000029,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000011,0x00000017,0x0000001b,
0x0000001e,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00040005,0x00000009,0x6f6c6f63,0x00000072,0x00050005,
0x0000000d,0x78655473,0x65727574,0x00000000,0x00050005,0x00000011,0x43786574,0x64726f6f,
0x00000000,0x00040005,0x00000014,0x6867696c,0x00000074,0x00050005,0x00000015,0x67694c73,
0x616d7468,0x00000070,0x00060005,0x00000017,0x43786574,0x64726f6f,0x70616d4c,0x00000000,
0x00060005,0x0000001b,0x67617266,0x746e656d,0x6f6c6f43,0x00000072,0x00060005,0x0000001e,
0x77656976,0x6867694c,0x70616d74,0x00000073,0x00040047,0x0000000d,0x00000022,0x00000000,
0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,0x0000001e,0x00000000,
0x00040047,0x00000015,0x00000022,0x00000002,0x00040047,0x00000015,0x00000021,0x00000000,
0x00040047,0x00000017,0x0000001e,0x00000001,0x00040047,0x0000001b,0x0000001e,0x00000000,
0x00040047,0x0000001e,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,
0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,
0x00040020,0x00000008,0x00000007,0x00000007,0x00090019,0x0000000a,0x00000006,0x00000001,
0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a,
0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000,
0x00040017,0x0000000f,0x00000006,0x00000002,0x00040020,0x00000010,0x00000001,0x0000000f,
0x0004003b,0x00000010,0x00000011,0x00000001,0x0004003b,0x0000000c,0x00000015,0x00000000,
0x0004003b,0x00000010,0x00000017,0x00000001,0x00040020,0x0000001a,0x00000003,0x00000007,
0x0004003b,0x0000001a,0x0000001b,0x00000003,0x0004002b,0x00000006,0x0000001c,0x3f800000,
0x00040020,0x0000001d,0x00000001,0x00000006,0x0004003b,0x0000001d,0x0000001e,0x00000001,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,
0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,0x00000014,0x00000007,0x0004003d,
0x0000000b,0x0000000e,0x0000000d,0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,
0x00000007,0x00000013,0x0000000e,0x00000012,0x0003003e,0x00000009,0x00000013,0x0004003d,
0x0000000b,0x00000016,0x00000015,0x0004003d,0x0000000f,0x00000018,0x00000017,0x00050057,
0x00000007,0x00000019,0x00000016,0x00000018,0x0003003e,0x00000014,0x00000019,0x0004003d,
0x00000006,0x0000001f,0x0000001e,0x00050083,0x00000006,0x00000020,0x0000001c,0x0000001f,
0x0004003d,0x00000007,0x00000021,0x00000009,0x0005008e,0x00000007,0x00000022,0x00000021,
0x00000020,0x0004003d,0x00000007,0x00000023,0x00000014,0x00050085,0x00000007,0x00000024,
0x00000022,0x00000023,0x0004003d,0x00000006,0x00000025,0x0000001e,0x0004003d,0x00000007,
0x00000026,0x00000014,0x0005008e,0x00000007,0x00000027,0x00000026,0x00000025,0x00050081,
0x00000007,0x00000028,0x00000024,0x00000027,0x0003003e,0x0000001b,0x00000028,0x000100fd,
0x00010038
};

View file

@ -0,0 +1,59 @@
// 8.13.3559
#pragma once
const uint32_t polygon_lmap_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000036,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000c000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000029,
0x0000002b,0x0000002d,0x0000002e,0x00000031,0x00030003,0x00000002,0x000001c2,0x00090004,
0x415f4c47,0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,
0x78657472,0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,
0x00030005,0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,
0x00000000,0x00060006,0x0000000e,0x00000000,0x614d7076,0x78697274,0x00000000,0x00030005,
0x00000010,0x00006370,0x00070005,0x00000014,0x66696e55,0x426d726f,0x65666675,0x6a624f72,
0x00746365,0x00050006,0x00000014,0x00000000,0x65646f6d,0x0000006c,0x00070006,0x00000014,
0x00000001,0x77656976,0x6867694c,0x70616d74,0x00000073,0x00030005,0x00000016,0x006f6275,
0x00050005,0x0000001d,0x65566e69,0x78657472,0x00000000,0x00050005,0x00000029,0x43786574,
0x64726f6f,0x00000000,0x00050005,0x0000002b,0x65546e69,0x6f6f4378,0x00006472,0x00060005,
0x0000002d,0x43786574,0x64726f6f,0x70616d4c,0x00000000,0x00060005,0x0000002e,0x65546e69,
0x6f6f4378,0x6d4c6472,0x00007061,0x00060005,0x00000031,0x77656976,0x6867694c,0x70616d74,
0x00000073,0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,
0x00000002,0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,
0x00000023,0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,
0x0000000e,0x00000002,0x00040048,0x00000014,0x00000000,0x00000005,0x00050048,0x00000014,
0x00000000,0x00000023,0x00000000,0x00050048,0x00000014,0x00000000,0x00000007,0x00000010,
0x00050048,0x00000014,0x00000001,0x00000023,0x00000040,0x00030047,0x00000014,0x00000002,
0x00040047,0x00000016,0x00000022,0x00000001,0x00040047,0x00000016,0x00000021,0x00000000,
0x00040047,0x0000001d,0x0000001e,0x00000000,0x00040047,0x00000029,0x0000001e,0x00000000,
0x00040047,0x0000002b,0x0000001e,0x00000001,0x00040047,0x0000002d,0x0000001e,0x00000001,
0x00040047,0x0000002e,0x0000001e,0x00000002,0x00040047,0x00000031,0x0000001e,0x00000002,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,
0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,
0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,
0x0000000d,0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,
0x00000009,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,
0x00000009,0x0000000d,0x0004001e,0x00000014,0x0000000d,0x00000006,0x00040020,0x00000015,
0x00000002,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000002,0x00040020,0x00000017,
0x00000002,0x0000000d,0x00040017,0x0000001b,0x00000006,0x00000003,0x00040020,0x0000001c,
0x00000001,0x0000001b,0x0004003b,0x0000001c,0x0000001d,0x00000001,0x0004002b,0x00000006,
0x0000001f,0x3f800000,0x00040020,0x00000025,0x00000003,0x00000007,0x00040017,0x00000027,
0x00000006,0x00000002,0x00040020,0x00000028,0x00000003,0x00000027,0x0004003b,0x00000028,
0x00000029,0x00000003,0x00040020,0x0000002a,0x00000001,0x00000027,0x0004003b,0x0000002a,
0x0000002b,0x00000001,0x0004003b,0x00000028,0x0000002d,0x00000003,0x0004003b,0x0000002a,
0x0000002e,0x00000001,0x00040020,0x00000030,0x00000003,0x00000006,0x0004003b,0x00000030,
0x00000031,0x00000003,0x0004002b,0x0000000b,0x00000032,0x00000001,0x00040020,0x00000033,
0x00000002,0x00000006,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
0x00000005,0x00050041,0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,
0x00000013,0x00000012,0x00050041,0x00000017,0x00000018,0x00000016,0x0000000c,0x0004003d,
0x0000000d,0x00000019,0x00000018,0x00050092,0x0000000d,0x0000001a,0x00000013,0x00000019,
0x0004003d,0x0000001b,0x0000001e,0x0000001d,0x00050051,0x00000006,0x00000020,0x0000001e,
0x00000000,0x00050051,0x00000006,0x00000021,0x0000001e,0x00000001,0x00050051,0x00000006,
0x00000022,0x0000001e,0x00000002,0x00070050,0x00000007,0x00000023,0x00000020,0x00000021,
0x00000022,0x0000001f,0x00050091,0x00000007,0x00000024,0x0000001a,0x00000023,0x00050041,
0x00000025,0x00000026,0x0000000a,0x0000000c,0x0003003e,0x00000026,0x00000024,0x0004003d,
0x00000027,0x0000002c,0x0000002b,0x0003003e,0x00000029,0x0000002c,0x0004003d,0x00000027,
0x0000002f,0x0000002e,0x0003003e,0x0000002d,0x0000002f,0x00050041,0x00000033,0x00000034,
0x00000016,0x00000032,0x0004003d,0x00000006,0x00000035,0x00000034,0x0003003e,0x00000031,
0x00000035,0x000100fd,0x00010038
};

View file

@ -0,0 +1,51 @@
// 8.13.3559
#pragma once
const uint32_t polygon_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000030,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000022,
0x00000024,0x00000026,0x0000002e,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,
0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,
0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,
0x00060006,0x0000000e,0x00000000,0x4d70766d,0x69727461,0x00000078,0x00030005,0x00000010,
0x00006370,0x00050005,0x00000016,0x65566e69,0x78657472,0x00000000,0x00050005,0x00000022,
0x43786574,0x64726f6f,0x00000000,0x00050005,0x00000024,0x65546e69,0x6f6f4378,0x00006472,
0x00040005,0x00000026,0x6f6c6f63,0x00000072,0x00070005,0x00000027,0x66696e55,0x426d726f,
0x65666675,0x6a624f72,0x00746365,0x00050006,0x00000027,0x00000000,0x6f6c6f63,0x00000072,
0x00030005,0x00000029,0x006f6275,0x00050005,0x0000002e,0x65725461,0x6c6f6873,0x00000064,
0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,
0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,
0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,
0x00000002,0x00040047,0x00000016,0x0000001e,0x00000000,0x00040047,0x00000022,0x0000001e,
0x00000000,0x00040047,0x00000024,0x0000001e,0x00000001,0x00040047,0x00000026,0x0000001e,
0x00000001,0x00050048,0x00000027,0x00000000,0x00000023,0x00000000,0x00030047,0x00000027,
0x00000002,0x00040047,0x00000029,0x00000022,0x00000001,0x00040047,0x00000029,0x00000021,
0x00000000,0x00040047,0x0000002e,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,
0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,
0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,0x00000003,0x00000008,
0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,
0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,
0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,0x0000000e,0x0004003b,
0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,0x0000000d,0x00040017,
0x00000014,0x00000006,0x00000003,0x00040020,0x00000015,0x00000001,0x00000014,0x0004003b,
0x00000015,0x00000016,0x00000001,0x0004002b,0x00000006,0x00000018,0x3f800000,0x00040020,
0x0000001e,0x00000003,0x00000007,0x00040017,0x00000020,0x00000006,0x00000002,0x00040020,
0x00000021,0x00000003,0x00000020,0x0004003b,0x00000021,0x00000022,0x00000003,0x00040020,
0x00000023,0x00000001,0x00000020,0x0004003b,0x00000023,0x00000024,0x00000001,0x0004003b,
0x0000001e,0x00000026,0x00000003,0x0003001e,0x00000027,0x00000007,0x00040020,0x00000028,
0x00000002,0x00000027,0x0004003b,0x00000028,0x00000029,0x00000002,0x00040020,0x0000002a,
0x00000002,0x00000007,0x00040020,0x0000002d,0x00000003,0x00000006,0x0004003b,0x0000002d,
0x0000002e,0x00000003,0x0004002b,0x00000006,0x0000002f,0x00000000,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000011,0x00000012,
0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,0x0004003d,0x00000014,
0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,0x00000017,0x00000000,0x00050051,
0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,0x00000006,0x0000001b,0x00000017,
0x00000002,0x00070050,0x00000007,0x0000001c,0x00000019,0x0000001a,0x0000001b,0x00000018,
0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,0x00050041,0x0000001e,0x0000001f,
0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,0x0004003d,0x00000020,0x00000025,
0x00000024,0x0003003e,0x00000022,0x00000025,0x00050041,0x0000002a,0x0000002b,0x00000029,
0x0000000c,0x0004003d,0x00000007,0x0000002c,0x0000002b,0x0003003e,0x00000026,0x0000002c,
0x0003003e,0x0000002e,0x0000002f,0x000100fd,0x00010038
};

View file

@ -0,0 +1,80 @@
// 8.13.3559
#pragma once
const uint32_t polygon_warp_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000058,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000029,
0x0000002b,0x00000051,0x00000056,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,
0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,
0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,
0x00060006,0x0000000e,0x00000000,0x614d7076,0x78697274,0x00000000,0x00030005,0x00000010,
0x00006370,0x00070005,0x00000014,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,
0x00050006,0x00000014,0x00000000,0x65646f6d,0x0000006c,0x00050006,0x00000014,0x00000001,
0x6f6c6f63,0x00000072,0x00050006,0x00000014,0x00000002,0x656d6974,0x00000000,0x00050006,
0x00000014,0x00000003,0x6f726373,0x00006c6c,0x00030005,0x00000016,0x006f6275,0x00050005,
0x0000001d,0x65566e69,0x78657472,0x00000000,0x00050005,0x00000029,0x43786574,0x64726f6f,
0x00000000,0x00050005,0x0000002b,0x65546e69,0x6f6f4378,0x00006472,0x00040005,0x00000051,
0x6f6c6f63,0x00000072,0x00050005,0x00000056,0x65725461,0x6c6f6873,0x00000064,0x00050048,
0x00000008,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,
0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,
0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,
0x00040048,0x00000014,0x00000000,0x00000005,0x00050048,0x00000014,0x00000000,0x00000023,
0x00000000,0x00050048,0x00000014,0x00000000,0x00000007,0x00000010,0x00050048,0x00000014,
0x00000001,0x00000023,0x00000040,0x00050048,0x00000014,0x00000002,0x00000023,0x00000050,
0x00050048,0x00000014,0x00000003,0x00000023,0x00000054,0x00030047,0x00000014,0x00000002,
0x00040047,0x00000016,0x00000022,0x00000001,0x00040047,0x00000016,0x00000021,0x00000000,
0x00040047,0x0000001d,0x0000001e,0x00000000,0x00040047,0x00000029,0x0000001e,0x00000000,
0x00040047,0x0000002b,0x0000001e,0x00000001,0x00040047,0x00000051,0x0000001e,0x00000001,
0x00040047,0x00000056,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,
0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,
0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,
0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,
0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,
0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,0x0000000e,0x0004003b,0x0000000f,
0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,0x0000000d,0x0006001e,0x00000014,
0x0000000d,0x00000007,0x00000006,0x00000006,0x00040020,0x00000015,0x00000002,0x00000014,
0x0004003b,0x00000015,0x00000016,0x00000002,0x00040020,0x00000017,0x00000002,0x0000000d,
0x00040017,0x0000001b,0x00000006,0x00000003,0x00040020,0x0000001c,0x00000001,0x0000001b,
0x0004003b,0x0000001c,0x0000001d,0x00000001,0x0004002b,0x00000006,0x0000001f,0x3f800000,
0x00040020,0x00000025,0x00000003,0x00000007,0x00040017,0x00000027,0x00000006,0x00000002,
0x00040020,0x00000028,0x00000003,0x00000027,0x0004003b,0x00000028,0x00000029,0x00000003,
0x00040020,0x0000002a,0x00000001,0x00000027,0x0004003b,0x0000002a,0x0000002b,0x00000001,
0x0004002b,0x00000006,0x0000002d,0x40000000,0x0004002b,0x0000000b,0x0000002e,0x00000002,
0x00040020,0x0000002f,0x00000002,0x00000006,0x00040015,0x00000033,0x00000020,0x00000000,
0x0004002b,0x00000033,0x00000034,0x00000001,0x00040020,0x00000035,0x00000001,0x00000006,
0x0004002b,0x00000006,0x00000038,0x4051eb85,0x0004002b,0x00000033,0x0000003f,0x00000000,
0x0004002b,0x00000006,0x00000046,0x3d4ccccd,0x0004002b,0x0000000b,0x00000049,0x00000003,
0x00040020,0x0000004c,0x00000003,0x00000006,0x0004003b,0x00000025,0x00000051,0x00000003,
0x0004002b,0x0000000b,0x00000052,0x00000001,0x00040020,0x00000053,0x00000002,0x00000007,
0x0004003b,0x0000004c,0x00000056,0x00000003,0x0004002b,0x00000006,0x00000057,0x00000000,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,
0x00050041,0x00000017,0x00000018,0x00000016,0x0000000c,0x0004003d,0x0000000d,0x00000019,
0x00000018,0x00050092,0x0000000d,0x0000001a,0x00000013,0x00000019,0x0004003d,0x0000001b,
0x0000001e,0x0000001d,0x00050051,0x00000006,0x00000020,0x0000001e,0x00000000,0x00050051,
0x00000006,0x00000021,0x0000001e,0x00000001,0x00050051,0x00000006,0x00000022,0x0000001e,
0x00000002,0x00070050,0x00000007,0x00000023,0x00000020,0x00000021,0x00000022,0x0000001f,
0x00050091,0x00000007,0x00000024,0x0000001a,0x00000023,0x00050041,0x00000025,0x00000026,
0x0000000a,0x0000000c,0x0003003e,0x00000026,0x00000024,0x0004003d,0x00000027,0x0000002c,
0x0000002b,0x00050041,0x0000002f,0x00000030,0x00000016,0x0000002e,0x0004003d,0x00000006,
0x00000031,0x00000030,0x00050085,0x00000006,0x00000032,0x0000002d,0x00000031,0x00050041,
0x00000035,0x00000036,0x0000002b,0x00000034,0x0004003d,0x00000006,0x00000037,0x00000036,
0x00050085,0x00000006,0x00000039,0x00000037,0x00000038,0x00050081,0x00000006,0x0000003a,
0x00000032,0x00000039,0x0006000c,0x00000006,0x0000003b,0x00000001,0x0000000d,0x0000003a,
0x00050041,0x0000002f,0x0000003c,0x00000016,0x0000002e,0x0004003d,0x00000006,0x0000003d,
0x0000003c,0x00050085,0x00000006,0x0000003e,0x0000002d,0x0000003d,0x00050041,0x00000035,
0x00000040,0x0000002b,0x0000003f,0x0004003d,0x00000006,0x00000041,0x00000040,0x00050085,
0x00000006,0x00000042,0x00000041,0x00000038,0x00050081,0x00000006,0x00000043,0x0000003e,
0x00000042,0x0006000c,0x00000006,0x00000044,0x00000001,0x0000000d,0x00000043,0x00050050,
0x00000027,0x00000045,0x0000003b,0x00000044,0x0005008e,0x00000027,0x00000047,0x00000045,
0x00000046,0x00050081,0x00000027,0x00000048,0x0000002c,0x00000047,0x0003003e,0x00000029,
0x00000048,0x00050041,0x0000002f,0x0000004a,0x00000016,0x00000049,0x0004003d,0x00000006,
0x0000004b,0x0000004a,0x00050041,0x0000004c,0x0000004d,0x00000029,0x0000003f,0x0004003d,
0x00000006,0x0000004e,0x0000004d,0x00050081,0x00000006,0x0000004f,0x0000004e,0x0000004b,
0x00050041,0x0000004c,0x00000050,0x00000029,0x0000003f,0x0003003e,0x00000050,0x0000004f,
0x00050041,0x00000053,0x00000054,0x00000016,0x00000052,0x0004003d,0x00000007,0x00000055,
0x00000054,0x0003003e,0x00000051,0x00000055,0x0003003e,0x00000056,0x00000057,0x000100fd,
0x00010038
};

View file

@ -0,0 +1,64 @@
// 1011.0.0
#pragma once
const uint32_t postprocess_frag_spv[] = {
0x07230203,0x00010000,0x0008000a,0x00000046,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000002c,0x00030010,
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,
0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,
0x6e69616d,0x00000000,0x00060005,0x00000009,0x6f6e6e75,0x65546d72,0x6f6f4378,0x00006472,
0x00050005,0x0000000b,0x43786574,0x64726f6f,0x00000000,0x00060005,0x0000000d,0x68737550,
0x736e6f43,0x746e6174,0x00000000,0x00060006,0x0000000d,0x00000000,0x74736f70,0x636f7270,
0x00737365,0x00050006,0x0000000d,0x00000001,0x6d6d6167,0x00000061,0x00060006,0x0000000d,
0x00000002,0x57726373,0x68746469,0x00000000,0x00060006,0x0000000d,0x00000003,0x48726373,
0x68676965,0x00000074,0x00050006,0x0000000d,0x00000004,0x7366666f,0x00587465,0x00050006,
0x0000000d,0x00000005,0x7366666f,0x00597465,0x00030005,0x0000000f,0x00006370,0x00060005,
0x0000002c,0x67617266,0x746e656d,0x6f6c6f43,0x00000072,0x00050005,0x00000030,0x78655473,
0x65727574,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000,0x00050048,0x0000000d,
0x00000000,0x00000023,0x00000044,0x00050048,0x0000000d,0x00000001,0x00000023,0x00000048,
0x00050048,0x0000000d,0x00000002,0x00000023,0x0000004c,0x00050048,0x0000000d,0x00000003,
0x00000023,0x00000050,0x00050048,0x0000000d,0x00000004,0x00000023,0x00000054,0x00050048,
0x0000000d,0x00000005,0x00000023,0x00000058,0x00030047,0x0000000d,0x00000002,0x00040047,
0x0000002c,0x0000001e,0x00000000,0x00040047,0x00000030,0x00000022,0x00000000,0x00040047,
0x00000030,0x00000021,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,
0x00000008,0x00000007,0x00000007,0x00040020,0x0000000a,0x00000001,0x00000007,0x0004003b,
0x0000000a,0x0000000b,0x00000001,0x0008001e,0x0000000d,0x00000006,0x00000006,0x00000006,
0x00000006,0x00000006,0x00000006,0x00040020,0x0000000e,0x00000009,0x0000000d,0x0004003b,
0x0000000e,0x0000000f,0x00000009,0x00040015,0x00000010,0x00000020,0x00000001,0x0004002b,
0x00000010,0x00000011,0x00000002,0x00040020,0x00000012,0x00000009,0x00000006,0x0004002b,
0x00000010,0x00000015,0x00000003,0x0004002b,0x00000010,0x0000001a,0x00000004,0x0004002b,
0x00000010,0x0000001d,0x00000005,0x0004002b,0x00000010,0x00000022,0x00000000,0x0004002b,
0x00000006,0x00000025,0x00000000,0x00020014,0x00000026,0x00040017,0x0000002a,0x00000006,
0x00000004,0x00040020,0x0000002b,0x00000003,0x0000002a,0x0004003b,0x0000002b,0x0000002c,
0x00000003,0x00090019,0x0000002d,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
0x00000001,0x00000000,0x0003001b,0x0000002e,0x0000002d,0x00040020,0x0000002f,0x00000000,
0x0000002e,0x0004003b,0x0000002f,0x00000030,0x00000000,0x00040017,0x00000034,0x00000006,
0x00000003,0x0004002b,0x00000006,0x00000036,0x3fc00000,0x0004002b,0x00000010,0x00000038,
0x00000001,0x0004002b,0x00000006,0x0000003d,0x3f800000,0x00050036,0x00000002,0x00000004,
0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,
0x0004003d,0x00000007,0x0000000c,0x0000000b,0x00050041,0x00000012,0x00000013,0x0000000f,
0x00000011,0x0004003d,0x00000006,0x00000014,0x00000013,0x00050041,0x00000012,0x00000016,
0x0000000f,0x00000015,0x0004003d,0x00000006,0x00000017,0x00000016,0x00050050,0x00000007,
0x00000018,0x00000014,0x00000017,0x00050085,0x00000007,0x00000019,0x0000000c,0x00000018,
0x00050041,0x00000012,0x0000001b,0x0000000f,0x0000001a,0x0004003d,0x00000006,0x0000001c,
0x0000001b,0x00050041,0x00000012,0x0000001e,0x0000000f,0x0000001d,0x0004003d,0x00000006,
0x0000001f,0x0000001e,0x00050050,0x00000007,0x00000020,0x0000001c,0x0000001f,0x00050081,
0x00000007,0x00000021,0x00000019,0x00000020,0x0003003e,0x00000009,0x00000021,0x00050041,
0x00000012,0x00000023,0x0000000f,0x00000022,0x0004003d,0x00000006,0x00000024,0x00000023,
0x000500ba,0x00000026,0x00000027,0x00000024,0x00000025,0x000300f7,0x00000029,0x00000000,
0x000400fa,0x00000027,0x00000028,0x00000042,0x000200f8,0x00000028,0x0004003d,0x0000002e,
0x00000031,0x00000030,0x0004003d,0x00000007,0x00000032,0x00000009,0x00070058,0x0000002a,
0x00000033,0x00000031,0x00000032,0x00000002,0x00000025,0x0008004f,0x00000034,0x00000035,
0x00000033,0x00000033,0x00000000,0x00000001,0x00000002,0x0005008e,0x00000034,0x00000037,
0x00000035,0x00000036,0x00050041,0x00000012,0x00000039,0x0000000f,0x00000038,0x0004003d,
0x00000006,0x0000003a,0x00000039,0x00060050,0x00000034,0x0000003b,0x0000003a,0x0000003a,
0x0000003a,0x0007000c,0x00000034,0x0000003c,0x00000001,0x0000001a,0x00000037,0x0000003b,
0x00050051,0x00000006,0x0000003e,0x0000003c,0x00000000,0x00050051,0x00000006,0x0000003f,
0x0000003c,0x00000001,0x00050051,0x00000006,0x00000040,0x0000003c,0x00000002,0x00070050,
0x0000002a,0x00000041,0x0000003e,0x0000003f,0x00000040,0x0000003d,0x0003003e,0x0000002c,
0x00000041,0x000200f9,0x00000029,0x000200f8,0x00000042,0x0004003d,0x0000002e,0x00000043,
0x00000030,0x0004003d,0x00000007,0x00000044,0x00000009,0x00070058,0x0000002a,0x00000045,
0x00000043,0x00000044,0x00000002,0x00000025,0x0003003e,0x0000002c,0x00000045,0x000200f9,
0x00000029,0x000200f8,0x00000029,0x000100fd,0x00010038
};

View file

@ -0,0 +1,36 @@
// 8.13.3559
#pragma once
const uint32_t postprocess_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000029,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000c,0x0000001a,
0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,
0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00050005,0x00000009,0x43786574,0x64726f6f,0x00000000,0x00060005,0x0000000c,0x565f6c67,
0x65747265,0x646e4978,0x00007865,0x00060005,0x00000018,0x505f6c67,0x65567265,0x78657472,
0x00000000,0x00060006,0x00000018,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,
0x0000001a,0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000c,
0x0000000b,0x0000002a,0x00050048,0x00000018,0x00000000,0x0000000b,0x00000000,0x00030047,
0x00000018,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,
0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040015,0x0000000a,
0x00000020,0x00000001,0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,
0x0000000c,0x00000001,0x0004002b,0x0000000a,0x0000000e,0x00000001,0x0004002b,0x0000000a,
0x00000010,0x00000002,0x00040017,0x00000017,0x00000006,0x00000004,0x0003001e,0x00000018,
0x00000017,0x00040020,0x00000019,0x00000003,0x00000018,0x0004003b,0x00000019,0x0000001a,
0x00000003,0x0004002b,0x0000000a,0x0000001b,0x00000000,0x0004002b,0x00000006,0x0000001d,
0x40000000,0x0004002b,0x00000006,0x0000001f,0xbf800000,0x0004002b,0x00000006,0x00000022,
0x00000000,0x0004002b,0x00000006,0x00000023,0x3f800000,0x00040020,0x00000027,0x00000003,
0x00000017,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
0x0004003d,0x0000000a,0x0000000d,0x0000000c,0x000500c4,0x0000000a,0x0000000f,0x0000000d,
0x0000000e,0x000500c7,0x0000000a,0x00000011,0x0000000f,0x00000010,0x0004006f,0x00000006,
0x00000012,0x00000011,0x0004003d,0x0000000a,0x00000013,0x0000000c,0x000500c7,0x0000000a,
0x00000014,0x00000013,0x00000010,0x0004006f,0x00000006,0x00000015,0x00000014,0x00050050,
0x00000007,0x00000016,0x00000012,0x00000015,0x0003003e,0x00000009,0x00000016,0x0004003d,
0x00000007,0x0000001c,0x00000009,0x0005008e,0x00000007,0x0000001e,0x0000001c,0x0000001d,
0x00050050,0x00000007,0x00000020,0x0000001f,0x0000001f,0x00050081,0x00000007,0x00000021,
0x0000001e,0x00000020,0x00050051,0x00000006,0x00000024,0x00000021,0x00000000,0x00050051,
0x00000006,0x00000025,0x00000021,0x00000001,0x00070050,0x00000017,0x00000026,0x00000024,
0x00000025,0x00000022,0x00000023,0x00050041,0x00000027,0x00000028,0x0000001a,0x0000001b,
0x0003003e,0x00000028,0x00000026,0x000100fd,0x00010038
};

View file

@ -0,0 +1,46 @@
// 8.13.3559
#pragma once
const uint32_t shadows_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000002b,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000027,
0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,
0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000008,
0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000000a,0x00000000,0x00060005,
0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,0x00060006,0x0000000e,0x00000000,
0x614d7076,0x78697274,0x00000000,0x00030005,0x00000010,0x00006370,0x00070005,0x00000014,
0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,0x00050006,0x00000014,0x00000000,
0x65646f6d,0x0000006c,0x00030005,0x00000016,0x006f6275,0x00050005,0x0000001d,0x65566e69,
0x78657472,0x00000000,0x00040005,0x00000027,0x6f6c6f63,0x00000072,0x00050048,0x00000008,
0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,
0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,
0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,0x00040048,
0x00000014,0x00000000,0x00000005,0x00050048,0x00000014,0x00000000,0x00000023,0x00000000,
0x00050048,0x00000014,0x00000000,0x00000007,0x00000010,0x00030047,0x00000014,0x00000002,
0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,0x00000000,
0x00040047,0x0000001d,0x0000001e,0x00000000,0x00040047,0x00000027,0x0000001e,0x00000000,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,
0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,
0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,
0x0000000d,0x00000007,0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,
0x00000009,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,
0x00000009,0x0000000d,0x0003001e,0x00000014,0x0000000d,0x00040020,0x00000015,0x00000002,
0x00000014,0x0004003b,0x00000015,0x00000016,0x00000002,0x00040020,0x00000017,0x00000002,
0x0000000d,0x00040017,0x0000001b,0x00000006,0x00000003,0x00040020,0x0000001c,0x00000001,
0x0000001b,0x0004003b,0x0000001c,0x0000001d,0x00000001,0x0004002b,0x00000006,0x0000001f,
0x3f800000,0x00040020,0x00000025,0x00000003,0x00000007,0x0004003b,0x00000025,0x00000027,
0x00000003,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,0x00000006,0x00000029,
0x3f000000,0x0007002c,0x00000007,0x0000002a,0x00000028,0x00000028,0x00000028,0x00000029,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,
0x00050041,0x00000017,0x00000018,0x00000016,0x0000000c,0x0004003d,0x0000000d,0x00000019,
0x00000018,0x00050092,0x0000000d,0x0000001a,0x00000013,0x00000019,0x0004003d,0x0000001b,
0x0000001e,0x0000001d,0x00050051,0x00000006,0x00000020,0x0000001e,0x00000000,0x00050051,
0x00000006,0x00000021,0x0000001e,0x00000001,0x00050051,0x00000006,0x00000022,0x0000001e,
0x00000002,0x00070050,0x00000007,0x00000023,0x00000020,0x00000021,0x00000022,0x0000001f,
0x00050091,0x00000007,0x00000024,0x0000001a,0x00000023,0x00050041,0x00000025,0x00000026,
0x0000000a,0x0000000c,0x0003003e,0x00000026,0x00000024,0x0003003e,0x00000027,0x0000002a,
0x000100fd,0x00010038
};

View file

@ -0,0 +1,54 @@
// 8.13.3559
#pragma once
const uint32_t skybox_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000032,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x0000001d,0x00000029,
0x0000002b,0x0000002d,0x00000030,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,
0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,
0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,
0x00060006,0x0000000e,0x00000000,0x614d7076,0x78697274,0x00000000,0x00030005,0x00000010,
0x00006370,0x00070005,0x00000014,0x66696e55,0x426d726f,0x65666675,0x6a624f72,0x00746365,
0x00050006,0x00000014,0x00000000,0x65646f6d,0x0000006c,0x00030005,0x00000016,0x006f6275,
0x00050005,0x0000001d,0x65566e69,0x78657472,0x00000000,0x00050005,0x00000029,0x43786574,
0x64726f6f,0x00000000,0x00050005,0x0000002b,0x65546e69,0x6f6f4378,0x00006472,0x00040005,
0x0000002d,0x6f6c6f63,0x00000072,0x00050005,0x00000030,0x65725461,0x6c6f6873,0x00000064,
0x00050048,0x00000008,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,
0x00040048,0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,
0x00000000,0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,
0x00000002,0x00040048,0x00000014,0x00000000,0x00000005,0x00050048,0x00000014,0x00000000,
0x00000023,0x00000000,0x00050048,0x00000014,0x00000000,0x00000007,0x00000010,0x00030047,
0x00000014,0x00000002,0x00040047,0x00000016,0x00000022,0x00000001,0x00040047,0x00000016,
0x00000021,0x00000000,0x00040047,0x0000001d,0x0000001e,0x00000000,0x00040047,0x00000029,
0x0000001e,0x00000000,0x00040047,0x0000002b,0x0000001e,0x00000001,0x00040047,0x0000002d,
0x0000001e,0x00000001,0x00040047,0x00000030,0x0000001e,0x00000002,0x00020013,0x00000002,
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,0x00000003,
0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,0x00000020,
0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,0x00000007,
0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000009,0x0000000e,
0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,0x00000011,0x00000009,0x0000000d,
0x0003001e,0x00000014,0x0000000d,0x00040020,0x00000015,0x00000002,0x00000014,0x0004003b,
0x00000015,0x00000016,0x00000002,0x00040020,0x00000017,0x00000002,0x0000000d,0x00040017,
0x0000001b,0x00000006,0x00000003,0x00040020,0x0000001c,0x00000001,0x0000001b,0x0004003b,
0x0000001c,0x0000001d,0x00000001,0x0004002b,0x00000006,0x0000001f,0x3f800000,0x00040020,
0x00000025,0x00000003,0x00000007,0x00040017,0x00000027,0x00000006,0x00000002,0x00040020,
0x00000028,0x00000003,0x00000027,0x0004003b,0x00000028,0x00000029,0x00000003,0x00040020,
0x0000002a,0x00000001,0x00000027,0x0004003b,0x0000002a,0x0000002b,0x00000001,0x0004003b,
0x00000025,0x0000002d,0x00000003,0x0007002c,0x00000007,0x0000002e,0x0000001f,0x0000001f,
0x0000001f,0x0000001f,0x00040020,0x0000002f,0x00000003,0x00000006,0x0004003b,0x0000002f,
0x00000030,0x00000003,0x0004002b,0x00000006,0x00000031,0x00000000,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000011,0x00000012,
0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,0x00050041,0x00000017,
0x00000018,0x00000016,0x0000000c,0x0004003d,0x0000000d,0x00000019,0x00000018,0x00050092,
0x0000000d,0x0000001a,0x00000013,0x00000019,0x0004003d,0x0000001b,0x0000001e,0x0000001d,
0x00050051,0x00000006,0x00000020,0x0000001e,0x00000000,0x00050051,0x00000006,0x00000021,
0x0000001e,0x00000001,0x00050051,0x00000006,0x00000022,0x0000001e,0x00000002,0x00070050,
0x00000007,0x00000023,0x00000020,0x00000021,0x00000022,0x0000001f,0x00050091,0x00000007,
0x00000024,0x0000001a,0x00000023,0x00050041,0x00000025,0x00000026,0x0000000a,0x0000000c,
0x0003003e,0x00000026,0x00000024,0x0004003d,0x00000027,0x0000002c,0x0000002b,0x0003003e,
0x00000029,0x0000002c,0x0003003e,0x0000002d,0x0000002e,0x0003003e,0x00000030,0x00000031,
0x000100fd,0x00010038
};

View file

@ -0,0 +1,49 @@
// 8.13.3559
#pragma once
const uint32_t sprite_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x0000002f,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000022,
0x00000024,0x00000026,0x0000002d,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,
0x735f4252,0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,
0x00000000,0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,
0x0000000a,0x00000000,0x00060005,0x0000000e,0x68737550,0x736e6f43,0x746e6174,0x00000000,
0x00060006,0x0000000e,0x00000000,0x4d70766d,0x69727461,0x00000078,0x00050006,0x0000000e,
0x00000001,0x68706c61,0x00000061,0x00030005,0x00000010,0x00006370,0x00050005,0x00000016,
0x65566e69,0x78657472,0x00000000,0x00050005,0x00000022,0x43786574,0x64726f6f,0x00000000,
0x00050005,0x00000024,0x65546e69,0x6f6f4378,0x00006472,0x00040005,0x00000026,0x6f6c6f63,
0x00000072,0x00050005,0x0000002d,0x65725461,0x6c6f6873,0x00000064,0x00050048,0x00000008,
0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,0x0000000e,
0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,0x00050048,
0x0000000e,0x00000000,0x00000007,0x00000010,0x00050048,0x0000000e,0x00000001,0x00000023,
0x00000040,0x00030047,0x0000000e,0x00000002,0x00040047,0x00000016,0x0000001e,0x00000000,
0x00040047,0x00000022,0x0000001e,0x00000000,0x00040047,0x00000024,0x0000001e,0x00000001,
0x00040047,0x00000026,0x0000001e,0x00000001,0x00040047,0x0000002d,0x0000001e,0x00000002,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
0x00040017,0x00000007,0x00000006,0x00000004,0x0003001e,0x00000008,0x00000007,0x00040020,
0x00000009,0x00000003,0x00000008,0x0004003b,0x00000009,0x0000000a,0x00000003,0x00040015,
0x0000000b,0x00000020,0x00000001,0x0004002b,0x0000000b,0x0000000c,0x00000000,0x00040018,
0x0000000d,0x00000007,0x00000004,0x0004001e,0x0000000e,0x0000000d,0x00000006,0x00040020,
0x0000000f,0x00000009,0x0000000e,0x0004003b,0x0000000f,0x00000010,0x00000009,0x00040020,
0x00000011,0x00000009,0x0000000d,0x00040017,0x00000014,0x00000006,0x00000003,0x00040020,
0x00000015,0x00000001,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000001,0x0004002b,
0x00000006,0x00000018,0x3f800000,0x00040020,0x0000001e,0x00000003,0x00000007,0x00040017,
0x00000020,0x00000006,0x00000002,0x00040020,0x00000021,0x00000003,0x00000020,0x0004003b,
0x00000021,0x00000022,0x00000003,0x00040020,0x00000023,0x00000001,0x00000020,0x0004003b,
0x00000023,0x00000024,0x00000001,0x0004003b,0x0000001e,0x00000026,0x00000003,0x0004002b,
0x0000000b,0x00000027,0x00000001,0x00040020,0x00000028,0x00000009,0x00000006,0x00040020,
0x0000002c,0x00000003,0x00000006,0x0004003b,0x0000002c,0x0000002d,0x00000003,0x0004002b,
0x00000006,0x0000002e,0x3d886595,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
0x000200f8,0x00000005,0x00050041,0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,
0x0000000d,0x00000013,0x00000012,0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,
0x00000006,0x00000019,0x00000017,0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,
0x00000001,0x00050051,0x00000006,0x0000001b,0x00000017,0x00000002,0x00070050,0x00000007,
0x0000001c,0x00000019,0x0000001a,0x0000001b,0x00000018,0x00050091,0x00000007,0x0000001d,
0x00000013,0x0000001c,0x00050041,0x0000001e,0x0000001f,0x0000000a,0x0000000c,0x0003003e,
0x0000001f,0x0000001d,0x0004003d,0x00000020,0x00000025,0x00000024,0x0003003e,0x00000022,
0x00000025,0x00050041,0x00000028,0x00000029,0x00000010,0x00000027,0x0004003d,0x00000006,
0x0000002a,0x00000029,0x00070050,0x00000007,0x0000002b,0x00000018,0x00000018,0x00000018,
0x0000002a,0x0003003e,0x00000026,0x0000002b,0x0003003e,0x0000002d,0x0000002e,0x000100fd,
0x00010038
};

View file

@ -0,0 +1,154 @@
// 1011.0.0
#pragma once
const uint32_t world_warp_frag_spv[] = {
0x07230203,0x00010000,0x0008000a,0x000000c1,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000019,0x000000b9,0x00030010,
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,
0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,
0x6e69616d,0x00000000,0x00040005,0x00000009,0x53726373,0x00657a69,0x00060005,0x0000000a,
0x68737550,0x736e6f43,0x746e6174,0x00000000,0x00050006,0x0000000a,0x00000000,0x656d6974,
0x00000000,0x00050006,0x0000000a,0x00000001,0x6c616373,0x00000065,0x00060006,0x0000000a,
0x00000002,0x57726373,0x68746469,0x00000000,0x00060006,0x0000000a,0x00000003,0x48726373,
0x68676965,0x00000074,0x00050006,0x0000000a,0x00000004,0x7366666f,0x00587465,0x00050006,
0x0000000a,0x00000005,0x7366666f,0x00597465,0x00060006,0x0000000a,0x00000006,0x65786970,
0x7a69536c,0x00000065,0x00050006,0x0000000a,0x00000007,0x64666572,0x00586665,0x00050006,
0x0000000a,0x00000008,0x64666572,0x00596665,0x00060006,0x0000000a,0x00000009,0x64666572,
0x69576665,0x00687464,0x00070006,0x0000000a,0x0000000a,0x64666572,0x65486665,0x74686769,
0x00000000,0x00030005,0x0000000c,0x00006370,0x00050005,0x00000016,0x67617266,0x726f6f43,
0x00000064,0x00060005,0x00000019,0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00030005,
0x00000024,0x00007675,0x00040005,0x00000029,0x6e694d78,0x00000000,0x00040005,0x0000002d,
0x78614d78,0x00000000,0x00040005,0x00000034,0x6e694d79,0x00000000,0x00040005,0x00000038,
0x78614d79,0x00000000,0x00030005,0x00000066,0x00007873,0x00030005,0x00000077,0x00007973,
0x00040005,0x00000086,0x69685378,0x00007466,0x00040005,0x00000091,0x69685379,0x00007466,
0x00050005,0x0000009a,0x74736964,0x6974726f,0x00006e6f,0x00060005,0x000000b9,0x67617266,
0x746e656d,0x6f6c6f43,0x00000072,0x00050005,0x000000bd,0x78655473,0x65727574,0x00000000,
0x00050048,0x0000000a,0x00000000,0x00000023,0x00000044,0x00050048,0x0000000a,0x00000001,
0x00000023,0x00000048,0x00050048,0x0000000a,0x00000002,0x00000023,0x0000004c,0x00050048,
0x0000000a,0x00000003,0x00000023,0x00000050,0x00050048,0x0000000a,0x00000004,0x00000023,
0x00000054,0x00050048,0x0000000a,0x00000005,0x00000023,0x00000058,0x00050048,0x0000000a,
0x00000006,0x00000023,0x0000005c,0x00050048,0x0000000a,0x00000007,0x00000023,0x00000060,
0x00050048,0x0000000a,0x00000008,0x00000023,0x00000064,0x00050048,0x0000000a,0x00000009,
0x00000023,0x00000068,0x00050048,0x0000000a,0x0000000a,0x00000023,0x0000006c,0x00030047,
0x0000000a,0x00000002,0x00040047,0x00000019,0x0000000b,0x0000000f,0x00040047,0x000000b9,
0x0000001e,0x00000000,0x00040047,0x000000bd,0x00000022,0x00000000,0x00040047,0x000000bd,
0x00000021,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,
0x00000007,0x00000007,0x000d001e,0x0000000a,0x00000006,0x00000006,0x00000006,0x00000006,
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,
0x0000000b,0x00000009,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000009,0x00040015,
0x0000000d,0x00000020,0x00000001,0x0004002b,0x0000000d,0x0000000e,0x00000002,0x00040020,
0x0000000f,0x00000009,0x00000006,0x0004002b,0x0000000d,0x00000012,0x00000003,0x00040017,
0x00000017,0x00000006,0x00000004,0x00040020,0x00000018,0x00000001,0x00000017,0x0004003b,
0x00000018,0x00000019,0x00000001,0x0004002b,0x0000000d,0x0000001c,0x00000004,0x0004002b,
0x0000000d,0x0000001f,0x00000005,0x00040020,0x00000028,0x00000007,0x00000006,0x0004002b,
0x0000000d,0x0000002a,0x00000007,0x0004002b,0x0000000d,0x00000030,0x00000009,0x0004002b,
0x0000000d,0x00000035,0x00000008,0x0004002b,0x0000000d,0x0000003b,0x0000000a,0x00020014,
0x0000003f,0x0004002b,0x0000000d,0x00000040,0x00000000,0x0004002b,0x00000006,0x00000043,
0x00000000,0x00040015,0x00000047,0x00000020,0x00000000,0x0004002b,0x00000047,0x00000048,
0x00000000,0x0004002b,0x00000047,0x00000057,0x00000001,0x0004002b,0x0000000d,0x00000067,
0x00000001,0x0004002b,0x00000006,0x0000006c,0x40000000,0x0004002b,0x00000006,0x0000008c,
0x40490e56,0x0004002b,0x00000006,0x0000008e,0x41200000,0x0004002b,0x00000006,0x000000a4,
0x3bda3c21,0x0004002b,0x0000000d,0x000000a9,0x00000006,0x0005002c,0x00000007,0x000000b2,
0x00000043,0x00000043,0x0004002b,0x00000006,0x000000b4,0x3f000000,0x0005002c,0x00000007,
0x000000b5,0x000000b4,0x000000b4,0x00040020,0x000000b8,0x00000003,0x00000017,0x0004003b,
0x000000b8,0x000000b9,0x00000003,0x00090019,0x000000ba,0x00000006,0x00000001,0x00000000,
0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x000000bb,0x000000ba,0x00040020,
0x000000bc,0x00000000,0x000000bb,0x0004003b,0x000000bc,0x000000bd,0x00000000,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,
0x00000009,0x00000007,0x0004003b,0x00000008,0x00000016,0x00000007,0x0004003b,0x00000008,
0x00000024,0x00000007,0x0004003b,0x00000028,0x00000029,0x00000007,0x0004003b,0x00000028,
0x0000002d,0x00000007,0x0004003b,0x00000028,0x00000034,0x00000007,0x0004003b,0x00000028,
0x00000038,0x00000007,0x0004003b,0x00000028,0x00000066,0x00000007,0x0004003b,0x00000028,
0x00000077,0x00000007,0x0004003b,0x00000028,0x00000086,0x00000007,0x0004003b,0x00000028,
0x00000091,0x00000007,0x0004003b,0x00000008,0x0000009a,0x00000007,0x00050041,0x0000000f,
0x00000010,0x0000000c,0x0000000e,0x0004003d,0x00000006,0x00000011,0x00000010,0x00050041,
0x0000000f,0x00000013,0x0000000c,0x00000012,0x0004003d,0x00000006,0x00000014,0x00000013,
0x00050050,0x00000007,0x00000015,0x00000011,0x00000014,0x0003003e,0x00000009,0x00000015,
0x0004003d,0x00000017,0x0000001a,0x00000019,0x0007004f,0x00000007,0x0000001b,0x0000001a,
0x0000001a,0x00000000,0x00000001,0x00050041,0x0000000f,0x0000001d,0x0000000c,0x0000001c,
0x0004003d,0x00000006,0x0000001e,0x0000001d,0x00050041,0x0000000f,0x00000020,0x0000000c,
0x0000001f,0x0004003d,0x00000006,0x00000021,0x00000020,0x00050050,0x00000007,0x00000022,
0x0000001e,0x00000021,0x00050083,0x00000007,0x00000023,0x0000001b,0x00000022,0x0003003e,
0x00000016,0x00000023,0x0004003d,0x00000007,0x00000025,0x00000016,0x0004003d,0x00000007,
0x00000026,0x00000009,0x00050088,0x00000007,0x00000027,0x00000025,0x00000026,0x0003003e,
0x00000024,0x00000027,0x00050041,0x0000000f,0x0000002b,0x0000000c,0x0000002a,0x0004003d,
0x00000006,0x0000002c,0x0000002b,0x0003003e,0x00000029,0x0000002c,0x00050041,0x0000000f,
0x0000002e,0x0000000c,0x0000002a,0x0004003d,0x00000006,0x0000002f,0x0000002e,0x00050041,
0x0000000f,0x00000031,0x0000000c,0x00000030,0x0004003d,0x00000006,0x00000032,0x00000031,
0x00050081,0x00000006,0x00000033,0x0000002f,0x00000032,0x0003003e,0x0000002d,0x00000033,
0x00050041,0x0000000f,0x00000036,0x0000000c,0x00000035,0x0004003d,0x00000006,0x00000037,
0x00000036,0x0003003e,0x00000034,0x00000037,0x00050041,0x0000000f,0x00000039,0x0000000c,
0x00000035,0x0004003d,0x00000006,0x0000003a,0x00000039,0x00050041,0x0000000f,0x0000003c,
0x0000000c,0x0000003b,0x0004003d,0x00000006,0x0000003d,0x0000003c,0x00050081,0x00000006,
0x0000003e,0x0000003a,0x0000003d,0x0003003e,0x00000038,0x0000003e,0x00050041,0x0000000f,
0x00000041,0x0000000c,0x00000040,0x0004003d,0x00000006,0x00000042,0x00000041,0x000500ba,
0x0000003f,0x00000044,0x00000042,0x00000043,0x000300f7,0x00000046,0x00000000,0x000400fa,
0x00000044,0x00000045,0x00000046,0x000200f8,0x00000045,0x00050041,0x00000028,0x00000049,
0x00000016,0x00000048,0x0004003d,0x00000006,0x0000004a,0x00000049,0x0004003d,0x00000006,
0x0000004b,0x00000029,0x000500ba,0x0000003f,0x0000004c,0x0000004a,0x0000004b,0x000200f9,
0x00000046,0x000200f8,0x00000046,0x000700f5,0x0000003f,0x0000004d,0x00000044,0x00000005,
0x0000004c,0x00000045,0x000300f7,0x0000004f,0x00000000,0x000400fa,0x0000004d,0x0000004e,
0x0000004f,0x000200f8,0x0000004e,0x00050041,0x00000028,0x00000050,0x00000016,0x00000048,
0x0004003d,0x00000006,0x00000051,0x00000050,0x0004003d,0x00000006,0x00000052,0x0000002d,
0x000500b8,0x0000003f,0x00000053,0x00000051,0x00000052,0x000200f9,0x0000004f,0x000200f8,
0x0000004f,0x000700f5,0x0000003f,0x00000054,0x0000004d,0x00000046,0x00000053,0x0000004e,
0x000300f7,0x00000056,0x00000000,0x000400fa,0x00000054,0x00000055,0x00000056,0x000200f8,
0x00000055,0x00050041,0x00000028,0x00000058,0x00000016,0x00000057,0x0004003d,0x00000006,
0x00000059,0x00000058,0x0004003d,0x00000006,0x0000005a,0x00000034,0x000500ba,0x0000003f,
0x0000005b,0x00000059,0x0000005a,0x000200f9,0x00000056,0x000200f8,0x00000056,0x000700f5,
0x0000003f,0x0000005c,0x00000054,0x0000004f,0x0000005b,0x00000055,0x000300f7,0x0000005e,
0x00000000,0x000400fa,0x0000005c,0x0000005d,0x0000005e,0x000200f8,0x0000005d,0x00050041,
0x00000028,0x0000005f,0x00000016,0x00000057,0x0004003d,0x00000006,0x00000060,0x0000005f,
0x0004003d,0x00000006,0x00000061,0x00000038,0x000500b8,0x0000003f,0x00000062,0x00000060,
0x00000061,0x000200f9,0x0000005e,0x000200f8,0x0000005e,0x000700f5,0x0000003f,0x00000063,
0x0000005c,0x00000056,0x00000062,0x0000005d,0x000300f7,0x00000065,0x00000000,0x000400fa,
0x00000063,0x00000064,0x00000065,0x000200f8,0x00000064,0x00050041,0x0000000f,0x00000068,
0x0000000c,0x00000067,0x0004003d,0x00000006,0x00000069,0x00000068,0x00050041,0x0000000f,
0x0000006a,0x0000000c,0x0000000e,0x0004003d,0x00000006,0x0000006b,0x0000006a,0x00050088,
0x00000006,0x0000006d,0x0000006b,0x0000006c,0x00050041,0x00000028,0x0000006e,0x00000016,
0x00000048,0x0004003d,0x00000006,0x0000006f,0x0000006e,0x00050083,0x00000006,0x00000070,
0x0000006d,0x0000006f,0x0006000c,0x00000006,0x00000071,0x00000001,0x00000004,0x00000070,
0x00050085,0x00000006,0x00000072,0x00000071,0x0000006c,0x00050041,0x0000000f,0x00000073,
0x0000000c,0x0000000e,0x0004003d,0x00000006,0x00000074,0x00000073,0x00050088,0x00000006,
0x00000075,0x00000072,0x00000074,0x00050083,0x00000006,0x00000076,0x00000069,0x00000075,
0x0003003e,0x00000066,0x00000076,0x00050041,0x0000000f,0x00000078,0x0000000c,0x00000067,
0x0004003d,0x00000006,0x00000079,0x00000078,0x00050041,0x0000000f,0x0000007a,0x0000000c,
0x00000012,0x0004003d,0x00000006,0x0000007b,0x0000007a,0x00050088,0x00000006,0x0000007c,
0x0000007b,0x0000006c,0x00050041,0x00000028,0x0000007d,0x00000016,0x00000057,0x0004003d,
0x00000006,0x0000007e,0x0000007d,0x00050083,0x00000006,0x0000007f,0x0000007c,0x0000007e,
0x0006000c,0x00000006,0x00000080,0x00000001,0x00000004,0x0000007f,0x00050085,0x00000006,
0x00000081,0x00000080,0x0000006c,0x00050041,0x0000000f,0x00000082,0x0000000c,0x00000012,
0x0004003d,0x00000006,0x00000083,0x00000082,0x00050088,0x00000006,0x00000084,0x00000081,
0x00000083,0x00050083,0x00000006,0x00000085,0x00000079,0x00000084,0x0003003e,0x00000077,
0x00000085,0x00050041,0x0000000f,0x00000087,0x0000000c,0x00000040,0x0004003d,0x00000006,
0x00000088,0x00000087,0x00050085,0x00000006,0x00000089,0x0000006c,0x00000088,0x00050041,
0x00000028,0x0000008a,0x00000024,0x00000057,0x0004003d,0x00000006,0x0000008b,0x0000008a,
0x00050085,0x00000006,0x0000008d,0x0000008b,0x0000008c,0x00050085,0x00000006,0x0000008f,
0x0000008d,0x0000008e,0x00050081,0x00000006,0x00000090,0x00000089,0x0000008f,0x0003003e,
0x00000086,0x00000090,0x00050041,0x0000000f,0x00000092,0x0000000c,0x00000040,0x0004003d,
0x00000006,0x00000093,0x00000092,0x00050085,0x00000006,0x00000094,0x0000006c,0x00000093,
0x00050041,0x00000028,0x00000095,0x00000024,0x00000048,0x0004003d,0x00000006,0x00000096,
0x00000095,0x00050085,0x00000006,0x00000097,0x00000096,0x0000008c,0x00050085,0x00000006,
0x00000098,0x00000097,0x0000008e,0x00050081,0x00000006,0x00000099,0x00000094,0x00000098,
0x0003003e,0x00000091,0x00000099,0x0004003d,0x00000006,0x0000009b,0x00000086,0x0006000c,
0x00000006,0x0000009c,0x00000001,0x0000000d,0x0000009b,0x0004003d,0x00000006,0x0000009d,
0x00000066,0x00050085,0x00000006,0x0000009e,0x0000009c,0x0000009d,0x0004003d,0x00000006,
0x0000009f,0x00000091,0x0006000c,0x00000006,0x000000a0,0x00000001,0x0000000d,0x0000009f,
0x0004003d,0x00000006,0x000000a1,0x00000077,0x00050085,0x00000006,0x000000a2,0x000000a0,
0x000000a1,0x00050050,0x00000007,0x000000a3,0x0000009e,0x000000a2,0x0005008e,0x00000007,
0x000000a5,0x000000a3,0x000000a4,0x0003003e,0x0000009a,0x000000a5,0x0004003d,0x00000007,
0x000000a6,0x0000009a,0x0004003d,0x00000007,0x000000a7,0x00000024,0x00050081,0x00000007,
0x000000a8,0x000000a7,0x000000a6,0x0003003e,0x00000024,0x000000a8,0x000200f9,0x00000065,
0x000200f8,0x00000065,0x00050041,0x0000000f,0x000000aa,0x0000000c,0x000000a9,0x0004003d,
0x00000006,0x000000ab,0x000000aa,0x0004003d,0x00000007,0x000000ac,0x00000024,0x00050050,
0x00000007,0x000000ad,0x000000ab,0x000000ab,0x00050088,0x00000007,0x000000ae,0x000000ac,
0x000000ad,0x0003003e,0x00000024,0x000000ae,0x0004003d,0x00000007,0x000000af,0x00000024,
0x0004003d,0x00000007,0x000000b0,0x00000009,0x00050085,0x00000007,0x000000b1,0x000000af,
0x000000b0,0x0004003d,0x00000007,0x000000b3,0x00000009,0x00050083,0x00000007,0x000000b6,
0x000000b3,0x000000b5,0x0008000c,0x00000007,0x000000b7,0x00000001,0x0000002b,0x000000b1,
0x000000b2,0x000000b6,0x0003003e,0x00000024,0x000000b7,0x0004003d,0x000000bb,0x000000be,
0x000000bd,0x0004003d,0x00000007,0x000000bf,0x00000024,0x00070058,0x00000017,0x000000c0,
0x000000be,0x000000bf,0x00000002,0x00000043,0x0003003e,0x000000b9,0x000000c0,0x000100fd,
0x00010038
};

View file

@ -0,0 +1,33 @@
// 8.13.3559
#pragma once
const uint32_t world_warp_vert_spv[] = {
0x07230203,0x00010000,0x00080008,0x00000024,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000017,0x0000001b,0x00030003,
0x00000002,0x000001c2,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,0x64616873,
0x6f5f7265,0x63656a62,0x00007374,0x00040005,0x00000004,0x6e69616d,0x00000000,0x00050005,
0x0000000c,0x69736f70,0x6e6f6974,0x00000073,0x00060005,0x00000015,0x505f6c67,0x65567265,
0x78657472,0x00000000,0x00060006,0x00000015,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,
0x00030005,0x00000017,0x00000000,0x00060005,0x0000001b,0x565f6c67,0x65747265,0x646e4978,
0x00007865,0x00050048,0x00000015,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000015,
0x00000002,0x00040047,0x0000001b,0x0000000b,0x0000002a,0x00020013,0x00000002,0x00030021,
0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,
0x00000004,0x00040015,0x00000008,0x00000020,0x00000000,0x0004002b,0x00000008,0x00000009,
0x00000003,0x0004001c,0x0000000a,0x00000007,0x00000009,0x00040020,0x0000000b,0x00000007,
0x0000000a,0x0004002b,0x00000006,0x0000000d,0xbf800000,0x0004002b,0x00000006,0x0000000e,
0x00000000,0x0004002b,0x00000006,0x0000000f,0x3f800000,0x0007002c,0x00000007,0x00000010,
0x0000000d,0x0000000d,0x0000000e,0x0000000f,0x0004002b,0x00000006,0x00000011,0x40400000,
0x0007002c,0x00000007,0x00000012,0x00000011,0x0000000d,0x0000000e,0x0000000f,0x0007002c,
0x00000007,0x00000013,0x0000000d,0x00000011,0x0000000e,0x0000000f,0x0006002c,0x0000000a,
0x00000014,0x00000010,0x00000012,0x00000013,0x0003001e,0x00000015,0x00000007,0x00040020,
0x00000016,0x00000003,0x00000015,0x0004003b,0x00000016,0x00000017,0x00000003,0x00040015,
0x00000018,0x00000020,0x00000001,0x0004002b,0x00000018,0x00000019,0x00000000,0x00040020,
0x0000001a,0x00000001,0x00000018,0x0004003b,0x0000001a,0x0000001b,0x00000001,0x0004002b,
0x00000018,0x0000001d,0x00000003,0x00040020,0x0000001f,0x00000007,0x00000007,0x00040020,
0x00000022,0x00000003,0x00000007,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
0x000200f8,0x00000005,0x0004003b,0x0000000b,0x0000000c,0x00000007,0x0003003e,0x0000000c,
0x00000014,0x0004003d,0x00000018,0x0000001c,0x0000001b,0x0005008b,0x00000018,0x0000001e,
0x0000001c,0x0000001d,0x00050041,0x0000001f,0x00000020,0x0000000c,0x0000001e,0x0004003d,
0x00000007,0x00000021,0x00000020,0x00050041,0x00000022,0x00000023,0x00000017,0x00000019,
0x0003003e,0x00000023,0x00000021,0x000100fd,0x00010038
};

205
src/vk/vk_buffer.c Normal file
View file

@ -0,0 +1,205 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
// internal helper
static void
copyBuffer(const VkBuffer * src, VkBuffer * dst, VkDeviceSize size)
{
VkCommandBuffer commandBuffer = QVk_CreateCommandBuffer(&vk_transferCommandPool,
VK_COMMAND_BUFFER_LEVEL_PRIMARY);
QVk_BeginCommand(&commandBuffer);
VkBufferCopy copyRegion = {
.srcOffset = 0,
.dstOffset = 0,
.size = size
};
vkCmdCopyBuffer(commandBuffer, *src, *dst, 1, &copyRegion);
QVk_SubmitCommand(&commandBuffer, &vk_device.transferQueue);
vkFreeCommandBuffers(vk_device.logical, vk_transferCommandPool, 1,
&commandBuffer);
}
// internal helper
static void
createStagedBuffer(const void *data, VkDeviceSize size, qvkbuffer_t * dstBuffer,
qvkbufferopts_t bufferOpts)
{
qvkstagingbuffer_t *stgBuffer;
stgBuffer = (qvkstagingbuffer_t *) malloc(sizeof(qvkstagingbuffer_t));
VK_VERIFY(QVk_CreateStagingBuffer(size, stgBuffer,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
VK_MEMORY_PROPERTY_HOST_CACHED_BIT));
if (data)
{
void *dst;
// staging buffers in vkQuake2 are required to be host coherent,
// so no flushing/invalidation is involved
dst = buffer_map(&stgBuffer->resource);
memcpy(dst, data, (size_t) size);
buffer_unmap(&stgBuffer->resource);
}
VK_VERIFY(QVk_CreateBuffer(size, dstBuffer, bufferOpts));
copyBuffer(&stgBuffer->resource.buffer, &dstBuffer->resource.buffer, size);
QVk_FreeStagingBuffer(stgBuffer);
free(stgBuffer);
}
VkResult
QVk_CreateBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer,
const qvkbufferopts_t options)
{
VkBufferCreateInfo bcInfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.size = size,
.usage = options.usage,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = NULL,
};
// separate transfer queue makes sense only if the buffer is targetted
// for being transfered to GPU, so ignore it if it's CPU-only
uint32_t queueFamilies[] = {
(uint32_t)vk_device.gfxFamilyIndex,
(uint32_t)vk_device.transferFamilyIndex
};
if (vk_device.gfxFamilyIndex != vk_device.transferFamilyIndex)
{
bcInfo.sharingMode = VK_SHARING_MODE_CONCURRENT;
bcInfo.queueFamilyIndexCount = 2;
bcInfo.pQueueFamilyIndices = queueFamilies;
}
dstBuffer->currentOffset = 0;
return buffer_create(&dstBuffer->resource, bcInfo,
options.reqMemFlags, options.prefMemFlags);
}
void
QVk_FreeBuffer(qvkbuffer_t *buffer)
{
buffer_destroy(&buffer->resource);
buffer->currentOffset = 0;
}
void
QVk_FreeStagingBuffer(qvkstagingbuffer_t *buffer)
{
buffer_destroy(&buffer->resource);
buffer->currentOffset = 0;
}
VkResult
QVk_CreateStagingBuffer(VkDeviceSize size, qvkstagingbuffer_t *dstBuffer,
VkMemoryPropertyFlags reqMemFlags,
VkMemoryPropertyFlags prefMemFlags)
{
VkBufferCreateInfo bcInfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.size = ROUNDUP(size, 1024),
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = NULL,
};
reqMemFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
dstBuffer->currentOffset = 0;
return buffer_create(&dstBuffer->resource, bcInfo, reqMemFlags,
prefMemFlags);
}
VkResult
QVk_CreateUniformBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer,
VkMemoryPropertyFlags reqMemFlags,
VkMemoryPropertyFlags prefMemFlags)
{
qvkbufferopts_t dstOpts = {
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
.reqMemFlags = reqMemFlags,
.prefMemFlags = prefMemFlags,
};
dstOpts.reqMemFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
if((vk_device.properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) ||
(dstOpts.prefMemFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
{
dstOpts.prefMemFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
return QVk_CreateBuffer(size, dstBuffer, dstOpts);
}
void
QVk_CreateVertexBuffer(const void *data, VkDeviceSize size,
qvkbuffer_t *dstBuffer,
VkMemoryPropertyFlags reqMemFlags,
VkMemoryPropertyFlags prefMemFlags)
{
qvkbufferopts_t dstOpts = {
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT |
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
.reqMemFlags = reqMemFlags,
.prefMemFlags = prefMemFlags,
};
if((vk_device.properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) ||
(dstOpts.prefMemFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
{
dstOpts.prefMemFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
createStagedBuffer(data, size, dstBuffer, dstOpts);
}
void
QVk_CreateIndexBuffer(const void *data, VkDeviceSize size,
qvkbuffer_t *dstBuffer,
VkMemoryPropertyFlags reqMemFlags,
VkMemoryPropertyFlags prefMemFlags)
{
qvkbufferopts_t dstOpts = {
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
.reqMemFlags = reqMemFlags,
.prefMemFlags = prefMemFlags,
};
if((vk_device.properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) ||
(dstOpts.prefMemFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
{
dstOpts.prefMemFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
createStagedBuffer(data, size, dstBuffer, dstOpts);
}

91
src/vk/vk_cmd.c Normal file
View file

@ -0,0 +1,91 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
VkResult QVk_BeginCommand(const VkCommandBuffer *commandBuffer)
{
VkCommandBufferBeginInfo cmdInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.pNext = NULL,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
.pInheritanceInfo = NULL
};
return vkBeginCommandBuffer(*commandBuffer, &cmdInfo);
}
void QVk_SubmitCommand(const VkCommandBuffer *commandBuffer, const VkQueue *queue)
{
VK_VERIFY(vkEndCommandBuffer(*commandBuffer));
VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.pNext = NULL,
.waitSemaphoreCount = 0,
.pWaitSemaphores = NULL,
.pWaitDstStageMask = NULL,
.commandBufferCount = 1,
.pCommandBuffers = commandBuffer,
.signalSemaphoreCount = 0,
.pSignalSemaphores = NULL
};
VkFenceCreateInfo fCreateInfo = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = NULL,
.flags = 0
};
VkFence queueFence;
VK_VERIFY(vkCreateFence(vk_device.logical, &fCreateInfo, NULL, &queueFence));
VK_VERIFY(vkQueueSubmit(*queue, 1, &submitInfo, queueFence));
VK_VERIFY(vkWaitForFences(vk_device.logical, 1, &queueFence, VK_TRUE, UINT64_MAX));
vkDestroyFence(vk_device.logical, queueFence, NULL);
}
VkResult QVk_CreateCommandPool(VkCommandPool *commandPool, uint32_t queueFamilyIndex)
{
VkCommandPoolCreateInfo cpCreateInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.pNext = NULL,
// allow the command pool to be explicitly reset without reallocating it manually during recording each frame
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,
.queueFamilyIndex = queueFamilyIndex
};
return vkCreateCommandPool(vk_device.logical, &cpCreateInfo, NULL, commandPool);
}
VkCommandBuffer QVk_CreateCommandBuffer(const VkCommandPool *commandPool, VkCommandBufferLevel level)
{
VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
VkCommandBufferAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.pNext = NULL,
.commandPool = *commandPool,
.level = level,
.commandBufferCount = 1
};
VK_VERIFY(vkAllocateCommandBuffers(vk_device.logical, &allocInfo, &commandBuffer));
return commandBuffer;
}

2644
src/vk/vk_common.c Normal file

File diff suppressed because it is too large Load diff

365
src/vk/vk_device.c Normal file
View file

@ -0,0 +1,365 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
// internal helper
static qboolean deviceExtensionsSupported(const VkPhysicalDevice *physicalDevice, const char* extensionName)
{
uint32_t availableExtCount = 0;
qboolean vk_extension_available = false;
VK_VERIFY(vkEnumerateDeviceExtensionProperties(*physicalDevice, NULL, &availableExtCount, NULL));
if (availableExtCount > 0)
{
VkExtensionProperties *extensions = (VkExtensionProperties *)malloc(availableExtCount * sizeof(VkExtensionProperties));
VK_VERIFY(vkEnumerateDeviceExtensionProperties(*physicalDevice, NULL, &availableExtCount, extensions));
for (uint32_t i = 0; i < availableExtCount; ++i)
{
vk_extension_available |= strcmp(extensions[i].extensionName, extensionName) == 0;
}
free(extensions);
}
// lack of extension disqualifies the device
return vk_extension_available;
}
// internal helper
static void getBestPhysicalDevice(const VkPhysicalDevice *devices, int preferredIdx, int count)
{
VkPhysicalDeviceProperties deviceProperties;
VkPhysicalDeviceFeatures deviceFeatures;
uint32_t queueFamilyCount = 0;
for (int i = 0; i < count; ++i)
{
vkGetPhysicalDeviceProperties(devices[i], &deviceProperties);
vkGetPhysicalDeviceFeatures(devices[i], &deviceFeatures);
vkGetPhysicalDeviceQueueFamilyProperties(devices[i], &queueFamilyCount, NULL);
if (queueFamilyCount == 0)
continue;
// prefer discrete GPU but if it's the only one available then don't be picky
// also - if the user specifies a preferred device, select it
qboolean bestProperties = deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
if (preferredIdx == i || (bestProperties && preferredIdx < 0) || count == 1)
{
uint32_t formatCount = 0;
uint32_t presentModesCount = 0;
// check if requested device extensions are present
qboolean extSupported = deviceExtensionsSupported(&devices[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME);
// no required extensions? try next device
if (!extSupported)
continue;
// if extensions are fine, query surface formats and present modes to see if the device can be used
VK_VERIFY(vkGetPhysicalDeviceSurfaceFormatsKHR(devices[i], vk_surface, &formatCount, NULL));
VK_VERIFY(vkGetPhysicalDeviceSurfacePresentModesKHR(devices[i], vk_surface, &presentModesCount, NULL));
if (formatCount == 0 || presentModesCount == 0)
continue;
VkQueueFamilyProperties *queueFamilies = (VkQueueFamilyProperties *)malloc(queueFamilyCount * sizeof(VkQueueFamilyProperties));
vkGetPhysicalDeviceQueueFamilyProperties(devices[i], &queueFamilyCount, queueFamilies);
// secondary check - device is OK if there's at least on queue with VK_QUEUE_GRAPHICS_BIT set
for (uint32_t j = 0; j < queueFamilyCount; ++j)
{
// check if this queue family has support for presentation
VkBool32 presentSupported;
VK_VERIFY(vkGetPhysicalDeviceSurfaceSupportKHR(devices[i], j, vk_surface, &presentSupported));
// good optimization would be to find a queue where presentIdx == gfxQueueIdx for less overhead
if (vk_device.presentFamilyIndex < 0 && queueFamilies[j].queueCount > 0 && presentSupported)
{
vk_device.presentFamilyIndex = j;
}
if (vk_device.gfxFamilyIndex < 0 && queueFamilies[j].queueCount > 0 && (queueFamilies[j].queueFlags & VK_QUEUE_GRAPHICS_BIT))
{
vk_device.gfxFamilyIndex = j;
}
if (vk_device.transferFamilyIndex < 0 && queueFamilies[j].queueCount > 0 && !(queueFamilies[j].queueFlags & VK_QUEUE_GRAPHICS_BIT) && (queueFamilies[j].queueFlags & VK_QUEUE_TRANSFER_BIT))
{
vk_device.transferFamilyIndex = j;
}
}
free(queueFamilies);
// accept only device that has support for presentation and drawing
if (vk_device.presentFamilyIndex >= 0 && vk_device.gfxFamilyIndex >= 0)
{
if (vk_device.transferFamilyIndex < 0)
{
vk_device.transferFamilyIndex = vk_device.gfxFamilyIndex;
}
vk_device.physical = devices[i];
vk_device.properties = deviceProperties;
vk_device.features = deviceFeatures;
return;
}
}
}
}
// internal helper
static qboolean selectPhysicalDevice(int preferredDeviceIdx)
{
uint32_t physicalDeviceCount = 0;
VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &physicalDeviceCount, NULL));
if (physicalDeviceCount == 0)
{
R_Printf(PRINT_ALL, "No Vulkan-capable devices found!\n");
return false;
}
R_Printf(PRINT_ALL, "...found %d Vulkan-capable device(s)\n", physicalDeviceCount);
VkPhysicalDevice *physicalDevices = (VkPhysicalDevice *)malloc(physicalDeviceCount * sizeof(VkPhysicalDevice));
VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &physicalDeviceCount, physicalDevices));
getBestPhysicalDevice(physicalDevices, preferredDeviceIdx < physicalDeviceCount ? preferredDeviceIdx : -1, physicalDeviceCount);
free(physicalDevices);
if (vk_device.physical == VK_NULL_HANDLE)
{
R_Printf(PRINT_ALL, "Could not find a suitable physical device!\n");
return false;
}
if (!vk_device.features.samplerAnisotropy)
{
R_Printf(PRINT_ALL, "...anisotropy filtering is unsupported.\n");
}
return true;
}
// internal helper
static VkResult createLogicalDevice()
{
// at least one queue (graphics and present combined) has to be present
uint32_t numQueues = 1;
float queuePriority = 1.f;
VkDeviceQueueCreateInfo queueCreateInfo[3];
queueCreateInfo[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo[0].pNext = NULL;
queueCreateInfo[0].flags = 0;
queueCreateInfo[0].queueFamilyIndex = vk_device.gfxFamilyIndex;
queueCreateInfo[0].queueCount = 1;
queueCreateInfo[0].pQueuePriorities = &queuePriority;
queueCreateInfo[1].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo[1].pNext = NULL;
queueCreateInfo[1].flags = 0;
queueCreateInfo[1].queueFamilyIndex = 0;
queueCreateInfo[1].queueCount = 1;
queueCreateInfo[1].pQueuePriorities = &queuePriority;
queueCreateInfo[2].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo[2].pNext = NULL;
queueCreateInfo[2].flags = 0;
queueCreateInfo[2].queueFamilyIndex = 0;
queueCreateInfo[2].queueCount = 1;
queueCreateInfo[2].pQueuePriorities = &queuePriority;
VkPhysicalDeviceFeatures wantedDeviceFeatures = {
.samplerAnisotropy = vk_device.features.samplerAnisotropy,
.fillModeNonSolid = vk_device.features.fillModeNonSolid, // for wireframe rendering
.sampleRateShading = vk_device.features.sampleRateShading, // for sample shading
};
// a graphics and present queue are different - two queues have to be created
if (vk_device.gfxFamilyIndex != vk_device.presentFamilyIndex)
{
queueCreateInfo[numQueues++].queueFamilyIndex = vk_device.presentFamilyIndex;
}
// a separate transfer queue exists that's different from present and graphics queue?
if (vk_device.transferFamilyIndex != vk_device.gfxFamilyIndex && vk_device.transferFamilyIndex != vk_device.presentFamilyIndex)
{
queueCreateInfo[numQueues++].queueFamilyIndex = vk_device.transferFamilyIndex;
}
const char *deviceExtensions[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
VkDeviceCreateInfo deviceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.pEnabledFeatures = &wantedDeviceFeatures,
.ppEnabledExtensionNames = deviceExtensions,
.enabledExtensionCount = 1,
.enabledLayerCount = 0,
.ppEnabledLayerNames = NULL,
.queueCreateInfoCount = numQueues,
.pQueueCreateInfos = queueCreateInfo
};
#if VK_HEADER_VERSION > 101
const char *validationLayers[] = { "VK_LAYER_KHRONOS_validation" };
#else
const char *validationLayers[] = { "VK_LAYER_LUNARG_standard_validation" };
#endif
if (vk_validation->value)
{
deviceCreateInfo.enabledLayerCount = sizeof(validationLayers)/sizeof(validationLayers[0]);
deviceCreateInfo.ppEnabledLayerNames = validationLayers;
}
return vkCreateDevice(vk_device.physical, &deviceCreateInfo, NULL, &vk_device.logical);
}
// internal helper
static const char *deviceTypeString(VkPhysicalDeviceType dType)
{
#define DEVTYPESTR(r) case VK_ ##r: return "VK_"#r
switch (dType)
{
DEVTYPESTR(PHYSICAL_DEVICE_TYPE_OTHER);
DEVTYPESTR(PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);
DEVTYPESTR(PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);
DEVTYPESTR(PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);
DEVTYPESTR(PHYSICAL_DEVICE_TYPE_CPU);
default: return "<unknown>";
}
#undef DEVTYPESTR
return "UNKNOWN DEVICE";
}
// internal helper
static const char *vendorNameString(uint32_t vendorId)
{
switch (vendorId)
{
case 0x1002: return "AMD";
case 0x1010: return "ImgTec";
case 0x10DE: return "NVIDIA";
case 0x13B5: return "ARM";
case 0x5143: return "Qualcomm";
case 0x8086: return "Intel";
default: return "unknown";
}
}
qboolean QVk_CreateDevice(int preferredDeviceIdx)
{
if (!selectPhysicalDevice(preferredDeviceIdx))
return false;
vk_config.vendor_name = vendorNameString(vk_device.properties.vendorID);
vk_config.device_type = deviceTypeString(vk_device.properties.deviceType);
VkResult res = createLogicalDevice();
if (res != VK_SUCCESS)
{
R_Printf(PRINT_ALL, "Could not create Vulkan logical device: %s\n", QVk_GetError(res));
return false;
}
vkGetDeviceQueue(vk_device.logical, vk_device.gfxFamilyIndex, 0, &vk_device.gfxQueue);
vkGetDeviceQueue(vk_device.logical, vk_device.presentFamilyIndex, 0, &vk_device.presentQueue);
vkGetDeviceQueue(vk_device.logical, vk_device.transferFamilyIndex, 0, &vk_device.transferQueue);
vkGetPhysicalDeviceMemoryProperties(vk_device.physical, &vk_device.mem_properties);
// init our memory management
vulkan_memory_init();
return true;
}
// debug label related functions
void QVk_DebugSetObjectName(uint64_t obj, VkObjectType objType, const char *objName)
{
if (qvkSetDebugUtilsObjectNameEXT)
{
VkDebugUtilsObjectNameInfoEXT oNameInf = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = NULL,
.objectType = objType,
.objectHandle = obj,
.pObjectName = objName
};
qvkSetDebugUtilsObjectNameEXT(vk_device.logical, &oNameInf);
}
}
void QVk_DebugSetObjectTag(uint64_t obj, VkObjectType objType, uint64_t tagName,
size_t tagSize, const void *tagData)
{
if (qvkSetDebugUtilsObjectTagEXT)
{
VkDebugUtilsObjectTagInfoEXT oTagInf = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT,
.pNext = NULL,
.objectType = objType,
.objectHandle = obj,
.tagName = tagName,
.tagSize = tagSize,
.pTag = tagData
};
qvkSetDebugUtilsObjectTagEXT(vk_device.logical, &oTagInf);
}
}
void QVk_DebugLabelBegin(const VkCommandBuffer *cmdBuffer, const char *labelName, const float r, const float g, const float b)
{
if (qvkCmdBeginDebugUtilsLabelEXT)
{
VkDebugUtilsLabelEXT labelInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
.pNext = NULL,
.pLabelName = labelName,
.color = { r, g, b, 1.f }
};
qvkCmdBeginDebugUtilsLabelEXT(*cmdBuffer, &labelInfo);
}
}
void QVk_DebugLabelEnd(const VkCommandBuffer *cmdBuffer)
{
if (qvkCmdEndDebugUtilsLabelEXT)
{
qvkCmdEndDebugUtilsLabelEXT(*cmdBuffer);
}
}
void QVk_DebugLabelInsert(const VkCommandBuffer *cmdBuffer, const char *labelName, const float r, const float g, const float b)
{
if (qvkInsertDebugUtilsLabelEXT)
{
VkDebugUtilsLabelEXT labelInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
.pNext = NULL,
.pLabelName = labelName,
.color = { r, g, b, 1.f }
};
qvkInsertDebugUtilsLabelEXT(*cmdBuffer, &labelInfo);
}
}

371
src/vk/vk_draw.c Normal file
View file

@ -0,0 +1,371 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_draw.c
#include "header/local.h"
static image_t *draw_chars;
/*
===============
Draw_InitLocal
===============
*/
void Draw_InitLocal (void)
{
draw_chars = Vk_FindImage("pics/conchars.pcx", it_pic);
if (!draw_chars)
{
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx", __func__);
}
}
/*
================
RE_Draw_CharScaled
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.
================
*/
void RE_Draw_CharScaled (int x, int y, int num, float scale)
{
int row, col;
float frow, fcol, size;
if (!vk_frameStarted)
return;
num &= 255;
if ((num & 127) == 32)
return; // space
if (y <= -8)
return; // totally off screen
row = num >> 4;
col = num & 15;
frow = row * 0.0625;
fcol = col * 0.0625;
size = 0.0625;
float imgTransform[] = { (float)x / vid.width, (float)y / vid.height,
8.f * scale / vid.width, 8.f * scale / vid.height,
fcol, frow, size, size };
QVk_DrawTexRect(imgTransform, sizeof(imgTransform), &draw_chars->vk_texture);
}
/*
=============
RE_Draw_FindPic
=============
*/
image_t *RE_Draw_FindPic (char *name)
{
image_t *vk;
if (name[0] != '/' && name[0] != '\\')
{
char fullname[MAX_QPATH];
Com_sprintf(fullname, sizeof(fullname), "pics/%s.pcx", name);
vk = Vk_FindImage(fullname, it_pic);
}
else
vk = Vk_FindImage(name + 1, it_pic);
return vk;
}
/*
=============
RE_Draw_GetPicSize
=============
*/
void RE_Draw_GetPicSize (int *w, int *h, char *name)
{
image_t *vk;
vk = RE_Draw_FindPic(name);
if (!vk)
{
*w = *h = -1;
return;
}
*w = vk->width;
*h = vk->height;
}
/*
=============
RE_Draw_StretchPic
=============
*/
void RE_Draw_StretchPic (int x, int y, int w, int h, char *name)
{
image_t *vk;
if (!vk_frameStarted)
return;
vk = RE_Draw_FindPic(name);
if (!vk)
{
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, name);
return;
}
float imgTransform[] = { (float)x / vid.width, (float)y / vid.height,
(float)w / vid.width, (float)h / vid.height,
0, 0, 1, 1 };
QVk_DrawTexRect(imgTransform, sizeof(imgTransform), &vk->vk_texture);
}
/*
=============
RE_Draw_PicScaled
=============
*/
void RE_Draw_PicScaled (int x, int y, char *name, float scale)
{
image_t *vk;
vk = RE_Draw_FindPic(name);
if (!vk)
{
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, name);
return;
}
RE_Draw_StretchPic(x, y, vk->width*scale, vk->height*scale, name);
}
/*
=============
RE_Draw_TileClear
This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void RE_Draw_TileClear (int x, int y, int w, int h, char *name)
{
image_t *image;
if (!vk_frameStarted)
return;
image = RE_Draw_FindPic(name);
if (!image)
{
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, name);
return;
}
// Change viewport and scissor to draw in the top left corner as the world view.
VkViewport tileViewport = vk_viewport;
VkRect2D tileScissor = vk_scissor;
tileViewport.x = 0.f;
tileViewport.y = 0.f;
tileScissor.offset.x = 0;
tileScissor.offset.y = 0;
vkCmdSetViewport(vk_activeCmdbuffer, 0u, 1u, &tileViewport);
vkCmdSetScissor(vk_activeCmdbuffer, 0u, 1u, &tileScissor);
const float divisor = (vk_pixel_size->value < 1.0f ? 1.0f : vk_pixel_size->value);
float imgTransform[] = { (float)x / (vid.width * divisor), (float)y / (vid.height * divisor),
(float)w / (vid.width * divisor), (float)h / (vid.height * divisor),
(float)x / (64.0 * divisor), (float)y / (64.0 * divisor),
(float)w / (64.0 * divisor), (float)h / (64.0 * divisor) };
QVk_DrawTexRect(imgTransform, sizeof(imgTransform), &image->vk_texture);
// Restore viewport and scissor.
vkCmdSetViewport(vk_activeCmdbuffer, 0u, 1u, &vk_viewport);
vkCmdSetScissor(vk_activeCmdbuffer, 0u, 1u, &vk_scissor);
}
/*
=============
RE_Draw_Fill
Fills a box of pixels with a single color
=============
*/
void RE_Draw_Fill (int x, int y, int w, int h, int c)
{
union
{
unsigned c;
byte v[4];
} color;
if (!vk_frameStarted)
return;
if ((unsigned)c > 255)
ri.Sys_Error(ERR_FATAL, "%s: bad color", __func__);
color.c = d_8to24table[c];
float imgTransform[] = { (float)x / vid.width, (float)y / vid.height,
(float)w / vid.width, (float)h / vid.height,
color.v[0] / 255.f, color.v[1] / 255.f, color.v[2] / 255.f, 1.f };
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
}
//=============================================================================
/*
================
RE_Draw_FadeScreen
================
*/
void RE_Draw_FadeScreen (void)
{
float imgTransform[] = { 0.f, 0.f, vid.width, vid.height, 0.f, 0.f, 0.f, .8f };
if (!vk_frameStarted)
return;
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
}
//====================================================================
/*
=============
RE_Draw_StretchRaw
=============
*/
extern unsigned r_rawpalette[256];
extern qvktexture_t vk_rawTexture;
static int scaled_size = 512;
void RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data)
{
int i, j;
int hscale, vscale;
unsigned *dest;
byte *source;
byte *image_scaled;
unsigned *raw_image32;
if (!vk_frameStarted)
return;
if (vk_retexturing->value)
{
// triple scaling
if (cols < (vid.width / 3) || rows < (vid.height / 3))
{
image_scaled = malloc(cols * rows * 9);
scale3x(data, image_scaled, cols, rows);
cols = cols * 3;
rows = rows * 3;
}
else
// double scaling
{
image_scaled = malloc(cols * rows * 4);
scale2x(data, image_scaled, cols, rows);
cols = cols * 2;
rows = rows * 2;
}
}
else
{
image_scaled = data;
}
if (vk_rawTexture.resource.image == VK_NULL_HANDLE)
{
// get power of two image size,
// could be updated only size only after recreate texture
for (scaled_size = 512; scaled_size < cols && scaled_size < rows; scaled_size <<= 1)
;
}
raw_image32 = malloc(scaled_size * scaled_size * sizeof(unsigned));
hscale = cols * 0x10000 / scaled_size;
vscale = rows * 0x10000 / scaled_size;
source = image_scaled;
dest = raw_image32;
for (i = 0; i < scaled_size; i++)
{
for (j = 0; j < scaled_size; j++)
{
*dest = r_rawpalette[*(source + ((j * hscale) >> 16))];
dest ++;
}
source = image_scaled + (((i * vscale) >> 16) * cols);
}
if (vk_retexturing->value)
{
free(image_scaled);
SmoothColorImage(raw_image32, scaled_size * scaled_size, scaled_size >> 7);
}
if (vk_rawTexture.resource.image != VK_NULL_HANDLE)
{
QVk_UpdateTextureData(&vk_rawTexture, (unsigned char*)raw_image32, 0, 0, scaled_size, scaled_size);
}
else
{
QVVKTEXTURE_CLEAR(vk_rawTexture);
QVk_CreateTexture(&vk_rawTexture, (unsigned char*)raw_image32, scaled_size, scaled_size,
vk_current_sampler, false);
QVk_DebugSetObjectName((uint64_t)vk_rawTexture.resource.image,
VK_OBJECT_TYPE_IMAGE, "Image: raw texture");
QVk_DebugSetObjectName((uint64_t)vk_rawTexture.imageView,
VK_OBJECT_TYPE_IMAGE_VIEW, "Image View: raw texture");
QVk_DebugSetObjectName((uint64_t)vk_rawTexture.descriptorSet,
VK_OBJECT_TYPE_DESCRIPTOR_SET, "Descriptor Set: raw texture");
QVk_DebugSetObjectName((uint64_t)vk_rawTexture.resource.memory,
VK_OBJECT_TYPE_DEVICE_MEMORY, "Memory: raw texture");
}
free(raw_image32);
float imgTransform[] = { (float)x / vid.width, (float)y / vid.height,
(float)w / vid.width, (float)h / vid.height,
0.f, 0.f, 1.f, 1.0f };
QVk_DrawTexRect(imgTransform, sizeof(imgTransform), &vk_rawTexture);
}

1584
src/vk/vk_image.c Normal file

File diff suppressed because it is too large Load diff

626
src/vk/vk_light.c Normal file
View file

@ -0,0 +1,626 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_light.c
#include "header/local.h"
static int r_dlightframecount;
#define DLIGHT_CUTOFF 64
/*
=============================================================================
DYNAMIC LIGHTS BLEND RENDERING
=============================================================================
*/
void R_RenderDlight (dlight_t *light)
{
int i, j;
float rad;
rad = light->intensity * 0.35;
struct {
vec3_t verts;
float color[3];
} lightVerts[18];
for (i = 0; i < 3; i++)
lightVerts[0].verts[i] = light->origin[i] - vpn[i] * rad;
lightVerts[0].color[0] = light->color[0] * 0.2;
lightVerts[0].color[1] = light->color[1] * 0.2;
lightVerts[0].color[2] = light->color[2] * 0.2;
for (i = 16; i >= 0; i--)
{
float a;
a = i / 16.0 * M_PI * 2;
for (j = 0; j < 3; j++)
{
lightVerts[i+1].verts[j] = light->origin[j] + vright[j] * cos(a)*rad
+ vup[j] * sin(a)*rad;
lightVerts[i+1].color[j] = 0.f;
}
}
QVk_BindPipeline(&vk_drawDLightPipeline);
VkBuffer vbo;
VkDeviceSize vboOffset;
uint32_t uboOffset;
VkDescriptorSet uboDescriptorSet;
uint8_t *vertData = QVk_GetVertexBuffer(sizeof(lightVerts), &vbo, &vboOffset);
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(r_viewproj_matrix), &uboOffset, &uboDescriptorSet);
memcpy(vertData, lightVerts, sizeof(lightVerts));
memcpy(uboData, r_viewproj_matrix, sizeof(r_viewproj_matrix));
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawDLightPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo(48), 0, VK_INDEX_TYPE_UINT16);
vkCmdDrawIndexed(vk_activeCmdbuffer, 48, 1, 0, 0, 0);
}
/*
=============
R_RenderDlights
=============
*/
void R_RenderDlights (void)
{
int i;
dlight_t *l;
if (!vk_flashblend->value)
return;
r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
l = r_newrefdef.dlights;
for (i=0 ; i<r_newrefdef.num_dlights ; i++, l++)
R_RenderDlight (l);
}
/*
=============================================================================
DYNAMIC LIGHTS
=============================================================================
*/
/*
=============
R_MarkLights
=============
*/
void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
{
cplane_t *splitplane;
float dist;
msurface_t *surf;
int i;
if (node->contents != -1)
return;
splitplane = node->plane;
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
if (dist > light->intensity-DLIGHT_CUTOFF)
{
R_MarkLights (light, bit, node->children[0]);
return;
}
if (dist < -light->intensity+DLIGHT_CUTOFF)
{
R_MarkLights (light, bit, node->children[1]);
return;
}
// mark the polygons
surf = r_worldmodel->surfaces + node->firstsurface;
for (i=0 ; i<node->numsurfaces ; i++, surf++)
{
if (surf->dlightframe != r_dlightframecount)
{
surf->dlightbits = 0;
surf->dlightframe = r_dlightframecount;
}
surf->dlightbits |= bit;
}
R_MarkLights (light, bit, node->children[0]);
R_MarkLights (light, bit, node->children[1]);
}
/*
=============
R_PushDlights
=============
*/
void R_PushDlights (void)
{
int i;
dlight_t *l;
if (vk_flashblend->value)
return;
r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
l = r_newrefdef.dlights;
for (i=0 ; i<r_newrefdef.num_dlights ; i++, l++)
R_MarkLights ( l, 1<<i, r_worldmodel->nodes );
}
/*
=============================================================================
LIGHT SAMPLING
=============================================================================
*/
vec3_t pointcolor;
cplane_t *lightplane; // used as shadow plane
vec3_t lightspot;
static int RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
{
float front, back, frac;
int side;
cplane_t *plane;
vec3_t mid;
msurface_t *surf;
int s, t, ds, dt;
int i;
mtexinfo_t *tex;
byte *lightmap;
int maps;
int r;
if (node->contents != -1)
return -1; // didn't hit anything
// calculate mid point
// FIXME: optimize for axial
plane = node->plane;
front = DotProduct (start, plane->normal) - plane->dist;
back = DotProduct (end, plane->normal) - plane->dist;
side = front < 0;
if ( (back < 0) == side)
return RecursiveLightPoint (node->children[side], start, end);
frac = front / (front-back);
mid[0] = start[0] + (end[0] - start[0])*frac;
mid[1] = start[1] + (end[1] - start[1])*frac;
mid[2] = start[2] + (end[2] - start[2])*frac;
// go down front side
r = RecursiveLightPoint (node->children[side], start, mid);
if (r >= 0)
return r; // hit something
// check for impact on this node
VectorCopy (mid, lightspot);
lightplane = plane;
surf = r_worldmodel->surfaces + node->firstsurface;
for (i=0 ; i<node->numsurfaces ; i++, surf++)
{
vec3_t scale;
if (surf->flags&(SURF_DRAWTURB|SURF_DRAWSKY))
continue; // no lightmaps
tex = surf->texinfo;
s = DotProduct (mid, tex->vecs[0]) + tex->vecs[0][3];
t = DotProduct (mid, tex->vecs[1]) + tex->vecs[1][3];;
if (s < surf->texturemins[0] ||
t < surf->texturemins[1])
continue;
ds = s - surf->texturemins[0];
dt = t - surf->texturemins[1];
if ( ds > surf->extents[0] || dt > surf->extents[1] )
continue;
if (!surf->samples)
return 0;
ds >>= 4;
dt >>= 4;
lightmap = surf->samples;
VectorCopy (vec3_origin, pointcolor);
lightmap += 3*(dt * ((surf->extents[0]>>4)+1) + ds);
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
maps++)
{
for (int j=0 ; j<3 ; j++)
scale[j] = r_modulate->value*r_newrefdef.lightstyles[surf->styles[maps]].rgb[j];
pointcolor[0] += lightmap[0] * scale[0] * (1.0/255);
pointcolor[1] += lightmap[1] * scale[1] * (1.0/255);
pointcolor[2] += lightmap[2] * scale[2] * (1.0/255);
lightmap += 3*((surf->extents[0]>>4)+1) *
((surf->extents[1]>>4)+1);
}
return 1;
}
// go down back side
return RecursiveLightPoint (node->children[!side], mid, end);
}
/*
===============
R_LightPoint
===============
*/
void R_LightPoint (vec3_t p, vec3_t color, entity_t *currententity)
{
vec3_t end;
float r;
int lnum;
dlight_t *dl;
vec3_t dist;
if (!r_worldmodel->lightdata || !currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = RecursiveLightPoint (r_worldmodel->nodes, p, end);
if (r == -1)
{
VectorCopy (vec3_origin, color);
}
else
{
VectorCopy (pointcolor, color);
}
//
// add dynamic lights
//
dl = r_newrefdef.dlights;
for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++, dl++)
{
float add;
VectorSubtract (currententity->origin,
dl->origin,
dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0/256);
if (add > 0)
{
VectorMA (color, add, dl->color, color);
}
}
VectorScale (color, r_modulate->value, color);
}
//===================================================================
static float s_blocklights[34*34*3];
/*
===============
R_AddDynamicLights
===============
*/
static void R_AddDynamicLights (msurface_t *surf)
{
int lnum;
int sd, td;
float fdist, frad, fminlight;
vec3_t impact, local;
int s, t;
int i;
int smax, tmax;
mtexinfo_t *tex;
dlight_t *dl;
float *pfBL;
float fsacc, ftacc;
smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1;
tex = surf->texinfo;
for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
{
if ( !(surf->dlightbits & (1<<lnum) ) )
continue; // not lit by this light
dl = &r_newrefdef.dlights[lnum];
frad = dl->intensity;
fdist = DotProduct (dl->origin, surf->plane->normal) -
surf->plane->dist;
frad -= fabs(fdist);
// rad is now the highest intensity on the plane
fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
if (frad < fminlight)
continue;
fminlight = frad - fminlight;
for (i=0 ; i<3 ; i++)
{
impact[i] = dl->origin[i] -
surf->plane->normal[i]*fdist;
}
local[0] = DotProduct (impact, tex->vecs[0]) + tex->vecs[0][3] - surf->texturemins[0];
local[1] = DotProduct (impact, tex->vecs[1]) + tex->vecs[1][3] - surf->texturemins[1];
pfBL = s_blocklights;
for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
{
td = local[1] - ftacc;
if ( td < 0 )
td = -td;
for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBL += 3)
{
sd = Q_ftol( local[0] - fsacc );
if ( sd < 0 )
sd = -sd;
if (sd > td)
fdist = sd + (td>>1);
else
fdist = td + (sd>>1);
if ( fdist < fminlight )
{
pfBL[0] += ( frad - fdist ) * dl->color[0];
pfBL[1] += ( frad - fdist ) * dl->color[1];
pfBL[2] += ( frad - fdist ) * dl->color[2];
}
}
}
}
}
/*
** R_SetCacheState
*/
void R_SetCacheState( msurface_t *surf )
{
int maps;
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
maps++)
{
surf->cached_light[maps] = r_newrefdef.lightstyles[surf->styles[maps]].white;
}
}
/*
===============
R_BuildLightMap
Combine and scale multiple lightmaps into the floating format in blocklights
===============
*/
void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
{
int smax, tmax;
int r, g, b, a, max;
int i, j, size;
byte *lightmap;
float scale[4];
int nummaps;
float *bl;
if ( surf->texinfo->flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP) )
ri.Sys_Error (ERR_DROP, "R_BuildLightMap called for non-lit surface");
smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1;
size = smax*tmax;
if (size > (sizeof(s_blocklights)>>4) )
ri.Sys_Error (ERR_DROP, "Bad s_blocklights size");
// set to full bright if no light data
if (!surf->samples)
{
for (i=0 ; i<size*3 ; i++)
s_blocklights[i] = 255;
goto store;
}
// count the # of maps
for ( nummaps = 0 ; nummaps < MAXLIGHTMAPS && surf->styles[nummaps] != 255 ;
nummaps++)
;
lightmap = surf->samples;
// add all the lightmaps
if ( nummaps == 1 )
{
int maps;
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
maps++)
{
bl = s_blocklights;
for (i=0 ; i<3 ; i++)
scale[i] = r_modulate->value*r_newrefdef.lightstyles[surf->styles[maps]].rgb[i];
if ( scale[0] == 1.0F &&
scale[1] == 1.0F &&
scale[2] == 1.0F )
{
for (i=0 ; i<size ; i++, bl+=3)
{
bl[0] = lightmap[i*3+0];
bl[1] = lightmap[i*3+1];
bl[2] = lightmap[i*3+2];
}
}
else
{
for (i=0 ; i<size ; i++, bl+=3)
{
bl[0] = lightmap[i*3+0] * scale[0];
bl[1] = lightmap[i*3+1] * scale[1];
bl[2] = lightmap[i*3+2] * scale[2];
}
}
lightmap += size*3; // skip to next lightmap
}
}
else
{
int maps;
memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 );
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
maps++)
{
bl = s_blocklights;
for (i=0 ; i<3 ; i++)
scale[i] = r_modulate->value*r_newrefdef.lightstyles[surf->styles[maps]].rgb[i];
if ( scale[0] == 1.0F &&
scale[1] == 1.0F &&
scale[2] == 1.0F )
{
for (i=0 ; i<size ; i++, bl+=3 )
{
bl[0] += lightmap[i*3+0];
bl[1] += lightmap[i*3+1];
bl[2] += lightmap[i*3+2];
}
}
else
{
for (i=0 ; i<size ; i++, bl+=3)
{
bl[0] += lightmap[i*3+0] * scale[0];
bl[1] += lightmap[i*3+1] * scale[1];
bl[2] += lightmap[i*3+2] * scale[2];
}
}
lightmap += size*3; // skip to next lightmap
}
}
// add all the dynamic lights
if (surf->dlightframe == r_framecount)
R_AddDynamicLights (surf);
store:
// put into texture format
stride -= (smax<<2);
bl = s_blocklights;
for (i = 0; i < tmax; i++, dest += stride)
{
for (j = 0; j < smax; j++)
{
r = Q_ftol(bl[0]);
g = Q_ftol(bl[1]);
b = Q_ftol(bl[2]);
// catch negative lights
if (r < 0)
r = 0;
if (g < 0)
g = 0;
if (b < 0)
b = 0;
/*
** determine the brightest of the three color components
*/
if (r > g)
max = r;
else
max = g;
if (b > max)
max = b;
/*
** alpha is ONLY used for the mono lightmap case. For this reason
** we set it to the brightest of the color components so that
** things don't get too dim.
*/
a = max;
/*
** rescale all the color components if the intensity of the greatest
** channel exceeds 1.0
*/
if (max > 255)
{
float t = 255.0F / max;
r = r * t;
g = g * t;
b = b * t;
a = a * t;
}
dest[0] = r;
dest[1] = g;
dest[2] = b;
dest[3] = a;
bl += 3;
dest += 4;
}
}
}

999
src/vk/vk_mesh.c Normal file
View file

@ -0,0 +1,999 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_mesh.c: triangle model functions
#include "header/local.h"
/*
=============================================================
ALIAS MODELS
=============================================================
*/
#define NUMVERTEXNORMALS 162
static float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "../constants/anorms.h"
};
typedef float vec4_t[4];
enum {
TRIANGLE_STRIP = 0,
TRIANGLE_FAN = 1
} pipelineIdx;
typedef struct {
vec3_t vertex;
float color[4];
float texCoord[2];
} modelvert;
typedef struct {
int vertexCount;
int firstVertex;
} drawinfo_t;
polyvert_t *verts_buffer = NULL;
lmappolyvert_t *lmappolyverts_buffer = NULL;
static drawinfo_t *drawInfo[2] = {NULL, NULL};
static modelvert *vertList[2] = {NULL, NULL};
static vec4_t *s_lerped = NULL;
static vec3_t *shadowverts = NULL;
static int verts_count = 0;
vec3_t shadevector;
float shadelight[3];
// precalculated dot products for quantized angles
#define SHADEDOT_QUANT 16
static float r_avertexnormal_dots[SHADEDOT_QUANT][256] = {
#include "../constants/anormtab.h"
};
float *shadedots = r_avertexnormal_dots[0];
extern float r_view_matrix[16];
extern float r_projection_matrix[16];
extern float r_viewproj_matrix[16];
// correction matrix with "hacked depth" for models with RF_DEPTHHACK flag set
static float r_vulkan_correction_dh[16] = {
1.f, 0.f, 0.f, 0.f,
0.f, -1.f, 0.f, 0.f,
0.f, 0.f, .3f, 0.f,
0.f, 0.f, .3f, 1.f
};
int
Mesh_VertsRealloc(int count)
{
void *ptr;
if (verts_count > count)
{
return 0;
}
verts_count = ROUNDUP(count * 2, 256);
ptr = realloc(s_lerped, verts_count * sizeof(vec4_t));
if (!ptr)
{
return -1;
}
s_lerped = ptr;
ptr = realloc(shadowverts, verts_count * sizeof(vec3_t));
if (!ptr)
{
return -1;
}
shadowverts = ptr;
ptr = realloc(verts_buffer, verts_count * sizeof(polyvert_t));
if (!ptr)
{
return -1;
}
verts_buffer = ptr;
ptr = realloc(lmappolyverts_buffer, verts_count * sizeof(polyvert_t));
if (!ptr)
{
return -1;
}
lmappolyverts_buffer = ptr;
ptr = realloc(vertList[0], verts_count * sizeof(modelvert));
if (!ptr)
{
return -1;
}
vertList[0] = ptr;
ptr = realloc(vertList[1], verts_count * sizeof(modelvert));
if (!ptr)
{
return -1;
}
vertList[1] = ptr;
ptr = realloc(drawInfo[0], verts_count * sizeof(drawinfo_t));
if (!ptr)
{
return -1;
}
drawInfo[0] = ptr;
ptr = realloc(drawInfo[1], verts_count * sizeof(drawinfo_t));
if (!ptr)
{
return -1;
}
drawInfo[1] = ptr;
return 0;
}
/*
===============
Mesh_Init
===============
*/
void Mesh_Init (void)
{
s_lerped = NULL;
shadowverts = NULL;
verts_buffer = NULL;
lmappolyverts_buffer = NULL;
vertList[0] = NULL;
vertList[1] = NULL;
drawInfo[0] = NULL;
drawInfo[1] = NULL;
verts_count = 0;
if (Mesh_VertsRealloc(MAX_VERTS))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
}
/*
================
Mesh_Free
================
*/
void Mesh_Free (void)
{
if (vk_validation->value > 1)
{
R_Printf(PRINT_ALL, "%s: Deallocated %d mesh verts\n",
__func__, verts_count);
}
verts_count = 0;
if (shadowverts)
{
free(shadowverts);
}
shadowverts = NULL;
if (s_lerped)
{
free(s_lerped);
}
s_lerped = NULL;
if (verts_buffer)
{
free(verts_buffer);
}
verts_buffer = NULL;
if (lmappolyverts_buffer)
{
free(lmappolyverts_buffer);
}
lmappolyverts_buffer = NULL;
if (vertList[0])
{
free(vertList[0]);
}
if (vertList[1])
{
free(vertList[1]);
}
vertList[0] = NULL;
vertList[1] = NULL;
if (drawInfo[0])
{
free(drawInfo[0]);
}
if (drawInfo[1])
{
free(drawInfo[1]);
}
drawInfo[0] = NULL;
drawInfo[1] = NULL;
}
static void Vk_LerpVerts( int nverts, dtrivertx_t *v, dtrivertx_t *ov, dtrivertx_t *verts, float *lerp, float move[3], float frontv[3], float backv[3], entity_t *currententity )
{
int i;
//PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM
if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
{
for (i=0 ; i < nverts; i++, v++, ov++, lerp+=4 )
{
float *normal = r_avertexnormals[verts[i].lightnormalindex];
lerp[0] = move[0] + ov->v[0]*backv[0] + v->v[0]*frontv[0] + normal[0] * POWERSUIT_SCALE;
lerp[1] = move[1] + ov->v[1]*backv[1] + v->v[1]*frontv[1] + normal[1] * POWERSUIT_SCALE;
lerp[2] = move[2] + ov->v[2]*backv[2] + v->v[2]*frontv[2] + normal[2] * POWERSUIT_SCALE;
}
}
else
{
for (i=0 ; i < nverts; i++, v++, ov++, lerp+=4)
{
lerp[0] = move[0] + ov->v[0]*backv[0] + v->v[0]*frontv[0];
lerp[1] = move[1] + ov->v[1]*backv[1] + v->v[1]*frontv[1];
lerp[2] = move[2] + ov->v[2]*backv[2] + v->v[2]*frontv[2];
}
}
}
/*
=============
Vk_DrawAliasFrameLerp
interpolates between two frames and origins
FIXME: batch lerp all vertexes
=============
*/
static void Vk_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp, image_t *skin, float *modelMatrix, int leftHandOffset, int translucentIdx, entity_t *currententity)
{
daliasframe_t *frame, *oldframe;
dtrivertx_t *v, *ov, *verts;
int *order;
float frontlerp;
float alpha;
vec3_t move, delta, vectors[3];
vec3_t frontv, backv;
int i;
float *lerp;
frame = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
verts = v = frame->verts;
oldframe = (daliasframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->oldframe * paliashdr->framesize);
ov = oldframe->verts;
order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
if (currententity->flags & RF_TRANSLUCENT)
alpha = currententity->alpha;
else
alpha = 1.0;
frontlerp = 1.0 - backlerp;
// move should be the delta back to the previous frame * backlerp
VectorSubtract (currententity->oldorigin, currententity->origin, delta);
AngleVectors (currententity->angles, vectors[0], vectors[1], vectors[2]);
move[0] = DotProduct (delta, vectors[0]); // forward
move[1] = -DotProduct (delta, vectors[1]); // left
move[2] = DotProduct (delta, vectors[2]); // up
VectorAdd (move, oldframe->translate, move);
for (i=0 ; i<3 ; i++)
{
move[i] = backlerp*move[i] + frontlerp*frame->translate[i];
}
for (i=0 ; i<3 ; i++)
{
frontv[i] = frontlerp*frame->scale[i];
backv[i] = backlerp*oldframe->scale[i];
}
if (Mesh_VertsRealloc(paliashdr->num_xyz))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
lerp = s_lerped[0];
Vk_LerpVerts( paliashdr->num_xyz, v, ov, verts, lerp, move, frontv, backv, currententity );
int vertCounts[2] = { 0, 0 };
int pipeCounters[2] = { 0, 0 };
VkDeviceSize maxTriangleFanIdxCnt = 0;
if (Mesh_VertsRealloc(1))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
drawInfo[0][0].firstVertex = 0;
drawInfo[1][0].firstVertex = 0;
struct {
float model[16];
int textured;
} meshUbo;
while (1)
{
int count;
// get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0)
{
count = -count;
pipelineIdx = TRIANGLE_FAN;
}
else
{
pipelineIdx = TRIANGLE_STRIP;
}
if (Mesh_VertsRealloc(pipeCounters[pipelineIdx]))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].vertexCount = count;
maxTriangleFanIdxCnt = max(maxTriangleFanIdxCnt, ((count - 2) * 3));
if (currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE))
{
meshUbo.textured = 0;
do
{
int vertIdx = vertCounts[pipelineIdx];
int index_xyz = order[2];
if (Mesh_VertsRealloc(vertIdx))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
// unused in this case, since texturing is disabled
vertList[pipelineIdx][vertIdx].texCoord[0] = 0.f;
vertList[pipelineIdx][vertIdx].texCoord[1] = 0.f;
vertList[pipelineIdx][vertIdx].color[0] = shadelight[0];
vertList[pipelineIdx][vertIdx].color[1] = shadelight[1];
vertList[pipelineIdx][vertIdx].color[2] = shadelight[2];
vertList[pipelineIdx][vertIdx].color[3] = alpha;
if (verts_count < index_xyz)
{
R_Printf(PRINT_ALL, "%s: Model has issues with lerped index\n", __func__);
return;
}
vertList[pipelineIdx][vertIdx].vertex[0] = s_lerped[index_xyz][0];
vertList[pipelineIdx][vertIdx].vertex[1] = s_lerped[index_xyz][1];
vertList[pipelineIdx][vertIdx].vertex[2] = s_lerped[index_xyz][2];
vertCounts[pipelineIdx]++;
order += 3;
} while (--count);
}
else
{
meshUbo.textured = 1;
do
{
int vertIdx = vertCounts[pipelineIdx];
int index_xyz = order[2];
float l;
if (Mesh_VertsRealloc(vertIdx))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
// texture coordinates come from the draw list
vertList[pipelineIdx][vertIdx].texCoord[0] = ((float *)order)[0];
vertList[pipelineIdx][vertIdx].texCoord[1] = ((float *)order)[1];
// normals and vertexes come from the frame list
l = shadedots[verts[index_xyz].lightnormalindex];
vertList[pipelineIdx][vertIdx].color[0] = l * shadelight[0];
vertList[pipelineIdx][vertIdx].color[1] = l * shadelight[1];
vertList[pipelineIdx][vertIdx].color[2] = l * shadelight[2];
vertList[pipelineIdx][vertIdx].color[3] = alpha;
if (verts_count < index_xyz)
{
R_Printf(PRINT_ALL, "%s: Model has issues with lerped index\n", __func__);
return;
}
vertList[pipelineIdx][vertIdx].vertex[0] = s_lerped[index_xyz][0];
vertList[pipelineIdx][vertIdx].vertex[1] = s_lerped[index_xyz][1];
vertList[pipelineIdx][vertIdx].vertex[2] = s_lerped[index_xyz][2];
vertCounts[pipelineIdx]++;
order += 3;
} while (--count);
}
if (Mesh_VertsRealloc(pipeCounters[pipelineIdx] + 1))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
pipeCounters[pipelineIdx]++;
drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].firstVertex = vertCounts[pipelineIdx];
}
uint32_t uboOffset;
VkDescriptorSet uboDescriptorSet;
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(meshUbo), &uboOffset, &uboDescriptorSet);
memcpy(meshUbo.model, modelMatrix, sizeof(float) * 16);
memcpy(uboData, &meshUbo, sizeof(meshUbo));
// player configuration screen model is using the UI renderpass
int pidx = (r_newrefdef.rdflags & RDF_NOWORLDMODEL) ? RP_UI : RP_WORLD;
// non-depth write alias models don't occur with RF_WEAPONMODEL set, so no need for additional left-handed pipelines
qvkpipeline_t pipelines[2][2] = {
{ vk_drawModelPipelineFan[pidx], vk_drawLefthandModelPipelineFan },
{ vk_drawNoDepthModelPipelineFan, vk_drawLefthandModelPipelineFan } };
for (int p = 0; p < 2; p++)
{
VkDeviceSize vaoSize = sizeof(modelvert) * vertCounts[p];
VkBuffer vbo;
VkDeviceSize vboOffset;
uint8_t *vertData = QVk_GetVertexBuffer(vaoSize, &vbo, &vboOffset);
memcpy(vertData, vertList[p], vaoSize);
QVk_BindPipeline(&pipelines[translucentIdx][leftHandOffset]);
VkDescriptorSet descriptorSets[] = { skin->vk_texture.descriptorSet, uboDescriptorSet };
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[translucentIdx][leftHandOffset].layout, 0, 2, descriptorSets, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
if (p == TRIANGLE_STRIP)
{
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleStripIbo(maxTriangleFanIdxCnt), 0, VK_INDEX_TYPE_UINT16);
for (i = 0; i < pipeCounters[p]; i++)
{
vkCmdDrawIndexed(vk_activeCmdbuffer, (drawInfo[p][i].vertexCount - 2) * 3, 1, 0, drawInfo[p][i].firstVertex, 0);
}
}
else
{
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo(maxTriangleFanIdxCnt), 0, VK_INDEX_TYPE_UINT16);
for (i = 0; i < pipeCounters[p]; i++)
{
vkCmdDrawIndexed(vk_activeCmdbuffer, (drawInfo[p][i].vertexCount - 2) * 3, 1, 0, drawInfo[p][i].firstVertex, 0);
}
}
}
}
/*
=============
Vk_DrawAliasShadow
=============
*/
extern vec3_t lightspot;
static void Vk_DrawAliasShadow (dmdl_t *paliashdr, int posenum, float *modelMatrix, entity_t *currententity)
{
int *order;
vec3_t point;
float height, lheight;
lheight = currententity->origin[2] - lightspot[2];
height = 0;
order = (int *)((byte *)paliashdr + paliashdr->ofs_glcmds);
height = -lheight + 1.0;
uint32_t uboOffset;
VkDescriptorSet uboDescriptorSet;
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(float) * 16, &uboOffset, &uboDescriptorSet);
memcpy(uboData, modelMatrix, sizeof(float) * 16);
while (1)
{
int i;
int count;
i = 0;
// get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0)
{
count = -count;
pipelineIdx = TRIANGLE_FAN;
}
else
{
pipelineIdx = TRIANGLE_STRIP;
}
if (Mesh_VertsRealloc(count))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
do
{
if (Mesh_VertsRealloc(order[2]))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
// normals and vertexes come from the frame list
memcpy( point, s_lerped[order[2]], sizeof( point ) );
point[0] -= shadevector[0]*(point[2]+lheight);
point[1] -= shadevector[1]*(point[2]+lheight);
point[2] = height;
shadowverts[i][0] = point[0];
shadowverts[i][1] = point[1];
shadowverts[i][2] = point[2];
order += 3;
i++;
} while (--count);
if (i > 0)
{
VkDeviceSize vaoSize = sizeof(vec3_t) * i;
VkBuffer vbo;
VkDeviceSize vboOffset;
uint8_t *vertData = QVk_GetVertexBuffer(vaoSize, &vbo, &vboOffset);
memcpy(vertData, shadowverts, vaoSize);
QVk_BindPipeline(&vk_shadowsPipelineFan);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_shadowsPipelineFan.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
if (pipelineIdx == TRIANGLE_STRIP)
{
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleStripIbo((i - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
vkCmdDrawIndexed(vk_activeCmdbuffer, (i - 2) * 3, 1, 0, 0, 0);
}
else
{
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((i - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
vkCmdDrawIndexed(vk_activeCmdbuffer, (i - 2) * 3, 1, 0, 0, 0);
}
}
}
}
/*
** R_CullAliasModel
*/
static qboolean R_CullAliasModel( vec3_t bbox[8], entity_t *e, model_t *currentmodel )
{
int i;
vec3_t mins, maxs;
dmdl_t *paliashdr;
vec3_t vectors[3];
vec3_t thismins, oldmins, thismaxs, oldmaxs;
daliasframe_t *pframe, *poldframe;
vec3_t angles;
paliashdr = (dmdl_t *)currentmodel->extradata;
if ( ( e->frame >= paliashdr->num_frames ) || ( e->frame < 0 ) )
{
R_Printf(PRINT_ALL, "%s %s: no such frame %d\n",
__func__, currentmodel->name, e->frame);
e->frame = 0;
}
if ( ( e->oldframe >= paliashdr->num_frames ) || ( e->oldframe < 0 ) )
{
R_Printf(PRINT_ALL, "%s %s: no such oldframe %d\n",
__func__, currentmodel->name, e->oldframe);
e->oldframe = 0;
}
pframe = ( daliasframe_t * ) ( ( byte * ) paliashdr +
paliashdr->ofs_frames +
e->frame * paliashdr->framesize);
poldframe = ( daliasframe_t * ) ( ( byte * ) paliashdr +
paliashdr->ofs_frames +
e->oldframe * paliashdr->framesize);
/*
** compute axially aligned mins and maxs
*/
if ( pframe == poldframe )
{
for ( i = 0; i < 3; i++ )
{
mins[i] = pframe->translate[i];
maxs[i] = mins[i] + pframe->scale[i]*255;
}
}
else
{
for ( i = 0; i < 3; i++ )
{
thismins[i] = pframe->translate[i];
thismaxs[i] = thismins[i] + pframe->scale[i]*255;
oldmins[i] = poldframe->translate[i];
oldmaxs[i] = oldmins[i] + poldframe->scale[i]*255;
if ( thismins[i] < oldmins[i] )
mins[i] = thismins[i];
else
mins[i] = oldmins[i];
if ( thismaxs[i] > oldmaxs[i] )
maxs[i] = thismaxs[i];
else
maxs[i] = oldmaxs[i];
}
}
/*
** compute a full bounding box
*/
for ( i = 0; i < 8; i++ )
{
vec3_t tmp;
if ( i & 1 )
tmp[0] = mins[0];
else
tmp[0] = maxs[0];
if ( i & 2 )
tmp[1] = mins[1];
else
tmp[1] = maxs[1];
if ( i & 4 )
tmp[2] = mins[2];
else
tmp[2] = maxs[2];
VectorCopy( tmp, bbox[i] );
}
/*
** rotate the bounding box
*/
VectorCopy( e->angles, angles );
angles[YAW] = -angles[YAW];
AngleVectors( angles, vectors[0], vectors[1], vectors[2] );
for ( i = 0; i < 8; i++ )
{
vec3_t tmp;
VectorCopy( bbox[i], tmp );
bbox[i][0] = DotProduct( vectors[0], tmp );
bbox[i][1] = -DotProduct( vectors[1], tmp );
bbox[i][2] = DotProduct( vectors[2], tmp );
VectorAdd( e->origin, bbox[i], bbox[i] );
}
{
int p, f, aggregatemask = ~0;
for ( p = 0; p < 8; p++ )
{
int mask = 0;
for ( f = 0; f < 4; f++ )
{
float dp = DotProduct( frustum[f].normal, bbox[p] );
if ( ( dp - frustum[f].dist ) < 0 )
{
mask |= ( 1 << f );
}
}
aggregatemask &= mask;
}
if ( aggregatemask )
{
return true;
}
return false;
}
}
/*
=================
R_DrawAliasModel
=================
*/
void R_DrawAliasModel (entity_t *currententity, model_t *currentmodel)
{
int i;
int leftHandOffset = 0;
dmdl_t *paliashdr;
float an;
vec3_t bbox[8];
float prev_viewproj[16];
if ( !( currententity->flags & RF_WEAPONMODEL ) )
{
if ( R_CullAliasModel( bbox, currententity, currentmodel ) )
return;
}
if ( currententity->flags & RF_WEAPONMODEL )
{
if ( r_lefthand->value == 2 )
return;
}
paliashdr = (dmdl_t *)currentmodel->extradata;
//
// get lighting information
//
// PMM - rewrote, reordered to handle new shells & mixing
// PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
//
if ( currententity->flags & ( RF_SHELL_HALF_DAM | RF_SHELL_GREEN | RF_SHELL_RED | RF_SHELL_BLUE | RF_SHELL_DOUBLE ) )
{
VectorClear (shadelight);
if (currententity->flags & RF_SHELL_HALF_DAM)
{
shadelight[0] = 0.56;
shadelight[1] = 0.59;
shadelight[2] = 0.45;
}
if ( currententity->flags & RF_SHELL_DOUBLE )
{
shadelight[0] = 0.9;
shadelight[1] = 0.7;
}
if ( currententity->flags & RF_SHELL_RED )
shadelight[0] = 1.0;
if ( currententity->flags & RF_SHELL_GREEN )
shadelight[1] = 1.0;
if ( currententity->flags & RF_SHELL_BLUE )
shadelight[2] = 1.0;
}
else if ( currententity->flags & RF_FULLBRIGHT )
{
for (i=0 ; i<3 ; i++)
shadelight[i] = 1.0;
}
else
{
R_LightPoint (currententity->origin, shadelight, currententity);
// player lighting hack for communication back to server
// big hack!
if ( currententity->flags & RF_WEAPONMODEL )
{
// pick the greatest component, which should be the same
// as the mono value returned by software
if (shadelight[0] > shadelight[1])
{
if (shadelight[0] > shadelight[2])
r_lightlevel->value = 150*shadelight[0];
else
r_lightlevel->value = 150*shadelight[2];
}
else
{
if (shadelight[1] > shadelight[2])
r_lightlevel->value = 150*shadelight[1];
else
r_lightlevel->value = 150*shadelight[2];
}
}
}
if ( currententity->flags & RF_MINLIGHT )
{
for (i=0 ; i<3 ; i++)
if (shadelight[i] > 0.1)
break;
if (i == 3)
{
shadelight[0] = 0.1;
shadelight[1] = 0.1;
shadelight[2] = 0.1;
}
}
if ( currententity->flags & RF_GLOW )
{ // bonus items will pulse with time
float scale;
scale = 0.1 * sin(r_newrefdef.time*7);
for (i=0 ; i<3 ; i++)
{
float min;
min = shadelight[i] * 0.8;
shadelight[i] += scale;
if (shadelight[i] < min)
shadelight[i] = min;
}
}
// =================
// PGM ir goggles color override
if ( r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
{
shadelight[0] = 1.0;
shadelight[1] = 0.0;
shadelight[2] = 0.0;
}
// PGM
// =================
shadedots = r_avertexnormal_dots[((int)(currententity->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
an = currententity->angles[1]/180*M_PI;
shadevector[0] = cos(-an);
shadevector[1] = sin(-an);
shadevector[2] = 1;
VectorNormalize (shadevector);
//
// locate the proper data
//
c_alias_polys += paliashdr->num_tris;
//
// draw all the triangles
//
if (currententity->flags & RF_DEPTHHACK || r_newrefdef.rdflags & RDF_NOWORLDMODEL) { // hack the depth range to prevent view model from poking into walls
float r_proj_aspect = (float)r_newrefdef.width / r_newrefdef.height;
float r_proj_fovy = r_newrefdef.fov_y;
float dist = (r_farsee->value == 0) ? 4096.0f : 8192.0f;
// use different range for player setup screen so it doesn't collide with the viewmodel
r_vulkan_correction_dh[10] = 0.3f - (r_newrefdef.rdflags & RDF_NOWORLDMODEL) * 0.1f;
r_vulkan_correction_dh[14] = 0.3f - (r_newrefdef.rdflags & RDF_NOWORLDMODEL) * 0.1f;
memcpy(prev_viewproj, r_viewproj_matrix, sizeof(r_viewproj_matrix));
if (currententity->flags & RF_WEAPONMODEL && r_gunfov->value < 0)
{
Mat_Perspective(r_projection_matrix, r_vulkan_correction_dh, r_proj_fovy, r_proj_aspect, 4, dist);
}
else
{
Mat_Perspective(r_projection_matrix, r_vulkan_correction_dh, r_gunfov->value, r_proj_aspect, 4, dist);
}
Mat_Mul(r_view_matrix, r_projection_matrix, r_viewproj_matrix);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
}
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
{
Mat_Scale(r_viewproj_matrix, -1.f, 1.f, 1.f);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
leftHandOffset = 1;
}
currententity->angles[PITCH] = -currententity->angles[PITCH]; // sigh.
{
float model[16];
image_t *skin;
Mat_Identity(model);
R_RotateForEntity (currententity, model);
currententity->angles[PITCH] = -currententity->angles[PITCH]; // sigh.
// select skin
if (currententity->skin)
skin = currententity->skin; // custom player skin
else
{
if (currententity->skinnum >= MAX_MD2SKINS)
skin = currentmodel->skins[0];
else
{
skin = currentmodel->skins[currententity->skinnum];
if (!skin)
skin = currentmodel->skins[0];
}
}
if (!skin)
skin = r_notexture; // fallback...
// draw it
if ( (currententity->frame >= paliashdr->num_frames)
|| (currententity->frame < 0) )
{
R_Printf(PRINT_ALL, "%s %s: no such frame %d\n",
__func__, currentmodel->name, currententity->frame);
currententity->frame = 0;
currententity->oldframe = 0;
}
if ( (currententity->oldframe >= paliashdr->num_frames)
|| (currententity->oldframe < 0))
{
R_Printf(PRINT_ALL, "%s %s: no such oldframe %d\n",
__func__, currentmodel->name, currententity->oldframe);
currententity->frame = 0;
currententity->oldframe = 0;
}
if ( !r_lerpmodels->value )
currententity->backlerp = 0;
Vk_DrawAliasFrameLerp (paliashdr, currententity->backlerp, skin, model, leftHandOffset, (currententity->flags & RF_TRANSLUCENT) ? 1 : 0, currententity);
}
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
{
Mat_Scale(r_viewproj_matrix, -1.f, 1.f, 1.f);
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
}
if (currententity->flags & RF_DEPTHHACK || r_newrefdef.rdflags & RDF_NOWORLDMODEL)
{
memcpy(r_viewproj_matrix, prev_viewproj, sizeof(prev_viewproj));
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
}
if (vk_shadows->value && !(currententity->flags & (RF_TRANSLUCENT | RF_WEAPONMODEL)))
{
float model[16];
Mat_Identity(model);
R_RotateForEntity(currententity, model);
Vk_DrawAliasShadow (paliashdr, currententity->frame, model, currententity);
}
}

1525
src/vk/vk_model.c Normal file

File diff suppressed because it is too large Load diff

222
src/vk/vk_pipeline.c Normal file
View file

@ -0,0 +1,222 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
qvkshader_t QVk_CreateShader(const uint32_t *shaderSrc, size_t shaderCodeSize, VkShaderStageFlagBits shaderStage)
{
qvkshader_t shader;
VkShaderModuleCreateInfo smCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.codeSize = shaderCodeSize,
.pCode = shaderSrc
};
VK_VERIFY(vkCreateShaderModule(vk_device.logical, &smCreateInfo, NULL, &shader.module));
VkPipelineShaderStageCreateInfo vssCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.stage = shaderStage,
.module = shader.module,
.pName = "main",
.pSpecializationInfo = NULL
};
shader.createInfo = vssCreateInfo;
return shader;
}
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo,
qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount)
{
VkPipelineShaderStageCreateInfo *ssCreateInfos = (VkPipelineShaderStageCreateInfo *)malloc(shaderCount * sizeof(VkPipelineShaderStageCreateInfo));
for (int i = 0; i < shaderCount; i++)
{
ssCreateInfos[i] = shaders[i].createInfo;
}
VkPipelineInputAssemblyStateCreateInfo iaCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.topology = pipeline->topology,
.primitiveRestartEnable = VK_FALSE
};
VkViewport viewport = {
.x = 0.f,
.y = 0.f,
.width = (float)vid.width,
.height = (float)vid.height,
.minDepth = 0.f,
.maxDepth = 1.f,
};
VkRect2D scissor = {
.offset.x = 0,
.offset.y = 0,
.extent = vk_swapchain.extent
};
VkPipelineViewportStateCreateInfo vpCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.viewportCount = 1,
.pViewports = &viewport,
.scissorCount = 1,
.pScissors = &scissor
};
VkPipelineRasterizationStateCreateInfo rCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.depthClampEnable = VK_FALSE,
.rasterizerDiscardEnable = VK_FALSE,
.polygonMode = VK_POLYGON_MODE_FILL,
.cullMode = pipeline->cullMode,
.frontFace = VK_FRONT_FACE_CLOCKWISE,
.depthBiasEnable = VK_FALSE,
.depthBiasConstantFactor = 0.f,
.depthBiasClamp = 0.f,
.depthBiasSlopeFactor = 0.f,
.lineWidth = 1.f
};
VkPipelineMultisampleStateCreateInfo msCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.rasterizationSamples = renderpass->sampleCount,
.sampleShadingEnable = (vk_sampleshading->value > 0 && vk_device.features.sampleRateShading) ? VK_TRUE : VK_FALSE,
.minSampleShading = (vk_sampleshading->value > 0 && vk_device.features.sampleRateShading) ? 1.f : 0.f,
.pSampleMask = NULL,
.alphaToCoverageEnable = VK_FALSE,
.alphaToOneEnable = VK_FALSE
};
VkPipelineDepthStencilStateCreateInfo dCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.depthTestEnable = pipeline->depthTestEnable,
.depthWriteEnable = pipeline->depthTestEnable == VK_TRUE ? pipeline->depthWriteEnable : VK_FALSE, // there should be NO depth writes if depthTestEnable is false but Intel seems to not follow the specs fully...
.depthCompareOp = VK_COMPARE_OP_LESS,
.depthBoundsTestEnable = VK_FALSE,
.stencilTestEnable = VK_FALSE,
.front = { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_NEVER, 0, 0, 0 },
.back = { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_NEVER, 0, 0, 0 },
.minDepthBounds = 0.f,
.maxDepthBounds = 1.f
};
VkPipelineColorBlendStateCreateInfo cbsCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.logicOpEnable = VK_FALSE,
.logicOp = VK_LOGIC_OP_COPY,
.attachmentCount = 1,
.pAttachments = &pipeline->blendOpts,
.blendConstants[0] = 0.f,
.blendConstants[1] = 0.f,
.blendConstants[2] = 0.f,
.blendConstants[3] = 0.f
};
VkDynamicState dynamicStates[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
VkPipelineDynamicStateCreateInfo dsCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.dynamicStateCount = 2,
.pDynamicStates = dynamicStates
};
// push constant sizes accomodate for maximum number of uploaded elements (should probably be checked against the hardware's maximum supported value)
VkPushConstantRange pushConstantRange[] = {
{
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
.offset = 0,
.size = 17 * sizeof(float)
},
{
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
.offset = 17 * sizeof(float),
.size = 11 * sizeof(float)
}};
VkPipelineLayoutCreateInfo plCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.setLayoutCount = descLayoutCount,
.pSetLayouts = descriptorLayout,
// for simplicity assume only two push constant range is passed,
// so it's not the most flexible approach
.pushConstantRangeCount = 2,
.pPushConstantRanges = pushConstantRange
};
VK_VERIFY(vkCreatePipelineLayout(vk_device.logical, &plCreateInfo, NULL, &pipeline->layout));
// create THE pipeline
VkGraphicsPipelineCreateInfo pCreateInfo = {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.pNext = NULL,
.flags = pipeline->flags,
.stageCount = shaderCount,
.pStages = ssCreateInfos,
.pVertexInputState = vertexInputInfo,
.pInputAssemblyState = &iaCreateInfo,
.pTessellationState = NULL,
.pViewportState = &vpCreateInfo,
.pRasterizationState = &rCreateInfo,
.pMultisampleState = &msCreateInfo,
.pDepthStencilState = &dCreateInfo,
.pColorBlendState = &cbsCreateInfo,
.pDynamicState = &dsCreateInfo,
.layout = pipeline->layout,
.renderPass = renderpass->rp,
.subpass = 0,
.basePipelineHandle = VK_NULL_HANDLE,
.basePipelineIndex = -1
};
VK_VERIFY(vkCreateGraphicsPipelines(vk_device.logical, VK_NULL_HANDLE, 1, &pCreateInfo, NULL, &pipeline->pl));
free(ssCreateInfos);
}
void QVk_DestroyPipeline(qvkpipeline_t *pipeline)
{
if (pipeline->layout != VK_NULL_HANDLE)
vkDestroyPipelineLayout(vk_device.logical, pipeline->layout, NULL);
if (pipeline->pl != VK_NULL_HANDLE)
vkDestroyPipeline(vk_device.logical, pipeline->pl, NULL);
pipeline->layout = VK_NULL_HANDLE;
pipeline->pl = VK_NULL_HANDLE;
}

1761
src/vk/vk_rmain.c Normal file

File diff suppressed because it is too large Load diff

325
src/vk/vk_rmisc.c Normal file
View file

@ -0,0 +1,325 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_misc.c
#include "header/local.h"
/*
==================
RE_InitParticleTexture
==================
*/
static byte dottexture[8][8] =
{
{0,0,0,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,1,1,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
};
void RE_InitParticleTexture (void)
{
int x,y,i;
byte data[8][8][4];
//
// particle texture
//
for (x=0 ; x<8 ; x++)
{
for (y=0 ; y<8 ; y++)
{
data[y][x][0] = 255;
data[y][x][1] = 255;
data[y][x][2] = 255;
data[y][x][3] = dottexture[x][y]*255;
}
}
r_particletexture = Vk_LoadPic("***particle***", (byte *)data,
8, 8, 8, 8, it_sprite, 32);
//
// particle texture
//
for (x=0 ; x<8 ; x++)
{
for (y=0 ; y<8 ; y++)
{
for (i=0 ; i<4 ; i++)
{
data[y][x][i] = ((y < 4) && (x < 4)) ? 255 : 0;
}
}
}
r_squaretexture = Vk_LoadPic("***square***", (byte *)data,
8, 8, 8, 8, it_sprite, 32);
//
// also use this for bad textures, but without alpha
//
for (x=0 ; x<8 ; x++)
{
for (y=0 ; y<8 ; y++)
{
data[y][x][0] = dottexture[x&3][y&3]*255;
data[y][x][1] = 0;
data[y][x][2] = 0;
data[y][x][3] = 255;
}
}
r_notexture = Vk_LoadPic("***r_notexture***", (byte *)data,
8, 8, 8, 8, it_wall, 32);
}
/*
==============================================================================
SCREEN SHOTS
==============================================================================
*/
/*
==================
Vk_ScreenShot_f
==================
*/
void Vk_ScreenShot_f (void)
{
byte *buffer;
int i;
size_t buffSize = vid.width * vid.height * 4;
if (!vk_device.screenshotSupported)
{
R_Printf(PRINT_ALL, "%s: Screenshots are not supported by this GPU.\n", __func__);
return;
}
buffer = malloc(buffSize);
VkExtent2D extent = {
.width = (uint32_t)(vid.width),
.height = (uint32_t)(vid.height),
};
VkOffset2D offset = {
.x = (int32_t)((vk_swapchain.extent.width - extent.width) / 2u),
.y = (int32_t)((vk_swapchain.extent.height - extent.height) / 2u),
};
QVk_ReadPixels(buffer, &offset, &extent);
// swap rgb to bgr
if (vk_swapchain.format == VK_FORMAT_R8G8B8A8_UNORM ||
vk_swapchain.format == VK_FORMAT_R8G8B8A8_SRGB)
{
for (i = 0; i < buffSize; i += 4)
{
buffer[i + 3] = 255;
}
}
else
{
for (i = 0; i < buffSize; i += 4)
{
int temp;
temp = buffer[i];
buffer[i] = buffer[i + 2];
buffer[i + 2] = temp;
buffer[i + 3] = 255; // alpha component
}
}
ri.Vid_WriteScreenshot(vid.width, vid.height, 4, buffer);
free(buffer);
}
/*
** Vk_Strings_f
*/
void Vk_Strings_f(void)
{
int i = 0;
uint32_t numDevices = 0;
int usedDevice = 0;
VkPhysicalDevice *physicalDevices;
VkPhysicalDeviceProperties deviceProperties;
int preferredDevice = (int)vk_device_idx->value;
int msaa = (int)vk_msaa->value;
uint32_t driverMajor = VK_VERSION_MAJOR(vk_device.properties.driverVersion);
uint32_t driverMinor = VK_VERSION_MINOR(vk_device.properties.driverVersion);
uint32_t driverPatch = VK_VERSION_PATCH(vk_device.properties.driverVersion);
// NVIDIA driver version decoding scheme
if (vk_device.properties.vendorID == 0x10DE)
{
driverMajor = ((uint32_t)(vk_device.properties.driverVersion) >> 22) & 0x3ff;
driverMinor = ((uint32_t)(vk_device.properties.driverVersion) >> 14) & 0x0ff;
uint32_t secondary = ((uint32_t)(vk_device.properties.driverVersion) >> 6) & 0x0ff;
uint32_t tertiary = vk_device.properties.driverVersion & 0x03f;
driverPatch = (secondary << 8) | tertiary;
}
VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &numDevices, NULL));
if (!numDevices)
{
return;
}
physicalDevices = malloc(sizeof(VkPhysicalDevice) * numDevices);
if (!physicalDevices)
{
return;
}
VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &numDevices, physicalDevices));
if (preferredDevice >= numDevices)
{
preferredDevice = -1;
}
R_Printf(PRINT_ALL, "------------------------------------\n");
R_Printf(PRINT_ALL, "Vulkan API: %d.%d\n", VK_VERSION_MAJOR(vk_config.vk_version),
VK_VERSION_MINOR(vk_config.vk_version));
R_Printf(PRINT_ALL, "Header version: %d\n", VK_HEADER_VERSION);
R_Printf(PRINT_ALL, "Devices found:\n");
for (i = 0; i < numDevices; ++i)
{
qboolean isPreferred = false;
vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
isPreferred = (preferredDevice == i) || (
preferredDevice < 0 &&
deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
);
if (isPreferred) {
usedDevice = i;
}
R_Printf(PRINT_ALL, "%s#%d: %s\n",
isPreferred && numDevices > 1 ? "* " : " ",
i, deviceProperties.deviceName);
}
free(physicalDevices);
R_Printf(PRINT_ALL, "Using device #%d:\n", usedDevice);
R_Printf(PRINT_ALL, " deviceName: %s\n", vk_device.properties.deviceName);
R_Printf(PRINT_ALL, " resolution: %dx%d", vid.width, vid.height);
if (msaa > 0)
{
R_Printf(PRINT_ALL, " (MSAAx%d)\n", msaa);
}
else
{
R_Printf(PRINT_ALL, "\n");
}
#ifndef __linux__
// Intel on Windows and MacOS (Linux uses semver for Mesa drivers)
if (vk_device.properties.vendorID == 0x8086)
{
R_Printf(PRINT_ALL, " driverVersion: %d (0x%X)\n",
vk_device.properties.driverVersion,
vk_device.properties.driverVersion);
}
else
#endif
{
R_Printf(PRINT_ALL, " driverVersion: %d.%d.%d (0x%X)\n",
driverMajor, driverMinor, driverPatch,
vk_device.properties.driverVersion);
}
R_Printf(PRINT_ALL, " apiVersion: %d.%d.%d\n",
VK_VERSION_MAJOR(vk_device.properties.apiVersion),
VK_VERSION_MINOR(vk_device.properties.apiVersion),
VK_VERSION_PATCH(vk_device.properties.apiVersion));
R_Printf(PRINT_ALL, " deviceID: %d\n", vk_device.properties.deviceID);
R_Printf(PRINT_ALL, " vendorID: 0x%X (%s)\n",
vk_device.properties.vendorID, vk_config.vendor_name);
R_Printf(PRINT_ALL, " deviceType: %s\n", vk_config.device_type);
R_Printf(PRINT_ALL, " gfx/present/transfer: %d/%d/%d\n",
vk_device.gfxFamilyIndex,
vk_device.presentFamilyIndex,
vk_device.transferFamilyIndex);
R_Printf(PRINT_ALL, "Present mode: %s\n", vk_config.present_mode);
R_Printf(PRINT_ALL, "Swapchain image format: %d\n", vk_swapchain.format);
R_Printf(PRINT_ALL, "Supported present modes: ");
i = 0;
while(vk_config.supported_present_modes[i])
{
R_Printf(PRINT_ALL, "%s ", vk_config.supported_present_modes[i++]);
}
R_Printf(PRINT_ALL, "\n");
R_Printf(PRINT_ALL, "Enabled extensions: ");
i = 0;
while(vk_config.extensions[i])
{
R_Printf(PRINT_ALL, "%s ", vk_config.extensions[i++]);
}
R_Printf(PRINT_ALL, "\n");
R_Printf(PRINT_ALL, "Enabled layers: ");
i = 0;
while(vk_config.layers[i])
{
R_Printf(PRINT_ALL, "%s ", vk_config.layers[i++]);
}
R_Printf(PRINT_ALL, "\n");
}
/*
** Vk_Mem_f
*/
void Vk_Mem_f(void)
{
R_Printf(PRINT_ALL, "\nDynamic buffer stats: \n");
R_Printf(PRINT_ALL, "Vertex : %u/%ukB (%.1f%% max: %ukB)\n",
vk_config.vertex_buffer_usage / 1024,
vk_config.vertex_buffer_size / 1024,
100.f * vk_config.vertex_buffer_usage / vk_config.vertex_buffer_size,
vk_config.vertex_buffer_max_usage / 1024);
R_Printf(PRINT_ALL, "Index : %u/%uB (%.1f%% max: %uB)\n",
vk_config.index_buffer_usage,
vk_config.index_buffer_size,
100.f * vk_config.index_buffer_usage / vk_config.index_buffer_size,
vk_config.index_buffer_max_usage);
R_Printf(PRINT_ALL, "Uniform: %u/%ukB (%.1f%% max: %ukB)\n",
vk_config.uniform_buffer_usage / 1024,
vk_config.uniform_buffer_size / 1024,
100.f * vk_config.uniform_buffer_usage / vk_config.uniform_buffer_size,
vk_config.uniform_buffer_max_usage / 1024);
R_Printf(PRINT_ALL, "Triangle index: %u/%u (%.1f%% max: %u)\n",
vk_config.triangle_index_usage,
vk_config.triangle_index_count,
100.f * vk_config.triangle_index_usage / vk_config.triangle_index_count,
vk_config.triangle_index_max_usage);
}

1324
src/vk/vk_rsurf.c Normal file

File diff suppressed because it is too large Load diff

85
src/vk/vk_shaders.c Normal file
View file

@ -0,0 +1,85 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/shaders.h"
// ingame shaders stored as uint32_t arrays (autogenerated by glslangValidator)
#include "spirv/basic_vert.c"
#include "spirv/basic_frag.c"
#include "spirv/basic_color_quad_vert.c"
#include "spirv/basic_color_quad_frag.c"
#include "spirv/model_vert.c"
#include "spirv/model_frag.c"
#include "spirv/nullmodel_vert.c"
#include "spirv/particle_vert.c"
#include "spirv/point_particle_vert.c"
#include "spirv/point_particle_frag.c"
#include "spirv/sprite_vert.c"
#include "spirv/beam_vert.c"
#include "spirv/skybox_vert.c"
#include "spirv/d_light_vert.c"
#include "spirv/polygon_vert.c"
#include "spirv/polygon_lmap_vert.c"
#include "spirv/polygon_lmap_frag.c"
#include "spirv/polygon_warp_vert.c"
#include "spirv/shadows_vert.c"
#include "spirv/postprocess_vert.c"
#include "spirv/postprocess_frag.c"
#include "spirv/world_warp_vert.c"
#include "spirv/world_warp_frag.c"
const size_t basic_vert_size = sizeof(basic_vert_spv);
const size_t basic_frag_size = sizeof(basic_frag_spv);
const size_t basic_color_quad_vert_size = sizeof(basic_color_quad_vert_spv);
const size_t basic_color_quad_frag_size = sizeof(basic_color_quad_frag_spv);
const size_t model_vert_size = sizeof(model_vert_spv);
const size_t model_frag_size = sizeof(model_frag_spv);
const size_t nullmodel_vert_size = sizeof(nullmodel_vert_spv);
const size_t particle_vert_size = sizeof(particle_vert_spv);
const size_t point_particle_vert_size = sizeof(point_particle_vert_spv);
const size_t point_particle_frag_size = sizeof(point_particle_frag_spv);
const size_t sprite_vert_size = sizeof(sprite_vert_spv);
const size_t beam_vert_size = sizeof(beam_vert_spv);
const size_t skybox_vert_size = sizeof(skybox_vert_spv);
const size_t d_light_vert_size = sizeof(d_light_vert_spv);
const size_t polygon_vert_size = sizeof(polygon_vert_spv);
const size_t polygon_lmap_vert_size = sizeof(polygon_lmap_vert_spv);
const size_t polygon_lmap_frag_size = sizeof(polygon_lmap_frag_spv);
const size_t polygon_warp_vert_size = sizeof(polygon_warp_vert_spv);
const size_t shadows_vert_size = sizeof(shadows_vert_spv);
const size_t postprocess_vert_size = sizeof(postprocess_vert_spv);
const size_t postprocess_frag_size = sizeof(postprocess_frag_spv);
const size_t world_warp_vert_size = sizeof(world_warp_vert_spv);
const size_t world_warp_frag_size = sizeof(world_warp_frag_spv);

250
src/vk/vk_swapchain.c Normal file
View file

@ -0,0 +1,250 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
// internal helper
static const char *presentModeString(VkPresentModeKHR presentMode)
{
#define PMSTR(r) case VK_ ##r: return "VK_"#r
switch (presentMode)
{
PMSTR(PRESENT_MODE_IMMEDIATE_KHR);
PMSTR(PRESENT_MODE_MAILBOX_KHR);
PMSTR(PRESENT_MODE_FIFO_KHR);
PMSTR(PRESENT_MODE_FIFO_RELAXED_KHR);
default: return "<unknown>";
}
#undef PMSTR
return "UNKNOWN PRESENT MODE";
}
// internal helper
static VkSurfaceFormatKHR getSwapSurfaceFormat(const VkSurfaceFormatKHR *surfaceFormats, uint32_t formatCount)
{
VkSurfaceFormatKHR swapSurfaceFormat;
memset(&swapSurfaceFormat, 0, sizeof(swapSurfaceFormat));
if (!surfaceFormats || !formatCount)
{
return swapSurfaceFormat;
}
for (size_t i = 0; i < formatCount; ++i)
{
if (surfaceFormats[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR &&
surfaceFormats[i].format == VK_FORMAT_B8G8R8A8_UNORM)
{
swapSurfaceFormat.colorSpace = surfaceFormats[i].colorSpace;
swapSurfaceFormat.format = surfaceFormats[i].format;
return swapSurfaceFormat;
}
}
// no preferred format, so get the first one from list
swapSurfaceFormat.colorSpace = surfaceFormats[0].colorSpace;
swapSurfaceFormat.format = surfaceFormats[0].format;
return swapSurfaceFormat;
}
// internal helper
// look to https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPresentModeKHR.html for more information
static VkPresentModeKHR getSwapPresentMode(const VkPresentModeKHR *presentModes, uint32_t presentModesCount, VkPresentModeKHR desiredMode)
{
// PRESENT_MODE_FIFO_KHR is guaranteed to exist due to spec requirements
VkPresentModeKHR usedPresentMode = VK_PRESENT_MODE_FIFO_KHR;
if (!presentModes)
{
return usedPresentMode;
}
// check if the desired present mode is supported
for (uint32_t i = 0; i < presentModesCount; ++i)
{
// mode supported, nothing to do here
if (presentModes[i] == desiredMode)
{
vk_config.present_mode = presentModeString(desiredMode);
R_Printf(PRINT_ALL, "...using present mode: %s\n", vk_config.present_mode);
return desiredMode;
}
}
// preferred present mode not found - choose the next best thing
for (uint32_t i = 0; i < presentModesCount; ++i)
{
// always prefer mailbox for triple buffering with whole image replace
if (presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR)
{
usedPresentMode = presentModes[i];
break;
}
// prefer immediate update with tearing
else if (presentModes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR)
{
usedPresentMode = presentModes[i];
}
}
vk_config.present_mode = presentModeString(usedPresentMode);
R_Printf(PRINT_ALL, "...present mode %s not supported, using present mode: %s\n", presentModeString(desiredMode), vk_config.present_mode);
return usedPresentMode;
}
// internal helper
static VkCompositeAlphaFlagBitsKHR getSupportedCompositeAlpha(VkCompositeAlphaFlagsKHR supportedFlags)
{
VkCompositeAlphaFlagBitsKHR compositeAlphaFlags[] = {
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR,
VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR,
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
};
for (int i = 0; i < 4; ++i)
{
if (supportedFlags & compositeAlphaFlags[i])
return compositeAlphaFlags[i];
}
return VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR;
}
qboolean QVk_CheckExtent(void)
{
VkSurfaceCapabilitiesKHR surfaceCaps;
VK_VERIFY(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk_device.physical, vk_surface, &surfaceCaps));
if (surfaceCaps.currentExtent.width == 0 || surfaceCaps.currentExtent.height == 0)
{
return false;
}
return true;
}
VkResult QVk_CreateSwapchain()
{
VkSurfaceCapabilitiesKHR surfaceCaps;
VkSurfaceFormatKHR *surfaceFormats = NULL;
VkPresentModeKHR *presentModes = NULL;
uint32_t formatCount, presentModesCount;
VK_VERIFY(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk_device.physical, vk_surface, &surfaceCaps));
VK_VERIFY(vkGetPhysicalDeviceSurfaceFormatsKHR(vk_device.physical, vk_surface, &formatCount, NULL));
VK_VERIFY(vkGetPhysicalDeviceSurfacePresentModesKHR(vk_device.physical, vk_surface, &presentModesCount, NULL));
if (formatCount > 0)
{
surfaceFormats = (VkSurfaceFormatKHR *)malloc(formatCount * sizeof(VkSurfaceFormatKHR));
VK_VERIFY(vkGetPhysicalDeviceSurfaceFormatsKHR(vk_device.physical, vk_surface, &formatCount, surfaceFormats));
}
if (presentModesCount > 0)
{
presentModes = (VkPresentModeKHR *)malloc(presentModesCount * sizeof(VkPresentModeKHR));
VK_VERIFY(vkGetPhysicalDeviceSurfacePresentModesKHR(vk_device.physical, vk_surface, &presentModesCount, presentModes));
R_Printf(PRINT_ALL, "Supported present modes: ");
for (int i = 0; i < presentModesCount; i++)
{
R_Printf(PRINT_ALL, "%s ", presentModeString(presentModes[i]));
vk_config.supported_present_modes[i] = presentModeString(presentModes[i]);
}
R_Printf(PRINT_ALL, "\n");
}
VkSurfaceFormatKHR swapSurfaceFormat = getSwapSurfaceFormat(surfaceFormats, formatCount);
VkPresentModeKHR swapPresentMode = getSwapPresentMode(presentModes, presentModesCount, r_vsync->value > 0 ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_MAILBOX_KHR);
free(surfaceFormats);
free(presentModes);
VkExtent2D extent = surfaceCaps.currentExtent;
if(extent.width == UINT32_MAX || extent.height == UINT32_MAX)
{
extent.width = max(surfaceCaps.minImageExtent.width, min(surfaceCaps.maxImageExtent.width, vid.width));
extent.height = max(surfaceCaps.minImageExtent.height, min(surfaceCaps.maxImageExtent.height, vid.height));
}
// request at least 2 images - this fixes fullscreen crashes on AMD when launching the game in fullscreen
uint32_t imageCount = max(2, surfaceCaps.minImageCount);
if (swapPresentMode != VK_PRESENT_MODE_FIFO_KHR)
imageCount = max(3, surfaceCaps.minImageCount);
if (surfaceCaps.maxImageCount > 0)
imageCount = min(imageCount, surfaceCaps.maxImageCount);
VkImageUsageFlags imgUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
// TRANSFER_SRC_BIT is required for taking screenshots
if (surfaceCaps.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
{
imgUsage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
vk_device.screenshotSupported = true;
}
VkSwapchainKHR oldSwapchain = vk_swapchain.sc;
VkSwapchainCreateInfoKHR scCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.pNext = NULL,
.flags = 0,
.surface = vk_surface,
.minImageCount = imageCount,
.imageFormat = swapSurfaceFormat.format,
.imageColorSpace = swapSurfaceFormat.colorSpace,
.imageExtent = extent,
.imageArrayLayers = 1,
.imageUsage = imgUsage,
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = NULL,
.preTransform = (surfaceCaps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfaceCaps.currentTransform,
.compositeAlpha = getSupportedCompositeAlpha(surfaceCaps.supportedCompositeAlpha),
.presentMode = swapPresentMode,
.clipped = VK_TRUE,
.oldSwapchain = oldSwapchain
};
uint32_t queueFamilyIndices[] = { (uint32_t)vk_device.gfxFamilyIndex, (uint32_t)vk_device.presentFamilyIndex };
if (vk_device.presentFamilyIndex != vk_device.gfxFamilyIndex)
{
scCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
scCreateInfo.queueFamilyIndexCount = 2;
scCreateInfo.pQueueFamilyIndices = queueFamilyIndices;
}
vk_swapchain.format = swapSurfaceFormat.format;
vk_swapchain.extent = extent;
R_Printf(PRINT_ALL, "...trying swapchain extent: %dx%d\n", vk_swapchain.extent.width, vk_swapchain.extent.height);
R_Printf(PRINT_ALL, "...trying swapchain image format: %d\n", vk_swapchain.format);
VkResult res = vkCreateSwapchainKHR(vk_device.logical, &scCreateInfo, NULL, &vk_swapchain.sc);
if (res != VK_SUCCESS)
return res;
VK_VERIFY(vkGetSwapchainImagesKHR(vk_device.logical, vk_swapchain.sc, &imageCount, NULL));
vk_swapchain.images = (VkImage *)malloc(imageCount * sizeof(VkImage));
vk_swapchain.imageCount = imageCount;
res = vkGetSwapchainImagesKHR(vk_device.logical, vk_swapchain.sc, &imageCount, vk_swapchain.images);
if (oldSwapchain != VK_NULL_HANDLE)
vkDestroySwapchainKHR(vk_device.logical, oldSwapchain, NULL);
return res;
}

620
src/vk/vk_util.c Normal file
View file

@ -0,0 +1,620 @@
/*
Copyright (C) 2018 Christoph Schied
Copyright (C) 2020 Denis Pauk
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 the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "header/util.h"
#include "header/local.h"
#include <assert.h>
static uint32_t
get_memory_type(uint32_t mem_req_type_bits, VkMemoryPropertyFlags mem_prop)
{
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++) {
if(mem_req_type_bits & (1 << i)) {
if((vk_device.mem_properties.memoryTypes[i].propertyFlags & mem_prop) == mem_prop)
return i;
}
}
return -1;
}
typedef struct MemoryResource_s {
// type of memory
uint32_t memory_type;
// offset step
VkDeviceSize alignment;
// id memory used
VkBool32 used;
// suballocate
VkBool32 suballocate;
// shared memory used for image
VkDeviceMemory memory;
// image size
VkDeviceSize size;
// posision in shared memory
VkDeviceSize offset;
} MemoryResource_t;
// 1MB buffers / 512 x 512 * RGBA
#define MEMORY_THRESHOLD (512 * 512 * 4)
static VkDeviceSize memory_block_threshold;
static MemoryResource_t *used_memory;
static VkDeviceSize used_memory_size;
void
vulkan_memory_init(void)
{
memory_block_threshold = MEMORY_THRESHOLD;
used_memory_size = 1024; // Size of buffers history
used_memory = malloc(used_memory_size * sizeof(MemoryResource_t));
memset(used_memory, 0, used_memory_size * sizeof(MemoryResource_t));
}
static void
memory_type_print(VkMemoryPropertyFlags mem_prop)
{
#define MPSTR(r, prop) \
if((prop & VK_ ##r) != 0) \
{ R_Printf(PRINT_ALL, " %s", "VK_"#r); };
MPSTR(MEMORY_PROPERTY_DEVICE_LOCAL_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_HOST_VISIBLE_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_HOST_COHERENT_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_HOST_CACHED_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_PROTECTED_BIT, mem_prop);
MPSTR(MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD, mem_prop);
MPSTR(MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD, mem_prop);
#undef PMSTR
}
void
vulkan_memory_types_show(void)
{
R_Printf(PRINT_ALL, "\nMemory blocks:");
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
{
if (vk_device.mem_properties.memoryTypes[i].propertyFlags)
{
R_Printf(PRINT_ALL, "\n #%d:", i);
memory_type_print(vk_device.mem_properties.memoryTypes[i].propertyFlags);
}
}
R_Printf(PRINT_ALL, "\n");
}
static VkBool32
vulkan_memory_is_used(int start_pos, int end_pos, VkDeviceMemory memory)
{
int pos;
for (pos = start_pos; pos < end_pos; pos++)
{
if (used_memory[pos].memory == memory && used_memory[pos].used)
return VK_TRUE;
}
return VK_FALSE;
}
void
vulkan_memory_free_unused(void)
{
int pos_global;
for (pos_global = 0; pos_global < used_memory_size; pos_global ++)
{
VkDeviceMemory memory = used_memory[pos_global].memory;
if (memory != VK_NULL_HANDLE && !used_memory[pos_global].used)
{
int pos_local;
// is used somewhere else after
if (vulkan_memory_is_used(pos_global, used_memory_size, memory))
continue;
// is used somewhere else before
if (vulkan_memory_is_used(0, pos_global, memory))
continue;
// free current memory block
vkFreeMemory(vk_device.logical, memory, NULL);
memset(&used_memory[pos_global], 0, sizeof(MemoryResource_t));
// cleanup same block
for (pos_local = pos_global + 1; pos_local < used_memory_size; pos_local++)
{
if (used_memory[pos_local].memory == memory)
{
memset(&used_memory[pos_local], 0, sizeof(MemoryResource_t));
}
}
}
}
}
void
vulkan_memory_delete(void)
{
int pos_global;
for (pos_global = 0; pos_global < used_memory_size; pos_global ++)
{
VkDeviceMemory memory = used_memory[pos_global].memory;
if (memory != VK_NULL_HANDLE)
{
int pos_local;
// free current memory block
vkFreeMemory(vk_device.logical, memory, NULL);
memset(&used_memory[pos_global], 0, sizeof(MemoryResource_t));
// cleanup same block
for (pos_local = pos_global + 1; pos_local < used_memory_size; pos_local++)
{
if (used_memory[pos_local].memory == memory)
{
memset(&used_memory[pos_local], 0, sizeof(MemoryResource_t));
}
}
}
}
free(used_memory);
}
static VkResult
memory_block_min(VkDeviceSize size,
uint32_t memory_type,
VkDeviceSize alignment,
VkBool32 suballocate,
int* block_pos)
{
int pos;
VkDeviceSize min_size = memory_block_threshold;
VkResult result = VK_ERROR_OUT_OF_DEVICE_MEMORY;
// update max_size
if (min_size < size)
{
*block_pos = -1;
return result;
}
// search minimal posible size
for (pos = 0; pos < used_memory_size; pos ++)
{
if (used_memory[pos].memory_type == memory_type &&
used_memory[pos].suballocate == suballocate &&
used_memory[pos].alignment == alignment &&
used_memory[pos].memory != VK_NULL_HANDLE &&
used_memory[pos].used == VK_FALSE &&
used_memory[pos].size < min_size &&
used_memory[pos].size >= size)
{
// save minimal size
min_size = used_memory[pos].size;
*block_pos = pos;
result = VK_SUCCESS;
}
}
return result;
}
static VkResult
memory_block_empty(int *block_pos)
{
int pos;
MemoryResource_t *memory;
// search empty memory
for (pos = *block_pos; pos < used_memory_size; pos ++)
{
if (used_memory[pos].memory == VK_NULL_HANDLE)
{
*block_pos = pos;
return VK_SUCCESS;
}
}
memory = realloc(used_memory, (used_memory_size * 2) * sizeof(MemoryResource_t));
if (!memory)
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
// use previous end
*block_pos = used_memory_size;
// update old struct
memset(memory + used_memory_size, 0, used_memory_size * sizeof(MemoryResource_t));
used_memory_size *= 2;
used_memory = memory;
return VK_SUCCESS;
}
static VkResult
memory_block_allocate(VkDeviceSize size,
uint32_t memory_type,
VkDeviceSize alignment,
VkBool32 suballocate,
int *block_pos)
{
int pos = 0;
if (memory_block_empty(&pos) == VK_SUCCESS)
{
VkResult result;
VkDeviceMemory memory;
if (size < MEMORY_THRESHOLD)
size = MEMORY_THRESHOLD;
// allocate only aligned
size = ROUNDUP(size, alignment);
// Need to split only buffers with suballocate support
if (suballocate)
{
// requested bigger then usual
if (size > memory_block_threshold)
{
size *= 2;
// up threshold for next allocations
memory_block_threshold = size;
}
// allcate bigger memory for reuse
else if (size < memory_block_threshold)
{
size = memory_block_threshold;
}
}
VkMemoryAllocateInfo mem_alloc_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = size,
.memoryTypeIndex = memory_type
};
result = vkAllocateMemory(vk_device.logical, &mem_alloc_info, NULL, &memory);
if (result == VK_SUCCESS)
{
used_memory[pos].memory = memory;
used_memory[pos].memory_type = memory_type;
used_memory[pos].alignment = alignment;
used_memory[pos].offset = 0;
used_memory[pos].size = size;
used_memory[pos].suballocate = suballocate;
used_memory[pos].used = VK_FALSE;
*block_pos = pos;
}
return result;
}
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
static VkResult
memory_create(VkDeviceSize size,
uint32_t memory_type,
VkBool32 suballocate,
VkDeviceSize alignment,
VkDeviceMemory *memory,
VkDeviceSize *offset)
{
int pos = -1;
VkResult result;
result = memory_block_min(size, memory_type, alignment, suballocate, &pos);
if (result != VK_SUCCESS)
{
result = memory_block_allocate(size, memory_type, alignment, suballocate, &pos);
}
if (result == VK_SUCCESS)
{
// check size of block,
// new block should be at least same size as current
// and beger than double minimal offset
// and marked as not for mmap
if (used_memory[pos].size > (size * 2) &&
(used_memory[pos].size > (used_memory[pos].alignment * 2)) &&
used_memory[pos].suballocate)
{
// search from next slot
int new_pos = pos + 1;
result = memory_block_empty(&new_pos);
if (result == VK_SUCCESS)
{
VkDeviceSize new_size = ROUNDUP(size, used_memory[pos].alignment);
// split to several blocks
memcpy(&used_memory[new_pos], &used_memory[pos], sizeof(MemoryResource_t));
used_memory[new_pos].offset = used_memory[pos].offset + new_size;
used_memory[new_pos].size = used_memory[pos].size - new_size;
// save new size to block, it can be bigger than required
used_memory[pos].size = used_memory[new_pos].offset - used_memory[pos].offset;
assert(used_memory[pos].size > 0);
}
}
used_memory[pos].used = VK_TRUE;
*offset = used_memory[pos].offset;
*memory = used_memory[pos].memory;
return result;
}
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
static void
memory_destroy(VkDeviceMemory memory, VkDeviceSize offset)
{
int pos;
for (pos = 0; pos < used_memory_size; pos ++)
{
if (used_memory[pos].memory == memory && used_memory[pos].offset == offset)
{
used_memory[pos].used = VK_FALSE;
return;
}
}
// looks as no such memory registered
vkFreeMemory(vk_device.logical, memory, NULL);
}
static VkResult
memory_create_by_property(VkMemoryRequirements* mem_reqs,
VkMemoryPropertyFlags mem_properties,
VkMemoryPropertyFlags mem_preferences,
VkDeviceMemory *memory,
VkDeviceSize *offset)
{
uint32_t memory_index;
VkMemoryPropertyFlags host_visible;
memory_index = get_memory_type(mem_reqs->memoryTypeBits,
mem_properties | mem_preferences);
// prefered memory allocation
if (memory_index == -1)
{
memory_index = get_memory_type(mem_reqs->memoryTypeBits,
mem_properties);
}
// strictly required
if (memory_index == -1)
{
R_Printf(PRINT_ALL, "%s:%d: Have not found required memory type.\n",
__func__, __LINE__);
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
host_visible = mem_properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
return memory_create(mem_reqs->size, memory_index,
// suballocate allowed
host_visible != VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
mem_reqs->alignment, memory, offset);
}
VkResult
buffer_create(BufferResource_t *buf,
VkBufferCreateInfo buf_create_info,
VkMemoryPropertyFlags mem_properties,
VkMemoryPropertyFlags mem_preferences)
{
assert(buf_create_info.size > 0);
assert(buf);
VkResult result = VK_SUCCESS;
buf->size = buf_create_info.size;
buf->is_mapped = VK_FALSE;
result = vkCreateBuffer(vk_device.logical, &buf_create_info, NULL, &buf->buffer);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_buffer;
}
assert(buf->buffer != VK_NULL_HANDLE);
VkMemoryRequirements mem_reqs;
vkGetBufferMemoryRequirements(vk_device.logical, buf->buffer, &mem_reqs);
result = memory_create_by_property(&mem_reqs, mem_properties, mem_preferences,
&buf->memory, &buf->offset);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_mem_alloc;
}
assert(buf->memory != VK_NULL_HANDLE);
result = vkBindBufferMemory(vk_device.logical, buf->buffer, buf->memory, buf->offset);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_bind_buf_memory;
}
return VK_SUCCESS;
fail_bind_buf_memory:
memory_destroy(buf->memory, buf->offset);
fail_mem_alloc:
vkDestroyBuffer(vk_device.logical, buf->buffer, NULL);
fail_buffer:
buf->buffer = VK_NULL_HANDLE;
buf->memory = VK_NULL_HANDLE;
buf->size = 0;
return result;
}
VkResult
image_create(ImageResource_t *img,
VkImageCreateInfo img_create_info,
VkMemoryPropertyFlags mem_properties,
VkMemoryPropertyFlags mem_preferences)
{
assert(img);
VkResult result = VK_SUCCESS;
result = vkCreateImage(vk_device.logical, &img_create_info, NULL, &img->image);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_buffer;
}
assert(img->image != VK_NULL_HANDLE);
VkMemoryRequirements mem_reqs;
vkGetImageMemoryRequirements(vk_device.logical, img->image, &mem_reqs);
img->size = mem_reqs.size;
result = memory_create_by_property(&mem_reqs, mem_properties, mem_preferences,
&img->memory, &img->offset);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_mem_alloc;
}
assert(img->memory != VK_NULL_HANDLE);
result = vkBindImageMemory(vk_device.logical, img->image, img->memory, img->offset);
if(result != VK_SUCCESS) {
R_Printf(PRINT_ALL, "%s:%d: VkResult verification: %s\n",
__func__, __LINE__, QVk_GetError(result));
goto fail_bind_buf_memory;
}
return VK_SUCCESS;
fail_bind_buf_memory:
memory_destroy(img->memory, img->offset);
fail_mem_alloc:
vkDestroyImage(vk_device.logical, img->image, NULL);
fail_buffer:
img->image = VK_NULL_HANDLE;
img->memory = VK_NULL_HANDLE;
img->size = 0;
return result;
}
VkResult
buffer_destroy(BufferResource_t *buf)
{
assert(!buf->is_mapped);
// buffer should be destroed before bound memory
if(buf->buffer != VK_NULL_HANDLE)
{
vkDestroyBuffer(vk_device.logical, buf->buffer, NULL);
buf->buffer = VK_NULL_HANDLE;
}
// buffer desroed, we can free up memory
if(buf->memory != VK_NULL_HANDLE)
{
memory_destroy(buf->memory, buf->offset);
buf->memory = VK_NULL_HANDLE;
}
memset(buf, 0, sizeof(BufferResource_t));
return VK_SUCCESS;
}
VkResult
image_destroy(ImageResource_t *img)
{
// image should be destroed before bound memory
if(img->image != VK_NULL_HANDLE)
{
vkDestroyImage(vk_device.logical, img->image, NULL);
img->image = VK_NULL_HANDLE;
}
// image destroed, we can free up memory
if(img->memory != VK_NULL_HANDLE)
{
memory_destroy(img->memory, img->offset);
img->memory = VK_NULL_HANDLE;
}
memset(img, 0, sizeof(ImageResource_t));
return VK_SUCCESS;
}
VkResult
buffer_flush(BufferResource_t *buf)
{
VkResult result = VK_SUCCESS;
VkMappedMemoryRange ranges[1] = {{
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
.memory = buf->memory,
.offset = buf->offset,
.size = buf->size
}};
result = vkFlushMappedMemoryRanges(vk_device.logical, 1, ranges);
return result;
}
VkResult
buffer_invalidate(BufferResource_t *buf)
{
VkResult result = VK_SUCCESS;
VkMappedMemoryRange ranges[1] = {{
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
.memory = buf->memory,
.offset = buf->offset,
.size = buf->size
}};
result = vkInvalidateMappedMemoryRanges(vk_device.logical, 1, ranges);
return result;
}
void *
buffer_map(BufferResource_t *buf)
{
assert(buf->memory);
assert(!buf->is_mapped);
buf->is_mapped = VK_TRUE;
void *ret = NULL;
assert(buf->memory != VK_NULL_HANDLE);
assert(buf->size > 0);
VK_VERIFY(vkMapMemory(vk_device.logical, buf->memory,
buf->offset/*offset*/, buf->size, 0 /*flags*/, &ret));
return ret;
}
void
buffer_unmap(BufferResource_t *buf)
{
assert(buf->memory);
assert(buf->is_mapped);
buf->is_mapped = VK_FALSE;
vkUnmapMemory(vk_device.logical, buf->memory);
}

99
src/vk/vk_validation.c Normal file
View file

@ -0,0 +1,99 @@
/*
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "header/local.h"
static VkDebugUtilsMessengerEXT validationMessenger = VK_NULL_HANDLE;
// layer message to string
static const char* msgToString(VkDebugUtilsMessageTypeFlagsEXT type)
{
int g = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) != 0 ? 1 : 0;
int p = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) != 0 ? 1 : 0;
int v = (type & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) != 0 ? 1 : 0;
if (g) return "";
if (p && !v) return "(performance)";
if (p && v) return "(performance and validation)";
if (v) return "(validation)";
return "?";
}
// validation layer callback function (VK_EXT_debug_utils)
static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity,
VkDebugUtilsMessageTypeFlagsEXT msgType,
const VkDebugUtilsMessengerCallbackDataEXT *callbackData,
void* userData)
{
switch (msgSeverity)
{
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT:
R_Printf(PRINT_ALL, "VK_INFO: %s %s\n", callbackData->pMessage, msgToString(msgType));
break;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT:
R_Printf(PRINT_ALL, "VK_VERBOSE: %s %s\n", callbackData->pMessage, msgToString(msgType));
break;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT:
R_Printf(PRINT_ALL, "VK_WARNING: %s %s\n", callbackData->pMessage, msgToString(msgType));
break;
default:
R_Printf(PRINT_ALL, "VK_ERROR: %s %s\n", callbackData->pMessage, msgToString(msgType));
assert(!"Vulkan error occured!");
}
return VK_FALSE;
}
void QVk_CreateValidationLayers()
{
VkDebugUtilsMessengerCreateInfoEXT callbackInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
.pNext = NULL,
.flags = 0,
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
.pfnUserCallback = debugUtilsCallback,
.pUserData = NULL
};
if(vk_validation->value)
{
callbackInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
}
if (qvkCreateDebugUtilsMessengerEXT)
{
VK_VERIFY(qvkCreateDebugUtilsMessengerEXT(vk_instance, &callbackInfo, NULL, &validationMessenger));
R_Printf(PRINT_ALL, "...Vulkan validation layers enabled\n");
}
}
void QVk_DestroyValidationLayers()
{
if( validationMessenger != VK_NULL_HANDLE && qvkDestroyDebugUtilsMessengerEXT)
{
qvkDestroyDebugUtilsMessengerEXT( vk_instance, validationMessenger, NULL );
validationMessenger = VK_NULL_HANDLE;
}
}

732
src/vk/vk_warp.c Normal file
View file

@ -0,0 +1,732 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2018-2019 Krzysztof Kondrak
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// vk_warp.c -- sky and water polygons
#include "header/local.h"
static char skyname[MAX_QPATH];
static float skyrotate;
static vec3_t skyaxis;
static image_t *sky_images[6];
static msurface_t *warpface;
#define SUBDIVIDE_SIZE 64
static void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
{
int i, j;
float *v;
mins[0] = mins[1] = mins[2] = 9999;
maxs[0] = maxs[1] = maxs[2] = -9999;
v = verts;
for (i=0 ; i<numverts ; i++)
for (j=0 ; j<3 ; j++, v++)
{
if (*v < mins[j])
mins[j] = *v;
if (*v > maxs[j])
maxs[j] = *v;
}
}
static void SubdividePolygon (int numverts, float *verts)
{
int i, j, k;
vec3_t mins, maxs;
float *v;
vec3_t front[64], back[64];
int f, b;
float dist[64];
float frac;
vkpoly_t *poly;
vec3_t total;
float total_s, total_t;
if (numverts > 60)
ri.Sys_Error (ERR_DROP, "%s: numverts = %i", __func__, numverts);
BoundPoly (numverts, verts, mins, maxs);
for (i=0 ; i<3 ; i++)
{
float m;
m = (mins[i] + maxs[i]) * 0.5;
m = SUBDIVIDE_SIZE * floor (m/SUBDIVIDE_SIZE + 0.5);
if (maxs[i] - m < 8)
continue;
if (m - mins[i] < 8)
continue;
// cut it
v = verts + i;
for (j=0 ; j<numverts ; j++, v+= 3)
dist[j] = *v - m;
// wrap cases
dist[j] = dist[0];
v-=i;
VectorCopy (verts, v);
f = b = 0;
v = verts;
for (j=0 ; j<numverts ; j++, v+= 3)
{
if (dist[j] >= 0)
{
VectorCopy (v, front[f]);
f++;
}
if (dist[j] <= 0)
{
VectorCopy (v, back[b]);
b++;
}
if (dist[j] == 0 || dist[j+1] == 0)
continue;
if ( (dist[j] > 0) != (dist[j+1] > 0) )
{
// clip point
frac = dist[j] / (dist[j] - dist[j+1]);
for (k=0 ; k<3 ; k++)
front[f][k] = back[b][k] = v[k] + frac*(v[3+k] - v[k]);
f++;
b++;
}
}
SubdividePolygon (f, front[0]);
SubdividePolygon (b, back[0]);
return;
}
// add a point in the center to help keep warp valid
poly = Hunk_Alloc (sizeof(vkpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));
poly->next = warpface->polys;
warpface->polys = poly;
poly->numverts = numverts+2;
VectorClear (total);
total_s = 0;
total_t = 0;
for (i=0 ; i<numverts ; i++, verts+= 3)
{
float s, t;
VectorCopy (verts, poly->verts[i+1]);
s = DotProduct (verts, warpface->texinfo->vecs[0]);
t = DotProduct (verts, warpface->texinfo->vecs[1]);
total_s += s;
total_t += t;
VectorAdd (total, verts, total);
poly->verts[i+1][3] = s;
poly->verts[i+1][4] = t;
}
VectorScale (total, (1.0/numverts), poly->verts[0]);
poly->verts[0][3] = total_s/numverts;
poly->verts[0][4] = total_t/numverts;
// copy first vertex to last
memcpy (poly->verts[i+1], poly->verts[1], sizeof(poly->verts[0]));
}
/*
================
Vk_SubdivideSurface
Breaks a polygon up along axial 64 unit
boundaries so that turbulent and sky warps
can be done reasonably.
================
*/
void Vk_SubdivideSurface (msurface_t *fa, model_t *loadmodel)
{
vec3_t verts[64];
int numverts;
int i;
float *vec;
warpface = fa;
//
// convert edges back to a normal polygon
//
numverts = 0;
for (i=0 ; i<fa->numedges ; i++)
{
int lindex;
lindex = loadmodel->surfedges[fa->firstedge + i];
if (lindex > 0)
vec = loadmodel->vertexes[loadmodel->edges[lindex].v[0]].position;
else
vec = loadmodel->vertexes[loadmodel->edges[-lindex].v[1]].position;
VectorCopy (vec, verts[numverts]);
numverts++;
}
SubdividePolygon (numverts, verts[0]);
}
//=========================================================
/*
=============
EmitWaterPolys
Does a water warp on the pre-fragmented vkpoly_t chain
=============
*/
void
EmitWaterPolys (msurface_t *fa, image_t *texture, float *modelMatrix,
float *color, qboolean solid_surface)
{
vkpoly_t *p, *bp;
float *v;
int i;
struct {
float model[16];
float color[4];
float time;
float scroll;
} polyUbo;
polyUbo.color[0] = color[0];
polyUbo.color[1] = color[1];
polyUbo.color[2] = color[2];
polyUbo.color[3] = color[3];
polyUbo.time = r_newrefdef.time;
if (fa->texinfo->flags & SURF_FLOWING)
polyUbo.scroll = (-64 * ((r_newrefdef.time*0.5) - (int)(r_newrefdef.time*0.5))) / 64.f;
else
polyUbo.scroll = 0;
if (modelMatrix)
{
memcpy(polyUbo.model, modelMatrix, sizeof(float) * 16);
}
else
{
Mat_Identity(polyUbo.model);
}
if (solid_surface)
{
// Solid surface
QVk_BindPipeline(&vk_drawPolySolidWarpPipeline);
}
else
{
// Blend surface
QVk_BindPipeline(&vk_drawPolyWarpPipeline);
}
uint32_t uboOffset;
VkDescriptorSet uboDescriptorSet;
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(polyUbo), &uboOffset, &uboDescriptorSet);
memcpy(uboData, &polyUbo, sizeof(polyUbo));
VkBuffer vbo;
VkDeviceSize vboOffset;
VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
if (solid_surface)
{
// Solid surface
vkCmdBindDescriptorSets(
vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
vk_drawPolySolidWarpPipeline.layout, 0, 2,
descriptorSets, 1, &uboOffset);
}
else
{
// Blend surface
vkCmdBindDescriptorSets(
vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
vk_drawPolyWarpPipeline.layout, 0, 2,
descriptorSets, 1, &uboOffset);
}
for (bp = fa->polys; bp; bp = bp->next)
{
p = bp;
if (Mesh_VertsRealloc(p->numverts))
{
ri.Sys_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
}
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE)
{
verts_buffer[i].vertex[0] = v[0];
verts_buffer[i].vertex[1] = v[1];
verts_buffer[i].vertex[2] = v[2];
verts_buffer[i].texCoord[0] = v[3] / 64.f;
verts_buffer[i].texCoord[1] = v[4] / 64.f;
}
uint8_t *vertData = QVk_GetVertexBuffer(sizeof(polyvert_t) * p->numverts, &vbo, &vboOffset);
memcpy(vertData, verts_buffer, sizeof(polyvert_t) * p->numverts);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((p->numverts - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0);
}
}
//===================================================================
static vec3_t skyclip[6] = {
{1,1,0},
{1,-1,0},
{0,-1,1},
{0,1,1},
{1,0,1},
{-1,0,1}
};
// 1 = s, 2 = t, 3 = 2048
static int st_to_vec[6][3] =
{
{3,-1,2},
{-3,1,2},
{1,3,2},
{-1,-3,2},
{-2,-1,3}, // 0 degrees yaw, look straight up
{2,-1,-3} // look straight down
// {-1,2,3},
// {1,2,-3}
};
// s = [0]/[2], t = [1]/[2]
static int vec_to_st[6][3] =
{
{-2,3,1},
{2,3,-1},
{1,3,2},
{-1,3,-2},
{-2,-1,3},
{-2,1,-3}
// {-1,2,3},
// {1,2,-3}
};
static float skymins[2][6], skymaxs[2][6];
static float sky_min, sky_max;
static void DrawSkyPolygon (int nump, vec3_t vecs)
{
int i;
vec3_t v, av;
float s, t, dv;
int axis;
float *vp;
// decide which face it maps to
VectorCopy (vec3_origin, v);
for (i=0, vp=vecs ; i<nump ; i++, vp+=3)
{
VectorAdd (vp, v, v);
}
av[0] = fabs(v[0]);
av[1] = fabs(v[1]);
av[2] = fabs(v[2]);
if (av[0] > av[1] && av[0] > av[2])
{
if (v[0] < 0)
axis = 1;
else
axis = 0;
}
else if (av[1] > av[2] && av[1] > av[0])
{
if (v[1] < 0)
axis = 3;
else
axis = 2;
}
else
{
if (v[2] < 0)
axis = 5;
else
axis = 4;
}
// project new texture coords
for (i=0 ; i<nump ; i++, vecs+=3)
{
int j;
j = vec_to_st[axis][2];
if (j > 0)
dv = vecs[j - 1];
else
dv = -vecs[-j - 1];
if (dv < 0.001)
continue; // don't divide by zero
j = vec_to_st[axis][0];
if (j < 0)
s = -vecs[-j -1] / dv;
else
s = vecs[j-1] / dv;
j = vec_to_st[axis][1];
if (j < 0)
t = -vecs[-j -1] / dv;
else
t = vecs[j-1] / dv;
if (s < skymins[0][axis])
skymins[0][axis] = s;
if (t < skymins[1][axis])
skymins[1][axis] = t;
if (s > skymaxs[0][axis])
skymaxs[0][axis] = s;
if (t > skymaxs[1][axis])
skymaxs[1][axis] = t;
}
}
#define ON_EPSILON 0.1 // point on plane side epsilon
#define MAX_CLIP_VERTS 64
static void ClipSkyPolygon (int nump, vec3_t vecs, int stage)
{
float *norm;
float *v;
qboolean front, back;
float d, e;
float dists[MAX_CLIP_VERTS];
int sides[MAX_CLIP_VERTS];
vec3_t newv[2][MAX_CLIP_VERTS];
int newc[2];
int i, j;
if (nump > MAX_CLIP_VERTS-2)
ri.Sys_Error (ERR_DROP, "%s: MAX_CLIP_VERTS", __func__);
if (stage == 6)
{ // fully clipped, so draw it
DrawSkyPolygon (nump, vecs);
return;
}
front = back = false;
norm = skyclip[stage];
for (i=0, v = vecs ; i<nump ; i++, v+=3)
{
d = DotProduct (v, norm);
if (d > ON_EPSILON)
{
front = true;
sides[i] = SIDE_FRONT;
}
else if (d < -ON_EPSILON)
{
back = true;
sides[i] = SIDE_BACK;
}
else
sides[i] = SIDE_ON;
dists[i] = d;
}
if (!front || !back)
{ // not clipped
ClipSkyPolygon (nump, vecs, stage+1);
return;
}
// clip it
sides[i] = sides[0];
dists[i] = dists[0];
VectorCopy (vecs, (vecs+(i*3)) );
newc[0] = newc[1] = 0;
for (i=0, v = vecs ; i<nump ; i++, v+=3)
{
switch (sides[i])
{
case SIDE_FRONT:
VectorCopy (v, newv[0][newc[0]]);
newc[0]++;
break;
case SIDE_BACK:
VectorCopy (v, newv[1][newc[1]]);
newc[1]++;
break;
case SIDE_ON:
VectorCopy (v, newv[0][newc[0]]);
newc[0]++;
VectorCopy (v, newv[1][newc[1]]);
newc[1]++;
break;
}
if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
continue;
d = dists[i] / (dists[i] - dists[i+1]);
for (j=0 ; j<3 ; j++)
{
e = v[j] + d*(v[j+3] - v[j]);
newv[0][newc[0]][j] = e;
newv[1][newc[1]][j] = e;
}
newc[0]++;
newc[1]++;
}
// continue
ClipSkyPolygon (newc[0], newv[0][0], stage+1);
ClipSkyPolygon (newc[1], newv[1][0], stage+1);
}
/*
=================
R_AddSkySurface
=================
*/
void R_AddSkySurface (msurface_t *fa)
{
int i;
vec3_t verts[MAX_CLIP_VERTS];
vkpoly_t *p;
// calculate vertex values for sky box
for (p=fa->polys ; p ; p=p->next)
{
for (i=0 ; i<p->numverts ; i++)
{
VectorSubtract (p->verts[i], r_origin, verts[i]);
}
ClipSkyPolygon (p->numverts, verts[0], 0);
}
}
/*
==============
R_ClearSkyBox
==============
*/
void R_ClearSkyBox (void)
{
int i;
for (i=0 ; i<6 ; i++)
{
skymins[0][i] = skymins[1][i] = 9999;
skymaxs[0][i] = skymaxs[1][i] = -9999;
}
}
static void MakeSkyVec (float s, float t, int axis, float *vertexData)
{
vec3_t v, b;
int j;
float dist = (r_farsee->value == 0) ? 2300.0f : 4096.0f;
b[0] = s * dist;
b[1] = t * dist;
b[2] = dist;
for (j = 0; j<3; j++)
{
int k;
k = st_to_vec[axis][j];
if (k < 0)
v[j] = -b[-k - 1];
else
v[j] = b[k - 1];
}
// avoid bilerp seam
s = (s + 1)*0.5;
t = (t + 1)*0.5;
if (s < sky_min)
s = sky_min;
else if (s > sky_max)
s = sky_max;
if (t < sky_min)
t = sky_min;
else if (t > sky_max)
t = sky_max;
t = 1.0 - t;
vertexData[0] = v[0];
vertexData[1] = v[1];
vertexData[2] = v[2];
vertexData[3] = s;
vertexData[4] = t;
}
/*
==============
R_DrawSkyBox
==============
*/
static int skytexorder[6] = {0,2,1,3,4,5};
void R_DrawSkyBox (void)
{
int i;
if (skyrotate)
{ // check for no sky at all
for (i = 0; i<6; i++)
if (skymins[0][i] < skymaxs[0][i]
&& skymins[1][i] < skymaxs[1][i])
break;
if (i == 6)
return; // nothing visible
}
float model[16];
Mat_Identity(model);
Mat_Rotate(model, r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);
Mat_Translate(model, r_origin[0], r_origin[1], r_origin[2]);
struct {
float data[5];
} skyVerts[4];
QVk_BindPipeline(&vk_drawSkyboxPipeline);
uint32_t uboOffset;
VkDescriptorSet uboDescriptorSet;
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(model), &uboOffset, &uboDescriptorSet);
memcpy(uboData, model, sizeof(model));
for (i = 0; i<6; i++)
{
if (skyrotate)
{ // hack, forces full sky to draw when rotating
skymins[0][i] = -1;
skymins[1][i] = -1;
skymaxs[0][i] = 1;
skymaxs[1][i] = 1;
}
if (skymins[0][i] >= skymaxs[0][i]
|| skymins[1][i] >= skymaxs[1][i])
continue;
MakeSkyVec(skymins[0][i], skymins[1][i], i, skyVerts[0].data);
MakeSkyVec(skymins[0][i], skymaxs[1][i], i, skyVerts[1].data);
MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i, skyVerts[2].data);
MakeSkyVec(skymaxs[0][i], skymins[1][i], i, skyVerts[3].data);
float verts[] = {
skyVerts[0].data[0], skyVerts[0].data[1], skyVerts[0].data[2], skyVerts[0].data[3], skyVerts[0].data[4],
skyVerts[1].data[0], skyVerts[1].data[1], skyVerts[1].data[2], skyVerts[1].data[3], skyVerts[1].data[4],
skyVerts[2].data[0], skyVerts[2].data[1], skyVerts[2].data[2], skyVerts[2].data[3], skyVerts[2].data[4],
skyVerts[0].data[0], skyVerts[0].data[1], skyVerts[0].data[2], skyVerts[0].data[3], skyVerts[0].data[4],
skyVerts[2].data[0], skyVerts[2].data[1], skyVerts[2].data[2], skyVerts[2].data[3], skyVerts[2].data[4],
skyVerts[3].data[0], skyVerts[3].data[1], skyVerts[3].data[2], skyVerts[3].data[3], skyVerts[3].data[4]
};
VkBuffer vbo;
VkDeviceSize vboOffset;
uint8_t *vertData = QVk_GetVertexBuffer(sizeof(verts), &vbo, &vboOffset);
memcpy(vertData, verts, sizeof(verts));
VkDescriptorSet descriptorSets[] = { sky_images[skytexorder[i]]->vk_texture.descriptorSet, uboDescriptorSet };
float gamma = 2.1F - vid_gamma->value;
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
vk_drawSkyboxPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
vkCmdDraw(vk_activeCmdbuffer, 6, 1, 0, 0);
}
}
/*
============
RE_SetSky
============
*/
// 3dstudio environment map names
static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
void RE_SetSky (char *name, float rotate, vec3_t axis)
{
int i;
char pathname[MAX_QPATH];
strncpy(skyname, name, sizeof(skyname) - 1);
skyrotate = rotate;
VectorCopy(axis, skyaxis);
for (i = 0; i<6; i++)
{
// chop down rotating skies for less memory
if (vk_skymip->value || skyrotate)
vk_picmip->value++;
Com_sprintf(pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
sky_images[i] = Vk_FindImage(pathname, it_sky);
if (!sky_images[i]) {
Com_sprintf(pathname, sizeof(pathname), "pics/Skies/%s%s.m8", skyname, suf[i]);
sky_images[i] = Vk_FindImage(pathname, it_sky);
}
if (!sky_images[i])
sky_images[i] = r_notexture;
if (vk_skymip->value || skyrotate)
{ // take less memory
vk_picmip->value--;
sky_min = 1.0 / 256;
sky_max = 255.0 / 256;
}
else
{
sky_min = 1.0 / 512;
sky_max = 511.0 / 512;
}
}
}

1905
src/vk/volk/volk.c Normal file

File diff suppressed because it is too large Load diff

1257
src/vk/volk/volk.h Normal file

File diff suppressed because it is too large Load diff