mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 19:38:37 +02:00
[vk] remove unused vk_texture_manager.cpp and unused shader conversions (#3432)
- Trivial dead code removal, also these shaders are useless TODO: maybe in a future do YUV280 or whatever in shader for vic :) Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3432 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: DraVee <dravee@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
84fdbbaaa1
commit
acf7deea95
14 changed files with 7 additions and 600 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
|
|
@ -31,15 +31,6 @@
|
|||
#include "video_core/surface.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
#include "video_core/host_shaders/convert_abgr8_srgb_to_d24s8_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_rgba8_to_bgra8_frag_spv.h"
|
||||
#include "video_core/host_shaders/convert_yuv420_to_rgb_comp_spv.h"
|
||||
#include "video_core/host_shaders/convert_rgb_to_yuv420_comp_spv.h"
|
||||
#include "video_core/host_shaders/convert_bc7_to_rgba8_comp_spv.h"
|
||||
#include "video_core/host_shaders/convert_astc_hdr_to_rgba16f_comp_spv.h"
|
||||
#include "video_core/host_shaders/convert_rgba16f_to_rgba8_frag_spv.h"
|
||||
#include "video_core/host_shaders/dither_temporal_frag_spv.h"
|
||||
#include "video_core/host_shaders/dynamic_resolution_scale_comp_spv.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
|
|
@ -540,17 +531,6 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_,
|
|||
convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)),
|
||||
convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)),
|
||||
convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)),
|
||||
convert_abgr8_srgb_to_d24s8_frag(device.IsExtShaderStencilExportSupported()
|
||||
? BuildShader(device, CONVERT_ABGR8_SRGB_TO_D24S8_FRAG_SPV)
|
||||
: vk::ShaderModule{}),
|
||||
convert_rgba_to_bgra_frag(BuildShader(device, CONVERT_RGBA8_TO_BGRA8_FRAG_SPV)),
|
||||
convert_yuv420_to_rgb_comp(BuildShader(device, CONVERT_YUV420_TO_RGB_COMP_SPV)),
|
||||
convert_rgb_to_yuv420_comp(BuildShader(device, CONVERT_RGB_TO_YUV420_COMP_SPV)),
|
||||
convert_bc7_to_rgba8_comp(BuildShader(device, CONVERT_BC7_TO_RGBA8_COMP_SPV)),
|
||||
convert_astc_hdr_to_rgba16f_comp(BuildShader(device, CONVERT_ASTC_HDR_TO_RGBA16F_COMP_SPV)),
|
||||
convert_rgba16f_to_rgba8_frag(BuildShader(device, CONVERT_RGBA16F_TO_RGBA8_FRAG_SPV)),
|
||||
dither_temporal_frag(BuildShader(device, DITHER_TEMPORAL_FRAG_SPV)),
|
||||
dynamic_resolution_scale_comp(BuildShader(device, DYNAMIC_RESOLUTION_SCALE_COMP_SPV)),
|
||||
linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)),
|
||||
nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) {}
|
||||
|
||||
|
|
@ -711,19 +691,6 @@ void BlitImageHelper::ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer,
|
|||
ConvertDepthStencil(*convert_s8d24_to_abgr8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertABGR8SRGBToD24S8(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
if (!device.IsExtShaderStencilExportSupported()) {
|
||||
// Shader requires VK_EXT_shader_stencil_export which is not available
|
||||
LOG_WARNING(Render_Vulkan, "ConvertABGR8SRGBToD24S8 requires shader_stencil_export, skipping");
|
||||
return;
|
||||
}
|
||||
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::ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask,
|
||||
const std::array<f32, 4>& clear_color,
|
||||
const Region2D& dst_region) {
|
||||
|
|
@ -1192,68 +1159,4 @@ void BlitImageHelper::ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass rende
|
|||
});
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertRGBAtoGBRA(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_rgba_to_bgra_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_rgba_to_bgra_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertYUV420toRGB(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_yuv420_to_rgb_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_yuv420_to_rgb_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertRGBtoYUV420(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_rgb_to_yuv420_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_rgb_to_yuv420_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertBC7toRGBA8(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_bc7_to_rgba8_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_bc7_to_rgba8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertASTCHDRtoRGBA16F(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_astc_hdr_to_rgba16f_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_astc_hdr_to_rgba16f_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ConvertRGBA16FtoRGBA8(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(convert_rgba16f_to_rgba8_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*convert_rgba16f_to_rgba8_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ApplyDitherTemporal(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(dither_temporal_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*dither_temporal_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
void BlitImageHelper::ApplyDynamicResolutionScale(const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view) {
|
||||
ConvertPipeline(dynamic_resolution_scale_pipeline,
|
||||
dst_framebuffer->RenderPass(),
|
||||
false);
|
||||
Convert(*dynamic_resolution_scale_pipeline, dst_framebuffer, src_image_view);
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
|
|
@ -70,8 +70,6 @@ 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);
|
||||
|
|
@ -86,16 +84,6 @@ public:
|
|||
void ClearDepthStencil(const Framebuffer* dst_framebuffer, bool depth_clear, f32 clear_depth,
|
||||
u8 stencil_mask, u32 stencil_ref, u32 stencil_compare_mask,
|
||||
const Region2D& dst_region);
|
||||
|
||||
void ConvertRGBAtoGBRA(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ConvertYUV420toRGB(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ConvertRGBtoYUV420(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ConvertBC7toRGBA8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ConvertASTCHDRtoRGBA16F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ConvertRGBA16FtoRGBA8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ApplyDitherTemporal(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
void ApplyDynamicResolutionScale(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
||||
|
||||
private:
|
||||
void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
|
||||
const ImageView& src_image_view);
|
||||
|
|
@ -150,15 +138,6 @@ private:
|
|||
vk::ShaderModule convert_d32f_to_abgr8_frag;
|
||||
vk::ShaderModule convert_d24s8_to_abgr8_frag;
|
||||
vk::ShaderModule convert_s8d24_to_abgr8_frag;
|
||||
vk::ShaderModule convert_abgr8_srgb_to_d24s8_frag;
|
||||
vk::ShaderModule convert_rgba_to_bgra_frag;
|
||||
vk::ShaderModule convert_yuv420_to_rgb_comp;
|
||||
vk::ShaderModule convert_rgb_to_yuv420_comp;
|
||||
vk::ShaderModule convert_bc7_to_rgba8_comp;
|
||||
vk::ShaderModule convert_astc_hdr_to_rgba16f_comp;
|
||||
vk::ShaderModule convert_rgba16f_to_rgba8_frag;
|
||||
vk::ShaderModule dither_temporal_frag;
|
||||
vk::ShaderModule dynamic_resolution_scale_comp;
|
||||
vk::Sampler linear_sampler;
|
||||
vk::Sampler nearest_sampler;
|
||||
|
||||
|
|
@ -179,15 +158,6 @@ private:
|
|||
vk::Pipeline convert_d32f_to_abgr8_pipeline;
|
||||
vk::Pipeline convert_d24s8_to_abgr8_pipeline;
|
||||
vk::Pipeline convert_s8d24_to_abgr8_pipeline;
|
||||
vk::Pipeline convert_abgr8_srgb_to_d24s8_pipeline;
|
||||
vk::Pipeline convert_rgba_to_bgra_pipeline;
|
||||
vk::Pipeline convert_yuv420_to_rgb_pipeline;
|
||||
vk::Pipeline convert_rgb_to_yuv420_pipeline;
|
||||
vk::Pipeline convert_bc7_to_rgba8_pipeline;
|
||||
vk::Pipeline convert_astc_hdr_to_rgba16f_pipeline;
|
||||
vk::Pipeline convert_rgba16f_to_rgba8_pipeline;
|
||||
vk::Pipeline dither_temporal_pipeline;
|
||||
vk::Pipeline dynamic_resolution_scale_pipeline;
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
|
|
|||
|
|
@ -1254,25 +1254,13 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
|
|||
|
||||
switch (dst_view.format) {
|
||||
case PixelFormat::D24_UNORM_S8_UINT:
|
||||
// Handle sRGB source formats
|
||||
if (src_view.format == PixelFormat::A8B8G8R8_SRGB ||
|
||||
src_view.format == PixelFormat::B8G8R8A8_SRGB) {
|
||||
// Verify format support before conversion
|
||||
if (device.IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
FormatType::Optimal)) {
|
||||
return blit_image_helper.ConvertABGR8SRGBToD24S8(dst, src_view);
|
||||
} else {
|
||||
// Fallback to regular ABGR8 conversion if sRGB not supported
|
||||
return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view);
|
||||
}
|
||||
}
|
||||
if (src_view.format == PixelFormat::A8B8G8R8_UNORM ||
|
||||
src_view.format == PixelFormat::B8G8R8A8_UNORM) {
|
||||
if (src_view.format == PixelFormat::A8B8G8R8_UNORM
|
||||
|| src_view.format == PixelFormat::B8G8R8A8_UNORM
|
||||
|| src_view.format == PixelFormat::A8B8G8R8_SRGB
|
||||
|| src_view.format == PixelFormat::B8G8R8A8_SRGB) {
|
||||
return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view);
|
||||
}
|
||||
break;
|
||||
|
||||
case PixelFormat::A8B8G8R8_UNORM:
|
||||
case PixelFormat::A8B8G8R8_SNORM:
|
||||
case PixelFormat::A8B8G8R8_SINT:
|
||||
|
|
|
|||
|
|
@ -1,144 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "video_core/renderer_vulkan/vk_texture_manager.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
TextureManager::TextureManager(const Device& device_, MemoryAllocator& memory_allocator_)
|
||||
: device(device_), memory_allocator(memory_allocator_) {
|
||||
|
||||
// Create a default texture for fallback in case of errors
|
||||
default_texture = CreateDefaultTexture();
|
||||
}
|
||||
|
||||
TextureManager::~TextureManager() {
|
||||
std::lock_guard<std::mutex> lock(texture_mutex);
|
||||
// Clear all cached textures
|
||||
texture_cache.clear();
|
||||
|
||||
// Default texture will be cleaned up automatically by vk::Image's destructor
|
||||
}
|
||||
|
||||
VkImage TextureManager::GetTexture(const std::string& texture_path) {
|
||||
std::lock_guard<std::mutex> lock(texture_mutex);
|
||||
|
||||
// Check if the texture is already in the cache
|
||||
auto it = texture_cache.find(texture_path);
|
||||
if (it != texture_cache.end()) {
|
||||
return *it->second;
|
||||
}
|
||||
|
||||
// Load the texture and add it to the cache
|
||||
vk::Image new_texture = LoadTexture(texture_path);
|
||||
if (new_texture) {
|
||||
VkImage raw_handle = *new_texture;
|
||||
texture_cache.emplace(texture_path, std::move(new_texture));
|
||||
return raw_handle;
|
||||
}
|
||||
|
||||
// If loading fails, return the default texture if it exists
|
||||
LOG_WARNING(Render_Vulkan, "Failed to load texture: {}, using default", texture_path);
|
||||
if (default_texture.has_value()) {
|
||||
return *(*default_texture);
|
||||
}
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void TextureManager::ReloadTexture(const std::string& texture_path) {
|
||||
std::lock_guard<std::mutex> lock(texture_mutex);
|
||||
|
||||
// Remove the texture from cache if it exists
|
||||
auto it = texture_cache.find(texture_path);
|
||||
if (it != texture_cache.end()) {
|
||||
LOG_INFO(Render_Vulkan, "Reloading texture: {}", texture_path);
|
||||
texture_cache.erase(it);
|
||||
}
|
||||
|
||||
// The texture will be reloaded on next GetTexture call
|
||||
}
|
||||
|
||||
bool TextureManager::IsTextureLoadedCorrectly(VkImage texture) {
|
||||
// Check if the texture handle is valid
|
||||
static const VkImage null_handle = VK_NULL_HANDLE;
|
||||
return texture != null_handle;
|
||||
}
|
||||
|
||||
void TextureManager::CleanupTextureCache() {
|
||||
std::lock_guard<std::mutex> lock(texture_mutex);
|
||||
|
||||
// TODO: track usage and remove unused textures [ZEP]
|
||||
|
||||
LOG_INFO(Render_Vulkan, "Handling texture cache cleanup, current size: {}", texture_cache.size());
|
||||
}
|
||||
|
||||
void TextureManager::HandleTextureRendering(const std::string& texture_path,
|
||||
std::function<void(VkImage)> render_callback) {
|
||||
VkImage texture = GetTexture(texture_path);
|
||||
|
||||
if (!IsTextureLoadedCorrectly(texture)) {
|
||||
LOG_ERROR(Render_Vulkan, "Texture failed to load correctly: {}, attempting reload", texture_path);
|
||||
ReloadTexture(texture_path);
|
||||
texture = GetTexture(texture_path);
|
||||
}
|
||||
|
||||
// Execute the rendering callback with the texture
|
||||
render_callback(texture);
|
||||
}
|
||||
|
||||
vk::Image TextureManager::LoadTexture(const std::string& texture_path) {
|
||||
// TODO: load image data from disk
|
||||
// and create a proper Vulkan texture [ZEP]
|
||||
|
||||
if (!std::filesystem::exists(texture_path)) {
|
||||
LOG_ERROR(Render_Vulkan, "Texture file not found: {}", texture_path);
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
LOG_INFO(Render_Vulkan, "Loaded texture: {}", texture_path);
|
||||
|
||||
// TODO: create an actual VkImage [ZEP]
|
||||
return CreateDefaultTexture();
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR(Render_Vulkan, "Error loading texture {}: {}", texture_path, e.what());
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
vk::Image TextureManager::CreateDefaultTexture() {
|
||||
// Create a small default texture (1x1 pixel) to use as a fallback
|
||||
// const VkExtent2D extent{1, 1};
|
||||
|
||||
/* // Create image
|
||||
const VkImageCreateInfo image_ci{
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = texture_format,
|
||||
.extent = {extent.width, extent.height, 1},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||
.queueFamilyIndexCount = 0,
|
||||
.pQueueFamilyIndices = nullptr,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
}; */
|
||||
|
||||
// TODO: create an actual VkImage [ZEP]
|
||||
LOG_INFO(Render_Vulkan, "Created default fallback texture");
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
Loading…
Add table
Add a link
Reference in a new issue