mirror of https://github.com/AxioDL/metaforce.git
Windows fixes & memory fixes
This commit is contained in:
parent
3fd0b1f23a
commit
c7f05d0a59
|
@ -112,6 +112,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
|
|||
SCOPED_GRAPHICS_DEBUG_GROUP("CMappableObject::Draw", zeus::skCyan);
|
||||
if (IsDoorType(x0_type)) {
|
||||
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
|
||||
if (m_doorSurface) // TODO
|
||||
for (int s = 0; s < 6; ++s) {
|
||||
DoorSurface& ds = *m_doorSurface;
|
||||
ds.m_surface.draw(colors.first, s * 4, 4);
|
||||
|
|
|
@ -12,6 +12,14 @@
|
|||
#include <memory>
|
||||
#include <regex>
|
||||
|
||||
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
CVar* com_developer = nullptr;
|
||||
|
@ -165,7 +173,13 @@ void CVarManager::serialize() {
|
|||
textOut.WriteString(str);
|
||||
}
|
||||
|
||||
auto* file = fopen(filename.c_str(), "wbe");
|
||||
auto* file = fopen(filename.c_str(),
|
||||
#ifdef _MSC_VER
|
||||
"wb"
|
||||
#else
|
||||
"wbe"
|
||||
#endif
|
||||
);
|
||||
if (file != nullptr) {
|
||||
u32 writeLen = memOut.GetWritePosition();
|
||||
u32 offset = 0;
|
||||
|
@ -182,7 +196,13 @@ std::vector<StoreCVar::CVar> CVarManager::loadCVars(const std::string& filename)
|
|||
CBasics::Sstat st;
|
||||
if (CBasics::Stat(filename.c_str(), &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
|
||||
auto* file = fopen(filename.c_str(), "rbe");
|
||||
auto* file = fopen(filename.c_str(),
|
||||
#ifdef _MSC_VER
|
||||
"rb"
|
||||
#else
|
||||
"rbe"
|
||||
#endif
|
||||
);
|
||||
if (file != nullptr) {
|
||||
|
||||
std::unique_ptr<u8[]> inBuf(new u8[st.st_size]);
|
||||
|
|
|
@ -593,7 +593,9 @@ void CCubeRenderer::EndScene() {
|
|||
|
||||
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, s32 value) {
|
||||
if (option == EDebugOption::PVSState) {
|
||||
xc8_pvs->SetState(EPVSVisSetState(value));
|
||||
if (xc8_pvs) {
|
||||
xc8_pvs->SetState(EPVSVisSetState(value));
|
||||
}
|
||||
} else if (option == EDebugOption::PVSMode) {
|
||||
xc0_pvsMode = EPVSMode(value);
|
||||
} else if (option == EDebugOption::FogDisabled) {
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "CToken.hpp"
|
||||
#include "GCNTypes.hpp"
|
||||
#include "Graphics/CCubeModel.hpp"
|
||||
#include "Graphics/CCubeSurface.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "IObjectStore.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CCubeSurface;
|
||||
class CCubeMaterial;
|
||||
|
||||
enum class CModelFlagBits : u16 {
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
void Execute(ERglTevStage stage) const;
|
||||
|
||||
bool operator<=>(const CTevPass&) const = default;
|
||||
auto operator<=>(const CTevPass&) const = default;
|
||||
};
|
||||
|
||||
extern const CTevPass skPassThru;
|
||||
|
|
|
@ -342,7 +342,7 @@ void CTexture::InvalidateTexMap(GX::TexMapID id) {
|
|||
|
||||
CFactoryFnReturn FTextureFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||
CObjectReference* selfRef) {
|
||||
const auto label = fmt::format("{} {}", tag.type, tag.id);
|
||||
const auto label = fmt::format(FMT_STRING("{} {}"), tag.type, tag.id);
|
||||
return TToken<CTexture>::GetIObjObjectFor(std::make_unique<CTexture>(in, label));
|
||||
}
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
#include "Runtime/Graphics/CModel.hpp"
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
#include <zeus/CAABox.hpp>
|
||||
|
@ -17,7 +18,6 @@ namespace metaforce {
|
|||
class CAreaOctTree;
|
||||
class CLight;
|
||||
class CMetroidModelInstance;
|
||||
class CModel;
|
||||
class CPVSVisSet;
|
||||
class CParticleGen;
|
||||
class CSkinnedModel;
|
||||
|
|
|
@ -704,6 +704,7 @@ void CMain::ShutdownSubsystems() {
|
|||
// Metaforce additions
|
||||
CMoviePlayer::Shutdown();
|
||||
CFont::Shutdown();
|
||||
CFluidPlaneManager::Shutdown();
|
||||
}
|
||||
|
||||
void CMain::Shutdown() {
|
||||
|
|
|
@ -140,4 +140,8 @@ void CFluidPlaneManager::SetupRippleMap() {
|
|||
"Ripple Map");
|
||||
}
|
||||
|
||||
void CFluidPlaneManager::Shutdown() {
|
||||
RippleMapTex.reset();
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
rstl::reserved_vector<CSplashRecord, 32>& SplashRecords() { return x18_splashes; }
|
||||
const CRippleManager& GetRippleManager() const { return x0_rippleManager; }
|
||||
CRippleManager& RippleManager() { return x0_rippleManager; }
|
||||
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -178,7 +178,7 @@ struct WindowSize {
|
|||
uint32_t fb_height;
|
||||
float scale;
|
||||
|
||||
bool operator<=>(const WindowSize& rhs) const = default;
|
||||
auto operator<=>(const WindowSize& rhs) const = default;
|
||||
};
|
||||
enum class MouseButton {
|
||||
None = 0,
|
||||
|
|
|
@ -161,7 +161,7 @@ struct CTevOp {
|
|||
, xc_scale(static_cast<GX::TevScale>(compressedDesc >> 6 & 3))
|
||||
, x10_regId(static_cast<GX::TevRegID>(compressedDesc >> 9 & 3)) {}
|
||||
|
||||
bool operator<=>(const CTevOp&) const = default;
|
||||
auto operator<=>(const CTevOp&) const = default;
|
||||
};
|
||||
struct ColorPass {
|
||||
GX::TevColorArg x0_a;
|
||||
|
@ -177,7 +177,7 @@ struct ColorPass {
|
|||
, x8_c(static_cast<GX::TevColorArg>(compressedDesc >> 10 & 0x1F))
|
||||
, xc_d(static_cast<GX::TevColorArg>(compressedDesc >> 15 & 0x1F)) {}
|
||||
|
||||
bool operator<=>(const ColorPass&) const = default;
|
||||
auto operator<=>(const ColorPass&) const = default;
|
||||
};
|
||||
struct AlphaPass {
|
||||
GX::TevAlphaArg x0_a;
|
||||
|
@ -193,7 +193,7 @@ struct AlphaPass {
|
|||
, x8_c(static_cast<GX::TevAlphaArg>(compressedDesc >> 10 & 0x1F))
|
||||
, xc_d(static_cast<GX::TevAlphaArg>(compressedDesc >> 15 & 0x1F)) {}
|
||||
|
||||
bool operator<=>(const AlphaPass&) const = default;
|
||||
auto operator<=>(const AlphaPass&) const = default;
|
||||
};
|
||||
} // namespace CTevCombiners
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -19,7 +19,7 @@ static std::vector<std::string> g_Args;
|
|||
|
||||
// SDL
|
||||
static SDL_Window* g_window;
|
||||
static WindowSize g_windowSize;
|
||||
WindowSize g_windowSize;
|
||||
|
||||
// GPU
|
||||
using gpu::g_depthBuffer;
|
||||
|
|
|
@ -129,8 +129,17 @@ void set_chan_mat_src(GX::ChannelID id, GX::ColorSrc src) noexcept {
|
|||
gx::g_colorChannels[id - GX::COLOR0A0].matSrc = src;
|
||||
}
|
||||
|
||||
void load_light(GX::LightID id, const Light& light) noexcept { gx::g_lights[id] = light; }
|
||||
void load_light_ambient(GX::LightID id, const zeus::CColor& ambient) noexcept { gx::g_lights[id] = ambient; }
|
||||
static inline u8 light_idx(GX::LightID id) {
|
||||
#ifdef _MSC_VER
|
||||
unsigned long r = 0;
|
||||
_BitScanForward(&r, id);
|
||||
return r;
|
||||
#else
|
||||
return __builtin_ctz(id);
|
||||
#endif
|
||||
}
|
||||
void load_light(GX::LightID id, const Light& light) noexcept { gx::g_lights[light_idx(id)] = light; }
|
||||
void load_light_ambient(GX::LightID id, const zeus::CColor& ambient) noexcept { gx::g_lights[light_idx(id)] = ambient; }
|
||||
void set_light_state(std::bitset<MaxLights> bits) noexcept { gx::g_lightState = bits; }
|
||||
|
||||
namespace gx {
|
||||
|
@ -187,6 +196,9 @@ static inline wgpu::BlendFactor to_blend_factor(metaforce::ERglBlendFactor fac)
|
|||
return wgpu::BlendFactor::Dst;
|
||||
case metaforce::ERglBlendFactor::InvDstColor:
|
||||
return wgpu::BlendFactor::OneMinusDst;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, FMT_STRING("invalid blend factor {}"), fac);
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,6 +220,9 @@ static inline wgpu::CompareFunction to_compare_function(metaforce::ERglEnum func
|
|||
return wgpu::CompareFunction::GreaterEqual;
|
||||
case metaforce::ERglEnum::Always:
|
||||
return wgpu::CompareFunction::Always;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, FMT_STRING("invalid depth fn {}"), func);
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +343,8 @@ wgpu::RenderPipeline build_pipeline(const PipelineConfig& config, const ShaderIn
|
|||
return g_device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
|
||||
ShaderInfo populate_pipeline_config(PipelineConfig& config, GX::Primitive primitive, const BindGroupRanges& ranges) noexcept {
|
||||
ShaderInfo populate_pipeline_config(PipelineConfig& config, GX::Primitive primitive,
|
||||
const BindGroupRanges& ranges) noexcept {
|
||||
for (size_t idx = 0; const auto& item : g_tevStages) {
|
||||
// Copy until disabled TEV stage (indicating end)
|
||||
if (!item) {
|
||||
|
|
|
@ -116,7 +116,7 @@ void queue_surface(const u8* dlStart, u32 dlSize) noexcept {
|
|||
std::vector<u32> indices;
|
||||
|
||||
size_t offset = 0;
|
||||
while (offset < dlSize) {
|
||||
while (offset < dlSize - 6) {
|
||||
const auto header = dlStart[offset];
|
||||
const auto primitive = static_cast<GX::Primitive>(header & 0xF8);
|
||||
const auto vtxFmt = static_cast<VertexFormat>(header & 0x3);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "gpu.hpp"
|
||||
|
||||
#include <aurora/aurora.hpp>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <dawn/native/DawnNative.h>
|
||||
#include <dawn/webgpu_cpp.h>
|
||||
|
@ -9,6 +11,11 @@
|
|||
|
||||
#include "dawn/BackendBinding.hpp"
|
||||
|
||||
// FIXME hack to avoid crash on Windows
|
||||
namespace aurora {
|
||||
extern WindowSize g_windowSize;
|
||||
} // namespace aurora
|
||||
|
||||
namespace aurora::gpu {
|
||||
static logvisor::Module Log("aurora::gpu");
|
||||
|
||||
|
@ -192,18 +199,17 @@ void initialize(SDL_Window* window) {
|
|||
g_swapChain = g_device.CreateSwapChain(nullptr, &descriptor);
|
||||
}
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
SDL_GL_GetDrawableSize(window, &width, &height);
|
||||
const auto size = get_window_size();
|
||||
g_graphicsConfig = GraphicsConfig{
|
||||
.width = static_cast<uint32_t>(width),
|
||||
.height = static_cast<uint32_t>(height),
|
||||
.width = size.fb_width,
|
||||
.height = size.fb_height,
|
||||
.colorFormat = swapChainFormat,
|
||||
.depthFormat = wgpu::TextureFormat::Depth32Float,
|
||||
.msaaSamples = 1, // TODO 4
|
||||
.textureAnistropy = 16,
|
||||
};
|
||||
resize_swapchain(width, height);
|
||||
resize_swapchain(size.fb_width, size.fb_height);
|
||||
g_windowSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue