code: Address build issues

This commit is contained in:
GPUCode
2022-11-20 12:32:35 +02:00
parent 8b8cee1a5a
commit d1039d9a81
9 changed files with 28 additions and 23 deletions

View File

@ -30,7 +30,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent)
if (checked && Settings::values.graphics_api == Settings::GraphicsAPI::Vulkan) { if (checked && Settings::values.graphics_api == Settings::GraphicsAPI::Vulkan) {
try { try {
Vulkan::Instance debug_inst{true}; Vulkan::Instance debug_inst{true};
} catch (vk::LayerNotPresentError& err) { } catch (vk::LayerNotPresentError&) {
ui->toggle_renderer_debug->toggle(); ui->toggle_renderer_debug->toggle();
QMessageBox::warning( QMessageBox::warning(
this, tr("Validation layer not available"), this, tr("Validation layer not available"),
@ -45,7 +45,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent)
if (checked && Settings::values.graphics_api == Settings::GraphicsAPI::Vulkan) { if (checked && Settings::values.graphics_api == Settings::GraphicsAPI::Vulkan) {
try { try {
Vulkan::Instance debug_inst{false, true}; Vulkan::Instance debug_inst{false, true};
} catch (vk::LayerNotPresentError& err) { } catch (vk::LayerNotPresentError&) {
ui->toggle_dump_command_buffers->toggle(); ui->toggle_dump_command_buffers->toggle();
QMessageBox::warning( QMessageBox::warning(
this, tr("Command buffer dumping not available"), this, tr("Command buffer dumping not available"),

View File

@ -60,6 +60,7 @@
#include "common/literals.h" #include "common/literals.h"
#include "common/logging/backend.h" #include "common/logging/backend.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/memory_detect.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/scm_rev.h" #include "common/scm_rev.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"

View File

@ -39,19 +39,19 @@ constexpr void DecodePixel(const std::byte* source, std::byte* dest) {
const u32 abgr = Common::swap32(rgb << 8) | 0xFF000000; const u32 abgr = Common::swap32(rgb << 8) | 0xFF000000;
std::memcpy(dest, &abgr, 4); std::memcpy(dest, &abgr, 4);
} else if constexpr (format == PixelFormat::RGB565 && converted) { } else if constexpr (format == PixelFormat::RGB565 && converted) {
const auto abgr = Color::DecodeRGB565(reinterpret_cast<const u8*>(source)); const auto abgr = Common::Color::DecodeRGB565(reinterpret_cast<const u8*>(source));
std::memcpy(dest, abgr.AsArray(), 4); std::memcpy(dest, abgr.AsArray(), 4);
} else if constexpr (format == PixelFormat::RGB5A1 && converted) { } else if constexpr (format == PixelFormat::RGB5A1 && converted) {
const auto abgr = Color::DecodeRGB5A1(reinterpret_cast<const u8*>(source)); const auto abgr = Common::Color::DecodeRGB5A1(reinterpret_cast<const u8*>(source));
std::memcpy(dest, abgr.AsArray(), 4); std::memcpy(dest, abgr.AsArray(), 4);
} else if constexpr (format == PixelFormat::RGBA4 && converted) { } else if constexpr (format == PixelFormat::RGBA4 && converted) {
const auto abgr = Color::DecodeRGBA4(reinterpret_cast<const u8*>(source)); const auto abgr = Common::Color::DecodeRGBA4(reinterpret_cast<const u8*>(source));
std::memcpy(dest, abgr.AsArray(), 4); std::memcpy(dest, abgr.AsArray(), 4);
} else if constexpr (format == PixelFormat::IA8) { } else if constexpr (format == PixelFormat::IA8) {
std::memset(dest, static_cast<int>(source[1]), 3); std::memset(dest, static_cast<int>(source[1]), 3);
dest[3] = source[0]; dest[3] = source[0];
} else if constexpr (format == PixelFormat::RG8) { } else if constexpr (format == PixelFormat::RG8) {
const auto rgba = Color::DecodeRG8(reinterpret_cast<const u8*>(source)); const auto rgba = Common::Color::DecodeRG8(reinterpret_cast<const u8*>(source));
std::memcpy(dest, rgba.AsArray(), 4); std::memcpy(dest, rgba.AsArray(), 4);
} else if constexpr (format == PixelFormat::I8) { } else if constexpr (format == PixelFormat::I8) {
std::memset(dest, static_cast<int>(source[0]), 3); std::memset(dest, static_cast<int>(source[0]), 3);
@ -61,8 +61,8 @@ constexpr void DecodePixel(const std::byte* source, std::byte* dest) {
dest[3] = source[0]; dest[3] = source[0];
} else if constexpr (format == PixelFormat::IA4) { } else if constexpr (format == PixelFormat::IA4) {
const u8 ia4 = static_cast<const u8>(source[0]); const u8 ia4 = static_cast<const u8>(source[0]);
std::memset(dest, Color::Convert4To8(ia4 >> 4), 3); std::memset(dest, Common::Color::Convert4To8(ia4 >> 4), 3);
dest[3] = std::byte{Color::Convert4To8(ia4 & 0xF)}; dest[3] = std::byte{Common::Color::Convert4To8(ia4 & 0xF)};
} else { } else {
std::memcpy(dest, source, bytes_per_pixel); std::memcpy(dest, source, bytes_per_pixel);
} }
@ -72,7 +72,7 @@ template <PixelFormat format>
constexpr void DecodePixel4(u32 x, u32 y, const std::byte* source_tile, std::byte* dest_pixel) { constexpr void DecodePixel4(u32 x, u32 y, const std::byte* source_tile, std::byte* dest_pixel) {
const u32 morton_offset = VideoCore::MortonInterleave(x, y); const u32 morton_offset = VideoCore::MortonInterleave(x, y);
const u8 value = static_cast<const u8>(source_tile[morton_offset >> 1]); const u8 value = static_cast<const u8>(source_tile[morton_offset >> 1]);
const u8 pixel = Color::Convert4To8((morton_offset % 2) ? (value >> 4) : (value & 0xF)); const u8 pixel = Common::Color::Convert4To8((morton_offset % 2) ? (value >> 4) : (value & 0xF));
if constexpr (format == PixelFormat::I4) { if constexpr (format == PixelFormat::I4) {
std::memset(dest_pixel, static_cast<int>(pixel), 3); std::memset(dest_pixel, static_cast<int>(pixel), 3);
@ -102,7 +102,7 @@ constexpr void DecodePixelETC1(u32 x, u32 y, const std::byte* source_tile, std::
std::memcpy(&packed_alpha, subtile_ptr, sizeof(u64)); std::memcpy(&packed_alpha, subtile_ptr, sizeof(u64));
subtile_ptr += sizeof(u64); subtile_ptr += sizeof(u64);
alpha = Color::Convert4To8((packed_alpha >> (4 * (x * subtile_width + y))) & 0xF); alpha = Common::Color::Convert4To8((packed_alpha >> (4 * (x * subtile_width + y))) & 0xF);
} }
const u64_le subtile_data = MakeInt<u64_le>(subtile_ptr); const u64_le subtile_data = MakeInt<u64_le>(subtile_ptr);
@ -131,15 +131,15 @@ constexpr void EncodePixel(const std::byte* source, std::byte* dest) {
} else if constexpr (format == PixelFormat::RGB565 && converted) { } else if constexpr (format == PixelFormat::RGB565 && converted) {
Common::Vec4<u8> rgba; Common::Vec4<u8> rgba;
std::memcpy(rgba.AsArray(), source, 4); std::memcpy(rgba.AsArray(), source, 4);
Color::EncodeRGB565(rgba, reinterpret_cast<u8*>(dest)); Common::Color::EncodeRGB565(rgba, reinterpret_cast<u8*>(dest));
} else if constexpr (format == PixelFormat::RGB5A1 && converted) { } else if constexpr (format == PixelFormat::RGB5A1 && converted) {
Common::Vec4<u8> rgba; Common::Vec4<u8> rgba;
std::memcpy(rgba.AsArray(), source, 4); std::memcpy(rgba.AsArray(), source, 4);
Color::EncodeRGB5A1(rgba, reinterpret_cast<u8*>(dest)); Common::Color::EncodeRGB5A1(rgba, reinterpret_cast<u8*>(dest));
} else if constexpr (format == PixelFormat::RGBA4 && converted) { } else if constexpr (format == PixelFormat::RGBA4 && converted) {
Common::Vec4<u8> rgba; Common::Vec4<u8> rgba;
std::memcpy(rgba.AsArray(), source, 4); std::memcpy(rgba.AsArray(), source, 4);
Color::EncodeRGBA4(rgba, reinterpret_cast<u8*>(dest)); Common::Color::EncodeRGBA4(rgba, reinterpret_cast<u8*>(dest));
} else { } else {
std::memcpy(dest, source, bytes_per_pixel); std::memcpy(dest, source, bytes_per_pixel);
} }

View File

@ -180,8 +180,8 @@ static std::array<float, 3 * 2> MakeOrthographicMatrix(float width, float height
return matrix; return matrix;
} }
RendererVulkan::RendererVulkan(Frontend::EmuWindow& window) RendererVulkan::RendererVulkan(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window)
: RendererBase{window}, instance{window, Settings::values.physical_device}, : RendererBase{window, secondary_window}, instance{window, Settings::values.physical_device},
scheduler{instance, renderpass_cache, *this}, scheduler{instance, renderpass_cache, *this},
renderpass_cache{instance, scheduler}, desc_manager{instance, scheduler}, renderpass_cache{instance, scheduler}, desc_manager{instance, scheduler},
runtime{instance, scheduler, renderpass_cache, desc_manager}, runtime{instance, scheduler, renderpass_cache, desc_manager},

View File

@ -63,14 +63,14 @@ class RasterizerVulkan;
class RendererVulkan : public RendererBase { class RendererVulkan : public RendererBase {
public: public:
RendererVulkan(Frontend::EmuWindow& window); explicit RendererVulkan(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window);
~RendererVulkan() override; ~RendererVulkan() override;
VideoCore::ResultStatus Init() override; VideoCore::ResultStatus Init() override;
VideoCore::RasterizerInterface* Rasterizer() override; VideoCore::RasterizerInterface* Rasterizer() override;
void ShutDown() override; void ShutDown() override;
void SwapBuffers() override; void SwapBuffers() override;
void TryPresent(int timeout_ms) override {} void TryPresent(int timeout_ms, bool is_secondary) override {}
void PrepareVideoDumping() override {} void PrepareVideoDumping() override {}
void CleanupVideoDumping() override {} void CleanupVideoDumping() override {}
void Sync() override; void Sync() override;

View File

@ -37,6 +37,10 @@ Scheduler::Scheduler(const Instance& instance, RenderpassCache& renderpass_cache
} }
Scheduler::~Scheduler() { Scheduler::~Scheduler() {
if (!use_worker_thread) {
return;
}
stop_requested = true; stop_requested = true;
// Push a dummy chunk to unblock the thread // Push a dummy chunk to unblock the thread

View File

@ -118,7 +118,7 @@ void Swapchain::Present() {
vk::Queue present_queue = instance.GetPresentQueue(); vk::Queue present_queue = instance.GetPresentQueue();
try { try {
[[maybe_unused]] vk::Result result = present_queue.presentKHR(present_info); [[maybe_unused]] vk::Result result = present_queue.presentKHR(present_info);
} catch (vk::OutOfDateKHRError& err) { } catch (vk::OutOfDateKHRError&) {
is_outdated = true; is_outdated = true;
} catch (...) { } catch (...) {
LOG_CRITICAL(Render_Vulkan, "Swapchain presentation failed"); LOG_CRITICAL(Render_Vulkan, "Swapchain presentation failed");

View File

@ -265,7 +265,7 @@ void ConvertABGRToRGBA(std::span<const std::byte> source, std::span<std::byte> d
void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) { void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) {
u32 j = 0; u32 j = 0;
for (std::size_t i = 0; i < dest.size(); i += 4) { for (std::size_t i = 0; i < dest.size(); i += 4) {
auto rgba = Color::DecodeRGBA4(reinterpret_cast<const u8*>(source.data() + j)); auto rgba = Common::Color::DecodeRGBA4(reinterpret_cast<const u8*>(source.data() + j));
std::memcpy(dest.data() + i, rgba.AsArray(), sizeof(rgba)); std::memcpy(dest.data() + i, rgba.AsArray(), sizeof(rgba));
j += 2; j += 2;
} }
@ -276,7 +276,7 @@ void ConvertRGBA8ToRGBA4(std::span<const std::byte> source, std::span<std::byte>
for (std::size_t i = 0; i < dest.size(); i += 2) { for (std::size_t i = 0; i < dest.size(); i += 2) {
Common::Vec4<u8> rgba; Common::Vec4<u8> rgba;
std::memcpy(rgba.AsArray(), source.data() + j, sizeof(rgba)); std::memcpy(rgba.AsArray(), source.data() + j, sizeof(rgba));
Color::EncodeRGBA4(rgba, reinterpret_cast<u8*>(dest.data() + i)); Common::Color::EncodeRGBA4(rgba, reinterpret_cast<u8*>(dest.data() + i));
j += 4; j += 4;
} }
} }
@ -284,7 +284,7 @@ void ConvertRGBA8ToRGBA4(std::span<const std::byte> source, std::span<std::byte>
void ConvertRGB5A1ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) { void ConvertRGB5A1ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) {
u32 j = 0; u32 j = 0;
for (std::size_t i = 0; i < dest.size(); i += 4) { for (std::size_t i = 0; i < dest.size(); i += 4) {
auto rgba = Color::DecodeRGB5A1(reinterpret_cast<const u8*>(source.data() + j)); auto rgba = Common::Color::DecodeRGB5A1(reinterpret_cast<const u8*>(source.data() + j));
std::memcpy(dest.data() + i, rgba.AsArray(), sizeof(rgba)); std::memcpy(dest.data() + i, rgba.AsArray(), sizeof(rgba));
j += 2; j += 2;
} }
@ -295,7 +295,7 @@ void ConvertRGBA8ToRGB5A1(std::span<const std::byte> source, std::span<std::byte
for (std::size_t i = 0; i < dest.size(); i += 2) { for (std::size_t i = 0; i < dest.size(); i += 2) {
Common::Vec4<u8> rgba; Common::Vec4<u8> rgba;
std::memcpy(rgba.AsArray(), source.data() + j, sizeof(rgba)); std::memcpy(rgba.AsArray(), source.data() + j, sizeof(rgba));
Color::EncodeRGB5A1(rgba, reinterpret_cast<u8*>(dest.data() + i)); Common::Color::EncodeRGB5A1(rgba, reinterpret_cast<u8*>(dest.data() + i));
j += 4; j += 4;
} }
} }

View File

@ -53,7 +53,7 @@ ResultStatus Init(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondar
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window, secondary_window); g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window, secondary_window);
break; break;
case Settings::GraphicsAPI::Vulkan: case Settings::GraphicsAPI::Vulkan:
g_renderer = std::make_unique<Vulkan::RendererVulkan>(emu_window); g_renderer = std::make_unique<Vulkan::RendererVulkan>(emu_window, secondary_window);
break; break;
default: default:
LOG_CRITICAL(Render, "Invalid graphics API enum value {}", graphics_api); LOG_CRITICAL(Render, "Invalid graphics API enum value {}", graphics_api);