summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-19 01:00:51 -0400
committerGravatar ameerj2021-07-22 21:51:33 -0400
commit36d040da7059e438fa35f1a5de5d5aed4cef5ca4 (patch)
tree304f0b94407b689627c4966212c06dc3e8ad65d5 /src/shader_recompiler/backend
parentglasm: Implement PrimitiveId attribute read (diff)
downloadyuzu-36d040da7059e438fa35f1a5de5d5aed4cef5ca4.tar.gz
yuzu-36d040da7059e438fa35f1a5de5d5aed4cef5ca4.tar.xz
yuzu-36d040da7059e438fa35f1a5de5d5aed4cef5ca4.zip
glasm: Implement FSWZADD
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp16
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h3
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp13
3 files changed, 28 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index 4fc7d2f2f..f110fd7f8 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -281,7 +281,8 @@ void SetupOptions(const IR::Program& program, const Profile& profile, std::strin
281 if (info.uses_atomic_f16x2_add || info.uses_atomic_f16x2_min || info.uses_atomic_f16x2_max) { 281 if (info.uses_atomic_f16x2_add || info.uses_atomic_f16x2_min || info.uses_atomic_f16x2_max) {
282 header += "OPTION NV_shader_atomic_fp16_vector;"; 282 header += "OPTION NV_shader_atomic_fp16_vector;";
283 } 283 }
284 if (info.uses_subgroup_invocation_id || info.uses_subgroup_mask || info.uses_subgroup_vote) { 284 if (info.uses_subgroup_invocation_id || info.uses_subgroup_mask || info.uses_subgroup_vote ||
285 info.uses_fswzadd) {
285 header += "OPTION NV_shader_thread_group;"; 286 header += "OPTION NV_shader_thread_group;";
286 } 287 }
287 if (info.uses_subgroup_shuffles) { 288 if (info.uses_subgroup_shuffles) {
@@ -416,12 +417,25 @@ std::string EmitGLASM(const Profile& profile, IR::Program& program, Bindings& bi
416 if (program.local_memory_size > 0) { 417 if (program.local_memory_size > 0) {
417 header += fmt::format("lmem[{}],", program.local_memory_size); 418 header += fmt::format("lmem[{}],", program.local_memory_size);
418 } 419 }
420 if (program.info.uses_fswzadd) {
421 header += "FSWZA[4],FSWZB[4],";
422 }
419 header += "RC;" 423 header += "RC;"
420 "LONG TEMP "; 424 "LONG TEMP ";
421 for (size_t index = 0; index < ctx.reg_alloc.NumUsedLongRegisters(); ++index) { 425 for (size_t index = 0; index < ctx.reg_alloc.NumUsedLongRegisters(); ++index) {
422 header += fmt::format("D{},", index); 426 header += fmt::format("D{},", index);
423 } 427 }
424 header += "DC;"; 428 header += "DC;";
429 if (program.info.uses_fswzadd) {
430 header += "MOV.F FSWZA[0],-1;"
431 "MOV.F FSWZA[1],1;"
432 "MOV.F FSWZA[2],-1;"
433 "MOV.F FSWZA[3],0;"
434 "MOV.F FSWZB[0],-1;"
435 "MOV.F FSWZB[1],-1;"
436 "MOV.F FSWZB[2],1;"
437 "MOV.F FSWZB[3],-1;";
438 }
425 ctx.code.insert(0, header); 439 ctx.code.insert(0, header);
426 ctx.code += "END"; 440 ctx.code += "END";
427 return ctx.code; 441 return ctx.code;
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
index 2eb1eb123..15380a955 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
@@ -616,7 +616,8 @@ void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU3
616 const IR::Value& clamp, const IR::Value& segmentation_mask); 616 const IR::Value& clamp, const IR::Value& segmentation_mask);
617void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index, 617void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 index,
618 const IR::Value& clamp, const IR::Value& segmentation_mask); 618 const IR::Value& clamp, const IR::Value& segmentation_mask);
619void EmitFSwizzleAdd(EmitContext& ctx, ScalarF32 op_a, ScalarF32 op_b, ScalarU32 swizzle); 619void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a, ScalarF32 op_b,
620 ScalarU32 swizzle);
620void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a); 621void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a);
621void EmitDPdyFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a); 622void EmitDPdyFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a);
622void EmitDPdxCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a); 623void EmitDPdxCoarse(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a);
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp
index 0f987daeb..af0e13d43 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp
@@ -95,8 +95,17 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, Sca
95 Shuffle(ctx, inst, value, index, clamp, segmentation_mask, "XOR"); 95 Shuffle(ctx, inst, value, index, clamp, segmentation_mask, "XOR");
96} 96}
97 97
98void EmitFSwizzleAdd(EmitContext&, ScalarF32, ScalarF32, ScalarU32) { 98void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, ScalarF32 op_a, ScalarF32 op_b,
99 throw NotImplementedException("GLASM instruction"); 99 ScalarU32 swizzle) {
100 const auto ret{ctx.reg_alloc.Define(inst)};
101 ctx.Add("AND.U RC.z,{}.threadid,3;"
102 "SHL.U RC.z,RC.z,1;"
103 "SHR.U RC.z,{},RC.z;"
104 "AND.U RC.z,RC.z,3;"
105 "MUL.F RC.x,{},FSWZA[RC.z];"
106 "MUL.F RC.y,{},FSWZB[RC.z];"
107 "ADD.F {}.x,RC.x,RC.y;",
108 ctx.stage_name, swizzle, op_a, op_b, ret);
100} 109}
101 110
102void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) { 111void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, ScalarF32 p) {