// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x30, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movl %ecx, %esi
callq 0xa9e4
testq %rax, %rax
je 0x7ca9e
movl 0x1c(%rax), %eax
testl %eax, %eax
cmovnel %eax, %ebp
movq 0x20(%r15), %rax
movq 0x28(%r15), %rcx
cmpq %rcx, %rax
je 0x7cb7a
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 0x7ce3d
subq %rax, %rcx
cmpq $0x5, %rcx
jae 0x7ce94
leaq 0x38(%r15), %rdi
callq 0x1760e
movl %eax, %ecx
movq 0x28(%r15), %rax
addq $-0x4, %rax
testb %cl, %cl
jne 0x7cb05
movl (%rax), %esi
movq %r14, %rdi
callq 0x17bce
addq $0x10, %rax
movl (%rax), %eax
movl %eax, 0x8(%rsp)
testl %eax, %eax
je 0x7cee2
movq %r14, %rdi
movq %r15, %rsi
callq 0x11e4a
movl 0x9c(%rax), %esi
movq %r14, %rdi
callq 0x90a4
movq (%r14), %r8
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq *0xb0(%r8)
leaq 0x12a4f(%rip), %rsi     # 0x8f59c
leaq 0x18537(%rip), %rcx     # 0x9508b
leaq 0x12679(%rip), %r9      # 0x8f1d4
leaq 0x8(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rdx
callq 0x82175
leaq 0x10(%rsp), %rdi
callq 0x6548
jmp 0x7ce21
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movl 0x8(%r15), %esi
movq %r14, %rdi
callq 0x90a4
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x16cd4
movl 0x84(%r12), %edx
movl %edx, %ecx
testb %al, %al
je 0x7cbd9
cmpl $0x3, %edx
ja 0x7cc8e
leaq 0x1e254(%rip), %rax     # 0x9ae18
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x21479(%rip), %rsi     # 0x9e04d
jmp 0x7ccf3
cmpl $0x6, %edx
ja 0x7ccc4
leaq 0x1e213(%rip), %rax     # 0x9adfc
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb 0x89(%r12), %al
cmpb $0x1, 0x8a(%r12)
jne 0x7cc2a
testb %al, %al
je 0x7ccd6
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0x7cf73
leaq 0x21517(%rip), %rsi     # 0x9e13c
jmp 0x7ccf3
leaq 0x2152b(%rip), %rcx     # 0x9e15c
leaq 0x21534(%rip), %rsi     # 0x9e16c
jmp 0x7cced
leaq 0x2148c(%rip), %rsi     # 0x9e0d0
jmp 0x7ccf3
leaq 0x2149d(%rip), %rax     # 0x9e0ed
leaq 0x214a6(%rip), %rsi     # 0x9e0fd
jmp 0x7ccb5
movb 0x89(%r12), %al
cmpb $0x1, 0x8a(%r12)
jne 0x7ccdf
testb %al, %al
je 0x7ce31
cmpl $0x4e83, 0x7d0(%r14) # imm = 0x4E83
jbe 0x7cfbe
leaq 0x21412(%rip), %rsi     # 0x9e09e
jmp 0x7ccf3
leaq 0x21472(%rip), %rsi     # 0x9e107
jmp 0x7ccf3
leaq 0x214e2(%rip), %rax     # 0x9e180
leaq 0x214ed(%rip), %rsi     # 0x9e192
jmp 0x7ccb5
leaq 0x21474(%rip), %rax     # 0x9e122
leaq 0x2147d(%rip), %rsi     # 0x9e132
cmpb $0x0, 0x89(%r12)
cmovneq %rax, %rsi
jmp 0x7ccf3
leaq 0x214d3(%rip), %rsi     # 0x9e19e
jmp 0x7ccf3
leaq 0x214a2(%rip), %rsi     # 0x9e176
jmp 0x7ccf3
leaq 0x21472(%rip), %rsi     # 0x9e14f
jmp 0x7ccf3
leaq 0x213d4(%rip), %rcx     # 0x9e0ba
leaq 0x213db(%rip), %rsi     # 0x9e0c8
testb %al, %al
cmovneq %rcx, %rsi
movq %rbx, %rdi
callq 0x64d0
leaq 0x163cb(%rip), %rsi     # 0x930cd
movq %rbx, %rdi
callq 0x64d0
movl 0x80(%r12), %esi
movq %r14, %rdi
callq 0x90a4
movq (%r14), %r8
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq *0x98(%r8)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x64f0
leaq 0x10(%rsp), %rdi
callq 0x6548
cmpl $0xd, 0xc(%r15)
jne 0x7ce12
cmpl $0x2, 0x8c(%r15)
jne 0x7ce12
cmpl $0x6, 0x84(%r15)
je 0x7ce12
movl 0x94(%r12), %eax
cmpq $0x3, %rax
jae 0x7cd95
leaq 0x1e364(%rip), %rcx     # 0x9b0e8
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq %rbx, %rdi
callq 0x64d0
jmp 0x7ce12
movq %r14, %rdi
movl %ebp, %esi
callq 0x1067e
movq %rax, %r15
testq %rax, %rax
je 0x7ce12
movl 0x1c(%r15), %esi
testl %esi, %esi
je 0x7cdbf
movq %r14, %rdi
callq 0xa9e4
movq %rax, %r15
testq %rax, %rax
je 0x7ce12
movl 0x8(%r15), %esi
pushq $0x18
popq %rdx
movq %r14, %rdi
callq 0x103d2
testb %al, %al
jne 0x7ce12
leaq 0x2140e(%rip), %rsi     # 0x9e1e7
movq %rbx, %rdi
callq 0x64d0
movl 0x8(%r15), %esi
pushq $0x19
popq %rdx
movq %r14, %rdi
callq 0x103d2
testb %al, %al
jne 0x7ce03
leaq 0x213f7(%rip), %rsi     # 0x9e1f2
movq %rbx, %rdi
callq 0x64d0
leaq 0x213c2(%rip), %rsi     # 0x9e1cc
movq %rbx, %rdi
callq 0x64d0
leaq 0x123bb(%rip), %rsi     # 0x8f1d4
movq %rbx, %rdi
callq 0x64d0
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21277(%rip), %rsi     # 0x9e0af
jmp 0x7ccf3
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
testl %r12d, %r12d
jne 0x7cf30
leaq 0x2111f(%rip), %rsi     # 0x9df77
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69f40(%rip), %rsi     # 0xe6dc0
movq 0x6b159(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x7d007
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
leaq 0x2113f(%rip), %rsi     # 0x9dfe5
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69ef2(%rip), %rsi     # 0xe6dc0
movq 0x6b10b(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x7d007
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %rbx
leaq 0x21128(%rip), %rsi     # 0x9e01c
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69ea4(%rip), %rsi     # 0xe6dc0
movq 0x6b0bd(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x7d007
leaq 0x21077(%rip), %rsi     # 0x9dfae
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69e61(%rip), %rsi     # 0xe6dc0
movq 0x6b07a(%rip), %rdx     # 0xe7fe0
movq %rbx, %rdi
callq 0x6490
jmp 0x7d007
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r15
leaq 0x210e5(%rip), %rsi     # 0x9e06a
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69e13(%rip), %rsi     # 0xe6dc0
movq 0x6b02c(%rip), %rdx     # 0xe7fe0
movq %r15, %rdi
callq 0x6490
jmp 0x7d007
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r15
leaq 0x2109a(%rip), %rsi     # 0x9e06a
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x69dc8(%rip), %rsi     # 0xe6dc0
movq 0x6afe1(%rip), %rdx     # 0xe7fe0
movq %r15, %rdi
callq 0x6490
jmp 0x7d00b
jmp 0x7d01f
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x7d022
jmp 0x7d079
movq %rax, %r14
movq %r15, %rdi
callq 0x6200
jmp 0x7d079
jmp 0x7d03a
jmp 0x7d03a
jmp 0x7d04e
jmp 0x7d04e
jmp 0x7d076
jmp 0x7d03a
jmp 0x7d04e
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x7d051
jmp 0x7d081
movq %rax, %r14
movq %rbx, %rdi
callq 0x6200
jmp 0x7d081
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6548
jmp 0x7d079
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x7d07c
jmp 0x7d076
movq %rax, %r14
movq %rbx, %rdi
callq 0x6548
movq %r14, %rdi
callq 0x64b0
nop