Skip to content

Commit d240209

Browse files
committed
Revert "video_out: HDR support (shadps4-emu#2381)"
This reverts commit 8f2883a.
1 parent 5113898 commit d240209

16 files changed

+16
-186
lines changed

src/common/config.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ std::filesystem::path find_fs_path_or(const basic_value<TC>& v, const K& ky,
3131

3232
namespace Config {
3333

34-
static bool isHDRAllowed = false;
3534
static bool isNeo = false;
3635
static bool isFullscreen = false;
3736
static std::string fullscreenMode = "borderless";
@@ -102,10 +101,6 @@ static bool showBackgroundImage = true;
102101
// Language
103102
u32 m_language = 1; // english
104103

105-
bool allowHDR() {
106-
return isHDRAllowed;
107-
}
108-
109104
bool GetUseUnifiedInputConfig() {
110105
return useUnifiedInputConfig;
111106
}
@@ -656,7 +651,6 @@ void load(const std::filesystem::path& path) {
656651
if (data.contains("General")) {
657652
const toml::value& general = data.at("General");
658653

659-
isHDRAllowed = toml::find_or<bool>(general, "allowHDR", false);
660654
isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
661655
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
662656
fullscreenMode = toml::find_or<std::string>(general, "FullscreenMode", "borderless");
@@ -792,7 +786,6 @@ void save(const std::filesystem::path& path) {
792786
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
793787
}
794788

795-
data["General"]["allowHDR"] = isHDRAllowed;
796789
data["General"]["isPS4Pro"] = isNeo;
797790
data["General"]["Fullscreen"] = isFullscreen;
798791
data["General"]["FullscreenMode"] = fullscreenMode;
@@ -901,7 +894,6 @@ void saveMainWindow(const std::filesystem::path& path) {
901894
}
902895

903896
void setDefaultValues() {
904-
isHDRAllowed = false;
905897
isNeo = false;
906898
isFullscreen = false;
907899
isTrophyPopupDisabled = false;

src/common/config.h

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void SetUseUnifiedInputConfig(bool use);
5151
u32 getScreenWidth();
5252
u32 getScreenHeight();
5353
s32 getGpuId();
54-
bool allowHDR();
5554

5655
bool debugDump();
5756
bool collectShadersForDebug();

src/core/libraries/videoout/driver.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct Frame;
1818
namespace Libraries::VideoOut {
1919

2020
struct VideoOutPort {
21+
bool is_open = false;
2122
SceVideoOutResolutionStatus resolution;
2223
std::array<VideoOutBuffer, MaxDisplayBuffers> buffer_slots;
2324
std::array<u64, MaxDisplayBuffers> buffer_labels; // should be contiguous in memory
@@ -32,8 +33,6 @@ struct VideoOutPort {
3233
std::condition_variable vo_cv;
3334
std::condition_variable vblank_cv;
3435
int flip_rate = 0;
35-
bool is_open = false;
36-
bool is_mode_changing = false; // Used to prevent flip during mode change
3736

3837
s32 FindFreeGroup() const {
3938
s32 index = 0;

src/core/libraries/videoout/video_out.cpp

-54
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "common/assert.h"
55
#include "common/config.h"
6-
#include "common/elf_info.h"
76
#include "common/logging/log.h"
87
#include "core/libraries/libs.h"
98
#include "core/libraries/system/userservice.h"
@@ -316,12 +315,6 @@ s32 sceVideoOutSubmitEopFlip(s32 handle, u32 buf_id, u32 mode, u32 arg, void** u
316315
s32 PS4_SYSV_ABI sceVideoOutGetDeviceCapabilityInfo(
317316
s32 handle, SceVideoOutDeviceCapabilityInfo* pDeviceCapabilityInfo) {
318317
pDeviceCapabilityInfo->capability = 0;
319-
if (presenter->IsHDRSupported()) {
320-
auto& game_info = Common::ElfInfo::Instance();
321-
if (game_info.GetPSFAttributes().support_hdr) {
322-
pDeviceCapabilityInfo->capability |= ORBIS_VIDEO_OUT_DEVICE_CAPABILITY_BT2020_PQ;
323-
}
324-
}
325318
return ORBIS_OK;
326319
}
327320

@@ -359,49 +352,6 @@ s32 PS4_SYSV_ABI sceVideoOutAdjustColor(s32 handle, const SceVideoOutColorSettin
359352
return ORBIS_OK;
360353
}
361354

362-
struct Mode {
363-
u32 size;
364-
u8 encoding;
365-
u8 range;
366-
u8 colorimetry;
367-
u8 depth;
368-
u64 refresh_rate;
369-
u64 resolution;
370-
u8 reserved[8];
371-
};
372-
373-
void PS4_SYSV_ABI sceVideoOutModeSetAny_(Mode* mode, u32 size) {
374-
std::memset(mode, 0xff, size);
375-
mode->size = size;
376-
}
377-
378-
s32 PS4_SYSV_ABI sceVideoOutConfigureOutputMode_(s32 handle, u32 reserved, const Mode* mode,
379-
const void* options, u32 size_mode,
380-
u32 size_options) {
381-
auto* port = driver->GetPort(handle);
382-
if (!port) {
383-
return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE;
384-
}
385-
386-
if (reserved != 0) {
387-
return ORBIS_VIDEO_OUT_ERROR_INVALID_VALUE;
388-
}
389-
390-
if (mode->colorimetry != OrbisVideoOutColorimetry::Any) {
391-
auto& game_info = Common::ElfInfo::Instance();
392-
if (mode->colorimetry == OrbisVideoOutColorimetry::Bt2020PQ &&
393-
game_info.GetPSFAttributes().support_hdr) {
394-
port->is_mode_changing = true;
395-
presenter->SetHDR(true);
396-
port->is_mode_changing = false;
397-
} else {
398-
return ORBIS_VIDEO_OUT_ERROR_INVALID_VALUE;
399-
}
400-
}
401-
402-
return ORBIS_OK;
403-
}
404-
405355
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
406356
driver = std::make_unique<VideoOutDriver>(Config::getScreenWidth(), Config::getScreenHeight());
407357

@@ -440,10 +390,6 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) {
440390
sceVideoOutAdjustColor);
441391
LIB_FUNCTION("-Ozn0F1AFRg", "libSceVideoOut", 1, "libSceVideoOut", 0, 0,
442392
sceVideoOutDeleteFlipEvent);
443-
LIB_FUNCTION("pjkDsgxli6c", "libSceVideoOut", 1, "libSceVideoOut", 0, 0,
444-
sceVideoOutModeSetAny_);
445-
LIB_FUNCTION("N1bEoJ4SRw4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0,
446-
sceVideoOutConfigureOutputMode_);
447393

448394
// openOrbis appears to have libSceVideoOut_v1 module libSceVideoOut_v1.1
449395
LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutOpen);

src/core/libraries/videoout/video_out.h

-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_NONE = 0;
4040
constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_VR = 7;
4141
constexpr int SCE_VIDEO_OUT_BUFFER_ATTRIBUTE_OPTION_STRICT_COLORIMETRY = 8;
4242

43-
constexpr int ORBIS_VIDEO_OUT_DEVICE_CAPABILITY_BT2020_PQ = 0x80;
44-
45-
enum OrbisVideoOutColorimetry : u8 {
46-
Bt2020PQ = 12,
47-
Any = 0xFF,
48-
};
49-
5043
enum class OrbisVideoOutEventId : s16 {
5144
Flip = 0,
5245
Vblank = 1,

src/imgui/renderer/imgui_core.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ void OnResize() {
118118
Sdl::OnResize();
119119
}
120120

121-
void OnSurfaceFormatChange(vk::Format surface_format) {
122-
Vulkan::OnSurfaceFormatChange(surface_format);
123-
}
124-
125121
void Shutdown(const vk::Device& device) {
126122
auto result = device.waitIdle();
127123
if (result != vk::Result::eSuccess) {

src/imgui/renderer/imgui_core.h

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ void Initialize(const Vulkan::Instance& instance, const Frontend::WindowSDL& win
2222

2323
void OnResize();
2424

25-
void OnSurfaceFormatChange(vk::Format surface_format);
26-
2725
void Shutdown(const vk::Device& device);
2826

2927
bool ProcessEvent(SDL_Event* event);

src/imgui/renderer/imgui_impl_vulkan.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -1265,20 +1265,4 @@ void Shutdown() {
12651265
IM_DELETE(bd);
12661266
}
12671267

1268-
void OnSurfaceFormatChange(vk::Format surface_format) {
1269-
VkData* bd = GetBackendData();
1270-
const InitInfo& v = bd->init_info;
1271-
auto& pl_format = const_cast<vk::Format&>(
1272-
bd->init_info.pipeline_rendering_create_info.pColorAttachmentFormats[0]);
1273-
if (pl_format != surface_format) {
1274-
pl_format = surface_format;
1275-
if (bd->pipeline) {
1276-
v.device.destroyPipeline(bd->pipeline, v.allocator);
1277-
bd->pipeline = VK_NULL_HANDLE;
1278-
CreatePipeline(v.device, v.allocator, v.pipeline_cache, nullptr, &bd->pipeline,
1279-
v.subpass);
1280-
}
1281-
}
1282-
}
1283-
12841268
} // namespace ImGui::Vulkan

src/imgui/renderer/imgui_impl_vulkan.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,5 @@ void RenderDrawData(ImDrawData& draw_data, vk::CommandBuffer command_buffer,
6767
vk::Pipeline pipeline = VK_NULL_HANDLE);
6868

6969
void SetBlendEnabled(bool enabled);
70-
void OnSurfaceFormatChange(vk::Format surface_format);
7170

72-
} // namespace ImGui::Vulkan
71+
} // namespace ImGui::Vulkan

src/video_core/host_shaders/post_process.frag

+6-13
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,16 @@ layout (binding = 0) uniform sampler2D texSampler;
1010

1111
layout(push_constant) uniform settings {
1212
float gamma;
13-
bool hdr;
1413
} pp;
1514

1615
const float cutoff = 0.0031308, a = 1.055, b = 0.055, d = 12.92;
17-
vec3 gamma(vec3 rgb) {
18-
return mix(
19-
a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b,
20-
d * rgb / pp.gamma,
21-
lessThan(rgb, vec3(cutoff))
22-
);
16+
vec3 gamma(vec3 rgb)
17+
{
18+
return mix(a * pow(rgb, vec3(1.0 / (2.4 + 1.0 - pp.gamma))) - b, d * rgb / pp.gamma, lessThan(rgb, vec3(cutoff)));
2319
}
2420

25-
void main() {
21+
void main()
22+
{
2623
vec4 color_linear = texture(texSampler, uv);
27-
if (pp.hdr) {
28-
color = color_linear;
29-
} else {
30-
color = vec4(gamma(color_linear.rgb), color_linear.a);
31-
}
24+
color = vec4(gamma(color_linear.rgb), color_linear.a);
3225
}

src/video_core/renderer_vulkan/vk_platform.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ std::vector<const char*> GetInstanceExtensions(Frontend::WindowSystemType window
160160
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
161161
}
162162

163-
if (Config::allowHDR()) {
164-
extensions.push_back(VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
165-
}
166-
167163
if (enable_debug_utils) {
168164
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
169165
}

src/video_core/renderer_vulkan/vk_presenter.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ void Presenter::RecreateFrame(Frame* frame, u32 width, u32 height) {
397397
frame->height = height;
398398

399399
frame->imgui_texture = ImGui::Vulkan::AddTexture(view, vk::ImageLayout::eShaderReadOnlyOptimal);
400-
frame->is_hdr = swapchain.GetHDR();
401400
}
402401

403402
Frame* Presenter::PrepareLastFrame() {
@@ -563,8 +562,7 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
563562
if (image_id != VideoCore::NULL_IMAGE_ID) {
564563
const auto& image = texture_cache.GetImage(image_id);
565564
const auto extent = image.info.size;
566-
if (frame->width != extent.width || frame->height != extent.height ||
567-
frame->is_hdr != swapchain.GetHDR()) {
565+
if (frame->width != extent.width || frame->height != extent.height) {
568566
RecreateFrame(frame, extent.width, extent.height);
569567
}
570568
}
@@ -915,7 +913,7 @@ Frame* Presenter::GetRenderFrame() {
915913
}
916914

917915
// Initialize default frame image
918-
if (frame->width == 0 || frame->height == 0 || frame->is_hdr != swapchain.GetHDR()) {
916+
if (frame->width == 0 || frame->height == 0) {
919917
RecreateFrame(frame, 1920, 1080);
920918
}
921919

src/video_core/renderer_vulkan/vk_presenter.h

-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct Frame {
3131
vk::Fence present_done;
3232
vk::Semaphore ready_semaphore;
3333
u64 ready_tick;
34-
bool is_hdr{false};
3534

3635
ImTextureID imgui_texture;
3736
};
@@ -47,7 +46,6 @@ class Rasterizer;
4746
class Presenter {
4847
struct PostProcessSettings {
4948
float gamma = 1.0f;
50-
bool hdr = false;
5149
};
5250

5351
public:
@@ -104,18 +102,6 @@ class Presenter {
104102
return *rasterizer.get();
105103
}
106104

107-
bool IsHDRSupported() const {
108-
return swapchain.HasHDR();
109-
}
110-
111-
void SetHDR(bool enable) {
112-
if (!IsHDRSupported()) {
113-
return;
114-
}
115-
swapchain.SetHDR(enable);
116-
pp_settings.hdr = enable;
117-
}
118-
119105
private:
120106
void CreatePostProcessPipeline();
121107
Frame* PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop = true);

0 commit comments

Comments
 (0)