95 viewport->flag &= ~DO_UPDATE;
104 viewport->size[0] = viewport->size[1] = -1;
105 viewport->active_view = 0;
118 return &viewport->draw_data;
123 int *size = viewport->size;
124 float const empty_pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
127 if (viewport->color_render_tx[0] ==
nullptr) {
146 if ((viewport->flag &
GPU_VIEWPORT_STEREO) != 0 && viewport->color_render_tx[1] ==
nullptr) {
163 if (viewport->depth_tx ==
nullptr) {
174 static int depth_clear = 0;
179 if (!viewport->depth_tx || !viewport->color_render_tx[0] || !viewport->color_overlay_tx[0]) {
189 for (
int i = 0; i < 2; i++) {
212 viewport->active_view =
view;
217 GPUTexture *
color, *depth;
228 if (!is_xr_surface) {
233 viewport->depth_tx = depth;
251 if (viewport->view_settings.curve_mapping) {
253 viewport->view_settings.curve_mapping->changed_timestamp)
260 if (viewport->orig_curve_mapping != view_settings->
curve_mapping) {
266 CurveMapping *tmp_curve_mapping_vp = viewport->view_settings.curve_mapping;
268 viewport->view_settings.curve_mapping =
nullptr;
273 viewport->view_settings.curve_mapping = tmp_curve_mapping_vp;
275 if (tmp_curve_mapping && viewport->view_settings.curve_mapping ==
nullptr) {
281 viewport->dither = dither;
282 viewport->do_color_management =
true;
294 &viewport->stereo_comp_fb,
299 GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[0]),
300 GPU_ATTACHMENT_TEXTURE(viewport->color_render_tx[0]),
375 const uint vbo_len = 4;
403 const rctf *rect_pos,
406 const float compare_limit = 0.0001f;
407 const bool parameters_changed =
409 &viewport->batch.last_used_parameters.rect_pos, rect_pos, compare_limit) ||
410 !
BLI_rctf_compare(&viewport->batch.last_used_parameters.rect_uv, rect_uv, compare_limit));
412 if (viewport->batch.batch && parameters_changed) {
414 viewport->batch.batch =
nullptr;
417 if (!viewport->batch.batch) {
419 viewport->batch.last_used_parameters.rect_pos = *rect_pos;
420 viewport->batch.last_used_parameters.rect_uv = *rect_uv;
422 return viewport->batch.batch;
427 if (viewport->batch.batch) {
429 viewport->batch.batch =
nullptr;
437 const rctf *rect_pos,
439 bool display_colorspace,
440 bool do_overlay_merge)
442 GPUTexture *color = viewport->color_render_tx[
view];
443 GPUTexture *color_overlay = viewport->color_overlay_tx[
view];
445 bool use_ocio =
false;
449 if (viewport->do_color_management && display_colorspace) {
459 &viewport->display_settings,
491 bool display_colorspace,
492 bool do_overlay_merge)
494 GPUTexture *color = viewport->color_render_tx[
view];
496 if (color ==
nullptr) {
504 rcti sanitized_rect = *rect;
515 pos_rect.
xmin = sanitized_rect.
xmin;
516 pos_rect.ymin = sanitized_rect.
ymin;
517 pos_rect.xmax = sanitized_rect.
xmin +
w;
518 pos_rect.ymax = sanitized_rect.
ymin + h;
521 uv_rect.
xmin = halfx;
522 uv_rect.ymin = halfy;
523 uv_rect.xmax = halfx + 1.0f;
524 uv_rect.ymax = halfy + 1.0f;
529 std::swap(uv_rect.xmin, uv_rect.xmax);
532 std::swap(uv_rect.ymin, uv_rect.ymax);
536 viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
546 bool display_colorspace,
547 bool do_overlay_merge)
551 if (viewport->color_render_tx[view] ==
nullptr) {
559 pos_rect.
xmin = -1.0f;
560 pos_rect.ymin = -1.0f;
561 pos_rect.xmax = 1.0f;
562 pos_rect.ymax = 1.0f;
571 viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
574 viewport->depth_tx =
nullptr;
585 return viewport->active_view;
595 return viewport->color_render_tx[
view];
600 return viewport->color_overlay_tx[
view];
605 return viewport->depth_tx;
611 &viewport->overlay_fb,
613 GPU_ATTACHMENT_TEXTURE(viewport->depth_tx),
614 GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[viewport->active_view]),
616 return viewport->overlay_fb;
621 if (viewport->draw_data) {
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE bool equals_v2v2_int(const int v1[2], const int v2[2]) ATTR_WARN_UNUSED_RESULT
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_sanitize(struct rcti *rect)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
#define SET_FLAG_FROM_TEST(value, test, flag)
@ COLORMANAGE_VIEW_USE_HDR
@ S3D_ANAGLYPH_YELLOWBLUE
@ S3D_ANAGLYPH_GREENMAGENTA
void DRW_gpu_context_disable()
void DRW_gpu_context_enable()
void DRW_viewport_data_free(DRWData *drw_data)
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_program_set_imm_shader(blender::gpu::Batch *batch)
void GPU_batch_program_set_builtin(blender::gpu::Batch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_draw(blender::gpu::Batch *batch)
#define GPU_batch_uniform_1i(batch, name, x)
bool GPU_clear_viewport_workaround()
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
int GPU_offscreen_width(const GPUOffScreen *offscreen)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
void GPU_offscreen_viewport_data_get(GPUOffScreen *offscreen, GPUFrameBuffer **r_fb, GPUTexture **r_color, GPUTexture **r_depth)
void GPU_framebuffer_restore()
int GPU_offscreen_height(const GPUOffScreen *offscreen)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_matrix_identity_projection_set()
void GPU_matrix_identity_set()
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
@ GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE
@ GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE
void GPU_color_mask(bool r, bool g, bool b, bool a)
void GPU_depth_test(eGPUDepthTest test)
int GPU_texture_height(const GPUTexture *texture)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
int GPU_texture_width(const GPUTexture *texture)
void GPU_texture_clear(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
#define GPU_TEXTURE_FREE_SAFE(texture)
void GPU_vertbuf_attr_get_raw_data(blender::gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void IMB_colormanagement_finish_glsl_draw()
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
draw_view in_light_buf[] float
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
GPUTexture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
void GPU_viewport_unbind(GPUViewport *)
static const GPUVertFormat & gpu_viewport_batch_format()
void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool display_colorspace, bool do_overlay_merge)
void GPU_viewport_colorspace_set(GPUViewport *viewport, ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither)
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, int view, const rcti *rect, bool display_colorspace, bool do_overlay_merge)
GPUViewport * GPU_viewport_create()
GPUViewport * GPU_viewport_stereo_create()
static blender::gpu::Batch * gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
static void gpu_viewport_draw_colormanaged(GPUViewport *viewport, int view, const rctf *rect_pos, const rctf *rect_uv, bool display_colorspace, bool do_overlay_merge)
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool is_xr_surface)
static void gpu_viewport_textures_create(GPUViewport *viewport)
bool GPU_viewport_is_stereo_get(GPUViewport *viewport)
bool GPU_viewport_do_update(GPUViewport *viewport)
static blender::gpu::Batch * gpu_viewport_batch_get(GPUViewport *viewport, const rctf *rect_pos, const rctf *rect_uv)
int GPU_viewport_active_view_get(GPUViewport *viewport)
static void gpu_viewport_textures_free(GPUViewport *viewport)
void GPU_viewport_free(GPUViewport *viewport)
GPUTexture * GPU_viewport_depth_texture(GPUViewport *viewport)
struct @645::@648 attr_id
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
static void gpu_viewport_batch_free(GPUViewport *viewport)
static struct @645 g_viewport
void GPU_viewport_tag_update(GPUViewport *viewport)
GPUFrameBuffer * GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
GPUTexture * GPU_viewport_overlay_texture(GPUViewport *viewport, int view)
DRWData ** GPU_viewport_data_get(GPUViewport *viewport)
BLI_INLINE float fb(float length, float L)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline int rect_size(int4 rect)
struct CurveMapping * curve_mapping
blender::gpu::Batch * batch
struct GPUViewportBatch::@647 last_used_parameters
GPUFrameBuffer * overlay_fb
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
GPUTexture * color_overlay_tx[2]
GPUTexture * color_render_tx[2]
GPUFrameBuffer * stereo_comp_fb
CurveMapping * orig_curve_mapping