// File: /workspace/github_cpp_makefile_star2_O1/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 0xc7f4
testq %rax, %rax
je 0xa0284
movl 0x1c(%rax), %eax
testl %eax, %eax
cmovnel %eax, %ebp
movq 0x20(%r15), %rcx
movq 0x28(%r15), %rax
cmpq %rax, %rcx
je 0xa03a8
movl 0x7cc(%r14), %r12d
testl %r12d, %r12d
movl $0x27d8, %edx           # imm = 0x27D8
movl $0x4e20, %esi           # imm = 0x4E20
cmovel %edx, %esi
cmpl %esi, 0x7d0(%r14)
jb 0xa0695
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0x5, %rdx
jae 0xa0703
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 0xa0320
movl (%rax), %esi
movq %r14, %rdi
callq 0x1c66e
addq $0x10, %rax
movl (%rax), %eax
movl %eax, 0x24(%rsp)
testl %eax, %eax
je 0xa0768
movq %r14, %rdi
movq %r15, %rsi
callq 0x14c4e
movl 0x9c(%rax), %esi
movq %r14, %rdi
callq 0xa426
movq (%r14), %r8
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq *0xb0(%r8)
leaq 0x1525e(%rip), %rsi     # 0xb55c4
leaq 0x1ad4e(%rip), %rcx     # 0xbb0bb
leaq 0x14e88(%rip), %r9      # 0xb51fc
leaq 0x24(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rdx
callq 0xa785d
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa0683
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0xa0683
leaq 0x10(%rbx), %r13
movq %r13, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movl 0x8(%r15), %esi
movq %r14, %rdi
callq 0xa426
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x1b812
movl 0x84(%r12), %edx
movl %edx, %ecx
testb %al, %al
je 0xa040a
cmpl $0x3, %edx
ja 0xa04b6
leaq 0x20a83(%rip), %rax     # 0xc0e78
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x23cc0(%rip), %rsi     # 0xc40c5
jmp 0xa0536
cmpl $0x6, %edx
ja 0xa04df
leaq 0x20a42(%rip), %rax     # 0xc0e5c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb 0x8a(%r12), %al
cmpb $0x1, %al
jne 0xa04fe
cmpb $0x1, 0x89(%r12)
jne 0xa04f1
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0xa0820
leaq 0x23d5a(%rip), %rsi     # 0xc41b4
jmp 0xa0536
leaq 0x23ce2(%rip), %rsi     # 0xc4148
jmp 0xa0536
leaq 0x23cf3(%rip), %rax     # 0xc4165
leaq 0x23cfc(%rip), %rsi     # 0xc4175
jmp 0xa0529
movb 0x8a(%r12), %al
cmpb $0x1, %al
jne 0xa051b
cmpb $0x1, 0x89(%r12)
jne 0xa050e
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0xa0883
leaq 0x23c65(%rip), %rsi     # 0xc4116
jmp 0xa0536
leaq 0x23cc2(%rip), %rsi     # 0xc417f
jmp 0xa0536
leaq 0x23d32(%rip), %rax     # 0xc41f8
leaq 0x23d3d(%rip), %rsi     # 0xc420a
jmp 0xa0529
leaq 0x23cc4(%rip), %rax     # 0xc419a
leaq 0x23ccd(%rip), %rsi     # 0xc41aa
jmp 0xa0529
leaq 0x23d30(%rip), %rsi     # 0xc4216
jmp 0xa0536
leaq 0x23cff(%rip), %rsi     # 0xc41ee
jmp 0xa0536
testb %al, %al
je 0xa04fe
leaq 0x23ccb(%rip), %rsi     # 0xc41c7
jmp 0xa0536
leaq 0x23ccf(%rip), %rax     # 0xc41d4
leaq 0x23cd8(%rip), %rsi     # 0xc41e4
jmp 0xa0529
testb %al, %al
je 0xa051b
leaq 0x23c0e(%rip), %rsi     # 0xc4127
jmp 0xa0536
leaq 0x23c10(%rip), %rax     # 0xc4132
leaq 0x23c17(%rip), %rsi     # 0xc4140
cmpb $0x0, 0x89(%r12)
cmovneq %rax, %rsi
movq %rbx, %rdi
callq 0x64e0
leaq 0x18bb8(%rip), %rsi     # 0xb90fd
movq %rbx, %rdi
callq 0x64e0
movl 0x80(%r12), %esi
movq %r14, %rdi
callq 0xa426
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 0xa059e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
cmpl $0xd, 0xc(%r15)
jne 0xa0674
cmpl $0x2, 0x8c(%r15)
jne 0xa0674
cmpl $0x6, 0x84(%r15)
je 0xa0674
movl 0x94(%r12), %eax
cmpq $0x3, %rax
jae 0xa05ee
leaq 0x20b86(%rip), %rcx     # 0xc1160
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq %rbx, %rdi
callq 0x64e0
jmp 0xa0674
movq %r14, %rdi
movl %ebp, %esi
callq 0x12cda
movq %rax, %r15
testq %rax, %rax
je 0xa0615
movl 0x1c(%r15), %esi
testl %esi, %esi
je 0xa0618
movq %r14, %rdi
callq 0xc7f4
movq %rax, %r15
jmp 0xa0618
xorl %r15d, %r15d
testq %r15, %r15
je 0xa0674
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0x18, %edx
callq 0x1299a
testb %al, %al
jne 0xa0674
leaq 0x23c26(%rip), %rsi     # 0xc425f
movq %rbx, %rdi
callq 0x64e0
movl 0x8(%r15), %esi
movq %r14, %rdi
movl $0x19, %edx
callq 0x1299a
testb %al, %al
jne 0xa0665
leaq 0x23c0d(%rip), %rsi     # 0xc426a
movq %rbx, %rdi
callq 0x64e0
leaq 0x23bd8(%rip), %rsi     # 0xc4244
movq %rbx, %rdi
callq 0x64e0
leaq 0x14b81(%rip), %rsi     # 0xb51fc
movq %rbx, %rdi
callq 0x64e0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
testl %r12d, %r12d
jne 0xa07cd
movq %r15, -0x10(%r15)
leaq 0x23934(%rip), %rsi     # 0xc3fef
leaq 0x23963(%rip), %rdx     # 0xc4025
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c6b9(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c691(%rip), %rsi     # 0xfcd80
movq 0x5d8e2(%rip), %rdx     # 0xfdfd8
movq %rbx, %rdi
callq 0x6470
jmp 0xa08e4
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2393d(%rip), %rsi     # 0xc405d
leaq 0x2396c(%rip), %rdx     # 0xc4093
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c654(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c62c(%rip), %rsi     # 0xfcd80
movq 0x5d87d(%rip), %rdx     # 0xfdfd8
movq %rbx, %rdi
callq 0x6470
jmp 0xa08e4
movl $0x10, %edi
callq 0x6140
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2390f(%rip), %rsi     # 0xc4094
leaq 0x23938(%rip), %rdx     # 0xc40c4
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c5ef(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c5c7(%rip), %rsi     # 0xfcd80
movq 0x5d818(%rip), %rdx     # 0xfdfd8
movq %rbx, %rdi
callq 0x6470
jmp 0xa08e4
movq %r15, -0x10(%r15)
leaq 0x2384e(%rip), %rsi     # 0xc4026
leaq 0x2387d(%rip), %rdx     # 0xc405c
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x6320
leaq 0x5c59c(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0x5c574(%rip), %rsi     # 0xfcd80
movq 0x5d7c5(%rip), %rdx     # 0xfdfd8
movq %rbx, %rdi
callq 0x6470
jmp 0xa08e4
movl $0x10, %edi
callq 0x6140
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x238a4(%rip), %rsi     # 0xc40e2
leaq 0x238d0(%rip), %rdx     # 0xc4115
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %r15, %rdi
callq 0x6320
leaq 0x5c536(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x5c50e(%rip), %rsi     # 0xfcd80
movq 0x5d75f(%rip), %rdx     # 0xfdfd8
movq %r15, %rdi
callq 0x6470
jmp 0xa08e4
movl $0x10, %edi
callq 0x6140
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x23841(%rip), %rsi     # 0xc40e2
leaq 0x2386d(%rip), %rdx     # 0xc4115
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %r15, %rdi
callq 0x6320
leaq 0x5c4d3(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x5c4ab(%rip), %rsi     # 0xfcd80
movq 0x5d6fc(%rip), %rdx     # 0xfdfd8
movq %r15, %rdi
callq 0x6470
jmp 0xa08e8
jmp 0xa0903
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0xa0909
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0xa0909
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0xa0997
movq %r15, %rdi
callq 0x6200
jmp 0xa0997
jmp 0xa092a
jmp 0xa092a
jmp 0xa0945
jmp 0xa0945
jmp 0xa0994
jmp 0xa092a
jmp 0xa0945
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xa094b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0xa094b
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0xa09ab
movq %rbx, %rdi
callq 0x6200
jmp 0xa09ab
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa0997
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0xa0997
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa09ab
movq 0x10(%rsp), %rsi
jmp 0xa09a3
jmp 0xa0994
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0xa09ab
movq (%r13), %rsi
incq %rsi
callq 0x6260
movq %r14, %rdi
callq 0x64a0
nop