Skip to content

Commit bfad2ed

Browse files
committed
Cleanup headers and added more forward declarations
1 parent e4b7e53 commit bfad2ed

5 files changed

Lines changed: 38 additions & 16 deletions

File tree

lib/API/MTL/MTLDescriptorHeap.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#define IR_RUNTIME_METALCPP
21
#include "MTLDescriptorHeap.h"
3-
#include "metal_irconverter_runtime.h"
2+
#include "MetalIRConverter.h"
43

54
using namespace offloadtest;
65

@@ -41,6 +40,11 @@ MTLDescriptorHeap::create(MTL::Device *Device,
4140
return std::make_unique<MTLDescriptorHeap>(Desc, Buf);
4241
}
4342

43+
MTLDescriptorHeap::~MTLDescriptorHeap() {
44+
if (Buffer)
45+
Buffer->release();
46+
}
47+
4448
MTLGPUDescriptorHandle
4549
MTLDescriptorHeap::getGPUDescriptorHandleForHeapStart() const {
4650
return MTLGPUDescriptorHandle{Buffer->gpuAddress()};

lib/API/MTL/MTLDescriptorHeap.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@
1212
#ifndef OFFLOADTEST_API_MTL_MTLDESCRIPTORHEAP_H
1313
#define OFFLOADTEST_API_MTL_MTLDESCRIPTORHEAP_H
1414

15-
#include "Metal/Metal.hpp"
1615
#include "llvm/Support/Error.h"
1716
#include <memory>
1817

18+
// Forward declarations
19+
namespace MTL {
20+
class Device;
21+
class Buffer;
22+
class RenderCommandEncoder;
23+
class ComputeCommandEncoder;
24+
} // namespace MTL
1925
struct IRDescriptorTableEntry;
2026

2127
namespace offloadtest {
2228
struct MTLGPUDescriptorHandle {
2329
MTLGPUDescriptorHandle &Offset(int32_t OffsetInDescriptors);
2430

25-
MTL::GPUAddress Ptr;
31+
uint64_t Ptr;
2632
};
2733

2834
enum class MTLDescriptorHeapType {
@@ -49,10 +55,7 @@ class MTLDescriptorHeap {
4955

5056
MTLDescriptorHeap(const MTLDescriptorHeapDesc &Desc, MTL::Buffer *Buffer)
5157
: Desc(Desc), Buffer(Buffer) {}
52-
~MTLDescriptorHeap() {
53-
if (Buffer)
54-
Buffer->release();
55-
}
58+
~MTLDescriptorHeap();
5659

5760
MTLGPUDescriptorHandle getGPUDescriptorHandleForHeapStart() const;
5861

lib/API/MTL/MTLTopLevelArgumentBuffer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#define IR_RUNTIME_METALCPP
21
#include "MTLTopLevelArgumentBuffer.h"
3-
#include "metal_irconverter_runtime.h"
42

53
using namespace offloadtest;
64

lib/API/MTL/MTLTopLevelArgumentBuffer.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
#define OFFLOADTEST_API_MTL_MTLTOPLEVELARGUMENTBUFFER_H
1414

1515
#include "MTLDescriptorHeap.h"
16-
#include "Metal/Metal.hpp"
17-
#include "metal_irconverter.h"
18-
#include "llvm/Support/Error.h"
19-
#include <memory>
20-
21-
struct IRDescriptorTableEntry;
16+
#include "MetalIRConverter.h"
2217

2318
namespace offloadtest {
2419
// Manages a Metal buffer that serves as the top-level argument buffer for

lib/API/MTL/MetalIRConverter.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===- MetalIRConverter.h - Metal IR Converter ---------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
#ifndef OFFLOADTEST_API_MTL_METALIRCONVERTER_H
13+
#define OFFLOADTEST_API_MTL_METALIRCONVERTER_H
14+
15+
#pragma push_macro("IR_RUNTIME_METALCPP")
16+
#define IR_RUNTIME_METALCPP
17+
#include "Metal/Metal.hpp"
18+
#include "metal_irconverter.h"
19+
#include "metal_irconverter_runtime.h"
20+
#pragma pop_macro("IR_RUNTIME_METALCPP")
21+
22+
#endif // OFFLOADTEST_API_MTL_METALIRCONVERTER_H

0 commit comments

Comments
 (0)