mirror of
https://github.com/encounter/aurora.git
synced 2025-07-05 04:35:55 +00:00
Replace usages of Log.report with helpers
This commit is contained in:
parent
7760ef8409
commit
37ae1bf9b5
@ -53,7 +53,7 @@ bool g_initialFrame = false;
|
||||
|
||||
AuroraInfo initialize(int argc, char* argv[], const AuroraConfig& config) noexcept {
|
||||
g_config = config;
|
||||
Log.report(LOG_INFO, "Aurora initializing");
|
||||
Log.info("Aurora initializing");
|
||||
if (g_config.appName == nullptr) {
|
||||
g_config.appName = "Aurora";
|
||||
}
|
||||
@ -107,7 +107,7 @@ AuroraInfo initialize(int argc, char* argv[], const AuroraConfig& config) noexce
|
||||
|
||||
imgui::create_context();
|
||||
const auto size = window::get_window_size();
|
||||
Log.report(LOG_INFO, "Using framebuffer size {}x{} scale {}", size.fb_width, size.fb_height, size.scale);
|
||||
Log.info("Using framebuffer size {}x{} scale {}", size.fb_width, size.fb_height, size.scale);
|
||||
if (g_config.imGuiInitCallback != nullptr) {
|
||||
g_config.imGuiInitCallback(&size);
|
||||
}
|
||||
@ -149,14 +149,14 @@ bool begin_frame() noexcept {
|
||||
g_currentView = surfaceTexture.texture.CreateView();
|
||||
break;
|
||||
case wgpu::SurfaceGetCurrentTextureStatus::SuccessSuboptimal: {
|
||||
Log.report(LOG_WARNING, "Surface texture is suboptimal");
|
||||
Log.warn("Surface texture is suboptimal");
|
||||
// Force swapchain recreation
|
||||
const auto size = window::get_window_size();
|
||||
webgpu::resize_swapchain(size.fb_width, size.fb_height, true);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
Log.report(LOG_ERROR, "Failed to get surface texture: {}", magic_enum::enum_name(surfaceTexture.status));
|
||||
Log.error("Failed to get surface texture: {}", magic_enum::enum_name(surfaceTexture.status));
|
||||
return false;
|
||||
}
|
||||
imgui::new_frame(window::get_window_size());
|
||||
|
@ -221,7 +221,7 @@ static PipelineRef find_pipeline(ShaderType type, const PipelineConfig& config,
|
||||
static inline void push_command(CommandType type, const Command::Data& data) {
|
||||
if (g_currentRenderPass == UINT32_MAX)
|
||||
UNLIKELY {
|
||||
Log.report(LOG_WARNING, "Dropping command {}", magic_enum::enum_name(type));
|
||||
Log.warn("Dropping command {}", magic_enum::enum_name(type));
|
||||
return;
|
||||
}
|
||||
g_renderPasses[g_currentRenderPass].commands.push_back({
|
||||
@ -399,7 +399,7 @@ void load_pipeline_cache() {
|
||||
find_pipeline(type, config, [=]() { return model::create_pipeline(g_state.model, config); }, true);
|
||||
} break;
|
||||
default:
|
||||
Log.report(LOG_WARNING, "Unknown pipeline type {}", static_cast<int>(type));
|
||||
Log.warn("Unknown pipeline type {}", static_cast<int>(type));
|
||||
break;
|
||||
}
|
||||
offset += size;
|
||||
|
@ -665,51 +665,50 @@ wgpu::ShaderModule build_shader(const ShaderConfig& config, const ShaderInfo& in
|
||||
}
|
||||
|
||||
if (EnableDebugPrints) {
|
||||
Log.report(LOG_INFO, "Shader config (hash {:x}):", hash);
|
||||
Log.info("Shader config (hash {:x}):", hash);
|
||||
{
|
||||
for (int i = 0; i < config.tevStageCount; ++i) {
|
||||
const auto& stage = config.tevStages[i];
|
||||
Log.report(LOG_INFO, " tevStages[{}]:", i);
|
||||
Log.report(LOG_INFO, " color_a: {}", TevColorArgNames[stage.colorPass.a]);
|
||||
Log.report(LOG_INFO, " color_b: {}", TevColorArgNames[stage.colorPass.b]);
|
||||
Log.report(LOG_INFO, " color_c: {}", TevColorArgNames[stage.colorPass.c]);
|
||||
Log.report(LOG_INFO, " color_d: {}", TevColorArgNames[stage.colorPass.d]);
|
||||
Log.report(LOG_INFO, " alpha_a: {}", TevAlphaArgNames[stage.alphaPass.a]);
|
||||
Log.report(LOG_INFO, " alpha_b: {}", TevAlphaArgNames[stage.alphaPass.b]);
|
||||
Log.report(LOG_INFO, " alpha_c: {}", TevAlphaArgNames[stage.alphaPass.c]);
|
||||
Log.report(LOG_INFO, " alpha_d: {}", TevAlphaArgNames[stage.alphaPass.d]);
|
||||
Log.report(LOG_INFO, " color_op_clamp: {}", stage.colorOp.clamp);
|
||||
Log.report(LOG_INFO, " color_op_op: {}", stage.colorOp.op);
|
||||
Log.report(LOG_INFO, " color_op_bias: {}", stage.colorOp.bias);
|
||||
Log.report(LOG_INFO, " color_op_scale: {}", stage.colorOp.scale);
|
||||
Log.report(LOG_INFO, " color_op_reg_id: {}", stage.colorOp.outReg);
|
||||
Log.report(LOG_INFO, " alpha_op_clamp: {}", stage.alphaOp.clamp);
|
||||
Log.report(LOG_INFO, " alpha_op_op: {}", stage.alphaOp.op);
|
||||
Log.report(LOG_INFO, " alpha_op_bias: {}", stage.alphaOp.bias);
|
||||
Log.report(LOG_INFO, " alpha_op_scale: {}", stage.alphaOp.scale);
|
||||
Log.report(LOG_INFO, " alpha_op_reg_id: {}", stage.alphaOp.outReg);
|
||||
Log.report(LOG_INFO, " kc_sel: {}", stage.kcSel);
|
||||
Log.report(LOG_INFO, " ka_sel: {}", stage.kaSel);
|
||||
Log.report(LOG_INFO, " texCoordId: {}", stage.texCoordId);
|
||||
Log.report(LOG_INFO, " texMapId: {}", stage.texMapId);
|
||||
Log.report(LOG_INFO, " channelId: {}", stage.channelId);
|
||||
Log.info(" tevStages[{}]:", i);
|
||||
Log.info(" color_a: {}", TevColorArgNames[stage.colorPass.a]);
|
||||
Log.info(" color_b: {}", TevColorArgNames[stage.colorPass.b]);
|
||||
Log.info(" color_c: {}", TevColorArgNames[stage.colorPass.c]);
|
||||
Log.info(" color_d: {}", TevColorArgNames[stage.colorPass.d]);
|
||||
Log.info(" alpha_a: {}", TevAlphaArgNames[stage.alphaPass.a]);
|
||||
Log.info(" alpha_b: {}", TevAlphaArgNames[stage.alphaPass.b]);
|
||||
Log.info(" alpha_c: {}", TevAlphaArgNames[stage.alphaPass.c]);
|
||||
Log.info(" alpha_d: {}", TevAlphaArgNames[stage.alphaPass.d]);
|
||||
Log.info(" color_op_clamp: {}", stage.colorOp.clamp);
|
||||
Log.info(" color_op_op: {}", stage.colorOp.op);
|
||||
Log.info(" color_op_bias: {}", stage.colorOp.bias);
|
||||
Log.info(" color_op_scale: {}", stage.colorOp.scale);
|
||||
Log.info(" color_op_reg_id: {}", stage.colorOp.outReg);
|
||||
Log.info(" alpha_op_clamp: {}", stage.alphaOp.clamp);
|
||||
Log.info(" alpha_op_op: {}", stage.alphaOp.op);
|
||||
Log.info(" alpha_op_bias: {}", stage.alphaOp.bias);
|
||||
Log.info(" alpha_op_scale: {}", stage.alphaOp.scale);
|
||||
Log.info(" alpha_op_reg_id: {}", stage.alphaOp.outReg);
|
||||
Log.info(" kc_sel: {}", stage.kcSel);
|
||||
Log.info(" ka_sel: {}", stage.kaSel);
|
||||
Log.info(" texCoordId: {}", stage.texCoordId);
|
||||
Log.info(" texMapId: {}", stage.texMapId);
|
||||
Log.info(" channelId: {}", stage.channelId);
|
||||
}
|
||||
for (int i = 0; i < config.colorChannels.size(); ++i) {
|
||||
const auto& chan = config.colorChannels[i];
|
||||
Log.report(LOG_INFO, " colorChannels[{}]: enabled {} mat {} amb {}", i, chan.lightingEnabled, chan.matSrc,
|
||||
chan.ambSrc);
|
||||
Log.info(" colorChannels[{}]: enabled {} mat {} amb {}", i, chan.lightingEnabled, chan.matSrc, chan.ambSrc);
|
||||
}
|
||||
for (int i = 0; i < config.tcgs.size(); ++i) {
|
||||
const auto& tcg = config.tcgs[i];
|
||||
if (tcg.src != GX_MAX_TEXGENSRC) {
|
||||
Log.report(LOG_INFO, " tcg[{}]: src {} mtx {} post {} type {} norm {}", i, tcg.src, tcg.mtx, tcg.postMtx,
|
||||
tcg.type, tcg.normalize);
|
||||
Log.info(" tcg[{}]: src {} mtx {} post {} type {} norm {}", i, tcg.src, tcg.mtx, tcg.postMtx, tcg.type,
|
||||
tcg.normalize);
|
||||
}
|
||||
}
|
||||
Log.report(LOG_INFO, " alphaCompare: comp0 {} ref0 {} op {} comp1 {} ref1 {}", config.alphaCompare.comp0,
|
||||
config.alphaCompare.ref0, config.alphaCompare.op, config.alphaCompare.comp1, config.alphaCompare.ref1);
|
||||
Log.report(LOG_INFO, " indexedAttributeCount: {}", config.indexedAttributeCount);
|
||||
Log.report(LOG_INFO, " fogType: {}", config.fogType);
|
||||
Log.info(" alphaCompare: comp0 {} ref0 {} op {} comp1 {} ref1 {}", config.alphaCompare.comp0,
|
||||
config.alphaCompare.ref0, config.alphaCompare.op, config.alphaCompare.comp1, config.alphaCompare.ref1);
|
||||
Log.info(" indexedAttributeCount: {}", config.indexedAttributeCount);
|
||||
Log.info(" fogType: {}", config.fogType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1325,7 +1324,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {{{8}{7}
|
||||
uniBufAttrs, sampBindings, texBindings, uniformBindings, vtxOutAttrs,
|
||||
vtxInAttrs, vtxXfrAttrs, fragmentFn, fragmentFnPre, vtxXfrAttrsPre, uniformPre);
|
||||
if (EnableDebugPrints) {
|
||||
Log.report(LOG_INFO, "Generated shader: {}", shaderSource);
|
||||
Log.info("Generated shader: {}", shaderSource);
|
||||
}
|
||||
|
||||
wgpu::ShaderModuleWGSLDescriptor wgslDescriptor{};
|
||||
|
@ -95,8 +95,7 @@ TextureHandle new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mi
|
||||
offset += dataSize;
|
||||
}
|
||||
if (data.size() != UINT32_MAX && offset < data.size()) {
|
||||
Log.report(LOG_WARNING, "new_static_texture_2d[{}]: texture used {} bytes, but given {} bytes", label, offset,
|
||||
data.size());
|
||||
Log.warn("new_static_texture_2d[{}]: texture used {} bytes, but given {} bytes", label, offset, data.size());
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
@ -205,7 +204,7 @@ void write_texture(const TextureRef& ref, ArrayRef<uint8_t> data) noexcept {
|
||||
offset += dataSize;
|
||||
}
|
||||
if (data.size() != UINT32_MAX && offset < data.size()) {
|
||||
Log.report(LOG_WARNING, "write_texture: texture used {} bytes, but given {} bytes", offset, data.size());
|
||||
Log.warn("write_texture: texture used {} bytes, but given {} bytes", offset, data.size());
|
||||
}
|
||||
}
|
||||
} // namespace aurora::gfx
|
||||
|
@ -101,13 +101,13 @@ static std::optional<std::string> remap_controller_layout(std::string mapping) {
|
||||
idx++;
|
||||
}
|
||||
if (entries.contains("rightshoulder") && !entries.contains("leftshoulder")) {
|
||||
Log.report(LOG_INFO, "Remapping GameCube controller layout");
|
||||
Log.info("Remapping GameCube controller layout");
|
||||
entries.insert_or_assign("back", entries["rightshoulder"]);
|
||||
// TODO trigger buttons may differ per platform
|
||||
entries.insert_or_assign("leftshoulder", "b11");
|
||||
entries.insert_or_assign("rightshoulder", "b10");
|
||||
} else if (entries.contains("leftshoulder") && entries.contains("rightshoulder") && entries.contains("back")) {
|
||||
Log.report(LOG_INFO, "Controller has standard layout");
|
||||
Log.info("Controller has standard layout");
|
||||
#if 0
|
||||
auto a = entries["a"sv];
|
||||
entries.insert_or_assign("a"sv, entries["b"sv]);
|
||||
@ -117,7 +117,7 @@ static std::optional<std::string> remap_controller_layout(std::string mapping) {
|
||||
entries.insert_or_assign("x", entries["y"]);
|
||||
entries.insert_or_assign("y", x);
|
||||
} else {
|
||||
Log.report(LOG_ERROR, "Controller has unsupported layout: {}", mapping);
|
||||
Log.error("Controller has unsupported layout: {}", mapping);
|
||||
return {};
|
||||
}
|
||||
for (auto [k, v] : entries) {
|
||||
@ -139,11 +139,11 @@ SDL_JoystickID add_controller(SDL_JoystickID which) noexcept {
|
||||
SDL_free(mapping);
|
||||
if (newMapping) {
|
||||
if (SDL_AddGamepadMapping(newMapping->c_str()) == -1) {
|
||||
Log.report(LOG_ERROR, "Failed to update controller mapping: {}", SDL_GetError());
|
||||
Log.error("Failed to update controller mapping: {}", SDL_GetError());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.report(LOG_ERROR, "Failed to retrieve mapping for controller");
|
||||
Log.error("Failed to retrieve mapping for controller");
|
||||
}
|
||||
}
|
||||
GameController controller;
|
||||
@ -339,14 +339,14 @@ void __PADLoadMapping(aurora::input::GameController* controller) {
|
||||
uint32_t magic = 0;
|
||||
fread(&magic, 1, sizeof(uint32_t), file);
|
||||
if (magic != SBIG('CTRL')) {
|
||||
aurora::input::Log.report(LOG_WARNING, "Invalid controller mapping magic!");
|
||||
aurora::input::Log.warn("Invalid controller mapping magic!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t version = 0;
|
||||
fread(&version, 1, sizeof(uint32_t), file);
|
||||
if (version != 1) {
|
||||
aurora::input::Log.report(LOG_WARNING, "Invalid controller mapping version!");
|
||||
aurora::input::Log.warn("Invalid controller mapping version!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,10 +289,10 @@ static wgpu::BackendType to_wgpu_backend(AuroraBackend backend) {
|
||||
bool initialize(AuroraBackend auroraBackend) {
|
||||
if (!g_instance) {
|
||||
#ifdef WEBGPU_DAWN
|
||||
Log.report(LOG_INFO, "Initializing Dawn");
|
||||
Log.info("Initializing Dawn");
|
||||
dawnProcSetProcs(&dawn::native::GetProcs());
|
||||
#endif
|
||||
Log.report(LOG_INFO, "Creating WGPU instance");
|
||||
Log.info("Creating WGPU instance");
|
||||
wgpu::InstanceDescriptor instanceDescriptor{
|
||||
.capabilities =
|
||||
{
|
||||
@ -306,18 +306,18 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
#endif
|
||||
g_instance = wgpu::CreateInstance(&instanceDescriptor);
|
||||
if (!g_instance) {
|
||||
Log.report(LOG_ERROR, "Failed to create WGPU instance");
|
||||
Log.error("Failed to create WGPU instance");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const wgpu::BackendType backend = to_wgpu_backend(auroraBackend);
|
||||
#ifdef EMSCRIPTEN
|
||||
if (backend != wgpu::BackendType::WebGPU) {
|
||||
Log.report(LOG_WARNING, "Backend type {} unsupported", magic_enum::enum_name(backend));
|
||||
Log.warn("Backend type {} unsupported", magic_enum::enum_name(backend));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
Log.report(LOG_INFO, "Attempting to initialize {}", magic_enum::enum_name(backend));
|
||||
Log.info("Attempting to initialize {}", magic_enum::enum_name(backend));
|
||||
#if 0
|
||||
// D3D12's debug layer is very slow
|
||||
g_dawnInstance->EnableBackendValidation(backend != WGPUBackendType::D3D12);
|
||||
@ -338,7 +338,7 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
};
|
||||
g_surface = g_instance.CreateSurface(&surfaceDescriptor);
|
||||
if (!g_surface) {
|
||||
Log.report(LOG_ERROR, "Failed to create surface");
|
||||
Log.error("Failed to create surface");
|
||||
return false;
|
||||
}
|
||||
{
|
||||
@ -353,16 +353,16 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
if (status == wgpu::RequestAdapterStatus::Success) {
|
||||
g_adapter = std::move(adapter);
|
||||
} else {
|
||||
Log.report(LOG_WARNING, "Adapter request failed: {}", message);
|
||||
Log.warn("Adapter request failed: {}", message);
|
||||
}
|
||||
});
|
||||
const auto status = g_instance.WaitAny(future, 5000000000);
|
||||
if (status != wgpu::WaitStatus::Success) {
|
||||
Log.report(LOG_ERROR, "Failed to create adapter: {}", magic_enum::enum_name(status));
|
||||
Log.error("Failed to create adapter: {}", magic_enum::enum_name(status));
|
||||
return false;
|
||||
}
|
||||
if (!g_adapter) {
|
||||
Log.report(LOG_ERROR, "Failed to create adapter");
|
||||
Log.error("Failed to create adapter");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -377,9 +377,8 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
if (description.IsUndefined()) {
|
||||
description = wgpu::StringView("Unknown");
|
||||
}
|
||||
Log.report(LOG_INFO, "Graphics adapter information\n API: {}\n Device: {} ({})\n Driver: {}",
|
||||
backendName, adapterName, magic_enum::enum_name(g_adapterInfo.adapterType),
|
||||
description);
|
||||
Log.info("Graphics adapter information\n API: {}\n Device: {} ({})\n Driver: {}", backendName, adapterName,
|
||||
magic_enum::enum_name(g_adapterInfo.adapterType), description);
|
||||
|
||||
{
|
||||
wgpu::Limits supportedLimits{};
|
||||
@ -448,7 +447,7 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
deviceDescriptor.SetDeviceLostCallback(
|
||||
wgpu::CallbackMode::AllowSpontaneous,
|
||||
[](const wgpu::Device& device, wgpu::DeviceLostReason reason, wgpu::StringView message) {
|
||||
Log.report(LOG_WARNING, "Device lost: {}", message);
|
||||
Log.warn("Device lost: {}", message);
|
||||
});
|
||||
const auto future = g_adapter.RequestDevice(
|
||||
&deviceDescriptor, wgpu::CallbackMode::WaitAnyOnly,
|
||||
@ -456,12 +455,12 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
if (status == wgpu::RequestDeviceStatus::Success) {
|
||||
g_device = std::move(device);
|
||||
} else {
|
||||
Log.report(LOG_WARNING, "Device request failed: {}", message);
|
||||
Log.warn("Device request failed: {}", message);
|
||||
}
|
||||
});
|
||||
const auto status = g_instance.WaitAny(future, 5000000000);
|
||||
if (status != wgpu::WaitStatus::Success) {
|
||||
Log.report(LOG_ERROR, "Failed to create device: {}", magic_enum::enum_name(status));
|
||||
Log.error("Failed to create device: {}", magic_enum::enum_name(status));
|
||||
return false;
|
||||
}
|
||||
if (!g_device) {
|
||||
@ -493,15 +492,15 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
wgpu::SurfaceCapabilities surfaceCapabilities;
|
||||
const wgpu::Status status = g_surface.GetCapabilities(g_adapter, &surfaceCapabilities);
|
||||
if (status != wgpu::Status::Success) {
|
||||
Log.report(LOG_ERROR, "Failed to get surface capabilities: {}", magic_enum::enum_name(status));
|
||||
Log.error("Failed to get surface capabilities: {}", magic_enum::enum_name(status));
|
||||
return false;
|
||||
}
|
||||
if (surfaceCapabilities.formatCount == 0) {
|
||||
Log.report(LOG_ERROR, "Surface has no formats");
|
||||
Log.error("Surface has no formats");
|
||||
return false;
|
||||
}
|
||||
if (surfaceCapabilities.presentModeCount == 0) {
|
||||
Log.report(LOG_ERROR, "Surface has no present modes");
|
||||
Log.error("Surface has no present modes");
|
||||
return false;
|
||||
}
|
||||
auto surfaceFormat = surfaceCapabilities.formats[0];
|
||||
@ -511,8 +510,8 @@ bool initialize(AuroraBackend auroraBackend) {
|
||||
} else if (surfaceFormat == wgpu::TextureFormat::BGRA8UnormSrgb) {
|
||||
surfaceFormat = wgpu::TextureFormat::BGRA8Unorm;
|
||||
}
|
||||
Log.report(LOG_INFO, "Using surface format {}, present mode {}", magic_enum::enum_name(surfaceFormat),
|
||||
magic_enum::enum_name(presentMode));
|
||||
Log.info("Using surface format {}, present mode {}", magic_enum::enum_name(surfaceFormat),
|
||||
magic_enum::enum_name(presentMode));
|
||||
const auto size = window::get_window_size();
|
||||
g_graphicsConfig = GraphicsConfig{
|
||||
.surfaceConfiguration =
|
||||
|
@ -42,7 +42,7 @@ void resize_swapchain() noexcept {
|
||||
}
|
||||
if (size.scale != g_windowSize.scale) {
|
||||
if (g_windowSize.scale > 0.f) {
|
||||
Log.report(LOG_INFO, "Display scale changed to {}", size.scale);
|
||||
Log.info("Display scale changed to {}", size.scale);
|
||||
}
|
||||
}
|
||||
g_windowSize = size;
|
||||
@ -207,7 +207,7 @@ bool create_window(AuroraBackend backend) {
|
||||
SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, SDL_GetError());
|
||||
g_window = SDL_CreateWindowWithProperties(props);
|
||||
if (g_window == nullptr) {
|
||||
Log.report(LOG_ERROR, "Failed to create window: {}", SDL_GetError());
|
||||
Log.error("Failed to create window: {}", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
set_window_icon();
|
||||
@ -225,7 +225,7 @@ bool create_renderer() {
|
||||
"Failed to set {}: {}", SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, SDL_GetError());
|
||||
g_renderer = SDL_CreateRendererWithProperties(props);
|
||||
if (g_renderer == nullptr) {
|
||||
Log.report(LOG_ERROR, "Failed to create renderer: {}", SDL_GetError());
|
||||
Log.error("Failed to create renderer: {}", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user