VideoCommon: Don't pass State by inout
Spirv-cross's MSL codegen makes the amazing choice of compiling calls to inout functions as `State temp = s; call_function(temp); s = temp`. Not all Metal backends handle this mess well. In particular, it causes register spills on Intel, losing about 5% in performance.
This commit is contained in:
parent
db6e928c8d
commit
25929789c1
|
@ -502,14 +502,6 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
|
||||||
"\n"
|
"\n"
|
||||||
"int4 getTevReg(in State s, uint index) {{\n");
|
"int4 getTevReg(in State s, uint index) {{\n");
|
||||||
WriteSwitch(out, api_type, "index", tev_regs_lookup_table, 2, false);
|
WriteSwitch(out, api_type, "index", tev_regs_lookup_table, 2, false);
|
||||||
out.Write("}}\n"
|
|
||||||
"\n"
|
|
||||||
"void setRegColor(inout State s, uint index, int3 color) {{\n");
|
|
||||||
WriteSwitch(out, api_type, "index", tev_c_set_table, 2, true);
|
|
||||||
out.Write("}}\n"
|
|
||||||
"\n"
|
|
||||||
"void setRegAlpha(inout State s, uint index, int alpha) {{\n");
|
|
||||||
WriteSwitch(out, api_type, "index", tev_a_set_table, 2, true);
|
|
||||||
out.Write("}}\n"
|
out.Write("}}\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
|
@ -861,9 +853,9 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
|
||||||
" else\n"
|
" else\n"
|
||||||
" color = clamp(color, -1024, 1023);\n"
|
" color = clamp(color, -1024, 1023);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" // Write result to the correct input register of the next stage\n"
|
" // Write result to the correct input register of the next stage\n");
|
||||||
" setRegColor(s, color_dest, color);\n"
|
WriteSwitch(out, api_type, "color_dest", tev_c_set_table, 6, true);
|
||||||
"\n");
|
out.Write("\n");
|
||||||
|
|
||||||
// Alpha combiner
|
// Alpha combiner
|
||||||
out.Write(" // Alpha Combiner\n");
|
out.Write(" // Alpha Combiner\n");
|
||||||
|
@ -927,11 +919,10 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
|
||||||
" else\n"
|
" else\n"
|
||||||
" alpha = clamp(alpha, -1024, 1023);\n"
|
" alpha = clamp(alpha, -1024, 1023);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" // Write result to the correct input register of the next stage\n"
|
" // Write result to the correct input register of the next stage\n");
|
||||||
" setRegAlpha(s, alpha_dest, alpha);\n"
|
WriteSwitch(out, api_type, "alpha_dest", tev_a_set_table, 6, true);
|
||||||
" }}\n");
|
out.Write(" }}\n"
|
||||||
|
" }} // Main TEV loop\n"
|
||||||
out.Write(" }} // Main TEV loop\n"
|
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
// Select the output color and alpha registers from the last stage.
|
// Select the output color and alpha registers from the last stage.
|
||||||
|
|
Loading…
Reference in New Issue