more bitdepth fixes

This commit is contained in:
David Rose 2013-01-11 21:01:49 +00:00
parent ab40d5456e
commit de10a2ae4e
2 changed files with 48 additions and 10 deletions

View File

@ -480,13 +480,16 @@ bind_slot(int face, bool rb_resize, Texture **attach, RenderTexturePlane slot, G
GLclampf priority = 1.0f;
glPrioritizeTextures(1, &gtc->_index, &priority);
#endif
GLint depth_size = 0;
if (!is_cube_map) {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D, gtc->_index, 0);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH_SIZE, &depth_size);
} else {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
gtc->_index, 0);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_TEXTURE_DEPTH_SIZE, &depth_size);
}
if (_use_depth_stencil) {
if (!is_cube_map) {
@ -498,6 +501,8 @@ bind_slot(int face, bool rb_resize, Texture **attach, RenderTexturePlane slot, G
gtc->_index, 0);
}
}
_fb_properties.set_depth_bits(depth_size);
} else {
#ifdef OPENGLES
tex->set_format(Texture::F_rgba4);
@ -516,13 +521,27 @@ bind_slot(int face, bool rb_resize, Texture **attach, RenderTexturePlane slot, G
glPrioritizeTextures(1, &gtc->_index, &priority);
#endif
glgsg->update_texture(tc, true);
GLint red_size = 0, green_size = 0, blue_size = 0, alpha_size = 0;
if (!is_cube_map) {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachpoint,
GL_TEXTURE_2D, gtc->_index, 0);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &green_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blue_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
} else {
glgsg->_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachpoint,
GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
gtc->_index, 0);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_TEXTURE_RED_SIZE, &red_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_TEXTURE_GREEN_SIZE, &green_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_TEXTURE_BLUE_SIZE, &blue_size);
GLP(GetTexLevelParameteriv)(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
}
if (attachpoint == GL_COLOR_ATTACHMENT0_EXT) {
_fb_properties.set_color_bits(red_size + green_size + blue_size);
_fb_properties.set_alpha_bits(alpha_size);
}
}
@ -602,13 +621,11 @@ bind_slot(int face, bool rb_resize, Texture **attach, RenderTexturePlane slot, G
// If we get here, we're using the simple fallback case.
#endif
#ifdef OPENGLES
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
_rb_size_x, _rb_size_y);
#else
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
_rb_size_x, _rb_size_y);
#endif
GLint depth_size = 0;
glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, &depth_size);
_fb_properties.set_depth_bits(depth_size);
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
@ -624,9 +641,17 @@ bind_slot(int face, bool rb_resize, Texture **attach, RenderTexturePlane slot, G
} else {
glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, glFormat,
_rb_size_x, _rb_size_y);
GLint red_size = 0, green_size = 0, blue_size = 0, alpha_size = 0;
glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_RED_SIZE_EXT, &red_size);
glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_GREEN_SIZE_EXT, &green_size);
glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_BLUE_SIZE_EXT, &blue_size);
glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_ALPHA_SIZE_EXT, &alpha_size);
_fb_properties.set_color_bits(red_size + green_size + blue_size);
_fb_properties.set_alpha_bits(alpha_size);
glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
glgsg->_glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, attachpoint,
GL_RENDERBUFFER_EXT, _rb[slot]);
}
}
@ -882,6 +907,7 @@ open_buffer() {
// tell the truth about what we actually provide by setting
// the _fb_properties accurately.
_fb_properties.set_depth_bits(1);
_fb_properties.set_color_bits(1);
_fb_properties.set_alpha_bits(_host->get_fb_properties().get_alpha_bits());
if (_gsg->get_supports_depth_stencil()) {

View File

@ -4177,12 +4177,16 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
switch (tex->get_format()) {
case Texture::F_depth_component:
case Texture::F_depth_component16:
case Texture::F_depth_component24:
case Texture::F_depth_component32:
case Texture::F_depth_stencil:
// If the texture is one of these special formats, we don't want
// to adapt it to the framebuffer's color format.
// Don't remap if we're one of these special format.
break;
default:
// If the texture is a color format, we want to match the
// presence of alpha according to the framebuffer.
if (_current_properties->get_alpha_bits()) {
tex->set_format(Texture::F_rgba);
} else {
@ -4303,12 +4307,17 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
Texture::Format format = tex->get_format();
switch (format) {
case Texture::F_depth_component:
case Texture::F_depth_stencil:
component_type = Texture::T_unsigned_int_24_8;
break;
case Texture::F_depth_component:
if (_current_properties->get_depth_bits() <= 8) {
component_type = Texture::T_unsigned_byte;
} else {
} else if (_current_properties->get_depth_bits() <= 16) {
component_type = Texture::T_unsigned_short;
} else {
component_type = Texture::T_float;
}
break;
@ -9589,6 +9598,9 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_DEPTH_COMPONENT:
#endif
case GL_DEPTH_COMPONENT16:
type = Texture::T_unsigned_short;
format = Texture::F_depth_component;
break;
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
type = Texture::T_float;
@ -9597,7 +9609,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
#ifndef OPENGLES_2
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
type = Texture::T_float;
type = Texture::T_unsigned_int_24_8;
format = Texture::F_depth_stencil;
break;
#endif