// File: /workspace/github_cpp_makefile_star2_O3/rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::image_type_glsl[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id)
{
	auto *var = maybe_get<SPIRVariable>(id);
	if (var && var->basevariable)
	{
		// For comparison images, check against the base variable,
		// and not the fake ID which might have been generated for this variable.
		id = var->basevariable;
	}

	if (!type.array.empty())
	{
		uint32_t major = 2, minor = 0;
		if (msl_options.is_ios())
		{
			major = 1;
			minor = 2;
		}
		if (!msl_options.supports_msl_version(major, minor))
		{
			if (msl_options.is_ios())
				SPIRV_CROSS_THROW("MSL 1.2 or greater is required for arrays of textures.");
			else
				SPIRV_CROSS_THROW("MSL 2.0 or greater is required for arrays of textures.");
		}

		if (type.array.size() > 1)
			SPIRV_CROSS_THROW("Arrays of arrays of textures are not supported in MSL.");

		// Arrays of images in MSL must be declared with a special array<T, N> syntax ala C++11 std::array.
		uint32_t array_size =
		    type.array_size_literal.back() ? type.array.back() : get<SPIRConstant>(type.array.back()).scalar();
		if (array_size == 0)
			SPIRV_CROSS_THROW("Unsized array of images is not supported in MSL.");

		auto &parent = get<SPIRType>(get_non_pointer_type(type).parent_type);
		return join("array<", image_type_glsl(parent, id), ", ", array_size, ">");
	}

	string img_type_name;

	// Bypass pointers because we need the real image struct
	auto &img_type = get<SPIRType>(type.self).image;
	if (image_is_comparison(type, id))
	{
		switch (img_type.dim)
		{
		case Dim1D:
			img_type_name += "depth1d_unsupported_by_metal";
			break;
		case Dim2D:
			if (img_type.ms && img_type.arrayed)
			{
				if (!msl_options.supports_msl_version(2, 1))
					SPIRV_CROSS_THROW("Multisampled array textures are supported from 2.1.");
				img_type_name += "depth2d_ms_array";
			}
			else if (img_type.ms)
				img_type_name += "depth2d_ms";
			else if (img_type.arrayed)
				img_type_name += "depth2d_array";
			else
				img_type_name += "depth2d";
			break;
		case Dim3D:
			img_type_name += "depth3d_unsupported_by_metal";
			break;
		case DimCube:
			img_type_name += (img_type.arrayed ? "depthcube_array" : "depthcube");
			break;
		default:
			img_type_name += "unknown_depth_texture_type";
			break;
		}
	}
	else
	{
		switch (img_type.dim)
		{
		case Dim1D:
			img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d");
			break;
		case DimBuffer:
		case Dim2D:
		case DimSubpassData:
			if (img_type.ms && img_type.arrayed)
			{
				if (!msl_options.supports_msl_version(2, 1))
					SPIRV_CROSS_THROW("Multisampled array textures are supported from 2.1.");
				img_type_name += "texture2d_ms_array";
			}
			else if (img_type.ms)
				img_type_name += "texture2d_ms";
			else if (img_type.arrayed)
				img_type_name += "texture2d_array";
			else
				img_type_name += "texture2d";
			break;
		case Dim3D:
			img_type_name += "texture3d";
			break;
		case DimCube:
			img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube");
			break;
		default:
			img_type_name += "unknown_texture_type";
			break;
		}
	}

	// Append the pixel type
	img_type_name += "<";
	img_type_name += type_to_glsl(get<SPIRType>(img_type.type));

	// For unsampled images, append the sample/read/write access qualifier.
	// For kernel images, the access qualifier my be supplied directly by SPIR-V.
	// Otherwise it may be set based on whether the image is read from or written to within the shader.
	if (type.basetype == SPIRType::Image && type.image.sampled == 2 && type.image.dim != DimSubpassData)
	{
		switch (img_type.access)
		{
		case AccessQualifierReadOnly:
			img_type_name += ", access::read";
			break;

		case AccessQualifierWriteOnly:
			img_type_name += ", access::write";
			break;

		case AccessQualifierReadWrite:
			img_type_name += ", access::read_write";
			break;

		default:
		{
			auto *p_var = maybe_get_backing_variable(id);
			if (p_var && p_var->basevariable)
				p_var = maybe_get<SPIRVariable>(p_var->basevariable);
			if (p_var && !has_decoration(p_var->self, DecorationNonWritable))
			{
				img_type_name += ", access::";

				if (!has_decoration(p_var->self, DecorationNonReadable))
					img_type_name += "read_";

				img_type_name += "write";
			}
			break;
		}
		}
	}

	img_type_name += ">";

	return img_type_name;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movl %ecx, %esi
callq 0xc7b4
testq %rax, %rax
je 0x9f410
movl 0x1c(%rax), %eax
testl %eax, %eax
cmovnel %eax, %ebp
movq 0x20(%r15), %rcx
movq 0x28(%r15), %rax
cmpq %rax, %rcx
je 0x9f4a7
cmpl $0x0, 0x7cc(%r14)
movl 0x7d0(%r14), %edx
je 0x9f50d
cmpl $0x4e1f, %edx           # imm = 0x4E1F
ja 0x9f519
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x23b97(%rip), %rsi     # 0xc2ff6
leaq 0x23bc6(%rip), %rdx     # 0xc302c
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c945(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c91d(%rip), %rsi     # 0xfbdb0
movq 0x5db3e(%rip), %rdx     # 0xfcfd8
movq %rbx, %rdi
callq 0x6470
jmp 0x9fa7b
leaq 0x10(%rbx), %r13
movq %r13, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movl 0x8(%r15), %esi
movq %r14, %rdi
callq 0xa3ea
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x1b12c
movl 0x84(%r12), %edx
movl %edx, %ecx
testb %al, %al
je 0x9f608
cmpl $0x3, %edx
ja 0x9f6bd
leaq 0x20990(%rip), %rax     # 0xbfe88
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x23b8d(%rip), %rsi     # 0xc3095
jmp 0x9f722
cmpl $0x27d7, %edx           # imm = 0x27D7
jbe 0x9f952
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0x5, %rdx
jae 0x9f888
movl 0x50(%r15), %ecx
leaq -0x1(%rcx), %rdx
addq $0x3e, %rcx
testq %rdx, %rdx
cmovnsq %rdx, %rcx
sarq $0x6, %rcx
shlq $0x3, %rcx
addq 0x48(%r15), %rcx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq 0x3f(%rsi), %rdi
andq %rdx, %rdi
xorl %r8d, %r8d
cmpq %rsi, %rdi
setbe %r8b
movq -0x8(%rcx,%r8,8), %rcx
addq $-0x4, %rax
btq %rdx, %rcx
jb 0x9f580
movl (%rax), %esi
movq %r14, %rdi
callq 0x1c036
addq $0x10, %rax
movl (%rax), %eax
movl %eax, 0x24(%rsp)
testl %eax, %eax
je 0x9f8ed
movq %r14, %rdi
movq %r15, %rsi
callq 0x14ac0
movl 0x9c(%rax), %esi
movq %r14, %rdi
callq 0xa3ea
movq (%r14), %r8
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq *0xb0(%r8)
leaq 0x14ffe(%rip), %rsi     # 0xb45c4
leaq 0x1aade(%rip), %rcx     # 0xba0ab
leaq 0x14c28(%rip), %r9      # 0xb41fc
leaq 0x24(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rdx
callq 0xa6951
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9f86a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x9f86a
cmpl $0x6, %edx
ja 0x9f6f3
leaq 0x20854(%rip), %rax     # 0xbfe6c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb 0x89(%r12), %al
cmpb $0x1, 0x8a(%r12)
jne 0x9f659
testb %al, %al
je 0x9f705
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0x9f9b7
leaq 0x23b30(%rip), %rsi     # 0xc3184
jmp 0x9f722
leaq 0x23b44(%rip), %rcx     # 0xc31a4
leaq 0x23b4d(%rip), %rsi     # 0xc31b4
jmp 0x9f71c
leaq 0x23aa5(%rip), %rsi     # 0xc3118
jmp 0x9f722
leaq 0x23ab6(%rip), %rax     # 0xc3135
leaq 0x23abf(%rip), %rsi     # 0xc3145
jmp 0x9f6e4
movb 0x89(%r12), %al
cmpb $0x1, 0x8a(%r12)
jne 0x9f70e
testb %al, %al
je 0x9f87c
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0x9fa1a
leaq 0x23a2b(%rip), %rsi     # 0xc30e6
jmp 0x9f722
leaq 0x23a8b(%rip), %rsi     # 0xc314f
jmp 0x9f722
leaq 0x23afb(%rip), %rax     # 0xc31c8
leaq 0x23b06(%rip), %rsi     # 0xc31da
jmp 0x9f6e4
leaq 0x23a8d(%rip), %rax     # 0xc316a
leaq 0x23a96(%rip), %rsi     # 0xc317a
cmpb $0x0, 0x89(%r12)
cmovneq %rax, %rsi
jmp 0x9f722
leaq 0x23aec(%rip), %rsi     # 0xc31e6
jmp 0x9f722
leaq 0x23abb(%rip), %rsi     # 0xc31be
jmp 0x9f722
leaq 0x23a8b(%rip), %rsi     # 0xc3197
jmp 0x9f722
leaq 0x239ed(%rip), %rcx     # 0xc3102
leaq 0x239f4(%rip), %rsi     # 0xc3110
testb %al, %al
cmovneq %rcx, %rsi
movq %rbx, %rdi
callq 0x64e0
leaq 0x189bc(%rip), %rsi     # 0xb80ed
movq %rbx, %rdi
callq 0x64e0
movl 0x80(%r12), %esi
movq %r14, %rdi
callq 0xa3ea
movq (%r14), %r8
movq %rsp, %rdi
movq %r14, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq *0x98(%r8)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x60b0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9f78a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
cmpl $0xd, 0xc(%r15)
jne 0x9f85b
cmpl $0x2, 0x8c(%r15)
jne 0x9f85b
cmpl $0x6, 0x84(%r15)
je 0x9f85b
movl 0x94(%r12), %eax
cmpq $0x3, %rax
jae 0x9f7da
leaq 0x2096a(%rip), %rcx     # 0xc0130
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq %rbx, %rdi
callq 0x64e0
jmp 0x9f85b
movq %r14, %rdi
movl %ebp, %esi
callq 0x12c9a
movq %rax, %r15
testq %rax, %rax
je 0x9f85b
movl 0x1c(%r15), %esi
testl %esi, %esi
je 0x9f804
movq %r14, %rdi
callq 0xc7b4
movq %rax, %r15
testq %rax, %rax
je 0x9f85b
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0x18, %edx
callq 0x12974
testb %al, %al
jne 0x9f85b
leaq 0x23a0f(%rip), %rsi     # 0xc322f
movq %rbx, %rdi
callq 0x64e0
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0x19, %edx
callq 0x12974
testb %al, %al
jne 0x9f84c
leaq 0x239f6(%rip), %rsi     # 0xc323a
movq %rbx, %rdi
callq 0x64e0
leaq 0x239c1(%rip), %rsi     # 0xc3214
movq %rbx, %rdi
callq 0x64e0
leaq 0x1499a(%rip), %rsi     # 0xb41fc
movq %rbx, %rdi
callq 0x64e0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x23874(%rip), %rsi     # 0xc30f7
jmp 0x9f722
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x23788(%rip), %rsi     # 0xc302d
leaq 0x237b7(%rip), %rdx     # 0xc3063
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c4ff(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c4d7(%rip), %rsi     # 0xfbdb0
movq 0x5d6f8(%rip), %rdx     # 0xfcfd8
movq %rbx, %rdi
callq 0x6470
jmp 0x9fa7b
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2375a(%rip), %rsi     # 0xc3064
leaq 0x23783(%rip), %rdx     # 0xc3094
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c49a(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c472(%rip), %rsi     # 0xfbdb0
movq 0x5d693(%rip), %rdx     # 0xfcfd8
movq %rbx, %rdi
callq 0x6470
jmp 0x9fa7b
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x23650(%rip), %rsi     # 0xc2fbf
leaq 0x2367f(%rip), %rdx     # 0xc2ff5
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c435(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c40d(%rip), %rsi     # 0xfbdb0
movq 0x5d62e(%rip), %rdx     # 0xfcfd8
movq %rbx, %rdi
callq 0x6470
jmp 0x9fa7b
movl $0x10, %edi
callq 0x6140
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x236dd(%rip), %rsi     # 0xc30b2
leaq 0x23709(%rip), %rdx     # 0xc30e5
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r15, %rdi
callq 0x6320
leaq 0x5c3cf(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x5c3a7(%rip), %rsi     # 0xfbdb0
movq 0x5d5c8(%rip), %rdx     # 0xfcfd8
movq %r15, %rdi
callq 0x6470
jmp 0x9fa7b
movl $0x10, %edi
callq 0x6140
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2367a(%rip), %rsi     # 0xc30b2
leaq 0x236a6(%rip), %rdx     # 0xc30e5
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r15, %rdi
callq 0x6320
leaq 0x5c36c(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x5c344(%rip), %rsi     # 0xfbdb0
movq 0x5d565(%rip), %rdx     # 0xfcfd8
movq %r15, %rdi
callq 0x6470
jmp 0x9fa7f
jmp 0x9faa2
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x9fa98
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x9faa5
jmp 0x9fb27
movq %rax, %r14
movq %r15, %rdi
callq 0x6200
jmp 0x9fb27
jmp 0x9fabd
jmp 0x9fadd
jmp 0x9fabd
jmp 0x9fadd
jmp 0x9fb24
jmp 0x9fabd
jmp 0x9fadd
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x9fad6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x9fae0
jmp 0x9fb3b
movq %rax, %r14
movq %rbx, %rdi
callq 0x6200
jmp 0x9fb3b
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9fb27
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x9fb27
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9fb3b
movq 0x10(%rsp), %rsi
jmp 0x9fb33
jmp 0x9fb24
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x9fb3b
movq (%r13), %rsi
incq %rsi
callq 0x6260
movq %r14, %rdi
callq 0x64a0
nop