Skip to content

Commit 2b9e5e9

Browse files
committed
Fix some wasm build issues;
1 parent 376f0b7 commit 2b9e5e9

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/api/l_filesystem_file.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ static int l_lovrFileRead(lua_State* L) {
4444
lua_Number n = lua_tonumber(L, 2);
4545
luax_check(L, n >= 0, "Number of bytes to read can not be negative");
4646
luax_check(L, n < 9007199254740992.0, "Number of bytes to read must be less than 2^53");
47-
size = (size_t) n;
47+
size = MIN((size_t) n, SIZE_MAX);
4848
} else {
49-
luax_assert(L, lovrFileGetSize(file, &size));
50-
size -= lovrFileTell(file);
49+
uint64_t fileSize;
50+
luax_assert(L, lovrFileGetSize(file, &fileSize));
51+
fileSize -= lovrFileTell(file);
52+
size = MIN(fileSize, SIZE_MAX);
5153
}
5254
size_t count;
5355
void* data = lovrMalloc(size);

src/core/gpu_web.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,16 @@ bool gpu_surface_init(gpu_surface_info* info) {
205205
return false; // TODO
206206
}
207207

208-
void gpu_surface_resize(uint32_t width, uint32_t height) {
209-
// TODO
208+
bool gpu_surface_resize(uint32_t width, uint32_t height) {
209+
return false; // TODO
210210
}
211211

212-
gpu_texture* gpu_surface_acquire(void) {
213-
return NULL; // TODO
212+
bool gpu_surface_acquire(gpu_texture** texture) {
213+
return false; // TODO
214214
}
215215

216-
void gpu_surface_present(void) {
217-
// TODO
216+
bool gpu_surface_present(void) {
217+
return false; // TODO
218218
}
219219

220220
// Sampler
@@ -681,8 +681,8 @@ gpu_stream* gpu_stream_begin(const char* label) {
681681
return stream;
682682
}
683683

684-
void gpu_stream_end(gpu_stream* stream) {
685-
//
684+
bool gpu_stream_end(gpu_stream* stream) {
685+
return true;
686686
}
687687

688688
void gpu_render_begin(gpu_stream* stream, gpu_canvas* canvas) {
@@ -1050,15 +1050,16 @@ void gpu_destroy(void) {
10501050
memset(&state, 0, sizeof(state));
10511051
}
10521052

1053-
uint32_t gpu_begin(void) {
1054-
return state.tick++;
1053+
bool gpu_begin(uint32_t* tick) {
1054+
*tick = state.tick++;
1055+
return true;
10551056
}
10561057

10571058
static void onSubmittedWorkDone(WGPUQueueWorkDoneStatus status, void* userdata) {
10581059
state.lastTickFinished = (uint32_t) (uintptr_t) userdata;
10591060
}
10601061

1061-
void gpu_submit(gpu_stream** streams, uint32_t count) {
1062+
bool gpu_submit(gpu_stream** streams, uint32_t count) {
10621063
WGPUCommandBuffer commandBuffers[64];
10631064
count = MIN(count, COUNTOF(commandBuffers));
10641065

@@ -1072,18 +1073,20 @@ void gpu_submit(gpu_stream** streams, uint32_t count) {
10721073
for (uint32_t i = 0; i < state.streamCount; i++) {
10731074
wgpuCommandEncoderRelease(state.streams[i].commands);
10741075
}
1076+
1077+
return true;
10751078
}
10761079

10771080
bool gpu_is_complete(uint32_t tick) {
10781081
return state.lastTickFinished >= tick;
10791082
}
10801083

1081-
bool gpu_wait_tick(uint32_t tick) {
1082-
return true; // TODO Unsupported
1084+
bool gpu_wait_tick(uint32_t tick, bool* waited) {
1085+
return *waited = false, true; // TODO unsupported?
10831086
}
10841087

1085-
void gpu_wait_idle(void) {
1086-
// TODO Unsupported
1088+
bool gpu_wait_idle(void) {
1089+
return true; // TODO unsupported?
10871090
}
10881091

10891092
// Helpers

src/modules/headset/headset_webxr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ extern bool webxr_vibrate(Device device, float strength, float duration, float f
3636
extern void webxr_stopVibration(Device device);
3737
extern struct ModelData* webxr_newModelData(Device device, bool animated);
3838
extern bool webxr_animate(struct Model* model);
39-
extern bool webxr_getTexture(Texture** texture);
40-
extern bool webxr_getPass(Pass** pass);
39+
extern bool webxr_getTexture(struct Texture** texture);
40+
extern bool webxr_getPass(struct Pass** pass);
4141
extern bool webxr_submit(void);
4242
extern bool webxr_isActive(void);
4343
extern bool webxr_isVisible(void);

0 commit comments

Comments
 (0)