Rust-GPU / Rust-GPU/rust-gpu

[Migrated] RuntimeArray as uniform creates invalid spv instead of erroring

Đang mở
#68 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Rust
Star
3.4k
Fork
126
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1098
Old labels: t: bug
Originally creatd by Firestar99 on 2023-11-13T10:30:24Z


Expected Behaviour

In the following example, you can't have a uniform with a variable amount of data, so it must be a storage_buffer instead. Currently, rust-gpu compiles it to an invalid spv, that is then caught by spirv-opt running afterwards, noticing the invalid spv and failing the build. Rust-gpu should probably catch this mistake earlier in the build pipeline and not even produce an invalid spv in the first place.

#[spirv(descriptor_set = 0, binding = 0, uniform)] vertex_input_buffer: &[f32],
Example & Steps To Reproduce
  1. have a shader entry point with the parameter declaration above
  2. compile the shader crate
  3. observe compile failing due to invalid spv being optimized

System Info

  • Rust: nightly-2023-05-27
  • OS: Ubuntu 23.04
  • GPU: irrevelant
  • SPIR-V: v2023.5 unknown hash, 2023-10-17T17:19:41

Backtrace

Backtrace

   Compiling space-engine v0.1.0 (<project dir>/space-engine)
error: failed to run custom build command for `space-engine v0.1.0 (<project dir>/space-engine)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `<project dir>/target/debug/build/space-engine-ab7683b3782ee376/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RUSTGPU_CODEGEN_ARGS
  cargo:rerun-if-env-changed=RUSTGPU_RUSTFLAGS
  --- stderr
     Compiling space-engine-shader v0.1.0 (<project dir>/space-engine-shader)
warning: error:0:0 - [VUID-StandaloneSpirv-OpTypeRuntimeArray-04680] For Vulkan, an OpTypeStruct variable containing an OpTypeRuntimeArray must be decorated with BufferBlock if it has storage class Uniform.
    |
    = note: spirv-opt failed, leaving as unoptimized
    = note: module `<project dir>/target/spirv-builder/spirv-unknown-vulkan1.2/release/deps/space_engine_shader.spvs/space-renderer-lod_obj-opaque_shader-opaque_vs.spv`
  error: error:0:0 - [VUID-StandaloneSpirv-OpTypeRuntimeArray-04680] For Vulkan, an OpTypeStruct variable containing an OpTypeRuntimeArray must be decorated with BufferBlock if it has storage class Uniform.
    |
    = note: spirv-val failed
    = note: module `<project dir>/target/spirv-builder/spirv-unknown-vulkan1.2/release/deps/space_engine_shader.spvs/space-renderer-lod_obj-opaque_shader-opaque_vs.spv`
  warning: `space-engine-shader` (lib) generated 1 warning
  error: could not compile `space-engine-shader` (lib) due to previous error; 1 warning emitted
  Error: SpirvBuilderError(BuildFailed)
Process finished with exit code 101

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với khai báo tham số điểm vào shader bằng #[spirv(..., uniform)] vertex_input_buffer: &[f32] và theo dõi đường dẫn của trình biên dịch xử lý các mảng runtime trong vùng lưu trữ uniform. Tái hiện quá trình build bằng spirv-opt và spirv-val, sau đó xác nhận rằng trình biên dịch báo cáo tổ hợp uniform/runtime-array không hợp lệ trước khi phát ra SPIR-V không hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.