Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_display_driver.cpp
| Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | if (texture_.buffer_width != buffer_width || texture_.buffer_height != buffer_height) { | ||||
| texture_.buffer_width = buffer_width; | texture_.buffer_width = buffer_width; | ||||
| texture_.buffer_height = buffer_height; | texture_.buffer_height = buffer_height; | ||||
| } | } | ||||
| /* New content will be provided to the texture in one way or another, so mark this in a | /* New content will be provided to the texture in one way or another, so mark this in a | ||||
| * centralized place. */ | * centralized place. */ | ||||
| texture_.need_update = true; | texture_.need_update = true; | ||||
| texture_.params = params; | |||||
| return true; | return true; | ||||
| } | } | ||||
| void BlenderDisplayDriver::update_end() | void BlenderDisplayDriver::update_end() | ||||
| { | { | ||||
| gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); | gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); | ||||
| glFlush(); | glFlush(); | ||||
| ▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | void BlenderDisplayDriver::texture_update_if_needed() | ||||
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id); | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_.gl_pbo_id); | ||||
| glTexSubImage2D( | glTexSubImage2D( | ||||
| GL_TEXTURE_2D, 0, 0, 0, texture_.width, texture_.height, GL_RGBA, GL_HALF_FLOAT, 0); | GL_TEXTURE_2D, 0, 0, 0, texture_.width, texture_.height, GL_RGBA, GL_HALF_FLOAT, 0); | ||||
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | ||||
| texture_.need_update = false; | texture_.need_update = false; | ||||
| } | } | ||||
| void BlenderDisplayDriver::vertex_buffer_update(const Params ¶ms) | void BlenderDisplayDriver::vertex_buffer_update(const Params & /*params*/) | ||||
| { | { | ||||
| /* Draw at the parameters for which the texture has been updated for. This allows to always draw | |||||
| * texture during bordered-rendered camera view without flickering. The validness of the display | |||||
| * parameters for a texture is guaranteed by the initial "clear" state which makes drawing to | |||||
| * have an early output. | |||||
| * | |||||
| * Such approach can cause some extra "jelly" effect during panning, but it is not more jelly | |||||
| * than overlay of selected objects. Also, it's possible to redraw texture at an intersection of | |||||
| * the texture draw parameters and the latest updated draw paaremters (altohoyugh, complexity of | |||||
| * doing it might not worth it. */ | |||||
| const int x = texture_.params.full_offset.x; | |||||
| const int y = texture_.params.full_offset.y; | |||||
| const int width = texture_.params.size.x; | |||||
| const int height = texture_.params.size.y; | |||||
| /* Invalidate old contents - avoids stalling if the buffer is still waiting in queue to be | /* Invalidate old contents - avoids stalling if the buffer is still waiting in queue to be | ||||
| * rendered. */ | * rendered. */ | ||||
| glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW); | glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW); | ||||
| float *vpointer = reinterpret_cast<float *>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY)); | float *vpointer = reinterpret_cast<float *>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY)); | ||||
| if (!vpointer) { | if (!vpointer) { | ||||
| return; | return; | ||||
| } | } | ||||
| vpointer[0] = 0.0f; | vpointer[0] = 0.0f; | ||||
| vpointer[1] = 0.0f; | vpointer[1] = 0.0f; | ||||
| vpointer[2] = params.full_offset.x; | vpointer[2] = x; | ||||
| vpointer[3] = params.full_offset.y; | vpointer[3] = y; | ||||
| vpointer[4] = 1.0f; | vpointer[4] = 1.0f; | ||||
| vpointer[5] = 0.0f; | vpointer[5] = 0.0f; | ||||
| vpointer[6] = (float)params.size.x + params.full_offset.x; | vpointer[6] = x + width; | ||||
| vpointer[7] = params.full_offset.y; | vpointer[7] = y; | ||||
| vpointer[8] = 1.0f; | vpointer[8] = 1.0f; | ||||
| vpointer[9] = 1.0f; | vpointer[9] = 1.0f; | ||||
| vpointer[10] = (float)params.size.x + params.full_offset.x; | vpointer[10] = x + width; | ||||
| vpointer[11] = (float)params.size.y + params.full_offset.y; | vpointer[11] = y + height; | ||||
| vpointer[12] = 0.0f; | vpointer[12] = 0.0f; | ||||
| vpointer[13] = 1.0f; | vpointer[13] = 1.0f; | ||||
| vpointer[14] = params.full_offset.x; | vpointer[14] = x; | ||||
| vpointer[15] = (float)params.size.y + params.full_offset.y; | vpointer[15] = y + height; | ||||
| glUnmapBuffer(GL_ARRAY_BUFFER); | glUnmapBuffer(GL_ARRAY_BUFFER); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||