mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 00:49:02 -06:00 
			
		
		
		
	TextureCache: Refactor and fix linux compiling.
This commit is contained in:
		@@ -7,6 +7,7 @@
 | 
				
			|||||||
#include <bit>
 | 
					#include <bit>
 | 
				
			||||||
#include <climits>
 | 
					#include <climits>
 | 
				
			||||||
#include <cstddef>
 | 
					#include <cstddef>
 | 
				
			||||||
 | 
					#include <type_traits>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common/common_types.h"
 | 
					#include "common/common_types.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,4 +45,10 @@ template <typename T>
 | 
				
			|||||||
    return static_cast<u32>(log2_f + static_cast<u64>((value ^ (1ULL << log2_f)) != 0ULL));
 | 
					    return static_cast<u32>(log2_f + static_cast<u64>((value ^ (1ULL << log2_f)) != 0ULL));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					requires std::is_integral_v<T>
 | 
				
			||||||
 | 
					[[nodiscard]] T NextPow2(T value) {
 | 
				
			||||||
 | 
					    return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U)));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace Common
 | 
					} // namespace Common
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <glad/glad.h>
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "common/bit_util.h"
 | 
				
			||||||
#include "common/literals.h"
 | 
					#include "common/literals.h"
 | 
				
			||||||
#include "common/settings.h"
 | 
					#include "common/settings.h"
 | 
				
			||||||
#include "video_core/renderer_opengl/gl_device.h"
 | 
					#include "video_core/renderer_opengl/gl_device.h"
 | 
				
			||||||
@@ -397,9 +398,6 @@ OGLTexture MakeImage(const VideoCommon::ImageInfo& info, GLenum gl_internal_form
 | 
				
			|||||||
    return GL_R32UI;
 | 
					    return GL_R32UI;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] u32 NextPow2(u32 value) {
 | 
					 | 
				
			||||||
    return 1U << (32U - std::countl_zero(value - 1U));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
} // Anonymous namespace
 | 
					} // Anonymous namespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ImageBufferMap::~ImageBufferMap() {
 | 
					ImageBufferMap::~ImageBufferMap() {
 | 
				
			||||||
@@ -1308,7 +1306,7 @@ void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image,
 | 
				
			|||||||
        const u32 copy_size = region.width * region.height * region.depth * img_bpp;
 | 
					        const u32 copy_size = region.width * region.height * region.depth * img_bpp;
 | 
				
			||||||
        if (pbo_size < copy_size) {
 | 
					        if (pbo_size < copy_size) {
 | 
				
			||||||
            intermediate_pbo.Create();
 | 
					            intermediate_pbo.Create();
 | 
				
			||||||
            pbo_size = NextPow2(copy_size);
 | 
					            pbo_size = Common::NextPow2(copy_size);
 | 
				
			||||||
            glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
 | 
					            glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // Copy from source to PBO
 | 
					        // Copy from source to PBO
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@
 | 
				
			|||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common/bit_cast.h"
 | 
					#include "common/bit_cast.h"
 | 
				
			||||||
 | 
					#include "common/bit_util.h"
 | 
				
			||||||
#include "common/settings.h"
 | 
					#include "common/settings.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "video_core/engines/fermi_2d.h"
 | 
					#include "video_core/engines/fermi_2d.h"
 | 
				
			||||||
@@ -775,16 +776,12 @@ bool TextureCacheRuntime::ShouldReinterpret(Image& dst, Image& src) {
 | 
				
			|||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] size_t NextPow2(size_t value) {
 | 
					 | 
				
			||||||
    return static_cast<size_t>(1ULL << ((8U * sizeof(size_t)) - std::countl_zero(value - 1U)));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) {
 | 
					VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) {
 | 
				
			||||||
    const auto level = (8 * sizeof(size_t)) - std::countl_zero(needed_size - 1ULL);
 | 
					    const auto level = (8 * sizeof(size_t)) - std::countl_zero(needed_size - 1ULL);
 | 
				
			||||||
    if (buffer_commits[level]) {
 | 
					    if (buffer_commits[level]) {
 | 
				
			||||||
        return *buffers[level];
 | 
					        return *buffers[level];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const auto new_size = 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 |
 | 
					    VkBufferUsageFlags flags = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
 | 
				
			||||||
                               VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT |
 | 
					                               VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT |
 | 
				
			||||||
                               VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
 | 
					                               VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user