Skip to content

Commit e99312e

Browse files
committed
opengl: Limit texture size to 4k on Intel
Intel/Mesa has GL_MAX_RECTANGLE_TEXTURE_SIZE=4096, but this was asking for 424*10. Drop the 10th frame which seems useless now, so the texture size works for Intel/Mesa.
1 parent 0ad9230 commit e99312e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

examples/protonect/src/opengl_depth_packet_processor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ struct Texture : public WithOpenGLBindings
279279

280280
void allocate(size_t new_width, size_t new_height)
281281
{
282+
GLint max_size;
283+
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &max_size);
284+
if (new_width > max_size || new_height > max_size)
285+
{
286+
LOG_ERROR << "GL_MAX_RECTANGLE_TEXTURE_SIZE is too small: " << max_size;
287+
exit(-1);
288+
}
289+
282290
width = new_width;
283291
height = new_height;
284292
size = height * width * bytes_per_pixel;
@@ -459,7 +467,7 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe
459467
}
460468
gl(b);
461469

462-
input_data.allocate(352, 424 * 10);
470+
input_data.allocate(352, 424 * 9);
463471

464472
for(int i = 0; i < 3; ++i)
465473
stage1_data[i].allocate(512, 424);
@@ -942,7 +950,7 @@ void OpenGLDepthPacketProcessor::process(const DepthPacket &packet)
942950

943951
glfwMakeContextCurrent(impl_->opengl_context_ptr);
944952

945-
std::copy(packet.buffer, packet.buffer + packet.buffer_length, impl_->input_data.data);
953+
std::copy(packet.buffer, packet.buffer + packet.buffer_length/10*9, impl_->input_data.data);
946954
impl_->input_data.upload();
947955
impl_->run(has_listener ? &ir : 0, has_listener ? &depth : 0);
948956

0 commit comments

Comments
 (0)