Blender
V5.0
source
blender
blenlib
intern
compute_context.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
BLI_compute_context.hh
"
10
#include "
BLI_stack.hh
"
11
12
#include <sstream>
13
#include <xxhash.h>
14
15
namespace
blender
{
16
17
ComputeContextHash
ComputeContextHash::from_bytes(
const
void
*
data
,
const
int64_t
len
)
18
{
19
ComputeContextHash final_hash;
20
const
XXH128_hash_t
hash
= XXH3_128bits(
data
,
len
);
21
/* Cast to void * to avoid warnings. */
22
memcpy(
static_cast<
void
*
>
(&final_hash), &
hash
,
sizeof
(
hash
));
23
static_assert
(
sizeof
(ComputeContextHash) ==
sizeof
(
hash
));
24
return
final_hash;
25
}
26
27
std::ostream &
operator<<
(std::ostream &stream,
const
ComputeContextHash
&
hash
)
28
{
29
std::stringstream ss;
30
ss <<
"0x"
<< std::hex <<
hash
.v1 <<
hash
.v2;
31
stream << ss.str();
32
return
stream;
33
}
34
35
void
ComputeContext::print_stack
(std::ostream &stream,
StringRef
name
)
const
36
{
37
Stack<const ComputeContext *>
stack;
38
for
(
const
ComputeContext
*current =
this
; current; current = current->parent_) {
39
stack.
push
(current);
40
}
41
stream <<
"Context Stack: "
<<
name
<<
"\n"
;
42
while
(!stack.
is_empty
()) {
43
const
ComputeContext
*current = stack.
pop
();
44
stream <<
"-> "
;
45
current->
print_current_in_line
(stream);
46
const
ComputeContextHash
¤t_hash = current->
hash_
;
47
stream <<
" \t(hash: "
<< current_hash <<
")\n"
;
48
}
49
}
50
51
std::ostream &
operator<<
(std::ostream &stream,
const
ComputeContext
&compute_context)
52
{
53
compute_context.
print_stack
(stream,
""
);
54
return
stream;
55
}
56
57
}
// namespace blender
BLI_compute_context.hh
BLI_stack.hh
data
BMesh const char void * data
Definition
bmesh_iterators_inline.hh:37
int64_t
long long int int64_t
Definition
btConvexHullComputer.cpp:31
blender::ComputeContext::ComputeContext
ComputeContext(const ComputeContext *parent)
Definition
BLI_compute_context.hh:111
blender::ComputeContext::print_stack
void print_stack(std::ostream &stream, StringRef name) const
Definition
compute_context.cc:35
blender::ComputeContext::hash_
ComputeContextHash hash_
Definition
BLI_compute_context.hh:105
blender::ComputeContext::print_current_in_line
virtual void print_current_in_line(std::ostream &stream) const =0
blender::Stack
Definition
BLI_stack.hh:70
blender::Stack::is_empty
bool is_empty() const
Definition
BLI_stack.hh:308
blender::Stack::pop
T pop()
Definition
BLI_stack.hh:242
blender::Stack::push
void push(const T &value)
Definition
BLI_stack.hh:213
blender::StringRef
Definition
BLI_string_ref.hh:150
blender
Definition
ANIM_action.hh:36
blender::operator<<
std::ostream & operator<<(std::ostream &stream, const eAlpha &space)
Definition
BLI_color.cc:15
name
const char * name
Definition
python_compat.hh:32
blender::ComputeContextHash
Definition
BLI_compute_context.hh:49
blender::ComputeContextHash::hash
uint64_t hash() const
Definition
BLI_compute_context.hh:53
len
uint len
Definition
uvedit_unwrap_ops.cc:2126
Generated on
for Blender by
doxygen
1.16.1