FrontendCommon: Remove unnecessary #ifndef LIBRETRO macros

These were only needed because of ancient compilers on the libretro
buildbot, it still compiles fine with these fields on the latest
compilers.
This commit is contained in:
Connor McLaughlin 2020-12-27 00:11:31 +10:00
parent 702ed21207
commit dc46d52029
6 changed files with 11 additions and 130 deletions

View file

@ -8,11 +8,9 @@
#include "core/settings.h"
#include "display_ps.hlsl.h"
#include "display_vs.hlsl.h"
#include <array>
#ifndef LIBRETRO
#include "frontend-common/postprocessing_shadergen.h"
#include <array>
#include <dxgi1_5.h>
#endif
#ifdef WITH_IMGUI
#include "imgui.h"
#include "imgui_impl_dx11.h"
@ -78,9 +76,7 @@ D3D11HostDisplay::D3D11HostDisplay() = default;
D3D11HostDisplay::~D3D11HostDisplay()
{
AssertMsg(!m_context, "Context should have been destroyed by now");
#ifndef LIBRETRO
AssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now");
#endif
}
HostDisplay::RenderAPI D3D11HostDisplay::GetRenderAPI() const
@ -105,11 +101,7 @@ bool D3D11HostDisplay::HasRenderDevice() const
bool D3D11HostDisplay::HasRenderSurface() const
{
#ifndef LIBRETRO
return static_cast<bool>(m_swap_chain);
#else
return true;
#endif
}
std::unique_ptr<HostDisplayTexture> D3D11HostDisplay::CreateTexture(u32 width, u32 height, const void* initial_data,
@ -236,15 +228,12 @@ void D3D11HostDisplay::EndSetDisplayPixels()
void D3D11HostDisplay::SetVSync(bool enabled)
{
#ifndef LIBRETRO
m_vsync = enabled;
#endif
}
bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation)
{
#ifndef LIBRETRO
UINT create_flags = 0;
if (debug_device)
create_flags |= D3D11_CREATE_DEVICE_DEBUG;
@ -347,7 +336,6 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
if (SUCCEEDED(hr))
m_allow_tearing_supported = (allow_tearing_supported == TRUE);
}
#endif
m_window_info = wi;
return true;
@ -356,13 +344,11 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
bool D3D11HostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation)
{
#ifndef LIBRETRO
if (m_window_info.type != WindowInfo::Type::Surfaceless && m_window_info.type != WindowInfo::Type::Libretro &&
!CreateSwapChain(nullptr))
{
return false;
}
#endif
if (!CreateResources())
return false;
@ -398,8 +384,6 @@ bool D3D11HostDisplay::DoneRenderContextCurrent()
return true;
}
#ifndef LIBRETRO
bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode)
{
if (m_window_info.type != WindowInfo::Type::Win32)
@ -498,35 +482,25 @@ bool D3D11HostDisplay::CreateSwapChainRTV()
return true;
}
#endif
bool D3D11HostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
{
#ifndef LIBRETRO
DestroyRenderSurface();
m_window_info = new_wi;
return CreateSwapChain(nullptr);
#else
m_window_info = new_wi;
return true;
#endif
}
void D3D11HostDisplay::DestroyRenderSurface()
{
#ifndef LIBRETRO
if (IsFullscreen())
SetFullscreen(false, 0, 0, 0.0f);
m_swap_chain_rtv.Reset();
m_swap_chain.Reset();
#endif
}
void D3D11HostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_height)
{
#ifndef LIBRETRO
if (!m_swap_chain)
return;
@ -539,31 +513,21 @@ void D3D11HostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_h
if (!CreateSwapChainRTV())
Panic("Failed to recreate swap chain RTV after resize");
#endif
}
bool D3D11HostDisplay::SupportsFullscreen() const
{
#ifndef LIBRETRO
return true;
#else
return false;
#endif
}
bool D3D11HostDisplay::IsFullscreen()
{
#ifndef LIBRETRO
BOOL is_fullscreen = FALSE;
return (m_swap_chain && SUCCEEDED(m_swap_chain->GetFullscreenState(&is_fullscreen, nullptr)) && is_fullscreen);
#else
return false;
#endif
}
bool D3D11HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate)
{
#ifndef LIBRETRO
if (!m_swap_chain)
return false;
@ -622,9 +586,6 @@ bool D3D11HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, flo
}
return true;
#else
return false;
#endif
}
bool D3D11HostDisplay::CreateResources()
@ -687,11 +648,9 @@ bool D3D11HostDisplay::CreateResources()
void D3D11HostDisplay::DestroyResources()
{
#ifndef LIBRETRO
m_post_processing_chain.ClearStages();
m_post_processing_input_texture.Destroy();
m_post_processing_stages.clear();
#endif
m_display_uniform_buffer.Release();
m_linear_sampler.Reset();
@ -726,7 +685,6 @@ void D3D11HostDisplay::DestroyImGuiContext()
bool D3D11HostDisplay::Render()
{
#ifndef LIBRETRO
if (ShouldSkipDisplayingFrame())
{
#ifdef WITH_IMGUI
@ -761,8 +719,6 @@ bool D3D11HostDisplay::Render()
#ifdef WITH_IMGUI
if (ImGui::GetCurrentContext())
ImGui_ImplDX11_NewFrame();
#endif
#endif
return true;
@ -783,7 +739,6 @@ void D3D11HostDisplay::RenderDisplay()
const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight(), m_display_top_margin);
#ifndef LIBRETRO
if (!m_post_processing_chain.IsEmpty())
{
ApplyPostProcessingChain(m_swap_chain_rtv.Get(), left, top, width, height, m_display_texture_handle,
@ -791,7 +746,6 @@ void D3D11HostDisplay::RenderDisplay()
m_display_texture_view_y, m_display_texture_view_width, m_display_texture_view_height);
return;
}
#endif
RenderDisplay(left, top, width, height, m_display_texture_handle, m_display_texture_width, m_display_texture_height,
m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width,
@ -861,8 +815,6 @@ void D3D11HostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 he
m_context->Draw(3, 0);
}
#ifndef LIBRETRO
D3D11HostDisplay::AdapterInfo D3D11HostDisplay::GetAdapterInfo()
{
ComPtr<IDXGIFactory> dxgi_factory;
@ -1092,13 +1044,4 @@ void D3D11HostDisplay::ApplyPostProcessingChain(ID3D11RenderTargetView* final_ta
m_context->PSSetShaderResources(0, 1, &null_srv);
}
#else // LIBRETRO
bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config)
{
return false;
}
#endif
} // namespace FrontendCommon

View file

@ -5,6 +5,7 @@
#include "common/window_info.h"
#include "common/windows_headers.h"
#include "core/host_display.h"
#include "frontend-common/postprocessing_chain.h"
#include <d3d11.h>
#include <dxgi.h>
#include <memory>
@ -13,10 +14,6 @@
#include <vector>
#include <wrl/client.h>
#ifndef LIBRETRO
#include "frontend-common/postprocessing_chain.h"
#endif
namespace FrontendCommon {
class D3D11HostDisplay : public HostDisplay
@ -35,8 +32,10 @@ public:
virtual bool HasRenderDevice() const override;
virtual bool HasRenderSurface() const override;
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device, bool threaded_presentation) override;
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool threaded_presentation) override;
virtual bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
bool threaded_presentation) override;
virtual bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation) override;
virtual void DestroyRenderDevice() override;
virtual bool MakeRenderContextCurrent() override;
@ -66,21 +65,17 @@ public:
virtual bool Render() override;
#ifndef LIBRETRO
struct AdapterInfo
{
std::vector<std::string> adapter_names;
std::vector<std::string> fullscreen_modes;
};
static AdapterInfo GetAdapterInfo();
#endif
protected:
static constexpr u32 DISPLAY_UNIFORM_BUFFER_SIZE = 16;
#ifndef LIBRETRO
static AdapterInfo GetAdapterInfo(IDXGIFactory* dxgi_factory);
#endif
virtual bool CreateResources() override;
virtual void DestroyResources() override;
@ -88,10 +83,8 @@ protected:
virtual bool CreateImGuiContext();
virtual void DestroyImGuiContext();
#ifndef LIBRETRO
bool CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode);
bool CreateSwapChainRTV();
#endif
void RenderDisplay();
void RenderSoftwareCursor();
@ -102,7 +95,6 @@ protected:
s32 texture_view_height, bool linear_filter);
void RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 height, HostDisplayTexture* texture_handle);
#ifndef LIBRETRO
struct PostProcessingStage
{
ComPtr<ID3D11VertexShader> vertex_shader;
@ -116,16 +108,13 @@ protected:
s32 final_height, void* texture_handle, u32 texture_width, s32 texture_height,
s32 texture_view_x, s32 texture_view_y, s32 texture_view_width,
s32 texture_view_height);
#endif
ComPtr<ID3D11Device> m_device;
ComPtr<ID3D11DeviceContext> m_context;
#ifndef LIBRETRO
ComPtr<IDXGIFactory> m_dxgi_factory;
ComPtr<IDXGISwapChain> m_swap_chain;
ComPtr<ID3D11RenderTargetView> m_swap_chain_rtv;
#endif
ComPtr<ID3D11RasterizerState> m_display_rasterizer_state;
ComPtr<ID3D11DepthStencilState> m_display_depth_stencil_state;
@ -140,7 +129,6 @@ protected:
D3D11::StreamBuffer m_display_uniform_buffer;
D3D11::AutoStagingTexture m_readback_staging_texture;
#ifndef LIBRETRO
bool m_allow_tearing_supported = false;
bool m_using_flip_model_swap_chain = true;
bool m_using_allow_tearing = false;
@ -149,7 +137,6 @@ protected:
PostProcessingChain m_post_processing_chain;
D3D11::Texture m_post_processing_input_texture;
std::vector<PostProcessingStage> m_post_processing_stages;
#endif
};
} // namespace FrontendCommon

View file

@ -8,9 +8,7 @@
#include "imgui.h"
#include "imgui_impl_opengl3.h"
#endif
#ifndef LIBRETRO
#include "postprocessing_shadergen.h"
#endif
Log_SetChannel(LibretroOpenGLHostDisplay);
namespace FrontendCommon {
@ -639,12 +637,10 @@ void main()
void OpenGLHostDisplay::DestroyResources()
{
#ifndef LIBRETRO
m_post_processing_chain.ClearStages();
m_post_processing_input_texture.Destroy();
m_post_processing_ubo.reset();
m_post_processing_stages.clear();
#endif
if (m_display_pixels_texture_id != 0)
{
@ -727,7 +723,6 @@ void OpenGLHostDisplay::RenderDisplay()
const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight(), m_display_top_margin);
#ifndef LIBRETRO
if (!m_post_processing_chain.IsEmpty())
{
ApplyPostProcessingChain(0, left, GetWindowHeight() - top - height, width, height, m_display_texture_handle,
@ -735,7 +730,6 @@ void OpenGLHostDisplay::RenderDisplay()
m_display_texture_view_y, m_display_texture_view_width, m_display_texture_view_height);
return;
}
#endif
RenderDisplay(left, GetWindowHeight() - top - height, width, height, m_display_texture_handle,
m_display_texture_width, m_display_texture_height, m_display_texture_view_x, m_display_texture_view_y,
@ -836,8 +830,6 @@ void OpenGLHostDisplay::RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s3
}
}
#ifndef LIBRETRO
bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config)
{
if (config.empty())
@ -1006,13 +998,4 @@ void OpenGLHostDisplay::ApplyPostProcessingChain(GLuint final_target, s32 final_
m_post_processing_ubo->Unbind();
}
#else
bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config)
{
return false;
}
#endif
} // namespace FrontendCommon

View file

@ -14,11 +14,8 @@
#include "common/gl/texture.h"
#include "common/window_info.h"
#include "core/host_display.h"
#include <memory>
#ifndef LIBRETRO
#include "postprocessing_chain.h"
#endif
#include <memory>
namespace FrontendCommon {
@ -86,7 +83,6 @@ protected:
s32 texture_view_height, bool linear_filter);
void RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s32 height, HostDisplayTexture* texture_handle);
#ifndef LIBRETRO
struct PostProcessingStage
{
GL::Program program;
@ -98,7 +94,6 @@ protected:
void ApplyPostProcessingChain(GLuint final_target, s32 final_left, s32 final_top, s32 final_width, s32 final_height,
void* texture_handle, u32 texture_width, s32 texture_height, s32 texture_view_x,
s32 texture_view_y, s32 texture_view_width, s32 texture_view_height);
#endif
std::unique_ptr<GL::Context> m_gl_context;
@ -114,12 +109,10 @@ protected:
u32 m_display_pixels_texture_pbo_map_offset = 0;
u32 m_display_pixels_texture_pbo_map_size = 0;
#ifndef LIBRETRO
PostProcessingChain m_post_processing_chain;
GL::Texture m_post_processing_input_texture;
std::unique_ptr<GL::StreamBuffer> m_post_processing_ubo;
std::vector<PostProcessingStage> m_post_processing_stages;
#endif
bool m_use_gles2_draw_path = false;
};

View file

@ -9,14 +9,12 @@
#include "common/vulkan/stream_buffer.h"
#include "common/vulkan/swap_chain.h"
#include "common/vulkan/util.h"
#include "postprocessing_shadergen.h"
#include <array>
#ifdef WITH_IMGUI
#include "imgui.h"
#include "imgui_impl_vulkan.h"
#endif
#ifndef LIBRETRO
#include "postprocessing_shadergen.h"
#endif
Log_SetChannel(VulkanHostDisplay);
namespace FrontendCommon {
@ -330,7 +328,8 @@ bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
return true;
}
bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device, bool threaded_presentation)
bool VulkanHostDisplay::InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
bool threaded_presentation)
{
Vulkan::ShaderCache::Create(shader_cache_directory, debug_device);
@ -424,8 +423,6 @@ void main()
if (m_pipeline_layout == VK_NULL_HANDLE)
return false;
#ifndef LIBRETRO
dslbuilder.AddBinding(1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT);
m_post_process_descriptor_set_layout = dslbuilder.Create(device);
if (m_post_process_descriptor_set_layout == VK_NULL_HANDLE)
@ -450,8 +447,6 @@ void main()
if (m_post_process_ubo_pipeline_layout == VK_NULL_HANDLE)
return false;
#endif
VkShaderModule vertex_shader = g_vulkan_shader_cache->GetVertexShader(fullscreen_quad_vertex_shader);
if (vertex_shader == VK_NULL_HANDLE)
return false;
@ -684,7 +679,6 @@ void VulkanHostDisplay::RenderDisplay()
const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight(), m_display_top_margin);
#ifndef LIBRETRO
if (!m_post_processing_chain.IsEmpty())
{
ApplyPostProcessingChain(left, top, width, height, m_display_texture_handle, m_display_texture_width,
@ -692,7 +686,6 @@ void VulkanHostDisplay::RenderDisplay()
m_display_texture_view_width, m_display_texture_view_height);
return;
}
#endif
BeginSwapChainRenderPass(m_swap_chain->GetCurrentFramebuffer());
RenderDisplay(left, top, width, height, m_display_texture_handle, m_display_texture_width, m_display_texture_height,
@ -798,8 +791,6 @@ std::vector<std::string> VulkanHostDisplay::EnumerateAdapterNames()
return {};
}
#ifndef LIBRETRO
VulkanHostDisplay::PostProcessingStage::PostProcessingStage(PostProcessingStage&& move)
: pipeline(move.pipeline), output_framebuffer(move.output_framebuffer),
output_texture(std::move(move.output_texture)), uniforms_size(move.uniforms_size)
@ -1058,13 +1049,4 @@ void VulkanHostDisplay::ApplyPostProcessingChain(s32 final_left, s32 final_top,
}
}
#else // LIBRETRO
bool VulkanHostDisplay::SetPostProcessingChain(const std::string_view& config)
{
return false;
}
#endif
} // namespace FrontendCommon

View file

@ -4,6 +4,7 @@
#include "common/vulkan/swap_chain.h"
#include "common/window_info.h"
#include "core/host_display.h"
#include "postprocessing_chain.h"
#include "vulkan_loader.h"
#include <memory>
#include <string_view>
@ -13,10 +14,6 @@ class StreamBuffer;
class SwapChain;
} // namespace Vulkan
#ifndef LIBRETRO
#include "postprocessing_chain.h"
#endif
namespace FrontendCommon {
class VulkanHostDisplay : public HostDisplay
@ -77,7 +74,6 @@ protected:
float src_rect_height;
};
#ifndef LIBRETRO
struct PostProcessingStage
{
PostProcessingStage() = default;
@ -94,7 +90,6 @@ protected:
void ApplyPostProcessingChain(s32 final_left, s32 final_top, s32 final_width, s32 final_height, void* texture_handle,
u32 texture_width, s32 texture_height, s32 texture_view_x, s32 texture_view_y,
s32 texture_view_width, s32 texture_view_height);
#endif
// Can be overridden by frontends.
virtual VkRenderPass GetRenderPassForDisplay() const;
@ -128,7 +123,6 @@ protected:
Vulkan::StagingTexture m_upload_staging_texture;
Vulkan::StagingTexture m_readback_staging_texture;
#ifndef LIBRETRO
VkDescriptorSetLayout m_post_process_descriptor_set_layout = VK_NULL_HANDLE;
VkDescriptorSetLayout m_post_process_ubo_descriptor_set_layout = VK_NULL_HANDLE;
VkPipelineLayout m_post_process_pipeline_layout = VK_NULL_HANDLE;
@ -139,7 +133,6 @@ protected:
VkFramebuffer m_post_processing_input_framebuffer = VK_NULL_HANDLE;
Vulkan::StreamBuffer m_post_processing_ubo;
std::vector<PostProcessingStage> m_post_processing_stages;
#endif
};
} // namespace FrontendCommon