mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
feature: hud (#37)
* build: replace FetchContent with direct includes for glm * build(deps): replace SOIL2 with stb for image and vorbis decoding * build: replace FetchContent with direct includes for toml++ * refactor(texture): bump block texture size to 512 and disable items tab * feat: add hotbar system with ItemStack and RowLayout * fix(ui): restrict Ctrl key handling to typing mode * feat(ui): add widget border support and highlight selected hotbar slot * fix(ui): update borders on scale change and correct Image width - Added update_border() calls in set_scale() for Button, ChatBox, Image, Label, and TextField. - Fixed Image::width() to multiply by width instead of height. - Added early return in Widget::update_border() if border is not supported. * feat(ui): add border visual feedback on slider drag * feat(ui): add ItemSlot widget and refactor hotbar to use it * feat(world_scene): add inventory UI and pause type enum * feat(ui): add item slot tooltip and make window size static * fix(ui label): account for background offset in width/height * refactor(ui): centralize item info label in inventory and add update * feat(ui): add hotbar interaction in inventory UI * fix(inventory-ui): correct row creation logic for first item The loop starting at index 0 created a new row on the first iteration (i % 10 == 0). Shift the loop to start at 1 and adjust modulus condition to create rows correctly every 10 items. * feat(block): add name_key for localized block names Add `name_key` field to all block TOML definitions, enabling per-block localization. Update `BlockData` struct and `BlockManager` with `local_name()` method that returns a localized string via the translation system. Add corresponding entries to `en_US.json` and `zh_CN.json`. Modify inventory UI to use the localized name when displaying block info, and fix a bug where emptying a hotbar slot did not clear the item locally. * fix(ui): change inventory item slot color from white to gray * fix(ui): add missing include for std::array
This commit is contained in:
155
include/glm/simd/neon.h
Normal file
155
include/glm/simd/neon.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/// @ref simd_neon
|
||||
/// @file glm/simd/neon.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#if GLM_ARCH & GLM_ARCH_NEON_BIT
|
||||
#include <arm_neon.h>
|
||||
|
||||
namespace glm {
|
||||
namespace neon {
|
||||
static inline float32x4_t dupq_lane(float32x4_t vsrc, int lane) {
|
||||
switch(lane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
||||
case 0: return vdupq_laneq_f32(vsrc, 0);
|
||||
case 1: return vdupq_laneq_f32(vsrc, 1);
|
||||
case 2: return vdupq_laneq_f32(vsrc, 2);
|
||||
case 3: return vdupq_laneq_f32(vsrc, 3);
|
||||
#else
|
||||
case 0: return vdupq_n_f32(vgetq_lane_f32(vsrc, 0));
|
||||
case 1: return vdupq_n_f32(vgetq_lane_f32(vsrc, 1));
|
||||
case 2: return vdupq_n_f32(vgetq_lane_f32(vsrc, 2));
|
||||
case 3: return vdupq_n_f32(vgetq_lane_f32(vsrc, 3));
|
||||
#endif
|
||||
}
|
||||
return vdupq_n_f32(0.0f);
|
||||
}
|
||||
|
||||
static inline float32x2_t dup_lane(float32x4_t vsrc, int lane) {
|
||||
switch(lane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
||||
case 0: return vdup_laneq_f32(vsrc, 0);
|
||||
case 1: return vdup_laneq_f32(vsrc, 1);
|
||||
case 2: return vdup_laneq_f32(vsrc, 2);
|
||||
case 3: return vdup_laneq_f32(vsrc, 3);
|
||||
#else
|
||||
case 0: return vdup_n_f32(vgetq_lane_f32(vsrc, 0));
|
||||
case 1: return vdup_n_f32(vgetq_lane_f32(vsrc, 1));
|
||||
case 2: return vdup_n_f32(vgetq_lane_f32(vsrc, 2));
|
||||
case 3: return vdup_n_f32(vgetq_lane_f32(vsrc, 3));
|
||||
#endif
|
||||
}
|
||||
return vdup_n_f32(0.0f);
|
||||
}
|
||||
|
||||
static inline float32x4_t copy_lane(float32x4_t vdst, int dlane, float32x4_t vsrc, int slane) {
|
||||
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
||||
switch(dlane) {
|
||||
default:
|
||||
case 0:
|
||||
switch(slane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: return vcopyq_laneq_f32(vdst, 0, vsrc, 0);
|
||||
case 1: return vcopyq_laneq_f32(vdst, 0, vsrc, 1);
|
||||
case 2: return vcopyq_laneq_f32(vdst, 0, vsrc, 2);
|
||||
case 3: return vcopyq_laneq_f32(vdst, 0, vsrc, 3);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch(slane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: return vcopyq_laneq_f32(vdst, 1, vsrc, 0);
|
||||
case 1: return vcopyq_laneq_f32(vdst, 1, vsrc, 1);
|
||||
case 2: return vcopyq_laneq_f32(vdst, 1, vsrc, 2);
|
||||
case 3: return vcopyq_laneq_f32(vdst, 1, vsrc, 3);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch(slane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: return vcopyq_laneq_f32(vdst, 2, vsrc, 0);
|
||||
case 1: return vcopyq_laneq_f32(vdst, 2, vsrc, 1);
|
||||
case 2: return vcopyq_laneq_f32(vdst, 2, vsrc, 2);
|
||||
case 3: return vcopyq_laneq_f32(vdst, 2, vsrc, 3);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch(slane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: return vcopyq_laneq_f32(vdst, 3, vsrc, 0);
|
||||
case 1: return vcopyq_laneq_f32(vdst, 3, vsrc, 1);
|
||||
case 2: return vcopyq_laneq_f32(vdst, 3, vsrc, 2);
|
||||
case 3: return vcopyq_laneq_f32(vdst, 3, vsrc, 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
||||
float l;
|
||||
switch(slane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: l = vgetq_lane_f32(vsrc, 0); break;
|
||||
case 1: l = vgetq_lane_f32(vsrc, 1); break;
|
||||
case 2: l = vgetq_lane_f32(vsrc, 2); break;
|
||||
case 3: l = vgetq_lane_f32(vsrc, 3); break;
|
||||
}
|
||||
switch(dlane) {
|
||||
default: assert(false); //Unreachable code executed!
|
||||
case 0: return vsetq_lane_f32(l, vdst, 0);
|
||||
case 1: return vsetq_lane_f32(l, vdst, 1);
|
||||
case 2: return vsetq_lane_f32(l, vdst, 2);
|
||||
case 3: return vsetq_lane_f32(l, vdst, 3);
|
||||
}
|
||||
#endif
|
||||
return vdupq_n_f32(0.0f);
|
||||
}
|
||||
|
||||
static inline float32x4_t mul_lane(float32x4_t v, float32x4_t vlane, int lane) {
|
||||
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
||||
switch(lane) {
|
||||
default: assert(false); return vdupq_n_f32(0.0f); //Unreachable code executed!
|
||||
case 0: return vmulq_laneq_f32(v, vlane, 0); break;
|
||||
case 1: return vmulq_laneq_f32(v, vlane, 1); break;
|
||||
case 2: return vmulq_laneq_f32(v, vlane, 2); break;
|
||||
case 3: return vmulq_laneq_f32(v, vlane, 3); break;
|
||||
}
|
||||
#else
|
||||
return vmulq_f32(v, dupq_lane(vlane, lane));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline float32x4_t madd_lane(float32x4_t acc, float32x4_t v, float32x4_t vlane, int lane) {
|
||||
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
||||
#ifdef GLM_CONFIG_FORCE_FMA
|
||||
# define FMADD_LANE(acc, x, y, L) do { asm volatile ("fmla %0.4s, %1.4s, %2.4s" : "+w"(acc) : "w"(x), "w"(dup_lane(y, L))); } while(0)
|
||||
#else
|
||||
# define FMADD_LANE(acc, x, y, L) do { acc = vmlaq_laneq_f32(acc, x, y, L); } while(0)
|
||||
#endif
|
||||
|
||||
switch(lane) {
|
||||
case 0:
|
||||
FMADD_LANE(acc, v, vlane, 0);
|
||||
return acc;
|
||||
case 1:
|
||||
FMADD_LANE(acc, v, vlane, 1);
|
||||
return acc;
|
||||
case 2:
|
||||
FMADD_LANE(acc, v, vlane, 2);
|
||||
return acc;
|
||||
case 3:
|
||||
FMADD_LANE(acc, v, vlane, 3);
|
||||
return acc;
|
||||
default:
|
||||
assert(false); //Unreachable code executed!
|
||||
}
|
||||
return vdupq_n_f32(0.0f);
|
||||
# undef FMADD_LANE
|
||||
#else
|
||||
return vaddq_f32(acc, vmulq_f32(v, dupq_lane(vlane, lane)));
|
||||
#endif
|
||||
}
|
||||
} //namespace neon
|
||||
} // namespace glm
|
||||
#endif // GLM_ARCH & GLM_ARCH_NEON_BIT
|
||||
Reference in New Issue
Block a user