blob: 3086bd293c2c6e50526e508308347c424f24e1cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Copyright 2025 LunarG, Inc.
* Copyright 2025 Google LLC
* SPDX-License-Identifier: MIT
*/
#include "mtl_command_buffer.h"
#include <Metal/MTLCommandBuffer.h>
#include <QuartzCore/CAMetalLayer.h>
void
mtl_encode_signal_event(mtl_command_buffer *cmd_buf_handle,
mtl_event *event_handle, uint64_t value)
{
@autoreleasepool {
id<MTLCommandBuffer> cmd_buf = (id<MTLCommandBuffer>)cmd_buf_handle;
id<MTLEvent> event = (id<MTLEvent>)event_handle;
[cmd_buf encodeSignalEvent:event value:value];
}
}
void
mtl_encode_wait_for_event(mtl_command_buffer *cmd_buf_handle,
mtl_event *event_handle, uint64_t value)
{
@autoreleasepool {
id<MTLCommandBuffer> cmd_buf = (id<MTLCommandBuffer>)cmd_buf_handle;
id<MTLEvent> event = (id<MTLEvent>)event_handle;
[cmd_buf encodeWaitForEvent:event value:value];
}
}
void
mtl_add_completed_handler(mtl_command_buffer *cmd, void (*callback)(void *data),
void *data)
{
@autoreleasepool {
id<MTLCommandBuffer> mtl_cmd = (id<MTLCommandBuffer>)cmd;
[mtl_cmd addCompletedHandler:^(id<MTLCommandBuffer> _Nonnull cmd_buf) {
if (callback)
callback(data);
}];
}
}
void
mtl_command_buffer_commit(mtl_command_buffer *cmd_buffer)
{
@autoreleasepool {
id<MTLCommandBuffer> cmd_buf = (id<MTLCommandBuffer>)cmd_buffer;
[cmd_buf commit];
}
}
void
mtl_present_drawable(mtl_command_buffer *cmd_buf, void *drawable_ptr)
{
@autoreleasepool {
id<MTLCommandBuffer> cmd = (id<MTLCommandBuffer>)cmd_buf;
id<CAMetalDrawable> drawable = [(id<CAMetalDrawable>)drawable_ptr autorelease];
[cmd presentDrawable:drawable];
}
}
|