mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
vk_texture_cache: Add a function to ImageView to check if src image is rescaled
This commit is contained in:
parent
4a13f9eecd
commit
35d94dcb2b
|
@ -797,9 +797,9 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) {
|
||||||
return *buffers[level];
|
return *buffers[level];
|
||||||
}
|
}
|
||||||
const auto new_size = Common::NextPow2(needed_size);
|
const auto new_size = Common::NextPow2(needed_size);
|
||||||
VkBufferUsageFlags flags = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
static constexpr VkBufferUsageFlags flags =
|
||||||
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT |
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
||||||
VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
|
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
|
||||||
buffers[level] = device.GetLogical().CreateBuffer({
|
buffers[level] = device.GetLogical().CreateBuffer({
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
|
@ -1329,6 +1329,10 @@ void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferIm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::IsRescaled() const noexcept {
|
||||||
|
return True(flags & ImageFlagBits::Rescaled);
|
||||||
|
}
|
||||||
|
|
||||||
bool Image::ScaleUp(bool ignore) {
|
bool Image::ScaleUp(bool ignore) {
|
||||||
if (True(flags & ImageFlagBits::Rescaled)) {
|
if (True(flags & ImageFlagBits::Rescaled)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1469,7 +1473,8 @@ bool Image::BlitScaleHelper(bool scale_up) {
|
||||||
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
|
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
|
||||||
ImageId image_id_, Image& image)
|
ImageId image_id_, Image& image)
|
||||||
: VideoCommon::ImageViewBase{info, image.info, image_id_}, device{&runtime.device},
|
: VideoCommon::ImageViewBase{info, image.info, image_id_}, device{&runtime.device},
|
||||||
image_handle{image.Handle()}, samples{ConvertSampleCount(image.info.num_samples)} {
|
src_image{&image}, image_handle{image.Handle()},
|
||||||
|
samples(ConvertSampleCount(image.info.num_samples)) {
|
||||||
using Shader::TextureType;
|
using Shader::TextureType;
|
||||||
|
|
||||||
const VkImageAspectFlags aspect_mask = ImageViewAspectMask(info);
|
const VkImageAspectFlags aspect_mask = ImageViewAspectMask(info);
|
||||||
|
@ -1607,6 +1612,13 @@ VkImageView ImageView::StorageView(Shader::TextureType texture_type,
|
||||||
return *view;
|
return *view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImageView::IsRescaled() const noexcept {
|
||||||
|
if (!src_image) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return src_image->IsRescaled();
|
||||||
|
}
|
||||||
|
|
||||||
vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_mask) {
|
vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_mask) {
|
||||||
return device->GetLogical().CreateImageView({
|
return device->GetLogical().CreateImageView({
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
|
|
|
@ -139,6 +139,8 @@ public:
|
||||||
return std::exchange(initialized, true);
|
return std::exchange(initialized, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsRescaled() const noexcept;
|
||||||
|
|
||||||
bool ScaleUp(bool ignore = false);
|
bool ScaleUp(bool ignore = false);
|
||||||
|
|
||||||
bool ScaleDown(bool ignore = false);
|
bool ScaleDown(bool ignore = false);
|
||||||
|
@ -213,6 +215,8 @@ public:
|
||||||
return buffer_size;
|
return buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsRescaled() const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct StorageViews {
|
struct StorageViews {
|
||||||
std::array<vk::ImageView, Shader::NUM_TEXTURE_TYPES> signeds;
|
std::array<vk::ImageView, Shader::NUM_TEXTURE_TYPES> signeds;
|
||||||
|
@ -222,6 +226,8 @@ private:
|
||||||
[[nodiscard]] vk::ImageView MakeView(VkFormat vk_format, VkImageAspectFlags aspect_mask);
|
[[nodiscard]] vk::ImageView MakeView(VkFormat vk_format, VkImageAspectFlags aspect_mask);
|
||||||
|
|
||||||
const Device* device = nullptr;
|
const Device* device = nullptr;
|
||||||
|
const Image* src_image{};
|
||||||
|
|
||||||
std::array<vk::ImageView, Shader::NUM_TEXTURE_TYPES> image_views;
|
std::array<vk::ImageView, Shader::NUM_TEXTURE_TYPES> image_views;
|
||||||
std::unique_ptr<StorageViews> storage_views;
|
std::unique_ptr<StorageViews> storage_views;
|
||||||
vk::ImageView depth_view;
|
vk::ImageView depth_view;
|
||||||
|
|
Loading…
Reference in a new issue