2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BUFFERS_H__
|
|
|
|
#define __BUFFERS_H__
|
|
|
|
|
|
|
|
#include "device_memory.h"
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
#include "film.h"
|
|
|
|
|
|
|
|
#include "kernel_types.h"
|
|
|
|
|
2014-01-15 14:29:22 +00:00
|
|
|
#include "util_half.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "util_string.h"
|
|
|
|
#include "util_thread.h"
|
|
|
|
#include "util_types.h"
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Device;
|
2014-03-26 17:11:16 +00:00
|
|
|
struct DeviceDrawParams;
|
2011-05-03 18:29:11 +00:00
|
|
|
struct float4;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
/* Buffer Parameters
|
2012-06-09 17:22:52 +00:00
|
|
|
* Size of render buffer and how it fits in the full image (border render). */
|
2011-12-20 12:25:37 +00:00
|
|
|
|
|
|
|
class BufferParams {
|
|
|
|
public:
|
|
|
|
/* width/height of the physical buffer */
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
/* offset into and width/height of the full buffer */
|
|
|
|
int full_x;
|
|
|
|
int full_y;
|
|
|
|
int full_width;
|
|
|
|
int full_height;
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
/* passes */
|
|
|
|
vector<Pass> passes;
|
|
|
|
|
|
|
|
/* functions */
|
|
|
|
BufferParams();
|
|
|
|
|
|
|
|
void get_offset_stride(int& offset, int& stride);
|
|
|
|
bool modified(const BufferParams& params);
|
|
|
|
void add_pass(PassType type);
|
|
|
|
int get_passes_size();
|
2011-12-20 12:25:37 +00:00
|
|
|
};
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Render Buffers */
|
|
|
|
|
|
|
|
class RenderBuffers {
|
|
|
|
public:
|
2011-12-20 12:25:37 +00:00
|
|
|
/* buffer parameters */
|
|
|
|
BufferParams params;
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* float buffer */
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
device_vector<float> buffer;
|
2011-04-27 11:58:34 +00:00
|
|
|
/* random number generator state */
|
|
|
|
device_vector<uint> rng_state;
|
|
|
|
|
|
|
|
RenderBuffers(Device *device);
|
|
|
|
~RenderBuffers();
|
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
void reset(Device *device, BufferParams& params);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
|
|
|
|
bool copy_from_device();
|
2012-09-04 13:29:07 +00:00
|
|
|
bool get_pass_rect(PassType type, float exposure, int sample, int components, float *pixels);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void device_free();
|
|
|
|
|
|
|
|
Device *device;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Display Buffer
|
|
|
|
*
|
2013-08-30 23:49:38 +00:00
|
|
|
* The buffer used for drawing during render, filled by converting the render
|
|
|
|
* buffers to byte of half float storage */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
class DisplayBuffer {
|
|
|
|
public:
|
2011-12-20 12:25:37 +00:00
|
|
|
/* buffer parameters */
|
|
|
|
BufferParams params;
|
2011-04-27 11:58:34 +00:00
|
|
|
/* dimensions for how much of the buffer is actually ready for display.
|
2012-06-09 17:22:52 +00:00
|
|
|
* with progressive render we can be using only a subset of the buffer.
|
|
|
|
* if these are zero, it means nothing can be drawn yet */
|
2011-04-27 11:58:34 +00:00
|
|
|
int draw_width, draw_height;
|
2011-08-28 13:55:59 +00:00
|
|
|
/* draw alpha channel? */
|
|
|
|
bool transparent;
|
2013-08-30 23:49:38 +00:00
|
|
|
/* use half float? */
|
|
|
|
bool half_float;
|
|
|
|
/* byte buffer for converted result */
|
|
|
|
device_vector<uchar4> rgba_byte;
|
|
|
|
device_vector<half4> rgba_half;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
DisplayBuffer(Device *device, bool linear = false);
|
2011-04-27 11:58:34 +00:00
|
|
|
~DisplayBuffer();
|
|
|
|
|
2011-12-20 12:25:37 +00:00
|
|
|
void reset(Device *device, BufferParams& params);
|
2011-04-27 11:58:34 +00:00
|
|
|
void write(Device *device, const string& filename);
|
|
|
|
|
|
|
|
void draw_set(int width, int height);
|
2014-03-26 08:57:30 +00:00
|
|
|
void draw(Device *device, const DeviceDrawParams& draw_params);
|
2011-04-27 11:58:34 +00:00
|
|
|
bool draw_ready();
|
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
device_memory& rgba_data();
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
protected:
|
|
|
|
void device_free();
|
|
|
|
|
|
|
|
Device *device;
|
|
|
|
};
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
/* Render Tile
|
|
|
|
* Rendering task on a buffer */
|
|
|
|
|
|
|
|
class RenderTile {
|
|
|
|
public:
|
|
|
|
int x, y, w, h;
|
|
|
|
int start_sample;
|
|
|
|
int num_samples;
|
|
|
|
int sample;
|
|
|
|
int resolution;
|
|
|
|
int offset;
|
|
|
|
int stride;
|
|
|
|
|
|
|
|
device_ptr buffer;
|
|
|
|
device_ptr rng_state;
|
|
|
|
|
|
|
|
RenderBuffers *buffers;
|
|
|
|
|
|
|
|
RenderTile();
|
|
|
|
};
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __BUFFERS_H__ */
|
|
|
|
|