Merge pull request #8367 from Robyt3/Graphics-Backend-Image-Format-Cleanup

Remove redundant graphics backend functions returning RGBA format
This commit is contained in:
Dennis Felsing 2024-05-18 01:09:40 +00:00 committed by GitHub
commit 058382f253
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 7 additions and 36 deletions

View file

@ -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); 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) size_t CCommandProcessorFragment_OpenGL::GLFormatToPixelSize(int GLFormat)
{ {
switch(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) 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) 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) 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) void CCommandProcessorFragment_OpenGL::Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand)

View file

@ -82,7 +82,6 @@ protected:
bool GetPresentedImageData(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData) override; 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); static size_t GLFormatToPixelSize(int GLFormat);
void TextureUpdate(int Slot, int X, int Y, int Width, int Height, int GLFormat, uint8_t *pTexData); void TextureUpdate(int Slot, int X, int Y, int Width, int Height, int GLFormat, uint8_t *pTexData);

View file

@ -30,13 +30,6 @@ static constexpr GLenum BUFFER_INIT_VERTEX_TARGET = GL_COPY_WRITE_BUFFER;
#endif #endif
// ------------ CCommandProcessorFragment_OpenGL3_3 // ------------ 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) void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram)
{ {
if(m_LastProgramId != pProgram->GetProgramId()) 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) 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) 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) 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) void CCommandProcessorFragment_OpenGL3_3::Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand)

View file

@ -71,7 +71,6 @@ protected:
void InitPrimExProgram(CGLSLPrimitiveExProgram *pProgram, class CGLSLCompiler *pCompiler, class IStorage *pStorage, bool Textured, bool Rotationless); void InitPrimExProgram(CGLSLPrimitiveExProgram *pProgram, class CGLSLCompiler *pCompiler, class IStorage *pStorage, bool Textured, bool Rotationless);
static int TexFormatToNewOpenGLFormat(int TexFormat);
bool IsNewApi() override { return true; } bool IsNewApi() override { return true; }
void UseProgram(CGLSLTWProgram *pProgram); void UseProgram(CGLSLTWProgram *pProgram);

View file

@ -2702,13 +2702,6 @@ protected:
return true; 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) [[nodiscard]] bool BuildMipmaps(VkImage Image, VkFormat ImageFormat, size_t Width, size_t Height, size_t Depth, size_t MipMapLevelCount)
{ {
VkCommandBuffer *pMemCommandBuffer; VkCommandBuffer *pMemCommandBuffer;
@ -6657,12 +6650,10 @@ public:
int Slot = pCommand->m_Slot; int Slot = pCommand->m_Slot;
int Width = pCommand->m_Width; int Width = pCommand->m_Width;
int Height = pCommand->m_Height; int Height = pCommand->m_Height;
int Format = pCommand->m_Format;
int StoreFormat = pCommand->m_StoreFormat;
int Flags = pCommand->m_Flags; int Flags = pCommand->m_Flags;
uint8_t *pData = pCommand->m_pData; 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; return false;
free(pData); free(pData);

View file

@ -347,7 +347,6 @@ int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureId, int x, int y
Cmd.m_Y = y; Cmd.m_Y = y;
Cmd.m_Width = Image.m_Width; Cmd.m_Width = Image.m_Width;
Cmd.m_Height = Image.m_Height; 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))); uint8_t *pTmpData = static_cast<uint8_t *>(malloc(Image.m_Width * Image.m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA)));
ConvertToRGBA(pTmpData, Image); ConvertToRGBA(pTmpData, Image);
@ -433,8 +432,6 @@ static CCommandBuffer::SCommand_Texture_Create LoadTextureCreateCommand(int Text
Cmd.m_Slot = TextureId; Cmd.m_Slot = TextureId;
Cmd.m_Width = Width; Cmd.m_Width = Width;
Cmd.m_Height = Height; Cmd.m_Height = Height;
Cmd.m_Format = CCommandBuffer::TEXFORMAT_RGBA;
Cmd.m_StoreFormat = CCommandBuffer::TEXFORMAT_RGBA;
Cmd.m_Flags = 0; Cmd.m_Flags = 0;
if(Flags & IGraphics::TEXLOAD_NOMIPMAPS) if(Flags & IGraphics::TEXLOAD_NOMIPMAPS)

View file

@ -527,9 +527,8 @@ public:
size_t m_Width; size_t m_Width;
size_t m_Height; size_t m_Height;
int m_Format;
int m_StoreFormat;
int m_Flags; int m_Flags;
// data must be in RGBA format
uint8_t *m_pData; // will be freed by the command processor uint8_t *m_pData; // will be freed by the command processor
}; };
@ -545,7 +544,7 @@ public:
int m_Y; int m_Y;
size_t m_Width; size_t m_Width;
size_t m_Height; size_t m_Height;
int m_Format; // data must be in RGBA format
uint8_t *m_pData; // will be freed by the command processor uint8_t *m_pData; // will be freed by the command processor
}; };