[Bf-blender-cvs] [8d5996595fb] vr_scene_inspection: Fix compile errors and broken drawing after changes in master
Julian Eisel
noreply at git.blender.org
Mon Feb 17 12:34:56 CET 2020
Commit: 8d5996595fb0e4af89622fb0261169c4f6bdc83c
Author: Julian Eisel
Date: Mon Feb 17 12:15:42 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB8d5996595fb0e4af89622fb0261169c4f6bdc83c
Fix compile errors and broken drawing after changes in master
There are still some issues left after the changes in master:
* Some optimizations need to be redone differently
* Color-space handling needs to be redone differently
* Upside-down drawing is broken
===================================================================
M source/blender/gpu/GPU_viewport.h
M source/blender/gpu/intern/gpu_shader.c
M source/blender/gpu/intern/gpu_viewport.c
M source/blender/windowmanager/intern/wm_xr.c
===================================================================
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index d2c7d4c8825..2d125032f47 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -100,8 +100,6 @@ GPUViewport *GPU_viewport_create(void);
void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect);
void GPU_viewport_unbind(GPUViewport *viewport);
void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect);
-void GPU_viewport_draw_to_screen_ex(
- GPUViewport *viewport, float x1, float x2, float y1, float y2, bool to_srgb);
void GPU_viewport_free(GPUViewport *viewport);
void GPU_viewport_colorspace_set(GPUViewport *viewport,
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 274215f2bbc..c950a1daaa5 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -1013,11 +1013,6 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = {
.vert = datatoc_gpu_shader_2D_image_vert_glsl,
.frag = datatoc_gpu_shader_image_overlays_merge_frag_glsl,
},
- [GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB] =
- {
- .vert = datatoc_gpu_shader_2D_image_rect_vert_glsl,
- .frag = datatoc_gpu_shader_image_linear_frag_glsl,
- },
[GPU_SHADER_2D_IMAGE] =
{
.vert = datatoc_gpu_shader_2D_image_vert_glsl,
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 8dce0fcf927..a3ee2d11e56 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -549,8 +549,8 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
BLI_assert(h == BLI_rcti_size_y(rect) + 1);
/* wmOrtho for the screen has this same offset */
- const float halfx = GLA_PIXEL_OFS / ABS(x2 - x1);
- const float halfy = GLA_PIXEL_OFS / ABS(y2 - y1);
+ const float halfx = GLA_PIXEL_OFS / w;
+ const float halfy = GLA_PIXEL_OFS / h;
rctf pos_rect = {
.xmin = rect->xmin,
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index e88082b14e9..69df585fca5 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -234,17 +234,18 @@ void wm_xr_session_toggle(bContext *C, void *xr_context_ptr)
*
* \{ */
-static void wm_xr_surface_viewport_bind(wmXrSurfaceData *surface_data, const rcti *rect)
+static void wm_xr_surface_viewport_bind(wmXrSurfaceData *surface_data, const rcti *UNUSED(rect))
{
if (surface_data->viewport_bound == false) {
- GPU_viewport_bind(surface_data->viewport, rect);
+ // GPU_viewport_bind(surface_data->viewport, rect);
}
surface_data->viewport_bound = true;
}
static void wm_xr_surface_viewport_unbind(wmXrSurfaceData *surface_data)
{
if (surface_data->viewport_bound) {
- GPU_viewport_unbind(surface_data->viewport);
+ // GPU_viewport_unbind(surface_data->viewport);
+ GPU_framebuffer_restore();
}
surface_data->viewport_bound = false;
}
@@ -285,7 +286,6 @@ static void wm_xr_session_free_data(wmSurface *surface)
GPU_context_active_set(surface->gpu_ctx);
DRW_opengl_context_enable_ex(false);
if (data->viewport) {
- GPU_viewport_clear_from_offscreen(data->viewport);
GPU_viewport_free(data->viewport);
}
if (data->offscreen) {
@@ -319,7 +319,6 @@ static bool wm_xr_session_surface_offscreen_ensure(const GHOST_XrDrawViewInfo *d
DRW_opengl_context_enable();
if (surface_data->offscreen) {
- GPU_viewport_clear_from_offscreen(surface_data->viewport);
GPU_viewport_free(surface_data->viewport);
GPU_offscreen_free(surface_data->offscreen);
}
@@ -328,8 +327,7 @@ static bool wm_xr_session_surface_offscreen_ensure(const GHOST_XrDrawViewInfo *d
draw_view->width, draw_view->height, 0, true, false, err_out))) {
failure = true;
}
- if ((failure == false) &&
- !(surface_data->viewport = GPU_viewport_create_from_offscreen(surface_data->offscreen))) {
+ if ((failure == false) && !(surface_data->viewport = GPU_viewport_create())) {
GPU_offscreen_free(surface_data->offscreen);
failure = true;
}
@@ -471,6 +469,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
viewport = surface_data->viewport;
wm_xr_surface_viewport_bind(surface_data, &rect);
glClear(GL_DEPTH_BUFFER_BIT);
+ GPU_framebuffer_restore();
BKE_screen_view3d_shading_init(&shading);
shading.flag |= V3D_SHADING_WORLD_ORIENTATION;
@@ -499,12 +498,11 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
wm_draw_offscreen_texture_parameters(offscreen);
wmViewport(&rect);
- const bool is_upside_down = surface_data->secondary_ghost_ctx &&
- GHOST_isUpsideDownContext(surface_data->secondary_ghost_ctx);
- const int ymin = is_upside_down ? draw_view->height : 0;
- const int ymax = is_upside_down ? 0 : draw_view->height;
- GPU_viewport_draw_to_screen_ex(
- viewport, 0, draw_view->width, ymin, ymax, draw_view->expects_srgb_buffer);
+ // const bool is_upside_down = surface_data->secondary_ghost_ctx &&
+ // GHOST_isUpsideDownContext(surface_data->secondary_ghost_ctx);
+ // const int ymin = is_upside_down ? draw_view->height : 0;
+ // const int ymax = is_upside_down ? 0 : draw_view->height;
+ GPU_viewport_draw_to_screen(viewport, &rect);
/* Leave viewport bound so GHOST_Xr can use its context/framebuffer, its unbound in
* wm_xr_session_surface_draw(). */
More information about the Bf-blender-cvs
mailing list