Bugfix #22052
OpenGL viewport render gave squeezed results in cases. Reason: some graphics cards only give offscreen buffers in multiples of 256 or 512 (my case). Current fix uses the actual size returned by graphics card, which is also safe for too large renders. More elaborate cropping or matching is for another time. (Added printf for feedback on this, might disappear)
This commit is contained in:
@@ -257,7 +257,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
|
||||
sizex= (scene->r.size*scene->r.xsch)/100;
|
||||
sizey= (scene->r.size*scene->r.ysch)/100;
|
||||
|
||||
ofs= GPU_offscreen_create(sizex, sizey);
|
||||
/* corrects render size with actual size, some gfx cards return units of 256 or 512 */
|
||||
ofs= GPU_offscreen_create(&sizex, &sizey);
|
||||
|
||||
if(!ofs) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer.");
|
||||
|
||||
@@ -2140,7 +2140,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
|
||||
GPUOffScreen *ofs;
|
||||
|
||||
/* bind */
|
||||
ofs= GPU_offscreen_create(sizex, sizey);
|
||||
ofs= GPU_offscreen_create(&sizex, &sizey);
|
||||
if(ofs == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -144,9 +144,10 @@ void GPU_framebuffer_free(GPUFrameBuffer *fb);
|
||||
void GPU_framebuffer_restore();
|
||||
|
||||
/* GPU OffScreen
|
||||
- wrapper around framebuffer and texture for simple offscreen drawing */
|
||||
- wrapper around framebuffer and texture for simple offscreen drawing
|
||||
- changes size if graphics card can't support it */
|
||||
|
||||
GPUOffScreen *GPU_offscreen_create(int width, int height);
|
||||
GPUOffScreen *GPU_offscreen_create(int *width, int *height);
|
||||
void GPU_offscreen_free(GPUOffScreen *ofs);
|
||||
void GPU_offscreen_bind(GPUOffScreen *ofs);
|
||||
void GPU_offscreen_unbind(GPUOffScreen *ofs);
|
||||
|
||||
@@ -847,7 +847,7 @@ struct GPUOffScreen {
|
||||
GPUTexture *depth;
|
||||
};
|
||||
|
||||
GPUOffScreen *GPU_offscreen_create(int width, int height)
|
||||
GPUOffScreen *GPU_offscreen_create(int *width, int *height)
|
||||
{
|
||||
GPUOffScreen *ofs;
|
||||
|
||||
@@ -859,18 +859,24 @@ GPUOffScreen *GPU_offscreen_create(int width, int height)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ofs->depth = GPU_texture_create_depth(width, height);
|
||||
ofs->depth = GPU_texture_create_depth(*width, *height);
|
||||
if(!ofs->depth) {
|
||||
GPU_offscreen_free(ofs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(*width!=ofs->depth->w || *height!=ofs->depth->h) {
|
||||
*width= ofs->depth->w;
|
||||
*height= ofs->depth->h;
|
||||
printf("Offscreen size differs from given size!\n");
|
||||
}
|
||||
|
||||
if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth)) {
|
||||
GPU_offscreen_free(ofs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ofs->color = GPU_texture_create_2D(width, height, NULL);
|
||||
ofs->color = GPU_texture_create_2D(*width, *height, NULL);
|
||||
if(!ofs->color) {
|
||||
GPU_offscreen_free(ofs);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user