Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_viewport.c
| Show All 34 Lines | |||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #include "DNA_vec_types.h" | #include "DNA_vec_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "GPU_framebuffer.h" | #include "GPU_framebuffer.h" | ||||
| #include "GPU_glew.h" | #include "GPU_glew.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_matrix.h" | |||||
| #include "GPU_texture.h" | #include "GPU_texture.h" | ||||
| #include "GPU_viewport.h" | #include "GPU_viewport.h" | ||||
| #include "GPU_uniformbuffer.h" | #include "GPU_uniformbuffer.h" | ||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Show All 12 Lines | typedef struct ViewportTempTexture { | ||||
| void *user[MAX_ENGINE_BUFFER_SHARING]; | void *user[MAX_ENGINE_BUFFER_SHARING]; | ||||
| GPUTexture *texture; | GPUTexture *texture; | ||||
| } ViewportTempTexture; | } ViewportTempTexture; | ||||
| struct GPUViewport { | struct GPUViewport { | ||||
| int size[2]; | int size[2]; | ||||
| int flag; | int flag; | ||||
| /* set the active view (for stereoscoptic viewport rendering) */ | |||||
fclem: Uppercase first letter and end with fullstop!
Also the comment should be
`/* Active view used… | |||||
| int active_view; | |||||
| /* If engine_handles mismatch we free all ViewportEngineData in this viewport */ | /* If engine_handles mismatch we free all ViewportEngineData in this viewport */ | ||||
| struct { | struct { | ||||
| void *handle; | void *handle; | ||||
| ViewportEngineData *data; | ViewportEngineData *data; | ||||
| } engine_data[MAX_ENABLE_ENGINE]; | } engine_data[MAX_ENABLE_ENGINE]; | ||||
| DefaultFramebufferList *fbl; | DefaultFramebufferList *fbl; | ||||
| DefaultTextureList *txl; | DefaultTextureList *txl; | ||||
| Show All 12 Lines | struct GPUViewport { | ||||
| float dither; | float dither; | ||||
| /* TODO(fclem) the uvimage display use the viewport but do not set any view transform for the | /* TODO(fclem) the uvimage display use the viewport but do not set any view transform for the | ||||
| * moment. The end goal would be to let the GPUViewport do the color management. */ | * moment. The end goal would be to let the GPUViewport do the color management. */ | ||||
| bool do_color_management; | bool do_color_management; | ||||
| }; | }; | ||||
| enum { | enum { | ||||
| DO_UPDATE = (1 << 0), | DO_UPDATE = (1 << 0), | ||||
| GPU_VIEWPORT_STEREO = (1 << 1), | |||||
| }; | }; | ||||
| static void gpu_viewport_buffers_free(FramebufferList *fbl, | static void gpu_viewport_buffers_free(FramebufferList *fbl, | ||||
| int fbl_len, | int fbl_len, | ||||
| TextureList *txl, | TextureList *txl, | ||||
| int txl_len); | int txl_len); | ||||
| static void gpu_viewport_storage_free(StorageList *stl, int stl_len); | static void gpu_viewport_storage_free(StorageList *stl, int stl_len); | ||||
| static void gpu_viewport_passes_free(PassList *psl, int psl_len); | static void gpu_viewport_passes_free(PassList *psl, int psl_len); | ||||
| static void gpu_viewport_texture_pool_free(GPUViewport *viewport); | static void gpu_viewport_texture_pool_free(GPUViewport *viewport); | ||||
| void GPU_viewport_tag_update(GPUViewport *viewport) | void GPU_viewport_tag_update(GPUViewport *viewport) | ||||
| { | { | ||||
| viewport->flag |= DO_UPDATE; | viewport->flag |= DO_UPDATE; | ||||
| } | } | ||||
| bool GPU_viewport_do_update(GPUViewport *viewport) | bool GPU_viewport_do_update(GPUViewport *viewport) | ||||
| { | { | ||||
| bool ret = (viewport->flag & DO_UPDATE); | bool ret = (viewport->flag & DO_UPDATE); | ||||
| viewport->flag &= ~DO_UPDATE; | viewport->flag &= ~DO_UPDATE; | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| GPUViewport *GPU_viewport_create(void) | GPUViewport *GPU_viewport_create(bool stereo) | ||||
| { | { | ||||
| GPUViewport *viewport = MEM_callocN(sizeof(GPUViewport), "GPUViewport"); | GPUViewport *viewport = MEM_callocN(sizeof(GPUViewport), "GPUViewport"); | ||||
| viewport->fbl = MEM_callocN(sizeof(DefaultFramebufferList), "FramebufferList"); | viewport->fbl = MEM_callocN(sizeof(DefaultFramebufferList), "FramebufferList"); | ||||
| viewport->txl = MEM_callocN(sizeof(DefaultTextureList), "TextureList"); | viewport->txl = MEM_callocN(sizeof(DefaultTextureList), "TextureList"); | ||||
| viewport->idatalist = DRW_instance_data_list_create(); | viewport->idatalist = DRW_instance_data_list_create(); | ||||
| viewport->do_color_management = false; | viewport->do_color_management = false; | ||||
| viewport->size[0] = viewport->size[1] = -1; | viewport->size[0] = viewport->size[1] = -1; | ||||
| SET_FLAG_FROM_TEST(viewport->flag, stereo, GPU_VIEWPORT_STEREO); | |||||
| viewport->active_view = -1; | |||||
| return viewport; | return viewport; | ||||
| } | } | ||||
| void *GPU_viewport_engine_data_create(GPUViewport *viewport, void *engine_type) | void *GPU_viewport_engine_data_create(GPUViewport *viewport, void *engine_type) | ||||
| { | { | ||||
| ViewportEngineData *data = MEM_callocN(sizeof(ViewportEngineData), "ViewportEngineData"); | ViewportEngineData *data = MEM_callocN(sizeof(ViewportEngineData), "ViewportEngineData"); | ||||
| int fbl_len, txl_len, psl_len, stl_len; | int fbl_len, txl_len, psl_len, stl_len; | ||||
| ▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | void GPU_viewport_cache_release(GPUViewport *viewport) | ||||
| for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) { | for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) { | ||||
| ViewportEngineData *data = viewport->engine_data[i].data; | ViewportEngineData *data = viewport->engine_data[i].data; | ||||
| int psl_len; | int psl_len; | ||||
| DRW_engine_viewport_data_size_get(data->engine_type, NULL, NULL, &psl_len, NULL); | DRW_engine_viewport_data_size_get(data->engine_type, NULL, NULL, &psl_len, NULL); | ||||
| gpu_viewport_passes_free(data->psl, psl_len); | gpu_viewport_passes_free(data->psl, psl_len); | ||||
| } | } | ||||
| } | } | ||||
| static void gpu_viewport_default_fb_create(GPUViewport *viewport) | void GPU_viewport_framebuffer_view_set(GPUViewport *viewport, int view) | ||||
Done Inline ActionsI'm not a huge fan of having a state dependent view here. I would prefer if all viewport functions that are used for a specific view would take the view as argument. fclem: I'm not a huge fan of having a state dependent view here.
I would prefer if all viewport… | |||||
| { | { | ||||
| /* Early check if the view is the latest requested. */ | |||||
| if (viewport->active_view == view) { | |||||
| return; | |||||
| } | |||||
| DefaultFramebufferList *dfbl = viewport->fbl; | DefaultFramebufferList *dfbl = viewport->fbl; | ||||
| DefaultTextureList *dtxl = viewport->txl; | DefaultTextureList *dtxl = viewport->txl; | ||||
| int *size = viewport->size; | |||||
| bool ok = true; | |||||
| dtxl->color = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL); | /* Only swap the texture when this is a Stereo Viewport. */ | ||||
| dtxl->color_overlay = GPU_texture_create_2d(size[0], size[1], GPU_SRGB8_A8, NULL, NULL); | if (((viewport->flag & GPU_VIEWPORT_STEREO) != 0)) { | ||||
| SWAP(GPUTexture *, dtxl->color, dtxl->color_stereo); | |||||
| /* Can be shared with GPUOffscreen. */ | SWAP(GPUTexture *, dtxl->color_overlay, dtxl->color_overlay_stereo); | ||||
| if (dtxl->depth == NULL) { | |||||
| dtxl->depth = GPU_texture_create_2d(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL); | |||||
| } | |||||
| if (!dtxl->depth || !dtxl->color) { | |||||
| ok = false; | |||||
| goto cleanup; | |||||
| } | } | ||||
| GPU_framebuffer_ensure_config(&dfbl->default_fb, | GPU_framebuffer_ensure_config(&dfbl->default_fb, | ||||
| { | { | ||||
| GPU_ATTACHMENT_TEXTURE(dtxl->depth), | GPU_ATTACHMENT_TEXTURE(dtxl->depth), | ||||
| GPU_ATTACHMENT_TEXTURE(dtxl->color), | GPU_ATTACHMENT_TEXTURE(dtxl->color), | ||||
| }); | }); | ||||
| Show All 16 Lines | GPU_framebuffer_ensure_config(&dfbl->color_only_fb, | ||||
| }); | }); | ||||
| GPU_framebuffer_ensure_config(&dfbl->overlay_only_fb, | GPU_framebuffer_ensure_config(&dfbl->overlay_only_fb, | ||||
| { | { | ||||
| GPU_ATTACHMENT_NONE, | GPU_ATTACHMENT_NONE, | ||||
| GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay), | GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay), | ||||
| }); | }); | ||||
| if (((viewport->flag & GPU_VIEWPORT_STEREO) != 0)) { | |||||
| GPU_framebuffer_ensure_config(&dfbl->stereo_comp_fb, | |||||
| { | |||||
| GPU_ATTACHMENT_NONE, | |||||
| GPU_ATTACHMENT_TEXTURE(dtxl->color_stereo_comp), | |||||
| GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay_stereo_comp), | |||||
| }); | |||||
| } | |||||
| else { | |||||
| dfbl->stereo_comp_fb = NULL; | |||||
| } | |||||
| viewport->active_view = view; | |||||
| } | |||||
| static void gpu_viewport_default_fb_create(GPUViewport *viewport) | |||||
| { | |||||
| DefaultFramebufferList *dfbl = viewport->fbl; | |||||
| DefaultTextureList *dtxl = viewport->txl; | |||||
| int *size = viewport->size; | |||||
| bool ok = true; | |||||
| dtxl->color = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL); | |||||
| dtxl->color_overlay = GPU_texture_create_2d(size[0], size[1], GPU_SRGB8_A8, NULL, NULL); | |||||
| if (((viewport->flag & GPU_VIEWPORT_STEREO) != 0)) { | |||||
| dtxl->color_stereo = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL); | |||||
| dtxl->color_overlay_stereo = GPU_texture_create_2d(size[0], size[1], GPU_SRGB8_A8, NULL, NULL); | |||||
| dtxl->color_stereo_comp = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL); | |||||
| dtxl->color_overlay_stereo_comp = GPU_texture_create_2d( | |||||
| size[0], size[1], GPU_SRGB8_A8, NULL, NULL); | |||||
| } | |||||
| /* Can be shared with GPUOffscreen. */ | |||||
| if (dtxl->depth == NULL) { | |||||
| dtxl->depth = GPU_texture_create_2d(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL); | |||||
| } | |||||
| if (!dtxl->depth || !dtxl->color) { | |||||
| ok = false; | |||||
| goto cleanup; | |||||
| } | |||||
| GPU_viewport_framebuffer_view_set(viewport, 0); | |||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->default_fb, NULL); | ok = ok && GPU_framebuffer_check_valid(dfbl->default_fb, NULL); | ||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->overlay_fb, NULL); | ok = ok && GPU_framebuffer_check_valid(dfbl->overlay_fb, NULL); | ||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->color_only_fb, NULL); | ok = ok && GPU_framebuffer_check_valid(dfbl->color_only_fb, NULL); | ||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->depth_only_fb, NULL); | ok = ok && GPU_framebuffer_check_valid(dfbl->depth_only_fb, NULL); | ||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->overlay_only_fb, NULL); | ok = ok && GPU_framebuffer_check_valid(dfbl->overlay_only_fb, NULL); | ||||
| if (((viewport->flag & GPU_VIEWPORT_STEREO) != 0)) { | |||||
| ok = ok && GPU_framebuffer_check_valid(dfbl->stereo_comp_fb, NULL); | |||||
| } | |||||
| cleanup: | cleanup: | ||||
| if (!ok) { | if (!ok) { | ||||
| GPU_viewport_free(viewport); | GPU_viewport_free(viewport); | ||||
| DRW_opengl_context_disable(); | DRW_opengl_context_disable(); | ||||
| return; | return; | ||||
| } | } | ||||
| GPU_framebuffer_restore(); | GPU_framebuffer_restore(); | ||||
| } | } | ||||
| void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect) | void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect) | ||||
| { | { | ||||
| DefaultFramebufferList *dfbl = viewport->fbl; | DefaultFramebufferList *dfbl = viewport->fbl; | ||||
| int fbl_len, txl_len; | int fbl_len, txl_len; | ||||
| int rect_size[2]; | int rect_size[2]; | ||||
| /* add one pixel because of scissor test */ | /* add one pixel because of scissor test */ | ||||
| rect_size[0] = BLI_rcti_size_x(rect) + 1; | rect_size[0] = BLI_rcti_size_x(rect) + 1; | ||||
| rect_size[1] = BLI_rcti_size_y(rect) + 1; | rect_size[1] = BLI_rcti_size_y(rect) + 1; | ||||
| Show All 9 Lines | if (!equals_v2v2_int(viewport->size, rect_size)) { | ||||
| for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) { | for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) { | ||||
| ViewportEngineData *data = viewport->engine_data[i].data; | ViewportEngineData *data = viewport->engine_data[i].data; | ||||
| DRW_engine_viewport_data_size_get(data->engine_type, &fbl_len, &txl_len, NULL, NULL); | DRW_engine_viewport_data_size_get(data->engine_type, &fbl_len, &txl_len, NULL, NULL); | ||||
| gpu_viewport_buffers_free(data->fbl, fbl_len, data->txl, txl_len); | gpu_viewport_buffers_free(data->fbl, fbl_len, data->txl, txl_len); | ||||
| } | } | ||||
| gpu_viewport_texture_pool_free(viewport); | gpu_viewport_texture_pool_free(viewport); | ||||
| viewport->active_view = -1; | |||||
| } | } | ||||
| } | } | ||||
| copy_v2_v2_int(viewport->size, rect_size); | copy_v2_v2_int(viewport->size, rect_size); | ||||
| gpu_viewport_texture_pool_clear_users(viewport); | gpu_viewport_texture_pool_clear_users(viewport); | ||||
| if (!dfbl->default_fb) { | if (!dfbl->default_fb) { | ||||
| gpu_viewport_default_fb_create(viewport); | gpu_viewport_default_fb_create(viewport); | ||||
| } | } | ||||
| GPU_viewport_framebuffer_view_set(viewport, view); | |||||
| } | } | ||||
| void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs) | void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs) | ||||
| { | { | ||||
| DefaultFramebufferList *dfbl = viewport->fbl; | DefaultFramebufferList *dfbl = viewport->fbl; | ||||
| DefaultTextureList *dtxl = viewport->txl; | DefaultTextureList *dtxl = viewport->txl; | ||||
| GPUTexture *color, *depth; | GPUTexture *color, *depth; | ||||
| GPUFrameBuffer *fb; | GPUFrameBuffer *fb; | ||||
| Show All 18 Lines | void GPU_viewport_colorspace_set(GPUViewport *viewport, | ||||
| float dither) | float dither) | ||||
| { | { | ||||
| memcpy(&viewport->view_settings, view_settings, sizeof(*view_settings)); | memcpy(&viewport->view_settings, view_settings, sizeof(*view_settings)); | ||||
| memcpy(&viewport->display_settings, display_settings, sizeof(*display_settings)); | memcpy(&viewport->display_settings, display_settings, sizeof(*display_settings)); | ||||
| viewport->dither = dither; | viewport->dither = dither; | ||||
| viewport->do_color_management = true; | viewport->do_color_management = true; | ||||
| } | } | ||||
| void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format) | |||||
| { | |||||
| DefaultTextureList *dtxl = viewport->txl; | |||||
| DefaultFramebufferList *dfbl = viewport->fbl; | |||||
| GPUVertFormat *vert_format = immVertexFormat(); | |||||
| uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| GPU_framebuffer_bind(dfbl->stereo_comp_fb); | |||||
| GPU_matrix_push(); | |||||
| GPU_matrix_push_projection(); | |||||
| GPU_matrix_identity_set(); | |||||
| GPU_matrix_identity_projection_set(); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE); | |||||
| immUniform1i("image_r_texture", 0); | |||||
| immUniform1i("image_l_texture", 1); | |||||
| immUniform1i("overlays_r_texture", 2); | |||||
| immUniform1i("overlays_l_texture", 3); | |||||
| bool swap = false; | |||||
| int settings = stereo_format->display_mode & 0x111; | |||||
| if (settings == S3D_DISPLAY_ANAGLYPH) { | |||||
| settings |= stereo_format->anaglyph_type << 3; | |||||
| } | |||||
Done Inline ActionsRemove mask. It is incorrect jbakker: Remove mask. It is incorrect | |||||
| else if (settings == S3D_DISPLAY_INTERLACE) { | |||||
| settings |= stereo_format->interlace_type << 3; | |||||
| swap = (stereo_format->flag & S3D_INTERLACE_SWAP) != 0; | |||||
| } | |||||
| immUniform1i("stereoDisplaySettings", settings); | |||||
| if (swap) { | |||||
| GPU_texture_bind(dtxl->color, 1); | |||||
| GPU_texture_bind(dtxl->color_stereo, 0); | |||||
| GPU_texture_bind(dtxl->color_overlay, 3); | |||||
| GPU_texture_bind(dtxl->color_overlay_stereo, 2); | |||||
| } | |||||
| else { | |||||
| GPU_texture_bind(dtxl->color, 0); | |||||
| GPU_texture_bind(dtxl->color_stereo, 1); | |||||
| GPU_texture_bind(dtxl->color_overlay, 2); | |||||
| GPU_texture_bind(dtxl->color_overlay_stereo, 3); | |||||
| } | |||||
| immBegin(GPU_PRIM_TRI_STRIP, 4); | |||||
| immAttr2f(texco, 0.0f, 0.0f); | |||||
| immVertex2f(pos, -1.0f, -1.0f); | |||||
| immAttr2f(texco, 1.0f, 0.0f); | |||||
| immVertex2f(pos, 1.0f, -1.0f); | |||||
| immAttr2f(texco, 0.0f, 1.0f); | |||||
| immVertex2f(pos, -1.0f, 1.0f); | |||||
| immAttr2f(texco, 1.0f, 1.0f); | |||||
| immVertex2f(pos, 1.0f, 1.0f); | |||||
| immEnd(); | |||||
| GPU_texture_unbind(dtxl->color); | |||||
| GPU_texture_unbind(dtxl->color_stereo); | |||||
| GPU_texture_unbind(dtxl->color_overlay); | |||||
| GPU_texture_unbind(dtxl->color_overlay_stereo); | |||||
| immUnbindProgram(); | |||||
| GPU_matrix_pop_projection(); | |||||
| GPU_matrix_pop(); | |||||
| GPU_framebuffer_restore(); | |||||
| } | |||||
| static void gpu_viewport_draw_colormanaged(GPUViewport *viewport, | static void gpu_viewport_draw_colormanaged(GPUViewport *viewport, | ||||
| const rctf *rect_pos, | const rctf *rect_pos, | ||||
| const rctf *rect_uv, | const rctf *rect_uv, | ||||
| bool display_colorspace) | bool display_colorspace) | ||||
| { | { | ||||
| DefaultTextureList *dtxl = viewport->txl; | DefaultTextureList *dtxl = viewport->txl; | ||||
| GPUTexture *color = dtxl->color; | GPUTexture *color = dtxl->color; | ||||
| GPUTexture *color_overlay = dtxl->color_overlay; | GPUTexture *color_overlay = dtxl->color_overlay; | ||||
| if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0) { | |||||
| color = dtxl->color_stereo_comp; | |||||
| color_overlay = dtxl->color_overlay_stereo_comp; | |||||
| } | |||||
| GPUVertFormat *vert_format = immVertexFormat(); | GPUVertFormat *vert_format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| bool use_ocio = false; | bool use_ocio = false; | ||||
| if (viewport->do_color_management && display_colorspace) { | if (viewport->do_color_management && display_colorspace) { | ||||
| use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(&viewport->view_settings, | use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(&viewport->view_settings, | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void GPU_viewport_unbind(GPUViewport *UNUSED(viewport)) | void GPU_viewport_unbind(GPUViewport *UNUSED(viewport)) | ||||
| { | { | ||||
| GPU_framebuffer_restore(); | GPU_framebuffer_restore(); | ||||
| DRW_opengl_context_disable(); | DRW_opengl_context_disable(); | ||||
| } | } | ||||
| GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport) | GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport, int view) | ||||
| { | { | ||||
| DefaultFramebufferList *dfbl = viewport->fbl; | DefaultFramebufferList *dfbl = viewport->fbl; | ||||
| if (dfbl->default_fb) { | if (dfbl->default_fb) { | ||||
| DefaultTextureList *dtxl = viewport->txl; | DefaultTextureList *dtxl = viewport->txl; | ||||
| if (viewport->active_view == view) { | |||||
| return dtxl->color; | return dtxl->color; | ||||
| } | } | ||||
| else { | |||||
| return dtxl->color_stereo; | |||||
| } | |||||
| } | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| static void gpu_viewport_buffers_free(FramebufferList *fbl, | static void gpu_viewport_buffers_free(FramebufferList *fbl, | ||||
| int fbl_len, | int fbl_len, | ||||
| TextureList *txl, | TextureList *txl, | ||||
| int txl_len) | int txl_len) | ||||
| Show All 11 Lines | if (tex) { | ||||
| GPU_texture_free(tex); | GPU_texture_free(tex); | ||||
| txl->textures[i] = NULL; | txl->textures[i] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void gpu_viewport_storage_free(StorageList *stl, int stl_len) | static void gpu_viewport_storage_free(StorageList *stl, int stl_len) | ||||
| { | { | ||||
| for (int i = 0; i < stl_len; i++) { | for (int i = 0; i < stl_len; i++) { | ||||
Done Inline Actionsremove new line fclem: remove new line | |||||
| void *storage = stl->storage[i]; | void *storage = stl->storage[i]; | ||||
| if (storage) { | if (storage) { | ||||
| MEM_freeN(storage); | MEM_freeN(storage); | ||||
| stl->storage[i] = NULL; | stl->storage[i] = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||
Uppercase first letter and end with fullstop!
Also the comment should be
/* Active view used for stereo viewport rendering. */