| 2401 | } |
| 2402 | |
| 2403 | bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *args, uint32_t length) |
| 2404 | { |
| 2405 | if (length < 3) |
| 2406 | return false; |
| 2407 | |
| 2408 | auto &callee = compiler.get<SPIRFunction>(args[2]); |
| 2409 | args += 3; |
| 2410 | |
| 2411 | // There are two types of cases we have to handle, |
| 2412 | // a callee might call sampler2D(texture2D, sampler) directly where |
| 2413 | // one or more parameters originate from parameters. |
| 2414 | // Alternatively, we need to provide combined image samplers to our callees, |
| 2415 | // and in this case we need to add those as well. |
| 2416 | |
| 2417 | pop_remap_parameters(); |
| 2418 | |
| 2419 | // Our callee has now been processed at least once. |
| 2420 | // No point in doing it again. |
| 2421 | callee.do_combined_parameters = false; |
| 2422 | |
| 2423 | auto ¶ms = functions.top()->combined_parameters; |
| 2424 | functions.pop(); |
| 2425 | if (functions.empty()) |
| 2426 | return true; |
| 2427 | |
| 2428 | auto &caller = *functions.top(); |
| 2429 | if (caller.do_combined_parameters) |
| 2430 | { |
| 2431 | for (auto ¶m : params) |
| 2432 | { |
| 2433 | VariableID image_id = param.global_image ? param.image_id : VariableID(args[param.image_id]); |
| 2434 | VariableID sampler_id = param.global_sampler ? param.sampler_id : VariableID(args[param.sampler_id]); |
| 2435 | |
| 2436 | auto *i = compiler.maybe_get_backing_variable(image_id); |
| 2437 | auto *s = compiler.maybe_get_backing_variable(sampler_id); |
| 2438 | if (i) |
| 2439 | image_id = i->self; |
| 2440 | if (s) |
| 2441 | sampler_id = s->self; |
| 2442 | |
| 2443 | register_combined_image_sampler(caller, 0, image_id, sampler_id, param.depth); |
| 2444 | } |
| 2445 | } |
| 2446 | |
| 2447 | return true; |
| 2448 | } |
| 2449 | |
| 2450 | void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, |
| 2451 | VariableID combined_module_id, |
no test coverage detected