From 0d843eaba674d42da08b3fa31d247cda880b5be2 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 May 2018 22:16:18 -0400 Subject: [PATCH 1/5] gl_rasterize_cache: Invert order of tex format RGB565. --- src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index e652bd9ed..a496dedc2 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -45,7 +45,7 @@ struct FormatTuple { static constexpr std::array tex_format_tuples = {{ {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 - {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5 + {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, false}, // B5G6R5 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 From 0658973a4e2df90b6676510e6b788bc84d0f072d Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 May 2018 22:35:41 -0400 Subject: [PATCH 2/5] nvhost_ctrl: Stub out IocCtrlEventWaitAsyncCommand. --- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 12 ++++++++---- src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index e979b9707..a2d3584e5 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -16,7 +16,9 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector& input, std::vector< case IoctlCommand::IocGetConfigCommand: return NvOsGetConfigU32(input, output); case IoctlCommand::IocCtrlEventWaitCommand: - return IocCtrlEventWait(input, output); + return IocCtrlEventWait(input, output, false); + case IoctlCommand::IocCtrlEventWaitAsyncCommand: + return IocCtrlEventWait(input, output, true); } UNIMPLEMENTED_MSG("Unimplemented ioctl"); return 0; @@ -45,11 +47,13 @@ u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector& input, std::vector& return 0; } -u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& output) { +u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& output, + bool is_async) { IocCtrlEventWaitParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); - NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, syncpt_id={} threshold={} timeout={}", - params.syncpt_id, params.threshold, params.timeout); + NGLOG_WARNING(Service_NVDRV, + "(STUBBED) called, syncpt_id={}, threshold={}, timeout={}, is_async={}", + params.syncpt_id, params.threshold, params.timeout, is_async); // TODO(Subv): Implement actual syncpt waiting. params.value = 0; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index aa9b5a14b..b2a5de65f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h @@ -134,7 +134,7 @@ private: u32 NvOsGetConfigU32(const std::vector& input, std::vector& output); - u32 IocCtrlEventWait(const std::vector& input, std::vector& output); + u32 IocCtrlEventWait(const std::vector& input, std::vector& output, bool is_async); }; } // namespace Service::Nvidia::Devices From 6306655665c097bc63f7fac7ffcb9907a98abebe Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 May 2018 22:39:31 -0400 Subject: [PATCH 3/5] nvhost_ctrl: Stub out IocCtrlEventRegister. --- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 8 ++++++++ src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index a2d3584e5..7872d1e09 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -19,6 +19,8 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector& input, std::vector< return IocCtrlEventWait(input, output, false); case IoctlCommand::IocCtrlEventWaitAsyncCommand: return IocCtrlEventWait(input, output, true); + case IoctlCommand::IocCtrlEventRegisterCommand: + return IocCtrlEventRegister(input, output); } UNIMPLEMENTED_MSG("Unimplemented ioctl"); return 0; @@ -61,4 +63,10 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& return 0; } +u32 nvhost_ctrl::IocCtrlEventRegister(const std::vector& input, std::vector& output) { + NGLOG_WARNING(Service_NVDRV, "(STUBBED) called"); + // TODO(bunnei): Implement this. + return 0; +} + } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index b2a5de65f..090261a60 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h @@ -135,6 +135,8 @@ private: u32 NvOsGetConfigU32(const std::vector& input, std::vector& output); u32 IocCtrlEventWait(const std::vector& input, std::vector& output, bool is_async); + + u32 IocCtrlEventRegister(const std::vector& input, std::vector& output); }; } // namespace Service::Nvidia::Devices From 68937a662dd09e67a7558e6ab21c5f31338db2a4 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 May 2018 23:10:44 -0400 Subject: [PATCH 4/5] gl_shader_decompiler: Partially implement F2F_R instruction. --- src/video_core/engines/shader_bytecode.h | 6 +++--- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index d75de85e2..198a470c0 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h @@ -456,9 +456,9 @@ private: INST("00011110--------", Id::FMUL32_IMM, Type::Arithmetic, "FMUL32_IMM"), INST("0101000010000---", Id::MUFU, Type::Arithmetic, "MUFU"), INST("0101110010010---", Id::RRO, Type::Arithmetic, "RRO"), - INST("0100110010101---", Id::F2F_C, Type::Arithmetic, "F2F_C"), - INST("0101110010101---", Id::F2F_R, Type::Arithmetic, "F2F_R"), - INST("0011100-10101---", Id::F2F_IMM, Type::Arithmetic, "F2F_IMM"), + INST("0100110010101---", Id::F2F_C, Type::Conversion, "F2F_C"), + INST("0101110010101---", Id::F2F_R, Type::Conversion, "F2F_R"), + INST("0011100-10101---", Id::F2F_IMM, Type::Conversion, "F2F_IMM"), INST("0100110010110---", Id::F2I_C, Type::Arithmetic, "F2I_C"), INST("0101110010110---", Id::F2I_R, Type::Arithmetic, "F2I_R"), INST("0011100-10110---", Id::F2I_IMM, Type::Arithmetic, "F2I_IMM"), diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 75822e750..c17bd7d2c 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -834,13 +834,14 @@ private: } case OpCode::Type::Conversion: { ASSERT_MSG(instr.conversion.size == Register::Size::Word, "Unimplemented"); - ASSERT_MSG(!instr.conversion.selector, "Unimplemented"); ASSERT_MSG(!instr.conversion.negate_a, "Unimplemented"); ASSERT_MSG(!instr.conversion.saturate_a, "Unimplemented"); switch (opcode->GetId()) { case OpCode::Id::I2I_R: case OpCode::Id::I2F_R: { + ASSERT_MSG(!instr.conversion.selector, "Unimplemented"); + std::string op_a = regs.GetRegisterAsInteger(instr.gpr20, 0, instr.conversion.is_signed); @@ -851,6 +852,10 @@ private: regs.SetRegisterToInteger(instr.gpr0, instr.conversion.is_signed, 0, op_a, 1, 1); break; } + case OpCode::Id::F2F_R: { + regs.SetRegisterToFloat(instr.gpr0, 0, regs.GetRegisterAsFloat(instr.gpr20), 1, 1); + break; + } default: { NGLOG_CRITICAL(HW_GPU, "Unhandled conversion instruction: {}", opcode->GetName()); UNREACHABLE(); From 6fcc7e9c3612cca64b3e6878046fc08b7b327292 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 29 May 2018 23:52:54 -0400 Subject: [PATCH 5/5] gl_shader_decompiler: F2F_R instruction: Implement abs. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index c17bd7d2c..70ddea643 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -853,7 +853,13 @@ private: break; } case OpCode::Id::F2F_R: { - regs.SetRegisterToFloat(instr.gpr0, 0, regs.GetRegisterAsFloat(instr.gpr20), 1, 1); + std::string op_a = regs.GetRegisterAsFloat(instr.gpr20); + + if (instr.conversion.abs_a) { + op_a = "abs(" + op_a + ')'; + } + + regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1); break; } default: {