-
Notifications
You must be signed in to change notification settings - Fork 417
Description
Source:
// 0 - 1
// | / 4
// 2 / |
// 3 - 5
static const float2 rect_to_triangle_mapping[] = {
float2(-0.5, 0.5),
float2(0.5, 0.5),
float2(-0.5, -0.5),
float2(-0.5, -0.5),
float2(0.5, 0.5),
float2(0.5, -0.5),
};
struct Rect {
float2 center;
float2 size;
};
struct VRectOut {
float4 pos : SV_Position;
nointerpolation uint32_t rect_id;
};
[shader("vertex")]
VRectOut rects_vert(
[[vk::binding(0, 0)]] const StructuredBuffer<Rect> rects : register(u0, space0),
uint32_t vertex_id : SV_VertexID) {
VRectOut output;
uint32_t rect_id = vertex_id / 6;
Rect r = rects[rect_id];
output.pos.xy = r.center + rect_to_triangle_mapping[vertex_id % 6] * r.size;
output.pos.w = 1.0;
output.rect_id = rect_id;
return output;
}Compling: slangc -entry rects_vert -o a.metal
Expected: a [[buffer(0)]] buffer in compiled shader argument.
Actual: got none:
#include <metal_stdlib>
#include <metal_math>
#include <metal_texture>
using namespace metal;
#line 5 "a.slang"
constant array<float2, int(6)> rect_to_triangle_mapping_0 = { float2(-0.5, 0.5), float2(0.5, 0.5), float2(-0.5, -0.5), float2(-0.5, -0.5), float2(0.5, 0.5), float2(0.5, -0.5) };
#line 19
struct VRectOut_0
{
float4 pos_0;
[[flat]] uint rect_id_0;
};
#line 14
struct Rect_0
{
float2 center_0;
float2 size_0;
};
#line 25
struct KernelContext_0
{
Rect_0 device* entryPointParams_rects_0;
};
#line 25
VRectOut_0 rects_vert_0(const uint thread* vertex_id_0, KernelContext_0 thread* kernelContext_0)
{
uint rect_id_1 = *vertex_id_0 / 6U;
#line 30
Rect_0 device* _S1 = kernelContext_0->entryPointParams_rects_0+rect_id_1;
#line 29
thread VRectOut_0 output_0;
(&output_0)->pos_0.xy = _S1->center_0 + rect_to_triangle_mapping_0[*vertex_id_0 % 6U] * _S1->size_0;
(&output_0)->pos_0.w = 1.0;
(&output_0)->rect_id_0 = rect_id_1;
return output_0;
}
#line 35
struct rects_vert_Result_0
{
float4 pos_1 [[position]];
uint rect_id_2 [[user(_SLANG_ATTR)]];
};
#line 35
[[vertex]] rects_vert_Result_0 rects_vert(uint vertex_id_1 [[vertex_id]])
{
#line 35
thread uint _S2 = vertex_id_1;
#line 35
KernelContext_0 kernelContext_1;
#line 35
VRectOut_0 _S3 = rects_vert_0(&_S2, &kernelContext_1);
#line 35
thread rects_vert_Result_0 _S4;
#line 35
(&_S4)->pos_1 = _S3.pos_0;
#line 35
(&_S4)->rect_id_2 = _S3.rect_id_0;
#line 35
return _S4;
}
Reactions are currently unavailable