-
Notifications
You must be signed in to change notification settings - Fork 116
remove has_capability() checks
#531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Firestar99
wants to merge
2
commits into
main
Choose a base branch
from
remove_has_capability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind}; | |
| use crate::spirv_type::SpirvType; | ||
| use rspirv::spirv::{Decoration, Word}; | ||
| use rustc_abi::{Align, Size}; | ||
| use rustc_codegen_spirv_types::Capability; | ||
| use rustc_codegen_ssa::traits::BuilderMethods; | ||
| use rustc_errors::ErrorGuaranteed; | ||
| use rustc_middle::ty::Ty; | ||
|
|
@@ -50,13 +49,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
| .in_bounds_access_chain(u32_ptr, None, array, [actual_index]) | ||
| .unwrap() | ||
| .with_type(u32_ptr); | ||
| if self.builder.has_capability(Capability::ShaderNonUniform) { | ||
| // apply NonUniform to the operation and the index | ||
| self.emit() | ||
| .decorate(ptr.def(self), Decoration::NonUniform, []); | ||
| self.emit() | ||
| .decorate(actual_index, Decoration::NonUniform, []); | ||
| } | ||
| // apply NonUniform to the operation and the index | ||
| self.emit() | ||
| .decorate(ptr.def(self), Decoration::NonUniform, []); | ||
| self.emit() | ||
| .decorate(actual_index, Decoration::NonUniform, []); | ||
|
Comment on lines
-53
to
+56
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test using this feature, but not enabling It should trigger a validation error from the new SPIR-T-based validation pass, if I'm not mistaken. |
||
| self.load(u32_ty, ptr, Align::ONE) | ||
| } | ||
|
|
||
|
|
@@ -252,13 +249,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
| .in_bounds_access_chain(u32_ptr, None, array, [actual_index]) | ||
| .unwrap() | ||
| .with_type(u32_ptr); | ||
| if self.builder.has_capability(Capability::ShaderNonUniform) { | ||
| // apply NonUniform to the operation and the index | ||
| self.emit() | ||
| .decorate(ptr.def(self), Decoration::NonUniform, []); | ||
| self.emit() | ||
| .decorate(actual_index, Decoration::NonUniform, []); | ||
| } | ||
| // apply NonUniform to the operation and the index | ||
| self.emit() | ||
| .decorate(ptr.def(self), Decoration::NonUniform, []); | ||
| self.emit() | ||
| .decorate(actual_index, Decoration::NonUniform, []); | ||
| self.store(value, ptr, Align::ONE); | ||
| Ok(()) | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // build-pass | ||
| // compile-flags: -C llvm-args=--disassemble | ||
| // compile-flags: -C target-feature=+RuntimeDescriptorArray,+StorageBufferArrayDynamicIndexing | ||
| // compile-flags: -C target-feature=+ShaderNonUniform,+StorageBufferArrayNonUniformIndexing | ||
| // normalize-stderr-test "OpSource .*\n" -> "" | ||
| // normalize-stderr-test "OpLine .*\n" -> "" | ||
| // normalize-stderr-test "%\d+ = OpString .*\n" -> "" | ||
| // normalize-stderr-test "; .*\n" -> "" | ||
| // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
| // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
| // ignore-spv1.0 | ||
| // ignore-spv1.1 | ||
| // ignore-spv1.2 | ||
| // ignore-spv1.3 | ||
| // ignore-spv1.4 | ||
| // ignore-vulkan1.0 | ||
| // ignore-vulkan1.1 | ||
|
|
||
| use spirv_std::glam::*; | ||
| use spirv_std::image::*; | ||
| use spirv_std::*; | ||
|
|
||
| #[spirv(vertex)] | ||
| pub fn main( | ||
| index: u32, | ||
| #[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffers: &RuntimeArray< | ||
| TypedBuffer<Vec4>, | ||
| >, | ||
| out: &mut Vec4, | ||
| ) { | ||
| unsafe { | ||
| *out = **buffers.index(index as usize); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| OpCapability Shader | ||
| OpCapability StorageBufferArrayDynamicIndexing | ||
| OpCapability ShaderNonUniform | ||
| OpCapability RuntimeDescriptorArray | ||
| OpCapability StorageBufferArrayNonUniformIndexing | ||
| OpMemoryModel Logical Simple | ||
| OpEntryPoint Vertex %1 "main" %2 %3 %4 | ||
| OpName %2 "index" | ||
| OpName %3 "buffers" | ||
| OpName %4 "out" | ||
| OpDecorate %8 Block | ||
| OpMemberDecorate %8 0 Offset 0 | ||
| OpDecorate %2 Location 0 | ||
| OpDecorate %3 NonWritable | ||
| OpDecorate %3 Binding 0 | ||
| OpDecorate %3 DescriptorSet 0 | ||
| OpDecorate %4 Location 0 | ||
| OpDecorate %9 NonUniform | ||
| %10 = OpTypeInt 32 0 | ||
| %11 = OpTypePointer Input %10 | ||
| %12 = OpTypeFloat 32 | ||
| %13 = OpTypeVector %12 4 | ||
| %8 = OpTypeStruct %13 | ||
| %14 = OpTypeRuntimeArray %8 | ||
| %15 = OpTypePointer StorageBuffer %14 | ||
| %16 = OpTypePointer Output %13 | ||
| %17 = OpTypeVoid | ||
| %18 = OpTypeFunction %17 | ||
| %2 = OpVariable %11 Input | ||
| %19 = OpTypePointer StorageBuffer %8 | ||
| %3 = OpVariable %15 StorageBuffer | ||
| %20 = OpTypePointer StorageBuffer %13 | ||
| %21 = OpConstant %10 0 | ||
| %4 = OpVariable %16 Output | ||
| %1 = OpFunction %17 None %18 | ||
| %22 = OpLabel | ||
| %23 = OpLoad %10 %2 | ||
| %9 = OpAccessChain %19 %3 %23 | ||
| %24 = OpAccessChain %20 %9 %21 | ||
| %25 = OpLoad %13 %24 | ||
| OpStore %4 %25 | ||
| OpNoLine | ||
| OpReturn | ||
| OpFunctionEnd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // build-pass | ||
| // compile-flags: -C llvm-args=--disassemble | ||
| // compile-flags: -C target-feature=+RuntimeDescriptorArray,+StorageBufferArrayDynamicIndexing | ||
| // normalize-stderr-test "OpSource .*\n" -> "" | ||
| // normalize-stderr-test "OpLine .*\n" -> "" | ||
| // normalize-stderr-test "%\d+ = OpString .*\n" -> "" | ||
| // normalize-stderr-test "; .*\n" -> "" | ||
| // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
| // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
| // ignore-spv1.0 | ||
| // ignore-spv1.1 | ||
| // ignore-spv1.2 | ||
| // ignore-spv1.3 | ||
| // ignore-spv1.4 | ||
| // ignore-vulkan1.0 | ||
| // ignore-vulkan1.1 | ||
|
|
||
| use spirv_std::glam::*; | ||
| use spirv_std::image::*; | ||
| use spirv_std::*; | ||
|
|
||
| #[spirv(vertex)] | ||
| pub fn main( | ||
| index: u32, | ||
| #[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffers: &RuntimeArray< | ||
| TypedBuffer<Vec4>, | ||
| >, | ||
| out: &mut Vec4, | ||
| ) { | ||
| unsafe { | ||
| *out = **buffers.index(index as usize); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
tests/compiletests/ui/arch/non_uniform/buffer_uniform.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| OpCapability Shader | ||
| OpCapability StorageBufferArrayDynamicIndexing | ||
| OpCapability RuntimeDescriptorArray | ||
| OpMemoryModel Logical Simple | ||
| OpEntryPoint Vertex %1 "main" %2 %3 %4 | ||
| OpName %2 "index" | ||
| OpName %3 "buffers" | ||
| OpName %4 "out" | ||
| OpDecorate %8 Block | ||
| OpMemberDecorate %8 0 Offset 0 | ||
| OpDecorate %2 Location 0 | ||
| OpDecorate %3 NonWritable | ||
| OpDecorate %3 Binding 0 | ||
| OpDecorate %3 DescriptorSet 0 | ||
| OpDecorate %4 Location 0 | ||
| %9 = OpTypeInt 32 0 | ||
| %10 = OpTypePointer Input %9 | ||
| %11 = OpTypeFloat 32 | ||
| %12 = OpTypeVector %11 4 | ||
| %8 = OpTypeStruct %12 | ||
| %13 = OpTypeRuntimeArray %8 | ||
| %14 = OpTypePointer StorageBuffer %13 | ||
| %15 = OpTypePointer Output %12 | ||
| %16 = OpTypeVoid | ||
| %17 = OpTypeFunction %16 | ||
| %2 = OpVariable %10 Input | ||
| %18 = OpTypePointer StorageBuffer %8 | ||
| %3 = OpVariable %14 StorageBuffer | ||
| %19 = OpTypePointer StorageBuffer %12 | ||
| %20 = OpConstant %9 0 | ||
| %4 = OpVariable %15 Output | ||
| %1 = OpFunction %16 None %17 | ||
| %21 = OpLabel | ||
| %22 = OpLoad %9 %2 | ||
| %23 = OpAccessChain %18 %3 %22 | ||
| %24 = OpAccessChain %19 %23 %20 | ||
| %25 = OpLoad %12 %24 | ||
| OpStore %4 %25 | ||
| OpNoLine | ||
| OpReturn | ||
| OpFunctionEnd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // build-pass | ||
| // compile-flags: -C llvm-args=--disassemble | ||
| // compile-flags: -C target-feature=+RuntimeDescriptorArray,+SampledImageArrayDynamicIndexing | ||
| // compile-flags: -C target-feature=+ShaderNonUniform,+SampledImageArrayNonUniformIndexing | ||
| // normalize-stderr-test "OpSource .*\n" -> "" | ||
| // normalize-stderr-test "OpLine .*\n" -> "" | ||
| // normalize-stderr-test "%\d+ = OpString .*\n" -> "" | ||
| // normalize-stderr-test "; .*\n" -> "" | ||
| // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
| // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
| // ignore-spv1.0 | ||
| // ignore-spv1.1 | ||
| // ignore-spv1.2 | ||
| // ignore-spv1.3 | ||
| // ignore-spv1.4 | ||
| // ignore-vulkan1.0 | ||
| // ignore-vulkan1.1 | ||
|
|
||
| use spirv_std::glam::*; | ||
| use spirv_std::image::*; | ||
| use spirv_std::*; | ||
|
|
||
| #[spirv(vertex)] | ||
| pub fn main( | ||
| index: u32, | ||
| #[spirv(descriptor_set = 0, binding = 0)] images: &RuntimeArray<Image2d>, | ||
| out: &mut Vec4, | ||
| ) { | ||
| unsafe { | ||
| *out = images.index(index as usize).fetch(UVec2::new(1, 2)); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is weird. I would almost want to say that the instruction is not yet supported, rather than claiming any connection to
VariablePointers(which doesn't give you pointer equality in general, just in very narrow cases).