mirror of https://github.com/AxioDL/metaforce.git
Windows fixes
This commit is contained in:
parent
15d60493f2
commit
4ee4963aaf
|
@ -15,7 +15,13 @@ if(MSVC)
|
|||
|
||||
# Shaddup MSVC
|
||||
add_definitions(-DUNICODE=1 -D_UNICODE=1 -D__SSE__=1 -D_CRT_SECURE_NO_WARNINGS=1 -DD_SCL_SECURE_NO_WARNINGS=1
|
||||
/IGNORE:4221 /wd4018 /wd4800 /wd4005 /wd4311 /wd4267 /wd4244 /wd4200 /wd4305 /wd4067 /wd4146 ${VS_DEFINES})
|
||||
-D_SCL_SECURE_NO_DEPRECATE=1 /IGNORE:4221 /wd4018 /wd4800 /wd4005 /wd4311 /wd4267 /wd4244 /wd4200 /wd4305
|
||||
/wd4067 /wd4146 ${VS_DEFINES})
|
||||
|
||||
if(WINDOWS_STORE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
add_definitions(-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
||||
|
||||
|
|
|
@ -558,13 +558,18 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath,
|
|||
#if _WIN32
|
||||
VisiGenPath += _S(".exe");
|
||||
#endif
|
||||
char thrIdx[16];
|
||||
snprintf(thrIdx, 16, "%d", hecl::ClientProcess::GetThreadWorkerIdx());
|
||||
hecl::SystemChar thrIdx[16];
|
||||
hecl::SNPrintf(thrIdx, 16, _S("%d"), hecl::ClientProcess::GetThreadWorkerIdx());
|
||||
hecl::SystemChar parPid[32];
|
||||
#if _WIN32
|
||||
hecl::SNPrintf(parPid, 32, _S("%ullX"), reinterpret_cast<unsigned long long>(GetCurrentProcess()));
|
||||
#else
|
||||
hecl::SNPrintf(parPid, 32, _S("%ullX"), reinterpret_cast<unsigned long long>(getpid()));
|
||||
#endif
|
||||
const hecl::SystemChar* args[] = {VisiGenPath.c_str(),
|
||||
visiIntOut.getAbsolutePath().c_str(),
|
||||
visiIn.getAbsolutePath().c_str(),
|
||||
thrIdx,
|
||||
nullptr};
|
||||
thrIdx, parPid, nullptr};
|
||||
if (0 == hecl::RunProcess(VisiGenPath.c_str(), args))
|
||||
{
|
||||
athena::io::FileReader r(visiIn.getAbsolutePath());
|
||||
|
|
|
@ -125,15 +125,20 @@ struct Application : boo::IApplicationCallback
|
|||
static hecl::SystemChar CwdBuf[1024];
|
||||
hecl::SystemString ExeDir;
|
||||
|
||||
void SetupBasics()
|
||||
{
|
||||
logvisor::RegisterStandardExceptions();
|
||||
logvisor::RegisterConsoleLogger();
|
||||
atSetExceptionHandler(AthenaExc);
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
int wmain(int argc, const boo::SystemChar** argv)
|
||||
#else
|
||||
int main(int argc, const boo::SystemChar** argv)
|
||||
#endif
|
||||
{
|
||||
logvisor::RegisterStandardExceptions();
|
||||
logvisor::RegisterConsoleLogger();
|
||||
atSetExceptionHandler(AthenaExc);
|
||||
SetupBasics();
|
||||
|
||||
if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024))
|
||||
{
|
||||
|
@ -152,7 +157,20 @@ int main(int argc, const boo::SystemChar** argv)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
#if WINAPI_FAMILY && !WINAPI_PARTITION_DESKTOP
|
||||
using namespace Windows::ApplicationModel::Core;
|
||||
|
||||
[Platform::MTAThread]
|
||||
int WINAPIV main(Platform::Array<Platform::String^>^ params)
|
||||
{
|
||||
SetupBasics();
|
||||
urde::Application appCb;
|
||||
auto viewProvider = ref new ViewProvider(appCb, _S("urde"), _S("URDE"), params, false);
|
||||
CoreApplication::Run(viewProvider);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif _WIN32
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -168,3 +186,4 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
|
|||
return wmain(argc+1, booArgv);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ class CModel
|
|||
boo::IGraphicsBufferS* m_staticVbo = nullptr;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
boo::IGraphicsBufferS* m_ibo;
|
||||
boo::IGraphicsBufferS* m_ibo = nullptr;
|
||||
|
||||
public:
|
||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
|
|
@ -1123,21 +1123,26 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
|||
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
/* Index buffer is always static */
|
||||
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, iboData, 4, m_hmdlMeta.indexCount);
|
||||
if (m_hmdlMeta.indexCount)
|
||||
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, iboData, 4, m_hmdlMeta.indexCount);
|
||||
|
||||
if (!m_hmdlMeta.bankCount)
|
||||
{
|
||||
/* Non-skinned models use static vertex buffers shared with CBooModel instances */
|
||||
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
|
||||
m_hmdlMeta.vertStride, m_hmdlMeta.vertCount);
|
||||
if (m_hmdlMeta.vertCount)
|
||||
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
|
||||
m_hmdlMeta.vertStride, m_hmdlMeta.vertCount);
|
||||
m_staticVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, m_hmdlMeta, m_staticVbo, m_ibo);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Skinned models use per-instance dynamic buffers for vertex manipulation effects */
|
||||
size_t vboSz = m_hmdlMeta.vertStride * m_hmdlMeta.vertCount;
|
||||
m_dynamicVertexData.reset(new uint8_t[vboSz]);
|
||||
memmove(m_dynamicVertexData.get(), vboData, vboSz);
|
||||
if (vboSz)
|
||||
{
|
||||
m_dynamicVertexData.reset(new uint8_t[vboSz]);
|
||||
memmove(m_dynamicVertexData.get(), vboData, vboSz);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -25,14 +25,12 @@ static const char* VS =
|
|||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = bu.color;\n"
|
||||
" vtf.pos = bu.xf * vec4(v.posIn.xyz, 1.0);\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.pos = mul(xf, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
|
|
|
@ -26,7 +26,7 @@ static const char* VS =
|
|||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.position = mul(xf * float4(v.posIn.xyz, 1.0));\n"
|
||||
" vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
|
|
|
@ -104,13 +104,12 @@ static const char* BlurVS =
|
|||
" float2 blurDir : BLURDIR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uv = uvIn.xy;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.blurDir = blurDir.xy;\n"
|
||||
" vtf.position = float4(posIn.xyz, 1.0);\n"
|
||||
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ static const char* VS =
|
|||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
|
@ -30,7 +30,7 @@ static const char* VS =
|
|||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn;\n"
|
||||
" vtf.uv = v.uvIn[vertId].xy;\n"
|
||||
" vtf.position = xf * float4(v.posIn[vertId].xyz, 1.0);\n"
|
||||
" vtf.position = mul(xf, float4(v.posIn[vertId].xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
|
@ -38,8 +38,8 @@ static const char* FS =
|
|||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
|
|
|
@ -13,7 +13,7 @@ static const char* VS =
|
|||
" float2 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct RandomStaticUniform\n"
|
||||
"cbuffer RandomStaticUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4 color;\n"
|
||||
" float randOff;\n"
|
||||
|
@ -32,10 +32,10 @@ static const char* VS =
|
|||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = su.color;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.randOff = su.randOff;\n"
|
||||
" vtf.discardThres = su.discardThres;\n"
|
||||
" vtf.randOff = randOff;\n"
|
||||
" vtf.discardThres = discardThres;\n"
|
||||
" vtf.pos = float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
|
|
@ -105,11 +105,15 @@ void CGuiFrame::DisableLights() const
|
|||
|
||||
void CGuiFrame::RemoveLight(CGuiLight* light)
|
||||
{
|
||||
if (m_indexedLights.empty())
|
||||
return;
|
||||
m_indexedLights[light->GetLightId()] = nullptr;
|
||||
}
|
||||
|
||||
void CGuiFrame::AddLight(CGuiLight* light)
|
||||
{
|
||||
if (m_indexedLights.empty())
|
||||
m_indexedLights.resize(8);
|
||||
m_indexedLights[light->GetLightId()] = light;
|
||||
}
|
||||
|
||||
|
|
|
@ -1187,7 +1187,7 @@ CGameArea::MREAHeader CGameArea::VerifyHeader() const
|
|||
return {};
|
||||
|
||||
MREAHeader header;
|
||||
athena::io::MemoryReader r(x110_mreaSecBufs[0].first.get() + 4, INT32_MAX);
|
||||
athena::io::MemoryReader r(x110_mreaSecBufs[0].first.get() + 4, x110_mreaSecBufs[0].second - 4);
|
||||
u32 version = r.readUint32Big();
|
||||
if (!(version & 0x10000))
|
||||
Log.report(logvisor::Fatal, "Attempted to load non-URDE MREA");
|
||||
|
@ -1208,10 +1208,6 @@ CGameArea::MREAHeader CGameArea::VerifyHeader() const
|
|||
header.pathSecIdx = r.readUint32Big();
|
||||
header.arotSecIdx = r.readUint32Big();
|
||||
|
||||
header.secSizes.reserve(header.secCount);
|
||||
for (u32 i=0 ; i<header.secCount ; ++i)
|
||||
header.secSizes.push_back(r.readUint32Big());
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,6 @@ private:
|
|||
u32 visiSecIdx;
|
||||
u32 pathSecIdx;
|
||||
u32 arotSecIdx;
|
||||
std::vector<u32> secSizes;
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 84393676f125f87c443b770738b552015998228d
|
||||
Subproject commit 23a08dcf40456c59ff40710d12241a8a8735fe5e
|
|
@ -313,7 +313,8 @@ std::vector<uint8_t> VISIBuilder::build(const zeus::CAABox& fullAabb,
|
|||
const std::vector<VISIRenderer::Entity>& entities,
|
||||
const std::vector<VISIRenderer::Light>& lights,
|
||||
size_t layer2LightCount,
|
||||
FPercent updatePercent)
|
||||
FPercent updatePercent,
|
||||
ProcessType parentPid)
|
||||
{
|
||||
Log.report(logvisor::Info, "Started!");
|
||||
|
||||
|
@ -321,8 +322,20 @@ std::vector<uint8_t> VISIBuilder::build(const zeus::CAABox& fullAabb,
|
|||
renderCache.m_lightMetaBit = featureCount;
|
||||
|
||||
Progress prog(updatePercent);
|
||||
pid_t parentPid = getppid();
|
||||
auto terminate = [this, parentPid]() { return renderCache.m_renderer.m_terminate || kill(parentPid, 0); };
|
||||
#ifndef _WIN32
|
||||
auto terminate = [this, parentPid]()
|
||||
{
|
||||
return renderCache.m_renderer.m_terminate || (parentPid ? kill(parentPid, 0) : false);
|
||||
};
|
||||
#else
|
||||
auto terminate = [this, parentPid]()
|
||||
{
|
||||
DWORD exitCode = 0;
|
||||
if (!GetExitCodeProcess(parentPid, &exitCode))
|
||||
return renderCache.m_renderer.m_terminate;
|
||||
return renderCache.m_renderer.m_terminate || (parentPid ? exitCode != STILL_ACTIVE : false);
|
||||
};
|
||||
#endif
|
||||
rootNode.buildChildren(0, 1, fullAabb, renderCache, prog, terminate);
|
||||
if (terminate())
|
||||
return {};
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
#include "athena/MemoryWriter.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef _WIN32
|
||||
using ProcessType = HANDLE;
|
||||
#else
|
||||
using ProcessType = pid_t;
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <> struct hash<zeus::CVector3f>
|
||||
|
@ -122,7 +128,8 @@ struct VISIBuilder
|
|||
const std::vector<VISIRenderer::Entity>& entities,
|
||||
const std::vector<VISIRenderer::Light>& lights,
|
||||
size_t layer2LightCount,
|
||||
FPercent updatePercent);
|
||||
FPercent updatePercent,
|
||||
ProcessType parentPid);
|
||||
|
||||
VISIBuilder(VISIRenderer& renderer) : renderCache(renderer) {}
|
||||
};
|
||||
|
|
|
@ -503,6 +503,14 @@ void VISIRenderer::Run(FPercent updatePercent)
|
|||
return;
|
||||
}
|
||||
|
||||
ProcessType parentPid = 0;
|
||||
if (m_argc > 4)
|
||||
#ifdef _WIN32
|
||||
parentPid = ProcessType(wcstoull(m_argv[4], nullptr, 16));
|
||||
#else
|
||||
parentPid = ProcessType(strtoull(m_argv[4], nullptr, 16));
|
||||
#endif
|
||||
|
||||
uint32_t layer2LightCount = 0;
|
||||
{
|
||||
athena::io::FileReader r(m_argv[1]);
|
||||
|
@ -579,7 +587,7 @@ void VISIRenderer::Run(FPercent updatePercent)
|
|||
VISIBuilder builder(*this);
|
||||
std::vector<uint8_t> dataOut = builder.build(m_totalAABB, m_models.size(),
|
||||
m_entities, m_lights, layer2LightCount,
|
||||
m_updatePercent);
|
||||
m_updatePercent, parentPid);
|
||||
if (dataOut.empty())
|
||||
{
|
||||
m_return = 1;
|
||||
|
|
Loading…
Reference in New Issue