Skip to content

Commit

Permalink
Runtime: Streamline some deferred UI events for RML 6
Browse files Browse the repository at this point in the history
The library no longer supports immediate rendering, so there's no point in keeping the old event names around. Since the contract was broken anyway, might as well rename the events to match the new behavior and get it over with.
  • Loading branch information
rdw-software committed Jun 2, 2024
1 parent b810bb9 commit e5ac724
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
16 changes: 8 additions & 8 deletions Runtime/Bindings/FFI/RmlUi_Renderer_WebGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ Rml::CompiledGeometryHandle RenderInterface_WebGPU::CompileGeometry(Rml::Span<co

RML_DEBUG_TRACE("Compiled geometry %p (%d vertices + %d indices; %d bytes per vertex)", geometry, num_vertices, num_indices, sizeof(Rml::Vertex));

geometry_compile_event_t payload {
.type = GEOMETRY_COMPILE_EVENT,
geometry_compilation_event_t payload {
.type = GEOMETRY_COMPILATION_EVENT,

Check notice on line 134 in Runtime/Bindings/FFI/RmlUi_Renderer_WebGPU.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Excess Number of Function Arguments

RenderInterface_WebGPU::CompileGeometry is no longer above the threshold for number of arguments
.compiled_geometry = *geometry,
};
deferred_event_t event { .geometry_compilation_details = payload };
Expand All @@ -145,26 +145,26 @@ void RenderInterface_WebGPU::RenderGeometry(Rml::CompiledGeometryHandle rmlGeome

RML_DEBUG_TRACE("Rendering compiled geometry %p with translation (%.2f, %.2f)", geometry, rmlTranslationVector.x, rmlTranslationVector.y);

compilation_render_event_t payload {
.type = COMPILATION_RENDER_EVENT,
geometry_render_event_t payload {
.type = GEOMETRY_RENDER_EVENT,
.compiled_geometry = *geometry,
.translate_u = rmlTranslationVector.x,
.translate_v = rmlTranslationVector.y,
.texture = reinterpret_cast<WGPUTexture>(rmlTextureHandle),
};
deferred_event_t event { .compilation_render_details = payload };
deferred_event_t event { .geometry_render_details = payload };
m_deferredEventsQueue->push(event);
}

void RenderInterface_WebGPU::ReleaseGeometry(Rml::CompiledGeometryHandle rmlGeometryHandle) {
rml_geometry_info_t* geometry = reinterpret_cast<rml_geometry_info_t*>(rmlGeometryHandle);
RML_DEBUG_TRACE("Releasing compiled geometry %p", geometry);

compilation_release_event_t payload {
.type = COMPILATION_RELEASE_EVENT,
geometry_release_event_t payload {
.type = GEOMETRY_RELEASE_EVENT,
.compiled_geometry = *geometry,
};
deferred_event_t event { .compilation_release_details = payload };
deferred_event_t event { .geometry_release_details = payload };
m_deferredEventsQueue->push(event);
}

Expand Down
29 changes: 10 additions & 19 deletions Runtime/Bindings/FFI/interop/interop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ typedef enum {
KEYBOARD_EVENT,
CHARACTER_INPUT_EVENT,
// RML UI events
GEOMETRY_COMPILATION_EVENT,
GEOMETRY_RENDER_EVENT,
GEOMETRY_COMPILE_EVENT,
COMPILATION_RENDER_EVENT,
COMPILATION_RELEASE_EVENT,
GEOMETRY_RELEASE_EVENT,
SCISSORTEST_STATUS_EVENT,
SCISSORTEST_REGION_EVENT,
TEXTURE_LOAD_EVENT,
Expand Down Expand Up @@ -147,30 +146,23 @@ typedef struct rml_geometry_info_t {
int num_indices;
} rml_geometry_info_t;
typedef struct geometry_render_event_t {
int type;
rml_geometry_info_t geometry;
float translate_u;
float translate_v;
} geometry_render_event_t;
typedef struct geometry_compile_event_t {
typedef struct geometry_compilation_event_t {
int type;
rml_geometry_info_t compiled_geometry;
} geometry_compile_event_t;
} geometry_compilation_event_t;
typedef struct compilation_render_event_t {
typedef struct geometry_render_event_t {
int type;
rml_geometry_info_t compiled_geometry;
float translate_u;
float translate_v;
wgpu_texture_t texture;
} compilation_render_event_t;
} geometry_render_event_t;
typedef struct compilation_release_event_t {
typedef struct geometry_release_event_t {
int type;
rml_geometry_info_t compiled_geometry;
} compilation_release_event_t;
} geometry_release_event_t;
typedef struct scissortest_status_event_t {
int type;
Expand Down Expand Up @@ -239,10 +231,9 @@ typedef union deferred_event_t {
key_event_t key_details;
character_input_event_t character_input_details;
// RML
geometry_compilation_event_t geometry_compilation_details;
geometry_render_event_t geometry_render_details;
geometry_compile_event_t geometry_compilation_details;
compilation_render_event_t compilation_render_details;
compilation_release_event_t compilation_release_details;
geometry_release_event_t geometry_release_details;
scissortest_status_event_t scissortest_status_details;
scissortest_region_event_t scissortest_region_details;
texture_load_event_t texture_load_details;
Expand Down
29 changes: 10 additions & 19 deletions Runtime/Bindings/FFI/interop/interop_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ typedef enum {
KEYBOARD_EVENT,
CHARACTER_INPUT_EVENT,
// RML UI events
GEOMETRY_COMPILATION_EVENT,
GEOMETRY_RENDER_EVENT,
GEOMETRY_COMPILE_EVENT,
COMPILATION_RENDER_EVENT,
COMPILATION_RELEASE_EVENT,
GEOMETRY_RELEASE_EVENT,
SCISSORTEST_STATUS_EVENT,
SCISSORTEST_REGION_EVENT,
TEXTURE_LOAD_EVENT,
Expand Down Expand Up @@ -138,30 +137,23 @@ typedef struct rml_geometry_info_t {
int num_indices;
} rml_geometry_info_t;

typedef struct geometry_render_event_t {
int type;
rml_geometry_info_t geometry;
float translate_u;
float translate_v;
} geometry_render_event_t;

typedef struct geometry_compile_event_t {
typedef struct geometry_compilation_event_t {
int type;
rml_geometry_info_t compiled_geometry;
} geometry_compile_event_t;
} geometry_compilation_event_t;

typedef struct compilation_render_event_t {
typedef struct geometry_render_event_t {
int type;
rml_geometry_info_t compiled_geometry;
float translate_u;
float translate_v;
wgpu_texture_t texture;
} compilation_render_event_t;
} geometry_render_event_t;

typedef struct compilation_release_event_t {
typedef struct geometry_release_event_t {
int type;
rml_geometry_info_t compiled_geometry;
} compilation_release_event_t;
} geometry_release_event_t;

typedef struct scissortest_status_event_t {
int type;
Expand Down Expand Up @@ -230,10 +222,9 @@ typedef union deferred_event_t {
key_event_t key_details;
character_input_event_t character_input_details;
// RML
geometry_compilation_event_t geometry_compilation_details;
geometry_render_event_t geometry_render_details;
geometry_compile_event_t geometry_compilation_details;
compilation_render_event_t compilation_render_details;
compilation_release_event_t compilation_release_details;
geometry_release_event_t geometry_release_details;
scissortest_status_event_t scissortest_status_details;
scissortest_region_event_t scissortest_region_details;
texture_load_event_t texture_load_details;
Expand Down

0 comments on commit e5ac724

Please sign in to comment.