Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Extended A Study in Bitmap: Is NDK the fast Pro...

bigbackboom
October 15, 2024
2

Extended A Study in Bitmap: Is NDK the fast Processing method by CPU?

bigbackboom

October 15, 2024
Tweet

Transcript

  1. EXTENDED A Study in Bitmap: Is NDK the Fastest Processing

    Method by CPU? キクチコウダイ
  2. パフォーマンス NDK: • Average: 50ms • Max: 75ms • Min:

    33ms • Median: 45.5ms JVM: • Average: 63.3ms • Max: 90ms • Min: 59ms • Median: 60ms まとめ
  3. Extended • テクスチャの色データを取 り出す GLSLの実装 #version 300 es precision mediump

    float; in vec2 v_texCoord; layout(location = 0) out vec4 outColor; uniform sampler2D s_texture; uniform vec3 rgb; uniform float alpha; void main() { // change color order since bitmap is BGR float filtering = 1.0 - alpha; vec4 texture = texture(s_texture , v_texCoord); float r = (texture.b * alpha) + (rgb.r * filtering) ; float g = (texture.g * alpha) + (rgb.g * filtering) ; float b = (texture.r * alpha) + (rgb.b * filtering) ; // change color order since bitmap is BGR outColor = vec4(r, g, b, 1.0f); }
  4. Extended • テクスチャの色データを取 り出す • 取り出したデータでブレン ディング処理をする GLSLの実装 #version 300

    es precision mediump float; in vec2 v_texCoord; layout(location = 0) out vec4 outColor; uniform sampler2D s_texture; uniform vec3 rgb; uniform float alpha; void main() { // change color order since bitmap is BGR float filtering = 1.0 - alpha; vec4 texture = texture(s_texture , v_texCoord); float r = (texture.b * alpha) + (rgb.r * filtering) ; float g = (texture.g * alpha) + (rgb.g * filtering) ; float b = (texture.r * alpha) + (rgb.b * filtering) ; // change color order since bitmap is BGR outColor = vec4(r, g, b, 1.0f); }
  5. Extended • テクスチャの色データを取 り出す • 取り出したデータでブレン ディング処理をする • 普通のプログラミング言語 に近いが、if文を使うと劇

    的に遅くなる😂 GLSLの実装 #version 300 es precision mediump float; in vec2 v_texCoord; layout(location = 0) out vec4 outColor; uniform sampler2D s_texture; uniform vec3 rgb; uniform float alpha; void main() { // change color order since bitmap is BGR float filtering = 1.0 - alpha; vec4 texture = texture(s_texture , v_texCoord); float r = (texture.b * alpha) + (rgb.r * filtering) ; float g = (texture.g * alpha) + (rgb.g * filtering) ; float b = (texture.r * alpha) + (rgb.b * filtering) ; // change color order since bitmap is BGR outColor = vec4(r, g, b, 1.0f); }
  6. Sample Repository: ❖ Kotlin 2.0 ❖ Multi-Module with NDK ❖

    Jetpack Compose https://github.com/BigBackBoom/hades