kinda works

This commit is contained in:
DevTekVE
2025-01-01 21:24:57 +01:00
parent 5a3ee2d376
commit aba1f4b5fc
2 changed files with 9 additions and 10 deletions
+8 -9
View File
@@ -46,8 +46,8 @@ DrivingModelFrame<T>::~DrivingModelFrame() {
DrivingModelFrameLegacy::DrivingModelFrameLegacy(cl_device_id device_id, cl_context context) : ModelFrame(device_id, context) {
input_frames = std::make_unique<float[]>(buf_size);
input_frames_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err));
net_input_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, frame_size_bytes, NULL, &err));
input_frames_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, frame_size_bytes, NULL, &err));
img_buffer_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, frame_size_bytes, NULL, &err));
loadyuv_init(&loadyuv, context, device_id, MODEL_WIDTH, MODEL_HEIGHT, true);
init_transform(device_id, context, MODEL_WIDTH, MODEL_HEIGHT);
@@ -55,20 +55,19 @@ DrivingModelFrameLegacy::DrivingModelFrameLegacy(cl_device_id device_id, cl_cont
cl_mem* DrivingModelFrameLegacy::prepare(cl_mem yuv_cl, int frame_width, int frame_height, int frame_stride, int frame_uv_offset, const mat3& projection) {
run_transform(yuv_cl, MODEL_WIDTH, MODEL_HEIGHT, frame_width, frame_height, frame_stride, frame_uv_offset, projection);
loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, net_input_cl);
CL_CHECK(clEnqueueReadBuffer(q, net_input_cl, CL_TRUE, 0, frame_size_bytes, &input_frames[0], 0, nullptr, nullptr));
copy_queue(&loadyuv, q, net_input_cl, input_frames_cl, 0, 0, frame_size_bytes);
// NOTE: Since thneed is using a different command queue, this clFinish is needed to ensure the image is ready.
CL_CHECK(clEnqueueCopyBuffer(q, img_buffer_cl, img_buffer_cl, 0, buf_size, buf_size, 0, nullptr, nullptr));
loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, img_buffer_cl);
CL_CHECK(clEnqueueCopyBuffer(q, img_buffer_cl, input_frames_cl, 0, 0, frame_size_bytes, 0, nullptr, nullptr));
clFinish(q);
// Return the pointer to the final buffer
return &input_frames_cl;
}
DrivingModelFrameLegacy::~DrivingModelFrameLegacy() {
deinit_transform();
loadyuv_destroy(&loadyuv);
CL_CHECK(clReleaseMemObject(net_input_cl));
CL_CHECK(clReleaseMemObject(img_buffer_cl));
CL_CHECK(clReleaseMemObject(input_frames_cl));
CL_CHECK(clReleaseCommandQueue(q));
}
+1 -1
View File
@@ -119,5 +119,5 @@ public:
private:
LoadYUVState loadyuv;
cl_mem net_input_cl, input_frames_cl;
cl_mem img_buffer_cl, input_frames_cl;
};