From 26d4d0c87deeae3b729ae1fbc99febab6fc9607f Mon Sep 17 00:00:00 2001 From: turanszkij Date: Sat, 10 Nov 2018 20:19:56 +0000 Subject: [PATCH] font renderer update part 2 - cleanup + fixes --- WickedEngine/wiFont.cpp | 20 +++++++++----------- WickedEngine/wiGraphicsDevice.cpp | 1 + WickedEngine/wiVersion.cpp | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index 229bd0180..2f327533f 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -45,10 +45,11 @@ namespace wiFont_Internal Texture2D* texture = nullptr; + // These won't be thread safe by the way! unordered_map rects; - inline int64_t glyphhash(int code, int style) { return (int64_t(code) << 32) | int64_t(style); } - inline int codefromhash(int64_t hash) { return int((hash >> 32) & 0xFFFFFFFF); } - inline int stylefromhash(int64_t hash) { return int(hash & 0xFFFFFFFF); } + constexpr int64_t glyphhash(int code, int style) { return (int64_t(code) << 32) | int64_t(style); } + constexpr int codefromhash(int64_t hash) { return int((hash >> 32) & 0xFFFFFFFF); } + constexpr int stylefromhash(int64_t hash) { return int(hash & 0xFFFFFFFF); } unordered_set pendingGlyphs; struct wiFontStyle @@ -116,9 +117,6 @@ namespace wiFont_Internal const int16_t lineHeight = (props.size < 0 ? uint16_t(fontStyle.lineHeight) : uint16_t(props.size)); const float relativeSize = (props.size < 0 ? 1 : (float)props.size / (float)fontStyle.lineHeight); - const HALF hzero = XMConvertFloatToHalf(0.0f); - const HALF hone = XMConvertFloatToHalf(1.0f); - int16_t line = 0; int16_t pos = 0; for (size_t i = 0; i < text.length(); ++i) @@ -389,8 +387,8 @@ void wiFont::BindPersistentState(GRAPHICSTHREAD threadID) { for (int64_t hash : pendingGlyphs) { - int code = codefromhash(hash); - int style = stylefromhash(hash); + const int code = codefromhash(hash); + const int style = stylefromhash(hash); wiFontStyle& fontStyle = *fontStyles[style]; // get bounding box for character (may be offset to account for chars that dip above or below the line @@ -433,9 +431,9 @@ void wiFont::BindPersistentState(GRAPHICSTHREAD threadID) for (auto it : rects) { - int64_t hash = it.first; - wchar_t code = codefromhash(hash); - int style = stylefromhash(hash); + const int64_t hash = it.first; + const wchar_t code = codefromhash(hash); + const int style = stylefromhash(hash); wiFontStyle& fontStyle = *fontStyles[style]; rect_xywhf& rect = it.second; diff --git a/WickedEngine/wiGraphicsDevice.cpp b/WickedEngine/wiGraphicsDevice.cpp index 5f34d6408..d5b09f3e8 100644 --- a/WickedEngine/wiGraphicsDevice.cpp +++ b/WickedEngine/wiGraphicsDevice.cpp @@ -40,6 +40,7 @@ uint32_t GraphicsDevice::GetFormatStride(FORMAT value) const case FORMAT_R11G11B10_FLOAT: case FORMAT_R16G16_FLOAT: case FORMAT_R16G16_UINT: + case FORMAT_R16G16_SINT: case FORMAT_R32_FLOAT: case FORMAT_R32_UINT: case FORMAT_R8G8B8A8_UINT: diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 6fee1a6be..0f7271f2a 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 22; // minor bug fixes, alterations, refactors, updates - const int revision = 10; + const int revision = 11; long GetVersion()