-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSL: Fix emission of bindless helper template for bindless SSBO.
- Loading branch information
1 parent
208adcd
commit 1b97ecd
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...o-opt/comp/simple-bindless-ssbo.msl2.argument.argument-tier-1.device-argument-buffer.comp
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,45 @@ | ||
#pragma clang diagnostic ignored "-Wmissing-prototypes" | ||
|
||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using namespace metal; | ||
|
||
template<typename T> | ||
struct spvDescriptor | ||
{ | ||
T value; | ||
}; | ||
|
||
template<typename T> | ||
struct spvDescriptorArray | ||
{ | ||
spvDescriptorArray(const device spvDescriptor<T>* ptr) : ptr(&ptr->value) | ||
{ | ||
} | ||
const device T& operator [] (size_t i) const | ||
{ | ||
return ptr[i]; | ||
} | ||
const device T* ptr; | ||
}; | ||
|
||
struct SSBO | ||
{ | ||
float4 a; | ||
}; | ||
|
||
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); | ||
|
||
struct spvDescriptorSetBuffer0 | ||
{ | ||
spvDescriptor<device SSBO *> ssbos [[id(0)]][1] /* unsized array hack */; | ||
}; | ||
|
||
kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) | ||
{ | ||
spvDescriptorArray<device SSBO*> ssbos {spvDescriptorSet0.ssbos}; | ||
|
||
ssbos[gl_WorkGroupID.x]->a += float4(2.0); | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
...o-opt/comp/simple-bindless-ssbo.msl2.argument.argument-tier-1.device-argument-buffer.comp
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,13 @@ | ||
#version 450 | ||
#extension GL_EXT_nonuniform_qualifier : require | ||
layout(local_size_x = 1) in; | ||
|
||
layout(set = 0, binding = 0) buffer SSBO | ||
{ | ||
vec4 a; | ||
} ssbos[]; | ||
|
||
void main() | ||
{ | ||
ssbos[gl_WorkGroupID.x].a += 2.0; | ||
} |
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