Skip to content

Commit 850ff88

Browse files
committed
Sometimes GLView.m's initFrame will be called sooner than kickstart, need to accomodate
1 parent cbeeb56 commit 850ff88

6 files changed

Lines changed: 48 additions & 24 deletions

File tree

backends/gpu/metal/sources/device.m

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "metalunit.h"
44

55
#include <kore3/gpu/device.h>
6+
#include <kore3/gpu/metal.h>
67
#include <kore3/util/align.h>
78

89
#include <kore3/log.h>
@@ -142,23 +143,6 @@ void kore_metal_device_create(kore_gpu_device *device, const kore_gpu_device_wis
142143
create_execution_fence(device);
143144
}
144145

145-
static kore_metal_library_creator_t custom_library_creator = NULL;
146-
147-
void kore_metal_set_library_creator(kore_metal_library_creator_t creator) {
148-
custom_library_creator = creator;
149-
}
150-
151-
id<MTLLibrary> kore_metal_create_library(id<MTLDevice> device) {
152-
if (custom_library_creator != NULL) {
153-
id<MTLLibrary> library = custom_library_creator(device);
154-
if (library != nil) {
155-
return library;
156-
}
157-
}
158-
159-
return [device newDefaultLibrary];
160-
}
161-
162146
void kore_metal_device_destroy(kore_gpu_device *device) {}
163147

164148
void kore_metal_device_set_name(kore_gpu_device *device, const char *name) {}

backends/gpu/metal/sources/metalunit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ CAMetalLayer *getMetalLayer(void);
1414
id getMetalDevice(void);
1515
id getMetalLibrary(void);
1616

17-
typedef id<MTLLibrary> (*kore_metal_library_creator_t)(id<MTLDevice> device);
18-
19-
void kore_metal_set_library_creator(kore_metal_library_creator_t creator);
20-
id<MTLLibrary> kore_metal_create_library(id<MTLDevice> device);
21-
2217
static MTLPixelFormat convert_format(kore_gpu_texture_format format) {
2318
switch (format) {
2419
case KORE_GPU_TEXTURE_FORMAT_UNDEFINED:

backends/system/ios/sources/GLView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <kore3/system.h>
1212

1313
#ifdef KORE_METAL
14-
#include <kore3/metal/library.h>
14+
#include <kore3/gpu/metal.h>
1515
#endif
1616

1717
static const int touchmaxcount = 20;

backends/system/macos/sources/BasicOpenGLView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <kore3/system.h>
77

88
#ifdef KORE_METAL
9-
#include <kore3/metal/library.h>
9+
#include <kore3/gpu/metal.h>
1010
#endif
1111

1212
#ifdef KORE_METAL

includes/kore3/gpu/metal.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef KORE_GPU_METAL_HEADER
2+
#define KORE_GPU_METAL_HEADER
3+
4+
#ifdef KORE_METAL
5+
6+
#import <Metal/Metal.h>
7+
8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif
11+
12+
typedef id<MTLLibrary> (*kore_metal_library_creator_t)(id<MTLDevice> device);
13+
14+
void kore_metal_set_library_creator(kore_metal_library_creator_t creator);
15+
id<MTLLibrary> kore_metal_create_library(id<MTLDevice> device);
16+
17+
#ifdef __cplusplus
18+
}
19+
#endif
20+
21+
#endif // KORE_METAL
22+
23+
#endif // KORE_GPU_METAL_HEADER

sources/gpu/metal.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <kore3/gpu/metal.h>
2+
3+
#ifdef KORE_METAL
4+
5+
static kore_metal_library_creator_t custom_library_creator = NULL;
6+
7+
void kore_metal_set_library_creator(kore_metal_library_creator_t creator) {
8+
custom_library_creator = creator;
9+
}
10+
11+
id<MTLLibrary> kore_metal_create_library(id<MTLDevice> device) {
12+
if (custom_library_creator != NULL) {
13+
id<MTLLibrary> library = custom_library_creator(device);
14+
if (library != nil) {
15+
return library;
16+
}
17+
}
18+
19+
return [device newDefaultLibrary];
20+
}
21+
22+
#endif // KORE_METAL

0 commit comments

Comments
 (0)