Skip to content

Commit

Permalink
fix issue on android array allocation (#25)
Browse files Browse the repository at this point in the history
* Update README with badges and detailed project description

Added multiple badges for status, version, license, and Discord, improving project visibility. Expanded the project description to highlight functionality, platform compatibility, and backend details. Included a link to the demo folder for better usability guidance.

* Update README with usage guide and project description

Added a detailed "How to use" section for integrating the library into multiplatform projects. Clarified the project description to emphasize its role as a Kotlin binding for the wgpu library.

* Update version references in README and build script

Adjusted the displayed version in the README badge to v22.0.1 for consistency. Updated the default version in build.gradle.kts to v22.0.2-SNAPSHOT.

* "Optimize array allocation with proper memory sizing"

This update ensures that memory for arrays is allocated with the correct size, leveraging the `allocator` to prevent potential memory mismanagement. Each structure now explicitly calculates the required memory size, improving performance and reducing errors.

* Update CI workflow to include 'fix/**' branch triggers

Extended the workflow to run on pushes and pull requests targeting 'fix/**' branches. This ensures that fixes are properly tested and integrated with the CI pipeline.
  • Loading branch information
ygdrasil-io authored Jan 20, 2025
1 parent 545d0d3 commit e8fc710
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [ main, 'release/**', 'feature/**' ]
branches: [ main, 'release/**', 'feature/**', 'fix/**']
pull_request:
branches: [ main, 'release/**', 'feature/**' ]
branches: [ main, 'release/**', 'feature/**', 'fix/**']

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
1 change: 0 additions & 1 deletion demo/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {

kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget = JvmTarget.JVM_22
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun NativeModel.Structure.toAndroidStructure() = templateBuilder {
}
newLine()
appendBlock("actual fun allocateArray(allocator: MemoryAllocator, size: UInt, provider: (UInt, $structureName) -> Unit): ArrayHolder<$structureName>") {
appendLine("val array = io.ygdrasil.wgpu.android.$structureName.ByValue().toArray(size.toInt())")
appendLine("val array = io.ygdrasil.wgpu.android.$structureName.ByValue(allocator.allocate($structureSize * size.toLong())).toArray(size.toInt())")
appendBlock("array.forEachIndexed", "index, structure") {
appendLine("(structure as io.ygdrasil.wgpu.android.$structureName.ByValue)") {
appendLine(".also { provider(index.toUInt(), $structureName.ByValue(it)) }")
Expand Down
Loading

0 comments on commit e8fc710

Please sign in to comment.