use tiled atlas texture sampling, increase shader speed using inv sqrt
This commit is contained in:
parent
e92748c2d9
commit
c4226b36fe
34 changed files with 1045 additions and 520 deletions
96
pxl8.sh
96
pxl8.sh
|
|
@ -8,7 +8,7 @@ if command -v ccache >/dev/null 2>&1; then
|
|||
CC="ccache $CC"
|
||||
fi
|
||||
|
||||
CFLAGS="-std=c23 -Wall -Wextra"
|
||||
CFLAGS="-std=c23 -Wall -Wextra -Wno-missing-braces"
|
||||
LIBS="-lm"
|
||||
MODE="debug"
|
||||
BUILDDIR=".build"
|
||||
|
|
@ -170,8 +170,8 @@ compile_source_file() {
|
|||
compile_shaders() {
|
||||
local build_mode="$1"
|
||||
local shader_dir="src/gfx/shaders/cpu"
|
||||
local so_dir=".build/shaders/cpu"
|
||||
local obj_dir=".build/shaders/cpu/obj"
|
||||
local so_dir=".build/$build_mode/shaders/cpu"
|
||||
local obj_dir=".build/$build_mode/shaders/cpu/obj"
|
||||
|
||||
if [[ ! -d "$shader_dir" ]]; then
|
||||
return 0
|
||||
|
|
@ -240,15 +240,17 @@ print_usage() {
|
|||
echo " clean Remove build artifacts"
|
||||
echo " help Show this help message"
|
||||
echo " install Install pxl8 to ~/.local/bin"
|
||||
echo " profile Profile with perf and generate flamegraph (Linux)"
|
||||
echo " run Build and run pxl8 (optional: cart.pxc or folder)"
|
||||
echo " update Download/update all dependencies"
|
||||
echo " vendor Fetch source for dependencies (ex. SDL3)"
|
||||
echo
|
||||
echo -e "${BOLD}OPTIONS:${NC}"
|
||||
echo " --all Clean both build artifacts and dependencies"
|
||||
echo " --cache Clear ccache (use with clean)"
|
||||
echo " --deps Clean only dependencies"
|
||||
echo " --release Build/run/clean in release mode (default: debug)"
|
||||
echo " --all Clean both build artifacts and dependencies"
|
||||
echo " --cache Clear ccache (use with clean)"
|
||||
echo " --deps Clean only dependencies"
|
||||
echo " --duration=N Profile duration in seconds (default: 30)"
|
||||
echo " --release Build/run/clean in release mode (default: debug)"
|
||||
}
|
||||
|
||||
setup_sdl3() {
|
||||
|
|
@ -324,6 +326,20 @@ update_fennel() {
|
|||
fi
|
||||
}
|
||||
|
||||
update_flamegraph() {
|
||||
print_info "Fetching FlameGraph"
|
||||
|
||||
if [[ -d "lib/FlameGraph/.git" ]]; then
|
||||
cd lib/FlameGraph && git pull --quiet origin master
|
||||
cd - > /dev/null
|
||||
else
|
||||
rm -rf lib/FlameGraph
|
||||
git clone --quiet https://github.com/brendangregg/FlameGraph.git lib/FlameGraph
|
||||
fi
|
||||
|
||||
print_info "Updated FlameGraph"
|
||||
}
|
||||
|
||||
update_linenoise() {
|
||||
print_info "Fetching linenoise"
|
||||
|
||||
|
|
@ -690,6 +706,72 @@ case "$COMMAND" in
|
|||
bash tools/aseprite/pxl8-ase.sh "$@"
|
||||
;;
|
||||
|
||||
profile)
|
||||
if [[ "$(uname)" != "Linux" ]]; then
|
||||
print_error "Profiling with perf is only supported on Linux"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v perf >/dev/null 2>&1; then
|
||||
print_error "perf not found. Install linux-tools or perf package."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "lib/FlameGraph" ]]; then
|
||||
mkdir -p lib
|
||||
update_flamegraph
|
||||
fi
|
||||
|
||||
"$0" build || exit 1
|
||||
|
||||
PROFILE_DIR=".build/debug/profile"
|
||||
mkdir -p "$PROFILE_DIR"
|
||||
|
||||
CART=""
|
||||
PERF_DURATION=30
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" =~ ^--duration=([0-9]+)$ ]]; then
|
||||
PERF_DURATION="${BASH_REMATCH[1]}"
|
||||
elif [[ "$arg" != "--release" ]] && [[ -z "$CART" ]]; then
|
||||
CART="$arg"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z "$CART" ]] && CART="demo"
|
||||
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
PERF_DATA="$PROFILE_DIR/perf_${TIMESTAMP}.data"
|
||||
PERF_SCRIPT="$PROFILE_DIR/perf_${TIMESTAMP}.perf"
|
||||
FOLDED="$PROFILE_DIR/perf_${TIMESTAMP}.folded"
|
||||
SVG="$PROFILE_DIR/flamegraph_${TIMESTAMP}.svg"
|
||||
|
||||
print_info "Starting server..."
|
||||
./bin/debug/pxl8d &
|
||||
SERVER_PID=$!
|
||||
sleep 0.5
|
||||
|
||||
trap "kill $SERVER_PID 2>/dev/null; wait $SERVER_PID 2>/dev/null" EXIT
|
||||
|
||||
print_info "Profiling pxl8 for ${PERF_DURATION}s (Ctrl+C to stop early)..."
|
||||
perf record -F 99 -g --call-graph dwarf -o "$PERF_DATA" -- \
|
||||
timeout "${PERF_DURATION}s" ./bin/debug/pxl8 "$CART" 2>/dev/null || true
|
||||
|
||||
print_info "Processing profile data..."
|
||||
perf script -i "$PERF_DATA" > "$PERF_SCRIPT"
|
||||
|
||||
print_info "Generating flamegraph..."
|
||||
lib/FlameGraph/stackcollapse-perf.pl "$PERF_SCRIPT" > "$FOLDED"
|
||||
lib/FlameGraph/flamegraph.pl --cp --colors orange --title "pxl8 profile" "$FOLDED" > "$SVG"
|
||||
|
||||
rm -f "$PERF_DATA" "$PERF_SCRIPT" "$FOLDED"
|
||||
|
||||
print_info "Flamegraph: $SVG"
|
||||
|
||||
if command -v xdg-open >/dev/null 2>&1; then
|
||||
xdg-open "$SVG" 2>/dev/null &
|
||||
fi
|
||||
;;
|
||||
|
||||
help|--help|-h|"")
|
||||
print_usage
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue