Skip to content

Commit d855d25

Browse files
committed
Merge pull request #368 from xlz/intel-opengl
Intel Mesa OpenGL bug fixes and cleanup
2 parents 7691a03 + 520b55d commit d855d25

16 files changed

+260
-390
lines changed

examples/protonect/include/libfreenect2/depth_packet_stream_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class LIBFREENECT2_API DepthPacketStreamParser : public DataCallback
6868

6969
uint32_t current_sequence_;
7070
uint32_t current_subsequence_;
71+
uint32_t processed_packets_;
7172
};
7273

7374
} /* namespace libfreenect2 */

examples/protonect/src/command_transaction.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#include <stdint.h>
3131

32+
#define WRITE_LIBUSB_ERROR(__RESULT) libusb_error_name(__RESULT) << " " << libusb_strerror((libusb_error)__RESULT)
33+
3234
namespace libfreenect2
3335
{
3436
namespace protocol
@@ -135,7 +137,7 @@ CommandTransaction::ResultCode CommandTransaction::send(const CommandBase& comma
135137

136138
if(r != LIBUSB_SUCCESS)
137139
{
138-
LOG_ERROR << "bulk transfer failed! libusb error " << r << ": " << libusb_error_name(r);
140+
LOG_ERROR << "bulk transfer failed: " << WRITE_LIBUSB_ERROR(r);
139141
code = Error;
140142
}
141143

@@ -157,7 +159,7 @@ void CommandTransaction::receive(CommandTransaction::Result& result)
157159

158160
if(r != LIBUSB_SUCCESS)
159161
{
160-
LOG_ERROR << "bulk transfer failed! libusb error " << r << ": " << libusb_error_name(r);
162+
LOG_ERROR << "bulk transfer failed: " << WRITE_LIBUSB_ERROR(r);
161163
result.code = Error;
162164
}
163165
}

examples/protonect/src/depth_packet_stream_parser.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace libfreenect2
3333

3434
DepthPacketStreamParser::DepthPacketStreamParser() :
3535
processor_(noopProcessor<DepthPacket>()),
36+
processed_packets_(-1),
3637
current_sequence_(0),
3738
current_subsequence_(0)
3839
{
@@ -79,7 +80,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
7980

8081
if(wb.length + in_length > wb.capacity)
8182
{
82-
LOG_ERROR << "subpacket too large";
83+
LOG_DEBUG << "subpacket too large";
8384
wb.length = 0;
8485
return;
8586
}
@@ -91,7 +92,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
9192
{
9293
if(footer->length != wb.length)
9394
{
94-
LOG_ERROR << "image data too short!";
95+
LOG_DEBUG << "image data too short!";
9596
}
9697
else
9798
{
@@ -110,15 +111,26 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
110111
packet.buffer_length = buffer_.back().length;
111112

112113
processor_->process(packet);
114+
115+
processed_packets_++;
116+
if (processed_packets_ == 0)
117+
processed_packets_ = current_sequence_;
118+
int diff = current_sequence_ - processed_packets_;
119+
const int interval = 30;
120+
if (current_sequence_ % interval == 0 && diff != 0)
121+
{
122+
LOG_INFO << diff << " of " << interval << " packets were lost";
123+
processed_packets_ = current_sequence_;
124+
}
113125
}
114126
else
115127
{
116-
LOG_WARNING << "skipping depth packet";
128+
LOG_DEBUG << "skipping depth packet";
117129
}
118130
}
119131
else
120132
{
121-
LOG_ERROR << "not all subsequences received " << current_subsequence_;
133+
LOG_DEBUG << "not all subsequences received " << current_subsequence_;
122134
}
123135

124136
current_sequence_ = footer->sequence;
@@ -132,7 +144,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
132144

133145
if(footer->subsequence * footer->length > fb.length)
134146
{
135-
LOG_ERROR << "front buffer too short! subsequence number is " << footer->subsequence;
147+
LOG_DEBUG << "front buffer too short! subsequence number is " << footer->subsequence;
136148
}
137149
else
138150
{

examples/protonect/src/flextGL.c

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
1-
/* WARNING: This file was automatically generated */
2-
/* Do not edit. */
3-
41
#include "flextGL.h"
52
#include "GLFW/glfw3.h"
63

7-
#include <stdio.h>
8-
9-
104
#ifdef __cplusplus
115
extern "C" {
126
#endif
137

14-
15-
void flextLoadOpenGLFunctions(OpenGLBindings *bindings);
16-
17-
int flextInit(GLFWwindow* window, OpenGLBindings *bindings)
18-
{
19-
20-
int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
21-
int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
22-
23-
flextLoadOpenGLFunctions(bindings);
24-
25-
/* --- Check for minimal version and profile --- */
26-
27-
if (major * 10 + minor < 33) {
28-
fprintf(stderr, "Error: OpenGL version 3.3 not supported.\n");
29-
fprintf(stderr, " Your version is %d.%d.\n", major, minor);
30-
fprintf(stderr, " Try updating your graphics driver.\n");
31-
return GL_FALSE;
32-
}
33-
34-
35-
/* --- Check for extensions --- */
36-
37-
38-
return GL_TRUE;
39-
}
40-
41-
42-
43-
void flextLoadOpenGLFunctions(OpenGLBindings *bindings)
8+
void flextInit(OpenGLBindings *bindings)
449
{
4510
/* --- Function pointer loading --- */
4611

@@ -305,59 +270,6 @@ void flextLoadOpenGLFunctions(OpenGLBindings *bindings)
305270
bindings->glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAME_PROC*)glfwGetProcAddress("glGetActiveUniformBlockName");
306271
bindings->glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDING_PROC*)glfwGetProcAddress("glUniformBlockBinding");
307272

308-
/* GL_VERSION_3_2 */
309-
310-
bindings->glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEX_PROC*)glfwGetProcAddress("glDrawElementsBaseVertex");
311-
bindings->glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEX_PROC*)glfwGetProcAddress("glDrawRangeElementsBaseVertex");
312-
bindings->glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEX_PROC*)glfwGetProcAddress("glDrawElementsInstancedBaseVertex");
313-
bindings->glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEX_PROC*)glfwGetProcAddress("glMultiDrawElementsBaseVertex");
314-
bindings->glProvokingVertex = (PFNGLPROVOKINGVERTEX_PROC*)glfwGetProcAddress("glProvokingVertex");
315-
bindings->glFenceSync = (PFNGLFENCESYNC_PROC*)glfwGetProcAddress("glFenceSync");
316-
bindings->glIsSync = (PFNGLISSYNC_PROC*)glfwGetProcAddress("glIsSync");
317-
bindings->glDeleteSync = (PFNGLDELETESYNC_PROC*)glfwGetProcAddress("glDeleteSync");
318-
bindings->glClientWaitSync = (PFNGLCLIENTWAITSYNC_PROC*)glfwGetProcAddress("glClientWaitSync");
319-
bindings->glWaitSync = (PFNGLWAITSYNC_PROC*)glfwGetProcAddress("glWaitSync");
320-
bindings->glGetInteger64v = (PFNGLGETINTEGER64V_PROC*)glfwGetProcAddress("glGetInteger64v");
321-
bindings->glGetSynciv = (PFNGLGETSYNCIV_PROC*)glfwGetProcAddress("glGetSynciv");
322-
bindings->glGetInteger64i_v = (PFNGLGETINTEGER64I_V_PROC*)glfwGetProcAddress("glGetInteger64i_v");
323-
bindings->glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64V_PROC*)glfwGetProcAddress("glGetBufferParameteri64v");
324-
bindings->glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTURE_PROC*)glfwGetProcAddress("glFramebufferTexture");
325-
bindings->glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLE_PROC*)glfwGetProcAddress("glTexImage2DMultisample");
326-
bindings->glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLE_PROC*)glfwGetProcAddress("glTexImage3DMultisample");
327-
bindings->glGetMultisamplefv = (PFNGLGETMULTISAMPLEFV_PROC*)glfwGetProcAddress("glGetMultisamplefv");
328-
bindings->glSampleMaski = (PFNGLSAMPLEMASKI_PROC*)glfwGetProcAddress("glSampleMaski");
329-
330-
/* GL_VERSION_3_3 */
331-
332-
bindings->glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXED_PROC*)glfwGetProcAddress("glBindFragDataLocationIndexed");
333-
bindings->glGetFragDataIndex = (PFNGLGETFRAGDATAINDEX_PROC*)glfwGetProcAddress("glGetFragDataIndex");
334-
bindings->glGenSamplers = (PFNGLGENSAMPLERS_PROC*)glfwGetProcAddress("glGenSamplers");
335-
bindings->glDeleteSamplers = (PFNGLDELETESAMPLERS_PROC*)glfwGetProcAddress("glDeleteSamplers");
336-
bindings->glIsSampler = (PFNGLISSAMPLER_PROC*)glfwGetProcAddress("glIsSampler");
337-
bindings->glBindSampler = (PFNGLBINDSAMPLER_PROC*)glfwGetProcAddress("glBindSampler");
338-
bindings->glSamplerParameteri = (PFNGLSAMPLERPARAMETERI_PROC*)glfwGetProcAddress("glSamplerParameteri");
339-
bindings->glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIV_PROC*)glfwGetProcAddress("glSamplerParameteriv");
340-
bindings->glSamplerParameterf = (PFNGLSAMPLERPARAMETERF_PROC*)glfwGetProcAddress("glSamplerParameterf");
341-
bindings->glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFV_PROC*)glfwGetProcAddress("glSamplerParameterfv");
342-
bindings->glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIV_PROC*)glfwGetProcAddress("glSamplerParameterIiv");
343-
bindings->glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIV_PROC*)glfwGetProcAddress("glSamplerParameterIuiv");
344-
bindings->glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIV_PROC*)glfwGetProcAddress("glGetSamplerParameteriv");
345-
bindings->glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIV_PROC*)glfwGetProcAddress("glGetSamplerParameterIiv");
346-
bindings->glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFV_PROC*)glfwGetProcAddress("glGetSamplerParameterfv");
347-
bindings->glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIV_PROC*)glfwGetProcAddress("glGetSamplerParameterIuiv");
348-
bindings->glQueryCounter = (PFNGLQUERYCOUNTER_PROC*)glfwGetProcAddress("glQueryCounter");
349-
bindings->glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64V_PROC*)glfwGetProcAddress("glGetQueryObjecti64v");
350-
bindings->glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64V_PROC*)glfwGetProcAddress("glGetQueryObjectui64v");
351-
bindings->glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOR_PROC*)glfwGetProcAddress("glVertexAttribDivisor");
352-
bindings->glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UI_PROC*)glfwGetProcAddress("glVertexAttribP1ui");
353-
bindings->glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIV_PROC*)glfwGetProcAddress("glVertexAttribP1uiv");
354-
bindings->glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UI_PROC*)glfwGetProcAddress("glVertexAttribP2ui");
355-
bindings->glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIV_PROC*)glfwGetProcAddress("glVertexAttribP2uiv");
356-
bindings->glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UI_PROC*)glfwGetProcAddress("glVertexAttribP3ui");
357-
bindings->glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIV_PROC*)glfwGetProcAddress("glVertexAttribP3uiv");
358-
bindings->glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UI_PROC*)glfwGetProcAddress("glVertexAttribP4ui");
359-
bindings->glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIV_PROC*)glfwGetProcAddress("glVertexAttribP4uiv");
360-
361273
}
362274

363275
/* ----------------------- Extension flag definitions ---------------------- */

0 commit comments

Comments
 (0)