| 2125 | _current_block = id; |
| 2126 | } |
| 2127 | id leave_block_and_kill() override |
| 2128 | { |
| 2129 | if (!is_in_block()) |
| 2130 | return 0; |
| 2131 | |
| 2132 | std::string &code = _blocks.at(_current_block); |
| 2133 | |
| 2134 | code += "\tdiscard;\n"; |
| 2135 | |
| 2136 | const type &return_type = _current_function->return_type; |
| 2137 | if (!return_type.is_void()) |
| 2138 | { |
| 2139 | // HLSL compiler doesn't handle discard like a shader kill |
| 2140 | // Add a return statement to exit functions in case discard is the last control flow statement |
| 2141 | // See https://docs.microsoft.com/windows/win32/direct3dhlsl/discard--sm4---asm- |
| 2142 | code += "\treturn "; |
| 2143 | write_constant(code, return_type, constant()); |
| 2144 | code += ";\n"; |
| 2145 | } |
| 2146 | else |
| 2147 | { |
| 2148 | code += "\treturn;\n"; |
| 2149 | } |
| 2150 | |
| 2151 | return set_block(0); |
| 2152 | } |
| 2153 | id leave_block_and_return(id value) override |
| 2154 | { |
| 2155 | if (!is_in_block()) |
nothing calls this directly
no test coverage detected