-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2276 from Try/msl-descriptor-array-fixup
Fix codegen for shader with only bindless ssbo
- Loading branch information
Showing
4 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...s-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag
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,68 @@ | ||
#pragma clang diagnostic ignored "-Wmissing-prototypes" | ||
|
||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using namespace metal; | ||
|
||
template<typename T> | ||
struct spvBufferDescriptor | ||
{ | ||
T value; | ||
int length; | ||
const device T& operator -> () const device | ||
{ | ||
return value; | ||
} | ||
const device T& operator * () const device | ||
{ | ||
return value; | ||
} | ||
}; | ||
|
||
template<typename T> | ||
struct spvDescriptorArray; | ||
|
||
template<typename T> | ||
struct spvDescriptorArray<device T*> | ||
{ | ||
spvDescriptorArray(const device spvBufferDescriptor<device T*>* ptr) : ptr(ptr) | ||
{ | ||
} | ||
const device T* operator [] (size_t i) const | ||
{ | ||
return ptr[i].value; | ||
} | ||
const int length(int i) const | ||
{ | ||
return ptr[i].length; | ||
} | ||
const device spvBufferDescriptor<device T*>* ptr; | ||
}; | ||
|
||
struct Ssbo | ||
{ | ||
uint val; | ||
uint data[1]; | ||
}; | ||
|
||
struct main0_in | ||
{ | ||
uint inputId [[user(locn0)]]; | ||
}; | ||
|
||
fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor<const device Ssbo*>* ssbo_ [[buffer(0)]]) | ||
{ | ||
spvDescriptorArray<const device Ssbo*> ssbo {ssbo_}; | ||
|
||
uint _15 = in.inputId; | ||
if (ssbo[_15]->val == 2u) | ||
{ | ||
discard_fragment(); | ||
} | ||
if (int((ssbo.length(123) - 4) / 4) == 25) | ||
{ | ||
discard_fragment(); | ||
} | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
...s-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag
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,68 @@ | ||
#pragma clang diagnostic ignored "-Wmissing-prototypes" | ||
|
||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using namespace metal; | ||
|
||
template<typename T> | ||
struct spvBufferDescriptor | ||
{ | ||
T value; | ||
int length; | ||
const device T& operator -> () const device | ||
{ | ||
return value; | ||
} | ||
const device T& operator * () const device | ||
{ | ||
return value; | ||
} | ||
}; | ||
|
||
template<typename T> | ||
struct spvDescriptorArray; | ||
|
||
template<typename T> | ||
struct spvDescriptorArray<device T*> | ||
{ | ||
spvDescriptorArray(const device spvBufferDescriptor<device T*>* ptr) : ptr(ptr) | ||
{ | ||
} | ||
const device T* operator [] (size_t i) const | ||
{ | ||
return ptr[i].value; | ||
} | ||
const int length(int i) const | ||
{ | ||
return ptr[i].length; | ||
} | ||
const device spvBufferDescriptor<device T*>* ptr; | ||
}; | ||
|
||
struct Ssbo | ||
{ | ||
uint val; | ||
uint data[1]; | ||
}; | ||
|
||
struct main0_in | ||
{ | ||
uint inputId [[user(locn0)]]; | ||
}; | ||
|
||
fragment void main0(main0_in in [[stage_in]], const device spvBufferDescriptor<const device Ssbo*>* ssbo_ [[buffer(0)]]) | ||
{ | ||
spvDescriptorArray<const device Ssbo*> ssbo {ssbo_}; | ||
|
||
uint _15 = in.inputId; | ||
if (ssbo[_15]->val == 2u) | ||
{ | ||
discard_fragment(); | ||
} | ||
if (int((ssbo.length(123) - 4) / 4) == 25) | ||
{ | ||
discard_fragment(); | ||
} | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
...s-msl/frag/runtime_array_as_argument_buffer_buf.msl3.argument-tier-1.rich-descriptor.frag
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,15 @@ | ||
#version 460 | ||
|
||
#extension GL_ARB_separate_shader_objects : enable | ||
#extension GL_EXT_nonuniform_qualifier : enable | ||
|
||
layout(location = 0) in flat uint inputId; | ||
|
||
layout(binding = 0, std430) readonly buffer Ssbo { uint val; uint data[]; } ssbo[]; | ||
|
||
void main() { | ||
if(ssbo[nonuniformEXT(inputId)].val==2) | ||
discard; | ||
if(ssbo[123].data.length()==25) | ||
discard; | ||
} |
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