1 /*
2 * Copyright (c) 2022-2023, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file media_debug_fast_dump.cpp
24 //!
25
26 #include "media_debug_fast_dump_imp.hpp"
27
28 #if USE_MEDIA_DEBUG_TOOL
29
30 namespace
31 {
32 std::unique_ptr<MediaDebugFastDumpImp> imp = nullptr;
33 } // namespace
34
CreateInstance(MOS_INTERFACE & osItf,MediaCopyWrapper & mediaCopyWrapper,const Config * cfg)35 void MediaDebugFastDump::CreateInstance(
36 MOS_INTERFACE &osItf,
37 MediaCopyWrapper &mediaCopyWrapper,
38 const Config *cfg)
39 {
40 if (imp == nullptr)
41 {
42 imp =
43 #if __cplusplus < 201402L
44 decltype(imp)(
45 new MediaDebugFastDumpImp(osItf, mediaCopyWrapper, cfg));
46 #else
47 std::make_unique<MediaDebugFastDumpImp>(osItf, mediaCopyWrapper, cfg);
48 #endif
49 }
50 }
51
DestroyInstance()52 void MediaDebugFastDump::DestroyInstance()
53 {
54 if (imp)
55 {
56 imp.reset();
57 }
58 }
59
IsGood()60 bool MediaDebugFastDump::IsGood()
61 {
62 return imp != nullptr && imp->IsGood();
63 }
64
Dump(MOS_RESOURCE & res,std::string && name,size_t dumpSize,size_t offset,std::function<void (std::ostream &,const void *,size_t)> && serializer)65 void MediaDebugFastDump::Dump(
66 MOS_RESOURCE &res,
67 std::string &&name,
68 size_t dumpSize,
69 size_t offset,
70 std::function<
71 void(std::ostream &, const void *, size_t)>
72 &&serializer)
73 {
74 if (imp)
75 {
76 (*imp)(res, std::move(name), dumpSize, offset, std::move(serializer));
77 }
78 }
79
Dump(const void * res,std::string && name,size_t dumpSize,size_t offset,std::function<void (std::ostream &,const void *,size_t)> && serializer)80 void MediaDebugFastDump::Dump(
81 const void *res,
82 std::string &&name,
83 size_t dumpSize,
84 size_t offset,
85 std::function<
86 void(std::ostream &, const void *, size_t)>
87 &&serializer)
88 {
89 if (imp)
90 {
91 (*imp)(res, std::move(name), dumpSize, offset, std::move(serializer));
92 }
93 }
94
95 #endif // USE_MEDIA_DEBUG_TOOL
96