| 30 | using ValidateFunctionCall = spvtest::ValidateBase<std::string>; |
| 31 | |
| 32 | std::string GenerateShader(const std::string& storage_class, |
| 33 | const std::string& capabilities, |
| 34 | const std::string& extensions) { |
| 35 | std::string spirv = R"( |
| 36 | OpCapability Shader |
| 37 | OpCapability Linkage |
| 38 | OpCapability AtomicStorage |
| 39 | )" + capabilities + R"( |
| 40 | OpExtension "SPV_KHR_storage_buffer_storage_class" |
| 41 | )" + |
| 42 | extensions + R"( |
| 43 | OpMemoryModel Logical GLSL450 |
| 44 | OpName %var "var" |
| 45 | %void = OpTypeVoid |
| 46 | %int = OpTypeInt 32 0 |
| 47 | %ptr = OpTypePointer )" + storage_class + R"( %int |
| 48 | %caller_ty = OpTypeFunction %void |
| 49 | %callee_ty = OpTypeFunction %void %ptr |
| 50 | )"; |
| 51 | |
| 52 | if (storage_class != "Function") { |
| 53 | spirv += "%var = OpVariable %ptr " + storage_class; |
| 54 | } |
| 55 | |
| 56 | spirv += R"( |
| 57 | %caller = OpFunction %void None %caller_ty |
| 58 | %1 = OpLabel |
| 59 | )"; |
| 60 | |
| 61 | if (storage_class == "Function") { |
| 62 | spirv += "%var = OpVariable %ptr Function"; |
| 63 | } |
| 64 | |
| 65 | spirv += R"( |
| 66 | %call = OpFunctionCall %void %callee %var |
| 67 | OpReturn |
| 68 | OpFunctionEnd |
| 69 | %callee = OpFunction %void None %callee_ty |
| 70 | %param = OpFunctionParameter %ptr |
| 71 | %2 = OpLabel |
| 72 | OpReturn |
| 73 | OpFunctionEnd |
| 74 | )"; |
| 75 | |
| 76 | return spirv; |
| 77 | } |
| 78 | |
| 79 | std::string GenerateShaderParameter(const std::string& storage_class, |
| 80 | const std::string& capabilities, |