awful batch script mostly functional, some other trash
This commit is contained in:
parent
e3050a8ec9
commit
1d2a1b006c
65
build.bat
65
build.bat
@ -1,14 +1,71 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set vulkan_include=C:\VulkanSDK\1.4.304.1\Include
|
||||
:: parse arguments
|
||||
for %%a in (%*) do set "%%a=1"
|
||||
if not "%msvc%"=="1" if not "%clang%"=="1" set clang=1
|
||||
if not "%release%"=="1" set debug=1
|
||||
if "%debug%"=="1" set release=0 && echo [debug mode]
|
||||
if "%release%"=="1" set debug=0 && echo [release mode]
|
||||
if "%clang%"=="1" set msvc=0 && echo [clang compiler]
|
||||
if "%msvc%"=="1" set clang=0 && echo [msvc compiler]
|
||||
if not "%directx%"=="1" if not "%vulkan%"=="1" set vulkan=1
|
||||
if "%vulkan%"=="1" set directx=0 && echo [vulkan backend]
|
||||
if "%directx%"=="1" set vulkan=0 && echo [directx backend]
|
||||
if "%~1"=="" echo [default build, building debug] && set debug=1
|
||||
|
||||
if "%msvc%"=="1" (
|
||||
echo [error: msvc currently unsupported]
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%vulkan%"=="1" echo test
|
||||
if "%vulkan%"=="1" set clang_renderer_flag=-DSTG_VULKAN_RENDERER
|
||||
|
||||
set vulkan_include=C:\VulkanSDK\1.4.304.1\Include
|
||||
|
||||
set out_name=Gears.exe
|
||||
|
||||
echo %clang_renderer_flag%
|
||||
|
||||
set clang_out=-o
|
||||
set clang_compiler=clang
|
||||
set clang_include=-I..\src\ -I..\external\ -I%vulkan_include%
|
||||
set clang_src=..\src\entry_windows.c .\vma.o
|
||||
set clang_link=-luser32 -lkernel32 -lGdi32
|
||||
set clang_common=-fuse-ld=lld-link %clang_include% %clang_link% %clang_renderer_flag% --target=x86_64-pc-windows-msvc -ferror-limit=50 -std=c99 -D_USE_MATH_DEFINES -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-microsoft-enum-forward-reference -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis
|
||||
set clang_debug=%clang_compiler% %clang_src% -g -O0 -DBUILD_DEBUG=1 %clang_common%
|
||||
set clang_release=%clang_compiler% %clang_src% -O2 %clang_common%
|
||||
|
||||
set vma_obj=vma.obj
|
||||
set clang_vma_compiler=clang++
|
||||
set clang_vma_include=-I..\external\vma\
|
||||
set clang_vma_common=%clang_vma_include% -Wl --target=x86_64-pc-windows-msvc -fuse-ld=lld-link -Wno-everything -D_USE_MATH_DEFINES -c -std=c++20 -I%vulkan_include%
|
||||
set clang_vma_debug=%clang_vma_compiler% ..\external\vma\vma.cpp -g -O0 %clang_vma_common%
|
||||
set clang_vma_release=%clang_vma_compiler% -O2 %clang_vma_common%
|
||||
|
||||
if "%clang%"=="1" set compile_debug=%clang_debug%
|
||||
if "%clang%"=="1" set compile_release=%clang_release%
|
||||
if "%clang%"=="1" set compile_vma_debug=%clang_vma_debug%
|
||||
if "%clang%"=="1" set compile_vma_release=%clang_vma_release%
|
||||
if "%clang%"=="1" set out=%clang_out%
|
||||
|
||||
if "%debug%"=="1" set compile=%compile_debug%
|
||||
if "%debug%"=="1" set compile_vma=%compile_vma_debug%
|
||||
if "%release%"=="1" set compile=%compile_release%
|
||||
if "%release%"=="1" set compile_vma=%compile_vma_release%
|
||||
|
||||
set linker_flags=-incremental:no -opt:ref User32.lib kernel32.lib
|
||||
set vma_src=..\external\vma\vma.cpp
|
||||
set game_src=..\src\entry_windows.c
|
||||
set vma_obj=.\vma.obj
|
||||
|
||||
mkdir build
|
||||
if not exist ".\build" mkdir build
|
||||
pushd build
|
||||
cl /DEBUG /c /I ..\external\vma /I %vulkan_include% /EHsc ..\external\vma\vma.cpp
|
||||
cl /DEBUG /I ..\external /I %vulkan_include% -DBUILD_DEBUG -DSTG_VULKAN_RENDERER ..\src\entry_windows.c %vma_obj% /link %linker_flags%
|
||||
echo vma
|
||||
%compile_vma%
|
||||
echo game
|
||||
echo %compile%
|
||||
%compile%
|
||||
|
||||
popd
|
||||
|
||||
8
build.sh
8
build.sh
@ -44,15 +44,15 @@ glsl_stage_comp="-fshader-stage=comp"
|
||||
glsl_out="-o./shaders/glsl/"
|
||||
|
||||
|
||||
clang_common="${include_flags} -g -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0"
|
||||
clang_common="${include_flags} -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis"
|
||||
clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}"
|
||||
clang_release="$compiler -g -O2 ${clang_common} ${auto_compile_flags}"
|
||||
clang_release="$compiler -O2 ${clang_common} ${auto_compile_flags}"
|
||||
clang_link="-lpthread -lm -lrt -ldl -l:libvma.a"
|
||||
clang_out="-o"
|
||||
|
||||
gcc_common="${include_flags} -std=c99 -fuse-ld=mold -g -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -DVMA_STATIC_VULKAN_FUNCTIONS=0"
|
||||
gcc_common="${include_flags} -std=c99 -fuse-ld=mold -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf"
|
||||
gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common} ${auto_compile_flags}"
|
||||
gcc_release="$compiler -g -O2 ${gcc_common} ${auto_compile_flags}"
|
||||
gcc_release="$compiler -O2 ${gcc_common} ${auto_compile_flags}"
|
||||
gcc_link="-lpthread -lm -lrt -ldl -l:libvma.a -lstdc++"
|
||||
gcc_out="-o"
|
||||
|
||||
|
||||
9
external/vma/vma.cpp
vendored
9
external/vma/vma.cpp
vendored
@ -2,4 +2,13 @@
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#define VMA_VULKAN_VERSION 1003000
|
||||
|
||||
#ifdef __linux__
|
||||
#define VK_USE_PLATFORM_XCB_KHR
|
||||
#elif _WIN32
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#else
|
||||
#error not yet implemented
|
||||
#endif
|
||||
|
||||
#include "vk_mem_alloc.h"
|
||||
|
||||
@ -12,7 +12,7 @@ static Arena *CreateArena(rawptr buffer, isize length)
|
||||
|
||||
static rawptr ArenaAllocAlign(Arena *arena, isize size, isize align)
|
||||
{
|
||||
rawptr ptr;
|
||||
rawptr ptr = NULL;
|
||||
|
||||
uintptr curr_ptr = (uintptr)arena->buffer + (uintptr)arena->pos;
|
||||
uintptr offset = AlignPow2(curr_ptr, align);
|
||||
|
||||
@ -13,7 +13,7 @@ LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM w_param, LPARAM l_
|
||||
Printfln("Window resizing");
|
||||
win32_window.w = LOWORD(l_param);
|
||||
win32_window.h = HIWORD(l_param);
|
||||
//SetRenderResolution(win32_window.w, win32_window.h);
|
||||
SetRenderResolution(win32_window.w, win32_window.h);
|
||||
} break;
|
||||
case WM_DESTROY: // TODO(MA): Probably handle these separately but for now, they're together
|
||||
case WM_CLOSE:
|
||||
@ -156,7 +156,7 @@ b32 _CreateWindow()
|
||||
0,
|
||||
window_class.lpszClassName,
|
||||
"Video Game",
|
||||
(WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME)|WS_VISIBLE,
|
||||
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
|
||||
@ -110,6 +110,19 @@ b32 _BeginFrame()
|
||||
|
||||
if (success)
|
||||
{
|
||||
VkImage curr_img = renderer.vk.sc.imgs[renderer.frame_state.img_ix];
|
||||
|
||||
VkImageSubresourceRange clear_range = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
};
|
||||
VkClearColorValue clear_value = { { 1.0f, 0.0f, 0.0f, 1.0f } };
|
||||
TransitionImageLayout(cmd, renderer.vk.sc.imgs[renderer.frame_state.img_ix], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
vkCmdClearColorImage(cmd, renderer.vk.sc.imgs[renderer.frame_state.img_ix], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_value, 1, &clear_range);
|
||||
|
||||
TransitionImage(cmd, &renderer.vk.sc.draw_img, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
TransitionImage(cmd, &renderer.vk.sc.depth_img, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL);
|
||||
|
||||
@ -197,7 +210,6 @@ b32 _FinishFrame()
|
||||
vkCmdEndRendering(cmd);
|
||||
|
||||
TransitionImage(cmd, &renderer.vk.sc.draw_img, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
TransitionImageLayout(cmd, curr_img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
|
||||
VkExtent2D extent = {
|
||||
.width = renderer.vk.sc.extent.width,
|
||||
@ -621,7 +633,7 @@ device_info.queueCreateInfoCount = count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert(InitVkDeviceFunctions(), "Failed to initialize device functions");
|
||||
Assert(InitVkDeviceFunctions(), "Failed to initialize device functions");
|
||||
vkGetDeviceQueue(renderer.vk.device, queues->graphics, 0, &queues->graphics_queue);
|
||||
vkGetDeviceQueue(renderer.vk.device, queues->transfer, 0, &queues->transfer_queue);
|
||||
success = true;
|
||||
@ -745,6 +757,7 @@ static b32 InitVkDeviceFunctions() {
|
||||
INIT_DEV_FN(vkQueuePresentKHR);
|
||||
INIT_DEV_FN(vkCmdDraw);
|
||||
INIT_DEV_FN(vkDeviceWaitIdle);
|
||||
INIT_DEV_FN(vkCmdClearColorImage);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1368,7 +1381,7 @@ const char *VkResultStr(VkResult result)
|
||||
}
|
||||
}
|
||||
|
||||
static VkBool32 DebugCallback(
|
||||
static VKAPI_ATTR VkBool32 DebugCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||
VkDebugUtilsMessageTypeFlagsEXT message_type,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
|
||||
|
||||
@ -136,6 +136,7 @@ VK_DECLARE(vkDestroyShaderModule);
|
||||
VK_DECLARE(vkQueuePresentKHR);
|
||||
VK_DECLARE(vkCmdDraw);
|
||||
VK_DECLARE(vkDeviceWaitIdle);
|
||||
VK_DECLARE(vkCmdClearColorImage);
|
||||
|
||||
// Vulkan Functions END
|
||||
|
||||
@ -269,7 +270,7 @@ typedef struct {
|
||||
|
||||
// Debug
|
||||
static b32 VLayersSupported();
|
||||
static VkBool32 DebugCallback(
|
||||
static VKAPI_ATTR VkBool32 DebugCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||
VkDebugUtilsMessageTypeFlagsEXT message_types,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
|
||||
@ -369,5 +370,5 @@ void _DestroyRenderer();
|
||||
static b32 _BeginFrame();
|
||||
static void _DrawTriangle();
|
||||
static b32 _FinishFrame();
|
||||
static void _SetRenderSize(u32 x, u32 y);
|
||||
static void _SetRenderResolution(u32 x, u32 y);
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ static VkDebugUtilsMessengerCreateInfoEXT debug_msg_info = {
|
||||
.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 = DebugCallback,
|
||||
.pfnUserCallback = (PFN_vkDebugUtilsMessengerCallbackEXT)DebugCallback,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user