wgpu | Cross-platform , safe , pure-rust graphics api

 by   gfx-rs Rust Version: v0.16.1 License: Apache-2.0

kandi X-RAY | wgpu Summary

kandi X-RAY | wgpu Summary

wgpu is a Rust library. wgpu has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

The repository hosts the following libraries:. For an overview of all the components in the gfx-rs ecosystem, see the big picture.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wgpu has a medium active ecosystem.
              It has 7976 star(s) with 614 fork(s). There are 100 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 410 open issues and 1126 have been closed. On average issues are closed in 57 days. There are 36 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of wgpu is v0.16.1

            kandi-Quality Quality

              wgpu has 0 bugs and 0 code smells.

            kandi-Security Security

              wgpu has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              wgpu code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              wgpu is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              wgpu releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              It has 17 lines of code, 0 functions and 6 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wgpu
            Get all kandi verified functions for this library.

            wgpu Key Features

            No Key Features are available at this moment for wgpu.

            wgpu Examples and Code Snippets

            No Code Snippets are available at this moment for wgpu.

            Community Discussions

            QUESTION

            Is it possible to index dynamically into a WebGPU storage buffer?
            Asked 2022-Feb-02 at 18:39

            I'm trying write a WGSL shader that reads an octree that is stored in a storage buffer. The problem is, the compiler doesn't like the dynamic index I'm calculating to access leaves in the storage buffer. wgpu produces the following validation error:

            ...

            ANSWER

            Answered 2022-Feb-02 at 18:39

            Indexing into storage buffers is totally fine. What Naga doesn't like is this line:

            Source https://stackoverflow.com/questions/70910601

            QUESTION

            Captured references in lifetimes
            Asked 2021-Dec-29 at 13:44

            In (an artificial simplification of) my project, I have a struct ContainsData which can only be modified through a handle HoldsRef<'a>, which holds a ref to some field in ContainsData. In addition, after use of the handle, some cleanup method must be called.

            ...

            ANSWER

            Answered 2021-Dec-29 at 13:44

            Edit: Found a partial solution below.

            Let's understand what's going on here.

            Lifetimes in closures (impl Fn(&T), and also impl Fn(T<'_>), which is the same as yours impl Fn(HoldsRef)), do not desugar into generic lifetimes like normal elided lifetimes (where fn foo(_: &T) desugars into fn foo<'a>(_: &'a T)); instead, they're desugared into higher ranked trait bounds.

            That is, impl Fn(&T) desugars into impl for<'a> Fn(&'a T), and in the same manner, impl Fn(HoldsRef) desugars into impl for<'a> Fn(HoldsRef<'a>). See also How does for<> syntax differ from a regular lifetime bound?.

            HRTB (Higher-Ranked Traits Bounds) means that the lifetime can be any lifetime. And "any lifetime" includes, of course, 'static. And because 'static is the longest lifetime possible, the compiler just use this as if you've written impl Fn(HoldsRef<'static>). Note this is only true from the callback's point of view, that is, the callback must be able to handle this case but modify() can call it with whatever lifetime it wants, not only static (as opposed to what would happen if you'd specify impl Fn(HoldsRef<'static>), then you'd have to pass a HoldsRef<'static>).

            Because the HoldsRef::set() method takes &'a i64, and 'a is 'static, so it's like it takes &'static i64. Now you will understand why the compiler complains when you provide a shorter lifetime.

            You may think that the solution is just to take a generic lifetime instead of HRTB, and tie it to self:

            Source https://stackoverflow.com/questions/70490143

            QUESTION

            wgpu WGSL compute shader does not appear to be doing anything
            Asked 2021-Aug-31 at 02:25

            I'm trying to follow along the "hello compute" example from wgpu on Windows 10 (with some minor modifications, mainly gutting the shader so it does basically no actual computing), but when I read the buffer at the end, it's always zeroed out.

            This is the shader I'm trying to run, it compiles fine and I think it's correct

            ...

            ANSWER

            Answered 2021-Aug-31 at 02:25

            The program works fine when I'm running it on my discrete graphics card, but wgpu is bugged on my integrated Intel HD Graphics 630, which is why the program appeared not to work.

            Source https://stackoverflow.com/questions/68969514

            QUESTION

            wgpu-rs: `thread 'main' panicked at 'Texture[1] does not exist'`
            Asked 2021-Aug-22 at 12:20

            I create a wgpu::TextureView within a render method as below:

            ...

            ANSWER

            Answered 2021-Aug-22 at 12:20

            There is an issue for this.

            This can be solved by forcing the SurfaceTexture to be dropped after the TextureView.

            Source https://stackoverflow.com/questions/68881273

            QUESTION

            Rust - update tree node with output from children
            Asked 2021-Aug-21 at 20:55

            I'm trying to implement a tree structure where each node is updated using some output from its children.

            The output can't be cloned or moved in the final applicaton. I'm running into multiple borrows errors, when I give the node ref's of its children to update it.

            I'm using the indextree crate.

            Can't get my head around it... Can't find anything like this with this updating behavior.

            my example code :

            The tree contains dynamic nodes like this

            ...

            ANSWER

            Answered 2021-Aug-21 at 20:25

            The CalcNode::update function does not actually need access to its children - really it just wants the value that is calculated from them, so you can move the calculation out of the update function to prevent aliasing references:

            Source https://stackoverflow.com/questions/68875479

            QUESTION

            Wgpu: correctly written WGSL shader parsing error
            Asked 2021-Aug-19 at 04:05

            I am using wgpu-rs and writing shaders in WGSL. To test an example shader, I copied some sample code from here: https://www.w3.org/TR/WGSL/#var-and-let.

            Here is my simple shader:

            ...

            ANSWER

            Answered 2021-Aug-19 at 04:05

            It appears the wgpu-rs shader validation is favoring the built-in step() function over a variable declared with the same name. Going by the W3 WGSL docs, this should resolve to the variable since it is in a closer scope.

            Renaming the step variable to something else should fix the immediate problem.

            There is already an issue created to track this, but I've added this as another example.

            Source https://stackoverflow.com/questions/68833291

            QUESTION

            How can I draw a line while only using vertices and indices?
            Asked 2021-Aug-16 at 14:56

            I use wgpu as my graphics backend for my project.

            this is my current implementation:

            ...

            ANSWER

            Answered 2021-Aug-16 at 14:56

            Untested but should work:

            Source https://stackoverflow.com/questions/68802146

            QUESTION

            Why does Rust seem to ignore my lifetime annotation?
            Asked 2021-Mar-07 at 06:18

            I have the following class

            ...

            ANSWER

            Answered 2021-Mar-07 at 06:18

            Thanks to @trentcl for pointing out the solution. I did not realize that functions can have lifetime annotations independently from traits, so I came up with the very convoluted annotations which did not convey my intent properly. Simplifying to the following fixed my issue

            Source https://stackoverflow.com/questions/66503664

            QUESTION

            Compute Shader Corrupting Vertex Buffer
            Asked 2020-Oct-08 at 08:31

            I'm making a tutorial for computing tangents and bitangents in a WGPU (Vulkan GLSL) compute shader. I'm creating the vertex buffer on the CPU from a .obj I made in blender.

            Here's the code for the compute shader.

            ...

            ANSWER

            Answered 2020-Oct-08 at 08:31

            Turns out Vulkan style GLSL aligns to the largest field in the struct when using std430.

            https://github.com/KhronosGroup/glslang/issues/264

            In my case it's vec3. The vec2 tex_coord is throwing it off causing the shader to pull data from the wrong parts of the vertex buffer.

            The fix was to change the struct in model_load.comp to specify the individual components instead.

            Source https://stackoverflow.com/questions/64252846

            QUESTION

            wgpu-rs: Putting a Matrix3 into a vertex shader results in odd behavior but using a Matrix4 works fine
            Asked 2020-May-13 at 16:24

            Using wgpu-rs, I'm trying to get a 3x3 cgmath matrix into a shader (compiled using glsl-to-spirv). However, the resulting mat3 in the shader has incorrect data. When I replace the mat3 and Matrix3 with mat4 and Matrix4, everything works fine and the matrix has correct data.

            Vertex Shader:

            ...

            ANSWER

            Answered 2020-May-13 at 16:24

            This is an open issue in wgpu-rs. Indeed the simplest workaround may be to make your mat3 into a mat4 until it is resolved.

            The problem seems to be a mistake of alignment in generating SPIR-V. The actual alignment is:

            1. If the member is a scalar consuming N basic machine units, the base alignment is N.
            2. If the member is a two- or four-component vector with components consuming N basic machine units, the base alignment is 2N or 4N, respectively.
            3. If the member is a three-component vector with components consuming N basic machine units, the base alignment is 4N.
            4. If the member is an array of scalars or vectors, the base alignment and array stride are set to match the base alignment of a single array element, according to rules (1), (2), and (3), and rounded up to the base alignment of a vec4. The array may have padding at the end; the base offset of the member following the array is rounded up to the next multiple of the base alignment.

            You are in case 4. Having a mat4 should leave no extra padding on the end and not give any possibility for misalignment issues.

            Source https://stackoverflow.com/questions/61768628

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install wgpu

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            We have the Matrix space with a few different rooms that form the wgpu community:.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/gfx-rs/wgpu.git

          • CLI

            gh repo clone gfx-rs/wgpu

          • sshUrl

            git@github.com:gfx-rs/wgpu.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link