Support DSA version of mipmap generation

This commit is contained in:
rdb 2015-11-11 17:08:09 +01:00
parent f9add18798
commit 8822ac0b05
3 changed files with 50 additions and 16 deletions

View File

@ -409,21 +409,20 @@ rebuild_bitplanes() {
// Now create the FBO's. // Now create the FBO's.
_have_any_color = false; _have_any_color = false;
_fbo.reserve(num_fbos);
for (int layer = 0; layer < num_fbos; ++layer) { if (num_fbos > _fbo.size()) {
if (layer >= _fbo.size()) { // Generate more FBO handles.
_fbo.push_back(0); int start = _fbo.size();
_fbo.resize(num_fbos, 0);
glgsg->_glGenFramebuffers(num_fbos - start, &_fbo[start]);
} }
for (int layer = 0; layer < num_fbos; ++layer) {
// Bind the FBO // Bind the FBO
if (_fbo[layer] == 0) {
glgsg->_glGenFramebuffers(1, &_fbo[layer]);
if (_fbo[layer] == 0) { if (_fbo[layer] == 0) {
report_my_gl_errors(); report_my_gl_errors();
return; return;
} }
}
glgsg->bind_fbo(_fbo[layer]); glgsg->bind_fbo(_fbo[layer]);
#ifndef OPENGLES #ifndef OPENGLES
@ -1118,11 +1117,7 @@ generate_mipmaps() {
CLP(TextureContext) *gtc = *it; CLP(TextureContext) *gtc = *it;
if (gtc->_generate_mipmaps) { if (gtc->_generate_mipmaps) {
glgsg->_state_texture = 0; glgsg->generate_mipmaps(gtc);
glgsg->update_texture(gtc, true);
glgsg->apply_texture(gtc);
glgsg->_glGenerateMipmap(gtc->_target);
glBindTexture(gtc->_target, 0);
} }
} }

View File

@ -1877,6 +1877,15 @@ reset() {
#endif // OPENGLES #endif // OPENGLES
#endif #endif
#ifndef OPENGLES
if (is_at_least_gl_version(4, 5) || has_extension("GL_ARB_direct_state_access")) {
_glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)
get_extension_func("glGenerateTextureMipmap");
} else {
_glGenerateTextureMipmap = NULL;
}
#endif
_supports_framebuffer_multisample = false; _supports_framebuffer_multisample = false;
if ( has_extension("GL_EXT_framebuffer_multisample") ) { if ( has_extension("GL_EXT_framebuffer_multisample") ) {
_supports_framebuffer_multisample = true; _supports_framebuffer_multisample = true;
@ -11760,6 +11769,31 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
return true; return true;
} }
////////////////////////////////////////////////////////////////////
// Function: GLGraphicsStateGuardian::generate_mipmaps
// Access: Protected
// Description: Causes mipmaps to be generated for an uploaded
// texture.
////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian)::
generate_mipmaps(CLP(TextureContext) *gtc) {
#ifndef OPENGLES
if (_glGenerateTextureMipmap != NULL) {
// OpenGL 4.5 offers an easy way to do this without binding.
_glGenerateTextureMipmap(gtc->_index);
return;
}
#endif
if (_glGenerateMipmap != NULL) {
_state_texture = 0;
update_texture(gtc, true);
apply_texture(gtc);
_glGenerateMipmap(gtc->_target);
glBindTexture(gtc->_target, 0);
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GLGraphicsStateGuardian::upload_simple_texture // Function: GLGraphicsStateGuardian::upload_simple_texture
// Access: Protected // Access: Protected

View File

@ -546,6 +546,7 @@ protected:
GLenum component_type, GLenum component_type,
bool one_page_only, int z, bool one_page_only, int z,
Texture::CompressionMode image_compression); Texture::CompressionMode image_compression);
void generate_mipmaps(CLP(TextureContext) *gtc);
bool upload_simple_texture(CLP(TextureContext) *gtc); bool upload_simple_texture(CLP(TextureContext) *gtc);
size_t get_texture_memory_size(CLP(TextureContext) *gtc); size_t get_texture_memory_size(CLP(TextureContext) *gtc);
@ -794,6 +795,10 @@ public:
PFNGLGENERATEMIPMAPEXTPROC _glGenerateMipmap; PFNGLGENERATEMIPMAPEXTPROC _glGenerateMipmap;
PFNGLBINDPROGRAMARBPROC _glBindProgram; PFNGLBINDPROGRAMARBPROC _glBindProgram;
#ifndef OPENGLES
PFNGLGENERATETEXTUREMIPMAPPROC _glGenerateTextureMipmap;
#endif
bool _supports_framebuffer_multisample; bool _supports_framebuffer_multisample;
bool _supports_framebuffer_multisample_coverage_nv; bool _supports_framebuffer_multisample_coverage_nv;
INLINE bool get_supports_framebuffer_multisample(); INLINE bool get_supports_framebuffer_multisample();