Vulkan: Allow tex shaders to specify a max scale.

This commit is contained in:
Unknown W. Brackets 2021-01-28 01:03:02 -08:00
parent c99b4b118a
commit c630d365cd
4 changed files with 7 additions and 0 deletions

View file

@ -161,6 +161,7 @@ void LoadPostShaderInfo(const std::vector<std::string> &directories) {
info.section = section.name();
section.Get("Name", &info.name, section.name().c_str());
section.Get("Compute", &temp, "");
section.Get("MaxScale", &info.maxScale, 255);
info.computeShaderFile = path + "/" + temp;
appendTextureShader(info);

View file

@ -70,6 +70,7 @@ struct TextureShaderInfo {
std::string name;
std::string computeShaderFile;
int maxScale;
bool operator == (const std::string &other) {
return name == other;

View file

@ -394,6 +394,7 @@ void TextureCacheVulkan::CompileScalingShader() {
if (copyCS_ != VK_NULL_HANDLE)
vulkan_->Delete().QueueDeleteShaderModule(copyCS_);
textureShader_.clear();
maxScaleFactor_ = 255;
} else if (uploadCS_ || copyCS_) {
// No need to recreate.
return;
@ -417,6 +418,7 @@ void TextureCacheVulkan::CompileScalingShader() {
_dbg_assert_msg_(copyCS_ != VK_NULL_HANDLE, "failed to compile copy shader");
textureShader_ = g_Config.sTextureShaderName;
maxScaleFactor_ = shaderInfo->maxScale;
}
void TextureCacheVulkan::ReleaseTexture(TexCacheEntry *entry, bool delete_them) {
@ -762,6 +764,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
VkFormat dstFmt = GetDestFormat(GETextureFormat(entry->format), gstate.getClutPaletteFormat());
int scaleFactor = standardScaleFactor_;
if (scaleFactor > maxScaleFactor_)
scaleFactor = maxScaleFactor_;
// Rachet down scale factor in low-memory mode.
if (lowMemoryMode_) {

View file

@ -139,6 +139,7 @@ private:
Vulkan2D *vulkan2D_;
std::string textureShader_;
int maxScaleFactor_ = 255;
VkShaderModule uploadCS_ = VK_NULL_HANDLE;
VkShaderModule copyCS_ = VK_NULL_HANDLE;