

Will make no difference. It's the same underlying code, and the two formats are identical - https://github.com/raspberrypi/userland ... _il.c#L732



Code: Select all
static int vcsm_square_redraw(RASPITEX_STATE *raspitex_state)
{
unsigned char *vcsm_buffer = NULL;
VCSM_CACHE_TYPE_T cache_type;
vcos_log_trace("%s", VCOS_FUNCTION);
glClearColor(255, 0, 0, 255);
GLCHK(glBindFramebuffer(GL_FRAMEBUFFER, fb_name));
GLCHK(glViewport(0, 0, fb_width, fb_height));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Fill the viewport with the camFill the viewport with the camera image
GLCHK(glUseProgram(vcsm_square_oes_shader.program));
GLCHK(glActiveTexture(GL_TEXTURE0));
GLCHK(glBindTexture(GL_TEXTURE_EXTERNAL_OES, raspitex_state->y_texture));
GLCHK(glBindBuffer(GL_ARRAY_BUFFER, quad_vbo));
GLCHK(glEnableVertexAttribArray(vcsm_square_oes_shader.attribute_locations[0]));
GLCHK(glVertexAttribPointer(vcsm_square_oes_shader.attribute_locations[0], 2, GL_FLOAT, GL_FALSE, 0, 0));
GLCHK(glDrawArrays(GL_TRIANGLES, 0, 6));
GLCHK(glFinish());
// Make the buffer CPU addressable with host cache enabled
vcsm_buffer = (unsigned char *) vcsm_lock_cache(vcsm_info.vcsm_handle, VCSM_CACHE_TYPE_HOST, &cache_type);
if (! vcsm_buffer) {
vcos_log_error("Failed to lock VCSM buffer for handle %d\n", vcsm_info.vcsm_handle);
return -1;
}
[color=#FF0000]/*HERE: HOW CAN I CALL EmptyThisBuffer on vcsm_buffer?*/[/color]
vcos_log_trace("Locked vcsm handle %d at %p\n", vcsm_info.vcsm_handle, vcsm_buffer);
vcsm_square_draw_pattern(vcsm_buffer);
// Release the locked texture memory to flush the CPU cache and allow GPU
// to read it
vcsm_unlock_ptr(vcsm_buffer);
// Enable default window surface
GLCHK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
// Draw the modified texture buffer to the screen
GLCHK(glViewport(raspitex_state->x, raspitex_state->y, raspitex_state->width, raspitex_state->height));
GLCHK(glUseProgram(vcsm_square_shader.program));
GLCHK(glActiveTexture(GL_TEXTURE0));
GLCHK(glBindTexture(GL_TEXTURE_2D, fb_tex_name));
GLCHK(glEnableVertexAttribArray(vcsm_square_shader.attribute_locations[0]));
GLCHK(glVertexAttribPointer(vcsm_square_shader.attribute_locations[0], 2, GL_FLOAT, GL_FALSE, 0, 0));
GLCHK(glDrawArrays(GL_TRIANGLES, 0, 6));
GLCHK(glDisableVertexAttribArray(vcsm_square_shader.attribute_locations[0]));
GLCHK(glUseProgram(0));
return 0;
}
Code: Select all
static int vcsm_square_redraw(RASPITEX_STATE *raspitex_state)
{
RASPITEX_STATE * state = raspitex_state;
unsigned char *vcsm_buffer = NULL;
static int onlyFirstTime = 0;
const int bytes_per_pixel = 4;
int buffer_size = state->width*state->height*4;
OMX_ERRORTYPE omx_res;
VCSM_CACHE_TYPE_T cache_type;
vcos_log_trace("%s", VCOS_FUNCTION);
glClearColor(255, 0, 0, 255);
GLCHK(glBindFramebuffer(GL_FRAMEBUFFER, fb_name));
GLCHK(glViewport(0, 0, fb_width, fb_height));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Fill the viewport with the camFill the viewport with the camera image
GLCHK(glUseProgram(vcsm_square_oes_shader.program));
GLCHK(glActiveTexture(GL_TEXTURE0));
GLCHK(glBindTexture(GL_TEXTURE_EXTERNAL_OES, raspitex_state->y_texture));
GLCHK(glBindBuffer(GL_ARRAY_BUFFER, quad_vbo));
GLCHK(glEnableVertexAttribArray(vcsm_square_oes_shader.attribute_locations[0]));
GLCHK(glVertexAttribPointer(vcsm_square_oes_shader.attribute_locations[0], 2, GL_FLOAT, GL_FALSE, 0, 0));
GLCHK(glDrawArrays(GL_TRIANGLES, 0, 6));
GLCHK(glFinish());
// Make the buffer CPU addressable with host cache enabled
vcsm_buffer = (unsigned char *) vcsm_lock_cache(vcsm_info.vcsm_handle, VCSM_CACHE_TYPE_HOST, &cache_type);
if (! vcsm_buffer) {
vcos_log_error("Failed to lock VCSM buffer for handle %d\n", vcsm_info.vcsm_handle);
return -1;
}
vcos_log_trace("Locked vcsm handle %d at %p\n", vcsm_info.vcsm_handle, vcsm_buffer);
//printf("Locked vcsm handle %d at %p\n", vcsm_info.vcsm_handle, vcsm_buffer);
fflush(stdout);
state->in_buffer = ilclient_get_input_buffer(state->video_encode, 200, 0);
if(state->in_buffer != NULL) {
printf ("in_buffer bot null \n");
OMX_BRCMVEGLIMAGETYPE image;
image.nWidth =vcsm_info.width;
image.nHeight = vcsm_info.height;
image.nStride = vcsm_info.width<<2;
image.nUmemHandle =vcsm_info.vcsm_handle; //vcsm_info.vcsm_handle;
image.nUmemOffset = 0;
image.nFlipped = 0;
state->in_buffer->pBuffer = ℑ
state->in_buffer->nFilledLen = sizeof(OMX_BRCMVEGLIMAGETYPE) ;
if (OMX_EmptyThisBuffer(ILC_GET_HANDLE(state->video_encode),state->in_buffer) != //state->in_buffer
OMX_ErrorNone) {
printf("Error emptying buffer!\n");
}
}
state->out_buffer = ilclient_get_output_buffer(state->video_encode, 201, 0);
if ( state->out_buffer==NULL) {
return -1;
}
omx_res = OMX_FillThisBuffer(ILC_GET_HANDLE(state->video_encode),state->out_buffer);
if (omx_res != OMX_ErrorNone) {
printf("Error filling buffer: %s\n", err2str(omx_res));
return -1;
}
vcsm_square_draw_pattern(vcsm_buffer);
// Release the locked texture memory to flush the CPU cache and allow GPU
// to read it
vcsm_unlock_ptr(vcsm_buffer);
// Enable default window surface
GLCHK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
// Draw the modified texture buffer to the screen
GLCHK(glViewport(raspitex_state->x, raspitex_state->y, raspitex_state->width, raspitex_state->height));
GLCHK(glUseProgram(vcsm_square_shader.program));
GLCHK(glActiveTexture(GL_TEXTURE0));
GLCHK(glBindTexture(GL_TEXTURE_2D, fb_tex_name));
GLCHK(glEnableVertexAttribArray(vcsm_square_shader.attribute_locations[0]));
GLCHK(glVertexAttribPointer(vcsm_square_shader.attribute_locations[0], 2, GL_FLOAT, GL_FALSE, 0, 0));
GLCHK(glDrawArrays(GL_TRIANGLES, 0, 6));
GLCHK(glDisableVertexAttribArray(vcsm_square_shader.attribute_locations[0]));
GLCHK(glUseProgram(0));
return 0;
}

From which call?

Code: Select all
diff --git a/gl_scenes/vcsm_square.c b/gl_scenes/vcsm_square.c
index e5117b2..b6cccbc 100644
--- a/gl_scenes/vcsm_square.c
+++ b/gl_scenes/vcsm_square.c
@@ -308,7 +308,7 @@ static int vcsm_square_redraw(RASPITEX_STATE *raspitex_state)
image.nWidth =state->width;
image.nHeight = state->height;
image.nStride = state->width<<2;
- image.nUmemHandle =vcsm_info.vcsm_handle; //vcsm_info.vcsm_handle;
+ image.nUmemHandle = vcsm_vc_hdl_from_hdl(vcsm_info.vcsm_handle); //vcsm_info.vcsm_handle;
image.nUmemOffset = 0;
image.nFlipped = 0;
state->in_buffer->pBuffer = ℑ
Code: Select all
#warning OMX_SKIP64BIT is not defined - this will be incompatible with the VC GPU code.Code: Select all
diff --git a/RaspiTex.h b/RaspiTex.h
index d69bafc..b718655 100644
--- a/RaspiTex.h
+++ b/RaspiTex.h
@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <mmal/mmal.h>
//INCLUDES ADDED
+#define OMX_SKIP64BIT
#include <ilclient.h>
#include <fcntl.h>
#include <sys/types.h>
I must confess to getting lost in your various hacks as to where the output buffers were being returned. I recognise that you were just trying things out, but it did all get a little messy in there. Overriding the FillBufferDone callback totally threw me! I'd also recommend that you don't do too much work in that callback context - I think you are blocking all IL communications at that point if you do significant amounts of work there. MMAL is a tad cleaner there in that the buffer callbacks are in a worker thread context.
When they wrote the IL spec they blundered pretty badly.longo92 wrote:I'm only a raspberry GPU-beginner proggrammer, this forum and code study is the only way to undestrand the things.
Just for curiosity what does the define OMX_SKIP64BIT ?? I always use OpenMax without define it.
https://github.com/raspberrypi/userland ... csm.c#L649longo92 wrote:And what does vcsm_vc_hdl_from_hdl (suppose perform some type of handler conversion) ? i cannot find its definition userland/interface/mmal/vc/.
Code: Select all
Resource b2be8300
PID 1046
RES_GUID 0x1000
LOCK_COUNT 0
REF_COUNT 1
res_handle 0x4
res_base_mem fe502000
SIZE 65536
DMABUF (null)
ATTACH (null)
SGT (null)
DMA_ADDR 0x00000000
Code: Select all
[ 4] 0x3e501ae0: used 68K (refcount 1 lock count 0, size 65536, align 4096, data 0x3e502000, d1Rual) 'sm_host_alloc'Yes, future steps is to use the equivalent mmal encoder instead of openMax encoder.I must confess to getting lost in your various hacks as to where the output buffers were being returned. I recognise that you were just trying things out, but it did all get a little messy in there. Overriding the FillBufferDone callback totally threw me! I'd also recommend that you don't do too much work in that callback context - I think you are blocking all IL communications at that point if you do significant amounts of work there. MMAL is a tad cleaner there in that the buffer callbacks are in a worker thread context.
? Because it limits my resolution only to the ones having power of two.Do note the requirement on RSO buffers to be a power of two in width.

Nope, AIUI it's a limitation of the hardware. It's referenced in the errata list for the 3D block (VideoCoreIV-AG100-R.pdf page 109)
Note that that is the stride that must be a power of two, not the width. You should be able to pad the image to the POT without filling it completely with image data.HW-2898 Address generation error for NPOT raster textures
BCM2835,BCM21553
For raster textures the address offset calculation
assumes power-of-2 widths when issuing memory
lookups. This is not true for mipmap level 0.
Workaround is to pad NPOT raster textures
appropriately

VCHIQ (the main IPC mechanism) is likely to complain if you do as it gets confused based on a set of Linux kernel page table flags. It'll be comparable to https://github.com/raspberrypi/userland/issues/386longo92 wrote: ↑Fri Sep 21, 2018 3:08 pmAll Clear.
Another cuorisity question: could i pass the vcsm_buffer retrieve with vcsm_buffer = (unsigned char *) vcsm_lock_cache(vcsm_info.vcsm_handle, VCSM_CACHE_TYPE_HOST, &cache_type) to the pBuffer and the proper size to the EmptyThisBuffer? Of course the encoder input port is set with OMX_COLOR_Format32bitABGR8888 (in one of my previouse experiment, when i encode using the glReadPixels, i notice that GL_RBA = OMX_COLOR_Format32bitABGR8888). Thanks
Regarding this quote, i have a question:which is the equivalent OMX_BRCMVEGLIMAGETYPE in MMAL?If you switch to MMAL, then setting MMAL_PARAMETER_ZERO_COPY on the buffer and populating buffer->data with the vcsm vc handle, and you should get the equivalent zero copy option as BRCMEGL.

https://github.com/raspberrypi/userland ... _il.c#L732
Code: Select all
{MMAL_ENCODING_EGL_IMAGE, OMX_COLOR_FormatBRCMEGL},
Sorry, misread what you were looking for.longo92 wrote: ↑Thu Sep 27, 2018 9:58 amOk, this is the encoding format. But OMX_BRCMVEGLIMAGETYPE is the data struct that i pass to the encoder (through the pBuffer of OMX_BUFFERHEADERTYPE), there is an equivalent struct in MMAL? Or pass directly the vcsm handle to Data field of MMAL_BUFFER_HEADER_T ?