PDA

View Full Version : problem with pbo .



shivmitra
11-08-2011, 01:25 AM
I am using PBO to update data to texture using glSubTexImage2d .
It works fine in ATI machine , but with a machine having Intel graphic card it doesnot work . I checked and found the extension gl_arb_pixel_buffer_object is supported on intel machine .

Here is some code snippet


GLuint InitializeTexturePBO(CPUInt16 bufferSize)
{
GLuint pbo;
(*m_glGenBuffersARB)(1,&pbo);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB,
bufferSize , NULL , GL_STREAM_DRAW_ARB);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
return pbo;
}
void* GetPBOBufferPointer(unsigned int identifier ,int width , int height)
{
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, identifier );
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB, width*height*4 ,
0, GL_STREAM_DRAW_ARB);
return (void*)(*m_glMapBufferARB)(GL_PIXEL_UNPACK_BUFFER_ ARB,
GL_WRITE_ONLY_ARB);
}


void UnmapPBOBuffer()
{
if(!m_glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB) )
throw CPCustomException();
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

}



i call it in this order .


InitializeTexturePBO();
GetPBOBufferPointer(); // take this pointer and decode video frames at this location
glBindTexture(GL_TEXTURE_2D , textureObjectList[sourceID]);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,ToInt16(m_vide oSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_width),
ToInt16(m_videoSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_height),GL_BGRA _EXT,GL_UNSIGNED_BYTE,
0);
UnmapPBOBuffer();


I am not able to understand why it fails on glTexSubImage call with error code GL_INVALID_OPERATION on intel card but works fine on ATI card ??

mhagain
11-08-2011, 03:55 AM
Because, like you said, GL_ARB_pixel_buffer_object is not supported on your Intel. The PBO extension just uses the same entry points as GL_ARB_vertex_buffer_object (which is supported on a wide range of Intels), but using the PBO targets in your function calls generates an invalid operation. Perfectly normal and expected behaviour.

shivmitra
11-08-2011, 03:58 AM
but when i do glGetString(GL_EXTENSION)
i get this string

GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_blend_color GL_EXT_abgr GL_EXT_texture3D GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_SGIS_texture_edge_clamp GL_SGIS_generate_mipmap GL_EXT_draw_range_elements GL_SGIS_texture_lod GL_EXT_rescale_normal GL_EXT_packed_pixels GL_EXT_texture_edge_clamp GL_EXT_separate_specular_color GL_ARB_multitexture GL_EXT_texture_env_combine GL_EXT_bgra GL_EXT_blend_func_separate GL_EXT_secondary_color GL_EXT_fog_coord GL_EXT_texture_env_add GL_ARB_texture_cube_map GL_ARB_transpose_matrix GL_ARB_texture_env_add GL_IBM_texture_mirrored_repeat GL_EXT_multi_draw_arrays GL_NV_blend_square GL_ARB_texture_compression GL_3DFX_texture_compression_FXT1 GL_EXT_texture_filter_anisotropic GL_ARB_texture_border_clamp GL_ARB_point_parameters GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_EXT_texture_compression_s3tc GL_ARB_shadow GL_ARB_window_pos GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_ARB_vertex_program GL_EXT_texture_rectangle GL_ARB_fragment_program GL_EXT_stencil_two_side GL_ATI_separate_stencil GL_ARB_vertex_buffer_object GL_EXT_texture_lod_bias GL_ARB_occlusion_query GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_non_power_of_two GL_ARB_vertex_shader GL_NV_texgen_reflection GL_ARB_point_sprite GL_EXT_blend_equation_separate GL_ARB_depth_texture GL_ARB_texture_rectangle GL_ARB_draw_buffers GL_ARB_color_buffer_float GL_ARB_half_float_pixel GL_ARB_texture_float "GL_ARB_pixel_buffer_object" GL_EXT_framebuffer_object GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_EXT_draw_buffers2 GL_WIN_swap_hint GL_EXT_texture_sRGB GL_ARB_multisample GL_EXT_packed_float GL_EXT_texture_shared_exponent GL_ARB_texture_rg GL_ARB_texture_compression_rgtc GL_NV_conditional_render GL_EXT_texture_swizzle GL_ARB_framebuffer_sRGB GL_EXT_packed_depth_stencil GL_ARB_depth_buffer_float GL_EXT_transform_feedback GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_ARB_framebuffer_object GL_EXT_texture_array GL_EXT_texture_integer GL_ARB_map_buffer_range GL_EXT_texture_snorm GL_INTEL_performance_queries GL_ARB_vertex_array_object

i have put gl_arb_pixel_buffer_object in quotes for clarity .
i suppose this means card supports PBO . in case it doesn't how can i find that card doesn't supports PBO.

shivmitra
11-08-2011, 04:03 AM
i am using gDEBugger for purpose of debugging and in that i found that GL_PIXEL_UNPACK_BUFFER_BINDING_ARB is changing it value when i m binding the buffer . So if unpack buffer is correctly bound , i think extension is available and working (i am just a beginner , so i might be wrong ) ..

mbentrup
11-09-2011, 05:22 AM
"GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped."

Unmap your PBO first, that it works on ATI is a bug.