mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Merge pull request #8367 from Robyt3/Graphics-Backend-Image-Format-Cleanup
Remove redundant graphics backend functions returning RGBA format
This commit is contained in:
commit
058382f253
|
@ -43,13 +43,6 @@ void CCommandProcessorFragment_OpenGL::Cmd_Update_Viewport(const CCommandBuffer:
|
|||
glViewport(pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height);
|
||||
}
|
||||
|
||||
int CCommandProcessorFragment_OpenGL::TexFormatToOpenGLFormat(int TexFormat)
|
||||
{
|
||||
if(TexFormat == CCommandBuffer::TEXFORMAT_RGBA)
|
||||
return GL_RGBA;
|
||||
return GL_RGBA;
|
||||
}
|
||||
|
||||
size_t CCommandProcessorFragment_OpenGL::GLFormatToPixelSize(int GLFormat)
|
||||
{
|
||||
switch(GLFormat)
|
||||
|
@ -665,7 +658,7 @@ void CCommandProcessorFragment_OpenGL::TextureUpdate(int Slot, int X, int Y, int
|
|||
|
||||
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, TexFormatToOpenGLFormat(pCommand->m_Format), pCommand->m_pData);
|
||||
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)
|
||||
|
@ -916,7 +909,7 @@ void CCommandProcessorFragment_OpenGL::TextureCreate(int Slot, int Width, int He
|
|||
|
||||
void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand)
|
||||
{
|
||||
TextureCreate(pCommand->m_Slot, pCommand->m_Width, pCommand->m_Height, TexFormatToOpenGLFormat(pCommand->m_Format), TexFormatToOpenGLFormat(pCommand->m_StoreFormat), pCommand->m_Flags, pCommand->m_pData);
|
||||
TextureCreate(pCommand->m_Slot, pCommand->m_Width, pCommand->m_Height, GL_RGBA, GL_RGBA, pCommand->m_Flags, pCommand->m_pData);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL::Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand)
|
||||
|
|
|
@ -82,7 +82,6 @@ protected:
|
|||
|
||||
bool GetPresentedImageData(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData) override;
|
||||
|
||||
static int TexFormatToOpenGLFormat(int TexFormat);
|
||||
static size_t GLFormatToPixelSize(int GLFormat);
|
||||
|
||||
void TextureUpdate(int Slot, int X, int Y, int Width, int Height, int GLFormat, uint8_t *pTexData);
|
||||
|
|
|
@ -30,13 +30,6 @@ static constexpr GLenum BUFFER_INIT_VERTEX_TARGET = GL_COPY_WRITE_BUFFER;
|
|||
#endif
|
||||
|
||||
// ------------ CCommandProcessorFragment_OpenGL3_3
|
||||
int CCommandProcessorFragment_OpenGL3_3::TexFormatToNewOpenGLFormat(int TexFormat)
|
||||
{
|
||||
if(TexFormat == CCommandBuffer::TEXFORMAT_RGBA)
|
||||
return GL_RGBA;
|
||||
return GL_RGBA;
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram)
|
||||
{
|
||||
if(m_LastProgramId != pProgram->GetProgramId())
|
||||
|
@ -514,7 +507,7 @@ void CCommandProcessorFragment_OpenGL3_3::TextureUpdate(int Slot, int X, int Y,
|
|||
|
||||
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, TexFormatToOpenGLFormat(pCommand->m_Format), pCommand->m_pData);
|
||||
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)
|
||||
|
@ -666,7 +659,7 @@ void CCommandProcessorFragment_OpenGL3_3::TextureCreate(int Slot, int Width, int
|
|||
|
||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand)
|
||||
{
|
||||
TextureCreate(pCommand->m_Slot, pCommand->m_Width, pCommand->m_Height, TexFormatToOpenGLFormat(pCommand->m_Format), TexFormatToOpenGLFormat(pCommand->m_StoreFormat), pCommand->m_Flags, pCommand->m_pData);
|
||||
TextureCreate(pCommand->m_Slot, pCommand->m_Width, pCommand->m_Height, GL_RGBA, GL_RGBA, pCommand->m_Flags, pCommand->m_pData);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand)
|
||||
|
|
|
@ -71,7 +71,6 @@ protected:
|
|||
|
||||
void InitPrimExProgram(CGLSLPrimitiveExProgram *pProgram, class CGLSLCompiler *pCompiler, class IStorage *pStorage, bool Textured, bool Rotationless);
|
||||
|
||||
static int TexFormatToNewOpenGLFormat(int TexFormat);
|
||||
bool IsNewApi() override { return true; }
|
||||
|
||||
void UseProgram(CGLSLTWProgram *pProgram);
|
||||
|
|
|
@ -2702,13 +2702,6 @@ protected:
|
|||
return true;
|
||||
}
|
||||
|
||||
VkFormat TextureFormatToVulkanFormat(int TexFormat)
|
||||
{
|
||||
if(TexFormat == CCommandBuffer::TEXFORMAT_RGBA)
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool BuildMipmaps(VkImage Image, VkFormat ImageFormat, size_t Width, size_t Height, size_t Depth, size_t MipMapLevelCount)
|
||||
{
|
||||
VkCommandBuffer *pMemCommandBuffer;
|
||||
|
@ -6657,12 +6650,10 @@ public:
|
|||
int Slot = pCommand->m_Slot;
|
||||
int Width = pCommand->m_Width;
|
||||
int Height = pCommand->m_Height;
|
||||
int Format = pCommand->m_Format;
|
||||
int StoreFormat = pCommand->m_StoreFormat;
|
||||
int Flags = pCommand->m_Flags;
|
||||
uint8_t *pData = pCommand->m_pData;
|
||||
|
||||
if(!CreateTextureCMD(Slot, Width, Height, TextureFormatToVulkanFormat(Format), TextureFormatToVulkanFormat(StoreFormat), Flags, pData))
|
||||
if(!CreateTextureCMD(Slot, Width, Height, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, Flags, pData))
|
||||
return false;
|
||||
|
||||
free(pData);
|
||||
|
|
|
@ -347,7 +347,6 @@ int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureId, int x, int y
|
|||
Cmd.m_Y = y;
|
||||
Cmd.m_Width = Image.m_Width;
|
||||
Cmd.m_Height = Image.m_Height;
|
||||
Cmd.m_Format = CCommandBuffer::TEXFORMAT_RGBA;
|
||||
|
||||
uint8_t *pTmpData = static_cast<uint8_t *>(malloc(Image.m_Width * Image.m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA)));
|
||||
ConvertToRGBA(pTmpData, Image);
|
||||
|
@ -433,8 +432,6 @@ static CCommandBuffer::SCommand_Texture_Create LoadTextureCreateCommand(int Text
|
|||
Cmd.m_Slot = TextureId;
|
||||
Cmd.m_Width = Width;
|
||||
Cmd.m_Height = Height;
|
||||
Cmd.m_Format = CCommandBuffer::TEXFORMAT_RGBA;
|
||||
Cmd.m_StoreFormat = CCommandBuffer::TEXFORMAT_RGBA;
|
||||
|
||||
Cmd.m_Flags = 0;
|
||||
if(Flags & IGraphics::TEXLOAD_NOMIPMAPS)
|
||||
|
|
|
@ -527,9 +527,8 @@ public:
|
|||
|
||||
size_t m_Width;
|
||||
size_t m_Height;
|
||||
int m_Format;
|
||||
int m_StoreFormat;
|
||||
int m_Flags;
|
||||
// data must be in RGBA format
|
||||
uint8_t *m_pData; // will be freed by the command processor
|
||||
};
|
||||
|
||||
|
@ -545,7 +544,7 @@ public:
|
|||
int m_Y;
|
||||
size_t m_Width;
|
||||
size_t m_Height;
|
||||
int m_Format;
|
||||
// data must be in RGBA format
|
||||
uint8_t *m_pData; // will be freed by the command processor
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue