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 c4fe1bf8a..5122ba1db 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -288,17 +288,16 @@ void CGraphics_Threaded::FreeTextureIndex(CTextureHandle *pIndex) pIndex->Invalidate(); } -int CGraphics_Threaded::UnloadTexture(CTextureHandle *pIndex) +void CGraphics_Threaded::UnloadTexture(CTextureHandle *pIndex) { if(pIndex->IsNullTexture() || !pIndex->IsValid()) - return 0; + return; CCommandBuffer::SCommand_Texture_Destroy Cmd; Cmd.m_Slot = pIndex->Id(); AddCmd(Cmd); FreeTextureIndex(pIndex); - return 0; } static bool ConvertToRGBA(uint8_t *pDest, const CImageInfo &SrcImage) @@ -337,25 +336,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()); @@ -434,8 +414,6 @@ static CCommandBuffer::SCommand_Texture_Create LoadTextureCreateCommand(int Text Cmd.m_Height = Height; Cmd.m_Flags = 0; - if(Flags & IGraphics::TEXLOAD_NOMIPMAPS) - Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS; if((Flags & IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE) != 0) Cmd.m_Flags |= CCommandBuffer::TEXFLAG_TO_2D_ARRAY_TEXTURE; if((Flags & IGraphics::TEXLOAD_TO_3D_TEXTURE) != 0) @@ -514,11 +492,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename, return m_NullTexture; } -IGraphics::CTextureHandle CGraphics_Threaded::NullTexture() const -{ - return m_NullTexture; -} - bool CGraphics_Threaded::LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, uint8_t *pTextData, uint8_t *pTextOutlineData) { if(Width == 0 || Height == 0) diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 156e9d6d5..dd1d4ce65 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() : @@ -963,11 +946,9 @@ public: IGraphics::CTextureHandle FindFreeTextureIndex(); void FreeTextureIndex(CTextureHandle *pIndex); - int UnloadTexture(IGraphics::CTextureHandle *pIndex) override; + void 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; - IGraphics::CTextureHandle NullTexture() const 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 da9206349..184e907e8 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -250,11 +250,9 @@ protected: public: enum { - TEXLOAD_NOMIPMAPS = 1 << 1, - TEXLOAD_NO_COMPRESSION = 1 << 2, - TEXLOAD_TO_3D_TEXTURE = (1 << 3), - TEXLOAD_TO_2D_ARRAY_TEXTURE = (1 << 4), - TEXLOAD_NO_2D_TEXTURE = (1 << 5), + TEXLOAD_TO_3D_TEXTURE = 1 << 0, + TEXLOAD_TO_2D_ARRAY_TEXTURE = 1 << 1, + TEXLOAD_NO_2D_TEXTURE = 1 << 2, }; class CTextureHandle @@ -340,12 +338,10 @@ public: // destination width must be equal to the subwidth of the source virtual void CopyTextureFromTextureBufferSub(uint8_t *pDestBuffer, size_t DestWidth, size_t DestHeight, const CImageInfo &SourceImage, size_t SrcSubOffsetX, size_t SrcSubOffsetY, size_t SrcSubCopyWidth, size_t SrcSubCopyHeight) = 0; - virtual int UnloadTexture(CTextureHandle *pIndex) = 0; + virtual void 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 CTextureHandle NullTexture() const = 0; virtual void TextureSet(CTextureHandle Texture) = 0; void TextureClear() { TextureSet(CTextureHandle()); }