Blender
V4.3
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
5
#include "
BLI_compute_context.hh
"
6
7
#include <sstream>
8
#include <xxhash.h>
9
10
namespace
blender
{
11
12
void
ComputeContextHash::mix_in
(
const
void
*data,
int64_t
len
)
13
{
14
const
int64_t
hash_size =
sizeof
(
ComputeContextHash
);
15
const
int64_t
buffer_len = hash_size +
len
;
16
DynamicStackBuffer<>
buffer_owner(buffer_len, 8);
17
char
*buffer =
static_cast<
char
*
>
(buffer_owner.
buffer
());
18
memcpy(buffer,
this
, hash_size);
19
memcpy(buffer + hash_size, data,
len
);
20
21
const
XXH128_hash_t
hash
= XXH3_128bits(buffer, buffer_len);
22
memcpy(
this
, &
hash
,
sizeof
(
hash
));
23
static_assert
(
sizeof
(
ComputeContextHash
) ==
sizeof
(
hash
));
24
}
25
26
std::ostream &
operator<<
(std::ostream &stream,
const
ComputeContextHash
&
hash
)
27
{
28
std::stringstream ss;
29
ss <<
"0x"
<< std::hex <<
hash
.v1 <<
hash
.v2;
30
stream << ss.str();
31
return
stream;
32
}
33
34
void
ComputeContext::print_stack
(std::ostream &stream,
StringRef
name)
const
35
{
36
Stack<const ComputeContext *>
stack;
37
for
(
const
ComputeContext
*current =
this
; current; current = current->parent_) {
38
stack.
push
(current);
39
}
40
stream <<
"Context Stack: "
<< name <<
"\n"
;
41
while
(!stack.
is_empty
()) {
42
const
ComputeContext
*current = stack.
pop
();
43
stream <<
"-> "
;
44
current->print_current_in_line(stream);
45
const
ComputeContextHash
¤t_hash = current->hash_;
46
stream <<
" \t(hash: "
<< current_hash <<
")\n"
;
47
}
48
}
49
50
std::ostream &
operator<<
(std::ostream &stream,
const
ComputeContext
&compute_context)
51
{
52
compute_context.
print_stack
(stream,
""
);
53
return
stream;
54
}
55
56
}
// namespace blender
BLI_compute_context.hh
blender::ComputeContext
Definition
BLI_compute_context.hh:73
blender::ComputeContext::print_stack
void print_stack(std::ostream &stream, StringRef name) const
Definition
compute_context.cc:34
blender::DynamicStackBuffer
Definition
BLI_memory_utils.hh:231
blender::DynamicStackBuffer::buffer
void * buffer() const
Definition
BLI_memory_utils.hh:262
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:128
len
int len
Definition
draw_manager_c.cc:115
blender
Definition
ANIM_action.hh:36
blender::operator<<
std::ostream & operator<<(std::ostream &stream, const eAlpha &space)
Definition
BLI_color.cc:11
hash
#define hash
Definition
noise.c:154
int64_t
__int64 int64_t
Definition
stdint.h:89
blender::ComputeContextHash
Definition
BLI_compute_context.hh:51
blender::ComputeContextHash::hash
uint64_t hash() const
Definition
BLI_compute_context.hh:55
blender::ComputeContextHash::mix_in
void mix_in(const void *data, int64_t len)
Definition
compute_context.cc:12
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0