// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::image_type_hlsl_modern[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerHLSL::image_type_hlsl_modern(const SPIRType &type, uint32_t)
{
	auto &imagetype = get<SPIRType>(type.image.type);
	const char *dim = nullptr;
	bool typed_load = false;
	uint32_t components = 4;

	switch (type.image.dim)
	{
	case Dim1D:
		typed_load = type.image.sampled == 2;
		dim = "1D";
		break;
	case Dim2D:
		typed_load = type.image.sampled == 2;
		dim = "2D";
		break;
	case Dim3D:
		typed_load = type.image.sampled == 2;
		dim = "3D";
		break;
	case DimCube:
		if (type.image.sampled == 2)
			SPIRV_CROSS_THROW("RWTextureCube does not exist in HLSL.");
		dim = "Cube";
		break;
	case DimRect:
		SPIRV_CROSS_THROW("Rectangle texture support is not yet implemented for HLSL."); // TODO
	case DimBuffer:
		if (type.image.sampled == 1)
			return join("Buffer<", type_to_glsl(imagetype), components, ">");
		else if (type.image.sampled == 2)
			return join("RWBuffer<", image_format_to_type(type.image.format, imagetype.basetype), ">");
		else
			SPIRV_CROSS_THROW("Sampler buffers must be either sampled or unsampled. Cannot deduce in runtime.");
	case DimSubpassData:
		dim = "2D";
		typed_load = false;
		break;
	default:
		SPIRV_CROSS_THROW("Invalid dimension.");
	}
	const char *arrayed = type.image.arrayed ? "Array" : "";
	const char *ms = type.image.ms ? "MS" : "";
	const char *rw = typed_load ? "RW" : "";
	return join(rw, "Texture", dim, ms, arrayed, "<",
	            typed_load ? image_format_to_type(type.image.format, imagetype.basetype) :
	                         join(type_to_glsl(imagetype), components),
	            ">");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x1a8(%rbp)
movq %rdi, %rax
movq %rax, -0x1a0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x198(%rbp)
movq -0x18(%rbp), %rax
movl 0x80(%rax), %esi
callq 0xea90
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movb $0x0, -0x31(%rbp)
movl $0x4, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x84(%rax), %eax
movq %rax, -0x190(%rbp)
subq $0x6, %rax
ja 0xba15f
movq -0x190(%rbp), %rax
leaq 0x8b6eb(%rip), %rcx     # 0x145440
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
sete %al
andb $0x1, %al
movb %al, -0x31(%rbp)
leaq 0x8804a(%rip), %rax     # 0x141dc2
movq %rax, -0x30(%rbp)
jmp 0xba22f
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
sete %al
andb $0x1, %al
movb %al, -0x31(%rbp)
leaq 0x8803e(%rip), %rax     # 0x141dd9
movq %rax, -0x30(%rbp)
jmp 0xba22f
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
sete %al
andb $0x1, %al
movb %al, -0x31(%rbp)
leaq 0x8805a(%rip), %rax     # 0x141e18
movq %rax, -0x30(%rbp)
jmp 0xba22f
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
jne 0xb9e90
movb $0x1, -0x6d(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1b8(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x7650
movq -0x1b0(%rbp), %rdx
leaq 0x8c09c(%rip), %rsi     # 0x145ea7
leaq -0x58(%rbp), %rdi
callq 0x7520
jmp 0xb9e16
movq -0x1b8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9c50
jmp 0xb9e28
movq -0x1b8(%rbp), %rdi
movb $0x0, -0x6d(%rbp)
leaq 0xf3f9e(%rip), %rsi     # 0x1addd8
leaq -0xb01b1(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xba3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xb9e6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x7708
leaq -0x59(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x6d(%rbp)
jne 0xb9e7f
jmp 0xb9e8b
movq -0x1b8(%rbp), %rdi
callq 0x72c0
jmp 0xba3d5
leaq 0x87f97(%rip), %rax     # 0x141e2e
movq %rax, -0x30(%rbp)
jmp 0xba22f
movb $0x1, -0x92(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1c8(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x7650
movq -0x1c0(%rbp), %rdx
leaq 0x8bff4(%rip), %rsi     # 0x145ecd
leaq -0x90(%rbp), %rdi
callq 0x7520
jmp 0xb9ee7
movq -0x1c8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x9c50
jmp 0xb9efc
movq -0x1c8(%rbp), %rdi
movb $0x0, -0x92(%rbp)
leaq 0xf3ec7(%rip), %rsi     # 0x1addd8
leaq -0xb0288(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xba3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xb9f48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7708
leaq -0x91(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x92(%rbp)
jne 0xb9f5f
jmp 0xb9f6b
movq -0x1c8(%rbp), %rdi
callq 0x72c0
jmp 0xba3d5
movq -0x18(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
jne 0xb9ff9
movq -0x198(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
xorl %ecx, %ecx
callq *%rax
movq -0x1a8(%rbp), %rdi
movq -0x1d0(%rbp), %rdx
leaq 0x8bf51(%rip), %rsi     # 0x145f0a
leaq 0x8422b(%rip), %r8      # 0x13e1eb
leaq -0x38(%rbp), %rcx
callq 0xd6e20
jmp 0xb9fcb
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xba3c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xba3d5
movq -0x18(%rbp), %rax
cmpl $0x2, 0x8c(%rax)
jne 0xba07b
movq -0x18(%rbp), %rax
movl 0x90(%rax), %esi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %edx
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0xba3e0
movq -0x1a8(%rbp), %rdi
movq -0x1d8(%rbp), %rdx
leaq 0x8bec9(%rip), %rsi     # 0x145f08
leaq 0x841a5(%rip), %rcx     # 0x13e1eb
callq 0xd6ee0
jmp 0xba04d
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0xba3c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0xba3d5
movb $0x1, -0xfa(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1e8(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x7650
movq -0x1e0(%rbp), %rdx
leaq 0x8be5e(%rip), %rsi     # 0x145f12
leaq -0xf8(%rbp), %rdi
callq 0x7520
jmp 0xba0c2
movq -0x1e8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x9c50
jmp 0xba0d7
movq -0x1e8(%rbp), %rdi
movb $0x0, -0xfa(%rbp)
leaq 0xf3cec(%rip), %rsi     # 0x1addd8
leaq -0xb0463(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xba3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xba123
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x7708
leaq -0xf9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xfa(%rbp)
jne 0xba13a
jmp 0xba146
movq -0x1e8(%rbp), %rdi
callq 0x72c0
jmp 0xba3d5
leaq 0x87c87(%rip), %rax     # 0x141dd9
movq %rax, -0x30(%rbp)
movb $0x0, -0x31(%rbp)
jmp 0xba22f
movb $0x1, -0x122(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1f8(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x7650
movq -0x1f0(%rbp), %rdx
leaq 0x8bdc9(%rip), %rsi     # 0x145f61
leaq -0x120(%rbp), %rdi
callq 0x7520
jmp 0xba1a6
movq -0x1f8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x9c50
jmp 0xba1bb
movq -0x1f8(%rbp), %rdi
movb $0x0, -0x122(%rbp)
leaq 0xf3c08(%rip), %rsi     # 0x1addd8
leaq -0xb0547(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xba3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xba207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x7708
leaq -0x121(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x122(%rbp)
jne 0xba21e
jmp 0xba22a
movq -0x1f8(%rbp), %rdi
callq 0x72c0
jmp 0xba3d5
movq -0x18(%rbp), %rax
movb 0x89(%rax), %dl
leaq 0x8465e(%rip), %rax     # 0x13e89e
leaq 0x87b86(%rip), %rcx     # 0x141dcd
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
movb 0x8a(%rax), %dl
leaq 0x84638(%rip), %rax     # 0x13e89e
leaq 0x87b85(%rip), %rcx     # 0x141df2
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x138(%rbp)
movb -0x31(%rbp), %dl
leaq 0x84619(%rip), %rax     # 0x13e89e
leaq 0x8bce8(%rip), %rcx     # 0x145f74
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x140(%rbp)
movb -0x31(%rbp), %al
movb $0x0, -0x181(%rbp)
testb $0x1, %al
je 0xba2c7
movq -0x18(%rbp), %rax
movl 0x90(%rax), %esi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %edx
leaq -0x160(%rbp), %rdi
callq 0xba3e0
jmp 0xba310
movq -0x198(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x180(%rbp), %rdi
movq %rdi, -0x200(%rbp)
xorl %ecx, %ecx
callq *%rax
movq -0x200(%rbp), %rsi
movb $0x1, -0x181(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0xd7090
jmp 0xba30e
jmp 0xba310
movq -0x1a8(%rbp), %rdi
leaq 0x83ecd(%rip), %rcx     # 0x13e1eb
movq %rsp, %rax
movq %rcx, 0x10(%rax)
leaq -0x160(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x8829a(%rip), %rcx     # 0x1425d1
movq %rcx, (%rax)
leaq 0x8bc36(%rip), %rdx     # 0x145f77
leaq -0x140(%rbp), %rsi
leaq -0x30(%rbp), %rcx
leaq -0x138(%rbp), %r8
leaq -0x130(%rbp), %r9
callq 0xd6fa0
jmp 0xba361
leaq -0x160(%rbp), %rdi
callq 0x7708
testb $0x1, -0x181(%rbp)
jne 0xba378
jmp 0xba384
leaq -0x180(%rbp), %rdi
callq 0x7708
jmp 0xba3c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xba3ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x7708
testb $0x1, -0x181(%rbp)
jne 0xba3b7
jmp 0xba3c3
leaq -0x180(%rbp), %rdi
callq 0x7708
jmp 0xba3d5
movq -0x1a0(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x7640
nop