Blender  V3.3
hydra/display_driver.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2022 NVIDIA Corporation
3  * Copyright 2022 Blender Foundation */
4 
5 #pragma once
6 
7 #include "hydra/config.h"
9 #include "util/thread.h"
10 
11 #include <pxr/imaging/hgi/hgi.h>
12 #include <pxr/imaging/hgi/texture.h>
13 
15 
16 class HdCyclesDisplayDriver final : public CCL_NS::DisplayDriver {
17  public:
18  HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi);
20 
21  private:
22  void next_tile_begin() override;
23 
24  bool update_begin(const Params &params, int texture_width, int texture_height) override;
25  void update_end() override;
26 
27  void flush() override;
28 
29  CCL_NS::half4 *map_texture_buffer() override;
30  void unmap_texture_buffer() override;
31 
32  GraphicsInterop graphics_interop_get() override;
33 
34  void graphics_interop_activate() override;
35  void graphics_interop_deactivate() override;
36 
37  void clear() override;
38 
39  void draw(const Params &params) override;
40 
41  void gl_context_create();
42  bool gl_context_enable();
43  void gl_context_disable();
44  void gl_context_dispose();
45 
46  HdCyclesSession *const _renderParam;
47  Hgi *const _hgi;
48 
49 #ifdef _WIN32
50  void *hdc_ = nullptr;
51  void *gl_context_ = nullptr;
52 #endif
53  CCL_NS::thread_mutex mutex_;
54 
55  PXR_NS::HgiTextureHandle texture_;
56  unsigned int gl_pbo_id_ = 0;
57  CCL_NS::int2 pbo_size_ = CCL_NS::make_int2(0, 0);
58  bool need_update_ = false;
59  std::atomic_bool need_clear_ = false;
60 
61  void *gl_render_sync_ = nullptr;
62  void *gl_upload_sync_ = nullptr;
63 };
64 
#define final(a, b, c)
Definition: BLI_hash.h:21
int int2[2]
HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi)
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE
Definition: hydra/config.h:17
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define make_int2(x, y)
Definition: metal/compat.h:206
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
Definition: thread.h:27