Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Labeler Configuration
# Labels PRs based on changed files using actions/labeler@v5 syntax

CI/CD:
'CI/CD':
- changed-files:
- any-glob-to-any-file: '.github/workflows/**/*'

Expand All @@ -17,7 +17,7 @@ Vendor:
- 'Vendor/**/*'
- '.gitmodules'

AI Agents:
'AI Agents':
- changed-files:
- any-glob-to-any-file:
- '.agents/**/*'
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get changed files
id: changed-files
Expand Down Expand Up @@ -46,7 +48,19 @@ jobs:
}

- name: Commit changes
if: steps.changed-files.outputs.any_changed == 'true'
if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'push'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Fix CI: Automated Clang-Format"

- name: Verify Clang-Format on Pull Requests
if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request'
shell: pwsh
run: |
$status = git status --porcelain
if ($status) {
Write-Error "Clang-Format check failed! Code formatting issues detected. Please run clang-format locally."
git diff
exit 1
}

5 changes: 3 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Pull Request Labeler

on:
- pull_request
- pull_request_target

jobs:
label:
runs-on: windows-latest
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Binaries
Bin/
Bin-Intermediate/
Build_Release/
Build_Development/
**/build/
**/bin/
**/obj/
Expand Down Expand Up @@ -33,8 +35,14 @@ recent_projects.txt
.idea/
.Rider*/

# Xcode / Mac IDE
*.xcodeproj/
*.xcworkspace/
*.xe

# Mac
.DS_Store
TimeEditor/Info.plist


# Sandbox
Expand Down
3 changes: 2 additions & 1 deletion Engine/Include/Renderer/GraphicsAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum class GraphicsAPI
OpenGL,
OpenGLES,
Vulkan,
DirectX11
DirectX11,
Metal
};
}
31 changes: 31 additions & 0 deletions Engine/Include/Renderer/Metal/MetalFramebuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include "Renderer/Framebuffer.hpp"

namespace TE
{

class MetalFramebuffer : public Framebuffer
{
public:
MetalFramebuffer(const FramebufferSpecification &spec);
virtual ~MetalFramebuffer();

void Invalidate();

virtual void Bind() override;
virtual void Unbind() override;
virtual void Resize(uint32_t width, uint32_t height) override;

virtual uint32_t GetColorAttachmentRendererID() const override { return 0; }
virtual const FramebufferSpecification &GetSpecification() const override { return m_Specification; }

void *GetColorTexture() const { return m_ColorTexture; }

private:
void *m_ColorTexture = nullptr;
void *m_DepthTexture = nullptr;
FramebufferSpecification m_Specification;
};

} // namespace TE
24 changes: 24 additions & 0 deletions Engine/Include/Renderer/Metal/MetalIndexBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "Renderer/IndexBuffer.hpp"

namespace TE
{
class MetalIndexBuffer : public IndexBuffer
{
public:
MetalIndexBuffer(uint32_t *indices, uint32_t count);
virtual ~MetalIndexBuffer();

virtual void Bind() const override;
virtual void Unbind() const override;
virtual void SetData(uint32_t *indices, uint32_t count) const override;

virtual uint32_t GetCount() const override { return m_Count; }
void *GetBuffer() const { return m_Buffer; }

private:
void *m_Buffer = nullptr;
uint32_t m_Count = 0;
};
} // namespace TE
32 changes: 32 additions & 0 deletions Engine/Include/Renderer/Metal/MetalRendererAPI.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once
#include "Renderer/RendererAPI.hpp"

namespace TE
{

class MetalRendererAPI : public RendererAPI
{
public:
virtual ~MetalRendererAPI() override = default;

virtual void Init() override;
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
virtual void SetClearColor(const glm::vec4 &color) override;
virtual void Clear() override;
virtual void DrawIndexed(uint32_t vao, uint32_t indexCount) override;
virtual void SetBlendMode(int blendMode) override;

virtual bool LoadLoader(void *(*loadProc)(const char *)) override;
virtual std::string GetVersionString() override;
virtual std::string GetGPUVendor() override;
virtual std::string GetGPURenderer() override;

virtual void GetViewport(int *viewport) override;
virtual void GetClearColor(float *color) override;
virtual void ReadPixelsRGBA(int x, int y, int width, int height, void *outPixels) override;
virtual void SetBlendFunc(BlendFactor src, BlendFactor dst) override;
virtual void SetBlendFuncSeparate(BlendFactor srcRGB, BlendFactor dstRGB, BlendFactor srcAlpha,
BlendFactor dstAlpha) override;
};

} // namespace TE
30 changes: 30 additions & 0 deletions Engine/Include/Renderer/Metal/MetalShader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "Renderer/Shader.hpp"

namespace TE
{
class MetalShader : public Shader
{
public:
MetalShader(const std::string &vertexSrc, const std::string &fragmentSrc);
MetalShader(const std::string &computeSrc);
virtual ~MetalShader();

virtual void Bind() const override;
virtual void Unbind() const override;

virtual void SetUniformMat4(const std::string &name, const glm::mat4 &value) override;
virtual void SetUniform4f(const std::string &name, const glm::vec4 &value) override;
virtual void SetUniform3f(const std::string &name, const glm::vec3 &value) override;
virtual void SetUniform2f(const std::string &name, const glm::vec2 &value) override;
virtual void SetUniform1f(const std::string &name, float value) override;
virtual void SetUniform1i(const std::string &name, int value) override;

void *GetLibrary() const { return m_Library; }

private:
void *m_Library = nullptr;
void *m_PipelineState = nullptr;
};
} // namespace TE
28 changes: 28 additions & 0 deletions Engine/Include/Renderer/Metal/MetalVertexArray.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "Renderer/VertexArray.hpp"

namespace TE
{
class MetalVertexArray : public VertexArray
{
public:
MetalVertexArray();
virtual ~MetalVertexArray();

virtual void Bind() const override;
virtual void Unbind() const override;

virtual void AddVertexBuffer(VertexBuffer *vertexBuffer) override;
virtual void SetIndexBuffer(IndexBuffer *indexBuffer) override;

virtual uint32_t GetRendererID() const override { return 0; }

VertexBuffer *GetVertexBuffer() const { return m_VertexBuffer; }
IndexBuffer *GetIndexBuffer() const { return m_IndexBuffer; }

private:
VertexBuffer *m_VertexBuffer = nullptr;
IndexBuffer *m_IndexBuffer = nullptr;
};
} // namespace TE
23 changes: 23 additions & 0 deletions Engine/Include/Renderer/Metal/MetalVertexBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "Renderer/VertexBuffer.hpp"

namespace TE
{
class MetalVertexBuffer : public VertexBuffer
{
public:
MetalVertexBuffer(float *vertices, uint32_t size);
virtual ~MetalVertexBuffer();

virtual void Bind() const override;
virtual void Unbind() const override;
virtual void SetData(float *vertices, uint32_t size) const override;

void *GetBuffer() const { return m_Buffer; }

private:
void *m_Buffer = nullptr;
uint32_t m_Size = 0;
};
} // namespace TE
8 changes: 8 additions & 0 deletions Engine/src/Renderer/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "Renderer/OpenGLES/OpenGLESFramebuffer.hpp"
#endif

#ifdef TE_SUPPORT_METAL
#include "Renderer/Metal/MetalFramebuffer.hpp"
#endif

namespace TE
{

Expand All @@ -24,6 +28,10 @@ std::shared_ptr<Framebuffer> Framebuffer::Create(const FramebufferSpecification
#if defined(TE_PLATFORM_MOBILE)
case GraphicsAPI::OpenGLES:
return std::make_shared<OpenGLESFramebuffer>(spec);
#endif
#ifdef TE_SUPPORT_METAL
case GraphicsAPI::Metal:
return std::make_shared<MetalFramebuffer>(spec);
#endif
default:
break;
Expand Down
7 changes: 7 additions & 0 deletions Engine/src/Renderer/IndexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#ifdef TE_SUPPORT_VULKAN
#include "Renderer/Vulkan/VulkanIndexBuffer.hpp"
#endif
#ifdef TE_SUPPORT_METAL
#include "Renderer/Metal/MetalIndexBuffer.hpp"
#endif

namespace TE
{
Expand All @@ -38,6 +41,10 @@ IndexBuffer *IndexBuffer::Create(uint32_t *indices, uint32_t Count)
#ifdef TE_SUPPORT_DIRECTX11
case GraphicsAPI::DirectX11:
return new DirectX11IndexBuffer(indices, Count);
#endif
#ifdef TE_SUPPORT_METAL
case GraphicsAPI::Metal:
return new MetalIndexBuffer(indices, Count);
#endif
default:
return nullptr;
Expand Down
67 changes: 67 additions & 0 deletions Engine/src/Renderer/Metal/MetalFramebuffer.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "Renderer/Metal/MetalFramebuffer.hpp"
#include "Core/Log.h"

#ifdef TE_SUPPORT_METAL
#import <Metal/Metal.h>
#endif

namespace TE
{

MetalFramebuffer::MetalFramebuffer(const FramebufferSpecification &spec)
: m_Specification(spec)
{
Invalidate();
}

MetalFramebuffer::~MetalFramebuffer()
{
#ifdef TE_SUPPORT_METAL
if (m_ColorTexture)
{
id<MTLTexture> tex = (__bridge_transfer id<MTLTexture>)m_ColorTexture;
tex = nil;
m_ColorTexture = nullptr;
}
if (m_DepthTexture)
{
id<MTLTexture> tex = (__bridge_transfer id<MTLTexture>)m_DepthTexture;
tex = nil;
m_DepthTexture = nullptr;
}
#endif
}

void MetalFramebuffer::Invalidate()
{
#ifdef TE_SUPPORT_METAL
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
if (!device || m_Specification.Width == 0 || m_Specification.Height == 0)
return;

MTLTextureDescriptor *colorDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:m_Specification.Width
height:m_Specification.Height
mipmapped:NO];
colorDesc.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
id<MTLTexture> colorTex = [device newTextureWithDescriptor:colorDesc];
m_ColorTexture = (__bridge_retained void *)colorTex;
#endif
}

void MetalFramebuffer::Bind()
{
}

void MetalFramebuffer::Unbind()
{
}

void MetalFramebuffer::Resize(uint32_t width, uint32_t height)
{
m_Specification.Width = width;
m_Specification.Height = height;
Invalidate();
}

} // namespace TE
Loading
Loading