Skip to content
Permalink
Browse files

glgsg: fix issue extracting texture data for multiview textures

  • Loading branch information
rdb committed Nov 10, 2019
1 parent cb01d45 commit 2d836697b0ce577a43b554d44b209c48c500f3cf
Showing with 19 additions and 4 deletions.
  1. +19 −4 panda/src/glstuff/glGraphicsStateGuardian_src.cxx
@@ -14270,7 +14270,17 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
return false;
}

tex->set_ram_image(image, compression, page_size);
int num_views = tex->get_num_views();
if (num_views == 1) {
// Replace the entire image, since we are modifying the only view.
tex->set_ram_image(image, compression, page_size);
} else {
// We're only modifying a single view, so we can't stomp all over the
// existing content.
PTA_uchar ram_image = tex->modify_ram_image();
nassertr(ram_image.size() == image.size() * num_views, false);
memcpy(ram_image.p() + image.size() * gtc->get_view(), image.p(), image.size());
}

if (gtc->_uses_mipmaps) {
// Also get the mipmap levels.
@@ -14286,7 +14296,12 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
type, compression, n)) {
return false;
}
tex->set_ram_mipmap_image(n, image, page_size);
if (num_views == 1) {
tex->set_ram_mipmap_image(n, image, page_size);
} else {
PTA_uchar ram_mipmap_image = tex->modify_ram_mipmap_image(n);
memcpy(ram_mipmap_image.p() + image.size() * gtc->get_view(), image.p(), image.size());
}
}
}

@@ -14350,13 +14365,13 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
#ifndef OPENGLES
} else if (target == GL_TEXTURE_BUFFER) {
// In the case of a buffer texture, we need to get it from the buffer.
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_image_size(n));
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_view_size(n));
_glGetBufferSubData(target, 0, image.size(), image.p());
#endif

} else if (compression == Texture::CM_off) {
// An uncompressed 1-d, 2-d, or 3-d texture.
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_image_size(n));
image = PTA_uchar::empty_array(tex->get_expected_ram_mipmap_view_size(n));
GLenum external_format = get_external_image_format(tex);
GLenum pixel_type = get_component_type(type);
glGetTexImage(target, n, external_format, pixel_type, image.p());

0 comments on commit 2d83669

Please sign in to comment.
You can’t perform that action at this time.