mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-25 18:22:05 +08:00
kinda works
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -119,5 +119,5 @@ public:
|
||||
|
||||
private:
|
||||
LoadYUVState loadyuv;
|
||||
cl_mem net_input_cl, input_frames_cl;
|
||||
cl_mem img_buffer_cl, input_frames_cl;
|
||||
};
|
||||
Reference in New Issue
Block a user