Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

PushConstant not being OpTypeStruct is invalid on Vulkan hosts #362

Closed

Description

@hrydgard

Quoth Baldur (hope he doesn't mind I post it here):

BTW I also noticed some invalid SPIR-V in your shader which may also affect this, you have a PushConstant storage class variable defined that is not an OpTypeStruct. All uniforms and push constant variables must be struct pointers with explicitly laid out structs.

Activity

  1. XAMPPRocky commented on Jan 5, 2021

    @XAMPPRocky
    Member

    Thank you for your issue! While I'm not doubting that is the case, I cannot find any reference in the SPIR-V spec that lays out that requirement. Perhaps they could expand further? @baldurk

    The closest thing I could find is the following:

    Composite objects in the UniformConstant, Uniform, and PushConstant Storage Classes must be explicitly laid out. The following apply to all the aggregate and matrix types describing such an object, recursively through their nested types

    Where composite is defined as "An aggregate, a matrix, or a vector.", which would imply to me that this is not a requirement for those storage classes containing scalars.

  2. msiglreith commented on Jan 5, 2021

    @msiglreith
    Contributor

    @XAMPPRocky That's probably referred to using Vulkan as host which comes with its own set of requirements and constraints:
    https://vulkan.lunarg.com/doc/view/1.2.131.1/mac/chunked_spec/chap14.html#interfaces-resources-pushconst

  3. hrydgard commented on Jan 5, 2021

    @hrydgard
    ContributorAuthor

    That's a good catch @msiglreith !

    Given how we want to use rust-gpu, having an option to, or at least initially, always following Vulkan's extra rules seems like the way to go.

  4. changed the title [-]Slightly invalid SPIR-V (PushConstant not OpTypeStruct), according to BaldurK[/-] [+]PushConstant not being OpTypeStruct is invalid on Vulkan hosts[/+] on Jan 5, 2021
  5. khyperia commented on Oct 28, 2021

    @khyperia
    Contributor

    I believe this was fixed by two things:

    1. ABI rewriting shenanigans of rustc taking a push constant struct and replacing it with a scalar - fixed by abi: readjust FnAbis to remove unsupported PassModes, via query hooks. #766
    2. Push constants being used directly instead of structs (i.e. #[spirv(push_constant)] asdf: &f32) - fixed by wrapping everything in a struct Deprecate #[spirv(block)] and auto-wrap in "interface blocks" instead. #576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: push constantIssues related to push constants.a: vulkanIssues specifically about Vulkan.c: rustc_codegen_spirvIssues specific to the rustc_codegen_spirv crate.t: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions