Add "stageMetersPerUnit" render setting for USD files that have that set to something other than the default (e.g. exported by Blender). And fix a crash when an application creates a Hydra render pass on a thread that does not have an OpenGL context current.
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
/* SPDX-License-Identifier: Apache-2.0
|
|
* Copyright 2022 NVIDIA Corporation
|
|
* Copyright 2022 Blender Foundation */
|
|
|
|
#pragma once
|
|
|
|
#include "hydra/config.h"
|
|
#include "session/display_driver.h"
|
|
#include "util/thread.h"
|
|
|
|
#include <pxr/imaging/hgi/hgi.h>
|
|
#include <pxr/imaging/hgi/texture.h>
|
|
|
|
HDCYCLES_NAMESPACE_OPEN_SCOPE
|
|
|
|
class HdCyclesDisplayDriver final : public CCL_NS::DisplayDriver {
|
|
public:
|
|
HdCyclesDisplayDriver(HdCyclesSession *renderParam, Hgi *hgi);
|
|
~HdCyclesDisplayDriver();
|
|
|
|
private:
|
|
void init();
|
|
void deinit();
|
|
|
|
void next_tile_begin() override;
|
|
|
|
bool update_begin(const Params ¶ms, int texture_width, int texture_height) override;
|
|
void update_end() override;
|
|
|
|
void flush() override;
|
|
|
|
CCL_NS::half4 *map_texture_buffer() override;
|
|
void unmap_texture_buffer() override;
|
|
|
|
GraphicsInterop graphics_interop_get() override;
|
|
|
|
void graphics_interop_activate() override;
|
|
void graphics_interop_deactivate() override;
|
|
|
|
void clear() override;
|
|
|
|
void draw(const Params ¶ms) override;
|
|
|
|
HdCyclesSession *const _renderParam;
|
|
Hgi *const _hgi;
|
|
|
|
#ifdef _WIN32
|
|
void *hdc_ = nullptr;
|
|
void *gl_context_ = nullptr;
|
|
#endif
|
|
|
|
CCL_NS::thread_mutex mutex_;
|
|
|
|
PXR_NS::HgiTextureHandle texture_;
|
|
unsigned int gl_pbo_id_ = 0;
|
|
CCL_NS::int2 pbo_size_ = CCL_NS::make_int2(0, 0);
|
|
bool need_update_ = false;
|
|
std::atomic_bool need_clear_ = false;
|
|
|
|
void *gl_render_sync_ = nullptr;
|
|
void *gl_upload_sync_ = nullptr;
|
|
};
|
|
|
|
HDCYCLES_NAMESPACE_CLOSE_SCOPE
|