From da8ec6bed9e371234be48cd3177867b53d905f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 1 Aug 2024 22:37:02 +0200 Subject: [PATCH] Remove unused `LoadTextureRawSub` and `CMD_TEXTURE_UPDATE` The `IGraphics::LoadTextureRawSub` function and the respective `CMD_TEXTURE_UPDATE` command are unused. Only text textures are updated after having been uploaded, but there is a separate `CMD_TEXT_TEXTURE_UPDATE` for that. --- .../client/backend/opengl/backend_opengl.cpp | 8 -------- .../client/backend/opengl/backend_opengl.h | 1 - .../client/backend/opengl/backend_opengl3.cpp | 5 ----- .../client/backend/opengl/backend_opengl3.h | 1 - .../client/backend/vulkan/backend_vulkan.cpp | 14 -------------- src/engine/client/graphics_threaded.cpp | 19 ------------------- src/engine/client/graphics_threaded.h | 18 ------------------ src/engine/graphics.h | 1 - 8 files changed, 67 deletions(-) diff --git a/src/engine/client/backend/opengl/backend_opengl.cpp b/src/engine/client/backend/opengl/backend_opengl.cpp index 2e3223871..3ca11ff59 100644 --- a/src/engine/client/backend/opengl/backend_opengl.cpp +++ b/src/engine/client/backend/opengl/backend_opengl.cpp @@ -656,11 +656,6 @@ void CCommandProcessorFragment_OpenGL::TextureUpdate(int Slot, int X, int Y, int free(pTexData); } -void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) -{ - TextureUpdate(pCommand->m_Slot, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height, GL_RGBA, pCommand->m_pData); -} - void CCommandProcessorFragment_OpenGL::DestroyTexture(int Slot) { m_pTextureMemoryUsage->store(m_pTextureMemoryUsage->load(std::memory_order_relaxed) - m_vTextures[Slot].m_MemSize, std::memory_order_relaxed); @@ -1057,9 +1052,6 @@ ERunCommandReturnTypes CCommandProcessorFragment_OpenGL::RunCommand(const CComma case CCommandBuffer::CMD_TEXTURE_DESTROY: Cmd_Texture_Destroy(static_cast(pBaseCommand)); break; - case CCommandBuffer::CMD_TEXTURE_UPDATE: - Cmd_Texture_Update(static_cast(pBaseCommand)); - break; case CCommandBuffer::CMD_TEXT_TEXTURES_CREATE: Cmd_TextTextures_Create(static_cast(pBaseCommand)); break; diff --git a/src/engine/client/backend/opengl/backend_opengl.h b/src/engine/client/backend/opengl/backend_opengl.h index c9e1f938d..f0d833cc4 100644 --- a/src/engine/client/backend/opengl/backend_opengl.h +++ b/src/engine/client/backend/opengl/backend_opengl.h @@ -89,7 +89,6 @@ protected: virtual bool Cmd_Init(const SCommand_Init *pCommand); virtual void Cmd_Shutdown(const SCommand_Shutdown *pCommand) {} - virtual void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand); virtual void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand); virtual void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand); virtual void Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand); diff --git a/src/engine/client/backend/opengl/backend_opengl3.cpp b/src/engine/client/backend/opengl/backend_opengl3.cpp index 3f4fb575a..95dbf3d36 100644 --- a/src/engine/client/backend/opengl/backend_opengl3.cpp +++ b/src/engine/client/backend/opengl/backend_opengl3.cpp @@ -505,11 +505,6 @@ void CCommandProcessorFragment_OpenGL3_3::TextureUpdate(int Slot, int X, int Y, free(pTexData); } -void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) -{ - TextureUpdate(pCommand->m_Slot, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height, GL_RGBA, pCommand->m_pData); -} - void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) { int Slot = 0; diff --git a/src/engine/client/backend/opengl/backend_opengl3.h b/src/engine/client/backend/opengl/backend_opengl3.h index 05b82a4df..7b68d813d 100644 --- a/src/engine/client/backend/opengl/backend_opengl3.h +++ b/src/engine/client/backend/opengl/backend_opengl3.h @@ -82,7 +82,6 @@ protected: bool Cmd_Init(const SCommand_Init *pCommand) override; void Cmd_Shutdown(const SCommand_Shutdown *pCommand) override; - void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) override; void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) override; void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) override; void Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand) override; diff --git a/src/engine/client/backend/vulkan/backend_vulkan.cpp b/src/engine/client/backend/vulkan/backend_vulkan.cpp index 4efcc5bd8..8c36efa4a 100644 --- a/src/engine/client/backend/vulkan/backend_vulkan.cpp +++ b/src/engine/client/backend/vulkan/backend_vulkan.cpp @@ -1263,7 +1263,6 @@ protected: { m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXTURE_CREATE)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_Texture_Create(static_cast(pBaseCommand)); }}; m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXTURE_DESTROY)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_Texture_Destroy(static_cast(pBaseCommand)); }}; - m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXTURE_UPDATE)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_Texture_Update(static_cast(pBaseCommand)); }}; m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXT_TEXTURES_CREATE)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_TextTextures_Create(static_cast(pBaseCommand)); }}; m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXT_TEXTURES_DESTROY)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_TextTextures_Destroy(static_cast(pBaseCommand)); }}; m_aCommandCallbacks[CommandBufferCMDOff(CCommandBuffer::CMD_TEXT_TEXTURE_UPDATE)] = {false, [](SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SCommand *pBaseCommand) {}, [this](const CCommandBuffer::SCommand *pBaseCommand, SRenderCommandExecuteBuffer &ExecBuffer) { return Cmd_TextTexture_Update(static_cast(pBaseCommand)); }}; @@ -6631,19 +6630,6 @@ public: return true; } - [[nodiscard]] bool Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) - { - size_t IndexTex = pCommand->m_Slot; - uint8_t *pData = pCommand->m_pData; - - if(!UpdateTexture(IndexTex, VK_FORMAT_B8G8R8A8_UNORM, pData, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height)) - return false; - - free(pData); - - return true; - } - [[nodiscard]] bool Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) { size_t ImageIndex = (size_t)pCommand->m_Slot; diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 88027a0aa..b3d4a6f28 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -337,25 +337,6 @@ static bool ConvertToRGBA(uint8_t *pDest, const CImageInfo &SrcImage) } } -int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureId, int x, int y, const CImageInfo &Image) -{ - dbg_assert(TextureId.IsValid(), "Invalid texture handle used with LoadTextureRawSub."); - - CCommandBuffer::SCommand_Texture_Update Cmd; - Cmd.m_Slot = TextureId.Id(); - Cmd.m_X = x; - Cmd.m_Y = y; - Cmd.m_Width = Image.m_Width; - Cmd.m_Height = Image.m_Height; - - uint8_t *pTmpData = static_cast(malloc(Image.m_Width * Image.m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA))); - ConvertToRGBA(pTmpData, Image); - Cmd.m_pData = pTmpData; - AddCmd(Cmd); - - return 0; -} - IGraphics::CTextureHandle CGraphics_Threaded::LoadSpriteTextureImpl(const CImageInfo &FromImageInfo, int x, int y, size_t w, size_t h, const char *pName) { m_vSpriteHelper.resize(w * h * FromImageInfo.PixelSize()); diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 17321917b..3b852b50f 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -93,7 +93,6 @@ public: // texture commands CMD_TEXTURE_CREATE, CMD_TEXTURE_DESTROY, - CMD_TEXTURE_UPDATE, CMD_TEXT_TEXTURES_CREATE, CMD_TEXT_TEXTURES_DESTROY, CMD_TEXT_TEXTURE_UPDATE, @@ -532,22 +531,6 @@ public: uint8_t *m_pData; // will be freed by the command processor }; - struct SCommand_Texture_Update : public SCommand - { - SCommand_Texture_Update() : - SCommand(CMD_TEXTURE_UPDATE) {} - - // texture information - int m_Slot; - - int m_X; - int m_Y; - size_t m_Width; - size_t m_Height; - // data must be in RGBA format - uint8_t *m_pData; // will be freed by the command processor - }; - struct SCommand_Texture_Destroy : public SCommand { SCommand_Texture_Destroy() : @@ -966,7 +949,6 @@ public: int UnloadTexture(IGraphics::CTextureHandle *pIndex) override; IGraphics::CTextureHandle LoadTextureRaw(const CImageInfo &Image, int Flags, const char *pTexName = nullptr) override; IGraphics::CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName = nullptr) override; - int LoadTextureRawSub(IGraphics::CTextureHandle TextureId, int x, int y, const CImageInfo &Image) override; bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, uint8_t *pTextData, uint8_t *pTextOutlineData) override; bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) override; diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 2bb017641..2c7c4dbfc 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -343,7 +343,6 @@ public: virtual int UnloadTexture(CTextureHandle *pIndex) = 0; virtual CTextureHandle LoadTextureRaw(const CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0; virtual CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0; - virtual int LoadTextureRawSub(CTextureHandle TextureId, int x, int y, const CImageInfo &Image) = 0; virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0; virtual void TextureSet(CTextureHandle Texture) = 0; void TextureClear() { TextureSet(CTextureHandle()); }