Fix T39468
Issue is that sampling functions did not pass a thread index to the texture sampler so all threads were contesting for the same pool. Paint cursors and sculpting that used openmp for threading suffered from this. Now use omp_get_thread_num to pass the thread number.
This commit is contained in:
parent
8b43b9f255
commit
6d973b87a6
Notes:
blender-bot
2023-02-14 10:53:19 +01:00
Referenced by issue #39468, Noisy textures in paint mode
|
@ -61,6 +61,10 @@
|
|||
* removed eventually (TODO) */
|
||||
#include "sculpt_intern.h"
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
/* TODOs:
|
||||
*
|
||||
* Some of the cursor drawing code is doing non-draw stuff
|
||||
|
@ -245,7 +249,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
|||
if (col) {
|
||||
float rgba[4];
|
||||
|
||||
paint_get_tex_pixel_col(mtex, x, y, rgba, pool);
|
||||
paint_get_tex_pixel_col(mtex, x, y, rgba, pool, omp_get_thread_num());
|
||||
|
||||
buffer[index * 4] = rgba[0] * 255;
|
||||
buffer[index * 4 + 1] = rgba[1] * 255;
|
||||
|
@ -253,7 +257,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
|||
buffer[index * 4 + 3] = rgba[3] * 255;
|
||||
}
|
||||
else {
|
||||
float avg = paint_get_tex_pixel(mtex, x, y, pool);
|
||||
float avg = paint_get_tex_pixel(mtex, x, y, pool, omp_get_thread_num());
|
||||
|
||||
avg += br->texture_sample_bias;
|
||||
|
||||
|
|
|
@ -198,8 +198,8 @@ void paint_calc_redraw_planes(float planes[4][4],
|
|||
const struct rcti *screen_rect);
|
||||
|
||||
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
|
||||
float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool);
|
||||
void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool);
|
||||
float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
|
||||
void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread);
|
||||
int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
|
||||
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
|
||||
void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
|
||||
|
|
|
@ -164,26 +164,25 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
|
|||
return len_v3(delta) / scale;
|
||||
}
|
||||
|
||||
float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool)
|
||||
float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
|
||||
{
|
||||
float intensity, rgba[4];
|
||||
float co[3] = {u, v, 0.0f};
|
||||
|
||||
externtex(mtex, co, &intensity,
|
||||
rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
|
||||
rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
|
||||
|
||||
return intensity;
|
||||
}
|
||||
|
||||
void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool)
|
||||
void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread)
|
||||
{
|
||||
float co[3] = {u, v, 0.0f};
|
||||
int hasrgb;
|
||||
float intensity;
|
||||
|
||||
hasrgb = externtex(mtex, co, &intensity,
|
||||
rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
|
||||
|
||||
rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
|
||||
if (!hasrgb) {
|
||||
rgba[0] = intensity;
|
||||
rgba[1] = intensity;
|
||||
|
|
|
@ -987,7 +987,7 @@ static float tex_strength(SculptSession *ss, Brush *br,
|
|||
x += br->mtex.ofs[0];
|
||||
y += br->mtex.ofs[1];
|
||||
|
||||
avg = paint_get_tex_pixel(&br->mtex, x, y, ss->tex_pool);
|
||||
avg = paint_get_tex_pixel(&br->mtex, x, y, ss->tex_pool, omp_get_thread_num());
|
||||
|
||||
avg += br->texture_sample_bias;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue