Fixed rendering for MacOS #82

Merged
Bogdan Nagirniak merged 10 commits from BLEN-473 into hydra-render 2023-08-02 09:37:25 +02:00
3 changed files with 22 additions and 13 deletions
Showing only changes of commit e6a5bd7351 - Show all commits

View File

@ -62,6 +62,7 @@ set(INC_SYS
${BOOST_INCLUDE_DIR}
${TBB_INCLUDE_DIR}
${GFLAGS_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
set(LIB

View File

@ -13,8 +13,9 @@
#include "MEM_guardedalloc.h"
#include "Eigen/Core"
#include "engine.h"
#include "render_task_delegate.h"
namespace blender::render::hydra {
@ -127,19 +128,29 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText());
}
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
BogdanNagirniak marked this conversation as resolved Outdated

Revert float -> void

Revert `float` -> `void`
{
pxr::HdRenderBuffer *buffer = static_cast<pxr::HdRenderBuffer *>(
GetRenderIndex().GetBprim(pxr::HdPrimTypeTokens->renderBuffer, buffer_id(aov_key)));
if (!buffer) {
return;
}
void *buf_data = buffer->Map();
memcpy(data,
buf_data,
buffer->GetWidth() * buffer->GetHeight() * pxr::HdDataSizeOfFormat(buffer->GetFormat()));
pxr::HdFormat format = buffer->GetFormat();
size_t len = buffer->GetWidth() * buffer->GetHeight() * pxr::HdGetComponentCount(format);
if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat32) {
float *buf_data = (float *)buffer->Map();
memcpy(data, buf_data, len * sizeof(float));
buffer->Unmap();
}
else if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat16) {
BogdanNagirniak marked this conversation as resolved Outdated

Add else

Add `else`
Eigen::half *buf_data = (Eigen::half *)buffer->Map();
for (size_t i = 0; i < len; ++i) {
data[i] = buf_data[i];
}
buffer->Unmap();
}
}
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, GPUTexture *texture)
{
@ -228,7 +239,7 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText());
}
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
BogdanNagirniak marked this conversation as resolved Outdated

Revert float -> void

Revert `float` -> `void`
{
GPUTexture *tex = nullptr;
int c;
@ -253,14 +264,11 @@ void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, GPUTexture *texture)
{
GPUTexture *tex = nullptr;
int c;
if (aov_key == pxr::HdAovTokens->color) {
tex = tex_color_;
c = 4;
}
else if (aov_key == pxr::HdAovTokens->depth) {
tex = tex_depth_;
c = 1;
}
if (!tex) {
return;

View File

@ -34,7 +34,7 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate {
virtual bool is_converged();
virtual void set_viewport(pxr::GfVec4d const &viewport);
virtual void add_aov(pxr::TfToken const &aov_key);
virtual void read_aov(pxr::TfToken const &aov_key, void *data);
virtual void read_aov(pxr::TfToken const &aov_key, float *data);
virtual void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture);
virtual void bind();
virtual void unbind();
@ -56,7 +56,7 @@ class GPURenderTaskDelegate : public RenderTaskDelegate {
void set_viewport(pxr::GfVec4d const &viewport) override;
void add_aov(pxr::TfToken const &aov_key) override;
void read_aov(pxr::TfToken const &aov_key, void *data) override;
void read_aov(pxr::TfToken const &aov_key, float *data) override;
void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture) override;
void bind() override;
void unbind() override;