Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmake/TransmuteCommon.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Set the common source files.
file(GLOB TR_COMMON_SOURCE
file(GLOB_RECURSE TR_COMMON_SOURCE
"src/common/*.cpp"
"src/common/**/*.cpp"
)

# Set the common include directories
Expand Down
2 changes: 1 addition & 1 deletion cmake/TransmuteCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT TR_ENABLE_INSPECTOR)
endif()

if(APPLE)
file(GLOB TR_CORE_SOURCE_MM "src/renderer/*.mm")
file(GLOB TR_CORE_SOURCE_MM "src/renderer/*.mm" "src/renderer/metal/*.mm")
list(APPEND TR_CORE_SOURCE ${TR_CORE_SOURCE_MM})
endif()

Expand Down
57 changes: 57 additions & 0 deletions src/common/assert.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <iostream>
#include <common/assert.hpp>
#include <common/compiler.hpp>
#include <common/platform.hpp>

namespace transmute::common
{
#if TR_COMPILER_IS(CLANG) || TR_COMPILER_IS(GCC)
void BreakPoint()
{
#if TR_PLATFORM_IS(X86)
__asm__ __volatile__("int $3\n\t");
#elif TR_PLATFORM_IS(ARM32)
__asm__ __volatile__("bkpt 0");
#elif TR_PLATFORM_IS(ARM64)
__asm__ __volatile__("brk 0xf000");
#elif TR_PLATFORM_IS(LOONGARCH)
__asm__ __volatile__("break 0");
#elif TR_PLATFORM_IS(RISCV)
__asm__ __volatile__("ebreak");
#elif TR_PLATFORM_IS(MIPS)
__asm__ __volatile__("break");
#elif TR_PLATFORM_IS(S390) || TR_PLATFORM_IS(S390X)
__asm__ __volatile__(".word 0x0001");
#elif TR_PLATFORM_IS(PPC) || TR_PLATFORM_IS(PPC64)
__asm__ __volatile__("twge 2,2");
#elif TR_PLATFORM_IS(WASM32) || TR_PLATFORM_IS(WASM64)
EM_ASM(debugger;);
#else
#error "Unsupported platform"
#endif
}

#elif TR_COMPILER_IS(MSVC)
void BreakPoint()
{
__debugbreak();
}

#else
#error "Unsupported compiler"
#endif

void HandleAssertionFailure(const char *file,
const char *function,
int line,
const char *condition)
{
std::cerr << "Assertion failure at " << file << ":" << line << " (" << function
<< "): " << condition;
#if defined(TR_ABORT_ON_ASSERT)
abort();
#else
BreakPoint();
#endif
}
}
10 changes: 10 additions & 0 deletions src/common/assert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

namespace transmute::common
{
void BreakPoint();
void HandleAssertionFailure(const char *file,
const char *function,
int line,
const char *condition);
}
20 changes: 20 additions & 0 deletions src/common/command_buffers/gpu/backend_connection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <common/command_buffers/gpu/backend_connection.hpp>

namespace commandbuffers::gpu
{
BackendConnection::BackendConnection(GPUInstance *instance, GPUBackendType type)
: instance_(instance)
, type_(type)
{
}

GPUBackendType BackendConnection::type() const
{
return type_;
}

GPUInstance *BackendConnection::getInstance() const
{
return instance_;
}
}
28 changes: 28 additions & 0 deletions src/common/command_buffers/gpu/backend_connection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include <vector>
#include <common/utility.hpp>
#include <common/non_movable.hpp>
#include <common/command_buffers/gpu/gpu_base.hpp>
#include <common/command_buffers/gpu/gpu_instance.hpp>
#include <common/command_buffers/gpu/gpu_adapter.hpp>
#include <common/command_buffers/gpu/physical_device.hpp>

namespace commandbuffers::gpu
{
class BackendConnection : public NonMovable
{
public:
BackendConnection(GPUInstance *instance, GPUBackendType type);
virtual ~BackendConnection() = default;

GPUBackendType type() const;
GPUInstance *getInstance() const;

virtual std::vector<Ref<gpu::PhysicalDeviceBase>> discoverPhysicalDevices(const RequestAdapterOptions &) = 0;

private:
GPUInstance *instance_ = nullptr;
GPUBackendType type_;
};
}
Loading