Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
99186f1f
Commit
99186f1f
authored
Apr 05, 2013
by
highgod0401
Committed by
Michael Niedermayer
Apr 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug of finding CPU device
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
9a8f1e72
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
28 deletions
+20
-28
opencl.c
libavutil/opencl.c
+20
-28
No files found.
libavutil/opencl.c
View file @
99186f1f
...
...
@@ -91,6 +91,9 @@ static OpenclUtils openclutils = {&openclutils_class};
static
GPUEnv
gpu_env
;
static
const
cl_device_type
device_type
[]
=
{
CL_DEVICE_TYPE_GPU
,
CL_DEVICE_TYPE_CPU
,
CL_DEVICE_TYPE_DEFAULT
};
typedef
struct
{
int
err_code
;
const
char
*
err_str
;
...
...
@@ -276,8 +279,8 @@ static int init_opencl_env(GPUEnv *gpu_env, AVOpenCLExternalEnv *ext_opencl_env)
cl_platform_id
*
platform_ids
=
NULL
;
cl_context_properties
cps
[
3
];
char
platform_name
[
100
];
int
i
,
ret
=
0
;
cl_device_type
device_type
[]
=
{
CL_DEVICE_TYPE_GPU
,
CL_DEVICE_TYPE_CPU
,
CL_DEVICE_TYPE_DEFAULT
};
int
i
,
j
,
ret
=
0
;
if
(
ext_opencl_env
)
{
if
(
gpu_env
->
is_user_created
)
return
0
;
...
...
@@ -328,22 +331,10 @@ static int init_opencl_env(GPUEnv *gpu_env, AVOpenCLExternalEnv *ext_opencl_env)
goto
end
;
}
gpu_env
->
platform_id
=
platform_ids
[
i
];
status
=
clGetDeviceIDs
(
gpu_env
->
platform_id
,
CL_DEVICE_TYPE_GPU
,
0
,
NULL
,
&
num_devices
);
if
(
status
!=
CL_SUCCESS
)
{
av_log
(
&
openclutils
,
AV_LOG_ERROR
,
"Could not get OpenCL device number:%s
\n
"
,
opencl_errstr
(
status
));
ret
=
AVERROR_EXTERNAL
;
goto
end
;
}
if
(
num_devices
==
0
)
{
//find CPU device
status
=
clGetDeviceIDs
(
gpu_env
->
platform_id
,
CL_DEVICE_TYPE_CPU
,
0
,
NULL
,
&
num_devices
);
}
if
(
status
!=
CL_SUCCESS
)
{
av_log
(
&
openclutils
,
AV_LOG_ERROR
,
"Could not get OpenCL device ids: %s
\n
"
,
opencl_errstr
(
status
));
ret
=
AVERROR
(
EINVAL
);
goto
end
;
for
(
j
=
0
;
j
<
FF_ARRAY_ELEMS
(
device_type
);
j
++
)
{
status
=
clGetDeviceIDs
(
gpu_env
->
platform_id
,
device_type
[
j
],
0
,
NULL
,
&
num_devices
);
if
(
status
==
CL_SUCCESS
)
break
;
}
if
(
num_devices
)
break
;
...
...
@@ -352,8 +343,15 @@ static int init_opencl_env(GPUEnv *gpu_env, AVOpenCLExternalEnv *ext_opencl_env)
ret
=
AVERROR_EXTERNAL
;
goto
end
;
}
if
(
i
>=
num_platforms
-
1
)
{
if
(
status
!=
CL_SUCCESS
)
{
av_log
(
&
openclutils
,
AV_LOG_ERROR
,
"Could not get OpenCL device ids: %s
\n
"
,
opencl_errstr
(
status
));
ret
=
AVERROR
(
EINVAL
);
goto
end
;
}
}
i
++
;
}
}
if
(
!
gpu_env
->
platform_id
)
{
...
...
@@ -378,22 +376,16 @@ static int init_opencl_env(GPUEnv *gpu_env, AVOpenCLExternalEnv *ext_opencl_env)
cps
[
2
]
=
0
;
/* Check for GPU. */
for
(
i
=
0
;
i
<
sizeof
(
device_type
);
i
++
)
{
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
device_type
);
i
++
)
{
gpu_env
->
device_type
=
device_type
[
i
];
gpu_env
->
context
=
clCreateContextFromType
(
cps
,
gpu_env
->
device_type
,
NULL
,
NULL
,
&
status
);
if
(
status
!=
CL_SUCCESS
)
{
av_log
(
&
openclutils
,
AV_LOG_ERROR
,
"Could not get OpenCL context from device type: %s
\n
"
,
opencl_errstr
(
status
));
ret
=
AVERROR_EXTERNAL
;
goto
end
;
}
if
(
gpu_env
->
context
)
if
(
status
==
CL_SUCCESS
)
break
;
}
if
(
!
gpu_env
->
context
)
{
av_log
(
&
openclutils
,
AV_LOG_ERROR
,
"Could not get OpenCL context from device type
\n
"
);
"Could not get OpenCL context from device type
: %s
\n
"
,
opencl_errstr
(
status
)
);
ret
=
AVERROR_EXTERNAL
;
goto
end
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment