diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-27 12:03:56 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-27 12:03:56 +0300 |
commit | 84189a63400a1c8950c8363a7af5a4525f7e94c9 (patch) | |
tree | 89519f96c5bc69dd663042713d044d93dc1517bc /source/blender/draw/intern | |
parent | f41c7723c93bc9e784634887da8b682787729538 (diff) | |
parent | 5625a21fc7cf3738278f02038cb6d8a3c2344584 (diff) |
Merge remote-tracking branch 'origin/blender-v3.2-release'
Diffstat (limited to 'source/blender/draw/intern')
4 files changed, 30 insertions, 7 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 5275bc51e8d..a0c7e064e00 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -69,6 +69,7 @@ enum { SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FVAR, SHADER_PATCH_EVALUATION_FACE_DOTS, + SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS, SHADER_PATCH_EVALUATION_ORCO, SHADER_COMP_CUSTOM_DATA_INTERP_1D, SHADER_COMP_CUSTOM_DATA_INTERP_2D, @@ -109,6 +110,7 @@ static const char *get_shader_code(int shader_type) case SHADER_PATCH_EVALUATION: case SHADER_PATCH_EVALUATION_FVAR: case SHADER_PATCH_EVALUATION_FACE_DOTS: + case SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS: case SHADER_PATCH_EVALUATION_ORCO: { return datatoc_common_subdiv_patch_evaluation_comp_glsl; } @@ -165,6 +167,9 @@ static const char *get_shader_name(int shader_type) case SHADER_PATCH_EVALUATION_FACE_DOTS: { return "subdiv patch evaluation face dots"; } + case SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS: { + return "subdiv patch evaluation face dots with normals"; + } case SHADER_PATCH_EVALUATION_ORCO: { return "subdiv patch evaluation orco"; } @@ -211,6 +216,13 @@ static GPUShader *get_patch_evaluation_shader(int shader_type) "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n" "#define FDOTS_EVALUATION\n"; } + else if (shader_type == SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS) { + defines = + "#define OSD_PATCH_BASIS_GLSL\n" + "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n" + "#define FDOTS_EVALUATION\n" + "#define FOTS_NORMALS\n"; + } else if (shader_type == SHADER_PATCH_EVALUATION_ORCO) { defines = "#define OSD_PATCH_BASIS_GLSL\n" @@ -1670,7 +1682,9 @@ void draw_subdiv_build_fdots_buffers(const DRWSubdivCache *cache, get_patch_param_format()); evaluator->wrapPatchParamBuffer(evaluator, &patch_param_buffer_interface); - GPUShader *shader = get_patch_evaluation_shader(SHADER_PATCH_EVALUATION_FACE_DOTS); + GPUShader *shader = get_patch_evaluation_shader( + fdots_nor ? SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS : + SHADER_PATCH_EVALUATION_FACE_DOTS); GPU_shader_bind(shader); int binding_point = 0; @@ -1683,7 +1697,11 @@ void draw_subdiv_build_fdots_buffers(const DRWSubdivCache *cache, GPU_vertbuf_bind_as_ssbo(patch_index_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(patch_param_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(fdots_pos, binding_point++); - GPU_vertbuf_bind_as_ssbo(fdots_nor, binding_point++); + /* F-dots normals may not be requested, still reserve the binding point. */ + if (fdots_nor) { + GPU_vertbuf_bind_as_ssbo(fdots_nor, binding_point); + } + binding_point++; GPU_indexbuf_bind_as_ssbo(fdots_indices, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->extra_coarse_face_data, binding_point++); BLI_assert(binding_point <= MAX_GPU_SUBDIV_SSBOS); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc index c2b4d389b7c..1671a1cd1e7 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc @@ -110,8 +110,11 @@ static void extract_fdots_init_subdiv(const DRWSubdivCache *subdiv_cache, GPUVertBuf *fdots_nor_vbo = cache->final.buff.vbo.fdots_nor; GPUIndexBuf *fdots_pos_ibo = cache->final.buff.ibo.fdots; - GPU_vertbuf_init_build_on_device( - fdots_nor_vbo, get_fdots_nor_format_subdiv(), subdiv_cache->num_coarse_poly); + /* The normals may not be requested. */ + if (fdots_nor_vbo) { + GPU_vertbuf_init_build_on_device( + fdots_nor_vbo, get_fdots_nor_format_subdiv(), subdiv_cache->num_coarse_poly); + } GPU_vertbuf_init_build_on_device( fdots_pos_vbo, get_fdots_pos_format(), subdiv_cache->num_coarse_poly); GPU_indexbuf_init_build_on_device(fdots_pos_ibo, subdiv_cache->num_coarse_poly); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc index e5dd025787d..fa5bf35198b 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc @@ -271,8 +271,6 @@ static void extract_vcol_init_subdiv(const DRWSubdivCache *subdiv_cache, blender::Vector<VColRef> refs = get_vcol_refs(cd_vdata, cd_ldata, vcol_layers); - gpuMeshVcol *vcol = mesh_vcol; - /* Index of the vertex color layer in the compact buffer. Used vertex color layers are stored in * a single buffer. */ int pack_layer_index = 0; @@ -287,10 +285,10 @@ static void extract_vcol_init_subdiv(const DRWSubdivCache *subdiv_cache, if (layer_i == -1) { printf("%s: missing color layer %s\n", __func__, ref.layer->name); - vcol += coarse_mesh->totloop; continue; } + gpuMeshVcol *vcol = mesh_vcol; MLoopCol *mcol = nullptr; MPropCol *pcol = nullptr; diff --git a/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl b/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl index cfe469a6283..0ffb216fc6f 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl @@ -70,10 +70,12 @@ layout(std430, binding = 8) writeonly buffer outputVertices FDotVert output_verts[]; }; +# ifdef FDOTS_NORMALS layout(std430, binding = 9) writeonly buffer outputNormals { FDotNor output_nors[]; }; +# endif layout(std430, binding = 10) writeonly buffer outputFdotsIndices { @@ -421,7 +423,9 @@ void main() fnor.flag = get_face_flag(coarse_quad_index); output_verts[coarse_quad_index] = vert; +# ifdef FDOTS_NORMALS output_nors[coarse_quad_index] = fnor; +# endif if (is_face_hidden(coarse_quad_index)) { output_indices[coarse_quad_index] = 0xffffffff; |