diff options
author | Julian Eisel <julian@blender.org> | 2020-03-16 20:14:24 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-03-16 20:14:24 +0300 |
commit | ddbbd9928ec443f813ee4d46011288e360278e9f (patch) | |
tree | 91f50fc6e8e8b68be5686903aca191d43cdafae5 /source/blender/gpu | |
parent | b86be9b2145458037fd0b17433b7af0efa7b6472 (diff) | |
parent | d2ef342b2a50a7eac725889708fd689ffa126e25 (diff) |
Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 71 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_viewport.c | 2 |
3 files changed, 46 insertions, 37 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 5eae86e50f0..f21cd990a41 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -189,15 +189,17 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers, GPUPrimType prim) * \{ */ /* Returns the Face Set random color for rendering in the overlay given its ID and a color seed. */ +#define GOLDEN_RATIO_CONJUGATE 0.618033988749895f static void face_set_overlay_color_get(const int face_set, const int seed, uchar *r_color) { float rgba[4]; - const float random_mod_hue = BLI_hash_int_01(abs(face_set) + seed); + float random_mod_hue = GOLDEN_RATIO_CONJUGATE * (abs(face_set) + (seed % 10)); + random_mod_hue = random_mod_hue - floorf(random_mod_hue); const float random_mod_sat = BLI_hash_int_01(abs(face_set) + seed + 1); const float random_mod_val = BLI_hash_int_01(abs(face_set) + seed + 2); hsv_to_rgb(random_mod_hue, - 0.45f + (random_mod_sat * 0.35f), - 1.0f - (random_mod_val * 0.45f), + 0.6f + (random_mod_sat * 0.25f), + 1.0f - (random_mod_val * 0.35f), &rgba[0], &rgba[1], &rgba[2]); @@ -264,8 +266,8 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, } /* Face Sets. */ - uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; for (uint i = 0; i < buffers->face_indices_len; i++) { + uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; if (show_face_sets) { const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; const int fset = abs(sculpt_face_sets[lt->poly]); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 33bc3ced5b2..348b9dddba9 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -180,27 +180,28 @@ float GPU_get_anisotropic(void) /* Set OpenGL state for an MTFace */ -static GPUTexture **gpu_get_image_gputexture(Image *ima, GLenum textarget) +static GPUTexture **gpu_get_image_gputexture(Image *ima, GLenum textarget, const int multiview_eye) { if (textarget == GL_TEXTURE_2D) { - return &ima->gputexture[TEXTARGET_TEXTURE_2D]; + return &(ima->gputexture[TEXTARGET_TEXTURE_2D][multiview_eye]); } else if (textarget == GL_TEXTURE_CUBE_MAP) { - return &ima->gputexture[TEXTARGET_TEXTURE_CUBE_MAP]; + return &(ima->gputexture[TEXTARGET_TEXTURE_CUBE_MAP][multiview_eye]); } else if (textarget == GL_TEXTURE_2D_ARRAY) { - return &ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY]; + return &(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][multiview_eye]); } else if (textarget == GL_TEXTURE_1D_ARRAY) { - return &ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING]; + return &(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][multiview_eye]); } return NULL; } -static uint gpu_texture_create_tile_mapping(Image *ima) +static uint gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye) { - GPUTexture *tilearray = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY]; + GPUTexture *tilearray = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][multiview_eye]; + if (tilearray == NULL) { return 0; } @@ -876,7 +877,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, BKE_image_tag_time(ima); /* Test if we already have a texture. */ - GPUTexture **tex = gpu_get_image_gputexture(ima, textarget); + GPUTexture **tex = gpu_get_image_gputexture(ima, textarget, iuser->multiview_eye); if (*tex) { return *tex; } @@ -904,7 +905,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, bindcode = gpu_texture_create_tile_array(ima, ibuf_intern); } else if (textarget == GL_TEXTURE_1D_ARRAY) { - bindcode = gpu_texture_create_tile_mapping(ima); + bindcode = gpu_texture_create_tile_mapping(ima, iuser->multiview_eye); } else { bindcode = gpu_texture_create_from_ibuf(ima, ibuf_intern, textarget); @@ -1288,14 +1289,16 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap) for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { if (ima->gpuflag & IMA_GPU_MIPMAP_COMPLETE) { - for (int a = 0; a < TEXTARGET_COUNT; a++) { - if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) { - GPUTexture *tex = ima->gputexture[a]; - if (tex != NULL) { - GPU_texture_bind(tex, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); - GPU_texture_unbind(tex); + for (int eye = 0; eye < 2; eye++) { + for (int a = 0; a < TEXTARGET_COUNT; a++) { + if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) { + GPUTexture *tex = ima->gputexture[a][eye]; + if (tex != NULL) { + GPU_texture_bind(tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + GPU_texture_unbind(tex); + } } } } @@ -1312,14 +1315,16 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap) else { for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { - for (int a = 0; a < TEXTARGET_COUNT; a++) { - if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) { - GPUTexture *tex = ima->gputexture[a]; - if (tex != NULL) { - GPU_texture_bind(tex, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); - GPU_texture_unbind(tex); + for (int eye = 0; eye < 2; eye++) { + for (int a = 0; a < TEXTARGET_COUNT; a++) { + if (ELEM(a, TEXTARGET_TEXTURE_2D, TEXTARGET_TEXTURE_2D_ARRAY)) { + GPUTexture *tex = ima->gputexture[a][eye]; + if (tex != NULL) { + GPU_texture_bind(tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + GPU_texture_unbind(tex); + } } } } @@ -1343,14 +1348,14 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i GPU_free_image(ima); } - GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D]; + GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D][0]; /* Check if we need to update the main gputexture. */ if (tex != NULL && tile == ima->tiles.first) { gpu_texture_update_from_ibuf(tex, ima, ibuf, NULL, x, y, w, h); } /* Check if we need to update the array gputexture. */ - tex = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY]; + tex = ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][0]; if (tex != NULL) { gpu_texture_update_from_ibuf(tex, ima, ibuf, tile, x, y, w, h); } @@ -1395,11 +1400,13 @@ void GPU_free_unused_buffers(Main *bmain) static void gpu_free_image_immediate(Image *ima) { - for (int i = 0; i < TEXTARGET_COUNT; i++) { - /* free glsl image binding */ - if (ima->gputexture[i] != NULL) { - GPU_texture_free(ima->gputexture[i]); - ima->gputexture[i] = NULL; + for (int eye = 0; eye < 2; eye++) { + for (int i = 0; i < TEXTARGET_COUNT; i++) { + /* free glsl image binding */ + if (ima->gputexture[i][eye] != NULL) { + GPU_texture_free(ima->gputexture[i][eye]); + ima->gputexture[i][eye] = NULL; + } } } diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 351c85aa2d8..941f5049dbf 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -677,7 +677,7 @@ static void gpu_viewport_storage_free(StorageList *stl, int stl_len) static void gpu_viewport_passes_free(PassList *psl, int psl_len) { - memset(psl, 0, sizeof(struct DRWPass *) * psl_len); + memset(psl->passes, 0, sizeof(*psl->passes) * psl_len); } /* Must be executed inside Drawmanager Opengl Context. */ |