Remove Z Buffer from ImBuf #109687

Merged
Sergey Sharybin merged 4 commits from Sergey/blender:imbuf_z_buffer into main 2023-07-04 17:03:10 +02:00
43 changed files with 48 additions and 659 deletions

View File

@ -78,7 +78,6 @@ char BKE_ftype_to_imtype(int ftype, const struct ImbFormatOptions *options);
int BKE_imtype_to_ftype(char imtype, struct ImbFormatOptions *r_options);
bool BKE_imtype_is_movie(char imtype);
bool BKE_imtype_supports_zbuf(char imtype);
bool BKE_imtype_supports_compress(char imtype);
bool BKE_imtype_supports_quality(char imtype);
bool BKE_imtype_requires_linear_float(char imtype);

View File

@ -2550,7 +2550,7 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *filepath, const ImageFormatData *im
BLI_file_ensure_parent_dir_exists(filepath);
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat);
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect);
if (ok == 0) {
perror(filepath);
}
@ -4320,7 +4320,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
{
Render *re;
RenderView *rv;
RenderBuffer *combined_buffer, *z_buffer;
RenderBuffer *combined_buffer;
RenderByteBuffer *byte_buffer;
float dither;
int channels, layer, pass;
@ -4382,12 +4382,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
if (rv == nullptr) {
byte_buffer = &rres.byte_buffer;
combined_buffer = &rres.combined_buffer;
z_buffer = &rres.z_buffer;
}
else {
byte_buffer = &rv->byte_buffer;
combined_buffer = &rv->combined_buffer;
z_buffer = &rv->z_buffer;
}
dither = iuser->scene->r.dither_intensity;
@ -4416,12 +4414,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
dither = 0.0f; /* don't dither passes */
}
}
for (rpass = static_cast<RenderPass *>(rl->passes.first); rpass; rpass = rpass->next) {
if (STREQ(rpass->name, RE_PASSNAME_Z) && rpass->view_id == actview) {
z_buffer = &rpass->buffer;
}
}
}
}
@ -4474,13 +4466,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
IMB_assign_float_buffer(ibuf, nullptr, IB_DO_NOT_TAKE_OWNERSHIP);
}
if (z_buffer) {
IMB_assign_shared_float_z_buffer(ibuf, z_buffer->data, z_buffer->sharing_info);
}
else {
IMB_assign_float_z_buffer(ibuf, nullptr, IB_DO_NOT_TAKE_OWNERSHIP);
}
/* TODO(sergey): Make this faster by either simply referencing the stamp
* or by changing both ImBuf and RenderResult to use same data type to
* store metadata. */

View File

@ -196,16 +196,6 @@ bool BKE_imtype_is_movie(const char imtype)
return false;
}
bool BKE_imtype_supports_zbuf(const char imtype)
{
switch (imtype) {
case R_IMF_IMTYPE_IRIZ:
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
return true;
}
return false;
}
bool BKE_imtype_supports_compress(const char imtype)
{
switch (imtype) {
@ -642,11 +632,6 @@ void BKE_image_format_to_imbuf(ImBuf *ibuf, const ImageFormatData *imf)
ibuf->foptions.flag |= OPENEXR_HALF;
}
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
if (!(imf->flag & R_IMF_FLAG_ZBUF)) {
/* Signal for exr saving. */
IMB_freezbuffloatImBuf(ibuf);
}
}
#endif
#ifdef WITH_CINEON
@ -800,9 +785,6 @@ void BKE_image_format_from_imbuf(ImageFormatData *im_format, const ImBuf *imbuf)
if (custom_flags & OPENEXR_COMPRESS) {
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; /* Can't determine compression */
}
if (imbuf->float_z_buffer.data) {
im_format->flag |= R_IMF_FLAG_ZBUF;
}
}
#endif

View File

@ -301,8 +301,6 @@ static void image_save_post(ReportList *reports,
* created. */
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbufImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
}
if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
ima->source = IMA_SRC_FILE;
@ -717,7 +715,6 @@ bool BKE_image_render_write_exr(ReportList *reports,
void *exrhandle = IMB_exr_get_handle();
const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16);
const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR);
const bool write_z = !multi_layer && (imf && (imf->flag & R_IMF_FLAG_ZBUF));
const int channels = (!multi_layer && imf && imf->planes == R_IMF_PLANES_RGB) ? 3 : 4;
Vector<float *> tmp_output_rects;
@ -782,12 +779,6 @@ bool BKE_image_render_write_exr(ReportList *reports,
IMB_exr_add_channel(
exrhandle, layname, passname, viewname, 4, 4 * rr->rectx, output_rect + a, half_float);
}
if (write_z && rview->z_buffer.data) {
const char *layname = (multi_layer) ? "Composite" : "";
IMB_exr_add_channel(
exrhandle, layname, "Z", viewname, 1, rr->rectx, rview->z_buffer.data, false);
}
}
}
@ -803,9 +794,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
/* Skip non-RGBA and Z passes if not using multi layer. */
if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") ||
(STREQ(rp->name, RE_PASSNAME_Z) && write_z)))
{
if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, ""))) {
continue;
}

View File

@ -178,9 +178,6 @@ static void do_versions_image_settings_2_60(Scene *sce)
if (rd->subimtype & R_PREVIEW_JPG) {
imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
}
if (rd->subimtype & R_OPENEXR_ZBUF) {
imf->flag |= R_IMF_FLAG_ZBUF;
}
break;
case R_IMF_IMTYPE_TIFF:
if (rd->subimtype & R_TIFF_16BIT) {

View File

@ -13,6 +13,7 @@
#include "DNA_lightprobe_types.h"
#include "DNA_modifier_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_genfile.h"
@ -278,5 +279,13 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
lightprobe->surfel_density = 1.0f;
}
}
/* Clear removed "Z Buffer" flag. */
{
const int R_IMF_FLAG_ZBUF_LEGACY = 1 << 0;
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->r.im_format.flag &= ~R_IMF_FLAG_ZBUF_LEGACY;
}
}
}
}

View File

@ -22,7 +22,6 @@ void CompositorNode::convert_to_operations(NodeConverter &converter,
NodeInput *image_socket = this->get_input_socket(0);
NodeInput *alpha_socket = this->get_input_socket(1);
NodeInput *depth_socket = this->get_input_socket(2);
CompositorOperation *compositor_operation = new CompositorOperation();
compositor_operation->set_scene(context.get_scene());
@ -43,7 +42,6 @@ void CompositorNode::convert_to_operations(NodeConverter &converter,
else {
converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
}
converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
converter.add_node_input_preview(image_socket);
}

View File

@ -225,21 +225,9 @@ void ImageNode::convert_to_operations(NodeConverter &converter,
converter.map_output_socket(alpha_image, alpha_operation->get_output_socket());
}
if (number_of_outputs > 2) {
NodeOutput *depth_image = this->get_output_socket(2);
ImageDepthOperation *depth_operation = new ImageDepthOperation();
depth_operation->set_image(image);
depth_operation->set_image_user(imageuser);
depth_operation->set_framenumber(framenumber);
depth_operation->set_render_data(context.get_render_data());
depth_operation->set_view_name(context.get_view_name());
converter.add_operation(depth_operation);
converter.map_output_socket(depth_image, depth_operation->get_output_socket());
}
if (number_of_outputs > 3) {
else {
/* happens when unlinking image datablock from multilayer node */
for (int i = 3; i < number_of_outputs; i++) {
for (int i = 2; i < number_of_outputs; i++) {

Change 3 to 2.

Change 3 to 2.
NodeOutput *output = this->get_output_socket(i);
NodeOperation *operation = nullptr;
switch (output->get_data_type()) {

View File

@ -23,7 +23,6 @@ void ViewerNode::convert_to_operations(NodeConverter &converter,
NodeInput *image_socket = this->get_input_socket(0);
NodeInput *alpha_socket = this->get_input_socket(1);
NodeInput *depth_socket = this->get_input_socket(2);
Image *image = (Image *)this->get_bnode()->id;
ImageUser *image_user = (ImageUser *)this->get_bnode()->storage;
ViewerOperation *viewer_operation = new ViewerOperation();
@ -58,7 +57,6 @@ void ViewerNode::convert_to_operations(NodeConverter &converter,
else {
converter.map_input_socket(alpha_socket, viewer_operation->get_input_socket(1));
}
converter.map_input_socket(depth_socket, viewer_operation->get_input_socket(2));
converter.add_node_input_preview(image_socket);

View File

@ -16,14 +16,11 @@ CompositorOperation::CompositorOperation()
{
this->add_input_socket(DataType::Color);
this->add_input_socket(DataType::Value);
this->add_input_socket(DataType::Value);
this->set_render_data(nullptr);
output_buffer_ = nullptr;
depth_buffer_ = nullptr;
image_input_ = nullptr;
alpha_input_ = nullptr;
depth_input_ = nullptr;
use_alpha_input_ = false;
active_ = false;
@ -44,15 +41,10 @@ void CompositorOperation::init_execution()
/* When initializing the tree during initial load the width and height can be zero. */
image_input_ = get_input_socket_reader(0);
alpha_input_ = get_input_socket_reader(1);
depth_input_ = get_input_socket_reader(2);
if (this->get_width() * this->get_height() != 0) {
output_buffer_ = (float *)MEM_callocN(
sizeof(float[4]) * this->get_width() * this->get_height(), "CompositorOperation");
}
if (depth_input_ != nullptr) {
depth_buffer_ = (float *)MEM_callocN(sizeof(float) * this->get_width() * this->get_height(),
"CompositorOperation");
}
}
void CompositorOperation::deinit_execution()
@ -69,7 +61,6 @@ void CompositorOperation::deinit_execution()
RenderView *rv = RE_RenderViewGetByName(rr, view_name_);
RE_RenderBuffer_assign_data(&rv->combined_buffer, output_buffer_);
RE_RenderBuffer_assign_data(&rv->z_buffer, depth_buffer_);
rr->have_combined = true;
}
@ -77,9 +68,6 @@ void CompositorOperation::deinit_execution()
if (output_buffer_) {
MEM_freeN(output_buffer_);
}
if (depth_buffer_) {
MEM_freeN(depth_buffer_);
}
}
if (re) {
@ -97,23 +85,17 @@ void CompositorOperation::deinit_execution()
if (output_buffer_) {
MEM_freeN(output_buffer_);
}
if (depth_buffer_) {
MEM_freeN(depth_buffer_);
}
}
output_buffer_ = nullptr;
depth_buffer_ = nullptr;
image_input_ = nullptr;
alpha_input_ = nullptr;
depth_input_ = nullptr;
}
void CompositorOperation::execute_region(rcti *rect, uint /*tile_number*/)
{
float color[8]; /* 7 is enough. */
float *buffer = output_buffer_;
float *zbuffer = depth_buffer_;
if (!buffer) {
return;
@ -180,8 +162,6 @@ void CompositorOperation::execute_region(rcti *rect, uint /*tile_number*/)
copy_v4_v4(buffer + offset4, color);
depth_input_->read_sampled(color, input_x, input_y, PixelSampler::Nearest);
zbuffer[offset] = color[0];
offset4 += COM_DATA_TYPE_COLOR_CHANNELS;
offset++;
if (is_braked()) {
@ -205,8 +185,6 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/
if (use_alpha_input_) {
output_buf.copy_from(inputs[1], area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
}
MemoryBuffer depth_buf(depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
depth_buf.copy_from(inputs[2], area);
}
void CompositorOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)

View File

@ -31,11 +31,6 @@ class CompositorOperation : public MultiThreadedOperation {
*/
float *output_buffer_;
/**
* \brief reference to the output depth float buffer
*/
float *depth_buffer_;
/**
* \brief local reference to the input image operation
*/
@ -46,11 +41,6 @@ class CompositorOperation : public MultiThreadedOperation {
*/
SocketReader *alpha_input_;
/**
* \brief local reference to the depth operation
*/
SocketReader *depth_input_;
/**
* \brief Ignore any alpha input
*/

View File

@ -22,8 +22,6 @@ BaseImageOperation::BaseImageOperation()
imagewidth_ = 0;
imageheight_ = 0;
framenumber_ = 0;
image_depth_buffer_ = nullptr;
depth_buffer_ = nullptr;
number_of_channels_ = 0;
rd_ = nullptr;
view_name_ = nullptr;
@ -36,10 +34,6 @@ ImageAlphaOperation::ImageAlphaOperation() : BaseImageOperation()
{
this->add_output_socket(DataType::Value);
}
ImageDepthOperation::ImageDepthOperation() : BaseImageOperation()
{
this->add_output_socket(DataType::Value);
}
ImBuf *BaseImageOperation::get_im_buf()
{
@ -71,10 +65,6 @@ void BaseImageOperation::init_execution()
if (stackbuf) {
image_float_buffer_ = stackbuf->float_buffer.data;
image_byte_buffer_ = stackbuf->byte_buffer.data;
image_depth_buffer_ = stackbuf->float_z_buffer.data;
if (stackbuf->float_z_buffer.data) {
depth_buffer_ = new MemoryBuffer(stackbuf->float_z_buffer.data, 1, stackbuf->x, stackbuf->y);
}
imagewidth_ = stackbuf->x;
imageheight_ = stackbuf->y;
number_of_channels_ = stackbuf->channels;
@ -86,10 +76,6 @@ void BaseImageOperation::deinit_execution()
image_float_buffer_ = nullptr;
image_byte_buffer_ = nullptr;
BKE_image_release_ibuf(image_, buffer_, nullptr);
if (depth_buffer_) {
delete depth_buffer_;
depth_buffer_ = nullptr;
}
}
void BaseImageOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)
@ -187,35 +173,4 @@ void ImageAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output,
output->copy_from(buffer_, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0);
}
void ImageDepthOperation::execute_pixel_sampled(float output[4],
float x,
float y,
PixelSampler /*sampler*/)
{
if (image_depth_buffer_ == nullptr) {
output[0] = 0.0f;
}
else {
if (x < 0 || y < 0 || x >= this->get_width() || y >= this->get_height()) {
output[0] = 0.0f;
}
else {
int offset = y * get_width() + x;
output[0] = image_depth_buffer_[offset];
}
}
}
void ImageDepthOperation::update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> /*inputs*/)
{
if (depth_buffer_) {
output->copy_from(depth_buffer_, area);
}
else {
output->fill(area, COM_VALUE_ZERO);
}
}
} // namespace blender::compositor

View File

@ -27,9 +27,7 @@ class BaseImageOperation : public MultiThreadedOperation {
/* TODO: Remove raw buffers when removing Tiled implementation. */
float *image_float_buffer_;
uint8_t *image_byte_buffer_;
float *image_depth_buffer_;
MemoryBuffer *depth_buffer_;
int imageheight_;
int imagewidth_;
int framenumber_;
@ -93,17 +91,4 @@ class ImageAlphaOperation : public BaseImageOperation {
const rcti &area,
Span<MemoryBuffer *> inputs) override;
};
class ImageDepthOperation : public BaseImageOperation {
public:
/**
* Constructor
*/
ImageDepthOperation();
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override;
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor

View File

@ -18,20 +18,16 @@ ViewerOperation::ViewerOperation()
this->set_image(nullptr);
this->set_image_user(nullptr);
output_buffer_ = nullptr;
depth_buffer_ = nullptr;
active_ = false;
do_depth_buffer_ = false;
view_settings_ = nullptr;
display_settings_ = nullptr;
use_alpha_input_ = false;
this->add_input_socket(DataType::Color);
this->add_input_socket(DataType::Value);
this->add_input_socket(DataType::Value);
image_input_ = nullptr;
alpha_input_ = nullptr;
depth_input_ = nullptr;
rd_ = nullptr;
view_name_ = nullptr;
flags_.use_viewer_border = true;
@ -43,8 +39,6 @@ void ViewerOperation::init_execution()
/* When initializing the tree during initial load the width and height can be zero. */
image_input_ = get_input_socket_reader(0);
alpha_input_ = get_input_socket_reader(1);
depth_input_ = get_input_socket_reader(2);
do_depth_buffer_ = (depth_input_ != nullptr);
if (is_active_viewer_output() && !exec_system_->is_breaked()) {
init_image();
@ -55,14 +49,12 @@ void ViewerOperation::deinit_execution()
{
image_input_ = nullptr;
alpha_input_ = nullptr;
depth_input_ = nullptr;
output_buffer_ = nullptr;
}
void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
{
float *buffer = output_buffer_;
float *depthbuffer = depth_buffer_;
if (!buffer) {
return;
}
@ -74,7 +66,7 @@ void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
const int offsetadd4 = offsetadd * 4;
int offset = (y1 * this->get_width() + x1);
int offset4 = offset * 4;
float alpha[4], depth[4];
float alpha[4];
int x;
int y;
bool breaked = false;
@ -86,8 +78,6 @@ void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
alpha_input_->read_sampled(alpha, x, y, PixelSampler::Nearest);
buffer[offset4 + 3] = alpha[0];
}
depth_input_->read_sampled(depth, x, y, PixelSampler::Nearest);
depthbuffer[offset] = depth[0];
offset++;
offset4 += 4;
@ -140,7 +130,6 @@ void ViewerOperation::init_image()
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
ibuf->x = get_width();
ibuf->y = get_height();
/* zero size can happen if no image buffers exist to define a sensible resolution */
@ -151,20 +140,12 @@ void ViewerOperation::init_image()
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
if (do_depth_buffer_) {
addzbuffloatImBuf(ibuf);
}
/* now we combine the input with ibuf */
output_buffer_ = ibuf->float_buffer.data;
/* needed for display buffer update */
ibuf_ = ibuf;
if (do_depth_buffer_) {
depth_buffer_ = ibuf->float_z_buffer.data;
}
BKE_image_release_ibuf(image_, ibuf_, lock);
BLI_thread_unlock(LOCK_DRAW_IMAGE);
@ -224,13 +205,6 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/,
output_buffer.copy_from(input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
}
if (depth_buffer_) {
MemoryBuffer depth_buffer(
depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
const MemoryBuffer *input_depth = inputs[2];
depth_buffer.copy_from(input_depth, area);
}
update_image(&area);
}

View File

@ -15,7 +15,6 @@ class ViewerOperation : public MultiThreadedOperation {
private:
/* TODO(manzanilla): To be removed together with tiled implementation. */
float *output_buffer_;
float *depth_buffer_;
Image *image_;
ImageUser *image_user_;
@ -23,7 +22,6 @@ class ViewerOperation : public MultiThreadedOperation {
float center_x_;
float center_y_;
ChunkOrdering chunk_order_;
bool do_depth_buffer_;
ImBuf *ibuf_;
bool use_alpha_input_;
const RenderData *rd_;
@ -34,7 +32,6 @@ class ViewerOperation : public MultiThreadedOperation {
SocketReader *image_input_;
SocketReader *alpha_input_;
SocketReader *depth_input_;
public:
ViewerOperation();

View File

@ -187,9 +187,7 @@ void ED_image_draw_info(struct Scene *scene,
int y,
const unsigned char cp[4],
const float fp[4],
const float linearcol[4],
const int *zp,
const float *zpf);
const float linearcol[4]);
bool ED_space_image_show_cache(const struct SpaceImage *sima);
bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima,

View File

@ -2415,10 +2415,7 @@ void uiTemplateImage(uiLayout *layout,
struct PointerRNA *userptr,
bool compact,
bool multiview);
void uiTemplateImageSettings(uiLayout *layout,
struct PointerRNA *imfptr,
bool color_management,
bool show_z_buffer);
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management);
void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imaptr);
void uiTemplateImageFormatViews(uiLayout *layout,

View File

@ -218,7 +218,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* image template */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
uiTemplateImageSettings(layout, &ptr, false, true);
uiTemplateImageSettings(layout, &ptr, false);
/* main draw call */
uiDefAutoButsRNA(

View File

@ -962,10 +962,7 @@ void uiTemplateImage(uiLayout *layout,
UI_block_funcN_set(block, NULL, NULL, NULL);
}
void uiTemplateImageSettings(uiLayout *layout,
PointerRNA *imfptr,
bool color_management,
bool show_z_buffer)
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_management)
{
ImageFormatData *imf = imfptr->data;
ID *id = imfptr->owner_id;
@ -1017,10 +1014,6 @@ void uiTemplateImageSettings(uiLayout *layout,
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
}
if (BKE_imtype_supports_zbuf(imf->imtype) && show_z_buffer) {
uiItemR(col, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
}
if (is_render_out && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
}
@ -1224,9 +1217,6 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
ofs += BLI_strncpy_rlen(str + ofs, TIP_(" RGB byte"), len - ofs);
}
}
if (ibuf->z_buffer.data || ibuf->float_z_buffer.data) {
ofs += BLI_strncpy_rlen(str + ofs, TIP_(" + Z"), len - ofs);
}
eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(
ibuf, ima->flag & IMA_HIGH_BITDEPTH, ibuf->planes >= 8);

View File

@ -129,9 +129,7 @@ void ED_image_draw_info(Scene *scene,
int y,
const uchar cp[4],
const float fp[4],
const float linearcol[4],
const int *zp,
const float *zpf)
const float linearcol[4])
{
rcti color_rect;
char str[256];
@ -177,21 +175,6 @@ void ED_image_draw_info(Scene *scene,
BLF_draw(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
if (zp) {
BLF_color3ub(blf_mono_font, 255, 255, 255);
SNPRINTF(str, " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (zpf) {
BLF_color3ub(blf_mono_font, 255, 255, 255);
SNPRINTF(str, " Z:%-.3f |", *zpf);
BLF_position(blf_mono_font, dx, dy, 0);
BLF_draw(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (channels == 1 && (cp != NULL || fp != NULL)) {
if (fp != NULL) {
SNPRINTF(str, " Val:%-.3f |", fp[0]);

View File

@ -198,7 +198,7 @@ int ED_space_image_get_display_channel_mask(ImBuf *ibuf)
const bool color = ibuf->channels >= 3;
const bool alpha = ibuf->channels == 4;
const bool zbuf = ibuf->z_buffer.data || ibuf->float_z_buffer.data || (ibuf->channels == 1);
const bool zbuf = ibuf->channels == 1;
if (!alpha) {
result &= ~(SI_USE_ALPHA | SI_SHOW_ALPHA);

View File

@ -2007,7 +2007,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* Image format settings. */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
uiTemplateImageSettings(layout, &imf_ptr, save_as_render, true);
uiTemplateImageSettings(layout, &imf_ptr, save_as_render);
if (!save_as_render) {
PointerRNA linear_settings_ptr = RNA_pointer_get(&imf_ptr, "linear_colorspace_settings");
@ -2258,7 +2258,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
ibuf = IMB_moviecacheIter_getImBuf(iter);
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
if (0 == IMB_saveiff(ibuf, ibuf->filepath, IB_rect | IB_zbuf | IB_zbuffloat)) {
if (0 == IMB_saveiff(ibuf, ibuf->filepath, IB_rect)) {
BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
break;
}

View File

@ -415,12 +415,6 @@ struct ImageSampleInfo {
float colf[4];
float linearcol[4];
int z;
float zf;
int *zp;
float *zfp;
int draw;
int color_manage;
};
@ -440,9 +434,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
info->y,
info->col,
info->colf,
info->linearcol,
info->zp,
info->zfp);
info->linearcol);
}
}
@ -575,9 +567,6 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->draw = 1;
info->channels = ibuf->channels;
info->zp = nullptr;
info->zfp = nullptr;
if (ibuf->byte_buffer.data) {
cp = ibuf->byte_buffer.data + 4 * (y * ibuf->x + x);
@ -608,15 +597,6 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->color_manage = true;
}
if (ibuf->z_buffer.data) {
info->z = ibuf->z_buffer.data[y * ibuf->x + x];
info->zp = &info->z;
}
if (ibuf->float_z_buffer.data) {
info->zf = ibuf->float_z_buffer.data[y * ibuf->x + x];
info->zfp = &info->zf;
}
ED_node_sample_set(info->colf);
}
else {

View File

@ -229,25 +229,6 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
info->color_manage = true;
}
if (ibuf->z_buffer.data) {
/* TODO: blend depth (not urgent). */
info->z = ibuf->z_buffer.data[y * ibuf->x + x];
info->zp = &info->z;
/* NOTE: Follows legacy code. Although it is unclear how z-buffer can be the same as a 4
* channel RGBA 8bpp buffer. */
if (ibuf->z_buffer.data == (int *)ibuf->byte_buffer.data) {
info->colp = NULL;
}
}
if (ibuf->float_z_buffer.data) {
/* TODO: blend depth (not urgent). */
info->zf = ibuf->float_z_buffer.data[y * ibuf->x + x];
info->zfp = &info->zf;
if (ibuf->float_z_buffer.data == ibuf->float_buffer.data) {
info->colfp = NULL;
}
}
if (curve_mapping && ibuf->channels == 4) {
/* we reuse this callback for set curves point operators */
if (RNA_struct_find_property(op->ptr, "point")) {
@ -415,9 +396,7 @@ void ED_imbuf_sample_draw(const bContext *C, ARegion *region, void *arg_info)
info->y,
info->colp,
info->colfp,
info->linearcol,
info->zp,
info->zfp);
info->linearcol);
if (info->sample_size > 1) {
ScrArea *area = CTX_wm_area(C);

View File

@ -164,9 +164,6 @@ void IMB_assign_shared_byte_buffer(struct ImBuf *ibuf,
void IMB_assign_shared_float_buffer(struct ImBuf *ibuf,
float *buffer_data,
const ImplicitSharingInfoHandle *implicit_sharing);
void IMB_assign_shared_float_z_buffer(struct ImBuf *ibuf,
float *buffer_data,
const ImplicitSharingInfoHandle *implicit_sharing);
/**
* Assign the content of the corresponding buffer with the given data and ownership.
@ -177,8 +174,6 @@ void IMB_assign_shared_float_z_buffer(struct ImBuf *ibuf,
*/
void IMB_assign_byte_buffer(struct ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership);
void IMB_assign_float_buffer(struct ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership);
void IMB_assign_z_buffer(struct ImBuf *ibuf, int *buffer_data, ImBufOwnership ownership);
void IMB_assign_float_z_buffer(struct ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership);
/**
* Make corresponding buffers available for modification.
@ -212,12 +207,6 @@ struct ImBuf *IMB_makeSingleUser(struct ImBuf *ibuf);
*/
struct ImBuf *IMB_dupImBuf(const struct ImBuf *ibuf1);
/**
* \attention Defined in allocimbuf.c
*/
bool addzbufImBuf(struct ImBuf *ibuf);
bool addzbuffloatImBuf(struct ImBuf *ibuf);
/**
* Approximate size of ImBuf in memory
*
@ -777,12 +766,6 @@ void IMB_flipy(struct ImBuf *ibuf);
void IMB_premultiply_alpha(struct ImBuf *ibuf);
void IMB_unpremultiply_alpha(struct ImBuf *ibuf);
/**
* \attention Defined in allocimbuf.c
*/
void IMB_freezbufImBuf(struct ImBuf *ibuf);
void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
/**
* \attention Defined in rectop.c
*/

View File

@ -133,10 +133,8 @@ typedef struct ImbFormatOptions {
typedef enum eImBufFlags {
IB_rect = 1 << 0,
IB_test = 1 << 1,
IB_zbuf = 1 << 3,
IB_mem = 1 << 4,
IB_rectfloat = 1 << 5,
IB_zbuffloat = 1 << 6,
IB_multilayer = 1 << 7,
IB_metadata = 1 << 8,
IB_animdeinterlace = 1 << 9,
@ -247,12 +245,6 @@ typedef struct ImBuf {
/** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */
double ppm[2];
/* zbuffer */
/** z buffer data, original zbuffer */
ImBufIntBuffer z_buffer;
/** z buffer data, camera coordinates */
ImBufFloatBuffer float_z_buffer;
/* parameters used by conversion between byte and float */
/** random dither value, for conversion from float -> byte rect */
float dither;

View File

@ -237,34 +237,10 @@ static void freeencodedbufferImBuf(ImBuf *ibuf)
ibuf->flags &= ~IB_mem;
}
void IMB_freezbufImBuf(ImBuf *ibuf)
{
if (ibuf == nullptr) {
return;
}
imb_free_buffer(ibuf->z_buffer);
ibuf->flags &= ~IB_zbuf;
}
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
{
if (ibuf == nullptr) {
return;
}
imb_free_buffer(ibuf->float_z_buffer);
ibuf->flags &= ~IB_zbuffloat;
}
void imb_freerectImbuf_all(ImBuf *ibuf)
{
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbufImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
freeencodedbufferImBuf(ibuf);
}
@ -331,40 +307,6 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
return rval;
}
bool addzbufImBuf(ImBuf *ibuf)
{
if (ibuf == nullptr) {
return false;
}
IMB_freezbufImBuf(ibuf);
if (!imb_alloc_buffer(ibuf->z_buffer, ibuf->x, ibuf->y, 1, sizeof(uint))) {
return false;
}
ibuf->flags |= IB_zbuf;
return false;
}
bool addzbuffloatImBuf(ImBuf *ibuf)
{
if (ibuf == nullptr) {
return false;
}
IMB_freezbuffloatImBuf(ibuf);
if (!imb_alloc_buffer(ibuf->float_z_buffer, ibuf->x, ibuf->y, 1, sizeof(float))) {
return false;
}
ibuf->flags |= IB_zbuffloat;
return true;
}
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
{
if (ibuf == nullptr) {
@ -478,10 +420,6 @@ bool imb_addrectImBuf(ImBuf *ibuf)
ibuf->flags |= IB_rect;
if (ibuf->planes > 32) {
return addzbufImBuf(ibuf);
}
return true;
}
@ -547,19 +485,6 @@ void IMB_assign_shared_float_buffer(ImBuf *ibuf,
}
}
void IMB_assign_shared_float_z_buffer(ImBuf *ibuf,
float *buffer_data,
const ImplicitSharingInfoHandle *implicit_sharing)
{
imb_free_buffer(ibuf->float_z_buffer);
ibuf->flags &= ~IB_zbuffloat;
if (buffer_data) {
imb_assign_shared_buffer(ibuf->float_z_buffer, buffer_data, implicit_sharing);
ibuf->flags |= IB_zbuffloat;
}
}
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, const ImBufOwnership ownership)
{
imb_free_buffer(ibuf->byte_buffer);
@ -586,32 +511,6 @@ void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, const ImBufOwnersh
}
}
void IMB_assign_z_buffer(ImBuf *ibuf, int *buffer_data, ImBufOwnership ownership)
{
imb_free_buffer(ibuf->z_buffer);
ibuf->flags &= ~IB_zbuf;
if (buffer_data) {
ibuf->z_buffer.ownership = ownership;
ibuf->z_buffer.data = buffer_data;
ibuf->flags |= IB_zbuf;
}
}
void IMB_assign_float_z_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
{
imb_free_buffer(ibuf->float_z_buffer);
ibuf->flags &= ~IB_zbuffloat;
if (buffer_data) {
ibuf->float_z_buffer.ownership = ownership;
ibuf->float_z_buffer.data = buffer_data;
ibuf->flags |= IB_zbuffloat;
}
}
ImBuf *IMB_allocFromBufferOwn(
uint8_t *byte_buffer, float *float_buffer, uint w, uint h, uint channels)
{
@ -711,18 +610,6 @@ bool IMB_initImBuf(ImBuf *ibuf, uint x, uint y, uchar planes, uint flags)
}
}
if (flags & IB_zbuf) {
if (addzbufImBuf(ibuf) == false) {
return false;
}
}
if (flags & IB_zbuffloat) {
if (addzbuffloatImBuf(ibuf) == false) {
return false;
}
}
/* assign default spaces */
colormanage_imbuf_set_default_spaces(ibuf);
@ -747,12 +634,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
if (ibuf1->float_buffer.data) {
flags |= IB_rectfloat;
}
if (ibuf1->z_buffer.data) {
flags |= IB_zbuf;
}
if (ibuf1->float_z_buffer.data) {
flags |= IB_zbuffloat;
}
x = ibuf1->x;
y = ibuf1->y;
@ -772,14 +653,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
size_t(ibuf1->channels) * x * y * sizeof(float));
}
if (flags & IB_zbuf) {
memcpy(ibuf2->z_buffer.data, ibuf1->z_buffer.data, size_t(x) * y * sizeof(int));
}
if (flags & IB_zbuffloat) {
memcpy(ibuf2->float_buffer.data, ibuf1->float_buffer.data, size_t(x) * y * sizeof(float));
}
if (ibuf1->encoded_buffer.data) {
ibuf2->encoded_buffer_size = ibuf1->encoded_buffer_size;
if (imb_addencodedbufferImBuf(ibuf2) == false) {
@ -800,8 +673,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
tbuf.byte_buffer = ibuf2->byte_buffer;
tbuf.float_buffer = ibuf2->float_buffer;
tbuf.encoded_buffer = ibuf2->encoded_buffer;
tbuf.z_buffer = ibuf2->z_buffer;
tbuf.float_z_buffer = ibuf2->float_z_buffer;
for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
tbuf.mipmap[a] = nullptr;
}

View File

@ -201,29 +201,6 @@ static void readtab(MFileOffset *inf, uint *tab, int len)
}
}
static void test_endian_zbuf(ImBuf *ibuf)
{
int len;
int *zval;
/* `BIG_LONG(1) == 1`, no change needed. */
#ifdef __BIG_ENDIAN__
return;
#endif
if (ibuf->z_buffer.data == nullptr) {
return;
}
len = ibuf->x * ibuf->y;
zval = ibuf->z_buffer.data;
while (len--) {
zval[0] = BIG_LONG(zval[0]);
zval++;
}
}
/* From misc_util: flip the bytes from x. */
#define GS(x) (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
@ -242,7 +219,6 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
{
uint *base, *lptr = nullptr;
float *fbase, *fptr = nullptr;
uint *zbase, *zptr;
const uchar *rledat;
const uchar *mem_end = mem + size;
MFileOffset _inf_data = {mem, 0}, *inf = &_inf_data;
@ -283,7 +259,9 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
const int xsize = image.xsize;
const int ysize = image.ysize;
const int zsize = image.zsize;
const int zsize_file = image.zsize;
const int zsize_read = min_ii(image.zsize, 4);
if (flags & IB_test) {
ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0);
@ -294,7 +272,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
}
if (rle) {
size_t tablen = size_t(ysize) * size_t(zsize) * sizeof(int);
size_t tablen = size_t(ysize) * size_t(zsize_file) * sizeof(int);
MFILE_SEEK(inf, HEADER_SIZE);
uint *starttab = static_cast<uint *>(MEM_mallocN(tablen, "iris starttab"));
@ -316,7 +294,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
cur = 0;
badorder = 0;
for (size_t y = 0; y < ysize; y++) {
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_file; z++) {
if (starttab[y + z * ysize] < cur) {
badorder = 1;
break;
@ -330,7 +308,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
if (bpp == 1) {
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize_read, IB_rect);
if (!ibuf) {
goto fail_rle;
}
@ -338,10 +316,9 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
ibuf->planes = 32;
}
base = (uint *)ibuf->byte_buffer.data;
zbase = (uint *)ibuf->z_buffer.data;
if (badorder) {
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
lptr = base;
for (size_t y = 0; y < ysize; y++) {
MFILE_SEEK(inf, starttab[y + z * ysize]);
@ -357,13 +334,11 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
}
else {
lptr = base;
zptr = zbase;
for (size_t y = 0; y < ysize; y++) {
uint *lptr_next = lptr + xsize;
uint *zptr_next = zptr + xsize;
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
@ -373,13 +348,11 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
dirty_flag |= expandrow(
(uchar *)lptr, (uchar *)lptr_next, rledat, rledat_next, 3 - z);
}
else if (z < 8) {
dirty_flag |= expandrow(
(uchar *)zptr, (uchar *)zptr_next, rledat, rledat_next, 7 - z);
else {
break;
}
}
lptr = lptr_next;
zptr = zptr_next;
}
}
}
@ -393,7 +366,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
fbase = ibuf->float_buffer.data;
if (badorder) {
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
fptr = fbase;
for (size_t y = 0; y < ysize; y++) {
MFILE_SEEK(inf, starttab[y + z * ysize]);
@ -413,7 +386,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
for (size_t y = 0; y < ysize; y++) {
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
MFILE_SEEK(inf, starttab[y + z * ysize]);
rledat = MFILE_DATA(inf);
MFILE_STEP(inf, lengthtab[y + z * ysize]);
@ -445,7 +418,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
if (bpp == 1) {
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize_read, IB_rect);
if (!ibuf) {
goto fail_uncompressed;
}
@ -454,18 +427,17 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
}
base = (uint *)ibuf->byte_buffer.data;
zbase = (uint *)ibuf->z_buffer.data;
MFILE_SEEK(inf, HEADER_SIZE);
rledat = MFILE_DATA(inf);
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
if (z < 4) {
lptr = base;
}
else if (z < 8) {
lptr = zbase;
else {
break;
}
for (size_t y = 0; y < ysize; y++) {
@ -490,7 +462,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
MFILE_SEEK(inf, HEADER_SIZE);
rledat = MFILE_DATA(inf);
for (size_t z = 0; z < zsize; z++) {
for (size_t z = 0; z < zsize_read; z++) {
fptr = fbase;
@ -578,8 +550,6 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
}
ibuf->ftype = IMB_FTYPE_IMAGIC;
test_endian_zbuf(ibuf);
if (ibuf->byte_buffer.data) {
IMB_convert_rgba_to_abgr(ibuf);
}
@ -963,22 +933,15 @@ static int compressrow(const uchar *lbuf, uchar *rlebuf, const int z, const int
bool imb_saveiris(ImBuf *ibuf, const char *filepath, int flags)
{
short zsize;
zsize = (ibuf->planes + 7) >> 3;
if (flags & IB_zbuf && ibuf->z_buffer.data != nullptr) {
zsize = 8;
}
const short zsize = (ibuf->planes + 7) >> 3;
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
const bool ok = output_iris(
filepath, (uint *)ibuf->byte_buffer.data, ibuf->z_buffer.data, ibuf->x, ibuf->y, zsize);
filepath, (uint *)ibuf->byte_buffer.data, nullptr, ibuf->x, ibuf->y, zsize);
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
return ok;
}

View File

@ -101,7 +101,6 @@ static struct ExrPass *imb_exr_get_pass(ListBase *lb, char *passname);
static bool exr_has_multiview(MultiPartInputFile &file);
static bool exr_has_multipart_file(MultiPartInputFile &file);
static bool exr_has_alpha(MultiPartInputFile &file);
static bool exr_has_zbuffer(MultiPartInputFile &file);
static void exr_printf(const char *__restrict fmt, ...);
static void imb_exr_type_by_channels(ChannelList &channels,
StringVector &views,
@ -463,8 +462,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
const bool is_zbuf = (flags & IB_zbuffloat) &&
ibuf->float_z_buffer.data != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
OStream *file_stream = nullptr;
@ -482,10 +479,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
if (is_alpha) {
header.channels().insert("A", Channel(HALF));
}
if (is_zbuf) {
/* z we do as float always */
header.channels().insert("Z", Channel(Imf::FLOAT));
}
FrameBuffer frameBuffer;
@ -511,13 +504,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
if (is_alpha) {
frameBuffer.insert("A", Slice(HALF, (char *)&to->a, xstride, ystride));
}
if (is_zbuf) {
frameBuffer.insert("Z",
Slice(Imf::FLOAT,
(char *)(ibuf->float_z_buffer.data + (height - 1) * width),
sizeof(float),
sizeof(float) * -width));
}
if (ibuf->float_buffer.data) {
float *from;
@ -577,8 +563,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
const bool is_zbuf = (flags & IB_zbuffloat) &&
ibuf->float_z_buffer.data != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
OStream *file_stream = nullptr;
@ -596,9 +580,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
if (is_alpha) {
header.channels().insert("A", Channel(Imf::FLOAT));
}
if (is_zbuf) {
header.channels().insert("Z", Channel(Imf::FLOAT));
}
FrameBuffer frameBuffer;
@ -629,13 +610,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
if (is_alpha) {
frameBuffer.insert("A", Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
}
if (is_zbuf) {
frameBuffer.insert("Z",
Slice(Imf::FLOAT,
(char *)(ibuf->float_z_buffer.data + (height - 1) * width),
sizeof(float),
sizeof(float) * -width));
}
file.setFrameBuffer(frameBuffer);
file.writePixels(height);
@ -1851,12 +1825,6 @@ static bool exr_has_chroma(MultiPartInputFile &file)
header.channels().findChannel("RY") != nullptr;
}
static bool exr_has_zbuffer(MultiPartInputFile &file)
{
const Header &header = file.header(0);
return !(header.channels().findChannel("Z") == nullptr);
}
static bool exr_has_alpha(MultiPartInputFile &file)
{
const Header &header = file.header(0);
@ -2100,16 +2068,6 @@ ImBuf *imb_load_openexr(const uchar *mem, size_t size, int flags, char colorspac
frameBuffer.insert(exr_rgba_channelname(*file, "A"),
Slice(Imf::FLOAT, (char *)(first + 3), xstride, ystride, 1, 1, 1.0f));
if (exr_has_zbuffer(*file)) {
float *firstz;
addzbuffloatImBuf(ibuf);
firstz = ibuf->float_z_buffer.data - (dw.min.x - dw.min.y * width);
firstz += (height - 1) * width;
frameBuffer.insert(
"Z", Slice(Imf::FLOAT, (char *)firstz, sizeof(float), -width * sizeof(float)));
}
InputPart in(*file, 0);
in.setFrameBuffer(frameBuffer);
in.readPixels(dw.min.y, dw.max.y);

View File

@ -255,8 +255,6 @@ void IMB_rect_crop(ImBuf *ibuf, const rcti *crop)
/* TODO(sergey: Validate ownership. */
rect_crop_4bytes((void **)&ibuf->byte_buffer.data, size_src, crop);
rect_crop_4bytes((void **)&ibuf->z_buffer.data, size_src, crop);
rect_crop_4bytes((void **)&ibuf->float_z_buffer.data, size_src, crop);
rect_crop_16bytes((void **)&ibuf->float_buffer.data, size_src, crop);
ibuf->x = size_dst[0];
@ -293,8 +291,6 @@ void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
/* TODO(sergey: Validate ownership. */
rect_realloc_4bytes((void **)&ibuf->byte_buffer.data, size);
rect_realloc_4bytes((void **)&ibuf->z_buffer.data, size);
rect_realloc_4bytes((void **)&ibuf->float_z_buffer.data, size);
rect_realloc_16bytes((void **)&ibuf->float_buffer.data, size);
ibuf->x = size[0];

View File

@ -1565,70 +1565,6 @@ static ImBuf *scaleupy(ImBuf *ibuf, int newy)
return ibuf;
}
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
{
int *zbuf, *newzbuf, *_newzbuf = nullptr;
float *zbuf_float, *newzbuf_float, *_newzbuf_float = nullptr;
int x, y;
int ofsx, ofsy, stepx, stepy;
if (ibuf->z_buffer.data) {
_newzbuf = static_cast<int *>(MEM_mallocN(newx * newy * sizeof(int), __func__));
if (_newzbuf == nullptr) {
IMB_freezbufImBuf(ibuf);
}
}
if (ibuf->float_z_buffer.data) {
_newzbuf_float = static_cast<float *>(
MEM_mallocN(size_t(newx) * newy * sizeof(float), __func__));
if (_newzbuf_float == nullptr) {
IMB_freezbuffloatImBuf(ibuf);
}
}
if (!_newzbuf && !_newzbuf_float) {
return;
}
stepx = round(65536.0 * (ibuf->x - 1.0) / (newx - 1.0));
stepy = round(65536.0 * (ibuf->y - 1.0) / (newy - 1.0));
ofsy = 32768;
newzbuf = _newzbuf;
newzbuf_float = _newzbuf_float;
for (y = newy; y > 0; y--, ofsy += stepy) {
if (newzbuf) {
zbuf = ibuf->z_buffer.data;
zbuf += (ofsy >> 16) * ibuf->x;
ofsx = 32768;
for (x = newx; x > 0; x--, ofsx += stepx) {
*newzbuf++ = zbuf[ofsx >> 16];
}
}
if (newzbuf_float) {
zbuf_float = ibuf->float_z_buffer.data;
zbuf_float += (ofsy >> 16) * ibuf->x;
ofsx = 32768;
for (x = newx; x > 0; x--, ofsx += stepx) {
*newzbuf_float++ = zbuf_float[ofsx >> 16];
}
}
}
if (_newzbuf) {
IMB_freezbufImBuf(ibuf);
IMB_assign_z_buffer(ibuf, _newzbuf, IB_TAKE_OWNERSHIP);
}
if (_newzbuf_float) {
IMB_freezbuffloatImBuf(ibuf);
IMB_assign_float_z_buffer(ibuf, _newzbuf_float, IB_TAKE_OWNERSHIP);
}
}
bool IMB_scaleImBuf(ImBuf *ibuf, uint newx, uint newy)
{
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
@ -1644,10 +1580,6 @@ bool IMB_scaleImBuf(ImBuf *ibuf, uint newx, uint newy)
return false;
}
/* Scale-up / scale-down functions below change ibuf->x and ibuf->y
* so we first scale the Z-buffer (if any). */
scalefast_Z_ImBuf(ibuf, newx, newy);
/* try to scale common cases in a fast way */
/* disabled, quality loss is unacceptable, see report #18609 (ton) */
if (0 && q_scale_linear_interpolation(ibuf, newx, newy)) {
@ -1764,8 +1696,6 @@ bool IMB_scalefastImBuf(ImBuf *ibuf, uint newx, uint newy)
IMB_assign_float_buffer(ibuf, reinterpret_cast<float *>(_newrectf), IB_TAKE_OWNERSHIP);
}
scalefast_Z_ImBuf(ibuf, newx, newy);
ibuf->x = newx;
ibuf->y = newy;
return true;

View File

@ -1339,31 +1339,6 @@ void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d,
imb_stereo3d_read_doit(&s3d_data, s3d);
if (ibuf_stereo3d->flags & (IB_zbuf | IB_zbuffloat)) {
if (is_float) {
addzbuffloatImBuf(ibuf_left);
addzbuffloatImBuf(ibuf_right);
}
else {
addzbufImBuf(ibuf_left);
addzbufImBuf(ibuf_right);
}
imb_stereo3d_data_init(&s3d_data,
is_float,
ibuf_left->x,
ibuf_left->y,
1,
ibuf_left->z_buffer.data,
ibuf_right->z_buffer.data,
ibuf_stereo3d->z_buffer.data,
ibuf_left->float_z_buffer.data,
ibuf_right->float_z_buffer.data,
ibuf_stereo3d->float_z_buffer.data);
imb_stereo3d_read_doit(&s3d_data, s3d);
}
IMB_freeImBuf(ibuf_stereo3d);
*r_ibuf_left = ibuf_left;

View File

@ -505,7 +505,7 @@ enum {
/** #ImageFormatData::flag */
enum {
R_IMF_FLAG_ZBUF = 1 << 0,
// R_IMF_FLAG_ZBUF = 1 << 0, /* DEPRECATED, and cleared. */
R_IMF_FLAG_PREVIEW_JPG = 1 << 1,
};

View File

@ -5907,13 +5907,6 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
"100 = maximum lossless compression with slow file output");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
/* flag */
prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", R_IMF_FLAG_ZBUF);
RNA_def_property_ui_text(
prop, "Z Buffer", "Save the z-depth per pixel (32-bit unsigned integer z-buffer)");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", R_IMF_FLAG_PREVIEW_JPG);
RNA_def_property_ui_text(

View File

@ -1664,7 +1664,6 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
RNA_def_boolean(func, "show_z_buffer", true, "", "Show option to save z-buffer");
func = RNA_def_function(srna, "template_image_stereo_3d", "uiTemplateImageStereo3d");
RNA_def_function_ui_description(func, "User interface for setting image stereo 3d options");

View File

@ -28,7 +28,6 @@ static void cmp_node_composite_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
b.add_input<decl::Float>("Z").default_value(1.0f).min(0.0f).max(1.0f);
}
static void node_composit_buts_composite(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)

View File

@ -209,17 +209,6 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree,
&prev_index);
if (ima) {
if (!ima->rr) {
cmp_node_image_add_pass_output(ntree,
node,
RE_PASSNAME_Z,
RE_PASSNAME_Z,
-1,
SOCK_FLOAT,
false,
available_sockets,
&prev_index);
}
BKE_image_release_ibuf(ima, ibuf, nullptr);
}
}

View File

@ -305,11 +305,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
const bool is_exr = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_OPENEXR;
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
/* Unclear where to get z-information from, so deactivate it. */
const bool show_z_buffer = false;
node_composit_buts_file_output(layout, C, ptr);
uiTemplateImageSettings(layout, &imfptr, true, show_z_buffer);
uiTemplateImageSettings(layout, &imfptr, true);
/* disable stereo output for multilayer, too much work for something that no one will use */
/* if someone asks for that we can implement it */
@ -432,7 +430,7 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
const bool use_color_management = RNA_boolean_get(&active_input_ptr, "save_as_render");
col = uiLayoutColumn(layout, false);
uiTemplateImageSettings(col, &imfptr, use_color_management, show_z_buffer);
uiTemplateImageSettings(col, &imfptr, use_color_management);
if (is_multiview) {
col = uiLayoutColumn(layout, false);

View File

@ -33,7 +33,6 @@ static void cmp_node_viewer_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
b.add_input<decl::Float>("Z").default_value(1.0f).min(0.0f).max(1.0f);
}
static void node_composit_init_viewer(bNodeTree * /*ntree*/, bNode *node)

View File

@ -330,7 +330,6 @@ class Context : public realtime_compositor::Context {
if (image_buffer->x != render_size.x || image_buffer->y != render_size.y) {
imb_freerectImBuf(image_buffer);
imb_freerectfloatImBuf(image_buffer);
IMB_freezbuffloatImBuf(image_buffer);
image_buffer->x = render_size.x;
image_buffer->y = render_size.y;
imb_addrectfloatImBuf(image_buffer, 4);

View File

@ -1003,7 +1003,6 @@ ImBuf *RE_render_result_rect_to_ibuf(RenderResult *rr,
/* if not exists, BKE_imbuf_write makes one */
IMB_assign_shared_byte_buffer(ibuf, rv->byte_buffer.data, rv->byte_buffer.sharing_info);
IMB_assign_shared_float_buffer(ibuf, rv->combined_buffer.data, rv->combined_buffer.sharing_info);
IMB_assign_shared_float_z_buffer(ibuf, rv->z_buffer.data, rv->z_buffer.sharing_info);
/* float factor for random dither, imbuf takes care of it */
ibuf->dither = dither;

View File

@ -306,7 +306,7 @@ static void seq_proxy_build_frame(const SeqRenderData *context,
BLI_file_ensure_parent_dir_exists(filepath);
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat);
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect);
if (ok == false) {
perror(filepath);
}

View File

@ -1581,11 +1581,6 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
IMB_assign_shared_float_buffer(
ibufs_arr[view_id], rres.combined_buffer.data, rres.combined_buffer.sharing_info);
if (rres.z_buffer.data) {
IMB_assign_shared_float_z_buffer(
ibufs_arr[view_id], rres.z_buffer.data, rres.z_buffer.sharing_info);
}
/* float buffers in the sequencer are not linear */
seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
}