diff options
Diffstat (limited to 'src/shader_recompiler/backend')
4 files changed, 35 insertions, 35 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index d0e308124..64e7bad75 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp | |||
| @@ -559,12 +559,12 @@ void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 559 | const IR::Value& offset, const IR::Value& lod_clamp) { | 559 | const IR::Value& offset, const IR::Value& lod_clamp) { |
| 560 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 560 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 561 | ScopedRegister dpdx, dpdy, coords; | 561 | ScopedRegister dpdx, dpdy, coords; |
| 562 | const bool multi_component{info.num_derivates > 1 || info.has_lod_clamp}; | 562 | const bool multi_component{info.num_derivatives > 1 || info.has_lod_clamp}; |
| 563 | if (multi_component) { | 563 | if (multi_component) { |
| 564 | // Allocate this early to avoid aliasing other registers | 564 | // Allocate this early to avoid aliasing other registers |
| 565 | dpdx = ScopedRegister{ctx.reg_alloc}; | 565 | dpdx = ScopedRegister{ctx.reg_alloc}; |
| 566 | dpdy = ScopedRegister{ctx.reg_alloc}; | 566 | dpdy = ScopedRegister{ctx.reg_alloc}; |
| 567 | if (info.num_derivates >= 3) { | 567 | if (info.num_derivatives >= 3) { |
| 568 | coords = ScopedRegister{ctx.reg_alloc}; | 568 | coords = ScopedRegister{ctx.reg_alloc}; |
| 569 | } | 569 | } |
| 570 | } | 570 | } |
| @@ -584,7 +584,7 @@ void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 584 | dpdx.reg, derivatives_vec, dpdx.reg, derivatives_vec, dpdy.reg, derivatives_vec, | 584 | dpdx.reg, derivatives_vec, dpdx.reg, derivatives_vec, dpdy.reg, derivatives_vec, |
| 585 | dpdy.reg, derivatives_vec); | 585 | dpdy.reg, derivatives_vec); |
| 586 | Register final_coord; | 586 | Register final_coord; |
| 587 | if (info.num_derivates >= 3) { | 587 | if (info.num_derivatives >= 3) { |
| 588 | ctx.Add("MOV.F {}.z,{}.x;" | 588 | ctx.Add("MOV.F {}.z,{}.x;" |
| 589 | "MOV.F {}.z,{}.y;", | 589 | "MOV.F {}.z,{}.y;", |
| 590 | dpdx.reg, coord_vec, dpdy.reg, coord_vec); | 590 | dpdx.reg, coord_vec, dpdy.reg, coord_vec); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index d9872ecc2..6e940bd5a 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -548,15 +548,15 @@ void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 548 | if (sparse_inst) { | 548 | if (sparse_inst) { |
| 549 | throw NotImplementedException("EmitImageGradient Sparse"); | 549 | throw NotImplementedException("EmitImageGradient Sparse"); |
| 550 | } | 550 | } |
| 551 | if (!offset.IsEmpty() && info.num_derivates <= 2) { | 551 | if (!offset.IsEmpty() && info.num_derivatives <= 2) { |
| 552 | throw NotImplementedException("EmitImageGradient offset"); | 552 | throw NotImplementedException("EmitImageGradient offset"); |
| 553 | } | 553 | } |
| 554 | const auto texture{Texture(ctx, info, index)}; | 554 | const auto texture{Texture(ctx, info, index)}; |
| 555 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; | 555 | const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; |
| 556 | const bool multi_component{info.num_derivates > 1 || info.has_lod_clamp}; | 556 | const bool multi_component{info.num_derivatives > 1 || info.has_lod_clamp}; |
| 557 | const auto derivatives_vec{ctx.var_alloc.Consume(derivatives)}; | 557 | const auto derivatives_vec{ctx.var_alloc.Consume(derivatives)}; |
| 558 | if (multi_component) { | 558 | if (multi_component) { |
| 559 | if (info.num_derivates >= 3) { | 559 | if (info.num_derivatives >= 3) { |
| 560 | const auto offset_vec{ctx.var_alloc.Consume(offset)}; | 560 | const auto offset_vec{ctx.var_alloc.Consume(offset)}; |
| 561 | ctx.Add("{}=textureGrad({},{},vec3({}.xz, {}.x),vec3({}.yw, {}.y));", texel, texture, | 561 | ctx.Add("{}=textureGrad({},{},vec3({}.xz, {}.x),vec3({}.yw, {}.y));", texel, texture, |
| 562 | coords, derivatives_vec, offset_vec, derivatives_vec, offset_vec); | 562 | coords, derivatives_vec, offset_vec, derivatives_vec, offset_vec); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 8decdf399..22ceca19c 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
| @@ -67,22 +67,22 @@ public: | |||
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivates, u32 num_derivates, | 70 | explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives, |
| 71 | Id offset, Id lod_clamp) { | 71 | u32 num_derivatives, Id offset, Id lod_clamp) { |
| 72 | if (!Sirit::ValidId(derivates)) { | 72 | if (!Sirit::ValidId(derivatives)) { |
| 73 | throw LogicError("Derivates must be present"); | 73 | throw LogicError("Derivatives must be present"); |
| 74 | } | 74 | } |
| 75 | boost::container::static_vector<Id, 3> deriv_x_accum; | 75 | boost::container::static_vector<Id, 3> deriv_x_accum; |
| 76 | boost::container::static_vector<Id, 3> deriv_y_accum; | 76 | boost::container::static_vector<Id, 3> deriv_y_accum; |
| 77 | for (u32 i = 0; i < num_derivates; ++i) { | 77 | for (u32 i = 0; i < num_derivatives; ++i) { |
| 78 | deriv_x_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2)); | 78 | deriv_x_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivatives, i * 2)); |
| 79 | deriv_y_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivates, i * 2 + 1)); | 79 | deriv_y_accum.push_back(ctx.OpCompositeExtract(ctx.F32[1], derivatives, i * 2 + 1)); |
| 80 | } | 80 | } |
| 81 | const Id derivates_X{ctx.OpCompositeConstruct( | 81 | const Id derivatives_X{ctx.OpCompositeConstruct( |
| 82 | ctx.F32[num_derivates], std::span{deriv_x_accum.data(), deriv_x_accum.size()})}; | 82 | ctx.F32[num_derivatives], std::span{deriv_x_accum.data(), deriv_x_accum.size()})}; |
| 83 | const Id derivates_Y{ctx.OpCompositeConstruct( | 83 | const Id derivatives_Y{ctx.OpCompositeConstruct( |
| 84 | ctx.F32[num_derivates], std::span{deriv_y_accum.data(), deriv_y_accum.size()})}; | 84 | ctx.F32[num_derivatives], std::span{deriv_y_accum.data(), deriv_y_accum.size()})}; |
| 85 | Add(spv::ImageOperandsMask::Grad, derivates_X, derivates_Y); | 85 | Add(spv::ImageOperandsMask::Grad, derivatives_X, derivatives_Y); |
| 86 | if (Sirit::ValidId(offset)) { | 86 | if (Sirit::ValidId(offset)) { |
| 87 | Add(spv::ImageOperandsMask::Offset, offset); | 87 | Add(spv::ImageOperandsMask::Offset, offset); |
| 88 | } | 88 | } |
| @@ -91,26 +91,26 @@ public: | |||
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivates_1, Id derivates_2, | 94 | explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives_1, Id derivatives_2, |
| 95 | Id offset, Id lod_clamp) { | 95 | Id offset, Id lod_clamp) { |
| 96 | if (!Sirit::ValidId(derivates_1) || !Sirit::ValidId(derivates_2)) { | 96 | if (!Sirit::ValidId(derivatives_1) || !Sirit::ValidId(derivatives_2)) { |
| 97 | throw LogicError("Derivates must be present"); | 97 | throw LogicError("Derivatives must be present"); |
| 98 | } | 98 | } |
| 99 | boost::container::static_vector<Id, 3> deriv_1_accum{ | 99 | boost::container::static_vector<Id, 3> deriv_1_accum{ |
| 100 | ctx.OpCompositeExtract(ctx.F32[1], derivates_1, 0), | 100 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_1, 0), |
| 101 | ctx.OpCompositeExtract(ctx.F32[1], derivates_1, 2), | 101 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_1, 2), |
| 102 | ctx.OpCompositeExtract(ctx.F32[1], derivates_2, 0), | 102 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_2, 0), |
| 103 | }; | 103 | }; |
| 104 | boost::container::static_vector<Id, 3> deriv_2_accum{ | 104 | boost::container::static_vector<Id, 3> deriv_2_accum{ |
| 105 | ctx.OpCompositeExtract(ctx.F32[1], derivates_1, 1), | 105 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_1, 1), |
| 106 | ctx.OpCompositeExtract(ctx.F32[1], derivates_1, 3), | 106 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_1, 3), |
| 107 | ctx.OpCompositeExtract(ctx.F32[1], derivates_2, 1), | 107 | ctx.OpCompositeExtract(ctx.F32[1], derivatives_2, 1), |
| 108 | }; | 108 | }; |
| 109 | const Id derivates_id1{ctx.OpCompositeConstruct( | 109 | const Id derivatives_id1{ctx.OpCompositeConstruct( |
| 110 | ctx.F32[3], std::span{deriv_1_accum.data(), deriv_1_accum.size()})}; | 110 | ctx.F32[3], std::span{deriv_1_accum.data(), deriv_1_accum.size()})}; |
| 111 | const Id derivates_id2{ctx.OpCompositeConstruct( | 111 | const Id derivatives_id2{ctx.OpCompositeConstruct( |
| 112 | ctx.F32[3], std::span{deriv_2_accum.data(), deriv_2_accum.size()})}; | 112 | ctx.F32[3], std::span{deriv_2_accum.data(), deriv_2_accum.size()})}; |
| 113 | Add(spv::ImageOperandsMask::Grad, derivates_id1, derivates_id2); | 113 | Add(spv::ImageOperandsMask::Grad, derivatives_id1, derivatives_id2); |
| 114 | if (Sirit::ValidId(offset)) { | 114 | if (Sirit::ValidId(offset)) { |
| 115 | Add(spv::ImageOperandsMask::Offset, offset); | 115 | Add(spv::ImageOperandsMask::Offset, offset); |
| 116 | } | 116 | } |
| @@ -548,12 +548,12 @@ Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, I | |||
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 550 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 551 | Id derivates, Id offset, Id lod_clamp) { | 551 | Id derivatives, Id offset, Id lod_clamp) { |
| 552 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 552 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
| 553 | const auto operands = | 553 | const auto operands = |
| 554 | info.num_derivates == 3 | 554 | info.num_derivatives == 3 |
| 555 | ? ImageOperands(ctx, info.has_lod_clamp != 0, derivates, offset, {}, lod_clamp) | 555 | ? ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, offset, {}, lod_clamp) |
| 556 | : ImageOperands(ctx, info.has_lod_clamp != 0, derivates, info.num_derivates, offset, | 556 | : ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, info.num_derivatives, offset, |
| 557 | lod_clamp); | 557 | lod_clamp); |
| 558 | return Emit(&EmitContext::OpImageSparseSampleExplicitLod, | 558 | return Emit(&EmitContext::OpImageSparseSampleExplicitLod, |
| 559 | &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], | 559 | &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index a440b557d..7d34575c8 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -543,7 +543,7 @@ Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& i | |||
| 543 | const IR::Value& skip_mips); | 543 | const IR::Value& skip_mips); |
| 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |
| 545 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 545 | Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
| 546 | Id derivates, Id offset, Id lod_clamp); | 546 | Id derivatives, Id offset, Id lod_clamp); |
| 547 | Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 547 | Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |
| 548 | void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color); | 548 | void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color); |
| 549 | Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index); | 549 | Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index); |