26 texture_state_.is_outdated =
true;
28 if (!reset_rendering) {
29 driver_->next_tile_begin();
33void PathTraceDisplay::mark_texture_updated()
35 texture_state_.is_outdated =
false;
44 DCHECK(!update_state_.is_active);
46 if (update_state_.is_active) {
47 LOG(ERROR) <<
"Attempt to re-activate update process.";
58 texture_state_.size =
make_int2(texture_width, texture_height);
61 if (!driver_->update_begin(
params, texture_width, texture_height)) {
62 LOG(ERROR) <<
"PathTraceDisplay implementation could not begin update.";
66 update_state_.is_active =
true;
73 DCHECK(update_state_.is_active);
75 if (!update_state_.is_active) {
76 LOG(ERROR) <<
"Attempt to deactivate inactive update process.";
80 driver_->update_end();
82 update_state_.is_active =
false;
87 return texture_state_.size;
95 const half4 *rgba_pixels,
int texture_x,
int texture_y,
int pixels_width,
int pixels_height)
97 DCHECK(update_state_.is_active);
99 if (!update_state_.is_active) {
100 LOG(ERROR) <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
104 mark_texture_updated();
113 if (!mapped_rgba_pixels) {
117 const int texture_width = texture_state_.size.x;
118 const int texture_height = texture_state_.size.y;
120 if (texture_x == 0 && texture_y == 0 && pixels_width == texture_width &&
121 pixels_height == texture_height)
123 const size_t size_in_bytes =
sizeof(
half4) * texture_width * texture_height;
124 memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes);
127 const half4 *rgba_row = rgba_pixels;
128 half4 *mapped_rgba_row = mapped_rgba_pixels + texture_y * texture_width + texture_x;
129 for (
int y = 0;
y < pixels_height;
130 ++
y, rgba_row += pixels_width, mapped_rgba_row += texture_width)
132 memcpy(mapped_rgba_row, rgba_row,
sizeof(
half4) * pixels_width);
145 DCHECK(!texture_buffer_state_.is_mapped);
146 DCHECK(update_state_.is_active);
148 if (texture_buffer_state_.is_mapped) {
149 LOG(ERROR) <<
"Attempt to re-map an already mapped texture buffer.";
153 if (!update_state_.is_active) {
154 LOG(ERROR) <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
158 half4 *mapped_rgba_pixels = driver_->map_texture_buffer();
160 if (mapped_rgba_pixels) {
161 texture_buffer_state_.is_mapped =
true;
164 return mapped_rgba_pixels;
169 DCHECK(texture_buffer_state_.is_mapped);
171 if (!texture_buffer_state_.is_mapped) {
172 LOG(ERROR) <<
"Attempt to unmap non-mapped texture buffer.";
176 texture_buffer_state_.is_mapped =
false;
178 mark_texture_updated();
179 driver_->unmap_texture_buffer();
188 DCHECK(!texture_buffer_state_.is_mapped);
189 DCHECK(update_state_.is_active);
191 if (texture_buffer_state_.is_mapped) {
193 <<
"Attempt to use graphics interoperability mode while the texture buffer is mapped.";
197 if (!update_state_.is_active) {
198 LOG(ERROR) <<
"Attempt to use graphics interoperability outside of PathTraceDisplay update.";
203 mark_texture_updated();
205 return driver_->graphics_interop_get();
210 driver_->graphics_interop_activate();
215 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()
DisplayDriver::GraphicsInterop graphics_interop_get()
bool update_begin(int texture_width, int texture_height)
void graphics_interop_deactivate()
void copy_pixels_to_texture(const half4 *rgba_pixels, int texture_x, int texture_y, int pixels_width, int pixels_height)
void unmap_texture_buffer()
#define CCL_NAMESPACE_END
#define DCHECK(expression)
std::unique_lock< std::mutex > thread_scoped_lock