Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit 09c6a52

Browse files
authored
Merge pull request #23 from rgiduthuri/rg/vnext001
bug fixes and runcl
2 parents 4865d0c + bb47f2a commit 09c6a52

16 files changed

+1573
-37
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ project(amdovx)
2323

2424
add_subdirectory(openvx)
2525
add_subdirectory(runvx)
26+
add_subdirectory(runcl)

amdovx.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runvx", "runvx\runvx.vcxpro
1010
{973F2004-2215-431F-8A2C-93ABAAFB6A24} = {973F2004-2215-431F-8A2C-93ABAAFB6A24}
1111
EndProjectSection
1212
EndProject
13+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runcl", "runcl\runcl.vcxproj", "{026F975C-4F8D-4908-8A55-A5B3B643AD59}"
14+
EndProject
1315
Global
1416
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1517
Debug|x64 = Debug|x64
@@ -24,6 +26,10 @@ Global
2426
{E14F83E9-2295-466C-9647-7BD0D03ECE4B}.Debug|x64.Build.0 = Debug|x64
2527
{E14F83E9-2295-466C-9647-7BD0D03ECE4B}.Release|x64.ActiveCfg = Release|x64
2628
{E14F83E9-2295-466C-9647-7BD0D03ECE4B}.Release|x64.Build.0 = Release|x64
29+
{026F975C-4F8D-4908-8A55-A5B3B643AD59}.Debug|x64.ActiveCfg = Debug|x64
30+
{026F975C-4F8D-4908-8A55-A5B3B643AD59}.Debug|x64.Build.0 = Debug|x64
31+
{026F975C-4F8D-4908-8A55-A5B3B643AD59}.Release|x64.ActiveCfg = Release|x64
32+
{026F975C-4F8D-4908-8A55-A5B3B643AD59}.Release|x64.Build.0 = Release|x64
2733
EndGlobalSection
2834
GlobalSection(SolutionProperties) = preSolution
2935
HideSolutionNode = FALSE

openvx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ add_library(openvx SHARED ${SOURCES})
6767

6868
if (OpenCL_FOUND)
6969
target_compile_definitions(openvx PUBLIC ENABLE_OPENCL=1)
70-
include_directories(${OpenCL_INCLUDE_DIRS})
70+
include_directories(${OpenCL_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS}/Headers)
7171
target_link_libraries(openvx ${OpenCL_LIBRARIES})
7272
else(OpenCL_FOUND)
7373
target_compile_definitions(openvx PUBLIC ENABLE_OPENCL=0)

openvx/ago/ago_interface.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,9 @@ int agoReleaseContext(AgoContext * acontext)
8787
return -1;
8888

8989
EnterCriticalSection(&acontext->cs);
90-
acontext->ref.external_count--;
91-
if (acontext->ref.external_count == 0) {
92-
// release all the resources
93-
LeaveCriticalSection(&acontext->cs);
94-
delete acontext;
95-
}
96-
else {
97-
LeaveCriticalSection(&acontext->cs);
98-
}
90+
// release all the resources
91+
LeaveCriticalSection(&acontext->cs);
92+
delete acontext;
9993
return 0;
10094
}
10195

openvx/ago/ago_internal.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ THE SOFTWARE.
3434
//
3535

3636
// version
37-
#define AGO_VERSION "0.9.5"
37+
#define AGO_VERSION "0.9.6"
3838

3939
// debug configuration
4040
#define ENABLE_DEBUG_MESSAGES 0 // 0:disable 1:enable
@@ -416,6 +416,7 @@ struct AgoData {
416416
vx_uint32 hierarchical_life_start;
417417
vx_uint32 hierarchical_life_end;
418418
struct AgoNode * ownerOfUserBufferOpenCL;
419+
std::list<AgoData *> roiDepList;
419420
public:
420421
AgoData();
421422
~AgoData();
@@ -680,6 +681,9 @@ struct AgoContext {
680681
cl_device_id opencl_device_list[16];
681682
char opencl_build_options[256];
682683
bool isAmdMediaOpsSupported;
684+
vx_size opencl_mem_alloc_size;
685+
vx_size opencl_mem_alloc_count;
686+
vx_size opencl_mem_release_count;
683687
#endif
684688
AgoTargetAffinityInfo_ attr_affinity;
685689
public:

openvx/ago/ago_platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ using namespace std;
6666
#endif
6767

6868
#if ENABLE_OPENCL
69+
#if __APPLE__
70+
#include <opencl.h>
71+
#else
6972
#include <CL/cl.h>
7073
#endif
74+
#endif
7175

7276
// platform specific shared library file extension
7377
#if _WIN32

openvx/ago/ago_util.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ void agoReplaceDataInGraph(AgoGraph * agraph, AgoData * dataFind, AgoData * data
517517
// replace all ROI master links
518518
for (AgoData * adata = agraph->dataList.head; adata; adata = adata->next) {
519519
if (adata->ref.type == VX_TYPE_IMAGE && adata->u.img.isROI && adata->u.img.roiMasterImage == dataFind) {
520+
dataFind->roiDepList.remove(adata);
520521
adata->u.img.roiMasterImage = dataReplace;
522+
adata->import_type = dataReplace->import_type;
523+
dataReplace->roiDepList.push_back(adata);
521524
}
522525
}
523526

@@ -1149,6 +1152,8 @@ int agoGetDataFromDescription(AgoContext * acontext, AgoGraph * agraph, AgoData
11491152
data->isInitialized = dataMaster->isInitialized;
11501153
data->u.img = dataMaster->u.img;
11511154
data->u.img.roiMasterImage = dataMaster;
1155+
data->import_type = dataMaster->import_type;
1156+
dataMaster->roiDepList.push_back(data);
11521157
data->u.img.isROI = vx_true_e;
11531158
data->u.img.rect_roi = rect;
11541159
data->u.img.width = data->u.img.rect_roi.end_x - data->u.img.rect_roi.start_x;
@@ -1166,6 +1171,8 @@ int agoGetDataFromDescription(AgoContext * acontext, AgoGraph * agraph, AgoData
11661171
data->children[child]->isInitialized = dataMaster->children[child]->isInitialized;
11671172
data->children[child]->u.img = dataMaster->children[child]->u.img;
11681173
data->children[child]->u.img.roiMasterImage = dataMaster->children[child];
1174+
data->children[child]->import_type = dataMaster->children[child]->import_type;
1175+
dataMaster->children[child]->roiDepList.push_back(data->children[child]);
11691176
data->children[child]->u.img.isROI = vx_true_e;
11701177
data->children[child]->u.img.rect_roi = rect;
11711178
data->children[child]->parent = data;
@@ -2145,8 +2152,13 @@ int agoDataSanityCheckAndUpdate(AgoData * data)
21452152
agoGetImageComponentsAndPlanes(data->ref.context, data->u.img.format, &data->u.img.components, &data->u.img.planes, &data->u.img.pixel_size_in_bits, &data->u.img.color_space, &data->u.img.channel_range);
21462153
// calculate other attributes and buffer size:
21472154
// - make sure that the stride is multiple of 16 bytes
2148-
data->u.img.stride_in_bytes = ALIGN16((data->u.img.width * data->u.img.pixel_size_in_bits + 7) >> 3);
2149-
data->size = ALIGN16(data->u.img.height) * data->u.img.stride_in_bytes;
2155+
if (data->import_type == VX_IMPORT_TYPE_NONE) {
2156+
data->u.img.stride_in_bytes = ALIGN16((data->u.img.width * data->u.img.pixel_size_in_bits + 7) >> 3);
2157+
data->size = ALIGN16(data->u.img.height) * data->u.img.stride_in_bytes;
2158+
}
2159+
else {
2160+
data->size = data->u.img.height * data->u.img.stride_in_bytes;
2161+
}
21502162
if (!data->size)
21512163
return -1;
21522164
if (data->u.img.isUniform) {
@@ -3076,6 +3088,7 @@ AgoContext::AgoContext()
30763088
, opencl_svmcaps{ 0 }
30773089
#endif
30783090
, opencl_context_imported{ false }, opencl_context{ nullptr }, opencl_cmdq{ nullptr }, opencl_config_flags{ 0 }, opencl_num_devices{ 0 }, isAmdMediaOpsSupported{ true }
3091+
, opencl_mem_alloc_size{ 0 }, opencl_mem_alloc_count{ 0 }, opencl_mem_release_count{ 0 }
30793092
#endif
30803093
{
30813094
memset(&kernelList, 0, sizeof(kernelList));
@@ -3163,6 +3176,13 @@ AgoContext::~AgoContext()
31633176
// remove kernel objects
31643177
agoResetKernelList(&kernelList);
31653178

3179+
#if ENABLE_OPENCL
3180+
if (opencl_mem_alloc_count > 0) {
3181+
agoAddLogEntry(&ref, VX_SUCCESS, "OK: OpenCL buffer usage: " VX_FMT_SIZE ", " VX_FMT_SIZE "/" VX_FMT_SIZE "\n",
3182+
opencl_mem_alloc_size, opencl_mem_release_count, opencl_mem_alloc_count);
3183+
}
3184+
#endif
3185+
31663186
// critical section
31673187
DeleteCriticalSection(&cs);
31683188
}

openvx/ago/ago_util_opencl.cpp

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static void clDumpBuffer(const char * fileNameFormat, cl_command_queue opencl_cm
3535
char fileName[1024]; sprintf(fileName, fileNameFormat, dumpBufferCount);
3636
cl_mem opencl_buffer = data->opencl_buffer;
3737
cl_uint opencl_buffer_offset = data->opencl_buffer_offset;
38-
cl_uint size = (cl_uint)data->size;
38+
cl_uint size = (cl_uint)(data->u.img.stride_in_bytes*data->u.img.height);
3939
FILE * fp = fopen(fileName, "wb"); if (!fp) { printf("ERROR: unable to create: %s\n", fileName); exit(1); }
4040
clFinish(opencl_cmdq);
4141
void * p = clEnqueueMapBuffer(opencl_cmdq, opencl_buffer, CL_TRUE, CL_MAP_READ, 0, opencl_buffer_offset + size, 0, NULL, NULL, NULL);
@@ -52,6 +52,26 @@ static void clDumpBuffer(const char * fileNameFormat, cl_command_queue opencl_cm
5252
#endif
5353

5454
#if ENABLE_OPENCL
55+
static cl_mem agoGpuOclCreateBuffer(AgoContext * context, cl_mem_flags flags, size_t size, void * host_ptr, cl_int * errcode_ret)
56+
{
57+
cl_mem mem = clCreateBuffer(context->opencl_context, flags, size, host_ptr, errcode_ret);
58+
if (mem) {
59+
context->opencl_mem_alloc_count++;
60+
context->opencl_mem_alloc_size += size;
61+
}
62+
return mem;
63+
}
64+
65+
static cl_mem agoGpuOclCreateImage(AgoContext * context, cl_mem_flags flags, const cl_image_format * image_format, const cl_image_desc * image_desc, void * host_ptr, cl_int * errcode_ret)
66+
{
67+
cl_mem mem = clCreateImage(context->opencl_context, flags, image_format, image_desc, host_ptr, errcode_ret);
68+
if (mem) {
69+
context->opencl_mem_alloc_count++;
70+
context->opencl_mem_alloc_size += image_desc->image_width; // TBD: currently assumes 8-bit 1D image
71+
}
72+
return mem;
73+
}
74+
5575
int agoGpuOclReleaseContext(AgoContext * context)
5676
{
5777
if (context->opencl_cmdq) {
@@ -114,6 +134,7 @@ int agoGpuOclReleaseData(AgoData * data)
114134
if (data->opencl_buffer_allocated) {
115135
clReleaseMemObject(data->opencl_buffer_allocated);
116136
data->opencl_buffer_allocated = NULL;
137+
data->ref.context->opencl_mem_release_count++;
117138
}
118139
#if defined(CL_VERSION_2_0)
119140
if (data->opencl_svm_buffer_allocated) {
@@ -342,17 +363,17 @@ int agoGpuOclAllocBuffer(AgoData * data)
342363
dataMaster->buffer = dataMaster->opencl_svm_buffer_allocated + dataMaster->opencl_buffer_offset;
343364
if (context->opencl_config_flags & CONFIG_OPENCL_SVM_AS_CLMEM) {
344365
// use svm buffer as opencl_buffer(GPU)
345-
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, dataMaster->size + dataMaster->opencl_buffer_offset, dataMaster->opencl_svm_buffer_allocated, &err);
366+
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, dataMaster->size + dataMaster->opencl_buffer_offset, dataMaster->opencl_svm_buffer_allocated, &err);
346367
}
347368
}
348369
else
349370
#endif
350371
{
351372
// allocate normal opencl_buffer
352-
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, dataMaster->size + dataMaster->opencl_buffer_offset, NULL, &err);
373+
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, dataMaster->size + dataMaster->opencl_buffer_offset, NULL, &err);
353374
}
354375
if (err) {
355-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d\n", context->opencl_context, (int)dataMaster->size + dataMaster->opencl_buffer_offset, err);
376+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d\n", context->opencl_context, (int)dataMaster->size + dataMaster->opencl_buffer_offset, err);
356377
return -1;
357378
}
358379
if (dataMaster->u.img.isUniform) {
@@ -412,14 +433,14 @@ int agoGpuOclAllocBuffer(AgoData * data)
412433
data->buffer = data->opencl_svm_buffer_allocated + data->opencl_buffer_offset;
413434
if (context->opencl_config_flags & CONFIG_OPENCL_SVM_AS_CLMEM) {
414435
// use svm buffer as opencl_buffer(GPU)
415-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, data->size + data->opencl_buffer_offset, data->opencl_svm_buffer_allocated, &err);
436+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, data->size + data->opencl_buffer_offset, data->opencl_svm_buffer_allocated, &err);
416437
}
417438
}
418439
else
419440
#endif
420441
{
421442
// normal opencl_buffer allocation
422-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, data->size + data->opencl_buffer_offset, NULL, &err);
443+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, data->size + data->opencl_buffer_offset, NULL, &err);
423444
if (data->opencl_buffer) {
424445
// initialize array header which containts numitems
425446
vx_uint32 zero = 0;
@@ -429,7 +450,7 @@ int agoGpuOclAllocBuffer(AgoData * data)
429450
}
430451
}
431452
if (err) {
432-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (array/cannystack)\n", context->opencl_context, (int)data->size, err);
453+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (array/cannystack)\n", context->opencl_context, (int)data->size, err);
433454
return -1;
434455
}
435456
}
@@ -444,19 +465,19 @@ int agoGpuOclAllocBuffer(AgoData * data)
444465
cl_int err = -1;
445466
cl_image_format format = { CL_INTENSITY, CL_UNORM_INT8 };
446467
cl_image_desc desc = { CL_MEM_OBJECT_IMAGE1D, 256, 0, 0, 1, 0, 0, 0, 0, NULL };
447-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateImage(context->opencl_context, CL_MEM_READ_WRITE, &format, &desc, NULL, &err);
468+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateImage(context, CL_MEM_READ_WRITE, &format, &desc, NULL, &err);
448469
if (err) {
449-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateImage(%p,CL_MEM_READ_WRITE,1D/U8,256,0,*) => %d (for LUT)\n", context->opencl_context, err);
470+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateImage(%p,CL_MEM_READ_WRITE,1D/U8,256,0,*) => %d (for LUT)\n", context->opencl_context, err);
450471
return -1;
451472
}
452473
data->opencl_buffer_offset = 0;
453474
}
454475
else {
455476
// normal opencl_buffer allocation
456477
cl_int err = -1;
457-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, data->size + data->opencl_buffer_offset, NULL, &err);
478+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, data->size + data->opencl_buffer_offset, NULL, &err);
458479
if (err) {
459-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,*) => %d (for LUT)\n", context->opencl_context, (int)(data->size + data->opencl_buffer_offset), err);
480+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,*) => %d (for LUT)\n", context->opencl_context, (int)(data->size + data->opencl_buffer_offset), err);
460481
return -1;
461482
}
462483
}
@@ -465,9 +486,9 @@ int agoGpuOclAllocBuffer(AgoData * data)
465486
else if (data->ref.type == VX_TYPE_REMAP) {
466487
if (!data->opencl_buffer) {
467488
cl_int err = -1;
468-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, data->size, NULL, &err);
489+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, data->size, NULL, &err);
469490
if (err) {
470-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Remap)\n", context->opencl_context, (int)data->size, err);
491+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Remap)\n", context->opencl_context, (int)data->size, err);
471492
return -1;
472493
}
473494
data->opencl_buffer_offset = 0;
@@ -476,9 +497,9 @@ int agoGpuOclAllocBuffer(AgoData * data)
476497
else if (data->ref.type == VX_TYPE_MATRIX) {
477498
if (!data->opencl_buffer) {
478499
cl_int err = -1;
479-
data->opencl_buffer = data->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, data->size, NULL, &err);
500+
data->opencl_buffer = data->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, data->size, NULL, &err);
480501
if (err) {
481-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Matrix)\n", context->opencl_context, (int)data->size, err);
502+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Matrix)\n", context->opencl_context, (int)data->size, err);
482503
return -1;
483504
}
484505
data->opencl_buffer_offset = 0;
@@ -488,9 +509,9 @@ int agoGpuOclAllocBuffer(AgoData * data)
488509
AgoData * dataMaster = data->u.tensor.roiMaster ? data->u.tensor.roiMaster : data; // to handle tensor ROI
489510
if (!dataMaster->opencl_buffer) {
490511
cl_int err = -1;
491-
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = clCreateBuffer(context->opencl_context, CL_MEM_READ_WRITE, dataMaster->size, NULL, &err);
512+
dataMaster->opencl_buffer = dataMaster->opencl_buffer_allocated = agoGpuOclCreateBuffer(context, CL_MEM_READ_WRITE, dataMaster->size, NULL, &err);
492513
if (err) {
493-
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Tensor)\n", context->opencl_context, (int)dataMaster->size, err);
514+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: agoGpuOclCreateBuffer(%p,CL_MEM_READ_WRITE,%d,0,*) => %d (for Tensor)\n", context->opencl_context, (int)dataMaster->size, err);
494515
return -1;
495516
}
496517
dataMaster->opencl_buffer_offset = 0;

openvx/api/vx_api.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxSwapImageHandle(vx_image image_, void* cons
867867
{
868868
AgoData * image = (AgoData *)image_;
869869
vx_status status = VX_ERROR_INVALID_REFERENCE;
870-
if (agoIsValidData(image, VX_TYPE_IMAGE)) {
870+
if (agoIsValidData(image, VX_TYPE_IMAGE) && !image->u.img.roiMasterImage) {
871871
CAgoLock lock(image->ref.context->cs);
872872
status = VX_ERROR_INVALID_PARAMETERS;
873873
if (image->import_type == VX_MEMORY_TYPE_HOST && num_planes == image->u.img.planes) {
@@ -880,7 +880,12 @@ VX_API_ENTRY vx_status VX_API_CALL vxSwapImageHandle(vx_image image_, void* cons
880880
image->children[i]->buffer_sync_flags &= ~AGO_BUFFER_SYNC_FLAG_DIRTY_MASK;
881881
image->children[i]->buffer_sync_flags |= AGO_BUFFER_SYNC_FLAG_DIRTY_BY_COMMIT;
882882
}
883-
// TBD: propagate to ROIs
883+
// propagate to ROIs
884+
for (auto roi = image->children[i]->roiDepList.begin(); roi != image->children[i]->roiDepList.end(); roi++) {
885+
(*roi)->buffer = image->children[i]->buffer +
886+
image->children[i]->u.img.rect_roi.start_y * image->children[i]->u.img.stride_in_bytes +
887+
((image->children[i]->u.img.rect_roi.start_x * image->children[i]->u.img.pixel_size_in_bits) >> 3);
888+
}
884889
}
885890
}
886891
else {
@@ -890,7 +895,12 @@ VX_API_ENTRY vx_status VX_API_CALL vxSwapImageHandle(vx_image image_, void* cons
890895
image->buffer_sync_flags &= ~AGO_BUFFER_SYNC_FLAG_DIRTY_MASK;
891896
image->buffer_sync_flags |= AGO_BUFFER_SYNC_FLAG_DIRTY_BY_COMMIT;
892897
}
893-
// TBD: propagate to ROIs
898+
// propagate to ROIs
899+
for (auto roi = image->roiDepList.begin(); roi != image->roiDepList.end(); roi++) {
900+
(*roi)->buffer = image->buffer +
901+
image->u.img.rect_roi.start_y * image->u.img.stride_in_bytes +
902+
((image->u.img.rect_roi.start_x * image->u.img.pixel_size_in_bits) >> 3);
903+
}
894904
}
895905
}
896906
#if ENABLE_OPENCL
@@ -904,7 +914,10 @@ VX_API_ENTRY vx_status VX_API_CALL vxSwapImageHandle(vx_image image_, void* cons
904914
image->children[i]->buffer_sync_flags &= ~AGO_BUFFER_SYNC_FLAG_DIRTY_MASK;
905915
image->children[i]->buffer_sync_flags |= AGO_BUFFER_SYNC_FLAG_DIRTY_BY_NODE_CL;
906916
}
907-
// TBD: propagate to ROIs
917+
// propagate to ROIs
918+
for (auto roi = image->children[i]->roiDepList.begin(); roi != image->children[i]->roiDepList.end(); roi++) {
919+
(*roi)->opencl_buffer = image->children[i]->opencl_buffer;
920+
}
908921
}
909922
}
910923
else {
@@ -914,7 +927,10 @@ VX_API_ENTRY vx_status VX_API_CALL vxSwapImageHandle(vx_image image_, void* cons
914927
image->buffer_sync_flags &= ~AGO_BUFFER_SYNC_FLAG_DIRTY_MASK;
915928
image->buffer_sync_flags |= AGO_BUFFER_SYNC_FLAG_DIRTY_BY_NODE_CL;
916929
}
917-
// TBD: propagate to ROIs
930+
// propagate to ROIs
931+
for (auto roi = image->roiDepList.begin(); roi != image->roiDepList.end(); roi++) {
932+
(*roi)->opencl_buffer = image->opencl_buffer;
933+
}
918934
}
919935
}
920936
#endif

0 commit comments

Comments
 (0)