rusty_dds, DirectXTex का शुद्ध Rust विकल्प है
एक texture pipeline को Microsoft DirectXTex से rusty_dds पर ले जाना: API mapping, मापे गए encode और decode boards, अब भी अनुपलब्ध BC formats, और एक सुरक्षित cutover।

क्या rusty_dds किसी game asset pipeline में DirectXTex की जगह ले सकता है?
DDS container काम, BC1 से BC5, BC7 और BC6H decode, और BC6H UF16 encode के लिए, हाँ। 24-केस ambientCG board पर rusty_dds हर 24 केस में per-core encode speed पर DirectXTex से आगे है और 22 में PSNR ऊँचा है। SF16 BC6H encode अभी टाला गया है।
Related reading
rusty_dds: DDS Texture Decode, Encode and GPU Upload in Pure Rustrusty_dds reads, decodes, encodes and plans GPU uploads for DirectDraw Surface textures in Rust, and on its 24-case board beats DirectXTex on encode speed in every case.
DirectXTex Microsoft की C++ texture processing library है, और इसका texconv command-line tool वह तरीका है जिससे कई studios PNGs और TIFFs को block-compressed .dds फ़ाइलों में bake करते हैं। rusty_dds उस काम के DDS हिस्से के लिए DirectXTex का शुद्ध Rust विकल्प है: container read और write, BCn decode और encode, mip generation और GPU upload plans, बिना C++ build के और MIT licence के साथ। यह guide एक से दूसरे पर जाने के बारे में है। Crate की व्यापक कहानी rusty_dds field note में है।
DirectXTex क्या करता है और टीमें इससे क्यों हटती हैं
आज यह कौन सा काम करता है
DirectXTex Microsoft की DDS programming guide में वर्णित DirectDraw Surface container पढ़ता और लिखता है, DXGI formats के बीच रूपांतरण करता है, mip chains बनाता है, और उन BC formats में compress करता है जिन्हें GPU सीधे sample करते हैं। runtime code अक्सर साथ वाले DDSTextureLoader का उपयोग फ़ाइल parse करने और blocks Direct3D को सौंपने के लिए करता है। एक सामान्य pipeline में texconv cook time पर Windows build machine पर चलता है और loader ship हुए game में।
यह कहाँ चुभता है
रगड़ मुख्यतः इस बात में है कि code कहाँ जा सकता है। DXGI शब्दावली से बंधी C++ library को Rust tool, cross-platform asset server या browser viewer में embed करना मुश्किल है, और हर native dependency CI में एक toolchain जोड़ती है। मॉड archives या user uploads से texture फ़ाइलें parse करना भी ठीक उसी तरह का अविश्वसनीय input है जहाँ memory-safe parser फ़ायदा देता है। rusty_dds दोनों का उत्तर default में safe Rust और API-agnostic upload plan से देता है जो DXGI, wgpu और Vulkan formats के नाम लेता है बिना किसी graphics API से link हुए।
दोनों की तुलना कैसे की गई
rusty_dds maintainers ने किसी अन्य Rust crate के बजाय सीधे DirectXTex के विरुद्ध मापा। proxy corpus ambientCG CC0 albedo, normal और mask maps हैं, लगभग 1024², जिन्हें BC1, BC4, BC5 और BC7 में compress किया गया। DirectXTex arm ने BC7 के लिए TEX_COMPRESS_BC7_QUICK और बाकी जगह default, non-parallel flags का उपयोग किया, जबकि rusty_dds ने 4096 blocks से ऊपर strip parallelism का, इसलिए speed पंक्तियाँ इस बात को ध्यान में रखकर पढ़ें। README ज़ोर देता है कि यह किसी studio का asset pack नहीं है और आपके अपने maps ही असली कसौटी हैं।
rusty_dds क्या कवर करता है, और क्या छूटा है
मापे गए boards
24-केस board पर rusty_dds 22 में PSNR ऊँचा है, 1 में बराबर और 1 में कम, और per-core encode speed तथा decode speed में सभी 24 में आगे है। एकमात्र quality नुकसान Wood095_NormalGL BC5S पर -0.51 dB है, जो signed BC4/BC5 window sweep को default में बंद रखने की कीमत है। Release 0.8 ने आख़िरी चार speed नुकसान बंद किए, सभी BC1 albedo, बिना एक भी output byte बदले। D3D11 और Vulkan पर 192 textures के texture-streaming replay में container parse 1.699 ms लिया जबकि दूसरा 2.121 ms, streaming CPU और p99 frame cost शोर के भीतर रहे और uploaded bytes एक जैसे रहे।
Formats और features
decode feature BC1 से BC5 signed और unsigned, BC7, BC6H, और float, 16-bit तथा packed uncompressed layouts को decode_rgba8 और decode_rgba_f32 के ज़रिए संभालता है। encode feature वही LDR matrix 2D, mips, arrays, cubes, NPOT और volumes पर कवर करता है, HDR के लिए BC6H UF16 mode 11 के साथ। Opt-in rate-distortion optimization λ=25 पर deflated BC1 payloads को 7.1% छोटा करता है, 0.17 dB लाभ के साथ। Polyhaven HDRIs BC6H से 48.0 से 56.6 dB log-PSNR पर round-trip होते हैं।
यह क्या नहीं करता
SF16 BC6H encode टाला गया है। BC7 encode modes 1, 4, 5 और 6 का उपयोग करता है, DirectXTex के quick mode के बराबर, exhaustive के नहीं। 54-केस synthetic grid पर DirectXTex अब भी 17 केसों में ऊँचा है, मुख्यतः BC2 और volume-texture BC1 से BC3 में। तीन signed BC4/BC5 केस DirectXTex से लगभग 1.10x पीछे चलते हैं जबकि score ऊँचा देते हैं। Crate अभी भी pre-1.0 है। अगर आप DirectXTex पर non-DDS काम जैसे सामान्य format conversion के लिए निर्भर हैं, तो source side के लिए rusty_png जैसा अलग image crate रखें।
DirectXTex से cutover, कदम दर कदम
सही features के साथ dependency जोड़ें
rusty_dds = "0.9" से शुरू करें, जो decode, encode और simd चालू करता है। ऐसे runtime loader या WASM build के लिए जो केवल textures पढ़ता है, default-features = false, features = ["decode"] इस्तेमाल करें। tuning चालू करके कभी ship न करें: यह frozen encoder constants को environment overrides के लिए फिर खोल देता है, और output अपने inputs का शुद्ध function रहना बंद कर देगा। MSRV 1.73 है। Release notes और API reference docs.rs पर हैं।
Loader calls map करें
जहाँ DDSTextureLoader फ़ाइल parse करके resource बनाता था, वहाँ अपने पास पहले से मौजूद bytes पर zero-copy view के लिए DdsView::parse(&bytes) का उपयोग करें, फिर offset, length और GPU format के लिए upload_plan_compressed(SubresourceId::mip_layer(0, 0)), जिसे आप अपने upload code को देते हैं। Dds::read अपना payload खुद रखता है; DdsView::read_into आपके दिए buffer को दोबारा इस्तेमाल करता है। Crate वह नहीं allocate करता जो आपने नहीं माँगा और कोई thread नहीं रखता, इसलिए decode_block_rows_into आपके job system को एक decode बाँटने देता है।
texconv calls map करें
Cook-time compression के लिए Dds::encode_from_rgba8(&pixels, EncodeLayout::flat_2d(DecodeContent::Bc7, w, h)) texconv -f BC7_UNORM जैसी call की जगह लेता है, और EncodeQuality::{Quality, Fast} tier चुनता है। बंडल किया गया CLI quick कामों को कवर करता है: rusty-dds info, rusty-dds decode और rusty-dds encode --format bc7। Scripted batches एक बार में एक format ले जा सकते हैं।
अपने ही assets पर switch रोकें
अपने असली textures के नमूने पर दोनों tools चलाएँ और प्रति map PSNR तथा size की तुलना करें, repo के harvest_corpus_vs_dxtex example को टेम्पलेट की तरह इस्तेमाल करते हुए। चूँकि rusty_dds deterministically encode करता है, output स्वीकार करने के बाद अपने payload hashes freeze कर दें, ताकि बाद का कोई भी drift build फेल कर दे। जहाँ भी फ़ाइल आपके studio के बाहर से आती है वहाँ Dds::read की जगह Dds::read_limited रखें।
आसपास के crates
Video और capture रास्ते जो textures में खत्म होते हैं, remade_ffmpeg_rs से feed हो सकते हैं, और self-hosted streaming client Starfire निकट का Media project है। Crate अपने repo landing पर pinned है, और Media band guide इस lane के बाकी हिस्से सूचीबद्ध करता है। इस पर बने tools को MATA.NETWORK पर host किया जा सकता है और Disco Party के ज़रिए साझा किया जा सकता है।
FAQ
rusty_dds कौन से DirectXTex features कवर नहीं करता?
rusty_dds एक DDS toolkit है, सामान्य image library नहीं। BC6H encode केवल UF16 mode 11 है, SF16 टाला गया है, और BC7 encode modes 1, 4, 5 और 6 का उपयोग करता है। 54-केस synthetic grid पर DirectXTex अब भी 17 केसों में ऊँची quality देता है, मुख्यतः BC2 और volume textures में।
क्या rusty_dds को unsafe code या C toolchain चाहिए?
नहीं, किसी C toolchain की ज़रूरत नहीं और कोई sys crate नहीं। simd feature बंद होने पर crate forbid(unsafe_code) है। simd चालू होने पर unsafe केवल AVX2 kernels तक सीमित है जो runtime-detected हैं, scalar twins के विरुद्ध oracle-tested हैं और output में byte-identical हैं।
क्या rusty_dds का output अलग-अलग मशीनों पर deterministic है?
हाँ, अनुबंध के अनुसार। एक payload केवल source bytes, crate version और EncodeLayout पर निर्भर करता है। CPU features, thread count और environment variables इसे नहीं बदलते, और payload hashes tests/encode_determinism.rs में frozen हैं।
rusty_dds मॉड्स या नेटवर्क से आई अविश्वसनीय DDS फ़ाइलों को कैसे संभालता है?
`Dds::read` की जगह byte budget के साथ `Dds::read_limited` इस्तेमाल करें। header के बाद की size गणनाएँ checked arithmetic का उपयोग करती हैं, इसलिए असंभव geometry fail closed हो जाती है, और एक robustness test suite तथा opt-in cargo-fuzz harness हर पाई गई regression को pin करते हैं।
क्या rusty_dds browser में काम करता है?
README में Windows, macOS, Linux और Web सूचीबद्ध हैं। WASM loader के लिए `default-features = false` और `features = ["decode"]` के साथ build करें, जो शून्य unsafe वाला decode-only build देता है।