Minor optimization/cleanup

This commit is contained in:
Henrik Rydgård 2022-12-10 12:05:40 +01:00
parent 4ec1e2a175
commit cdb830f390
5 changed files with 11 additions and 22 deletions

@ -219,19 +219,14 @@ int u8_strlen(const char *s)
} }
/* reads the next utf-8 sequence out of a string, updating an index */ /* reads the next utf-8 sequence out of a string, updating an index */
uint32_t u8_nextchar(const char *s, int *i) uint32_t u8_nextchar(const char *s, int *i) {
{ uint32_t ch = 0;
uint32_t ch = 0; int sz = 0;
int sz = 0; do {
ch = (ch << 6) + (unsigned char)s[(*i)++];
do { sz++;
ch <<= 6; } while (s[*i] && ((s[*i]) & 0xC0) == 0x80);
ch += (unsigned char)s[(*i)++]; return ch - offsetsFromUTF8[sz - 1];
sz++;
} while (s[*i] && !isutf(s[*i]));
ch -= offsetsFromUTF8[sz-1];
return ch;
} }
uint32_t u8_nextchar_unsafe(const char *s, int *i) { uint32_t u8_nextchar_unsafe(const char *s, int *i) {

@ -38,8 +38,6 @@ public:
return tag_; return tag_;
} }
void Touch() {}
// Used in image copies, etc. // Used in image copies, etc.
VkImage GetImage() const { return image_; } VkImage GetImage() const { return image_; }

@ -348,7 +348,6 @@ public:
VkImageView GetImageView() { VkImageView GetImageView() {
if (vkTex_) { if (vkTex_) {
vkTex_->Touch();
return vkTex_->GetImageView(); return vkTex_->GetImageView();
} }
return VK_NULL_HANDLE; // This would be bad. return VK_NULL_HANDLE; // This would be bad.
@ -356,7 +355,6 @@ public:
VkImageView GetImageArrayView() { VkImageView GetImageArrayView() {
if (vkTex_) { if (vkTex_) {
vkTex_->Touch();
return vkTex_->GetImageArrayView(); return vkTex_->GetImageArrayView();
} }
return VK_NULL_HANDLE; // This would be bad. 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_->UploadMip(cmdInit, 0, w, h, 0, bindBuf, bindOffset, w);
nullTexture_->EndCreate(cmdInit, false, VK_PIPELINE_STAGE_TRANSFER_BIT); nullTexture_->EndCreate(cmdInit, false, VK_PIPELINE_STAGE_TRANSFER_BIT);
} else {
nullTexture_->Touch();
} }
return nullTexture_; return nullTexture_;
} }

@ -285,7 +285,9 @@ void DrawBuffer::DrawImageRotated(ImageID atlas_image, float x, float y, float s
{u1, image->v2}, {u1, image->v2},
}; };
for (int i = 0; i < 6; i++) { 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]); V(v[i][0], v[i][1], 0, color, uv[i][0], uv[i][1]);
} }
} }

@ -404,8 +404,6 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) {
return; return;
} }
entry->vkTex->Touch();
int maxLevel = (entry->status & TexCacheEntry::STATUS_NO_MIPS) ? 0 : entry->maxLevel; int maxLevel = (entry->status & TexCacheEntry::STATUS_NO_MIPS) ? 0 : entry->maxLevel;
SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry); SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry);
curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey); curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey);