-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hlsl): emit constructor functions for arrays (#2281)
* test(hlsl-out): add failing case for array as ctor arg See issue #2184. * fix(hlsl): emit constructor functions for arrays
- Loading branch information
1 parent
67c081b
commit 0b87d19
Showing
12 changed files
with
146 additions
and
9 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,2 @@ | ||
( | ||
) |
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,10 @@ | ||
struct Ah { | ||
inner: array<f32, 2>, | ||
}; | ||
@group(0) @binding(0) | ||
var<storage> ah: Ah; | ||
|
||
@compute @workgroup_size(1) | ||
fn cs_main() { | ||
_ = ah; | ||
} |
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,17 @@ | ||
#version 310 es | ||
|
||
precision highp float; | ||
precision highp int; | ||
|
||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | ||
|
||
struct Ah { | ||
float inner[2]; | ||
}; | ||
layout(std430) readonly buffer Ah_block_0Compute { Ah _group_0_binding_0_cs; }; | ||
|
||
|
||
void main() { | ||
Ah unnamed = _group_0_binding_0_cs; | ||
} | ||
|
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,24 @@ | ||
|
||
struct Ah { | ||
float inner[2]; | ||
}; | ||
|
||
ByteAddressBuffer ah : register(t0); | ||
|
||
typedef float ret_Constructarray2_float_[2]; | ||
ret_Constructarray2_float_ Constructarray2_float_(float arg0, float arg1) { | ||
float ret[2] = { arg0, arg1 }; | ||
return ret; | ||
} | ||
|
||
Ah ConstructAh(float arg0[2]) { | ||
Ah ret = (Ah)0; | ||
ret.inner = arg0; | ||
return ret; | ||
} | ||
|
||
[numthreads(1, 1, 1)] | ||
void cs_main() | ||
{ | ||
Ah unnamed = ConstructAh(Constructarray2_float_(asfloat(ah.Load(0+0)), asfloat(ah.Load(0+4)))); | ||
} |
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,3 @@ | ||
vertex=() | ||
fragment=() | ||
compute=(cs_main:cs_5_1 ) |
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,18 @@ | ||
// language: metal2.0 | ||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
|
||
using metal::uint; | ||
|
||
struct type_1 { | ||
float inner[2]; | ||
}; | ||
struct Ah { | ||
type_1 inner; | ||
}; | ||
|
||
kernel void cs_main( | ||
device Ah const& ah [[user(fake0)]] | ||
) { | ||
Ah unnamed = ah; | ||
} |
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,38 @@ | ||
; SPIR-V | ||
; Version: 1.1 | ||
; Generator: rspirv | ||
; Bound: 20 | ||
OpCapability Shader | ||
OpExtension "SPV_KHR_storage_buffer_storage_class" | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint GLCompute %12 "cs_main" | ||
OpExecutionMode %12 LocalSize 1 1 1 | ||
OpDecorate %6 ArrayStride 4 | ||
OpMemberDecorate %7 0 Offset 0 | ||
OpDecorate %8 NonWritable | ||
OpDecorate %8 DescriptorSet 0 | ||
OpDecorate %8 Binding 0 | ||
OpDecorate %9 Block | ||
OpMemberDecorate %9 0 Offset 0 | ||
%2 = OpTypeVoid | ||
%4 = OpTypeInt 32 1 | ||
%3 = OpConstant %4 2 | ||
%5 = OpTypeFloat 32 | ||
%6 = OpTypeArray %5 %3 | ||
%7 = OpTypeStruct %6 | ||
%9 = OpTypeStruct %7 | ||
%10 = OpTypePointer StorageBuffer %9 | ||
%8 = OpVariable %10 StorageBuffer | ||
%13 = OpTypeFunction %2 | ||
%14 = OpTypePointer StorageBuffer %7 | ||
%16 = OpTypeInt 32 0 | ||
%15 = OpConstant %16 0 | ||
%12 = OpFunction %2 None %13 | ||
%11 = OpLabel | ||
%17 = OpAccessChain %14 %8 %15 | ||
OpBranch %18 | ||
%18 = OpLabel | ||
%19 = OpLoad %7 %17 | ||
OpReturn | ||
OpFunctionEnd |
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,11 @@ | ||
struct Ah { | ||
inner: array<f32,2>, | ||
} | ||
|
||
@group(0) @binding(0) | ||
var<storage> ah: Ah; | ||
|
||
@compute @workgroup_size(1, 1, 1) | ||
fn cs_main() { | ||
_ = ah; | ||
} |
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