27 texture_state_.is_outdated =
true;
29 if (!reset_rendering) {
30 driver_->next_tile_begin();
34void PathTraceDisplay::mark_texture_updated()
36 texture_state_.is_outdated =
false;
45 DCHECK(!update_state_.is_active);
47 if (update_state_.is_active) {
48 LOG_ERROR <<
"Attempt to re-activate update process.";
59 texture_state_.size =
make_int2(texture_width, texture_height);
62 if (!driver_->update_begin(
params, texture_width, texture_height)) {
63 LOG_ERROR <<
"PathTraceDisplay implementation could not begin update.";
67 update_state_.is_active =
true;
74 DCHECK(update_state_.is_active);
76 if (!update_state_.is_active) {
77 LOG_ERROR <<
"Attempt to deactivate inactive update process.";
81 driver_->update_end();
83 update_state_.is_active =
false;
88 return texture_state_.size;
98 const int pixels_width,
99 const int pixels_height)
101 DCHECK(update_state_.is_active);
103 if (!update_state_.is_active) {
104 LOG_ERROR <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
108 mark_texture_updated();
117 if (!mapped_rgba_pixels) {
121 const int texture_width = texture_state_.size.x;
122 const int texture_height = texture_state_.size.y;
124 if (texture_x == 0 && texture_y == 0 && pixels_width == texture_width &&
125 pixels_height == texture_height)
127 const size_t size_in_bytes =
sizeof(
half4) * texture_width * texture_height;
128 memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes);
131 const half4 *rgba_row = rgba_pixels;
132 half4 *mapped_rgba_row = mapped_rgba_pixels + texture_y * texture_width + texture_x;
133 for (
int y = 0;
y < pixels_height;
134 ++
y, rgba_row += pixels_width, mapped_rgba_row += texture_width)
136 memcpy(mapped_rgba_row, rgba_row,
sizeof(
half4) * pixels_width);
149 DCHECK(!texture_buffer_state_.is_mapped);
150 DCHECK(update_state_.is_active);
152 if (texture_buffer_state_.is_mapped) {
153 LOG_ERROR <<
"Attempt to re-map an already mapped texture buffer.";
157 if (!update_state_.is_active) {
158 LOG_ERROR <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
162 half4 *mapped_rgba_pixels = driver_->map_texture_buffer();
164 if (mapped_rgba_pixels) {
165 texture_buffer_state_.is_mapped =
true;
168 return mapped_rgba_pixels;
173 DCHECK(texture_buffer_state_.is_mapped);
175 if (!texture_buffer_state_.is_mapped) {
176 LOG_ERROR <<
"Attempt to unmap non-mapped texture buffer.";
180 texture_buffer_state_.is_mapped =
false;
182 mark_texture_updated();
183 driver_->unmap_texture_buffer();
192 return driver_->graphics_interop_get_device();
198 DCHECK(!texture_buffer_state_.is_mapped);
199 DCHECK(update_state_.is_active);
201 if (texture_buffer_state_.is_mapped) {
203 <<
"Attempt to use graphics interoperability mode while the texture buffer is mapped.";
204 interop_buffer.
clear();
205 return interop_buffer;
208 if (!update_state_.is_active) {
209 LOG_ERROR <<
"Attempt to use graphics interoperability outside of PathTraceDisplay update.";
210 interop_buffer.
clear();
211 return interop_buffer;
215 mark_texture_updated();
217 driver_->graphics_interop_update_buffer();
218 return interop_buffer;
223 driver_->graphics_interop_activate();
228 driver_->graphics_interop_deactivate();
void reset(const BufferParams &buffer_params, bool reset_rendering)
int2 get_texture_size() const
PathTraceDisplay(unique_ptr< DisplayDriver > driver)
void graphics_interop_activate()
half4 * map_texture_buffer()
bool update_begin(const int texture_width, const int texture_height)
void copy_pixels_to_texture(const half4 *rgba_pixels, const int texture_x, const int texture_y, const int pixels_width, const int pixels_height)
GraphicsInteropBuffer & graphics_interop_get_buffer()
void graphics_interop_deactivate()
GraphicsInteropDevice graphics_interop_get_device()
void unmap_texture_buffer()
#define CCL_NAMESPACE_END
#define DCHECK(expression)
std::unique_lock< std::mutex > thread_scoped_lock