Open 9291Sam opened 2 months ago
Also, changing the array index into pointer arithmetic also still causes the same error
Seems fine to me:
SPIR-V:
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 24
; Schema: 0
OpCapability Shader
OpCapability PhysicalStorageBufferAddresses
OpExtension "SPV_KHR_physical_storage_buffer"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel PhysicalStorageBuffer64 GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 460
OpSourceExtension "GL_EXT_buffer_reference"
OpName %main "main"
OpName %face_data "face_data"
OpName %PushConstants "PushConstants"
OpMemberName %PushConstants 0 "ptr_quads_data"
OpName %ChunkLocalFaceBuffer "ChunkLocalFaceBuffer"
OpMemberName %ChunkLocalFaceBuffer 0 "face_data"
OpName %in_push_constants "in_push_constants"
OpMemberDecorate %PushConstants 0 Offset 0
OpDecorate %PushConstants Block
OpDecorate %_runtimearr_uint ArrayStride 4
OpMemberDecorate %ChunkLocalFaceBuffer 0 NonWritable
OpMemberDecorate %ChunkLocalFaceBuffer 0 Offset 0
OpDecorate %ChunkLocalFaceBuffer Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer PhysicalStorageBuffer
%PushConstants = OpTypeStruct %_ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer
%_runtimearr_uint = OpTypeRuntimeArray %uint
%ChunkLocalFaceBuffer = OpTypeStruct %_runtimearr_uint
%_ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer = OpTypePointer PhysicalStorageBuffer %ChunkLocalFaceBuffer
%_ptr_PushConstant_PushConstants = OpTypePointer PushConstant %PushConstants
%in_push_constants = OpVariable %_ptr_PushConstant_PushConstants PushConstant
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_PushConstant__ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer = OpTypePointer PushConstant %_ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer
%int_46645 = OpConstant %int 46645
%_ptr_PhysicalStorageBuffer_uint = OpTypePointer PhysicalStorageBuffer %uint
%main = OpFunction %void None %3
%5 = OpLabel
%face_data = OpVariable %_ptr_Function_uint Function
%18 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer %in_push_constants %int_0
%19 = OpLoad %_ptr_PhysicalStorageBuffer_ChunkLocalFaceBuffer %18
%22 = OpAccessChain %_ptr_PhysicalStorageBuffer_uint %19 %int_0 %int_46645
%23 = OpLoad %uint %22 Aligned 4
OpStore %face_data %23
OpReturn
OpFunctionEnd
MSL:
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct ChunkLocalFaceBuffer;
struct PushConstants
{
device ChunkLocalFaceBuffer* ptr_quads_data;
};
struct ChunkLocalFaceBuffer
{
uint face_data[1];
};
kernel void main0(constant PushConstants& in_push_constants [[buffer(0)]])
{
uint face_data = in_push_constants.ptr_quads_data->face_data[46645];
}
MoltenVK SDK version is 1.3.290
Full Shader here:
produces the following error: