shader_recompiler: fixed sin/cos

Thanks to red_pring and gandalfthewhite0173
This commit is contained in:
psucien 2024-07-19 20:32:50 +02:00
parent 3b8efa608d
commit 9c49844107
3 changed files with 11 additions and 4 deletions

View File

@ -100,11 +100,11 @@ Id EmitFPNeg64(EmitContext& ctx, Id value) {
}
Id EmitFPSin(EmitContext& ctx, Id value) {
return ctx.OpSin(ctx.F32[1], value);
return ctx.OpSin(ctx.F32[1], ctx.OpFMul(ctx.F32[1], ctx.pi_x2, value));
}
Id EmitFPCos(EmitContext& ctx, Id value) {
return ctx.OpCos(ctx.F32[1], value);
return ctx.OpCos(ctx.F32[1], ctx.OpFMul(ctx.F32[1], ctx.pi_x2, value));
}
Id EmitFPExp2(EmitContext& ctx, Id value) {

View File

@ -1,11 +1,14 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <boost/container/static_vector.hpp>
#include <fmt/format.h>
#include "common/div_ceil.h"
#include "shader_recompiler/backend/spirv/spirv_emit_context.h"
#include <boost/container/static_vector.hpp>
#include <fmt/format.h>
static constexpr auto M_PI = 3.14159265358979323846f;
namespace Shader::Backend::SPIRV {
namespace {
@ -100,6 +103,8 @@ void EmitContext::DefineArithmeticTypes() {
u32_zero_value = ConstU32(0U);
f32_zero_value = ConstF32(0.0f);
pi_x2 = ConstF32(2.0f * float(M_PI));
input_f32 = Name(TypePointer(spv::StorageClass::Input, F32[1]), "input_f32");
input_u32 = Name(TypePointer(spv::StorageClass::Input, U32[1]), "input_u32");
input_s32 = Name(TypePointer(spv::StorageClass::Input, S32[1]), "input_s32");

View File

@ -143,6 +143,8 @@ public:
Id full_result_i32x2;
Id full_result_u32x2;
Id pi_x2;
Id true_value{};
Id false_value{};
Id u32_one_value{};