{"id":20989874,"url":"https://github.com/iddm/nvngx-rs","last_synced_at":"2025-04-23T17:09:38.631Z","repository":{"id":209830384,"uuid":"723115607","full_name":"iddm/nvngx-rs","owner":"iddm","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-06T14:51:52.000Z","size":163,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T17:09:33.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iddm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"iddm"}},"created_at":"2023-11-24T18:16:58.000Z","updated_at":"2024-04-07T20:41:56.000Z","dependencies_parsed_at":"2023-12-05T17:22:14.384Z","dependency_job_id":"dffe3fb8-4e8b-4c69-9b12-d49a0cc35d4a","html_url":"https://github.com/iddm/nvngx-rs","commit_stats":null,"previous_names":["vityafx/ngx-rs","iddm/nvngx-rs","vityafx/nvngx-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fnvngx-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fnvngx-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fnvngx-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fnvngx-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iddm","download_url":"https://codeload.github.com/iddm/nvngx-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477812,"owners_count":21437049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T06:26:34.135Z","updated_at":"2025-04-23T17:09:38.615Z","avatar_url":"https://github.com/iddm.png","language":"Rust","funding_links":["https://github.com/sponsors/iddm"],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/iddm/nvngx-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/iddm/nvngx-rs/actions/workflows/ci.yml)\n[![Crates](https://img.shields.io/crates/v/nvngx-rs.svg)](https://crates.io/crates/nvngx)\n[![Docs](https://docs.rs/nvngx-rs/badge.svg)](https://docs.rs/nvngx)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\n# NGX-rs\n\nA Rust wrapper over the NVIDIA NGX library.\n\n## Supported features\n\n- DLSS\n\n## Supported graphics APIs\n\n- Vulkan (only the [`ash`](https://crates.io/crates/ash) backend).\n\n## MSRV\n1.65\n\n## DLSS integration example\n\nOne can have something like that:\n\n```rust\n#[derive(Debug)]\npub struct Ngx {\n    super_sampling_feature: ngx::SuperSamplingFeature,\n    system: ngx::System,\n}\n\nimpl Ngx {\n    /// Creates a new NVIDIA NGX module instance with the super\n    /// sampling feature.\n    pub fn new(\n        logical_device: \u0026LogicalDevice,\n        command_pool: \u0026CommandPool,\n        extent: vk::Extent2D,\n        dlss_profile: crate::config::DlssProfile,\n    ) -\u003e Result\u003cSelf\u003e {\n        let path = std::path::Path::new(\"/tmp/\").canonicalize().unwrap();\n\n        let physical_device = logical_device.get_physical().get_handle();\n        let instance = \u0026logical_device.get_instance();\n        let system = ngx::System::new(\n            None,\n            env!(\"CARGO_PKG_VERSION\"),\n            \u0026path,\n            instance.get_entry(),\n            \u0026instance.get(),\n            physical_device,\n            logical_device.handle(),\n        )?;\n\n        let capability_parameters = ngx::vk::FeatureParameters::get_capability_parameters()?;\n        log::debug!(\"NGX capability parameters: {capability_parameters:#?}\");\n\n        if let Err(e) = capability_parameters.supports_super_sampling() {\n            return Err(e.into());\n        }\n\n        log::debug!(\"DLSS is supported, great!\");\n\n        if !capability_parameters.is_super_sampling_initialised() {\n            return Err(\"Super sampling couldn't initialise.\".into());\n        }\n\n        log::debug!(\"DLSS initialised correctly!\");\n\n        let optimal_settings = ngx::vk::SuperSamplingOptimalSettings::get_optimal_settings(\n            \u0026capability_parameters,\n            extent.width,\n            extent.height,\n            dlss_profile.into(),\n        )?;\n\n        let command_buffer = command_pool.allocate_primary_command_buffer_scoped()?;\n        command_buffer.set_label(\"NGXCreateSuperSampling\")?;\n\n        command_buffer.begin_recording()?;\n\n        let super_sampling_feature = system.create_super_sampling_feature(\n            command_buffer.get(),\n            capability_parameters,\n            optimal_settings.into(),\n        )?;\n\n        command_buffer.finish_recording()?;\n        command_buffer.submit_and_wait_and_clear()?;\n\n        Ok(Self {\n            super_sampling_feature,\n            system,\n        })\n    }\n}\n```\n\nAfter that, to render, one need to properly prepare the feature, before\nissuing a draw call. For example, (using the `ash` crate for Vulkan):\n\n```rust\nfn update_upscaling_configuration_parameters(\u0026mut self) -\u003e Result {\n    let jitter = self.get_pixel_jitter();\n    let dlss = self.ngx.super_sampling_feature;\n    let parameters = dlss.get_evaluation_parameters_mut();\n\n    // This is where you render your main scene to. Shouldn't contain\n    // any text, just the scene, shouldn't be post-processed.\n    parameters.set_color_input(self.storage_image.as_ref().into());\n\n    let mut output: ngx::VkImageResourceDescription = self.upscaled_image.as_ref().into();\n    output.set_writable();\n    /// The image to which the DLSS will upscale to. Should be of the\n    /// output resolution (rendering resolution).\n    parameters.set_color_output(output);\n\n    // An image of motion vectors.\n    parameters.set_motions_vectors(\n        self.motion_vectors_image.as_ref().into(),\n        // Use the default scaling.\n        None,\n    );\n\n    /// Jitter is optional, but should provide better results. Note that\n    /// it must also be applied to the camera, and so the motion vectors\n    /// should include it.\n    parameters.set_jitter_offsets(jitter.x, jitter.y);\n\n    /// The depth buffer.\n    parameters.set_depth_buffer(self.depth_image.as_ref().into());\n    let rendering_size = [\n        self.storage_image.get_extent().width,\n        self.storage_image.get_extent().height,\n    ];\n\n    // The dimensions of the output image.\n    parameters.set_rendering_dimensions([0, 0], rendering_size);\n\n    Ok(())\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fnvngx-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiddm%2Fnvngx-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fnvngx-rs/lists"}