From fb0ec551987320098995c31f5e0f1ab43b3bc907 Mon Sep 17 00:00:00 2001 From: spectranator Date: Sat, 6 Jul 2024 22:31:49 +0200 Subject: [PATCH 1/2] Note added to README about DEFINITELY incoming DMCA takedown --- README.md | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f61f9af5c0..edd27bcb15 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,41 @@ SPDX-License-Identifier: GPL-2.0-or-later It is written in C++ with portability in mind and runs on Linux and Windows +## !!! PENDING GITHUB MIRROR TAKEDOWN !!! + +I have received a takedown notice from GitHub! + +``` +Hi litucks, + +GitHub Trust & Safety is contacting you because we've received a DMCA takedown notice regarding the following content: + +https://github.com/litucks/torzu + +You can see the DMCA takedown notice that we received here, which includes the complainant's requested changes to your repository: + +https://enterprise.githubsupport.com/attachments/token/IRkbmN2s4Pu7U7fwBNZ2hXYoP/?name=2024-07-05-nintendo.rtf + +We want to make clear that it is never our desire or goal to take down open source projects, but instead to help developers address DMCA concerns with their projects. To that end, you have some options: + +1. If you choose to make changes in response to this takedown notice, you'll have 1 business day to make the requested changes. Once you've made the changes, please reply to this message and let us know. If you don't tell us that you've made changes within the next 1 business day, we'll need to disable the entire repository according to our GitHub DMCA Takedown Policy - https://docs.github.com/en/github/site-policy/dmca-takedown-policy + +If you need to remove specific content from your repository, simply making the repository private or deleting it via a commit won't resolve the alleged infringement. Instead, you must follow these instructions to remove the content from your repository's history, even if you don't think it's sensitive - https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/removing-sensitive-data-from-a-repository + +2. If you believe your content on GitHub was mistakenly identified by a DMCA takedown request, you have the right to contest the takedown by submitting a counter notice, as described in our DMCA Takedown Policy - https://docs.github.com/en/github/site-policy/dmca-takedown-policy + +We want to help ensure you can make informed decisions when responding to this takedown request. To help, we have partnered with leading legal providers who can help you evaluate the takedown request and determine how to respond at no cost to you. If you are interested in receiving legal support through this program (https://github.blog/2021-07-27-github-developer-rights-fellowship-stanford-law-school/), reply to this message to let us know that. + +It is important that you reply to this message within 1 business day regardless of which option you choose. If you do not, the repository will be disabled. + +Please let us know if you have any questions or need any help removing the content. + +Regards, +GitHub Trust & Safety +``` + +The next mirror repository is going to be at: https://codeberg.org/litucks/torzu (repo privatized until then) unless anything comes in the way. Otherwise you can use the button in the "About" menu of the emulator to get to the current mirror repository or simply check out the [main repository](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu). + ## Limited public development I feel like working publicly on this has taken away the fun. You may not understand, but it's quite stressful to have the public eye on a project. @@ -39,11 +74,6 @@ It is not all over though. My plan is to: Again, thanks to everyone who has supported my efforts so far in any way (even by creating bug reports), I really appreciate it. -## Possible pending GitHub mirror takedown - -I have received emails about takedowns on the release binaries hosted at mega (no worries I'll find another place to reupload them). -If the GitHub mirror gets taken down too, the next mirror repository is going to be at: https://codeberg.org/litucks/torzu (repo privatized until then) unless anything comes in the way. You can use the button in the "About" menu of the emulator to get to the current mirror repository or simply check out the [main repository](http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu). Please note that setting the new mirror repo to public is a manual process that could take me up to 2 days depending on how long it takes me to notice that the GitHub mirror has been taken down (specially mid-week). - ## Compatibility The emulator is capable of running most commercial games at full speed, provided you meet the [necessary hardware requirements](http://web.archive.org/web/20240130133811/https://yuzu-emu.org/help/quickstart/#hardware-requirements). From e8f43b7078d8f16bb9dc4a8682bf416c37621129 Mon Sep 17 00:00:00 2001 From: Jarrod Norwell Date: Sun, 30 Jun 2024 18:04:19 +0200 Subject: [PATCH 2/2] Added abgr8 srgb to d24s8 conversion shader --- src/video_core/host_shaders/CMakeLists.txt | 1 + .../convert_abgr8_srgb_to_d24s8.frag | 45 +++++++++++++++++++ src/video_core/renderer_vulkan/blit_image.cpp | 9 ++++ src/video_core/renderer_vulkan/blit_image.h | 5 +++ .../renderer_vulkan/vk_texture_cache.cpp | 3 ++ 5 files changed, 63 insertions(+) create mode 100644 src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 969f21d509..18c04390e6 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -18,6 +18,7 @@ set(SHADER_FILES blit_color_float.frag block_linear_unswizzle_2d.comp block_linear_unswizzle_3d.comp + convert_abgr8_srgb_to_d24s8.frag convert_abgr8_to_d24s8.frag convert_abgr8_to_d32f.frag convert_d32f_to_abgr8.frag diff --git a/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag b/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag new file mode 100644 index 0000000000..3e037af74d --- /dev/null +++ b/src/video_core/host_shaders/convert_abgr8_srgb_to_d24s8.frag @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#version 450 +#extension GL_ARB_shader_stencil_export : require + +precision highp int; +precision highp float; + +layout(binding = 0) uniform sampler2D color_texture; + +// Utility function to convert sRGB to linear space +highp float srgbToLinear(highp float srgb) { + if (srgb <= 0.04045) + return srgb / 12.92; + else + return pow((srgb + 0.055) / 1.055, 2.4); +} + +void main() { + ivec2 coord = ivec2(gl_FragCoord.xy); + + // Fetch sRGB color and convert to linear space + vec4 srgbColor = texelFetch(color_texture, coord, 0); + highp float r_linear = srgbToLinear(srgbColor.r); + highp float g_linear = srgbToLinear(srgbColor.g); + highp float b_linear = srgbToLinear(srgbColor.b); + + // Compute luminance for depth + highp float luminance = 0.2126 * r_linear + 0.7152 * g_linear + 0.0722 * b_linear; + highp uint depth_val = uint(luminance * (exp2(24.0) - 1.0)); + + // Extract the stencil value from the alpha component + highp uint stencil_val = uint(srgbColor.a * (exp2(8) - 1.0)); + + // Pack stencil and depth values into a single uint + highp uint byte0 = stencil_val << 24; + highp uint byte1 = (depth_val & 0x00FF0000u) >> 16; + highp uint byte2 = (depth_val & 0x0000FF00u) >> 8; + highp uint byte3 = depth_val & 0x000000FFu; + highp uint depth_stencil_unorm = byte0 | (byte1 << 16) | (byte2 << 8) | byte3; + + // Set depth and stencil values for the fragment + gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0); + gl_FragStencilRefARB = int(depth_stencil_unorm >> 24); +} diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index c3db09424e..23bf2b73bb 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp @@ -7,6 +7,7 @@ #include "common/settings.h" #include "video_core/host_shaders/blit_color_float_frag_spv.h" +#include "video_core/host_shaders/convert_abgr8_srgb_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" @@ -434,6 +435,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_, clear_stencil_frag(BuildShader(device, VULKAN_DEPTHSTENCIL_CLEAR_FRAG_SPV)), convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), + convert_abgr8_srgb_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_SRGB_TO_D24S8_FRAG_SPV)), convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), convert_abgr8_to_d32f_frag(BuildShader(device, CONVERT_ABGR8_TO_D32F_FRAG_SPV)), convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)), @@ -554,6 +556,13 @@ void BlitImageHelper::ConvertR16ToD16(const Framebuffer* dst_framebuffer, Convert(*convert_r16_to_d16_pipeline, dst_framebuffer, src_image_view); } +void BlitImageHelper::ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, + const ImageView& src_image_view) { + ConvertPipelineDepthTargetEx(convert_abgr8_srgb_to_d24s8_pipeline, + dst_framebuffer->RenderPass(), convert_abgr8_srgb_to_d24s8_frag); + Convert(*convert_abgr8_srgb_to_d24s8_pipeline, dst_framebuffer, src_image_view); +} + void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view) { ConvertPipelineDepthTargetEx(convert_abgr8_to_d24s8_pipeline, dst_framebuffer->RenderPass(), diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index b2104a59ee..76d384dd6f 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h @@ -67,6 +67,9 @@ public: void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); + void ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer, + const ImageView& src_image_view); + void ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); @@ -131,6 +134,7 @@ private: vk::ShaderModule clear_stencil_frag; vk::ShaderModule convert_depth_to_float_frag; vk::ShaderModule convert_float_to_depth_frag; + vk::ShaderModule convert_abgr8_srgb_to_d24s8_frag; vk::ShaderModule convert_abgr8_to_d24s8_frag; vk::ShaderModule convert_abgr8_to_d32f_frag; vk::ShaderModule convert_d32f_to_abgr8_frag; @@ -151,6 +155,7 @@ private: vk::Pipeline convert_r32_to_d32_pipeline; vk::Pipeline convert_d16_to_r16_pipeline; vk::Pipeline convert_r16_to_d16_pipeline; + vk::Pipeline convert_abgr8_srgb_to_d24s8_pipeline; vk::Pipeline convert_abgr8_to_d24s8_pipeline; vk::Pipeline convert_abgr8_to_d32f_pipeline; vk::Pipeline convert_d32f_to_abgr8_pipeline; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 1426a08702..2280f9174f 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1235,6 +1235,9 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im src_view.format == PixelFormat::B8G8R8A8_UNORM) { return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view); } + if (src_view.format == PixelFormat::A8B8G8R8_SRGB) { + return blit_image_helper.ConvertABGR8SRGBToD24S8(dst, src_view); + } break; case PixelFormat::D32_FLOAT: if (src_view.format == PixelFormat::A8B8G8R8_UNORM ||