Blender V5.3
draw_resource.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BKE_duplilist.hh"
10#include "BLI_ghash.hh"
11#include "GPU_material.hh"
12
13#include "draw_handle.hh"
14#include "draw_shader_shared.hh"
15
16namespace blender {
17
18/* -------------------------------------------------------------------- */
21
22bool ObjectAttribute::sync(const draw::ObjectRef &ref,
23 const GPUUniformAttr &attr,
25{
26 /* This function mirrors `lookup_instance_property` in `cycles/blender/blender_object.cpp`. */
27 hash_code = attr.hash_code;
28 return ref.find_rgba_attribute(attr, instance_index, &data_x);
29}
30
31bool ObjectAttribute::sync(const draw::ObjectRef &ref,
32 const char *name,
33 bool use_dupli,
35{
36 /* Mimic gpu_node_graph_add_uniform_attribute */
37 hash_code = BLI_ghashutil_strhash_p(name) << 1 | (use_dupli ? 0 : 1);
38 return ref.find_rgba_attribute(name, use_dupli, instance_index, &data_x);
39}
40
42
43/* -------------------------------------------------------------------- */
46
47bool LayerAttribute::sync(const Scene *scene, const ViewLayer *layer, const GPULayerAttr &attr)
48{
49 hash_code = attr.hash_code;
50
51 return BKE_view_layer_find_rgba_attribute(scene, layer, attr.name, &data.x);
52}
53
55
56} // namespace blender
Definition scene.h:133
#define instance_index
#define layer
BMesh Iterators.
bool BKE_view_layer_find_rgba_attribute(const Scene *scene, const ViewLayer *layer, const char *name, float r_value[4])
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
bool sync(const Scene *scene, const ViewLayer *layer, const GPULayerAttr &attr)
bool sync(const draw::ObjectRef &ref, const GPUUniformAttr &attr, int instance_index)