macos support
This commit is contained in:
parent
22aa0dd60e
commit
1575b3053a
32
Makefile
32
Makefile
@ -7,15 +7,19 @@ OBJARCH = elf64-x86-64
|
||||
|
||||
UNAME := $(shell uname -s)
|
||||
|
||||
OPT += -O3 -march=x86-64-v3
|
||||
OPT += -Os
|
||||
OPT += -march=core-avx2
|
||||
|
||||
DEBUG = -g
|
||||
|
||||
CSTD = -std=gnu23
|
||||
CXXSTD = -std=gnu++23
|
||||
CSTD = -std=gnu17
|
||||
CXXSTD = -std=gnu++20
|
||||
CFLAGS += -Wall -Werror
|
||||
CFLAGS += -Wfatal-errors
|
||||
CFLAGS += -Wno-error=unused-variable -Wno-error=unused-but-set-variable
|
||||
CFLAGS += -Wno-error=unused-variable
|
||||
#CFLAGS += -Wno-error=unused-but-set-variable
|
||||
CFLAGS += -Wno-format-security
|
||||
CFLAGS += -Wno-format
|
||||
CFLAGS += -Wno-error=unused-function
|
||||
CFLAGS += -Wno-error=array-bounds
|
||||
CFLAGS += -Wno-unknown-pragmas
|
||||
@ -34,7 +38,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
|
||||
@ -42,6 +46,9 @@ 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 \
|
||||
@ -56,8 +63,6 @@ endif
|
||||
|
||||
OBJS = \
|
||||
src/main.o \
|
||||
src/view.o \
|
||||
src/volk/volk.o \
|
||||
src/file.o \
|
||||
src/pack.o \
|
||||
src/dds/validate.o \
|
||||
@ -70,7 +75,6 @@ OBJS = \
|
||||
src/renpy/interact.o \
|
||||
src/audio.o
|
||||
|
||||
ifeq ($(UNAME),Linux)
|
||||
ZLIB = ../zlib-1.3.2
|
||||
CFLAGS += -I$(ZLIB)
|
||||
OBJS += \
|
||||
@ -82,14 +86,18 @@ OBJS += \
|
||||
$(ZLIB)/zutil.o \
|
||||
$(ZLIB)/crc32.o \
|
||||
$(ZLIB)/adler32.o
|
||||
|
||||
ifneq ($(UNAME),Darwin)
|
||||
OBJS += src/volk/volk.o
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME),Darwin)
|
||||
LIBS = \
|
||||
../SDL3-dist/lib/libSDL3.a
|
||||
../SDL3-dist/lib/libSDL3.a \
|
||||
../opus-dist/lib/libopus.a
|
||||
else
|
||||
LIBS = \
|
||||
../SDL3-dist/lib64/libSDL3.a \
|
||||
../SDL3-dist/lib64/libSDL3.a \
|
||||
../opus-dist/lib/libopus.a
|
||||
endif
|
||||
|
||||
@ -122,8 +130,8 @@ all: main
|
||||
main: $(OBJS) $(LIBS)
|
||||
$(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
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "vulkan/vulkan.h"
|
||||
#else
|
||||
#include "volk/volk.h"
|
||||
#endif
|
||||
|
||||
#include "collada/types.h"
|
||||
#include "collada/instance_types.h"
|
||||
@ -49,7 +53,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 = 3;
|
||||
static constexpr int shaderVariantCount = 2;
|
||||
static constexpr uint32_t maxJointsCount = 128;
|
||||
|
||||
// externally initialized, opaque handle
|
||||
|
||||
@ -2,8 +2,13 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#ifdef __APPLE__
|
||||
#include "vulkan/vulkan.h"
|
||||
#else
|
||||
#include "volk/volk.h"
|
||||
#endif
|
||||
|
||||
#include "dds/dds.h"
|
||||
|
||||
namespace dds {
|
||||
inline constexpr VkFormat dxgi_to_vulkan(DXGI_FORMAT dxgiFormat)
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "directxmath/directxmath.h"
|
||||
#ifdef __APPLE__
|
||||
#include "vulkan/vulkan.h"
|
||||
#else
|
||||
#include "volk/volk.h"
|
||||
#endif
|
||||
|
||||
#include "directxmath/directxmath.h"
|
||||
|
||||
#include "vulkan_helper.h"
|
||||
#include "minecraft/vulkan/per_world.h"
|
||||
|
||||
@ -6,6 +6,12 @@
|
||||
#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)
|
||||
{
|
||||
@ -37,7 +43,7 @@ namespace collada::scene {
|
||||
if (ret != 0)
|
||||
break;
|
||||
|
||||
if (statbuf.st_mtim.tv_sec != imageStats[i].mtime.tv_sec || statbuf.st_mtim.tv_nsec != imageStats[i].mtime.tv_nsec) {
|
||||
if (MTIME(statbuf).tv_sec != imageStats[i].mtime.tv_sec || MTIME(statbuf).tv_nsec != imageStats[i].mtime.tv_nsec) {
|
||||
if (statbuf.st_size != size) {
|
||||
size = statbuf.st_size;
|
||||
usleep(500);
|
||||
@ -48,8 +54,8 @@ namespace collada::scene {
|
||||
reload = true;
|
||||
vulkan.destroy_image(i);
|
||||
vulkan.load_image(i, imageStats[i].filenameTGA);
|
||||
imageStats[i].mtime.tv_sec = statbuf.st_mtim.tv_sec;
|
||||
imageStats[i].mtime.tv_nsec = statbuf.st_mtim.tv_nsec;
|
||||
imageStats[i].mtime.tv_sec = MTIME(statbuf).tv_sec;
|
||||
imageStats[i].mtime.tv_nsec = MTIME(statbuf).tv_nsec;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4,7 +4,12 @@
|
||||
#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"
|
||||
@ -370,13 +375,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,
|
||||
@ -770,7 +775,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))
|
||||
}
|
||||
@ -805,6 +810,7 @@ namespace collada::scene {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
VkPipelineShaderStageCreateInfo geometryShaderStages[3]{
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
@ -825,6 +831,7 @@ namespace collada::scene {
|
||||
.pName = "PSGeometryMain"
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
VkPipelineShaderStageCreateInfo shadowShaderStages[2]{
|
||||
{
|
||||
@ -972,6 +979,7 @@ namespace collada::scene {
|
||||
};
|
||||
|
||||
// geometry
|
||||
/*
|
||||
pipelineCreateInfos[i * shaderVariantCount + 2] = {
|
||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||
.pNext = &renderingCreateInfo,
|
||||
@ -987,6 +995,7 @@ namespace collada::scene {
|
||||
.pDynamicState = &dynamicState,
|
||||
.layout = pipelineLayout
|
||||
};
|
||||
*/
|
||||
};
|
||||
|
||||
pipelines = NewM<VkPipeline>(pipelineCount);
|
||||
|
||||
@ -2,7 +2,12 @@
|
||||
#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"
|
||||
|
||||
27
src/main.cpp
27
src/main.cpp
@ -1,7 +1,12 @@
|
||||
#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"
|
||||
@ -16,19 +21,12 @@
|
||||
#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 };
|
||||
@ -89,6 +87,7 @@ 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)
|
||||
{
|
||||
@ -99,6 +98,7 @@ 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,7 +363,10 @@ 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,
|
||||
@ -382,7 +385,9 @@ int main()
|
||||
};
|
||||
VK_CHECK(vkCreateInstance(&instanceCreateInfo, nullptr, &instance));
|
||||
|
||||
#ifndef __APPLE__
|
||||
volkLoadInstance(instance);
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// physical device and queue family index
|
||||
@ -484,7 +489,7 @@ int main()
|
||||
.dynamicRendering = true,
|
||||
};
|
||||
VkPhysicalDeviceFeatures enabledFeatures{
|
||||
.geometryShader = true,
|
||||
//.geometryShader = true,
|
||||
.samplerAnisotropy = true,
|
||||
};
|
||||
constexpr uint32_t enabledExtensionCount = 1;
|
||||
@ -1050,7 +1055,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,
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#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"
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#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"
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
#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"
|
||||
|
||||
@ -3,7 +3,13 @@
|
||||
#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"
|
||||
|
||||
@ -2,4 +2,4 @@ OPT = -O2
|
||||
CFLAGS = -I../include
|
||||
|
||||
pack_file: pack_file.cpp
|
||||
g++ -o $@ $(OPT) $(CFLAGS) $^
|
||||
g++ -std=c++11 -o $@ $(OPT) $(CFLAGS) $^
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user