From cdb830f3904954ba579ee14dc10662b3e8dd16f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 10 Dec 2022 12:05:40 +0100 Subject: [PATCH] Minor optimization/cleanup --- Common/Data/Encoding/Utf8.cpp | 21 ++++++++------------- Common/GPU/Vulkan/VulkanImage.h | 2 -- Common/GPU/Vulkan/thin3d_vulkan.cpp | 4 ---- Common/Render/DrawBuffer.cpp | 4 +++- GPU/Vulkan/TextureCacheVulkan.cpp | 2 -- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Common/Data/Encoding/Utf8.cpp b/Common/Data/Encoding/Utf8.cpp index d3ddbdbc21..d30a9432a8 100644 --- a/Common/Data/Encoding/Utf8.cpp +++ b/Common/Data/Encoding/Utf8.cpp @@ -219,19 +219,14 @@ int u8_strlen(const char *s) } /* reads the next utf-8 sequence out of a string, updating an index */ -uint32_t u8_nextchar(const char *s, int *i) -{ - uint32_t ch = 0; - int sz = 0; - - do { - ch <<= 6; - ch += (unsigned char)s[(*i)++]; - sz++; - } while (s[*i] && !isutf(s[*i])); - ch -= offsetsFromUTF8[sz-1]; - - return ch; +uint32_t u8_nextchar(const char *s, int *i) { + uint32_t ch = 0; + int sz = 0; + do { + ch = (ch << 6) + (unsigned char)s[(*i)++]; + sz++; + } while (s[*i] && ((s[*i]) & 0xC0) == 0x80); + return ch - offsetsFromUTF8[sz - 1]; } uint32_t u8_nextchar_unsafe(const char *s, int *i) { diff --git a/Common/GPU/Vulkan/VulkanImage.h b/Common/GPU/Vulkan/VulkanImage.h index e4835059ed..c088fdca5b 100644 --- a/Common/GPU/Vulkan/VulkanImage.h +++ b/Common/GPU/Vulkan/VulkanImage.h @@ -38,8 +38,6 @@ public: return tag_; } - void Touch() {} - // Used in image copies, etc. VkImage GetImage() const { return image_; } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 08aed9a332..9cfcbea7c9 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -348,7 +348,6 @@ public: VkImageView GetImageView() { if (vkTex_) { - vkTex_->Touch(); return vkTex_->GetImageView(); } return VK_NULL_HANDLE; // This would be bad. @@ -356,7 +355,6 @@ public: VkImageView GetImageArrayView() { if (vkTex_) { - vkTex_->Touch(); return vkTex_->GetImageArrayView(); } return VK_NULL_HANDLE; // This would be bad. @@ -673,8 +671,6 @@ VulkanTexture *VKContext::GetNullTexture() { } nullTexture_->UploadMip(cmdInit, 0, w, h, 0, bindBuf, bindOffset, w); nullTexture_->EndCreate(cmdInit, false, VK_PIPELINE_STAGE_TRANSFER_BIT); - } else { - nullTexture_->Touch(); } return nullTexture_; } diff --git a/Common/Render/DrawBuffer.cpp b/Common/Render/DrawBuffer.cpp index 9b09e7675b..e3efb6b5d0 100644 --- a/Common/Render/DrawBuffer.cpp +++ b/Common/Render/DrawBuffer.cpp @@ -285,7 +285,9 @@ void DrawBuffer::DrawImageRotated(ImageID atlas_image, float x, float y, float s {u1, image->v2}, }; for (int i = 0; i < 6; i++) { - rot(v[i], angle, x, y); + if (angle != 0.0f) { + rot(v[i], angle, x, y); + } V(v[i][0], v[i][1], 0, color, uv[i][0], uv[i][1]); } } diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index f060b47c54..a39d7e71b0 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -404,8 +404,6 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) { return; } - entry->vkTex->Touch(); - int maxLevel = (entry->status & TexCacheEntry::STATUS_NO_MIPS) ? 0 : entry->maxLevel; SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry); curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey);