MCPcopy Create free account
hub / github.com/crosire/reshade / leave_block_and_kill

Function leave_block_and_kill

source/effect_codegen_hlsl.cpp:2127–2152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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())

Callers

nothing calls this directly

Calls 5

write_constantFunction · 0.85
atMethod · 0.80
is_voidMethod · 0.80
constantClass · 0.70
set_blockFunction · 0.70

Tested by

no test coverage detected