Skip to content

Commit

Permalink
Extract OpenGL 3.0 & OpenGL 3.1 conversion methods into a separate li…
Browse files Browse the repository at this point in the history
…brary & add test

PiperOrigin-RevId: 597350676
  • Loading branch information
MediaPipe Team authored and copybara-github committed Jan 10, 2024
1 parent ad287c8 commit e8bf46f
Show file tree
Hide file tree
Showing 11 changed files with 871 additions and 203 deletions.
86 changes: 75 additions & 11 deletions mediapipe/calculators/tensor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ cc_library(
deps = [
":tensor_converter_calculator_cc_proto",
":tensor_converter_cpu",
":tensor_converter_gpu",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:port",
"//mediapipe/framework/formats:image_frame",
Expand All @@ -667,8 +668,6 @@ cc_library(
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:statusor",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:gpu_buffer_format",
"//mediapipe/gpu:gpu_origin_cc_proto",
"//mediapipe/util:resource_util",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:absl_check",
Expand All @@ -679,19 +678,16 @@ cc_library(
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
] + select({
"//mediapipe/gpu:disable_gpu": [],
"//mediapipe:apple": [
":tensor_converter_calculator_gpu_deps",
],
"//conditions:default": [
"tensor_converter_calculator_gpu_deps",
":tensor_converter_calculator_gpu_deps",
":tensor_converter_gl30",
":tensor_converter_gl31",
"//mediapipe/gpu:gl_base",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:shader_util",
],
}) + select({
"//mediapipe:apple": [
"//third_party/apple_frameworks:MetalKit",
],
"//conditions:default": [],
}),
alwayslink = 1,
)
Expand Down Expand Up @@ -725,6 +721,73 @@ cc_test(
],
)

cc_library(
name = "tensor_converter_gpu",
hdrs = ["tensor_converter_gpu.h"],
deps = [
"//mediapipe/framework/formats:tensor",
"//mediapipe/gpu:gpu_buffer",
"@com_google_absl//absl/status",
],
)

cc_library(
name = "tensor_converter_gl30",
srcs = ["tensor_converter_gl30.cc"],
hdrs = ["tensor_converter_gl30.h"],
features = ["-layering_check"], # allow depending on tensor_converter_calculator_gpu_deps
deps = [
":tensor_converter_gpu",
"//mediapipe/framework:port",
] + select({
"//mediapipe:apple": [],
"//conditions:default": [
":tensor_converter_calculator_gpu_deps",
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/formats:image_frame",
"//mediapipe/framework/formats:matrix",
"//mediapipe/framework/formats:tensor",
"//mediapipe/framework/port:ret_check",
"//mediapipe/gpu:gl_base_hdr",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_context",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:gl_texture_view",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:gpu_buffer_format",
"//mediapipe/gpu:shader_util",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
}),
)

cc_library(
name = "tensor_converter_gl31",
srcs = ["tensor_converter_gl31.cc"],
hdrs = ["tensor_converter_gl31.h"],
features = ["-layering_check"], # allow depending on tensor_converter_calculator_gpu_deps
deps = [
":tensor_converter_gpu",
"//mediapipe/framework:port",
] + select({
"//mediapipe:apple": [],
"//conditions:default": [
":tensor_converter_calculator_gpu_deps",
"//mediapipe/framework:calculator_context",
"//mediapipe/framework/formats:tensor",
"//mediapipe/framework/port:ret_check",
"//mediapipe/gpu:gl_calculator_helper",
"//mediapipe/gpu:gl_simple_shaders",
"//mediapipe/gpu:gpu_buffer",
"//mediapipe/gpu:shader_util",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
}),
)

cc_library(
name = "tensor_converter_calculator_gpu_deps",
visibility = ["//visibility:private"],
Expand All @@ -737,6 +800,7 @@ cc_library(
"//mediapipe/gpu:MPPMetalHelper",
"//mediapipe/gpu:MPPMetalUtil",
"//mediapipe/objc:mediapipe_framework_ios",
"//third_party/apple_frameworks:MetalKit",
],
# This setting is needed to allow bazel to build all targets on Mac with GPU disabled
":platform_apple_without_gpu": [],
Expand Down
Loading

0 comments on commit e8bf46f

Please sign in to comment.