GS-OGL: Remove available_vram (#8389)

This commit is contained in:
Berylskid 2023-03-13 18:07:34 +09:00 committed by GitHub
parent b244136179
commit 2a306cbd91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 48 deletions

View File

@ -47,8 +47,6 @@ namespace GLState
GLuint tex_unit[8];
GLuint64 tex_handle[8];
s64 available_vram;
void Clear()
{
fbo = 0;
@ -76,9 +74,5 @@ namespace GLState
ds = nullptr;
std::fill(std::begin(tex_unit), std::end(tex_unit), 0);
std::fill(std::begin(tex_handle), std::end(tex_handle), 0);
// Set a max vram limit for texture allocation
// (256MB are reserved for PBO/IBO/VBO/UBO buffers)
available_vram = (4096u - 256u) * 1024u * 1024u;
}
} // namespace GLState

View File

@ -51,7 +51,5 @@ namespace GLState
extern GLuint tex_unit[8]; // shader input texture
extern GLuint64 tex_handle[8]; // shader input texture
extern s64 available_vram;
extern void Clear();
} // namespace GLState

View File

@ -498,34 +498,6 @@ bool GSDeviceOGL::Create()
}
}
// ****************************************************************
// Get Available Memory
// ****************************************************************
GLint vram[4] = {0};
if (GLLoader::vendor_id_amd)
{
// Full vram, remove a small margin for others buffer
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, vram);
}
else if (GLAD_GL_NVX_gpu_memory_info)
{
// GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX <= give full memory
// Available vram
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, vram);
}
else
{
fprintf(stdout, "No extenstion supported to get available memory. Use default value !\n");
}
// When VRAM is at least 2GB, we set the limit to the default i.e. 3.8 GB
// When VRAM is below 2GB, we add a factor 2 because RAM can be used. Potentially
// low VRAM gpu can go higher but perf will be bad anyway.
if (vram[0] > 0 && vram[0] < 1800000)
GLState::available_vram = (s64)(vram[0]) * 1024ul * 2ul;
fprintf(stdout, "Available VRAM/RAM:%lldMB for textures\n", GLState::available_vram >> 20u);
// Basic to ensure structures are correctly packed
static_assert(sizeof(VSSelector) == 1, "Wrong VSSelector size");
static_assert(sizeof(PSSelector) == 12, "Wrong PSSelector size");

View File

@ -159,16 +159,6 @@ GSTextureOGL::GSTextureOGL(Type type, int width, int height, int levels, Format
glTextureParameteri(m_texture_id, GL_TEXTURE_SWIZZLE_A, GL_RED);
}
static int every_512 = 0;
GLState::available_vram -= GetMemUsage();
if ((GLState::available_vram < 0) && (every_512 % 512 == 0))
{
fprintf(stderr, "Available VRAM is very low (%lld), a crash is expected! Enable conservative buffer allocation or reduce upscaling!\n", GLState::available_vram);
every_512++;
// Pull emergency break
throw std::bad_alloc();
}
glTextureStorage2D(m_texture_id, m_mipmap_levels, gl_fmt, m_size.x, m_size.y);
}
@ -185,8 +175,6 @@ GSTextureOGL::~GSTextureOGL()
}
glDeleteTextures(1, &m_texture_id);
GLState::available_vram += GetMemUsage();
}
void* GSTextureOGL::GetNativeHandle() const