diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-02-21 20:22:25 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-02-21 20:22:25 +0300 |
commit | ec6545efad5fed99980fc3e2d5962b40fbeb12ae (patch) | |
tree | 31729e5064a46f3663d92cf74a422de50fbd2780 /source/blender/gpu/intern | |
parent | 3f0871dfcfbb1dda15c176dba92d36639305385a (diff) | |
parent | 813204838a268fd8108e9f9bc96bb1b4680c7929 (diff) |
Merge branch 'blender2.8' into topbar
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_compositing.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 36 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 8 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 64 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 12 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_viewport.c | 22 |
9 files changed, 93 insertions, 69 deletions
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 0400fc1025b..332102aca46 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -34,7 +34,7 @@ #include "BLI_utildefines.h" #include "BLI_rect.h" #include "BLI_math.h" -#include "BLI_polyfill2d.h" +#include "BLI_polyfill_2d.h" #include "BLI_sort_utils.h" diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index d0efee79ab0..3043b3ab686 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1901,7 +1901,7 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, } else if (buffers->use_bmesh) { /* due to dynamic nature of dyntopo, only get first material */ - if (BLI_gset_size(bm_faces) > 0) { + if (BLI_gset_len(bm_faces) > 0) { GSetIterator gs_iter; BMFace *f; diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c index 3de363cc76e..ca81ca72a32 100644 --- a/source/blender/gpu/intern/gpu_compositing.c +++ b/source/blender/gpu/intern/gpu_compositing.c @@ -1007,7 +1007,7 @@ bool GPU_fx_do_composite_pass( glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* the draw call we all waited for, draw a point per pixel, scaled per circle of confusion */ - GWN_batch_draw_stupid_instanced(fx->point_batch, 0, fx->dof_downsampled_w * fx->dof_downsampled_h, 0, 0, 0, NULL, NULL); + // GWN_batch_draw_stupid_instanced(fx->point_batch, 0, fx->dof_downsampled_w * fx->dof_downsampled_h, 0, 0, 0, NULL, NULL); GPU_texture_unbind(fx->dof_half_downsampled_far); GPU_framebuffer_texture_detach(fx->dof_far_blur); @@ -1023,11 +1023,11 @@ bool GPU_fx_do_composite_pass( /* have to clear the buffer unfortunately */ glClear(GL_COLOR_BUFFER_BIT); /* the draw call we all waited for, draw a point per pixel, scaled per circle of confusion */ - GWN_batch_draw_stupid_instanced(fx->point_batch, 0, fx->dof_downsampled_w * fx->dof_downsampled_h, 0, 0, 0, NULL, NULL); + // GWN_batch_draw_stupid_instanced(fx->point_batch, 0, fx->dof_downsampled_w * fx->dof_downsampled_h, 0, 0, 0, NULL, NULL); GWN_batch_program_use_end(fx->point_batch); /* disable bindings */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); GPU_framebuffer_texture_detach(fx->dof_near_blur); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index f9cf3235ac1..fdb5894e9ed 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -39,11 +39,11 @@ #include <string.h> #include "BLI_blenlib.h" +#include "BLI_hash.h" #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLI_hash.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" @@ -398,7 +398,7 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) if (alphablend == GPU_BLEND_SOLID) { glDisable(GL_BLEND); glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } else if (alphablend == GPU_BLEND_ADD) { glEnable(GL_BLEND); @@ -1319,9 +1319,9 @@ static LinkNode *image_free_queue = NULL; static void gpu_queue_image_for_free(Image *ima) { - BLI_lock_thread(LOCK_OPENGL); + BLI_thread_lock(LOCK_OPENGL); BLI_linklist_prepend(&image_free_queue, ima); - BLI_unlock_thread(LOCK_OPENGL); + BLI_thread_unlock(LOCK_OPENGL); } void GPU_free_unused_buffers(void) @@ -1329,7 +1329,7 @@ void GPU_free_unused_buffers(void) if (!BLI_thread_is_main()) return; - BLI_lock_thread(LOCK_OPENGL); + BLI_thread_lock(LOCK_OPENGL); /* images */ for (LinkNode *node = image_free_queue; node; node = node->next) { @@ -1346,7 +1346,7 @@ void GPU_free_unused_buffers(void) /* vbo buffers */ GPU_global_buffer_pool_free_unused(); - BLI_unlock_thread(LOCK_OPENGL); + BLI_thread_unlock(LOCK_OPENGL); } void GPU_free_image(Image *ima) @@ -1460,6 +1460,7 @@ static struct GPUMaterialState { Material *gmatbuf_fixed[FIXEDMAT]; Material *gboundmat; Object *gob; + eObjectMode gob_object_mode; DupliObject *dob; Scene *gscene; int glay; @@ -1554,7 +1555,7 @@ void GPU_end_dupli_object(void) void GPU_begin_object_materials( View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob, - bool glsl, bool *do_alpha_after) + bool glsl, const eObjectMode object_mode, bool *do_alpha_after) { Material *ma; GPUMaterial *gpumat; @@ -1592,7 +1593,7 @@ void GPU_begin_object_materials( #ifdef WITH_GAMEENGINE if (rv3d->rflag & RV3D_IS_GAME_ENGINE) { - ob = BKE_object_lod_matob_get(ob, view_layer); + ob = BKE_object_lod_matob_get(ob, view_layer, object_mode); } #else UNUSED_VARS(view_layer); @@ -1616,6 +1617,7 @@ void GPU_begin_object_materials( GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0; GMS.gob = ob; + GMS.gob_object_mode = object_mode; GMS.gscene = scene; GMS.is_opensubdiv = use_opensubdiv; GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */ @@ -1734,6 +1736,8 @@ static int gpu_get_particle_info(GPUParticleInfo *pi) pi->scalprops[3] = p->size; copy_v3_v3(pi->location, p->state.co); + pi->location[3] = BLI_hash_int_01(ind); + copy_v3_v3(pi->velocity, p->state.vel); copy_v3_v3(pi->angular_velocity, p->state.ave); return 1; @@ -1834,7 +1838,7 @@ int GPU_object_material_bind(int nr, void *attribs) } GPU_material_bind( - gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT), + gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob_object_mode & OB_MODE_TEXTURE_PAINT), GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac); auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f; @@ -2093,7 +2097,7 @@ int GPU_scene_object_lights(ViewLayer *view_layer, float viewmat[4][4], int orth return count; } -static void gpu_multisample(bool enable) +static void gpu_disable_multisample(void) { #ifdef __linux__ /* changing multisample from the default (enabled) causes problems on some @@ -2109,16 +2113,10 @@ static void gpu_multisample(bool enable) } if (toggle_ok) { - if (enable) - glEnable(GL_MULTISAMPLE); - else - glDisable(GL_MULTISAMPLE); + glDisable(GL_MULTISAMPLE); } #else - if (enable) - glEnable(GL_MULTISAMPLE); - else - glDisable(GL_MULTISAMPLE); + glDisable(GL_MULTISAMPLE); #endif } @@ -2150,7 +2148,7 @@ void GPU_state_init(void) glCullFace(GL_BACK); glDisable(GL_CULL_FACE); - gpu_multisample(false); + gpu_disable_multisample(); } void GPU_enable_program_point_size(void) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 57df877bf18..6bf330179d3 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -178,14 +178,6 @@ void gpu_extensions_init(void) GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OFFICIAL; } - /* XXX : TODO : Remove this once this sampling mipmap problem is gone. - * https://github.com/dfelinto/opengl-sandbox/blob/downsample/README.md */ - else if (strstr(renderer, "AMD VEGA") && - strstr(vendor, "X.Org")) - { - GG.device = GPU_DEVICE_AMD_VEGA; - GG.driver = GPU_DRIVER_OPENSOURCE; - } else if (strstr(vendor, "NVIDIA")) { GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OFFICIAL; diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index 09013cd29bd..e83eeefe2c5 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -385,6 +385,13 @@ bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256]) glBindFramebuffer(GL_FRAMEBUFFER, fb->object); GG.currentfb = fb->object; + /* On macOS glDrawBuffer must be set when checking completeness, + * otherwise it will return GL_FRAMEBUFFER_UNSUPPORTED when only a + * color buffer without depth is used. */ + if (fb->colortex[0]) { + glDrawBuffer(GL_COLOR_ATTACHMENT0); + } + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { @@ -602,18 +609,9 @@ void GPU_framebuffer_recursive_downsample( current_dim[0] /= 2; current_dim[1] /= 2; - if (GPU_type_matches(GPU_DEVICE_AMD_VEGA, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { - /* NOTE : here 16 is because of a bug on AMD Vega GPU + non-pro drivers, that prevents us - * from sampling mipmaps that are smaller or equal to 16px. (9) */ - if (current_dim[0] <= 16 && current_dim[1] <= 16) { - break; - } - } - else { - if (current_dim[0] <= 2 && current_dim[1] <= 2) { - /* Cannot reduce further. */ - break; - } + if (current_dim[0] <= 2 && current_dim[1] <= 2) { + /* Cannot reduce further. */ + break; } /* ensure that the viewport size is always at least 1x1 */ @@ -650,7 +648,7 @@ struct GPUOffScreen { GPUTexture *depth; }; -GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool high_bitdepth, char err_out[256]) +GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool depth, bool high_bitdepth, char err_out[256]) { GPUOffScreen *ofs; @@ -672,15 +670,17 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool high } } - ofs->depth = GPU_texture_create_depth_with_stencil_multisample(width, height, samples, err_out); - if (!ofs->depth) { - GPU_offscreen_free(ofs); - return NULL; - } + if (depth) { + ofs->depth = GPU_texture_create_depth_with_stencil_multisample(width, height, samples, err_out); + if (!ofs->depth) { + GPU_offscreen_free(ofs); + return NULL; + } - if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, 0, 0)) { - GPU_offscreen_free(ofs); - return NULL; + if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, 0, 0)) { + GPU_offscreen_free(ofs); + return NULL; + } } if (high_bitdepth) { @@ -740,6 +740,24 @@ void GPU_offscreen_unbind(GPUOffScreen *ofs, bool restore) glEnable(GL_SCISSOR_TEST); } +void GPU_offscreen_blit(GPUOffScreen *ofs, int x, int y) +{ + const int w = GPU_texture_width(ofs->color); + const int h = GPU_texture_height(ofs->color); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, ofs->fb->object); + GLenum status = glCheckFramebufferStatus(GL_READ_FRAMEBUFFER); + + if (status == GL_FRAMEBUFFER_COMPLETE) { + glBlitFramebuffer(0, 0, w, h, x, y, x + w, y + h, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + else { + gpu_print_framebuffer_error(status, NULL); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); +} + void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels) { const int w = GPU_texture_width(ofs->color); @@ -827,9 +845,9 @@ int GPU_offscreen_height(const GPUOffScreen *ofs) return GPU_texture_height(ofs->color); } -int GPU_offscreen_color_texture(const GPUOffScreen *ofs) +GPUTexture *GPU_offscreen_color_texture(const GPUOffScreen *ofs) { - return GPU_texture_opengl_bindcode(ofs->color); + return ofs->color; } /* only to be used by viewport code! */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 2e6c1cbf9df..2d7b9415030 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -417,7 +417,7 @@ void GPU_material_bind_uniforms( GPU_shader_uniform_vector(shader, material->partscalarpropsloc, 4, 1, pi->scalprops); } if (material->builtins & GPU_PARTICLE_LOCATION) { - GPU_shader_uniform_vector(shader, material->partcoloc, 3, 1, pi->location); + GPU_shader_uniform_vector(shader, material->partcoloc, 4, 1, pi->location); } if (material->builtins & GPU_PARTICLE_VELOCITY) { GPU_shader_uniform_vector(shader, material->partvel, 3, 1, pi->velocity); @@ -557,7 +557,9 @@ static float eval_profile(float r, short falloff_type, float sharpness, float pa { r = fabsf(r); - if (falloff_type == SHD_SUBSURFACE_BURLEY) { + if (falloff_type == SHD_SUBSURFACE_BURLEY || + falloff_type == SHD_SUBSURFACE_RANDOM_WALK) + { return burley_profile(r, param) / BURLEY_TRUNCATE_CDF; } else if (falloff_type == SHD_SUBSURFACE_CUBIC) { @@ -598,7 +600,9 @@ static void compute_sss_kernel( /* Christensen-Burley fitting */ float l[3], d[3]; - if (falloff_type == SHD_SUBSURFACE_BURLEY) { + if (falloff_type == SHD_SUBSURFACE_BURLEY || + falloff_type == SHD_SUBSURFACE_RANDOM_WALK) + { mul_v3_v3fl(l, rad, 0.25f * M_1_PI); const float A = 1.0f; const float s = 1.9f - A + 3.5f * (A - 0.8f) * (A - 0.8f); diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 598722d372b..c25d03dff2f 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -68,6 +68,7 @@ extern char datatoc_gpu_shader_2D_smooth_color_frag_glsl[]; extern char datatoc_gpu_shader_2D_image_vert_glsl[]; extern char datatoc_gpu_shader_3D_image_vert_glsl[]; +extern char datatoc_gpu_shader_image_frag_glsl[]; extern char datatoc_gpu_shader_image_linear_frag_glsl[]; extern char datatoc_gpu_shader_image_color_frag_glsl[]; extern char datatoc_gpu_shader_image_alpha_color_frag_glsl[]; @@ -75,7 +76,6 @@ extern char datatoc_gpu_shader_image_shuffle_color_frag_glsl[]; extern char datatoc_gpu_shader_image_interlace_frag_glsl[]; extern char datatoc_gpu_shader_image_mask_uniform_color_frag_glsl[]; extern char datatoc_gpu_shader_image_modulate_alpha_frag_glsl[]; -extern char datatoc_gpu_shader_image_rect_modulate_alpha_frag_glsl[]; extern char datatoc_gpu_shader_image_depth_linear_frag_glsl[]; extern char datatoc_gpu_shader_3D_vert_glsl[]; extern char datatoc_gpu_shader_3D_normal_vert_glsl[]; @@ -98,7 +98,7 @@ extern char datatoc_gpu_shader_instance_edges_variying_color_geom_glsl[]; extern char datatoc_gpu_shader_instance_edges_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl[]; extern char datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl[]; -extern char datatoc_gpu_shader_instance_mball_helpers_vert_glsl[]; +extern char datatoc_gpu_shader_instance_mball_handles_vert_glsl[]; extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[]; extern char datatoc_gpu_shader_3D_groundline_geom_glsl[]; @@ -710,8 +710,6 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_image_mask_uniform_color_frag_glsl }, [GPU_SHADER_3D_IMAGE_MODULATE_ALPHA] = { datatoc_gpu_shader_3D_image_vert_glsl, datatoc_gpu_shader_image_modulate_alpha_frag_glsl }, - [GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA] = { datatoc_gpu_shader_3D_image_vert_glsl, - datatoc_gpu_shader_image_rect_modulate_alpha_frag_glsl }, [GPU_SHADER_3D_IMAGE_DEPTH] = { datatoc_gpu_shader_3D_image_vert_glsl, datatoc_gpu_shader_image_depth_linear_frag_glsl }, @@ -728,10 +726,14 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_2D_smooth_color_frag_glsl }, [GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_linear_frag_glsl }, + [GPU_SHADER_2D_IMAGE] = { datatoc_gpu_shader_2D_image_vert_glsl, + datatoc_gpu_shader_image_frag_glsl }, [GPU_SHADER_2D_IMAGE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_color_frag_glsl }, [GPU_SHADER_2D_IMAGE_ALPHA_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_alpha_color_frag_glsl }, + [GPU_SHADER_2D_IMAGE_ALPHA] = { datatoc_gpu_shader_2D_image_vert_glsl, + datatoc_gpu_shader_image_modulate_alpha_frag_glsl }, [GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = { datatoc_gpu_shader_2D_image_vert_glsl, datatoc_gpu_shader_image_shuffle_color_frag_glsl }, [GPU_SHADER_3D_UNIFORM_COLOR] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl }, @@ -821,7 +823,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) [GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_3D_INSTANCE_MBALL_HELPERS] = { datatoc_gpu_shader_instance_mball_helpers_vert_glsl, + [GPU_SHADER_3D_INSTANCE_MBALL_HANDLES] = { datatoc_gpu_shader_instance_mball_handles_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl }, }; diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 3ef53b3a6c3..fc045805874 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -474,7 +474,7 @@ cleanup: GPU_framebuffer_slots_bind(dfbl->default_fb, 0); } -static void draw_ofs_to_screen(GPUViewport *viewport) +static void draw_ofs_to_screen(GPUViewport *viewport, const rcti *rect) { DefaultTextureList *dtxl = viewport->txl; @@ -483,6 +483,9 @@ static void draw_ofs_to_screen(GPUViewport *viewport) const float w = (float)GPU_texture_width(color); const float h = (float)GPU_texture_height(color); + BLI_assert(w == BLI_rcti_size_x(rect) + 1); + BLI_assert(h == BLI_rcti_size_y(rect) + 1); + Gwn_VertFormat *format = immVertexFormat(); unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -495,16 +498,16 @@ static void draw_ofs_to_screen(GPUViewport *viewport) immBegin(GWN_PRIM_TRI_STRIP, 4); immAttrib2f(texcoord, 0.0f, 0.0f); - immVertex2f(pos, 0.0f, 0.0f); + immVertex2f(pos, rect->xmin, rect->ymin); immAttrib2f(texcoord, 1.0f, 0.0f); - immVertex2f(pos, w, 0.0f); + immVertex2f(pos, rect->xmin + w, rect->ymin); immAttrib2f(texcoord, 0.0f, 1.0f); - immVertex2f(pos, 0.0f, h); + immVertex2f(pos, rect->xmin, rect->ymin + h); immAttrib2f(texcoord, 1.0f, 1.0f); - immVertex2f(pos, w, h); + immVertex2f(pos, rect->xmin + w, rect->ymin + h); immEnd(); @@ -523,9 +526,16 @@ void GPU_viewport_unbind(GPUViewport *viewport) glEnable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); + } +} +void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) +{ + DefaultFramebufferList *dfbl = viewport->fbl; + + if (dfbl->default_fb) { /* This might be bandwidth limiting */ - draw_ofs_to_screen(viewport); + draw_ofs_to_screen(viewport, rect); } } |