| 5668 | spvtest::ValidateBase<std::tuple<std::string, uint32_t, std::string>>; |
| 5669 | |
| 5670 | CodeGenerator GetSizedLoadStoreCodeGenerator(const std::string& base_type, |
| 5671 | uint32_t width) { |
| 5672 | CodeGenerator generator; |
| 5673 | generator.capabilities_ = "OpCapability Shader\nOpCapability Linkage\n"; |
| 5674 | if (width == 8) { |
| 5675 | generator.capabilities_ += |
| 5676 | "OpCapability UniformAndStorageBuffer8BitAccess\n"; |
| 5677 | generator.extensions_ = "OpExtension \"SPV_KHR_8bit_storage\"\n"; |
| 5678 | } else { |
| 5679 | generator.capabilities_ += |
| 5680 | "OpCapability UniformAndStorageBuffer16BitAccess\n"; |
| 5681 | generator.extensions_ = "OpExtension \"SPV_KHR_16bit_storage\"\n"; |
| 5682 | } |
| 5683 | generator.memory_model_ = "OpMemoryModel Logical GLSL450\n"; |
| 5684 | generator.before_types_ = R"(OpDecorate %block Block |
| 5685 | OpMemberDecorate %block 0 Offset 0 |
| 5686 | OpMemberDecorate %struct 0 Offset 0 |
| 5687 | )"; |
| 5688 | generator.types_ = R"(%void = OpTypeVoid |
| 5689 | %int = OpTypeInt 32 0 |
| 5690 | %int_0 = OpConstant %int 0 |
| 5691 | %int_1 = OpConstant %int 1 |
| 5692 | %int_2 = OpConstant %int 2 |
| 5693 | %int_3 = OpConstant %int 3 |
| 5694 | )"; |
| 5695 | |
| 5696 | if (width == 8) { |
| 5697 | generator.types_ += R"(%scalar = OpTypeInt 8 0 |
| 5698 | %vector = OpTypeVector %scalar 4 |
| 5699 | %struct = OpTypeStruct %vector |
| 5700 | )"; |
| 5701 | } else if (base_type == "int") { |
| 5702 | generator.types_ += R"(%scalar = OpTypeInt 16 0 |
| 5703 | %vector = OpTypeVector %scalar 4 |
| 5704 | %struct = OpTypeStruct %vector |
| 5705 | )"; |
| 5706 | } else { |
| 5707 | generator.types_ += R"(%scalar = OpTypeFloat 16 |
| 5708 | %vector = OpTypeVector %scalar 4 |
| 5709 | %matrix = OpTypeMatrix %vector 4 |
| 5710 | %struct = OpTypeStruct %matrix |
| 5711 | %ptr_ssbo_matrix = OpTypePointer StorageBuffer %matrix |
| 5712 | )"; |
| 5713 | generator.before_types_ += R"(OpMemberDecorate %struct 0 RowMajor |
| 5714 | OpMemberDecorate %struct 0 MatrixStride 16 |
| 5715 | )"; |
| 5716 | } |
| 5717 | generator.types_ += R"(%block = OpTypeStruct %struct |
| 5718 | %ptr_ssbo_block = OpTypePointer StorageBuffer %block |
| 5719 | %ptr_ssbo_struct = OpTypePointer StorageBuffer %struct |
| 5720 | %ptr_ssbo_vector = OpTypePointer StorageBuffer %vector |
| 5721 | %ptr_ssbo_scalar = OpTypePointer StorageBuffer %scalar |
| 5722 | %ld_var = OpVariable %ptr_ssbo_block StorageBuffer |
| 5723 | %st_var = OpVariable %ptr_ssbo_block StorageBuffer |
| 5724 | )"; |
| 5725 | |
| 5726 | generator.after_types_ = R"(%void_fn = OpTypeFunction %void |
| 5727 | %func = OpFunction %void None %void_fn |