Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-02-08 17:42:59 +0300
committerJeroen Bakker <jeroen@blender.org>2021-02-08 17:44:54 +0300
commitdf0bce3f7d0a91310ca88814a80e339f3da6c2c9 (patch)
tree12329b0dbfe70ee83bdb9a13471693a0d744e98f
parentbb0b250cbded8bb89d89e67cc2b39826bf3f7fa6 (diff)
Fix T81206: Do not limit gl texture size in image editor
This patch will show textures in the image editor with the maximum available resolution determined by the GPU Hardware/Driver. Currently the size is limited by the user preference texture size limit. An image user can set the `IMA_SHOW_MAX_RESOLUTION` flag to request gpu textures in the max supported resolution. When this flag isn't set the gpu texture is limited by the user preference setting. When the gl resolution limit is disabled the GPU texture is always created for the max supported resolution. Reviewed By: Clément Foucault Maniphest Tasks: T81206 Differential Revision: https://developer.blender.org/D9160
-rw-r--r--source/blender/blenkernel/intern/image_gpu.c38
-rw-r--r--source/blender/blenkernel/intern/movieclip.c3
-rw-r--r--source/blender/blenloader/intern/versioning_290.c14
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/gpu/GPU_capabilities.h2
-rw-r--r--source/blender/gpu/intern/gpu_capabilities.cc5
-rw-r--r--source/blender/imbuf/IMB_imbuf.h3
-rw-r--r--source/blender/imbuf/intern/util_gpu.c6
-rw-r--r--source/blender/makesdna/DNA_image_types.h6
9 files changed, 59 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c
index a6bd65227a0..2ee4505acf0 100644
--- a/source/blender/blenkernel/intern/image_gpu.c
+++ b/source/blender/blenkernel/intern/image_gpu.c
@@ -86,15 +86,15 @@ bool BKE_image_has_gpu_texture_premultiplied_alpha(Image *image, ImBuf *ibuf)
/* -------------------------------------------------------------------- */
/** \name UDIM gpu texture
* \{ */
-
-static bool is_over_resolution_limit(int w, int h)
+static bool is_over_resolution_limit(int w, int h, bool limit_gl_texture_size)
{
- return (w > GPU_texture_size_with_limit(w) || h > GPU_texture_size_with_limit(h));
+ return (w > GPU_texture_size_with_limit(w, limit_gl_texture_size) ||
+ h > GPU_texture_size_with_limit(h, limit_gl_texture_size));
}
-static int smaller_power_of_2_limit(int num)
+static int smaller_power_of_2_limit(int num, bool limit_gl_texture_size)
{
- return power_of_2_min_i(GPU_texture_size_with_limit(num));
+ return power_of_2_min_i(GPU_texture_size_with_limit(num, limit_gl_texture_size));
}
static GPUTexture *gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
@@ -153,6 +153,7 @@ static int compare_packtile(const void *a, const void *b)
static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
{
+ const bool limit_gl_texture_size = (ima->gpuflag & IMA_GPU_MAX_RESOLUTION) == 0;
int arraywidth = 0, arrayheight = 0;
ListBase boxes = {NULL};
@@ -168,9 +169,10 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
packtile->boxpack.w = ibuf->x;
packtile->boxpack.h = ibuf->y;
- if (is_over_resolution_limit(packtile->boxpack.w, packtile->boxpack.h)) {
- packtile->boxpack.w = smaller_power_of_2_limit(packtile->boxpack.w);
- packtile->boxpack.h = smaller_power_of_2_limit(packtile->boxpack.h);
+ if (is_over_resolution_limit(
+ packtile->boxpack.w, packtile->boxpack.h, limit_gl_texture_size)) {
+ packtile->boxpack.w = smaller_power_of_2_limit(packtile->boxpack.w, limit_gl_texture_size);
+ packtile->boxpack.h = smaller_power_of_2_limit(packtile->boxpack.h, limit_gl_texture_size);
}
arraywidth = max_ii(arraywidth, packtile->boxpack.w);
arrayheight = max_ii(arrayheight, packtile->boxpack.h);
@@ -312,18 +314,26 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
short requested_pass = iuser ? iuser->pass : 0;
short requested_layer = iuser ? iuser->layer : 0;
short requested_view = iuser ? iuser->multi_index : 0;
+ const bool limit_resolution = U.glreslimit != 0 &&
+ ((iuser && (iuser->flag & IMA_SHOW_MAX_RESOLUTION) == 0) ||
+ (iuser == NULL));
+ short requested_gpu_flags = limit_resolution ? 0 : IMA_GPU_MAX_RESOLUTION;
+#define GPU_FLAGS_TO_CHECK (IMA_GPU_MAX_RESOLUTION)
/* There is room for 2 multiview textures. When a higher number is requested we should always
* target the first view slot. This is fine as multi view images aren't used together. */
if (requested_view < 2) {
requested_view = 0;
}
if (ima->gpu_pass != requested_pass || ima->gpu_layer != requested_layer ||
- ima->gpu_view != requested_view) {
+ ima->gpu_view != requested_view ||
+ ((ima->gpuflag & GPU_FLAGS_TO_CHECK) != requested_gpu_flags)) {
ima->gpu_pass = requested_pass;
ima->gpu_layer = requested_layer;
ima->gpu_view = requested_view;
- ima->gpuflag |= IMA_GPU_REFRESH;
+ ima->gpuflag &= ~GPU_FLAGS_TO_CHECK;
+ ima->gpuflag |= requested_gpu_flags | IMA_GPU_REFRESH;
}
+#undef GPU_FLAGS_TO_CHECK
/* Check if image has been updated and tagged to be updated (full or partial). */
ImageTile *tile = BKE_image_get_tile(ima, 0);
@@ -390,9 +400,13 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH);
const bool store_premultiplied = BKE_image_has_gpu_texture_premultiplied_alpha(ima,
ibuf_intern);
+ const bool limit_gl_texture_size = (ima->gpuflag & IMA_GPU_MAX_RESOLUTION) == 0;
- *tex = IMB_create_gpu_texture(
- ima->id.name + 2, ibuf_intern, use_high_bitdepth, store_premultiplied);
+ *tex = IMB_create_gpu_texture(ima->id.name + 2,
+ ibuf_intern,
+ use_high_bitdepth,
+ store_premultiplied,
+ limit_gl_texture_size);
GPU_texture_wrap_mode(*tex, true, false);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index b872c91cc29..e82ed62ed5b 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -2112,7 +2112,8 @@ GPUTexture *BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser)
/* This only means RGBA16F instead of RGBA32F. */
const bool high_bitdepth = false;
const bool store_premultiplied = ibuf->rect_float ? false : true;
- *tex = IMB_create_gpu_texture(clip->id.name + 2, ibuf, high_bitdepth, store_premultiplied);
+ *tex = IMB_create_gpu_texture(
+ clip->id.name + 2, ibuf, high_bitdepth, store_premultiplied, false);
/* Do not generate mips for movieclips... too slow. */
GPU_texture_mipmap_mode(*tex, false, true);
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index bb477745849..2911bb6a7fc 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1601,5 +1601,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+
+ /* UV/Image Max resolution images in image editor. */
+ if (!DNA_struct_find(fd->filesdna, "SpaceImageOverlay")) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+ if (space->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)space;
+ sima->iuser.flag |= IMA_SHOW_MAX_RESOLUTION;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 776fa34d1c4..186f2d3a5a8 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -131,7 +131,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS;
BKE_imageuser_default(&simage->iuser);
- simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS;
+ simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS | IMA_SHOW_MAX_RESOLUTION;
BKE_scopes_new(&simage->scopes);
simage->sample_line_hist.height = 100;
diff --git a/source/blender/gpu/GPU_capabilities.h b/source/blender/gpu/GPU_capabilities.h
index e02fbaa6d04..b95053a3715 100644
--- a/source/blender/gpu/GPU_capabilities.h
+++ b/source/blender/gpu/GPU_capabilities.h
@@ -38,7 +38,7 @@ int GPU_max_textures_vert(void);
int GPU_max_textures_geom(void);
int GPU_max_textures_frag(void);
-int GPU_texture_size_with_limit(int res);
+int GPU_texture_size_with_limit(int res, bool limit_gl_texture_size);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
diff --git a/source/blender/gpu/intern/gpu_capabilities.cc b/source/blender/gpu/intern/gpu_capabilities.cc
index 1d2b0e5c7a8..6d9182dcf17 100644
--- a/source/blender/gpu/intern/gpu_capabilities.cc
+++ b/source/blender/gpu/intern/gpu_capabilities.cc
@@ -49,10 +49,11 @@ int GPU_max_texture_size(void)
return GCaps.max_texture_size;
}
-int GPU_texture_size_with_limit(int res)
+int GPU_texture_size_with_limit(int res, bool limit_gl_texture_size)
{
int size = GPU_max_texture_size();
- int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, size) : size;
+ int reslimit = (limit_gl_texture_size && (U.glreslimit != 0)) ? min_ii(U.glreslimit, size) :
+ size;
return min_ii(reslimit, res);
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 58ddc918f61..8866a8a8600 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -745,7 +745,8 @@ const char *IMB_ffmpeg_last_error(void);
struct GPUTexture *IMB_create_gpu_texture(const char *name,
struct ImBuf *ibuf,
bool use_high_bitdepth,
- bool use_premult);
+ bool use_premult,
+ bool limit_gl_texture_size);
struct GPUTexture *IMB_touch_gpu_texture(
const char *name, struct ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth);
void IMB_update_gpu_texture_sub(struct GPUTexture *tex,
diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c
index fc89de476a1..8bedf8eb93c 100644
--- a/source/blender/imbuf/intern/util_gpu.c
+++ b/source/blender/imbuf/intern/util_gpu.c
@@ -219,10 +219,12 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex,
GPUTexture *IMB_create_gpu_texture(const char *name,
ImBuf *ibuf,
bool use_high_bitdepth,
- bool use_premult)
+ bool use_premult,
+ bool limit_gl_texture_size)
{
GPUTexture *tex = NULL;
- int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)};
+ int size[2] = {GPU_texture_size_with_limit(ibuf->x, limit_gl_texture_size),
+ GPU_texture_size_with_limit(ibuf->y, limit_gl_texture_size)};
bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]);
#ifdef WITH_DDS
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index b1d752d6197..22408687daf 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -119,6 +119,10 @@ typedef struct ImageTile {
/* #define IMA_UNUSED_2 (1 << 2) */
#define IMA_NEED_FRAME_RECALC (1 << 3)
#define IMA_SHOW_STEREO (1 << 4)
+/* Do not limit the resolution by the limit texture size option in the user preferences.
+ * Images in the image editor or used as a backdrop are always shown using the maximum
+ * possible resolution. */
+#define IMA_SHOW_MAX_RESOLUTION (1 << 5)
/* Used to get the correct gpu texture from an Image datablock. */
typedef enum eGPUTextureTarget {
@@ -229,6 +233,8 @@ enum {
IMA_GPU_PARTIAL_REFRESH = (1 << 1),
/** All mipmap levels in OpenGL texture set? */
IMA_GPU_MIPMAP_COMPLETE = (1 << 2),
+ /** Current texture resolution won't be limited by the GL Texture Limit user preference. */
+ IMA_GPU_MAX_RESOLUTION = (1 << 3),
};
/* Image.source, where the image comes from */