-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entry: apply
NonWritable
to read-only StorageBuffer
s.
- Loading branch information
Showing
6 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 @@ | ||
// HACK(eddyb) duplicate of non-writable-storage_buffer.spirt.rs because only-/ignore- do not work with revisions. | ||
// only-not_spirt | ||
#![crate_name = "non_writable_storage_buffer"] | ||
|
||
// Tests that only `&T` (where `T: Freeze`) storage buffers get `NonWritable`. | ||
|
||
// build-pass | ||
// compile-flags: -C llvm-args=--disassemble-globals | ||
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" | ||
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
|
||
// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output | ||
// and the pre-`vulkan1.2` output, but per-revisions `{only,ignore}-*` directives | ||
// are not supported in `compiletest-rs`. | ||
// ignore-vulkan1.2 | ||
|
||
use spirv_std::spirv; | ||
|
||
#[spirv(fragment)] | ||
pub fn main( | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] buf_imm: &u32, | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] buf_mut: &mut u32, | ||
// FIXME(eddyb) use `AtomicU32` when methods on that work. | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] | ||
buf_interior_mut: &core::cell::UnsafeCell<u32>, | ||
) { | ||
let x = *buf_imm; | ||
*buf_mut = x; | ||
unsafe { | ||
*buf_interior_mut.get() = x; | ||
} | ||
} |
This file contains 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 @@ | ||
OpCapability Float64 | ||
OpCapability Int16 | ||
OpCapability Int64 | ||
OpCapability Int8 | ||
OpCapability ShaderClockKHR | ||
OpCapability Shader | ||
OpExtension "SPV_KHR_shader_clock" | ||
OpMemoryModel Logical Simple | ||
OpEntryPoint Fragment %1 "main" | ||
OpExecutionMode %1 OriginUpperLeft | ||
%2 = OpString "$OPSTRING_FILENAME/non-writable-storage_buffer.not_spirt.rs" | ||
%3 = OpString "$OPSTRING_FILENAME/cell.rs" | ||
OpName %4 "buf_imm" | ||
OpName %5 "buf_mut" | ||
OpName %6 "buf_interior_mut" | ||
OpDecorate %4 NonWritable | ||
OpDecorate %7 Block | ||
OpMemberDecorate %7 0 Offset 0 | ||
OpDecorate %4 DescriptorSet 0 | ||
OpDecorate %4 Binding 0 | ||
OpDecorate %5 DescriptorSet 0 | ||
OpDecorate %5 Binding 1 | ||
OpDecorate %6 DescriptorSet 0 | ||
OpDecorate %6 Binding 2 | ||
%8 = OpTypeInt 32 0 | ||
%9 = OpTypePointer StorageBuffer %8 | ||
%10 = OpTypeVoid | ||
%11 = OpTypeFunction %10 | ||
%7 = OpTypeStruct %8 | ||
%12 = OpTypePointer StorageBuffer %7 | ||
%13 = OpConstant %8 0 | ||
%4 = OpVariable %12 StorageBuffer | ||
%5 = OpVariable %12 StorageBuffer | ||
%6 = OpVariable %12 StorageBuffer |
This file contains 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 @@ | ||
// HACK(eddyb) duplicate of non-writable-storage_buffer.not_spirt.rs because only-/ignore- do not work with revisions. | ||
// only-spirt | ||
#![crate_name = "non_writable_storage_buffer"] | ||
|
||
// Tests that only `&T` (where `T: Freeze`) storage buffers get `NonWritable`. | ||
|
||
// build-pass | ||
// compile-flags: -C llvm-args=--disassemble-globals | ||
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" | ||
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
|
||
// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output | ||
// and the pre-`vulkan1.2` output, but per-revisions `{only,ignore}-*` directives | ||
// are not supported in `compiletest-rs`. | ||
// ignore-vulkan1.2 | ||
|
||
use spirv_std::spirv; | ||
|
||
#[spirv(fragment)] | ||
pub fn main( | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] buf_imm: &u32, | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] buf_mut: &mut u32, | ||
// FIXME(eddyb) use `AtomicU32` when methods on that work. | ||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] | ||
buf_interior_mut: &core::cell::UnsafeCell<u32>, | ||
) { | ||
let x = *buf_imm; | ||
*buf_mut = x; | ||
unsafe { | ||
*buf_interior_mut.get() = x; | ||
} | ||
} |
This file contains 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 @@ | ||
OpCapability Shader | ||
OpCapability Float64 | ||
OpCapability Int64 | ||
OpCapability Int16 | ||
OpCapability Int8 | ||
OpCapability ShaderClockKHR | ||
OpExtension "SPV_KHR_shader_clock" | ||
OpMemoryModel Logical Simple | ||
OpEntryPoint Fragment %1 "main" | ||
OpExecutionMode %1 OriginUpperLeft | ||
%2 = OpString "$OPSTRING_FILENAME/non-writable-storage_buffer.spirt.rs" | ||
OpName %3 "buf_imm" | ||
OpName %4 "buf_mut" | ||
OpName %5 "buf_interior_mut" | ||
OpDecorate %6 Block | ||
OpMemberDecorate %6 0 Offset 0 | ||
OpDecorate %3 NonWritable | ||
OpDecorate %3 Binding 0 | ||
OpDecorate %3 DescriptorSet 0 | ||
OpDecorate %4 Binding 1 | ||
OpDecorate %4 DescriptorSet 0 | ||
OpDecorate %5 Binding 2 | ||
OpDecorate %5 DescriptorSet 0 | ||
%7 = OpTypeVoid | ||
%8 = OpTypeFunction %7 | ||
%9 = OpTypeInt 32 0 | ||
%10 = OpTypePointer StorageBuffer %9 | ||
%6 = OpTypeStruct %9 | ||
%11 = OpTypePointer StorageBuffer %6 | ||
%3 = OpVariable %11 StorageBuffer | ||
%12 = OpConstant %9 0 | ||
%4 = OpVariable %11 StorageBuffer | ||
%5 = OpVariable %11 StorageBuffer |