mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Allow specifying texture LOD BIAS
This commit is contained in:
parent
6bb8cda483
commit
c951fc3ee4
|
@ -438,6 +438,8 @@ void CCommandProcessorFragment_OpenGL::Cmd_Init(const SCommand_Init *pCommand)
|
|||
m_pTextureMemoryUsage->store(0, std::memory_order_relaxed);
|
||||
m_MaxTexSize = -1;
|
||||
|
||||
m_OpenGLTextureLodBIAS = 0;
|
||||
|
||||
m_Has2DArrayTextures = pCommand->m_pCapabilities->m_2DArrayTextures;
|
||||
if(pCommand->m_pCapabilities->m_2DArrayTexturesAsExtension)
|
||||
{
|
||||
|
@ -653,6 +655,8 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
if(m_OpenGLTextureLodBIAS != 0)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, ((GLfloat)m_OpenGLTextureLodBIAS / 1000.0f));
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, Width, Height, 0, Oglformat, GL_UNSIGNED_BYTE, pTexData);
|
||||
}
|
||||
|
||||
|
@ -701,12 +705,16 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
|
|||
glTexParameteri(Target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(Target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(Target, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT);
|
||||
if(m_OpenGLTextureLodBIAS != 0)
|
||||
glTexParameterf(Target, GL_TEXTURE_LOD_BIAS, ((GLfloat)m_OpenGLTextureLodBIAS / 1000.0f));
|
||||
|
||||
if(IsNewApi())
|
||||
{
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT);
|
||||
if(m_OpenGLTextureLodBIAS != 0)
|
||||
glSamplerParameterf(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_LOD_BIAS, ((GLfloat)m_OpenGLTextureLodBIAS / 1000.0f));
|
||||
|
||||
glBindSampler(0, 0);
|
||||
}
|
||||
|
@ -1430,6 +1438,8 @@ void CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
|
|||
{
|
||||
CCommandProcessorFragment_OpenGL::Cmd_Init(pCommand);
|
||||
|
||||
m_OpenGLTextureLodBIAS = g_Config.m_GfxOpenGLTextureLODBIAS;
|
||||
|
||||
m_HasShaders = pCommand->m_pCapabilities->m_ShaderSupport;
|
||||
|
||||
bool HasAllFunc = true;
|
||||
|
@ -2159,6 +2169,8 @@ void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram)
|
|||
|
||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand)
|
||||
{
|
||||
m_OpenGLTextureLodBIAS = g_Config.m_GfxOpenGLTextureLODBIAS;
|
||||
|
||||
m_UseMultipleTextureUnits = g_Config.m_GfxEnableTextureUnitOptimization;
|
||||
if(!m_UseMultipleTextureUnits)
|
||||
{
|
||||
|
@ -2775,6 +2787,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
|
|||
{
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
if(m_OpenGLTextureLodBIAS != 0)
|
||||
glSamplerParameterf(m_aTextures[pCommand->m_Slot].m_Sampler, GL_TEXTURE_LOD_BIAS, ((GLfloat)m_OpenGLTextureLodBIAS / 1000.0f));
|
||||
//prevent mipmap display bugs, when zooming out far
|
||||
if(Width >= 1024 && Height >= 1024)
|
||||
{
|
||||
|
@ -2797,6 +2811,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
|
|||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT);
|
||||
if(m_OpenGLTextureLodBIAS != 0)
|
||||
glSamplerParameterf(m_aTextures[pCommand->m_Slot].m_Sampler2DArray, GL_TEXTURE_LOD_BIAS, ((GLfloat)m_OpenGLTextureLodBIAS / 1000.0f));
|
||||
|
||||
int ImageColorChannels = TexFormatToImageColorChannelCount(pCommand->m_Format);
|
||||
|
||||
|
|
|
@ -144,6 +144,8 @@ protected:
|
|||
int m_LastBlendMode; //avoid all possible opengl state changes
|
||||
bool m_LastClipEnable;
|
||||
|
||||
int m_OpenGLTextureLodBIAS;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -374,10 +374,14 @@ MACRO_CONFIG_INT(ClDemoSliceEnd, cl_demo_slice_end, -1, 0, 0, CFGFLAG_SAVE | CFG
|
|||
MACRO_CONFIG_INT(ClDemoShowSpeed, cl_demo_show_speed, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Show speed meter on change")
|
||||
MACRO_CONFIG_INT(ClDemoKeyboardShortcuts, cl_demo_keyboard_shortcuts, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable keyboard shortcuts in demo player")
|
||||
|
||||
//opengl
|
||||
// opengl
|
||||
MACRO_CONFIG_INT(GfxOpenGLMajor, gfx_opengl_major, 3, 1, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "OpenGL major version")
|
||||
MACRO_CONFIG_INT(GfxOpenGLMinor, gfx_opengl_minor, 0, 0, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "OpenGL minor version")
|
||||
MACRO_CONFIG_INT(GfxOpenGLPatch, gfx_opengl_patch, 0, 0, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "OpenGL patch version")
|
||||
|
||||
// float multiplied with 1000
|
||||
MACRO_CONFIG_INT(GfxOpenGLTextureLODBIAS, gfx_opengl_texture_lod_bias, -500, -15000, 15000, CFGFLAG_SAVE | CFGFLAG_CLIENT, "The lod bias for OpenGL texture sampling multiplied by 1000")
|
||||
|
||||
MACRO_CONFIG_INT(Gfx3DTextureAnalysisDone, gfx_3d_texture_analysis_done, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Analyzed, if sampling 3D/2D array textures was correct")
|
||||
#if !defined(CONF_PLATFORM_MACOSX)
|
||||
MACRO_CONFIG_INT(GfxEnableTextureUnitOptimization, gfx_enable_texture_unit_optimization, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Use multiple texture units, instead of only one.")
|
||||
|
|
Loading…
Reference in a new issue