Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_gpu_display.cpp
| Show First 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | bool BlenderGPUDisplay::do_update_begin(int texture_width, int texture_height) | ||||
| * | * | ||||
| * NOTE: Allocate the PBO for the the size which will fit the final render resolution (as in, | * NOTE: Allocate the PBO for the the size which will fit the final render resolution (as in, | ||||
| * at a resolution divider 1. This was we don't need to recreate graphics interoperability | * at a resolution divider 1. This was we don't need to recreate graphics interoperability | ||||
| * objects which are costly and which are tied to the specific underlying buffer size. | * objects which are costly and which are tied to the specific underlying buffer size. | ||||
| * The downside of this approach is that when graphics interopeability is not used we are sending | * The downside of this approach is that when graphics interopeability is not used we are sending | ||||
| * too much data to GPU when resolution divider is not 1. */ | * too much data to GPU when resolution divider is not 1. */ | ||||
| /* TODO(sergey): Investigate whether keeping the PBO exact size of the texute makes non-interop | /* TODO(sergey): Investigate whether keeping the PBO exact size of the texute makes non-interop | ||||
| * mode faster. */ | * mode faster. */ | ||||
| const int buffer_width = params_.size.x; | const int buffer_width = params_.full_size.x; | ||||
| const int buffer_height = params_.size.y; | const int buffer_height = params_.full_size.y; | ||||
| if (texture_.buffer_width != buffer_width || texture_.buffer_height != buffer_height) { | if (texture_.buffer_width != buffer_width || texture_.buffer_height != buffer_height) { | ||||
| const size_t size_in_bytes = sizeof(half4) * buffer_width * buffer_height; | const size_t size_in_bytes = sizeof(half4) * buffer_width * buffer_height; | ||||
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id_); | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id_); | ||||
| glBufferData(GL_PIXEL_UNPACK_BUFFER, size_in_bytes, 0, GL_DYNAMIC_DRAW); | glBufferData(GL_PIXEL_UNPACK_BUFFER, size_in_bytes, 0, GL_DYNAMIC_DRAW); | ||||
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | ||||
| texture_.buffer_width = buffer_width; | texture_.buffer_width = buffer_width; | ||||
| texture_.buffer_height = buffer_height; | texture_.buffer_height = buffer_height; | ||||
| Show All 35 Lines | void BlenderGPUDisplay::do_copy_pixels_to_texture( | ||||
| if (texture_x == 0 && texture_y == 0 && pixels_width == texture_.width && | if (texture_x == 0 && texture_y == 0 && pixels_width == texture_.width && | ||||
| pixels_height == texture_.height) { | pixels_height == texture_.height) { | ||||
| const size_t size_in_bytes = sizeof(half4) * texture_.width * texture_.height; | const size_t size_in_bytes = sizeof(half4) * texture_.width * texture_.height; | ||||
| memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes); | memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes); | ||||
| } | } | ||||
| else { | else { | ||||
| const half4 *rgba_row = rgba_pixels; | const half4 *rgba_row = rgba_pixels; | ||||
| half4 *mapped_rgba_row = mapped_rgba_pixels + texture_y * texture_.width; | half4 *mapped_rgba_row = mapped_rgba_pixels + texture_y * texture_.width + texture_x; | ||||
| for (int y = 0; y < pixels_height; | for (int y = 0; y < pixels_height; | ||||
| ++y, rgba_row += pixels_width, mapped_rgba_row += texture_.width) { | ++y, rgba_row += pixels_width, mapped_rgba_row += texture_.width) { | ||||
| memcpy(mapped_rgba_row, rgba_row, sizeof(half4) * pixels_width); | memcpy(mapped_rgba_row, rgba_row, sizeof(half4) * pixels_width); | ||||
| } | } | ||||
| } | } | ||||
| unmap_texture_buffer(); | unmap_texture_buffer(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines | |||||