Plain 2D rendering in D3D11, without the distracting feature set of a complete sprite renderer and allowing arbitrarily placed triangle vertices with absolute pixel coordinate positioning (there's really no need for the sometimes confusing complication of a full-on projection matrix pipeline for UI and 2D games). Like the original Minimal D3D11, this one uses a canonical 1:1 TRIANGLELIST vertex buffer with input layout, so no fancy manual custom buffer fetching and in-shader in
| package dumb_handle_map | |
| // NOTE: ONLY TO SHOW WHAT A GENERATION IS DOING | |
| // BUT DOES NO INSERTION WHATSOEVER | |
| Handle_Map :: struct($T: typeid) { | |
| entries: [dynamic]Entry(T), | |
| } | |
| Entry :: struct($T: typeid) { |
| import lldb | |
| import math | |
| import logging | |
| log = logging.getLogger(__name__) | |
| def is_slice_type(t, internal_dict): | |
| return (t.name.startswith("[]") or t.name.startswith("[dynamic]")) and not t.name.endswith(']') | |
| def slice_summary(value, internal_dict): |
Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.
Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.
The renderer is "im
Example of how to capture CPU counters with ETW on Windows, perf on Linux or kperf on Apple.
Using ETW needs somewhat recently updated Windows 10 or 11. Not sure about exact version.
Currently tested on:
- etw on Qualcomm Snapdragon X Elite, Windows 11, arm64
- etw on AMD Zen 3, Windows 11 (with virtualization enabled in BIOS)
| #pragma once | |
| // uncompressed png writer & reader | |
| // supports only 8-bit and 16-bit formats | |
| // Performance comparison for 8192x8192 BGRA8 image (256MB) | |
| // Compiled with "clang -O2", AVX2 requires extra "-mavx2" or "/arch:AVX2" argument | |
| // | |
| // For libpng (compressed) uses default libpng/zlib compression settings | |
| // For libpng (uncompressed) case following two functions are used: |
A minimal Direct3D 11 implementation of "antialiased point sampling", useful for smooth fractional movement and non-integer scaling of pixel art AKA "fat pixel" aesthetics.
Also view below side-by-side point sampling comparison on YouTube (video is zoomed in to counter implicit downsampling & compression artifacts and make aa effect more apparent) or check out the original Shadertoy.
The actual sampler is set to bilinear filtering (the default D3D11 sampler state) in order to utilize single texture-read hardware interpolation, then emulating point sampling in the shader and applying AA at the fat pixel boundaries. Use with premultiplied alpha textures* and keep a one pixel transparent border around
Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube



