Compare commits

..

4 Commits

Author SHA1 Message Date
c1558d99ee audio: implement stop/fadeout 2026-05-27 21:05:20 -05:00
8203e1f2f4 audio: more tracks 2026-05-27 19:38:53 -05:00
ac6b6138d4 audio: looped tracks 2026-05-27 16:54:51 -05:00
ae0b7526a5 self-compression 2026-05-26 22:50:10 -05:00
13 changed files with 42 additions and 105 deletions

View File

@ -7,19 +7,15 @@ OBJARCH = elf64-x86-64
UNAME := $(shell uname -s)
OPT += -Os
OPT += -march=core-avx2
OPT += -O3 -march=x86-64-v3
DEBUG = -g
CSTD = -std=gnu17
CXXSTD = -std=gnu++20
CSTD = -std=gnu23
CXXSTD = -std=gnu++23
CFLAGS += -Wall -Werror
CFLAGS += -Wfatal-errors
CFLAGS += -Wno-error=unused-variable
#CFLAGS += -Wno-error=unused-but-set-variable
CFLAGS += -Wno-format-security
CFLAGS += -Wno-format
CFLAGS += -Wno-error=unused-variable -Wno-error=unused-but-set-variable
CFLAGS += -Wno-error=unused-function
CFLAGS += -Wno-error=array-bounds
CFLAGS += -Wno-unknown-pragmas
@ -27,9 +23,6 @@ CFLAGS += -fno-strict-aliasing
CFLAGS += -I./include
CFLAGS += -I./data
CFLAGS += -I../SDL3-dist/include
ifeq ($(UNAME),Darwin)
CFLAGS += -I../MoltenVK/MoltenVK/include
endif
CFLAGS += -I../opus-dist/include
CFLAGS += -fpic
CFLAGS += -ffunction-sections
@ -38,7 +31,7 @@ CFLAGS += -fdata-sections
#FLAGS += -fstack-protector -fstack-protector-all -fno-omit-frame-pointer -fsanitize=address
LDFLAGS += -lm
#LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--gc-sections
#-Wl,--print-gc-sections
ifeq ($(UNAME),Linux)
LDFLAGS += -Wl,-z noexecstack
@ -46,9 +39,6 @@ endif
ifeq ($(UNAME),Darwin)
LDFLAGS += -framework Foundation -framework Cocoa -framework IOKit -framework AVFoundation -framework CoreVideo -framework CoreAudio -framework CoreMedia -framework CoreHaptics -framework AudioToolbox -framework GameController -framework ForceFeedback -framework Carbon -framework Metal -framework QuartzCore -framework UniformTypeIdentifiers
LDFLAGS += -lstdc++
#LDFLAGS += ../MoltenVK/MoltenVK/static/MoltenVK.xcframework/macos-arm64_x86_64/libMoltenVK.a
LDFLAGS += -framework IOSurface
LDFLAGS += ../MoltenVK-1.4.0/libMoltenVK.a-x86_64-master.o
endif
# src/collada/scene/vulkan.o \
@ -63,6 +53,8 @@ endif
OBJS = \
src/main.o \
src/view.o \
src/volk/volk.o \
src/file.o \
src/pack.o \
src/dds/validate.o \
@ -75,6 +67,7 @@ OBJS = \
src/renpy/interact.o \
src/audio.o
ifeq ($(UNAME),Linux)
ZLIB = ../zlib-1.3.2
CFLAGS += -I$(ZLIB)
OBJS += \
@ -86,15 +79,19 @@ OBJS += \
$(ZLIB)/zutil.o \
$(ZLIB)/crc32.o \
$(ZLIB)/adler32.o
ifneq ($(UNAME),Darwin)
OBJS += src/volk/volk.o
endif
WORLDS = \
data/minecraft/midnightmeadow/inthash.o \
data/minecraft/grandlecturn/inthash.o
SCENES = \
data/scenes/shadow_test/shadow_test.o \
data/scenes/eidelwind/eidelwind.o
ifeq ($(UNAME),Darwin)
LIBS = \
../SDL3-dist/lib/libSDL3.a \
../opus-dist/lib/libopus.a
../SDL3-dist/lib/libSDL3.a
else
LIBS = \
../SDL3-dist/lib64/libSDL3.a \
@ -127,11 +124,11 @@ all: main
%.opus.bin: %.pcm
./tools/opus_encode $< $@
main: $(OBJS) $(LIBS)
main: $(OBJS) $(LIBS) $(SCENES) $(WORLDS)
$(CC) $(ARCH) $(LDFLAGS) $(FLAGS) $(OPT) $(DEBUG) $^ -o $@
#%.spv: %.hlsl
# ../dxc/bin/dxc -spirv -T lib_6_3 -fspv-target-env=vulkan1.3 $< -Fo $@
%.spv: %.hlsl
../dxc/bin/dxc -spirv -T lib_6_3 -fspv-target-env=vulkan1.3 $< -Fo $@
tool/pack_file: tool/pack_file.cpp
make -C tool pack_file

View File

@ -1,10 +1,6 @@
#pragma once
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "collada/types.h"
#include "collada/instance_types.h"
@ -53,7 +49,7 @@ namespace collada::scene {
static constexpr uint32_t uniformBufferDescriptorCount = maxFrames * perFrameDescriptorCount + constantDescriptorCount;
// +3: linear sampler, shadow sampled image, scene sampled image (array)
static constexpr uint32_t bindingCount = uniformBufferDescriptorCount + 3;
static constexpr int shaderVariantCount = 2;
static constexpr int shaderVariantCount = 3;
static constexpr uint32_t maxJointsCount = 128;
// externally initialized, opaque handle

View File

@ -2,13 +2,8 @@
#include <assert.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "dds/dds.h"
#include "volk/volk.h"
namespace dds {
inline constexpr VkFormat dxgi_to_vulkan(DXGI_FORMAT dxgiFormat)

View File

@ -1,12 +1,7 @@
#pragma once
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "directxmath/directxmath.h"
#include "volk/volk.h"
#include "vulkan_helper.h"
#include "minecraft/vulkan/per_world.h"

View File

@ -6,12 +6,6 @@
#include "new.h"
#include "collada/scene/reload.h"
#ifdef __APPLE__
#define MTIME(s) ((s).st_mtimespec)
#else
#define MTIME(s) ((s).st_mtim)
#endif
namespace collada::scene {
void reload::load_images(types::descriptor const * const descriptor)
{
@ -43,7 +37,7 @@ namespace collada::scene {
if (ret != 0)
break;
if (MTIME(statbuf).tv_sec != imageStats[i].mtime.tv_sec || MTIME(statbuf).tv_nsec != imageStats[i].mtime.tv_nsec) {
if (statbuf.st_mtim.tv_sec != imageStats[i].mtime.tv_sec || statbuf.st_mtim.tv_nsec != imageStats[i].mtime.tv_nsec) {
if (statbuf.st_size != size) {
size = statbuf.st_size;
usleep(500);
@ -54,8 +48,8 @@ namespace collada::scene {
reload = true;
vulkan.destroy_image(i);
vulkan.load_image(i, imageStats[i].filenameTGA);
imageStats[i].mtime.tv_sec = MTIME(statbuf).tv_sec;
imageStats[i].mtime.tv_nsec = MTIME(statbuf).tv_nsec;
imageStats[i].mtime.tv_sec = statbuf.st_mtim.tv_sec;
imageStats[i].mtime.tv_nsec = statbuf.st_mtim.tv_nsec;
}
break;
}

View File

@ -4,12 +4,7 @@
#include <assert.h>
#include <sys/stat.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "collada/inputs.h"
@ -375,13 +370,13 @@ namespace collada::scene {
.binding = 0,
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
.descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT// | VK_SHADER_STAGE_GEOMETRY_BIT
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT
},
{
.binding = 1,
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT// | VK_SHADER_STAGE_GEOMETRY_BIT
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT
},
{
.binding = 2,
@ -775,7 +770,7 @@ namespace collada::scene {
{
VkPushConstantRange pushConstantRanges[1]{
{
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,// | VK_SHADER_STAGE_GEOMETRY_BIT,
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_GEOMETRY_BIT,
.offset = 0,
.size = (sizeof (PushConstant))
}
@ -810,7 +805,6 @@ namespace collada::scene {
}
};
/*
VkPipelineShaderStageCreateInfo geometryShaderStages[3]{
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
@ -831,7 +825,6 @@ namespace collada::scene {
.pName = "PSGeometryMain"
}
};
*/
VkPipelineShaderStageCreateInfo shadowShaderStages[2]{
{
@ -979,7 +972,6 @@ namespace collada::scene {
};
// geometry
/*
pipelineCreateInfos[i * shaderVariantCount + 2] = {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.pNext = &renderingCreateInfo,
@ -995,7 +987,6 @@ namespace collada::scene {
.pDynamicState = &dynamicState,
.layout = pipelineLayout
};
*/
};
pipelines = NewM<VkPipeline>(pipelineCount);

View File

@ -2,12 +2,7 @@
#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "directxmath/directxmath.h"

View File

@ -1,12 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "SDL3/SDL.h"
#include "SDL3/SDL_vulkan.h"
@ -21,12 +16,19 @@
#include "minmax.h"
#include "view.h"
#include "collada/scene.h"
#include "collada/scene/vulkan.h"
#include "minecraft/vulkan.h"
#include "font/outline.h"
#include "renpy/vulkan.h"
#include "renpy/interpreter.h"
#include "renpy/interact.h"
#include "renpy/script.h"
#include "scenes/shadow_test/shadow_test.h"
#include "scenes/eidelwind/eidelwind.h"
#include "audio.h"
VkInstance instance{ VK_NULL_HANDLE };
@ -87,7 +89,6 @@ XMMATRIX currentProjection()
return projection * XMMatrixScaling(-1, -1, 1);
}
/*
XMMATRIX currentView(collada::instance_types::node const & camera_node,
collada::instance_types::node const & camera_target_node)
{
@ -98,7 +99,6 @@ XMMATRIX currentView(collada::instance_types::node const & camera_node,
XMMATRIX view = XMMatrixLookAtLH(eye, at, up);
return view;
}
*/
float theta = 0;
@ -351,8 +351,8 @@ void gamepad_update(view & viewState)
float delta_yaw = rightx * -0.035;
float delta_pitch = righty * -0.035;
//viewState.applyTransform(delta_forward, delta_strafe, delta_elevation,
//delta_yaw, delta_pitch);
viewState.applyTransform(delta_forward, delta_strafe, delta_elevation,
delta_yaw, delta_pitch);
}
}
@ -363,10 +363,7 @@ int main()
SDL_InitFlags init_flags = SDL_INIT_VIDEO | SDL_INIT_GAMEPAD | SDL_INIT_AUDIO;
SDL_CHECK(SDL_Init(init_flags));
SDL_CHECK(SDL_Vulkan_LoadLibrary(NULL));
#ifndef __APPLE__
volkInitialize();
#endif
VkApplicationInfo appInfo{
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
@ -385,9 +382,7 @@ int main()
};
VK_CHECK(vkCreateInstance(&instanceCreateInfo, nullptr, &instance));
#ifndef __APPLE__
volkLoadInstance(instance);
#endif
//////////////////////////////////////////////////////////////////////
// physical device and queue family index
@ -489,7 +484,7 @@ int main()
.dynamicRendering = true,
};
VkPhysicalDeviceFeatures enabledFeatures{
//.geometryShader = true,
.geometryShader = true,
.samplerAnisotropy = true,
};
constexpr uint32_t enabledExtensionCount = 1;
@ -1055,7 +1050,7 @@ int main()
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
//.clearValue{ .color{ 0.0f, 0.0f, 0.2f, 1.0f } }
.clearValue{ .color{ { 0.0f, 0.0f, 0.0f, 0.0f} } }
.clearValue{ .color{ 0.0f, 0.0f, 0.0f, 0.0f } }
};
VkRenderingAttachmentInfo depthRenderingAttachmentInfo{
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,

View File

@ -1,12 +1,7 @@
#include <stdio.h>
#include <string.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "file.h"

View File

@ -1,12 +1,7 @@
#include <stdio.h>
#include <string.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "new.h"

View File

@ -1,11 +1,6 @@
#include <string.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vk_enum_string_helper.h"
#include "dds/validate.h"

View File

@ -3,13 +3,7 @@
#include <assert.h>
#include <string.h>
#ifdef __APPLE__
#include "vulkan/vulkan.h"
#else
#include "volk/volk.h"
#endif
#include "vulkan/vulkan.h"
#include "vulkan/vk_enum_string_helper.h"
#include "minmax.h"

View File

@ -2,4 +2,4 @@ OPT = -O2
CFLAGS = -I../include
pack_file: pack_file.cpp
g++ -std=c++11 -o $@ $(OPT) $(CFLAGS) $^
g++ -o $@ $(OPT) $(CFLAGS) $^