Apple의 iOS/macOS 전용 그래픽스 API. M1/M2 칩에 최적화. UE5 iOS 빌드에서 사용한다.

 

Apple이 OpenGL을 버린 이유

 

OpenGL

-> Khronos Group이 관리 (Apple이 통제 불가)

-> 크로스플랫폼 설계 -> Apple 하드웨어 최적화 한계

-> OpenGL ES -> 드라이버 오버헤드가 큼

-> iPhone 출시 이후 모바일 GPU 발전 속도를 못 따라감

 

Metal (2014)

-> Aplle이 직접 설계 : Apple 하드웨어에 완전 최적화된 구조

-> A시리즈 / M시리즈 칩과 긴밀하게 통합

-> CPU/GPU 통합 메모리 아키텍처 활용

-> 드라이버 오버헤드 OpenGL 대비 최대 10배 감소

 

Metal의 철학은 Vulkan/DX12와 비슷하다. 드라이버 개입을 줄이고 하드웨어를 직접 제어한다. 다만 Apple 생태계 전용이라는 점에서 차이가 난다.

 

Metal 이 특별한 이유 : Unified Memory Architecture

 

일반 PC ( 분리 메모리 )

- RAM (CPU용)  <--> GPU VRAM(GPU용) -> 느린 PCI-e 버스

- 텍스처 업로드 = 복사 비용 발생

- OpenGL/DX12 -> 분리 메모리 모델 전제 : 업로드 버퍼 따로 만들어야함

 

Apple Silicon ( 통합 메모리 )

- Unified Memory : CPU, GPU 같은 메모리 풀 -> 복사 없이 즉시 공유

- Metal -> 통합 메모리 최적화 설계 -> 제로 카피 텍스처 가능

 

 Metal 핵심 오브젝트  

  Metal DX12 Vulkan
GPU 접근점 MTLDevice ID3D12Device VkDevice
명령 제출 채널 MTLCommandQueue ID3D12CommandQueue VkQueue
명령 기록 버퍼 MTLCommandBuffer ID3D12CommandList VkCommandBuffer
셰이더 + 상태 묶음 MTLRenderPipelineState ID3D12PipelineStateObject
(PSO)
VkPipeline
GPU 메모리 MTLBuffer ( 버퍼 ) ID3D12Resource ( 리소스 ) VkBuffer ( 버퍼 )
텍스처, 이미지 MTLTexture ( 텍스처 ) ID3D12Resource ( 텍스처 ) VkImage ( 이미지 )
셰이더 MTLLibrary ( 모듈 ) ID3DBlob ( 컴파일된 셰이더 ) VkShaderModule ( 모듈 )

 

Metal Shading Language ( MSL )

// 버텍스 셰이더 ( MSL )
#include <metal_stdlib>
using namespace metal;

struct VertexInput
{
    float3 position [[attribute(0]]; // [[시맨틱]]
    float2 texCoord [[attribute(1)]];
};

struct VertexOutput
{
    float4 position [[position]]; // SV_POSIITON과 동일
    float2 texCoord;
};

struct Uniforms
{
    float4x4 modelMatrix;
    float4x4 viewMatrix;
    float4x4 projectionMatrix;
};

vertex VertexOutput vertexShader(VertexInput in [[stage_in]], constant Uniforms& uniforms [[buffer(1)]])
{
    VertexOutput out;
    float4x4 mvp = uniforms.projectionMatrix * uniforms.viewMatrix * uniforms.modelMatrix;
    out.position = mvp * float4(in.position, 1.0);
    out.texCoord = in.texCoord;
    return out;
}

// 픽셀(프래그먼트) 셰이더
fragment float4 fragmentShader(VertexOutput in [[stage_in]], texture2d<float> diffuseTexture [[texture(0)]],
sampler textureSampler [[sampler(0)]])
{
    return diffuseTexture.sample(textureSampler, in.texCoord);
    // UE5 TextureSample 노드와 같음
}

 

Metal과 다른 API 셰이더 언어 비교

GLSL (OpenGL) HLSL (DX12) MSL(Metal)
layout(location=0) in vec3 position; : POSITION float3 position; [[attribute(0)]] float3 position;
gl_Position = MVP * vec4(pos,1.0) output.Position = mul(MVP, pos) out.position = MVP * pos
uniform sampler2D t;
texture(t, uv)
Texture2D t;
t.Sample(s, uv)
texture2d<float> t 
t.sample(s, uv)

개념은 동일하고 문법만 다름.

 

UE5와 Metal의 관계

 

UE5 iOS/macOS 빌드 흐름

 

UE5 C++ / Blueprint -> RHI (MetalRHI) -> Metal API 호출. MTLCommandBuffer에 렌더링 명령 기록 -> MSL 셰이더 실행 ( HLSL -> SPIR-V -> MSL 변환 또는 직접 MSL) -> Apple GPU (A/M 시리즈)  -> 화면 출력

 

MoltenVK가 쓰이는 경우

 

Vulkan 코드 -> MoltanVK -> Metal API 변환 ( Apple이 Vulkan을 공식 지원하지 않기 때문 ) -> UE5 Vulkan 코드가 macOS/iOS 에서 실행되는 방법

 

Metal의 독특한 기능들

 

Metal Performance Shaders(MPS)

-> Apple이 제공하는 고도로 최적화된 GPU 커널 라이브러리 ( 행렬 연산, 합성곱, 이미지 처리 등 )

-> Core ML이 GPU 연산에 MPS를 사용

-> A 시리즈의 Neural Engine과 연동

 

MetalFX

-> Apple의 업스케일링 기술 ( NVIDIA DLSS, AMD FSR과 동급 )

-> 낮은 해상도로 렌더링 후 AI로 업스케일

-> Metal Temporal Upscaling

-> Metal Spatial Upscaling

-> UE5 iOS 빌드에서 성능 최적화에 활용 가능

 

Metal Ray Tracing

-> A14 이후 Apple GPU에서 하드웨어 레이 트레이싱 지원

-> DXR, Vulkan Ray Tracing과 동급

-> 모바일에서 레이 트레이싱 가능한 유일한 플랫폼

 

연결되는 단어들

 

MoltenVK : macOS/iOS에서 Vulkan을 Metal로 변환하는 레이어. Apple이 Vulkan을 미지원하는 문제의 해결책. LunarG와 Valve가 개발.

 

MetalFX : Apple의 업스케일링 기술. DLSS/FSR의 Apple 버전. Temporal과 Spatial 두 가지 모드.

 

MSL ( Metal Shading Language ) : Metal의 셰이더 언어. C++14 기반. HLSL/GLSL과 개념은 동일

 

Metal Performance Shaders (MPS) : Apple이 제공하는 최적화된 GPU 연산 라이브러리. 머신러닝, 이미지 처리, 행렬 연산.

 

Tile Memory : 모바일 GPU의 온칩 고속 메모리. Metal의 Render Pass 설계가 이 타일 메모리를 최대한 활용하도록 설계됨.        모바일 전력 효율의 핵심

'Word' 카테고리의 다른 글

WebGL / WebGPU  (0) 2026.07.14
OpenGL ES ( Embedded Systems )  (0) 2026.07.13
Vulkan  (0) 2026.07.09
DirectX/ Direct3D  (0) 2026.07.08
OpenGL ( Open Graphics Library )  (0) 2026.07.07

+ Recent posts