MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / GenerateShaderAccessChain

Function GenerateShaderAccessChain

test/val/val_function_test.cpp:112–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112std::string GenerateShaderAccessChain(const std::string& storage_class,
113 const std::string& capabilities,
114 const std::string& extensions) {
115 std::string spirv = R"(
116OpCapability Shader
117OpCapability Linkage
118OpCapability AtomicStorage
119)" + capabilities + R"(
120OpExtension "SPV_KHR_storage_buffer_storage_class"
121)" +
122 extensions + R"(
123OpMemoryModel Logical GLSL450
124OpName %var "var"
125OpName %gep "gep"
126%void = OpTypeVoid
127%int = OpTypeInt 32 0
128%int2 = OpTypeVector %int 2
129%int_0 = OpConstant %int 0
130%ptr = OpTypePointer )" + storage_class + R"( %int2
131%ptr2 = OpTypePointer )" +
132 storage_class + R"( %int
133%caller_ty = OpTypeFunction %void
134%callee_ty = OpTypeFunction %void %ptr2
135)";
136
137 if (storage_class != "Function") {
138 spirv += "%var = OpVariable %ptr " + storage_class;
139 }
140
141 spirv += R"(
142%caller = OpFunction %void None %caller_ty
143%1 = OpLabel
144)";
145
146 if (storage_class == "Function") {
147 spirv += "%var = OpVariable %ptr Function";
148 }
149
150 spirv += R"(
151%gep = OpAccessChain %ptr2 %var %int_0
152%call = OpFunctionCall %void %callee %gep
153OpReturn
154OpFunctionEnd
155%callee = OpFunction %void None %callee_ty
156%param = OpFunctionParameter %ptr2
157%2 = OpLabel
158OpReturn
159OpFunctionEnd
160)";
161
162 return spirv;
163}
164
165TEST_P(ValidateFunctionCall, VariableNoVariablePointers) {
166 const std::string storage_class = GetParam();

Callers 1

TEST_PFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected