// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::image_type_glsl[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerGLSL::image_type_glsl(const SPIRType &type, uint32_t id)
{
	auto &imagetype = get<SPIRType>(type.image.type);
	string res;

	switch (imagetype.basetype)
	{
	case SPIRType::Int:
		res = "i";
		break;
	case SPIRType::UInt:
		res = "u";
		break;
	default:
		break;
	}

	if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData && options.vulkan_semantics)
		return res + "subpassInput" + (type.image.ms ? "MS" : "");

	// If we're emulating subpassInput with samplers, force sampler2D
	// so we don't have to specify format.
	if (type.basetype == SPIRType::Image && type.image.dim != DimSubpassData)
	{
		// Sampler buffers are always declared as samplerBuffer even though they might be separate images in the SPIR-V.
		if (type.image.dim == DimBuffer && type.image.sampled == 1)
			res += "sampler";
		else
			res += type.image.sampled == 2 ? "image" : "texture";
	}
	else
		res += "sampler";

	switch (type.image.dim)
	{
	case Dim1D:
		res += "1D";
		break;
	case Dim2D:
		res += "2D";
		break;
	case Dim3D:
		res += "3D";
		break;
	case DimCube:
		res += "Cube";
		break;

	case DimBuffer:
		if (options.es && options.version < 320)
			require_extension_internal("GL_OES_texture_buffer");
		else if (!options.es && options.version < 300)
			require_extension_internal("GL_EXT_texture_buffer_object");
		res += "Buffer";
		break;

	case DimSubpassData:
		res += "2D";
		break;
	default:
		SPIRV_CROSS_THROW("Only 1D, 2D, 3D, Buffer, InputTarget and Cube textures supported.");
	}

	if (type.image.ms)
		res += "MS";
	if (type.image.arrayed)
	{
		if (is_legacy_desktop())
			require_extension_internal("GL_EXT_texture_array");
		res += "Array";
	}

	// "Shadow" state in GLSL only exists for samplers and combined image samplers.
	if (((type.basetype == SPIRType::SampledImage) || (type.basetype == SPIRType::Sampler)) &&
	    image_is_comparison(type, id))
	{
		res += "Shadow";
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x138(%rbp)
movq %rdi, %rax
movq %rax, -0x130(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x128(%rbp)
movq -0x18(%rbp), %rax
movl 0x80(%rax), %esi
callq 0xea90
movq %rax, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7530
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x120(%rbp)
subl $0x4, %eax
je 0x962a3
jmp 0x96296
movl -0x120(%rbp), %eax
subl $0x5, %eax
je 0x962c8
jmp 0x962dc
leaq 0xaae31(%rip), %rsi     # 0x1410db
leaq -0x48(%rbp), %rdi
callq 0x7510
jmp 0x962b5
jmp 0x962de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x96898
leaq 0xade7e(%rip), %rsi     # 0x14414d
leaq -0x48(%rbp), %rdi
callq 0x7510
jmp 0x962da
jmp 0x962de
jmp 0x962de
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0x96383
movq -0x18(%rbp), %rax
cmpl $0x6, 0x84(%rax)
jne 0x96383
movq -0x128(%rbp), %rax
testb $0x1, 0x43e(%rax)
je 0x96383
leaq 0xae928(%rip), %rdx     # 0x144c3c
leaq -0x78(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2f8c0
jmp 0x96323
movq -0x138(%rbp), %rdi
movq -0x18(%rbp), %rax
movb 0x8a(%rax), %cl
leaq 0xabab7(%rip), %rax     # 0x141df2
leaq 0xa855c(%rip), %rdx     # 0x13e89e
testb $0x1, %cl
cmovneq %rax, %rdx
leaq -0x78(%rbp), %rsi
callq 0x11910
jmp 0x96354
leaq -0x78(%rbp), %rdi
callq 0x7708
movl $0x1, -0x7c(%rbp)
jmp 0x9687f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7708
jmp 0x96898
movq -0x18(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0x963f6
movq -0x18(%rbp), %rax
cmpl $0x6, 0x84(%rax)
je 0x963f6
movq -0x18(%rbp), %rax
cmpl $0x5, 0x84(%rax)
jne 0x963c8
movq -0x18(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
jne 0x963c8
leaq 0xb1c6c(%rip), %rsi     # 0x148027
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x963c6
jmp 0x963f4
movq -0x18(%rbp), %rax
movl 0x8c(%rax), %eax
subl $0x2, %eax
leaq 0xae86d(%rip), %rax     # 0x144c49
leaq 0xb6821(%rip), %rsi     # 0x14cc04
cmoveq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x963f2
jmp 0x963f4
jmp 0x9640a
leaq 0xb1c2a(%rip), %rsi     # 0x148027
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96408
jmp 0x9640a
movq -0x18(%rbp), %rax
movl 0x84(%rax), %eax
movq %rax, -0x140(%rbp)
subq $0x6, %rax
ja 0x9664b
movq -0x140(%rbp), %rax
leaq 0xaa3c1(%rip), %rcx     # 0x1407f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xab97f(%rip), %rsi     # 0x141dc2
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x9644e
jmp 0x9671b
leaq 0xab97f(%rip), %rsi     # 0x141dd9
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96465
jmp 0x9671b
leaq 0xab9a7(%rip), %rsi     # 0x141e18
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x9647c
jmp 0x9671b
leaq 0xab9a6(%rip), %rsi     # 0x141e2e
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96493
jmp 0x9671b
movq -0x128(%rbp), %rax
testb $0x1, 0x43c(%rax)
je 0x9655b
movq -0x128(%rbp), %rax
cmpl $0x140, 0x438(%rax)     # imm = 0x140
jae 0x9655b
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x7650
movq -0x148(%rbp), %rdx
leaq 0xae76b(%rip), %rsi     # 0x144c4f
leaq -0xa0(%rbp), %rdi
callq 0x7520
jmp 0x964f2
movq -0x128(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x589d0
jmp 0x96507
leaq -0xa0(%rbp), %rdi
callq 0x7708
leaq -0xa1(%rbp), %rdi
callq 0x73d0
jmp 0x9661d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9654a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7708
leaq -0xa1(%rbp), %rdi
callq 0x73d0
jmp 0x96898
movq -0x128(%rbp), %rax
testb $0x1, 0x43c(%rax)
jne 0x9661b
movq -0x128(%rbp), %rax
cmpl $0x12c, 0x438(%rax)     # imm = 0x12C
jae 0x9661b
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x7650
movq -0x150(%rbp), %rdx
leaq 0xae6be(%rip), %rsi     # 0x144c65
leaq -0xc8(%rbp), %rdi
callq 0x7520
jmp 0x965b5
movq -0x128(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x589d0
jmp 0x965ca
leaq -0xc8(%rbp), %rdi
callq 0x7708
leaq -0xc9(%rbp), %rdi
callq 0x73d0
jmp 0x9661b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9660a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x7708
leaq -0xc9(%rbp), %rdi
callq 0x73d0
jmp 0x96898
jmp 0x9661d
leaq 0xab7fd(%rip), %rsi     # 0x141e21
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x9662f
jmp 0x9671b
leaq 0xab79e(%rip), %rsi     # 0x141dd9
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96646
jmp 0x9671b
movb $0x1, -0xf2(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x160(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x7650
movq -0x158(%rbp), %rdx
leaq 0xae5fe(%rip), %rsi     # 0x144c82
leaq -0xf0(%rbp), %rdi
callq 0x7520
jmp 0x96692
movq -0x160(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x9c50
jmp 0x966a7
movq -0x160(%rbp), %rdi
movb $0x0, -0xf2(%rbp)
leaq 0x11771c(%rip), %rsi    # 0x1addd8
leaq -0x8ca33(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x968aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x966f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x7708
leaq -0xf1(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xf2(%rbp)
jne 0x9670a
jmp 0x96716
movq -0x160(%rbp), %rdi
callq 0x72c0
jmp 0x96898
movq -0x18(%rbp), %rax
testb $0x1, 0x8a(%rax)
je 0x9673c
leaq 0xab6c3(%rip), %rsi     # 0x141df2
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x9673a
jmp 0x9673c
movq -0x18(%rbp), %rax
testb $0x1, 0x89(%rax)
je 0x96819
movq -0x128(%rbp), %rdi
callq 0xa32a0
movb %al, -0x161(%rbp)
jmp 0x96761
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x96770
jmp 0x96805
leaq -0x119(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x7650
movq -0x170(%rbp), %rdx
leaq 0xae533(%rip), %rsi     # 0x144cc4
leaq -0x118(%rbp), %rdi
callq 0x7520
jmp 0x9679f
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x589d0
jmp 0x967b4
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0x119(%rbp), %rdi
callq 0x73d0
jmp 0x96805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x967f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0x119(%rbp), %rdi
callq 0x73d0
jmp 0x96898
leaq 0xab5c1(%rip), %rsi     # 0x141dcd
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96817
jmp 0x96819
movq -0x18(%rbp), %rax
cmpl $0xe, 0xc(%rax)
je 0x9682d
movq -0x18(%rbp), %rax
cmpl $0xf, 0xc(%rax)
jne 0x96868
movq -0x128(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x2c890
movb %al, -0x171(%rbp)
jmp 0x96848
movb -0x171(%rbp), %al
testb $0x1, %al
jne 0x96854
jmp 0x96868
leaq 0xab758(%rip), %rsi     # 0x141fb3
leaq -0x48(%rbp), %rdi
callq 0x7340
jmp 0x96866
jmp 0x96868
movq -0x138(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7210
movl $0x1, -0x7c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0x130(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0x50(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)