Fix T77759: "Not enough texture slots!" Message lags computer

Patch supplied by Clément Foucault
This commit is contained in:
Jeroen Bakker 2020-07-13 15:42:48 +02:00
parent ad0154aebc
commit 061869fe61
Notes: blender-bot 2023-02-14 03:34:17 +01:00
Referenced by issue #77759, Workbench: "Not enough texture slots!" Message being spammed and lags the entire computer
3 changed files with 67 additions and 7 deletions

View File

@ -216,7 +216,11 @@ static void workbench_cache_hair_populate(WORKBENCH_PrivateData *wpd,
workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, interp) :
workbench_material_hair_setup(wpd, ob, matnr, color_type);
DRW_shgroup_hair_create_sub(ob, psys, md, grp);
grp = DRW_shgroup_hair_create_sub(ob, psys, md, grp);
if (use_texpaint_mode || (color_type == V3D_SHADING_TEXTURE_COLOR)) {
workbench_image_hair_setup_post(wpd, ob, matnr, use_texpaint_mode, ima, NULL, interp, grp);
}
}
/**

View File

@ -283,14 +283,62 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
DRWShadingGroup *grp = (tex_tile_data) ? prepass->image_tiled_shgrp : prepass->image_shgrp;
*grp_tex = grp = DRW_shgroup_create_sub(grp);
if (tex_tile_data) {
DRW_shgroup_uniform_texture_persistent(grp, "imageTileArray", tex);
DRW_shgroup_uniform_texture_persistent(grp, "imageTileData", tex_tile_data);
}
else {
DRW_shgroup_uniform_texture_persistent(grp, "imageTexture", tex);
if (!hair) {
if (tex_tile_data) {
DRW_shgroup_uniform_texture(grp, "imageTileArray", tex);
DRW_shgroup_uniform_texture(grp, "imageTileData", tex_tile_data);
}
else {
DRW_shgroup_uniform_texture(grp, "imageTexture", tex);
}
}
DRW_shgroup_uniform_bool_copy(grp, "imagePremult", (ima && ima->alpha_mode == IMA_ALPHA_PREMUL));
DRW_shgroup_uniform_bool_copy(grp, "imageNearest", (interp == SHD_INTERP_CLOSEST));
return grp;
}
/* Workaround for T77759 only present in LTS branch. */
void workbench_image_hair_setup_post(WORKBENCH_PrivateData *wpd,
Object *ob,
int mat_nr,
const bool use_texpaint_mode,
Image *ima,
ImageUser *iuser,
int interp,
DRWShadingGroup *grp)
{
GPUTexture *tex = NULL, *tex_tile_data = NULL;
if (!use_texpaint_mode) {
workbench_material_get_image(ob, mat_nr, &ima, &iuser, &interp);
if (ima == NULL) {
return;
}
}
if (ima == NULL) {
workbench_material_get_image(ob, mat_nr, &ima, &iuser, &interp);
}
if (ima) {
if (ima->source == IMA_SRC_TILED) {
tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D_ARRAY);
tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_1D_ARRAY);
}
else {
tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D);
}
}
if (tex == NULL) {
tex = wpd->dummy_image_tx;
}
if (tex_tile_data) {
DRW_shgroup_uniform_texture(grp, "imageTileArray", tex);
DRW_shgroup_uniform_texture(grp, "imageTileData", tex_tile_data);
}
else {
DRW_shgroup_uniform_texture(grp, "imageTexture", tex);
}
}

View File

@ -464,6 +464,14 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
ImageUser *iuser,
int interp,
bool hair);
void workbench_image_hair_setup_post(WORKBENCH_PrivateData *wpd,
Object *ob,
int mat_nr,
const bool use_texpaint_mode,
Image *ima,
ImageUser *iuser,
int interp,
DRWShadingGroup *grp);
#define workbench_material_setup(wpd, ob, mat_nr, color_type, r_transp) \
workbench_material_setup_ex(wpd, ob, mat_nr, color_type, false, r_transp)