[Bf-blender-cvs] [9673deb3072] tmp-eevee-shadow-commit-mp: EEVEE Shadows: Fix transparent bbox size
Commit: 9673deb3072bdbfc7eb8ce7ec2c4407364617cbb Author: Miguel Pozo Date: Mon Feb 6 19:57:35 2023 +0100 Branches: tmp-eevee-shadow-commit-mp https://developer.blender.org/rB9673deb3072bdbfc7eb8ce7ec2c4407364617cbb EEVEE Shadows: Fix transparent bbox size Box vertices goes from -1 to +1 === M source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_vert.glsl === diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_vert.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_vert.glsl index 130ce6512b2..b6a876193b1 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_vert.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_vert.glsl @@ -13,10 +13,10 @@ void main() ObjectBounds bounds = bounds_buf[drw_ResourceID]; interp.P = bounds.bounding_corners[0].xyz; - interp.P += bounds.bounding_corners[1].xyz * pos.x; - interp.P += bounds.bounding_corners[2].xyz * pos.y; - interp.P += bounds.bounding_corners[3].xyz * pos.z; + interp.P += bounds.bounding_corners[1].xyz * max(0, pos.x); + interp.P += bounds.bounding_corners[2].xyz * max(0, pos.y); + interp.P += bounds.bounding_corners[3].xyz * max(0, pos.z); interp.vP = point_world_to_view(interp.P); gl_Position = point_world_to_ndc(interp.P); -} \ No newline at end of file +} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7c023c098b6] tmp-eevee-shadow-commit-mp: EEVEE Shadows: Perform depth testing in tilemap_usage_transparent_ps_
Commit: 7c023c098b6c68906757cfd3903664f19f0e8026 Author: Miguel Pozo Date: Mon Feb 6 18:10:38 2023 +0100 Branches: tmp-eevee-shadow-commit-mp https://developer.blender.org/rB7c023c098b6c68906757cfd3903664f19f0e8026 EEVEE Shadows: Perform depth testing in tilemap_usage_transparent_ps_ === M source/blender/draw/engines/eevee_next/eevee_shadow.cc === diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index 30aa60ddabd..b0202f7bb86 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -1090,7 +1090,9 @@ void ShadowModule::set_view(View &view) tilemap_projection_ratio_ = tilemap_pixel_radius() / screen_pixel_radius(view, int2(target_size)); - usage_tag_fb.ensure(int2(target_size)); + /* TODO(Miguel Pozo): Attach a lower-res hiZ copy for improved performance */ + usage_tag_fb.ensure(GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx)); + render_fb_.ensure(int2(SHADOW_TILEMAP_RES * shadow_page_size_)); bool tile_update_remains = true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5b396924091] tmp-eevee-shadow-commit-mp: EEVEE Shadows: Prevent the far plane from casting shadows onto farther objects
Commit: 5b39692409143f9783a9ed1731821c3b3a0b37ac Author: Miguel Pozo Date: Mon Feb 6 18:03:22 2023 +0100 Branches: tmp-eevee-shadow-commit-mp https://developer.blender.org/rB5b39692409143f9783a9ed1731821c3b3a0b37ac EEVEE Shadows: Prevent the far plane from casting shadows onto farther objects === M source/blender/draw/engines/eevee_next/shaders/eevee_shadow_lib.glsl M source/blender/draw/engines/eevee_next/shaders/eevee_shadow_page_clear_comp.glsl === diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_lib.glsl index 89bfca6c14d..cf2fcf9dc28 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_lib.glsl @@ -158,6 +158,8 @@ ShadowSample shadow_punctual_sample_get( samp.bias = shadow_slope_bias_get(atlas_size, light, lNg, lP, samp.uv, samp.tile.lod); float occluder_ndc = shadow_tile_depth_get(atlas_tx, samp.tile, samp.uv); + /* Depth is cleared to FLT_MAX, we clamp it to 1 in punctual shadows for better precission */ + occluder_ndc = clamp(occluder_ndc, 0, 1); /* NOTE: Given to be both positive, so can use intBitsToFloat instead of orderedInt version. */ float near = intBitsToFloat(light.clip_near); @@ -217,4 +219,4 @@ ShadowSample shadow_sample(const bool is_directional, } } -/** \} */ \ No newline at end of file +/** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_page_clear_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_page_clear_comp.glsl index 1135af01376..3179b1667ca 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_page_clear_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_page_clear_comp.glsl @@ -12,5 +12,6 @@ void main() uvec2 page_co = unpackUvec2x16(clear_page_buf[gl_GlobalInvocationID.z]); uvec2 page_texel = page_co * pages_infos_buf.page_size + gl_GlobalInvocationID.xy; - imageStore(atlas_img, ivec2(page_texel), uvec4(floatBitsToUint(1.0))); -} \ No newline at end of file + /* Clear to FLT_MAX instead of 1 so the far plane doesn't cast shadows onto farther objects */ + imageStore(atlas_img, ivec2(page_texel), uvec4(floatBitsToUint(FLT_MAX))); +} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fcc11668218] master: GPU: Disable verbose GLSL variable names in debug builds
Commit: fcc1166821804ab257660a5b18bc6038e67ba2e1 Author: Miguel Pozo Date: Fri Feb 3 17:00:35 2023 +0100 Branches: master https://developer.blender.org/rBfcc1166821804ab257660a5b18bc6038e67ba2e1 GPU: Disable verbose GLSL variable names in debug builds GpuInput::node can be deallocated in some cases. (See T104265) This is a temp workaround until a proper solution is implemented. === M source/blender/gpu/intern/gpu_codegen.cc === diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 465a621e864..38f80760d61 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -169,7 +169,7 @@ static bool gpu_pass_is_valid(GPUPass *pass) /** \name Type > string conversion * \{ */ -#ifdef DEBUG +#if 0 # define SRC_NAME(io, link, list, type) \ link->node->name << "_" << io << BLI_findindex(&link->node->list, (const void *)link) << "_" \ << type ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e449861b64e] tmp-workbench-rewrite2: Group passes by material
Commit: e449861b64e31e7015206420fc229d3454bef071 Author: Miguel Pozo Date: Fri Jan 27 18:21:40 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBe449861b64e31e7015206420fc229d3454bef071 Group passes by material === M source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh M source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh index 92452eefed2..d49e500a32c 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh @@ -126,19 +126,18 @@ GPU_SHADER_CREATE_INFO(workbench_next_prepass) GPU_SHADER_CREATE_INFO(workbench_color_material) .define("WORKBENCH_COLOR_MATERIAL") -.storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]"); +.push_constant(Type::VEC4, "material_data"); GPU_SHADER_CREATE_INFO(workbench_color_texture) .define("WORKBENCH_COLOR_TEXTURE") .define("WORKBENCH_TEXTURE_IMAGE_ARRAY") -.define("WORKBENCH_COLOR_MATERIAL") -.storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]") .sampler(1, ImageType::FLOAT_2D, "imageTexture", Frequency::BATCH) .sampler(2, ImageType::FLOAT_2D_ARRAY, "imageTileArray", Frequency::BATCH) .sampler(3, ImageType::FLOAT_1D_ARRAY, "imageTileData", Frequency::BATCH) .push_constant(Type::BOOL, "isImageTile") .push_constant(Type::BOOL, "imagePremult") -.push_constant(Type::FLOAT, "imageTransparencyCutoff"); +.push_constant(Type::FLOAT, "imageTransparencyCutoff") +.additional_info("workbench_color_material"); GPU_SHADER_CREATE_INFO(workbench_color_vertex).define("WORKBENCH_COLOR_VERTEX"); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl index 59e30b310bb..47eadab28c3 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl @@ -17,7 +17,7 @@ void workbench_material_data_get(int handle, #else # ifdef WORKBENCH_COLOR_MATERIAL - vec4 data = materials_data[handle]; + vec4 data = material_data; # else vec4 data = vec4(0.0); # endif diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index a04f61418f6..abd3b3f1027 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -196,12 +196,7 @@ class Instance { if (batches[i] == nullptr) { continue; } -/* TODO(fclem): This create a cull-able instance for each sub-object. This is done - * for simplicity to reduce complexity. But this increase the overhead per object. - * Instead, we should use an indirection buffer to the material buffer. */ -ResourceHandle _handle = i == 0 ? handle : manager.resource_handle(ob_ref); - -Material &mat = resources.material_buf.get_or_resize(_handle.resource_index()); +Material mat; if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { mat = Material(*_mat); @@ -219,7 +214,7 @@ class Instance { get_material_image(ob_ref.object, i + 1, image, iuser, sampler_state); } -draw_mesh(ob_ref, mat, batches[i], _handle, image, sampler_state, iuser); +draw_mesh(ob_ref, mat, batches[i], handle, image, sampler_state, iuser); } } } @@ -241,7 +236,7 @@ class Instance { } if (batch) { - Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); + Material mat; if (object_state.color_type == V3D_SHADING_OBJECT_COLOR) { mat = Material(*ob_ref.object); @@ -287,7 +282,7 @@ class Instance { const bool in_front = (ob_ref.object->dtx & OB_DRAW_IN_FRONT) != 0; auto draw = [&](MeshPass &pass) { - pass.draw(ob_ref, batch, handle, image, sampler_state, iuser);
[Bf-blender-cvs] [98aad59d377] tmp-workbench-rewrite2: Revert "Use the same object id across object submeshes"
Commit: 98aad59d377703de495014db4203fc6153db6a8c Author: Miguel Pozo Date: Fri Jan 27 16:20:43 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB98aad59d377703de495014db4203fc6153db6a8c Revert "Use the same object id across object submeshes" This reverts commit 45bc00d298a71c77b73728c7e88995f05d070726. === M source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh M source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl M source/blender/draw/engines/workbench/workbench_defines.hh M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh index f0a89859c44..92452eefed2 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh @@ -40,7 +40,6 @@ GPU_SHADER_CREATE_INFO(workbench_next_mesh) .vertex_in(2, Type::VEC4, "ac") .vertex_in(3, Type::VEC2, "au") .vertex_source("workbench_prepass_vert.glsl") -.storage_buf(WB_OBJECT_ID_SLOT, Qualifier::READ, "uint", "object_id_data[]") .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl index 2f82cd2379d..7fcfb9b1c54 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl @@ -19,9 +19,5 @@ void main() workbench_material_data_get( resource_handle, ac.rgb, color_interp, alpha_interp, _roughness, metallic); -#ifdef WORKBENCH_NEXT - object_id = int(uint(object_id_data[resource_handle]) & 0xu) + 1; -#else object_id = int(uint(resource_handle) & 0xu) + 1; -#endif } diff --git a/source/blender/draw/engines/workbench/workbench_defines.hh b/source/blender/draw/engines/workbench/workbench_defines.hh index c69225b197a..4dfd69d9d50 100644 --- a/source/blender/draw/engines/workbench/workbench_defines.hh +++ b/source/blender/draw/engines/workbench/workbench_defines.hh @@ -5,7 +5,6 @@ #define WB_TILE_ARRAY_SLOT 2 #define WB_TILE_DATA_SLOT 3 #define WB_MATERIAL_SLOT 0 -#define WB_OBJECT_ID_SLOT 1 #define WB_WORLD_SLOT 4 #define WB_RESOLVE_GROUP_SIZE 8 diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 78ac2b2349f..a04f61418f6 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -80,7 +80,6 @@ class Instance { void end_sync() { resources.material_buf.push_update(); -resources.object_id_buf.push_update(); } void object_sync(Manager &manager, ObjectRef &ob_ref) @@ -203,8 +202,6 @@ class Instance { ResourceHandle _handle = i == 0 ? handle : manager.resource_handle(ob_ref); Material &mat = resources.material_buf.get_or_resize(_handle.resource_index()); -resources.object_id_buf.get_or_resize( -_handle.resource_index()) = handle.resource_index(); if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { mat = Material(*_mat); @@ -245,7 +242,6 @@ class Instance { if (batch) { Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); - resources.object_id_buf.get_or_resize(handle.resource_index()) = handle.resource_index(); if (object_state.color_type == V3D_SHADING_OBJECT_COLOR) { mat = Material(*ob_ref.object); diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index d926b0c015d..bc90f26b33d 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -23,7 +23,6 @@ void MeshPass::init_pass(SceneResources &resources, DRWState state, int clip_pla state_set(state, clip_planes); bind_texture(WB_MATCAP_SLOT, resources.matcap_tx); bind_ssbo(WB_MATERIAL_SLOT, &resources.material_buf); - bind_ssbo(WB_OBJECT_ID_SLOT, &resources.object_id_buf); bind_ubo(WB_WORLD_SLOT, resources.world_buf); if (clip_pla
[Bf-blender-cvs] [45bc00d298a] tmp-workbench-rewrite2: Use the same object id across object submeshes
Commit: 45bc00d298a71c77b73728c7e88995f05d070726 Author: Miguel Pozo Date: Fri Jan 27 16:20:39 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB45bc00d298a71c77b73728c7e88995f05d070726 Use the same object id across object submeshes === M source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh M source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl M source/blender/draw/engines/workbench/workbench_defines.hh M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh index 92452eefed2..f0a89859c44 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh @@ -40,6 +40,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_mesh) .vertex_in(2, Type::VEC4, "ac") .vertex_in(3, Type::VEC2, "au") .vertex_source("workbench_prepass_vert.glsl") +.storage_buf(WB_OBJECT_ID_SLOT, Qualifier::READ, "uint", "object_id_data[]") .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl index 7fcfb9b1c54..2f82cd2379d 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl @@ -19,5 +19,9 @@ void main() workbench_material_data_get( resource_handle, ac.rgb, color_interp, alpha_interp, _roughness, metallic); +#ifdef WORKBENCH_NEXT + object_id = int(uint(object_id_data[resource_handle]) & 0xu) + 1; +#else object_id = int(uint(resource_handle) & 0xu) + 1; +#endif } diff --git a/source/blender/draw/engines/workbench/workbench_defines.hh b/source/blender/draw/engines/workbench/workbench_defines.hh index 4dfd69d9d50..c69225b197a 100644 --- a/source/blender/draw/engines/workbench/workbench_defines.hh +++ b/source/blender/draw/engines/workbench/workbench_defines.hh @@ -5,6 +5,7 @@ #define WB_TILE_ARRAY_SLOT 2 #define WB_TILE_DATA_SLOT 3 #define WB_MATERIAL_SLOT 0 +#define WB_OBJECT_ID_SLOT 1 #define WB_WORLD_SLOT 4 #define WB_RESOLVE_GROUP_SIZE 8 diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index a04f61418f6..78ac2b2349f 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -80,6 +80,7 @@ class Instance { void end_sync() { resources.material_buf.push_update(); +resources.object_id_buf.push_update(); } void object_sync(Manager &manager, ObjectRef &ob_ref) @@ -202,6 +203,8 @@ class Instance { ResourceHandle _handle = i == 0 ? handle : manager.resource_handle(ob_ref); Material &mat = resources.material_buf.get_or_resize(_handle.resource_index()); +resources.object_id_buf.get_or_resize( +_handle.resource_index()) = handle.resource_index(); if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { mat = Material(*_mat); @@ -242,6 +245,7 @@ class Instance { if (batch) { Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); + resources.object_id_buf.get_or_resize(handle.resource_index()) = handle.resource_index(); if (object_state.color_type == V3D_SHADING_OBJECT_COLOR) { mat = Material(*ob_ref.object); diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index bc90f26b33d..d926b0c015d 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -23,6 +23,7 @@ void MeshPass::init_pass(SceneResources &resources, DRWState state, int clip_pla state_set(state, clip_planes); bind_texture(WB_MATCAP_SLOT, resources.matcap_tx); bind_ssbo(WB_MATERIAL_SLOT, &resources.material_buf); + bind_ssbo(WB_OBJECT_ID_SLOT, &resources.object_id_buf); bind_ubo(WB_WORLD_SLOT, resources.world_buf); if (clip_planes > 0) { bind_ubo(DRW_CLIPPING_UBO_SLOT, resources.clip_planes_buf); dif
[Bf-blender-cvs] [f5d94f97e41] master: Fix T104132: Vertex colors no longer displaying in Workbench
Commit: f5d94f97e41e71b69927965ac7a66a6188217495 Author: Miguel Pozo Date: Wed Jan 25 23:01:00 2023 +0100 Branches: master https://developer.blender.org/rBf5d94f97e41e71b69927965ac7a66a6188217495 Fix T104132: Vertex colors no longer displaying in Workbench === M source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl === diff --git a/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl index 59e30b310bb..b663c029d5e 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl @@ -12,7 +12,7 @@ void workbench_material_data_get(int handle, vec4 data = materials_data[uint(handle) & 0xFFFu]; color = data.rgb; if (materialIndex == 0) { -color_interp = vertex_color; +color = vertex_color; } #else ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e744673268a] master: Draw: Improve Texture assignment operator
Commit: e744673268a1144034631661ce8d897277454e25 Author: Miguel Pozo Date: Wed Jan 25 16:40:04 2023 +0100 Branches: master https://developer.blender.org/rBe744673268a1144034631661ce8d897277454e25 Draw: Improve Texture assignment operator Differential Revision: https://developer.blender.org/D17119 === M source/blender/draw/intern/DRW_gpu_wrapper.hh === diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 6d8c4cc8e87..22ad08b1cb9 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -560,10 +560,20 @@ class Texture : NonCopyable { Texture &operator=(Texture &&a) { -if (*this != a) { +if (this != std::addressof(a)) { + this->free(); + this->tx_ = a.tx_; this->name_ = a.name_; + this->stencil_view_ = a.stencil_view_; + this->mip_views_ = std::move(a.mip_views_); + this->layer_views_ = std::move(a.layer_views_); + a.tx_ = nullptr; + a.name_ = nullptr; + a.stencil_view_ = nullptr; + a.mip_views_.clear(); + a.layer_views_.clear(); } return *this; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [405b08e00da] master: Fix: Workbench Next: Ensure matcaps textures are loaded
Commit: 405b08e00da6841e27739573e85240ba30c3633f Author: Miguel Pozo Date: Wed Jan 25 17:12:14 2023 +0100 Branches: master https://developer.blender.org/rB405b08e00da6841e27739573e85240ba30c3633f Fix: Workbench Next: Ensure matcaps textures are loaded === M source/blender/draw/engines/workbench/workbench_resources.cc === diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc b/source/blender/draw/engines/workbench/workbench_resources.cc index d33b57b943e..25a2b284c40 100644 --- a/source/blender/draw/engines/workbench/workbench_resources.cc +++ b/source/blender/draw/engines/workbench/workbench_resources.cc @@ -8,8 +8,11 @@ namespace blender::workbench { -static bool get_matcap_tx(Texture &matcap_tx, const StudioLight &studio_light) +static bool get_matcap_tx(Texture &matcap_tx, StudioLight &studio_light) { + BKE_studiolight_ensure_flag(&studio_light, + STUDIOLIGHT_MATCAP_DIFFUSE_GPUTEXTURE | + STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE); ImBuf *matcap_diffuse = studio_light.matcap_diffuse.ibuf; ImBuf *matcap_specular = studio_light.matcap_specular.ibuf; if (matcap_diffuse && matcap_diffuse->rect_float) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ef3225b9daf] master: Cleanup: Workbench Next: Remove UNUSED_VARS
Commit: ef3225b9dafaf842a2c4ddfe672b796708b3d12b Author: Miguel Pozo Date: Wed Jan 25 13:16:53 2023 +0100 Branches: master https://developer.blender.org/rBef3225b9dafaf842a2c4ddfe672b796708b3d12b Cleanup: Workbench Next: Remove UNUSED_VARS === M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 15c18ffef9d..34db0a0dfe9 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -209,9 +209,9 @@ void ShadowPass::ShadowView::set_mode(ShadowPass::PassType type) void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, -bool debug_freeze) +bool /*debug_freeze*/) { - UNUSED_VARS(debug_freeze); + /* TODO (Miguel Pozo): Add debug_freeze support */ GPU_debug_group_begin("ShadowView.compute_visibility"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5cc9f07d5c5] master: Draw: Workbench Next: Fix shaders memory leaks
Commit: 5cc9f07d5c56e7201f17a40659c3f4c4c5a83002 Author: Miguel Pozo Date: Tue Jan 24 20:42:14 2023 +0100 Branches: master https://developer.blender.org/rB5cc9f07d5c56e7201f17a40659c3f4c4c5a83002 Draw: Workbench Next: Fix shaders memory leaks Ensure all shaders are deleted === M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_effect_outline.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shader_cache.cc M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 7d46703ad35..d7f2edb3e90 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -53,6 +53,15 @@ static void square_to_circle(float x, float y, float &r, float &T) } } +DofPass::~DofPass() +{ + DRW_SHADER_FREE_SAFE(prepare_sh_); + DRW_SHADER_FREE_SAFE(downsample_sh_); + DRW_SHADER_FREE_SAFE(blur1_sh_); + DRW_SHADER_FREE_SAFE(blur2_sh_); + DRW_SHADER_FREE_SAFE(resolve_sh_); +} + void DofPass::setup_samples() { float4 *sample = samples_buf_.begin(); diff --git a/source/blender/draw/engines/workbench/workbench_effect_outline.cc b/source/blender/draw/engines/workbench/workbench_effect_outline.cc index a1826d5ecf8..a4b321c44b5 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_outline.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_outline.cc @@ -12,6 +12,11 @@ namespace blender::workbench { +OutlinePass::~OutlinePass() +{ + DRW_SHADER_FREE_SAFE(sh_); +} + void OutlinePass::init(const SceneState &scene_state) { enabled_ = scene_state.draw_outline; diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index a32127d66b0..2f4d785216d 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -245,6 +245,11 @@ bool OpaquePass::is_empty() const /** \name TransparentPass * \{ */ +TransparentPass::~TransparentPass() +{ + DRW_SHADER_FREE_SAFE(resolve_sh_); +} + void TransparentPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_OIT | @@ -324,6 +329,11 @@ bool TransparentPass::is_empty() const /** \name TransparentDepthPass * \{ */ +TransparentDepthPass::~TransparentDepthPass() +{ + DRW_SHADER_FREE_SAFE(merge_sh_); +} + void TransparentDepthPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 5d9de764d56..20c07061b06 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -226,6 +226,8 @@ class TransparentPass { PassSimple resolve_ps_ = {"Transparent.Resolve"}; Framebuffer resolve_fb = {}; + ~TransparentPass(); + void sync(const SceneState &scene_state, SceneResources &resources); void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution); bool is_empty() const; @@ -243,6 +245,8 @@ class TransparentDepthPass { PassSimple merge_ps_ = {"TransparentDepth.Merge"}; Framebuffer merge_fb = {"TransparentDepth.Merge"}; + ~TransparentDepthPass(); + void sync(const SceneState &scene_state, SceneResources &resources); void draw(Manager &manager, View &view, SceneResources &resources); bool is_empty() const; @@ -261,13 +265,17 @@ class ShadowPass { VisibilityBuf pass_visibility_buf_ = {}; VisibilityBuf fail_visibility_buf_ = {}; +GPUShader *dynamic_pass_type_shader_; +GPUShader *static_pass_type_shader_; + public: +ShadowView(); +~ShadowView(); + void setup(View &view, float3 light_direction, bool force_fail_method); bool debug_object_culling(Object *ob); void set_mode(PassType type); -ShadowView(); - protected: virtual void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, @@ -298,6 +306,8 @@ class ShadowPass { Framebuffer fb_ = {}; public: + ~ShadowPass(); + void init(const SceneState &sc
[Bf-blender-cvs] [361ebe98d51] master: Draw: Workbench Next: Fix shadow culling after recent cleanup commit
Commit: 361ebe98d5147ea918335bce0347e19d10d7276b Author: Miguel Pozo Date: Tue Jan 24 15:45:07 2023 +0100 Branches: master https://developer.blender.org/rB361ebe98d5147ea918335bce0347e19d10d7276b Draw: Workbench Next: Fix shadow culling after recent cleanup commit 79ba1a1ac82d854d840e98141b2458e4c7e2a7dd changed virtual function signatures so they didn't match their parents. === M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 94b609519d6..5d9de764d56 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -269,8 +269,10 @@ class ShadowPass { ShadowView(); protected: -virtual void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len); -virtual VisibilityBuf &get_visibility_buffer(); +virtual void compute_visibility(ObjectBoundsBuf &bounds, +uint resource_len, +bool debug_freeze) override; +virtual VisibilityBuf &get_visibility_buffer() override; } view_ = {}; bool enabled_; diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index e4a409f1457..d13d717832e 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -202,8 +202,12 @@ void ShadowPass::ShadowView::set_mode(ShadowPass::PassType type) current_pass_type_ = type; } -void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len) +void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, +uint resource_len, +bool debug_freeze) { + UNUSED_VARS(debug_freeze); + GPU_debug_group_begin("ShadowView.compute_visibility"); uint word_per_draw = this->visibility_word_per_draw(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ba982119cdc] master: Workbench Next
Commit: ba982119cdcacfa8e603457face1d8ebc763ef75 Author: Miguel Pozo Date: Mon Jan 23 17:59:07 2023 +0100 Branches: master https://developer.blender.org/rBba982119cdcacfa8e603457face1d8ebc763ef75 Workbench Next Rewrite of the Workbench engine using C++ and the new Draw Manager API. The new engine can be enabled in Blender `Preferences > Experimental > Workbench Next`. After that, the engine can be selected in `Properties > Scene > Render Engine`. When `Workbench Next` is the active engine, it also handles the `Solid` viewport mode rendering. The rewrite aims to be functionally equivalent to the current Workbench engine, but it also includes some small fixes/tweaks: - `In Front` rendered objects now work correctly with DoF and Shadows. - The `Sampling > Viewport` setting is actually used when the viewport is in `Render Mode`. - In `Texture` mode, textured materials also use the material properties. (Previously, only non textured materials would) To do: - Sculpt PBVH. - Volume rendering. - Hair rendering. - Use the "no_geom" shader versions for shadow rendering. - Decide the final API for custom visibility culling (Needed for shadows). - Profile/optimize. Known Issues: - Matcaps are not loaded until they’re shown elsewhere. (e.g. when opening the `Viewort Shading` UI) - Outlines are drawn between different materials of the same object. (Each material submesh has its own object handle) Reviewed By: fclem Maniphest Tasks: T101619 Differential Revision: https://developer.blender.org/D16826 === M release/scripts/startup/bl_ui/properties_data_armature.py M release/scripts/startup/bl_ui/properties_data_bone.py M release/scripts/startup/bl_ui/properties_data_camera.py M release/scripts/startup/bl_ui/properties_data_curve.py M release/scripts/startup/bl_ui/properties_data_curves.py M release/scripts/startup/bl_ui/properties_data_lattice.py M release/scripts/startup/bl_ui/properties_data_light.py M release/scripts/startup/bl_ui/properties_data_mesh.py M release/scripts/startup/bl_ui/properties_data_metaball.py M release/scripts/startup/bl_ui/properties_data_pointcloud.py M release/scripts/startup/bl_ui/properties_data_speaker.py M release/scripts/startup/bl_ui/properties_data_volume.py M release/scripts/startup/bl_ui/properties_freestyle.py M release/scripts/startup/bl_ui/properties_material.py M release/scripts/startup/bl_ui/properties_material_gpencil.py M release/scripts/startup/bl_ui/properties_object.py M release/scripts/startup/bl_ui/properties_output.py M release/scripts/startup/bl_ui/properties_particle.py M release/scripts/startup/bl_ui/properties_physics_cloth.py M release/scripts/startup/bl_ui/properties_physics_common.py M release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py M release/scripts/startup/bl_ui/properties_physics_field.py M release/scripts/startup/bl_ui/properties_physics_fluid.py M release/scripts/startup/bl_ui/properties_physics_rigidbody.py M release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py M release/scripts/startup/bl_ui/properties_physics_softbody.py M release/scripts/startup/bl_ui/properties_render.py M release/scripts/startup/bl_ui/properties_texture.py M release/scripts/startup/bl_ui/properties_view_layer.py M release/scripts/startup/bl_ui/properties_world.py M release/scripts/startup/bl_ui/space_node.py M release/scripts/startup/bl_ui/space_sequencer.py M release/scripts/startup/bl_ui/space_userpref.py M source/blender/blenkernel/intern/scene.cc M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl M source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl M source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl M source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl M source/blender/draw/engines/workbench/shaders/workbench_matcap_lib.glsl M source/blender/draw/engines/workbench/shaders/workbench_material_lib.glsl A source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl A source/blender/draw/
[Bf-blender-cvs] [ba0a3747394] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: ba0a3747394fa041bed73250d7e07cd7ebe7f951 Author: Miguel Pozo Date: Mon Jan 23 17:56:42 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBba0a3747394fa041bed73250d7e07cd7ebe7f951 Merge branch 'master' into tmp-workbench-rewrite2 === === diff --cc release/scripts/startup/bl_ui/properties_data_camera.py index b348940a260,0a9a16999b8..6ecfa9dfbb4 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@@ -21,15 -21,15 +21,15 @@@ class CAMERA_PT_presets(PresetPanel, Pa preset_subdir = "camera" preset_operator = "script.execute_preset" preset_add_operator = "camera.preset_add" -COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH'} +COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH','BLENDER_WORKBENCH_NEXT'} - class SAFE_AREAS_PT_presets(PresetPanel, Panel): + class CAMERA_PT_safe_areas_presets(PresetPanel, Panel): bl_label = "Camera Presets" preset_subdir = "safe_areas" preset_operator = "script.execute_preset" - preset_add_operator = "safe_areas.preset_add" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH','BLENDER_WORKBENCH_NEXT'} + preset_add_operator = "camera.safe_areas_preset_add" -COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH'} ++COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH', 'BLENDER_WORKBENCH_NEXT'} class DATA_PT_context_camera(CameraButtonsPanel, Panel): diff --cc source/blender/draw/intern/DRW_gpu_wrapper.hh index bc090fe0436,1653dedebba..6d8c4cc8e87 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@@ -1048,20 -1066,25 +1066,35 @@@ class Framebuffer : NonCopyable GPUAttachment color7 = GPU_ATTACHMENT_NONE, GPUAttachment color8 = GPU_ATTACHMENT_NONE) { - GPU_framebuffer_ensure_config( - &fb_, {depth, color1, color2, color3, color4, color5, color6, color7, color8}); + if (fb_ == NULL) { + fb_ = GPU_framebuffer_create(name_); + } + GPUAttachment config[] = { + depth, color1, color2, color3, color4, color5, color6, color7, color8}; + GPU_framebuffer_config_array(fb_, config, sizeof(config) / sizeof(GPUAttachment)); + } + + /** +* Empty frame-buffer configuration. +*/ + void ensure(int2 target_size) + { + if (fb_ == NULL) { + fb_ = GPU_framebuffer_create(name_); + } + GPU_framebuffer_default_size(fb_, UNPACK2(target_size)); } + void bind() + { +GPU_framebuffer_bind(fb_); + } + + void clear_depth(float depth) + { +GPU_framebuffer_clear_depth(fb_, depth); + } + Framebuffer &operator=(Framebuffer &&a) { if (*this != a) { diff --cc source/blender/draw/intern/draw_view.hh index 5bf2bf1a568,e18abf94fce..3e93e0043aa --- a/source/blender/draw/intern/draw_view.hh +++ b/source/blender/draw/intern/draw_view.hh @@@ -69,9 -72,16 +69,19 @@@ class View void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id = 0); + /* For compatibility with old system. Will be removed at some point. */ + void sync(const DRWView *view); + + /** Disable a range in the multi-view array. Disabled view will not produce any instances. */ + void disable(IndexRange range); + + /** +* Update culling data using a compute shader. +* This is to be used if the matrices were updated externally +* on the GPU (not using the `sync()` method). +**/ + void compute_procedural_bounds(); + bool is_persp(int view_id = 0) const { BLI_assert(view_id < view_len_); @@@ -132,11 -142,15 +142,16 @@@ return (view_len_ == 1) ? 0 : divide_ceil_u(view_len_, 32); } + UniformArrayBuffer &matrices_ubo_get() + { + return data_; + } + - private: + protected: /** Called from draw manager. */ void bind(); - void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze); + virtual void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze); + virtual VisibilityBuf &get_visibility_buffer(); void update_viewport_size(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7e834457c5d] tmp-workbench-rewrite2: Add Workbench Next check to hard-coded Workbench checks
Commit: 7e834457c5d0c88cde470fca36cc7c90139cad01 Author: Miguel Pozo Date: Mon Jan 23 17:21:20 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB7e834457c5d0c88cde470fca36cc7c90139cad01 Add Workbench Next check to hard-coded Workbench checks === M source/blender/blenkernel/intern/scene.cc M source/blender/editors/space_view3d/view3d_utils.c M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 124de007ade..7461e6c07f2 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -1748,6 +1748,7 @@ IDTypeInfo IDType_ID_SCE = get_type_info(); const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE"; const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH"; +const char *RE_engine_id_BLENDER_WORKBENCH_NEXT = "BLENDER_WORKBENCH_NEXT"; const char *RE_engine_id_CYCLES = "CYCLES"; void free_avicodecdata(AviCodecData *acd) @@ -2939,7 +2940,8 @@ bool BKE_scene_uses_blender_eevee(const Scene *scene) bool BKE_scene_uses_blender_workbench(const Scene *scene) { - return STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH); + return STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH) || + STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH_NEXT); } bool BKE_scene_uses_cycles(const Scene *scene) diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index fc26e6b4a06..d87a2730c7b 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -84,7 +84,7 @@ bool ED_view3d_has_workbench_in_texture_color(const Scene *scene, } } else if (v3d->shading.type == OB_RENDER) { -if (STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH)) { +if (BKE_scene_uses_blender_workbench(scene)) { return scene->display.shading.color_type == V3D_SHADING_TEXTURE_COLOR; } } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index a4076a4c4e6..c85b40a9342 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2148,6 +2148,7 @@ enum { /** #RenderData.engine (scene.cc) */ extern const char *RE_engine_id_BLENDER_EEVEE; extern const char *RE_engine_id_BLENDER_WORKBENCH; +extern const char *RE_engine_id_BLENDER_WORKBENCH_NEXT; extern const char *RE_engine_id_CYCLES; /** \} */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 15ed20ce354..dcf50bb5893 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1165,7 +1165,7 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA View3DShading *shading = ptr->data; if (shading->type == OB_MATERIAL || - (shading->type == OB_RENDER && !STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH))) { + (shading->type == OB_RENDER && !BKE_scene_uses_blender_workbench(scene))) { /* When switching from workbench to render or material mode the geometry of any * active sculpt session needs to be recalculated. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b44a8f6749a] master: Fix: Draw: Negative scaled objects cause wrong resource indexing
Commit: b44a8f6749a5eed3fea980a413b1cd179dea2781 Author: Miguel Pozo Date: Mon Jan 23 16:25:04 2023 +0100 Branches: master https://developer.blender.org/rBb44a8f6749a5eed3fea980a413b1cd179dea2781 Fix: Draw: Negative scaled objects cause wrong resource indexing In the new Draw Manager, when the same DrawGroup has both front and back facing instances, the front facing instances don't offset their indices accordingly. Differential Revision: https://developer.blender.org/D17069 === M source/blender/draw/intern/shaders/draw_command_generate_comp.glsl === diff --git a/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl b/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl index 75e5cda29d2..11bf862a911 100644 --- a/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl +++ b/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl @@ -13,7 +13,8 @@ void write_draw_call(DrawGroup group, uint group_id) DrawCommand cmd; cmd.vertex_len = group.vertex_len; cmd.vertex_first = group.vertex_first; - if (group.base_index != -1) { + bool indexed_draw = group.base_index != -1; + if (indexed_draw) { cmd.base_index = group.base_index; cmd.instance_first_indexed = group.start; } @@ -23,7 +24,15 @@ void write_draw_call(DrawGroup group, uint group_id) /* Back-facing command. */ cmd.instance_len = group_buf[group_id].back_facing_counter; command_buf[group_id * 2 + 0] = cmd; + /* Front-facing command. */ + uint front_facing_start = group.start + (group.len - group.front_facing_len); + if (indexed_draw) { +cmd.instance_first_indexed = front_facing_start; + } + else { +cmd._instance_first_array = front_facing_start; + } cmd.instance_len = group_buf[group_id].front_facing_counter; command_buf[group_id * 2 + 1] = cmd; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [40f9f82977a] tmp-workbench-rewrite2: Fix alpha cutout
Commit: 40f9f82977a88126e021125c5a13082053483d97 Author: Miguel Pozo Date: Mon Jan 23 15:20:41 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB40f9f82977a88126e021125c5a13082053483d97 Fix alpha cutout textured meshes where getting drawn twice! === M source/blender/draw/engines/workbench/workbench_mesh_passes.cc === diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index d8bc3702c17..bc90f26b33d 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -97,6 +97,7 @@ void MeshPass::draw(ObjectRef &ref, texture_subpass_map_.lookup_or_add_cb(TextureSubPassKey(texture, geometry_type), add_cb) ->draw(batch, handle); + return; } } passes_[static_cast(geometry_type)][static_cast(eShaderType::MATERIAL)]->draw(batch, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4bc413eae12] tmp-workbench-rewrite2: Remove leftover View from engine data
Commit: 4bc413eae12a555c56461f29af384a71b771011b Author: Miguel Pozo Date: Mon Jan 23 13:37:18 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB4bc413eae12a555c56461f29af384a71b771011b Remove leftover View from engine data The pointer was getting read as the engine data info string. === M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index a1167c75708..a04f61418f6 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -401,7 +401,6 @@ struct WORKBENCH_Data { DRWViewportEmptyList *psl; DRWViewportEmptyList *stl; workbench::Instance *instance; - draw::View *view; char info[GPU_INFO_SIZE]; }; @@ -416,7 +415,6 @@ static void workbench_engine_init(void *vedata) WORKBENCH_Data *ved = reinterpret_cast(vedata); if (ved->instance == nullptr) { ved->instance = new workbench::Instance(); -ved->view = new draw::View("Default View"); } ved->instance->init(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2da005902f4] tmp-worbench-rewrite2-optimizations: Draw: Cleanup the GLSL intersection code
Commit: 2da005902f434b6d4301516e280c899129384b95 Author: Miguel Pozo Date: Fri Jan 13 17:51:54 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB2da005902f434b6d4301516e280c899129384b95 Draw: Cleanup the GLSL intersection code === M source/blender/draw/intern/shaders/common_intersect_lib.glsl M source/blender/draw/intern/shaders/common_math_geom_lib.glsl === diff --git a/source/blender/draw/intern/shaders/common_intersect_lib.glsl b/source/blender/draw/intern/shaders/common_intersect_lib.glsl index d1416e220a4..080771ca49b 100644 --- a/source/blender/draw/intern/shaders/common_intersect_lib.glsl +++ b/source/blender/draw/intern/shaders/common_intersect_lib.glsl @@ -124,311 +124,137 @@ IsectFrustum isect_data_setup(Frustum shape) /** \} */ /* -- */ -/** \name View Intersection functions. +/** \name Shape vs. Shape Intersection functions. * \{ */ -bool intersect_view(Pyramid pyramid) +bool intersect(IsectPyramid i_pyramid, IsectBox i_box) { - bool intersects = true; - - /* Do Pyramid vertices vs Frustum planes. */ - for (int p = 0; p < 6; ++p) { -bool is_any_vertex_on_positive_side = false; -for (int v = 0; v < 5; ++v) { - float test = dot(drw_view_culling.planes[p], vec4(pyramid.corners[v], 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; -break; - } -} -bool all_vertex_on_negative_side = !is_any_vertex_on_positive_side; -if (all_vertex_on_negative_side) { - intersects = false; - break; -} - } - - if (!intersects) { -return intersects; - } - - /* Now do Frustum vertices vs Pyramid planes. */ - IsectPyramid i_pyramid = isect_data_setup(pyramid); + /* Do Box vertices vs Pyramid planes. */ for (int p = 0; p < 5; ++p) { -bool is_any_vertex_on_positive_side = false; -for (int v = 0; v < 8; ++v) { - float test = dot(i_pyramid.planes[p], vec4(drw_view_culling.corners[v].xyz, 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; -break; - } -} -bool all_vertex_on_negative_side = !is_any_vertex_on_positive_side; -if (all_vertex_on_negative_side) { - intersects = false; - break; -} - } - return intersects; -} - -bool intersect_view(Box box) -{ - bool intersects = true; - - /* Do Box vertices vs Frustum planes. */ - for (int p = 0; p < 6; ++p) { -bool is_any_vertex_on_positive_side = false; -for (int v = 0; v < 8; ++v) { - float test = dot(drw_view_culling.planes[p], vec4(box.corners[v], 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; -break; - } -} -bool all_vertex_on_negative_side = !is_any_vertex_on_positive_side; -if (all_vertex_on_negative_side) { - intersects = false; - break; -} - } - - if (!intersects) { -return intersects; - } - - /* Now do Frustum vertices vs Box planes. */ - IsectBox i_box = isect_data_setup(box); - for (int p = 0; p < 6; ++p) { -bool is_any_vertex_on_positive_side = false; -for (int v = 0; v < 8; ++v) { - float test = dot(i_box.planes[p], vec4(drw_view_culling.corners[v].xyz, 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; -break; - } -} -bool all_vertex_on_negative_side = !is_any_vertex_on_positive_side; -if (all_vertex_on_negative_side) { - intersects = false; - break; -} - } - - return intersects; -} - -bool intersect_view(IsectBox i_box) -{ - bool intersects = true; - - /* Do Box vertices vs Frustum planes. */ - for (int p = 0; p < 6; ++p) { -bool is_any_vertex_on_positive_side = false; +bool separating_axis = true; for (int v = 0; v < 8; ++v) { - float test = dot(drw_view_culling.planes[p], vec4(i_box.corners[v], 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; + float signed_distance = point_plane_projection_dist(i_box.corners[v], i_pyramid.planes[p]); + if (signed_distance <= 0.0) { +separating_axis = false; break; } } -bool all_vertex_on_negative_side = !is_any_vertex_on_positive_side; -if (all_vertex_on_negative_side) { - intersects = false; - break; +if (separating_axis) { + return false; } } - if (!intersects) { -return intersects; - } - + /* Now do Pyramid vertices vs Box planes. */ for (int p = 0; p < 6; ++p) { -bool is_any_vertex_on_positive_side = false; -for (int v = 0; v < 8; ++v) { - float test = dot(i_box.planes[p], vec4(drw_view_culling.corners[v].xyz, 1.0)); - if (test > 0.0) { -is_any_vertex_on_positive_side = true; +boo
[Bf-blender-cvs] [693dffb7b7c] tmp-worbench-rewrite2-optimizations: Use smaller ObjectBounds
Commit: 693dffb7b7c1039c2165b83b1b81fa39256d6ef8 Author: Miguel Pozo Date: Fri Jan 20 18:01:18 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB693dffb7b7c1039c2165b83b1b81fa39256d6ef8 Use smaller ObjectBounds Only store center and size. Skip resource finalize computation. === M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/intern/draw_manager.cc M source/blender/draw/intern/draw_resource.hh M source/blender/draw/intern/draw_shader_shared.h M source/blender/draw/intern/draw_view.cc M source/blender/draw/intern/draw_view.hh M source/blender/draw/intern/shaders/draw_resource_finalize_comp.glsl M source/blender/draw/intern/shaders/draw_view_info.hh M source/blender/draw/intern/shaders/draw_visibility_comp.glsl === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 086553ca5c1..2022fb69945 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -269,7 +269,10 @@ class ShadowPass { ShadowView(); protected: -virtual void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze); +virtual void compute_visibility(ObjectMatricesBuf &matrices, +ObjectBoundsBuf &bounds, +uint resource_len, +bool debug_freeze); virtual VisibilityBuf &get_visibility_buffer(); } view_ = {}; diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 22c7b663220..909edd63667 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -201,7 +201,8 @@ void ShadowPass::ShadowView::set_mode(ShadowPass::PassType type) current_pass_type_ = type; } -void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, +void ShadowPass::ShadowView::compute_visibility(ObjectMatricesBuf &matrices, +ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze) { @@ -231,6 +232,8 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, GPU_storagebuf_clear(visibility_buf_, GPU_R32UI, GPU_DATA_UINT, &data); } + /* TODO(Miguel Pozo): Disabled in the optimization branch */ + do_visibility_ = false; if (do_visibility_) { /* TODO(Miguel Pozo): Use regular culling for the caps pass */ @@ -249,6 +252,7 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, GPU_shader_uniform_3fv(shader, "shadow_direction", light_direction_); GPU_uniformbuf_bind(extruded_frustum_, GPU_shader_get_uniform_block(shader, "extruded_frustum")); +GPU_storagebuf_bind(matrices, GPU_shader_get_ssbo(shader, "matrix_buf")); GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf")); if (current_pass_type_ == ShadowPass::FORCED_FAIL) { GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf")); diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index d1a60c1af1f..540e1900424 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -166,7 +166,7 @@ void Manager::submit(PassMain &pass, View &view) bool freeze_culling = (U.experimental.use_viewport_debug && DST.draw_ctx.v3d && (DST.draw_ctx.v3d->debug_flag & V3D_DEBUG_FREEZE_CULLING) != 0); - view.compute_visibility(bounds_buf, resource_len_, freeze_culling); + view.compute_visibility(matrix_buf, bounds_buf, resource_len_, freeze_culling); command::RecordingState state; state.inverted_view = view.is_inverted(); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index edc023c5703..09744d6403c 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -147,56 +147,54 @@ inline std::ostream &operator<<(std::ostream &stream, const ObjectInfos &infos) inline void ObjectBounds::sync() { - bounding_sphere.w = -1.0f; /* Disable test. */ + test_enabled = false; } inline void ObjectBounds::sync(Object &ob) { - BoundBox _bbox; -
[Bf-blender-cvs] [a9d716fa0fe] tmp-worbench-rewrite2-optimizations: Optimization: Draw: Avoid runtime.bb allocation for DupliObjects
Commit: a9d716fa0fe3f0d250de3438e0ac8af22514178a Author: Miguel Pozo Date: Wed Jan 18 15:17:47 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBa9d716fa0fe3f0d250de3438e0ac8af22514178a Optimization: Draw: Avoid runtime.bb allocation for DupliObjects === M source/blender/draw/intern/draw_manager_data.cc M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 5b4e0792577..125029b79e1 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -16,6 +16,7 @@ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_mesh.h" +#include "BKE_mesh_wrapper.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_pbvh.h" @@ -695,7 +696,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) drw_call_calc_orco(ob, ob_infos->orcotexfac); /* Random float value. */ uint random = (DST.dupli_source) ? - DST.dupli_source->random_id : +DST.dupli_source->random_id : /* TODO(fclem): this is rather costly to do at runtime. Maybe we can * put it in ob->runtime and make depsgraph ensure it is up to date. */ BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0); @@ -719,26 +720,41 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) static void drw_call_culling_init(DRWCullingState *cull, Object *ob) { - const BoundBox *bbox; - if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) { -float corner[3]; -/* Get BoundSphere center and radius from the BoundBox. */ -mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); -mul_v3_m4v3(corner, ob->object_to_world, bbox->vec[0]); -mul_m4_v3(ob->object_to_world, cull->bsphere.center); -cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); + /* Bypass test */ + cull->bsphere.radius = -1.0f; + /* Reset user data */ + cull->user_data = nullptr; + + if (ob != nullptr) { +if (ob->type == OB_MESH) { + /* Optimization: Retrieve the mesh cached min max directly. + * Avoids allocating a BoundBox on every sample for each DupliObject instance. + * TODO(Miguel Pozo): Remove once T92963 or T96968 are done */ + float3 min, max; + INIT_MINMAX(min, max); + BKE_mesh_wrapper_minmax(static_cast(ob->data), min, max); + + /* Get BoundSphere center and radius from min/max. */ + float3 min_world = float4x4(ob->object_to_world) * min; + float3 max_world = float4x4(ob->object_to_world) * max; + + mid_v3_v3v3(cull->bsphere.center, min_world, max_world); + cull->bsphere.radius = len_v3v3(cull->bsphere.center, max_world); +} +else if (const BoundBox *bbox = BKE_object_boundbox_get(ob)) { + float corner[3]; + /* Get BoundSphere center and radius from the BoundBox. */ + mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); + mul_v3_m4v3(corner, ob->object_to_world, bbox->vec[0]); + mul_m4_v3(ob->object_to_world, cull->bsphere.center); + cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); +} /* Bypass test for very large objects (see T67319). */ if (UNLIKELY(cull->bsphere.radius > 1e12)) { cull->bsphere.radius = -1.0f; } } - else { -/* Bypass test. */ -cull->bsphere.radius = -1.0f; - } - /* Reset user data */ - cull->user_data = nullptr; } static DRWResourceHandle drw_resource_handle_new(float (*obmat)[4], Object *ob) diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index a2de084b900..edc023c5703 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -13,6 +13,7 @@ #include "BKE_curve.h" #include "BKE_duplilist.h" #include "BKE_mesh.h" +#include "BKE_mesh_wrapper.h" #include "BKE_object.h" #include "BKE_volume.h" #include "BLI_hash.h" @@ -151,11 +152,25 @@ inline void ObjectBounds::sync() inline void ObjectBounds::sync(Object &ob) { - const BoundBox *bbox = BKE_object_boundbox_get(&ob); - if (bbox == nullptr) { -bounding_sphere.w = -1.0f; /* Disable test. */ - return; + BoundBox _bbox; + const BoundBox *bbox = &_bbox; + + if (ob.type == OB_MESH) { +/* Optimization: Retrieve the mesh cached min max directly. + * Avoids allocating a BoundBox on every sample for each DupliObj
[Bf-blender-cvs] [aef43d1461a] tmp-worbench-rewrite2-optimizations: Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations
Commit: aef43d1461acb61b38afe5a90c181bd167a8abd9 Author: Miguel Pozo Date: Fri Jan 20 17:50:21 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBaef43d1461acb61b38afe5a90c181bd167a8abd9 Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [99e5f4000c5] tmp-workbench-rewrite2: Add texture usage flags
Commit: 99e5f4000c5d6dcca44fe4018c87d37f1a833ea3 Author: Miguel Pozo Date: Thu Jan 19 16:58:51 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB99e5f4000c5d6dcca44fe4018c87d37f1a833ea3 Add texture usage flags === M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_resources.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 39b46c7ac1e..6b0b2e75c27 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -112,11 +112,12 @@ AntiAliasingPass::AntiAliasingPass() smaa_aa_weight_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_1"); smaa_resolve_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_2"); - smaa_search_tx_.ensure_2d(GPU_R8, {SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}); + smaa_search_tx_.ensure_2d( + GPU_R8, {SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}, GPU_TEXTURE_USAGE_SHADER_READ); GPU_texture_update(smaa_search_tx_, GPU_DATA_UBYTE, searchTexBytes); GPU_texture_filter_mode(smaa_search_tx_, true); - smaa_area_tx_.ensure_2d(GPU_RG8, {AREATEX_WIDTH, AREATEX_HEIGHT}); + smaa_area_tx_.ensure_2d(GPU_RG8, {AREATEX_WIDTH, AREATEX_HEIGHT}, GPU_TEXTURE_USAGE_SHADER_READ); GPU_texture_update(smaa_area_tx_, GPU_DATA_UBYTE, areaTexBytes); GPU_texture_filter_mode(smaa_area_tx_, true); } @@ -144,8 +145,11 @@ void AntiAliasingPass::sync(SceneResources &resources, int2 resolution) return; } - taa_accumulation_tx_.ensure_2d(GPU_RGBA16F, resolution); - sample0_depth_tx_.ensure_2d(GPU_DEPTH24_STENCIL8, resolution); + taa_accumulation_tx_.ensure_2d( + GPU_RGBA16F, resolution, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT); + sample0_depth_tx_.ensure_2d(GPU_DEPTH24_STENCIL8, + resolution, + GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT); taa_accumulation_ps_.init(); taa_accumulation_ps_.state_set(sample_ == 0 ? DRW_STATE_WRITE_COLOR : @@ -279,13 +283,15 @@ void AntiAliasingPass::draw(Manager &manager, } if (!DRW_state_is_image_render() || last_sample) { -smaa_weight_tx_.acquire(resolution, GPU_RGBA8); +smaa_weight_tx_.acquire( +resolution, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT); smaa_mix_factor_ = 1.0f - clamp_f(sample_ / 4.0f, 0.0f, 1.0f); smaa_viewport_metrics_ = float4(float2(1.0f / float2(resolution)), resolution); /* After a certain point SMAA is no longer necessary. */ if (smaa_mix_factor_ > 0.0f) { - smaa_edge_tx_.acquire(resolution, GPU_RG8); + smaa_edge_tx_.acquire( + resolution, GPU_RG8, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT); smaa_edge_fb_.ensure(GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(smaa_edge_tx_)); smaa_edge_fb_.bind(); manager.submit(smaa_edge_detect_ps_, view); diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 582adeb4ed9..7d46703ad35 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -222,7 +222,8 @@ void DofPass::draw(Manager &manager, View &view, SceneResources &resources, int2 DRW_stats_group_start("Depth Of Field"); int2 half_res = {max_ii(resolution.x / 2, 1), max_ii(resolution.y / 2, 1)}; - blur_tx_.acquire(half_res, GPU_RGBA16F); + blur_tx_.acquire( + half_res, GPU_RGBA16F, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT); downsample_fb_.ensure(GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(source_tx_), diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index e917aa1e81e..a1167c75708 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -62,7 +62,10 @@ class Instance { { const float2 viewport_size = DRW_viewport_size_get(); const int2 resolution = {int(viewport_size.x), int(viewport_size.y)}; -resources.depth_tx.ensure_2d(GPU_DEPTH24_STENCIL8, resolution); +resources.depth_tx.ensure_2d(GPU_DEPTH24_S
[Bf-blender-cvs] [2c432baad0b] tmp-workbench-rewrite2: Add texture mirror extension type support (see D16432)
Commit: 2c432baad0b4e21c8173d5c66ec07b81c290e16f Author: Miguel Pozo Date: Thu Jan 19 17:07:19 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB2c432baad0b4e21c8173d5c66ec07b81c290e16f Add texture mirror extension type support (see D16432) === M source/blender/draw/engines/workbench/workbench_materials_next.cc === diff --git a/source/blender/draw/engines/workbench/workbench_materials_next.cc b/source/blender/draw/engines/workbench/workbench_materials_next.cc index ec42c696ccc..74622882e52 100644 --- a/source/blender/draw/engines/workbench/workbench_materials_next.cc +++ b/source/blender/draw/engines/workbench/workbench_materials_next.cc @@ -69,17 +69,19 @@ void get_material_image(Object *ob, if (node && image) { switch (node->type) { case SH_NODE_TEX_IMAGE: { -NodeTexImage *storage = static_cast(node->storage); +const NodeTexImage *storage = static_cast(node->storage); const bool use_filter = (storage->interpolation != SHD_INTERP_CLOSEST); -const bool use_repeat = (storage->extension == SHD_IMAGE_EXTENSION_REPEAT); +const bool use_mirror = (storage->extension == SHD_IMAGE_EXTENSION_MIRROR); +const bool use_repeat = use_mirror || (storage->extension == SHD_IMAGE_EXTENSION_REPEAT); const bool use_clip = (storage->extension == SHD_IMAGE_EXTENSION_CLIP); SET_FLAG_FROM_TEST(sampler_state, use_filter, GPU_SAMPLER_FILTER); SET_FLAG_FROM_TEST(sampler_state, use_repeat, GPU_SAMPLER_REPEAT); SET_FLAG_FROM_TEST(sampler_state, use_clip, GPU_SAMPLER_CLAMP_BORDER); +SET_FLAG_FROM_TEST(sampler_state, use_mirror, GPU_SAMPLER_MIRROR_REPEAT); break; } case SH_NODE_TEX_ENVIRONMENT: { -NodeTexEnvironment *storage = static_cast(node->storage); +const NodeTexEnvironment *storage = static_cast(node->storage); const bool use_filter = (storage->interpolation != SHD_INTERP_CLOSEST); SET_FLAG_FROM_TEST(sampler_state, use_filter, GPU_SAMPLER_FILTER); break; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1b5a594a052] tmp-workbench-rewrite2: Fix textures after D14365
Commit: 1b5a594a0529bf696caa419f26ac34712b5caeb0 Author: Miguel Pozo Date: Thu Jan 19 16:11:09 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB1b5a594a0529bf696caa419f26ac34712b5caeb0 Fix textures after D14365 UVs are now stored as generic attributes. === M source/blender/draw/engines/workbench/workbench_state.cc === diff --git a/source/blender/draw/engines/workbench/workbench_state.cc b/source/blender/draw/engines/workbench/workbench_state.cc index 5e0699d0192..8dd20684e71 100644 --- a/source/blender/draw/engines/workbench/workbench_state.cc +++ b/source/blender/draw/engines/workbench/workbench_state.cc @@ -257,8 +257,10 @@ ObjectState::ObjectState(const SceneState &scene_state, Object *ob) CustomData_has_layer(cd_ldata, CD_PROP_COLOR) || CustomData_has_layer(cd_ldata, CD_PROP_BYTE_COLOR)); +bool has_uv = CustomData_has_layer(cd_ldata, CD_PROP_FLOAT2); + if (color_type == V3D_SHADING_TEXTURE_COLOR) { - if (ob->dt < OB_TEXTURE || !CustomData_has_layer(cd_ldata, CD_MLOOPUV)) { + if (ob->dt < OB_TEXTURE || !has_uv) { color_type = V3D_SHADING_MATERIAL_COLOR; } } @@ -275,7 +277,7 @@ ObjectState::ObjectState(const SceneState &scene_state, Object *ob) if (is_vertpaint_mode && has_color) { color_type = V3D_SHADING_VERTEX_COLOR; } - else if (is_texpaint_mode && CustomData_has_layer(cd_ldata, CD_MLOOPUV)) { + else if (is_texpaint_mode && has_uv) { color_type = V3D_SHADING_TEXTURE_COLOR; texture_paint_mode = true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a6b383bd69c] tmp-worbench-rewrite2-optimizations: Revert "Skip bbox allocation by retrieving bounds min/max"
Commit: a6b383bd69caa50fb35a8ffefcd276a26f4fa6e8 Author: Miguel Pozo Date: Tue Jan 17 16:13:25 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBa6b383bd69caa50fb35a8ffefcd276a26f4fa6e8 Revert "Skip bbox allocation by retrieving bounds min/max" This reverts commit c2022d6d3691ddcced42c24488344393249ba631. === M source/blender/blenkernel/intern/object.cc M source/blender/draw/intern/draw_manager_data.cc M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 817bc50cba4..d33f8fe5de7 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -3882,12 +3882,8 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us break; } case OB_MESH: { - Mesh *me = (Mesh *)ob->data; - INIT_MINMAX(r_min, r_max); - if (!BKE_mesh_wrapper_minmax(me, r_min, r_max)) { -r_min[0] = r_min[1] = r_min[2] = -1.0f; -r_max[0] = r_max[1] = r_max[2] = 1.0f; - } + const BoundBox bb = *BKE_mesh_boundbox_get(ob); + BKE_boundbox_minmax(&bb, ob->object_to_world, r_min, r_max); changed = true; break; } diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 5c06233054d..5b4e0792577 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -719,16 +719,12 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) static void drw_call_culling_init(DRWCullingState *cull, Object *ob) { - if (ob != nullptr) { -float3 min, max; -BKE_object_minmax(ob, min, max, false); -BoundBox bbox; -BKE_boundbox_init_from_minmax(&bbox, min, max); - + const BoundBox *bbox; + if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) { float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ -mid_v3_v3v3(cull->bsphere.center, bbox.vec[0], bbox.vec[6]); -mul_v3_m4v3(corner, ob->object_to_world, bbox.vec[0]); +mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); +mul_v3_m4v3(corner, ob->object_to_world, bbox->vec[0]); mul_m4_v3(ob->object_to_world, cull->bsphere.center); cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 69e7c3a0687..a2de084b900 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -151,15 +151,15 @@ inline void ObjectBounds::sync() inline void ObjectBounds::sync(Object &ob) { - float3 min, max; - BKE_object_minmax(&ob, min, max, false); - BoundBox bbox; - BKE_boundbox_init_from_minmax(&bbox, min, max); - - *reinterpret_cast(&bounding_corners[0]) = bbox.vec[0]; - *reinterpret_cast(&bounding_corners[1]) = bbox.vec[4]; - *reinterpret_cast(&bounding_corners[2]) = bbox.vec[3]; - *reinterpret_cast(&bounding_corners[3]) = bbox.vec[1]; + const BoundBox *bbox = BKE_object_boundbox_get(&ob); + if (bbox == nullptr) { +bounding_sphere.w = -1.0f; /* Disable test. */ +return; + } + *reinterpret_cast(&bounding_corners[0]) = bbox->vec[0]; + *reinterpret_cast(&bounding_corners[1]) = bbox->vec[4]; + *reinterpret_cast(&bounding_corners[2]) = bbox->vec[3]; + *reinterpret_cast(&bounding_corners[3]) = bbox->vec[1]; bounding_sphere.w = 0.0f; /* Enable test. */ } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0ea4baa94d8] tmp-worbench-rewrite2-optimizations: Revert "Experimental bbox cache"
Commit: 0ea4baa94d8c0720693310614c05366457a99fbe Author: Miguel Pozo Date: Wed Jan 11 17:28:29 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB0ea4baa94d8c0720693310614c05366457a99fbe Revert "Experimental bbox cache" This reverts commit 49e9d105f0e9d97fe2ff76ae6e4da04d94740a7b. === M source/blender/draw/intern/draw_manager_data.cc M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 01cdf785a05..5b4e0792577 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -719,18 +719,8 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) static void drw_call_culling_init(DRWCullingState *cull, Object *ob) { - /* WORKAROUND (Experimental): - * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */ - static const BoundBox *bbox_cache = nullptr; - static const void *object_data_cache = nullptr; - - if (ob != nullptr && ob->data != object_data_cache) { -// object_data_cache = ob->data; -bbox_cache = BKE_object_boundbox_get(ob); - } - const BoundBox *bbox = bbox_cache; - - if (ob != nullptr && bbox != nullptr) { + const BoundBox *bbox; + if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) { float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index d1a6b2a5468..a2de084b900 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -151,17 +151,7 @@ inline void ObjectBounds::sync() inline void ObjectBounds::sync(Object &ob) { - /* WORKAROUND (Experimental): - * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */ - static const BoundBox *bbox_cache = nullptr; - static const void *object_data_cache = nullptr; - - if (ob.data != object_data_cache) { -// object_data_cache = ob.data; -bbox_cache = BKE_object_boundbox_get(&ob); - } - - const BoundBox *bbox = bbox_cache; + const BoundBox *bbox = BKE_object_boundbox_get(&ob); if (bbox == nullptr) { bounding_sphere.w = -1.0f; /* Disable test. */ return; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f28259ea3d] tmp-worbench-rewrite2-optimizations: Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations
Commit: 6f28259ea3ded1790435a6f8b7bbdf30e65d3d0a Author: Miguel Pozo Date: Tue Jan 17 16:14:57 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB6f28259ea3ded1790435a6f8b7bbdf30e65d3d0a Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [89e114fa702] tmp-worbench-rewrite2-optimizations: Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations
Commit: 89e114fa702543b9c14bec0c0241d8b71add401c Author: Miguel Pozo Date: Wed Jan 11 15:27:31 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB89e114fa702543b9c14bec0c0241d8b71add401c Merge branch 'tmp-workbench-rewrite2' into tmp-worbench-rewrite2-optimizations === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c2022d6d369] tmp-worbench-rewrite2-optimizations: Skip bbox allocation by retrieving bounds min/max
Commit: c2022d6d3691ddcced42c24488344393249ba631 Author: Miguel Pozo Date: Tue Jan 17 16:13:17 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBc2022d6d3691ddcced42c24488344393249ba631 Skip bbox allocation by retrieving bounds min/max === M source/blender/blenkernel/intern/object.cc M source/blender/draw/intern/draw_manager_data.cc M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index d33f8fe5de7..817bc50cba4 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -3882,8 +3882,12 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us break; } case OB_MESH: { - const BoundBox bb = *BKE_mesh_boundbox_get(ob); - BKE_boundbox_minmax(&bb, ob->object_to_world, r_min, r_max); + Mesh *me = (Mesh *)ob->data; + INIT_MINMAX(r_min, r_max); + if (!BKE_mesh_wrapper_minmax(me, r_min, r_max)) { +r_min[0] = r_min[1] = r_min[2] = -1.0f; +r_max[0] = r_max[1] = r_max[2] = 1.0f; + } changed = true; break; } diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 5b4e0792577..5c06233054d 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -719,12 +719,16 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) static void drw_call_culling_init(DRWCullingState *cull, Object *ob) { - const BoundBox *bbox; - if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) { + if (ob != nullptr) { +float3 min, max; +BKE_object_minmax(ob, min, max, false); +BoundBox bbox; +BKE_boundbox_init_from_minmax(&bbox, min, max); + float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ -mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); -mul_v3_m4v3(corner, ob->object_to_world, bbox->vec[0]); +mid_v3_v3v3(cull->bsphere.center, bbox.vec[0], bbox.vec[6]); +mul_v3_m4v3(corner, ob->object_to_world, bbox.vec[0]); mul_m4_v3(ob->object_to_world, cull->bsphere.center); cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index a2de084b900..69e7c3a0687 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -151,15 +151,15 @@ inline void ObjectBounds::sync() inline void ObjectBounds::sync(Object &ob) { - const BoundBox *bbox = BKE_object_boundbox_get(&ob); - if (bbox == nullptr) { -bounding_sphere.w = -1.0f; /* Disable test. */ -return; - } - *reinterpret_cast(&bounding_corners[0]) = bbox->vec[0]; - *reinterpret_cast(&bounding_corners[1]) = bbox->vec[4]; - *reinterpret_cast(&bounding_corners[2]) = bbox->vec[3]; - *reinterpret_cast(&bounding_corners[3]) = bbox->vec[1]; + float3 min, max; + BKE_object_minmax(&ob, min, max, false); + BoundBox bbox; + BKE_boundbox_init_from_minmax(&bbox, min, max); + + *reinterpret_cast(&bounding_corners[0]) = bbox.vec[0]; + *reinterpret_cast(&bounding_corners[1]) = bbox.vec[4]; + *reinterpret_cast(&bounding_corners[2]) = bbox.vec[3]; + *reinterpret_cast(&bounding_corners[3]) = bbox.vec[1]; bounding_sphere.w = 0.0f; /* Enable test. */ } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [49e9d105f0e] tmp-worbench-rewrite2-optimizations: Experimental bbox cache
Commit: 49e9d105f0e9d97fe2ff76ae6e4da04d94740a7b Author: Miguel Pozo Date: Wed Jan 11 17:19:45 2023 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB49e9d105f0e9d97fe2ff76ae6e4da04d94740a7b Experimental bbox cache === M source/blender/draw/intern/draw_manager_data.cc M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 5b4e0792577..01cdf785a05 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -719,8 +719,18 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) static void drw_call_culling_init(DRWCullingState *cull, Object *ob) { - const BoundBox *bbox; - if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) { + /* WORKAROUND (Experimental): + * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */ + static const BoundBox *bbox_cache = nullptr; + static const void *object_data_cache = nullptr; + + if (ob != nullptr && ob->data != object_data_cache) { +// object_data_cache = ob->data; +bbox_cache = BKE_object_boundbox_get(ob); + } + const BoundBox *bbox = bbox_cache; + + if (ob != nullptr && bbox != nullptr) { float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index a2de084b900..d1a6b2a5468 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -151,7 +151,17 @@ inline void ObjectBounds::sync() inline void ObjectBounds::sync(Object &ob) { - const BoundBox *bbox = BKE_object_boundbox_get(&ob); + /* WORKAROUND (Experimental): + * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */ + static const BoundBox *bbox_cache = nullptr; + static const void *object_data_cache = nullptr; + + if (ob.data != object_data_cache) { +// object_data_cache = ob.data; +bbox_cache = BKE_object_boundbox_get(&ob); + } + + const BoundBox *bbox = bbox_cache; if (bbox == nullptr) { bounding_sphere.w = -1.0f; /* Disable test. */ return; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3a06bb5e45e] tmp-workbench-rewrite2: Add Freeze Culling support
Commit: 3a06bb5e45e650ac357bf18f7d7d9d9cc4eca00f Author: Miguel Pozo Date: Tue Jan 17 16:03:02 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB3a06bb5e45e650ac357bf18f7d7d9d9cc4eca00f Add Freeze Culling support === M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/intern/draw_view.cc M source/blender/draw/intern/draw_view.hh === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index afa8281d1e0..36fe0dcb21e 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -21,6 +21,8 @@ using namespace draw; class Instance { public: + View view = {"DefaultView"}; + SceneState scene_state; SceneResources resources; @@ -309,8 +311,10 @@ class Instance { } } - void draw(Manager &manager, View &view, GPUTexture *depth_tx, GPUTexture *color_tx) + void draw(Manager &manager, GPUTexture *depth_tx, GPUTexture *color_tx) { +view.sync(DRW_view_default_get()); + int2 resolution = scene_state.resolution; if (scene_state.render_finished) { @@ -364,9 +368,9 @@ class Instance { resources.depth_in_front_tx.release(); } - void draw_viewport(Manager &manager, View &view, GPUTexture *depth_tx, GPUTexture *color_tx) + void draw_viewport(Manager &manager, GPUTexture *depth_tx, GPUTexture *color_tx) { -this->draw(manager, view, depth_tx, color_tx); +this->draw(manager, depth_tx, color_tx); if (scene_state.sample + 1 < scene_state.samples_len) { DRW_viewport_request_redraw(); @@ -389,6 +393,7 @@ struct WORKBENCH_Data { DRWViewportEmptyList *psl; DRWViewportEmptyList *stl; workbench::Instance *instance; + draw::View *view; char info[GPU_INFO_SIZE]; }; @@ -403,6 +408,7 @@ static void workbench_engine_init(void *vedata) WORKBENCH_Data *ved = reinterpret_cast(vedata); if (ved->instance == nullptr) { ved->instance = new workbench::Instance(); +ved->view = new draw::View("Default View"); } ved->instance->init(); @@ -447,10 +453,8 @@ static void workbench_draw_scene(void *vedata) return; } DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - const DRWView *default_view = DRW_view_default_get(); draw::Manager *manager = DRW_manager_get(); - draw::View view("DefaultView", default_view); - ved->instance->draw_viewport(*manager, view, dtxl->depth, dtxl->color); + ved->instance->draw_viewport(*manager, dtxl->depth, dtxl->color); } static void workbench_instance_free(void *instance) diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index 2c5d4c6c9e6..85f31844311 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -31,6 +31,14 @@ void View::sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id) dirty_ = true; } +void View::sync(const DRWView *view) +{ + float4x4 view_mat, win_mat; + DRW_view_viewmat_get(view, view_mat.ptr(), false); + DRW_view_winmat_get(view, win_mat.ptr(), false); + this->sync(view_mat, win_mat); +} + void View::frustum_boundbox_calc(int view_id) { /* Extract the 8 corners from a Projection Matrix. */ diff --git a/source/blender/draw/intern/draw_view.hh b/source/blender/draw/intern/draw_view.hh index 0408081c99c..5bf2bf1a568 100644 --- a/source/blender/draw/intern/draw_view.hh +++ b/source/blender/draw/intern/draw_view.hh @@ -64,14 +64,14 @@ class View { View(const char *name, const DRWView *view) : visibility_buf_(name), debug_name_(name), view_len_(1) { -float4x4 view_mat, win_mat; -DRW_view_viewmat_get(view, view_mat.ptr(), false); -DRW_view_winmat_get(view, win_mat.ptr(), false); -this->sync(view_mat, win_mat); +this->sync(view); } void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id = 0); + /* For compatibility with old system. Will be removed at some point. */ + void sync(const DRWView *view); + bool is_persp(int view_id = 0) const { BLI_assert(view_id < view_len_); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2c547fc7b16] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: 2c547fc7b16db1ece49199e251422a273a80d74b Author: Miguel Pozo Date: Tue Jan 17 15:13:45 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB2c547fc7b16db1ece49199e251422a273a80d74b Merge branch 'master' into tmp-workbench-rewrite2 === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [15f8b6bbef8] tmp-workbench-rewrite2: Don't override local variable
Commit: 15f8b6bbef8156bb7d988d018a29933ea459e3bb Author: Miguel Pozo Date: Tue Jan 17 16:08:49 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB15f8b6bbef8156bb7d988d018a29933ea459e3bb Don't override local variable === M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 36fe0dcb21e..e917aa1e81e 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -196,9 +196,9 @@ class Instance { /* TODO(fclem): This create a cull-able instance for each sub-object. This is done * for simplicity to reduce complexity. But this increase the overhead per object. * Instead, we should use an indirection buffer to the material buffer. */ -ResourceHandle handle = i == 0 ? handle : manager.resource_handle(ob_ref); +ResourceHandle _handle = i == 0 ? handle : manager.resource_handle(ob_ref); -Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); +Material &mat = resources.material_buf.get_or_resize(_handle.resource_index()); if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { mat = Material(*_mat); @@ -216,7 +216,7 @@ class Instance { get_material_image(ob_ref.object, i + 1, image, iuser, sampler_state); } -draw_mesh(ob_ref, mat, batches[i], handle, image, sampler_state, iuser); +draw_mesh(ob_ref, mat, batches[i], _handle, image, sampler_state, iuser); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f8328ec172a] master: Fix: Draw: Freeze Culling
Commit: f8328ec172af4da655a9bfeaefd23d4e2f864ad5 Author: Miguel Pozo Date: Tue Jan 17 15:10:36 2023 +0100 Branches: master https://developer.blender.org/rBf8328ec172af4da655a9bfeaefd23d4e2f864ad5 Fix: Draw: Freeze Culling Bind the frozen culling data as well. Reviewed By: fclem Differential Revision: https://developer.blender.org/D17010 === M source/blender/draw/intern/draw_view.cc === diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index 82f614f20f2..5028b24c541 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -258,7 +258,8 @@ void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool d GPU_shader_uniform_1i(shader, "visibility_word_per_draw", word_per_draw); GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf")); GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf")); -GPU_uniformbuf_bind((frozen_) ? data_freeze_ : data_, DRW_VIEW_UBO_SLOT); +GPU_uniformbuf_bind(frozen_ ? data_freeze_ : data_, DRW_VIEW_UBO_SLOT); +GPU_uniformbuf_bind(frozen_ ? culling_freeze_ : culling_, DRW_VIEW_CULLING_UBO_SLOT); GPU_compute_dispatch(shader, divide_ceil_u(resource_len, DRW_VISIBILITY_GROUP_SIZE), 1, 1); GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE); } @@ -266,6 +267,7 @@ void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool d if (frozen_) { /* Bind back the non frozen data. */ GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT); +GPU_uniformbuf_bind(culling_, DRW_VIEW_CULLING_UBO_SLOT); } GPU_debug_group_end(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [15b2caab21a] tmp-workbench-rewrite2: Don't create an extra handle for shadows
Commit: 15b2caab21abfb3556d1f57b28d571519c707f89 Author: Miguel Pozo Date: Mon Jan 16 19:23:39 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB15b2caab21abfb3556d1f57b28d571519c707f89 Don't create an extra handle for shadows === M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index b63f63f7109..afa8281d1e0 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -165,6 +165,7 @@ class Instance { void mesh_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state) { +ResourceHandle handle = manager.resource_handle(ob_ref); bool has_transparent_material = false; if (object_state.sculpt_pbvh) { @@ -193,8 +194,8 @@ class Instance { /* TODO(fclem): This create a cull-able instance for each sub-object. This is done * for simplicity to reduce complexity. But this increase the overhead per object. * Instead, we should use an indirection buffer to the material buffer. */ +ResourceHandle handle = i == 0 ? handle : manager.resource_handle(ob_ref); -ResourceHandle handle = manager.resource_handle(ob_ref); Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); if (::Material *_mat = BKE_object_material_get_eval(ob_ref.object, i + 1)) { @@ -235,7 +236,6 @@ class Instance { } if (batch) { - ResourceHandle handle = manager.resource_handle(ob_ref); Material &mat = resources.material_buf.get_or_resize(handle.resource_index()); if (object_state.color_type == V3D_SHADING_OBJECT_COLOR) { @@ -267,7 +267,7 @@ class Instance { } if (object_state.draw_shadow) { - shadow_ps.object_sync(manager, ob_ref, scene_state, has_transparent_material); + shadow_ps.object_sync(manager, scene_state, ob_ref, handle, has_transparent_material); } } diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index ee63f2c2010..086553ca5c1 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -300,8 +300,9 @@ class ShadowPass { void update(); void sync(); void object_sync(Manager &manager, - ObjectRef &ob_ref, SceneState &scene_state, + ObjectRef &ob_ref, + ResourceHandle handle, const bool has_transp_mat); void draw(Manager &manager, View &view, diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 10a7ca19277..22c7b663220 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -391,8 +391,9 @@ void ShadowPass::sync() } void ShadowPass::object_sync(Manager &manager, - ObjectRef &ob_ref, SceneState &scene_state, + ObjectRef &ob_ref, + ResourceHandle handle, const bool has_transp_mat) { if (!enabled_) { @@ -423,8 +424,6 @@ void ShadowPass::object_sync(Manager &manager, /* Unless we force the FAIL Method we add draw commands to both methods, * then the visibility compute shader selects the one needed */ - ResourceHandle handle = manager.resource_handle(ob_ref); - if (!force_fail_pass) { PassMain::Sub &ps = *get_pass_ptr(PASS, is_manifold); ps.draw(geom_shadow, handle); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b82f7814c4f] master: Fix: Draw: Incorrect culling in the new Draw Manager
Commit: b82f7814c4f386c05215d7dc85d526fa10e2b4e1 Author: Miguel Pozo Date: Mon Jan 16 18:41:06 2023 +0100 Branches: master https://developer.blender.org/rBb82f7814c4f386c05215d7dc85d526fa10e2b4e1 Fix: Draw: Incorrect culling in the new Draw Manager ViewCullingData::corners (vec4) was casted to a BoundingBox (vec3), so the frustum corners were uploaded in the wrong format to the GPU. Now the ViewCullingData::corners are used directly without casting, since the BoundBox API is not really needed. Reviewed By: fclem Differential Revision: https://developer.blender.org/D17008 === M source/blender/draw/intern/draw_view.cc M source/blender/draw/intern/draw_view.hh === diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index 2e303aa9295..82f614f20f2 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -24,16 +24,14 @@ void View::sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id) is_inverted_ = (is_negative_m4(view_mat.ptr()) == is_negative_m4(win_mat.ptr())); - BoundBox &bound_box = *reinterpret_cast(&culling_[view_id].corners); - BoundSphere &bound_sphere = *reinterpret_cast(&culling_[view_id].bound_sphere); - frustum_boundbox_calc(bound_box, view_id); + frustum_boundbox_calc(view_id); frustum_culling_planes_calc(view_id); - frustum_culling_sphere_calc(bound_box, bound_sphere, view_id); + frustum_culling_sphere_calc(view_id); dirty_ = true; } -void View::frustum_boundbox_calc(BoundBox &bbox, int view_id) +void View::frustum_boundbox_calc(int view_id) { /* Extract the 8 corners from a Projection Matrix. */ #if 0 /* Equivalent to this but it has accuracy problems. */ @@ -43,16 +41,18 @@ void View::frustum_boundbox_calc(BoundBox &bbox, int view_id) } #endif + MutableSpan corners = {culling_[view_id].corners, ARRAY_SIZE(culling_[view_id].corners)}; + float left, right, bottom, top, near, far; bool is_persp = data_[view_id].winmat[3][3] == 0.0f; projmat_dimensions(data_[view_id].winmat.ptr(), &left, &right, &bottom, &top, &near, &far); - bbox.vec[0][2] = bbox.vec[3][2] = bbox.vec[7][2] = bbox.vec[4][2] = -near; - bbox.vec[0][0] = bbox.vec[3][0] = left; - bbox.vec[4][0] = bbox.vec[7][0] = right; - bbox.vec[0][1] = bbox.vec[4][1] = bottom; - bbox.vec[7][1] = bbox.vec[3][1] = top; + corners[0][2] = corners[3][2] = corners[7][2] = corners[4][2] = -near; + corners[0][0] = corners[3][0] = left; + corners[4][0] = corners[7][0] = right; + corners[0][1] = corners[4][1] = bottom; + corners[7][1] = corners[3][1] = top; /* Get the coordinates of the far plane. */ if (is_persp) { @@ -63,15 +63,16 @@ void View::frustum_boundbox_calc(BoundBox &bbox, int view_id) top *= sca_far; } - bbox.vec[1][2] = bbox.vec[2][2] = bbox.vec[6][2] = bbox.vec[5][2] = -far; - bbox.vec[1][0] = bbox.vec[2][0] = left; - bbox.vec[6][0] = bbox.vec[5][0] = right; - bbox.vec[1][1] = bbox.vec[5][1] = bottom; - bbox.vec[2][1] = bbox.vec[6][1] = top; + corners[1][2] = corners[2][2] = corners[6][2] = corners[5][2] = -far; + corners[1][0] = corners[2][0] = left; + corners[6][0] = corners[5][0] = right; + corners[1][1] = corners[5][1] = bottom; + corners[2][1] = corners[6][1] = top; /* Transform into world space. */ - for (int i = 0; i < 8; i++) { -mul_m4_v3(data_[view_id].viewinv.ptr(), bbox.vec[i]); + for (float4 &corner : corners) { +mul_m4_v3(data_[view_id].viewinv.ptr(), corner); +corner.w = 1.0; } } @@ -87,19 +88,22 @@ void View::frustum_culling_planes_calc(int view_id) culling_[view_id].planes[2]); /* Normalize. */ - for (int p = 0; p < 6; p++) { -culling_[view_id].planes[p].w /= normalize_v3(culling_[view_id].planes[p]); + for (float4 &plane : culling_[view_id].planes) { +plane.w /= normalize_v3(plane); } } -void View::frustum_culling_sphere_calc(const BoundBox &bbox, BoundSphere &bsphere, int view_id) +void View::frustum_culling_sphere_calc(int view_id) { + BoundSphere &bsphere = *reinterpret_cast(&culling_[view_id].bound_sphere); + Span corners = {culling_[view_id].corners, ARRAY_SIZE(culling_[view_id].corners)}; + /* Extract Bounding Sphere */ if (data_[view_id].winmat[3][3] != 0.0f) { /* Orthographic */ /* The most extreme points on the near and far plane. (normalized device coords). */ -const float *nearpoint = bbox.vec[0]; -const float *farpoint = bbox.vec[6]; +const float *nearpoint = corners[0]; +const float *farpoint = corners[6]; /* just use median point */ mid_v3_v3v3(bsphere.center, farpoint, nearpoint); @@ -113,12 +117,12 @@ void View::frustum_culling_sphere_calc(const BoundBox
[Bf-blender-cvs] [f32939af53a] blender-v3.3-release: Fix T101402: EEVEE: Wrong Volume transforms
Commit: f32939af53a110365a7563e9a43cba6423f8e94a Author: Miguel Pozo Date: Fri Nov 25 12:43:30 2022 +0100 Branches: blender-v3.3-release https://developer.blender.org/rBf32939af53a110365a7563e9a43cba6423f8e94a Fix T101402: EEVEE: Wrong Volume transforms Ensure VolumeUniformPool uses is always incremented when retrieving a buffer in alloc(). Otherwise the same buffer will be retrieved for more than one object when incrementing the pool size. Reviewed By: fclem Maniphest Tasks: T101402 Differential Revision: https://developer.blender.org/D16607 === M source/blender/draw/intern/draw_volume.cc === diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index 8f4383a98d8..38a4a6f214a 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -56,7 +56,6 @@ struct VolumeUniformBufPool { if (used >= ubos.size()) { VolumeInfosBuf *buf = new VolumeInfosBuf(); ubos.append(buf); - return buf; } return ubos[used++]; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b061ace7485] tmp-workbench-rewrite2: Add explicit initializations to all classes/structs
Commit: b061ace74851116b2ecc5d8b21a03a9430247c92 Author: Miguel Pozo Date: Tue Jan 10 17:36:32 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBb061ace74851116b2ecc5d8b21a03a9430247c92 Add explicit initializations to all classes/structs === M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index e1549884027..ee63f2c2010 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -39,9 +39,9 @@ class ShaderCache { }; struct Material { - float3 base_color; + float3 base_color = float3(0); /* Packed data into a int. Decoded in the shader. */ - uint packed_data; + uint packed_data = 0; Material(); Material(float3 color); @@ -60,38 +60,38 @@ void get_material_image(Object *ob, eGPUSamplerState &sampler_state); struct SceneState { - Scene *scene; + Scene *scene = nullptr; - Object *camera_object; - Camera *camera; - float4x4 view_projection_matrix; - int2 resolution; + Object *camera_object = nullptr; + Camera *camera = nullptr; + float4x4 view_projection_matrix = float4x4::identity(); + int2 resolution = int2(0); - eContextObjectMode object_mode; + eContextObjectMode object_mode = CTX_MODE_OBJECT; - View3DShading shading; + View3DShading shading = {}; eLightingType lighting_type = eLightingType::STUDIO; - bool xray_mode; + bool xray_mode = false; - DRWState cull_state; + DRWState cull_state = DRW_STATE_NO_DRAW; Vector clip_planes = {}; - float4 background_color; + float4 background_color = float4(0); - bool draw_cavity; - bool draw_curvature; - bool draw_shadows; - bool draw_outline; - bool draw_dof; - bool draw_aa; + bool draw_cavity = false; + bool draw_curvature = false; + bool draw_shadows = false; + bool draw_outline = false; + bool draw_dof = false; + bool draw_aa = false; - bool draw_object_id; - bool draw_transparent_depth; + bool draw_object_id = false; + bool draw_transparent_depth = false; - int sample; - int samples_len; - bool reset_taa_next_sample; - bool render_finished; + int sample = 0; + int samples_len = 0; + bool reset_taa_next_sample = false; + bool render_finished = false; /* Used when material_type == eMaterialType::SINGLE */ Material material_override = Material(float3(1.0f)); @@ -102,13 +102,13 @@ struct SceneState { }; struct ObjectState { - eV3DShadingColorType color_type; - bool sculpt_pbvh; - bool texture_paint_mode; - ::Image *image_paint_override; - eGPUSamplerState override_sampler_state; - bool draw_shadow; - bool use_per_material_batches; + eV3DShadingColorType color_type = V3D_SHADING_SINGLE_COLOR; + bool sculpt_pbvh = false; + bool texture_paint_mode = false; + ::Image *image_paint_override = nullptr; + eGPUSamplerState override_sampler_state = GPU_SAMPLER_DEFAULT; + bool draw_shadow = false; + bool use_per_material_batches = false; ObjectState(const SceneState &scene_state, Object *ob); }; @@ -119,12 +119,12 @@ class CavityEffect { * workbench_composite_info.hh (cavity_samples) */ static const int max_samples_ = 512; - UniformArrayBuffer samples_buf; + UniformArrayBuffer samples_buf = {}; - int sample_; - int sample_count_; - bool curvature_enabled_; - bool cavity_enabled_; + int sample_ = 0; + int sample_count_ = 0; + bool curvature_enabled_ = false; + bool cavity_enabled_ = false; public: void init(const SceneState &scene_state, struct SceneResources &resources); @@ -137,9 +137,9 @@ class CavityEffect { struct SceneResources { static const int jitter_tx_size = 64; - ShaderCache shader_cache; + ShaderCache shader_cache = {}; - StringRefNull current_matcap; + StringRefNull current_matcap = {}; Texture matcap_tx = "matcap_tx"; TextureFromPool color_tx = "wb_color_tx"; @@ -148,12 +148,12 @@ struct SceneResources { TextureFromPool depth_in_front_tx = "wb_depth_in_front_tx"; StorageVectorBuffer material_buf = {"material_buf"}; - UniformBuffer world_buf; + UniformBuffer world_buf = {}; UniformArrayBuffer clip_planes_buf; Texture jitter_tx = "wb_jitter_tx"; - CavityEffect cavity; + CavityEffect cavity = {}; void init(const SceneState &scene_state); void load_jitter_tx(int total_samples); @@ -163,11 +163,11 @@ class MeshPass : public PassMain { private: using TextureSubPassKey = std::pair; - Map texture_subpass_map_; + Map texture_subpass_map_ = {}; - PassMain::Sub *passes_[geometry_type_len][shader_type_len]; + PassMain::Sub *passes_[geometry_type_len][shader_type_len] = {{nullptr}};
[Bf-blender-cvs] [f1a90deb13f] tmp-workbench-rewrite2: Remove UNUSED macros (Needed after D16828)
Commit: f1a90deb13fe57a8617f3fa034fa87abfb31e8d8 Author: Miguel Pozo Date: Tue Jan 10 17:08:27 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBf1a90deb13fe57a8617f3fa034fa87abfb31e8d8 Remove UNUSED macros (Needed after D16828) === M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index e68a64bf69d..582adeb4ed9 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -237,7 +237,7 @@ void DofPass::draw(Manager &manager, View &view, SceneResources &resources, int2 }; CallbackData callback_data = {manager, view, down2_ps_}; - auto downsample_level = [](void *callback_data, int UNUSED(level)) { + auto downsample_level = [](void *callback_data, int /*level*/) { CallbackData *cd = static_cast(callback_data); cd->manager.submit(cd->pass, cd->view); }; diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index ce0e0f9347d..b63f63f7109 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -644,8 +644,8 @@ static void workbench_render_to_image(void *vedata, workbench_cache_init(vedata); auto workbench_render_cache = [](void *vedata, struct Object *ob, - struct RenderEngine *UNUSED(engine), - struct Depsgraph *UNUSED(depsgraph)) { + struct RenderEngine * /*engine*/, + struct Depsgraph * /*depsgraph*/) { workbench_cache_populate(vedata, ob); }; DRW_render_object_iter(vedata, engine, depsgraph, workbench_render_cache); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [47a629b972f] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: 47a629b972f78e3008bed6680c170922fdbef12b Author: Miguel Pozo Date: Tue Jan 10 16:02:00 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB47a629b972f78e3008bed6680c170922fdbef12b Merge branch 'master' into tmp-workbench-rewrite2 === === diff --cc source/blender/gpu/intern/gpu_texture_private.hh index 20543391691,344ec911adc..1b3c04a78f9 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@@ -41,10 -41,10 +41,10 @@@ typedef enum eGPUTextureType GPU_TEXTURE_CUBE_ARRAY = (GPU_TEXTURE_CUBE | GPU_TEXTURE_ARRAY), } eGPUTextureType; -ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_CUBE_ARRAY) +ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_BUFFER) /* Format types for samplers within the shader. - * This covers the sampler format type permutations within GLSL/MSL.*/ + * This covers the sampler format type permutations within GLSL/MSL. */ typedef enum eGPUSamplerFormat { GPU_SAMPLER_TYPE_FLOAT = 0, GPU_SAMPLER_TYPE_INT = 1, diff --cc source/blender/makesdna/DNA_userdef_types.h index 6654961f740,4c9568d9228..09f03706c00 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@@ -652,9 -652,6 +652,8 @@@ typedef struct UserDef_Experimental char use_override_templates; char enable_eevee_next; char use_sculpt_texture_paint; - char use_realtime_compositor; + char enable_workbench_next; - char _pad[6]; ++ char _pad[7]; /** `makesdna` does not allow empty structs. */ } UserDef_Experimental; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0b013d8873a] tmp-workbench-rewrite2: Code standards
Commit: 0b013d8873a369daec86dcdb25a5f2c2a7575c73 Author: Miguel Pozo Date: Tue Jan 10 13:46:50 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB0b013d8873a369daec86dcdb25a5f2c2a7575c73 Code standards === M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index dd1d6b17daa..e1549884027 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -16,12 +16,6 @@ namespace blender::workbench { using namespace draw; class ShaderCache { - private: - /* TODO(fclem): We might want to change to a Map since most shader will never be compiled. */ - GPUShader *prepass_shader_cache_[pipeline_type_len][geometry_type_len][shader_type_len] - [lighting_type_len][2] = {nullptr}; - GPUShader *resolve_shader_cache_[pipeline_type_len][lighting_type_len][2][2] = nullptr; - public: ~ShaderCache(); @@ -35,6 +29,13 @@ class ShaderCache { eLightingType lighting_type, bool cavity = false, bool curvature = false); + + private: + /* TODO(fclem): We might want to change to a Map since most shader will never be compiled. */ + GPUShader *prepass_shader_cache_[pipeline_type_len][geometry_type_len][shader_type_len] + [lighting_type_len][2 /*clip*/] = {nullptr}; + GPUShader *resolve_shader_cache_[pipeline_type_len][lighting_type_len][2 /*cavity*/] + [2 /*curvature*/] = nullptr; }; struct Material { @@ -47,9 +48,9 @@ struct Material { Material(::Object &ob, bool random = false); Material(::Material &mat); - bool is_transparent(); - static uint32_t pack_data(float metallic, float roughness, float alpha); + + bool is_transparent(); }; void get_material_image(Object *ob, @@ -114,24 +115,28 @@ struct ObjectState { class CavityEffect { private: - int sample_; - int sample_count_; - bool curvature_enabled_; - bool cavity_enabled_; - /* This value must be kept in sync with the one declared at * workbench_composite_info.hh (cavity_samples) */ static const int max_samples_ = 512; + UniformArrayBuffer samples_buf; - void load_samples_buf(int ssao_samples); + int sample_; + int sample_count_; + bool curvature_enabled_; + bool cavity_enabled_; public: void init(const SceneState &scene_state, struct SceneResources &resources); void setup_resolve_pass(PassSimple &pass, struct SceneResources &resources); + + private: + void load_samples_buf(int ssao_samples); }; struct SceneResources { + static const int jitter_tx_size = 64; + ShaderCache shader_cache; StringRefNull current_matcap; @@ -146,28 +151,28 @@ struct SceneResources { UniformBuffer world_buf; UniformArrayBuffer clip_planes_buf; - static const int jitter_tx_size = 64; Texture jitter_tx = "wb_jitter_tx"; - void load_jitter_tx(int total_samples); CavityEffect cavity; void init(const SceneState &scene_state); + void load_jitter_tx(int total_samples); }; class MeshPass : public PassMain { private: - PassMain::Sub *passes_[geometry_type_len][shader_type_len]; - using TextureSubPassKey = std::pair; + Map texture_subpass_map_; + PassMain::Sub *passes_[geometry_type_len][shader_type_len]; + bool is_empty_; public: MeshPass(const char *name); - /* Move to draw::Pass */ + /* TODO: Move to draw::Pass */ bool is_empty() const; void init_pass(SceneResources &resources, DRWState state, int clip_planes); @@ -244,10 +249,8 @@ class TransparentDepthPass { }; class ShadowPass { - - bool enabled_; - - enum PassType { Pass, Fail, ForcedFail, Length }; + private: + enum PassType { PASS = 0, FAIL, FORCED_FAIL, MAX }; class ShadowView : public View { bool force_fail_method_; @@ -270,6 +273,8 @@ class ShadowPass { virtual VisibilityBuf &get_visibility_buffer(); } view_ = {}; + bool enabled_; + UniformBuffer pass_data_; /* Draws are added to both passes and the visibily compute shader selects one of them */ @@ -279,9 +284,11 @@ class ShadowPass { /* In some cases, we know beforehand that we need to use the fail technique */ PassMain forced_fail_ps_ = {"Shadow.ForcedFail"}; - PassMain::Sub *passes_[PassType::Length][2][2] = {{{nullptr}}}; + /* [PassType][Is Manifold][Is Cap] */ + PassMain::Sub *passes_[PassType::MAX][2][2] = {{{nullptr}}}; PassMain::Sub *&get_pass_ptr(PassType type, bool manifold, bool cap = false); + /* [Is Pass Techn
[Bf-blender-cvs] [128d4104bfe] tmp-workbench-rewrite2: Remove blender:: namespace
Commit: 128d4104bfe459dcd279cce975c3c934775c4eaa Author: Miguel Pozo Date: Mon Jan 9 18:13:39 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB128d4104bfe459dcd279cce975c3c934775c4eaa Remove blender:: namespace === M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 94d15e7ff0f..91040390876 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -8,9 +8,9 @@ namespace blender::workbench { class TaaSamples { - void init_samples(blender::Array &samples, const int size) + void init_samples(Array &samples, const int size) { -samples = blender::Array(size); +samples = Array(size); BLI_jitter_init((float(*)[2])samples.begin(), size); /* Find closest element to center */ @@ -58,11 +58,11 @@ class TaaSamples { } public: - blender::Array x5; - blender::Array x8; - blender::Array x11; - blender::Array x16; - blender::Array x32; + Array x5; + Array x8; + Array x11; + Array x16; + Array x32; TaaSamples() { diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 85f12d9e71e..10a7ca19277 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -99,8 +99,8 @@ void ShadowPass::ShadowView::setup(View &view, float3 light_direction, bool forc float4 frustum_planes[6]; DRW_culling_frustum_planes_get(nullptr, (float(*)[4])frustum_planes); - blender::Vector faces_result = {}; - blender::Vector corners_result = {}; + Vector faces_result = {}; + Vector corners_result = {}; /* "Unlit" frustum faces are left "as-is" */ @@ -214,15 +214,15 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, words_len = ceil_to_multiple_u(max_ii(1, words_len), 4); uint32_t data = 0xu; - if (current_pass_type_ == ShadowPass::Pass) { + if (current_pass_type_ == ShadowPass::PASS) { /* TODO(fclem): Resize to nearest pow2 to reduce fragmentation. */ pass_visibility_buf_.resize(words_len); GPU_storagebuf_clear(pass_visibility_buf_, GPU_R32UI, GPU_DATA_UINT, &data); fail_visibility_buf_.resize(words_len); GPU_storagebuf_clear(fail_visibility_buf_, GPU_R32UI, GPU_DATA_UINT, &data); } - else if (current_pass_type_ == ShadowPass::Fail) { -/* Already computed in the ShadowPass::Pass */ + else if (current_pass_type_ == ShadowPass::FAIL) { +/* Already computed in the ShadowPass::PASS */ GPU_debug_group_end(); return; } @@ -239,8 +239,8 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, static GPUShader *static_pass_type_shader = GPU_shader_create_from_info_name( "workbench_next_shadow_visibility_compute_static_pass_type"); -GPUShader *shader = current_pass_type_ == ShadowPass::ForcedFail ? static_pass_type_shader : - dynamic_pass_type_shader; +GPUShader *shader = current_pass_type_ == ShadowPass::FORCED_FAIL ? static_pass_type_shader : + dynamic_pass_type_shader; GPU_shader_bind(shader); GPU_shader_uniform_1i(shader, "resource_len", resource_len); GPU_shader_uniform_1i(shader, "view_len", view_len_); @@ -250,7 +250,7 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, GPU_uniformbuf_bind(extruded_frustum_, GPU_shader_get_uniform_block(shader, "extruded_frustum")); GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf")); -if (current_pass_type_ == ShadowPass::ForcedFail) { +if (current_pass_type_ == ShadowPass::FORCED_FAIL) { GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf")); } else { @@ -270,11 +270,11 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, VisibilityBuf &ShadowPass::ShadowView::get_visibility_buffer() { switch (current_pass_type_) { -case ShadowPass::Pass: +case ShadowPass::PASS: return pass_visibility_buf_; -case ShadowPass::Fail: +case ShadowPass::FAIL: return fail_visibility_buf_; -case ShadowPass::ForcedFail: +case ShadowPass::FORCED_FAIL: return visibility_buf_;
[Bf-blender-cvs] [ee51f6b3e9f] tmp-workbench-rewrite2: Use functional type casting
Commit: ee51f6b3e9f2eb0caaecabb7cd4939c8163471cc Author: Miguel Pozo Date: Mon Jan 9 18:25:16 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBee51f6b3e9f2eb0caaecabb7cd4939c8163471cc Use functional type casting === M source/blender/draw/engines/workbench/workbench_effect_cavity.cc M source/blender/draw/engines/workbench/workbench_effect_dof.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc index 31a419f733e..30363b19681 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc @@ -64,7 +64,7 @@ void CavityEffect::load_samples_buf(int ssao_samples) double dphi; BLI_hammersley_1d(i, &dphi); -float phi = (float)dphi * 2.0f * M_PI + it_add; +float phi = float(dphi) * 2.0f * M_PI + it_add; samples_buf[i].x = math::cos(phi); samples_buf[i].y = math::sin(phi); /* This deliberately distribute more samples diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 0f80713fba9..e68a64bf69d 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -108,7 +108,7 @@ void DofPass::init(const SceneState &scene_state) resolve_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_resolve"); } - offset_ = scene_state.sample / (float)scene_state.samples_len; + offset_ = scene_state.sample / float(scene_state.samples_len); int2 half_res = scene_state.resolution / 2; half_res = {max_ii(half_res.x, 1), max_ii(half_res.y, 1)}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8cbbfa8c293] tmp-workbench-rewrite2: Fix MSL compilation
Commit: 8cbbfa8c293ce077d916e3c53da31618a490e960 Author: Miguel Pozo Date: Mon Jan 9 18:25:29 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB8cbbfa8c293ce077d916e3c53da31618a490e960 Fix MSL compilation === M source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl === diff --git a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl index a66af6008d9..7a5b66d0879 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl @@ -72,10 +72,10 @@ void main() color = mix(color, world_data.object_outline_color, outline_opacity); #endif - if (color != world_data.background_color) { -fragColor = color; + if (all(equal(color, world_data.background_color))) { +discard; } else { -discard; +fragColor = color; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f8eb85d9108] tmp-workbench-rewrite2: Split render output writing into their own functions
Commit: f8eb85d91085f2ac2bf115916487843ca3d18f78 Author: Miguel Pozo Date: Mon Jan 9 17:32:29 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBf8eb85d91085f2ac2bf115916487843ca3d18f78 Split render output writing into their own functions === M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index c4115d996b4..ce0e0f9347d 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -521,6 +521,75 @@ static bool workbench_render_framebuffers_init(void) # define GPU_FINISH_DELIMITER() #endif +static void write_render_color_output(struct RenderLayer *layer, + const char *viewname, + GPUFrameBuffer *fb, + const struct rcti *rect) +{ + RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_COMBINED, viewname); + if (rp) { +GPU_framebuffer_bind(fb); +GPU_framebuffer_read_color(fb, + rect->xmin, + rect->ymin, + BLI_rcti_size_x(rect), + BLI_rcti_size_y(rect), + 4, + 0, + GPU_DATA_FLOAT, + rp->rect); + } +} + +static void write_render_z_output(struct RenderLayer *layer, + const char *viewname, + GPUFrameBuffer *fb, + const struct rcti *rect, + float4x4 winmat) +{ + RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_Z, viewname); + if (rp) { +GPU_framebuffer_bind(fb); +GPU_framebuffer_read_depth(fb, + rect->xmin, + rect->ymin, + BLI_rcti_size_x(rect), + BLI_rcti_size_y(rect), + GPU_DATA_FLOAT, + rp->rect); + +int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect); + +/* Convert ogl depth [0..1] to view Z [near..far] */ +if (DRW_view_is_persp_get(nullptr)) { + for (float &z : MutableSpan(rp->rect, pix_num)) { +if (z == 1.0f) { + z = 1e10f; /* Background */ +} +else { + z = z * 2.0f - 1.0f; + z = winmat[3][2] / (z + winmat[2][2]); +} + } +} +else { + /* Keep in mind, near and far distance are negatives. */ + float near = DRW_view_near_distance_get(nullptr); + float far = DRW_view_far_distance_get(nullptr); + float range = fabsf(far - near); + + for (float &z : MutableSpan(rp->rect, pix_num)) { +if (z == 1.0f) { + z = 1e10f; /* Background */ +} +else { + z = z * range - near; +} + } +} + } +} + static void workbench_render_to_image(void *vedata, struct RenderEngine *engine, struct RenderLayer *layer, @@ -597,66 +666,8 @@ static void workbench_render_to_image(void *vedata, } while (ved->instance->scene_state.sample + 1 < ved->instance->scene_state.samples_len); const char *viewname = RE_GetActiveRenderView(engine->re); - /* Write render output. */ - { -RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_COMBINED, viewname); -if (rp) { - GPU_framebuffer_bind(dfbl->default_fb); - GPU_framebuffer_read_color(dfbl->default_fb, - rect->xmin, - rect->ymin, - BLI_rcti_size_x(rect), - BLI_rcti_size_y(rect), - 4, - 0, - GPU_DATA_FLOAT, - rp->rect); -} - } - /* Write render Z output */ - { -RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_Z, viewname); -if (rp) { - GPU_framebuffer_bind(dfbl->default_fb); - GPU_framebuffer_read_depth(dfbl->default_fb, - rect->xmin, - rect->ymin, - BLI_rcti_size_x(rect), - BLI_rcti_size_y(rect), - GPU_DATA_FLOAT, - rp->rect); - - int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_
[Bf-blender-cvs] [b87ae86e3cc] tmp-workbench-rewrite2: Class separators
Commit: b87ae86e3cc588206dd00e04c18504b850b0e3cd Author: Miguel Pozo Date: Mon Jan 9 17:39:16 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBb87ae86e3cc588206dd00e04c18504b850b0e3cd Class separators === M source/blender/draw/engines/workbench/workbench_mesh_passes.cc === diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index 84c7c58f12f..d47a806b694 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -4,6 +4,10 @@ namespace blender::workbench { +/* */ +/** \name MeshPass + * \{ */ + MeshPass::MeshPass(const char *name) : PassMain(name){}; /* Move to draw::Pass */ @@ -99,6 +103,12 @@ void MeshPass::draw(ObjectRef &ref, handle); } +/** \} */ + +/* */ +/** \name OpaquePass + * \{ */ + void OpaquePass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | @@ -226,6 +236,12 @@ bool OpaquePass::is_empty() const return gbuffer_ps_.is_empty() && gbuffer_in_front_ps_.is_empty(); } +/** \} */ + +/* */ +/** \name TransparentPass + * \{ */ + void TransparentPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_OIT | @@ -297,6 +313,12 @@ bool TransparentPass::is_empty() const return accumulation_ps_.is_empty() && accumulation_in_front_ps_.is_empty(); } +/** \} */ + +/* */ +/** \name TransparentDepthPass + * \{ */ + void TransparentDepthPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | @@ -370,4 +392,6 @@ bool TransparentDepthPass::is_empty() const return main_ps_.is_empty() && in_front_ps_.is_empty(); } +/** \} */ + } // namespace blender::workbench ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8f165c390d9] tmp-workbench-rewrite2: Fix Clang compilation
Commit: 8f165c390d968068f9a257955e89ebd7b7c8d535 Author: Miguel Pozo Date: Mon Jan 9 17:43:29 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB8f165c390d968068f9a257955e89ebd7b7c8d535 Fix Clang compilation === M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index a413dc17ec5..dd1d6b17daa 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -9,7 +9,7 @@ #include "workbench_enums.hh" #include "workbench_shader_shared.h" -extern DrawEngineType draw_engine_workbench_next; +extern "C" DrawEngineType draw_engine_workbench_next; namespace blender::workbench { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5627c8acea5] tmp-workbench-rewrite2: Replace sinf/cosf with math::sin/cos
Commit: 5627c8acea58e316164e39ddc883ffe8236e7599 Author: Miguel Pozo Date: Mon Jan 9 17:14:37 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB5627c8acea58e316164e39ddc883ffe8236e7599 Replace sinf/cosf with math::sin/cos === M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc M source/blender/draw/engines/workbench/workbench_effect_cavity.cc M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_resources.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 313aad6244e..94d15e7ff0f 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -82,7 +82,8 @@ static float filter_blackman_harris(float x, const float width) return 0.0f; } x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f); - return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f * cosf(3.0f * x); + return 0.35875f - 0.48829f * math::cos(x) + 0.14128f * math::cos(2.0f * x) - + 0.01168f * math::cos(3.0f * x); } /* Compute weights for the 3x3 neighborhood using a 1.5px filter. */ diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc index a87c0fa2ba1..31a419f733e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc @@ -65,8 +65,8 @@ void CavityEffect::load_samples_buf(int ssao_samples) BLI_hammersley_1d(i, &dphi); float phi = (float)dphi * 2.0f * M_PI + it_add; -samples_buf[i].x = cosf(phi); -samples_buf[i].y = sinf(phi); +samples_buf[i].x = math::cos(phi); +samples_buf[i].y = math::sin(phi); /* This deliberately distribute more samples * at the center of the disk (and thus the shadow). */ samples_buf[i].z = r; diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 11d5cd33f4c..0f80713fba9 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -75,13 +75,13 @@ void DofPass::setup_samples() /* Bokeh shape parameterization. */ if (blades_ > 1.0f) { float denom = T - (2.0 * M_PI / blades_) * floorf((blades_ * T + M_PI) / (2.0 * M_PI)); - r *= cosf(M_PI / blades_) / cosf(denom); + r *= math::cos(M_PI / blades_) / math::cos(denom); } T += rotation_; -sample->x = r * cosf(T) * ratio_; -sample->y = r * sinf(T); +sample->x = r * math::cos(T) * ratio_; +sample->y = r * math::sin(T); sample->w = 0; sample++; } diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc b/source/blender/draw/engines/workbench/workbench_resources.cc index 556df6a5366..84d624d22d5 100644 --- a/source/blender/draw/engines/workbench/workbench_resources.cc +++ b/source/blender/draw/engines/workbench/workbench_resources.cc @@ -78,8 +78,8 @@ void SceneResources::load_jitter_tx(int total_samples) for (int i = 0; i < texel_count; i++) { float phi = blue_noise[i][0] * 2.0f * M_PI; /* This rotate the sample per pixels */ -jitter[i].x = cosf(phi); -jitter[i].y = sinf(phi); +jitter[i].x = math::cos(phi); +jitter[i].y = math::sin(phi); /* This offset the sample along its direction axis (reduce banding) */ float bn = blue_noise[i][1] - 0.5f; bn = clamp_f(bn, -0.499f, 0.499f); /* fix fireflies */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b17578a943d] tmp-workbench-rewrite2: Use std::swap
Commit: b17578a943da17a510fedc023b2c9c58b2d88da4 Author: Miguel Pozo Date: Mon Jan 9 18:17:32 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBb17578a943da17a510fedc023b2c9c58b2d88da4 Use std::swap === M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 91040390876..39b46c7ac1e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -39,7 +39,7 @@ class TaaSamples { /* Swap center sample to the start of the array */ if (closest_index != 0) { - swap_v2_v2(samples[0], samples[closest_index]); + std::swap(samples[0], samples[closest_index]); } /* Sort list based on farthest distance with previous. */ @@ -53,7 +53,7 @@ class TaaSamples { index = j; } } - swap_v2_v2(samples[i + 1], samples[index]); + std::swap(samples[i + 1], samples[index]); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ed69fbadf73] tmp-workbench-rewrite2: Move get_dummy_gpu_materials to Instance
Commit: ed69fbadf73dd091143b5c2bc42f25c448c61e2e Author: Miguel Pozo Date: Mon Jan 9 17:25:11 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBed69fbadf73dd091143b5c2bc42f25c448c61e2e Move get_dummy_gpu_materials to Instance === M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index e10bcf872ae..c4115d996b4 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -19,8 +19,6 @@ namespace blender::workbench { using namespace draw; -GPUMaterial **get_dummy_gpu_materials(int material_count); - class Instance { public: SceneState scene_state; @@ -36,6 +34,17 @@ class Instance { DofPass dof_ps; AntiAliasingPass anti_aliasing_ps; + /* An array of nullptr GPUMaterial pointers so we can call DRW_cache_object_surface_material_get. + * They never get actually used. */ + Vector dummy_gpu_materials = {1, nullptr, {}}; + GPUMaterial **get_dummy_gpu_materials(int material_count) + { +if (material_count > dummy_gpu_materials.size()) { + dummy_gpu_materials.resize(material_count, nullptr); +} +return dummy_gpu_materials.begin(); + }; + void init(Object *camera_ob = nullptr) { scene_state.init(camera_ob); @@ -365,18 +374,6 @@ class Instance { } }; -/* This returns an array of nullptr GPUMaterial pointers so we can call - * DRW_cache_object_surface_material_get. They never get actually used. - */ -GPUMaterial **get_dummy_gpu_materials(int material_count) -{ - static Vector dummy_gpu_materials(1, nullptr, {}); - if (material_count > dummy_gpu_materials.size()) { -dummy_gpu_materials.resize(material_count, nullptr); - } - return dummy_gpu_materials.begin(); -}; - } // namespace blender::workbench /* */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8213d1735dd] tmp-workbench-rewrite2: Fix comments style
Commit: 8213d1735dd805467f5b78d871427228e3d488f1 Author: Miguel Pozo Date: Mon Jan 9 17:09:32 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB8213d1735dd805467f5b78d871427228e3d488f1 Fix comments style === M source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh index bd813a36c6e..c437605574d 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh @@ -58,7 +58,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_composite) .fragment_source("workbench_next_composite_frag.glsl") .additional_info("draw_fullscreen", "draw_view"); -// Lighting +/* Lighting */ GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_studio).define("WORKBENCH_LIGHTING_STUDIO"); @@ -68,7 +68,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_matcap) GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_flat).define("WORKBENCH_LIGHTING_FLAT"); -// Effects +/* Effects */ GPU_SHADER_CREATE_INFO(workbench_next_resolve_curvature) .define("WORKBENCH_CURVATURE") @@ -78,9 +78,9 @@ GPU_SHADER_CREATE_INFO(workbench_next_resolve_cavity) .define("WORKBENCH_CAVITY") .sampler(8, ImageType::FLOAT_2D, "jitter_tx") /* TODO(Miguel Pozo): GPU_SAMPLER_REPEAT is set in CavityEffect, it doesn't work here ? */ -.uniform_buf(5, "float4", "cavity_samples[512]"); +.uniform_buf(5, "vec4", "cavity_samples[512]"); -// Variations +/* Variations */ #define WORKBENCH_FINAL_VARIATION(name, ...) \ GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 17e1acb15e4..313aad6244e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -13,7 +13,7 @@ class TaaSamples { samples = blender::Array(size); BLI_jitter_init((float(*)[2])samples.begin(), size); -/* find closest element to center */ +/* Find closest element to center */ int closest_index = 0; float closest_squared_distance = 1.0f; @@ -29,7 +29,7 @@ class TaaSamples { float2 closest_sample = samples[closest_index]; for (float2 &sample : samples) { - /* move jitter samples so that closest sample is in center */ + /* Move jitter samples so that closest sample is in center */ sample -= closest_sample; /* Avoid samples outside range (wrap around). */ sample = {fmodf(sample.x + 0.5f, 1.0f), fmodf(sample.y + 0.5f, 1.0f)}; @@ -37,7 +37,7 @@ class TaaSamples { sample = (sample * 2.0f) - 1.0f; } -/* swap center sample to the start of the array */ +/* Swap center sample to the start of the array */ if (closest_index != 0) { swap_v2_v2(samples[0], samples[closest_index]); } @@ -96,7 +96,7 @@ static void setup_taa_weights(const float2 offset, float r_weights[9], float &r_ for (int y = -1; y <= 1; y++, i++) { float2 sample_co = float2(x, y) - offset; float r = len_v2(sample_co); - /* fclem: is radial distance ok here? */ + /* fclem: Is radial distance ok here? */ float weight = filter_blackman_harris(r, filter_width); r_weight_sum += weight; r_weights[i] = weight; @@ -215,7 +215,7 @@ void AntiAliasingPass::setup_view(View &view, int2 resolution) /* TODO(Miguel Pozo): New API equivalent? */ const DRWView *default_view = DRW_view_default_get(); float4x4 winmat, viewmat, persmat; - /* construct new matrices from transform delta */ + /* Construct new matrices from transform delta */ DRW_view_winmat_get(default_view, winmat.ptr(), false); DRW_view_viewmat_get(default_view, viewmat.ptr(), false); DRW_view_persmat_get(default_view, persmat.ptr(), false); diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 25b0c6de74e..11d5cd33f4c 100644 --- a
[Bf-blender-cvs] [9594be5eef5] tmp-workbench-rewrite2: Remove commented-out code
Commit: 9594be5eef59e75854ebecd58b20c0f00c15ad8e Author: Miguel Pozo Date: Mon Jan 9 17:11:23 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB9594be5eef59e75854ebecd58b20c0f00c15ad8e Remove commented-out code === M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl M source/blender/draw/engines/workbench/workbench_engine.cc === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index 7ebebdf8c2b..a81c1b5712e 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -32,7 +32,6 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) .vertex_out(workbench_shadow_iface) .define("WORKBENCH_NEXT") .uniform_buf(1, "ShadowPassData", "pass_data") -//.push_constant(Type::VEC3, "lightDirection") .define("lightDirection", "vData[0].light_direction_os") .typedef_source("workbench_shader_shared.h") .additional_info("draw_view") diff --git a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl index 5331ad5f7ae..a66af6008d9 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl @@ -41,20 +41,16 @@ void main() # ifdef WORKBENCH_CAVITY cavity_compute(uv, depth_tx, normal_tx, cavity, edges); -// color.rgb = vec3(cavity, edges, 0); # endif # ifdef WORKBENCH_CURVATURE curvature_compute(uv, object_id_tx, normal_tx, curvature); -// color.rgb = vec3(curvature); # endif float final_cavity_factor = clamp( (1.0 - cavity) * (1.0 + edges) * (1.0 + curvature), 0.0, 4.0); color.rgb *= final_cavity_factor; -// color.rgb *= vec3(0, 1, 0); - #endif bool shadow = texture(stencil_tx, uv).r != 0; diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index fff98692220..e10bcf872ae 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -319,7 +319,6 @@ class Instance { resources.object_id_tx.clear(uint4(0)); } -// resources.depth_tx.acquire(resolution, GPU_DEPTH24_STENCIL8); Framebuffer fb = Framebuffer("Workbench.Clear"); fb.ensure(GPU_ATTACHMENT_TEXTURE(resources.depth_tx)); fb.bind(); @@ -353,7 +352,6 @@ class Instance { resources.color_tx.release(); resources.object_id_tx.release(); -// resources.depth_tx.release(); resources.depth_in_front_tx.release(); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fdb4abc36da] tmp-workbench-rewrite2: Fix workbench_next_merge depth
Commit: fdb4abc36dadf57d22711af572a61818a5b960dd Author: Miguel Pozo Date: Mon Jan 9 17:10:12 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBfdb4abc36dadf57d22711af572a61818a5b960dd Fix workbench_next_merge depth === M source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh index 56ad367451d..fdf8fb61d9c 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh @@ -14,4 +14,5 @@ GPU_SHADER_CREATE_INFO(workbench_next_merge_depth) .sampler(0, ImageType::DEPTH_2D, "depth_tx") .fragment_source("workbench_next_merge_depth_frag.glsl") .additional_info("draw_fullscreen") +.depth_write(DepthWrite::ANY) .do_static_compilation(true); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4aec99931b8] tmp-workbench-rewrite2: Clarify TODO comments
Commit: 4aec99931b878473ab0a20545d9045adc16660ac Author: Miguel Pozo Date: Mon Jan 9 16:36:06 2023 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB4aec99931b878473ab0a20545d9045adc16660ac Clarify TODO comments === M source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc === diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index de0277e4320..17e1acb15e4 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -234,7 +234,9 @@ void AntiAliasingPass::draw(Manager &manager, GPUTexture *color_tx) { if (!enabled_) { -/* TODO(Miguel Pozo): Should render to the input color_tx and depth_tx in the first place */ +/* TODO(Miguel Pozo): Should render to the input color_tx and depth_tx in the first place. + * This requires the use of TextureRefs with stencil_view() support, + * but whether TextureRef will stay is still TBD. */ GPU_texture_copy(color_tx, resources.color_tx); GPU_texture_copy(depth_tx, resources.depth_tx); return; @@ -263,7 +265,10 @@ void AntiAliasingPass::draw(Manager &manager, if (sample0_depth_tx_.is_valid()) { GPU_texture_copy(sample0_depth_tx_, resources.depth_tx); } -/* TODO(Miguel Pozo): Should render to the input depth_tx in the first place */ +/* TODO(Miguel Pozo): Should render to the input depth_tx in the first place + * This requires the use of TextureRef with stencil_view() support, + * but whether TextureRef will stay is still TBD. */ + /* Copy back the saved depth buffer for correct overlays. */ GPU_texture_copy(depth_tx, resources.depth_tx); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a53e560ca57] tmp-worbench-rewrite2-optimizations: GPU Debug Groups profiling (WIP)
Commit: a53e560ca57cdcd7d79f9852c6da88f8eb1aaa01 Author: Miguel Pozo Date: Fri Dec 30 19:53:55 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBa53e560ca57cdcd7d79f9852c6da88f8eb1aaa01 GPU Debug Groups profiling (WIP) === M source/blender/draw/intern/draw_manager.c M source/blender/gpu/opengl/gl_context.cc M source/blender/gpu/opengl/gl_context.hh M source/blender/gpu/opengl/gl_debug.cc === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 5c1f5dd0a4a..4a3611eb048 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1007,8 +1007,10 @@ void DRW_cache_free_old_batches(Main *bmain) static void drw_engines_init(void) { + DRW_stats_group_start("drw_engines.engines_init"); DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { PROFILE_START(stime); +DRW_stats_group_start(engine->idname); const DrawEngineDataSize *data_size = engine->vedata_size; memset(data->psl->passes, 0, sizeof(*data->psl->passes) * data_size->psl_len); @@ -1017,15 +1019,19 @@ static void drw_engines_init(void) engine->engine_init(data); } +DRW_stats_group_end(); PROFILE_END_UPDATE(data->init_time, stime); } + DRW_stats_group_end(); } static void drw_engines_cache_init(void) { + DRW_stats_group_start("drw_engines.cache_init"); DRW_manager_begin_sync(); DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { +DRW_stats_group_start(engine->idname); if (data->text_draw_cache) { DRW_text_cache_destroy(data->text_draw_cache); data->text_draw_cache = NULL; @@ -1037,7 +1043,9 @@ static void drw_engines_cache_init(void) if (engine->cache_init) { engine->cache_init(data); } +DRW_stats_group_end(); } + DRW_stats_group_end(); } static void drw_engines_world_update(Scene *scene) @@ -1045,12 +1053,16 @@ static void drw_engines_world_update(Scene *scene) if (scene->world == NULL) { return; } + DRW_stats_group_start("drw_engines.world_update"); DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { if (engine->id_update) { + DRW_stats_group_start(engine->idname); engine->id_update(data, &scene->world->id); + DRW_stats_group_end(); } } + DRW_stats_group_end(); } static void drw_engines_cache_populate(Object *ob) @@ -1091,17 +1103,22 @@ static void drw_engines_cache_populate(Object *ob) static void drw_engines_cache_finish(void) { + DRW_stats_group_start("drw_engines.cache_finish"); DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { if (engine->cache_finish) { + DRW_stats_group_start(engine->idname); engine->cache_finish(data); + DRW_stats_group_end(); } } DRW_manager_end_sync(); + DRW_stats_group_end(); } static void drw_engines_draw_scene(void) { + DRW_stats_group_start("drw_engines.draw_scene"); DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { PROFILE_START(stime); if (engine->draw_scene) { @@ -1117,6 +1134,7 @@ static void drw_engines_draw_scene(void) } /* Reset state after drawing */ DRW_state_reset(); + DRW_stats_group_end(); } static void drw_engines_draw_text(void) @@ -1678,6 +1696,7 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, drw_context_state_init(); drw_manager_init(&DST, viewport, NULL); + DRW_viewport_colormanagement_set(viewport); const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; @@ -1716,6 +1735,8 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, /* Only iterate over objects for internal engines or when overlays are enabled */ if (do_populate_loop) { + DRW_stats_group_start("drw_render.populate_loop"); + DST.dupli_origin = NULL; DST.dupli_origin_data = NULL; DEGObjectIterSettings deg_iter_settings = {0}; @@ -1737,6 +1758,8 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, drw_engines_cache_populate(ob); } DEG_OBJECT_ITER_END; + + DRW_stats_group_end(); } drw_duplidata_free(); diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc index 375194c09f3..f3107746a5c 100644 --- a/source/blender/gpu/opengl/gl_context.cc +++ b/source/blender/gpu/opengl/gl_context.cc @@ -141,6 +141,8 @@ void GLContext::activate() bound_ubo_slots = 0; immActivate(); + + process_frame_timings(); } void GLContext::deactivate() diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh
[Bf-blender-cvs] [c6ce4eed5ef] tmp-worbench-rewrite2-optimizations: Optimization: Convert composite compute shader to fragment
Commit: c6ce4eed5ef1fdba514c6cd1253ea7fb66a7c31c Author: Miguel Pozo Date: Thu Dec 29 18:09:59 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBc6ce4eed5ef1fdba514c6cd1253ea7fb66a7c31c Optimization: Convert composite compute shader to fragment === M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh R094 source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl M source/blender/draw/engines/workbench/workbench_mesh_passes.cc === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 39428d1b93f..afbe75a8dbe 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -475,8 +475,8 @@ set(GLSL_SRC engines/workbench/shaders/workbench_cavity_lib.glsl engines/workbench/shaders/workbench_common_lib.glsl - engines/workbench/shaders/workbench_composite_comp.glsl engines/workbench/shaders/workbench_composite_frag.glsl + engines/workbench/shaders/workbench_next_composite_frag.glsl engines/workbench/shaders/workbench_curvature_lib.glsl engines/workbench/shaders/workbench_effect_cavity_frag.glsl engines/workbench/shaders/workbench_effect_dof_frag.glsl diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh index c33218cff1b..bd813a36c6e 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh @@ -47,17 +47,16 @@ GPU_SHADER_CREATE_INFO(workbench_composite_flat) * \{ */ GPU_SHADER_CREATE_INFO(workbench_next_composite) -.local_group_size(8, 8) .sampler(3, ImageType::FLOAT_2D, "normal_tx") .sampler(4, ImageType::FLOAT_2D, "material_tx") .sampler(5, ImageType::DEPTH_2D, "depth_tx") .sampler(6, ImageType::UINT_2D, "stencil_tx") .uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") -.push_constant(Type::BOOL, "forceShadowing") -.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") .typedef_source("workbench_shader_shared.h") -.compute_source("workbench_composite_comp.glsl") -.additional_info("draw_view"); +.push_constant(Type::BOOL, "forceShadowing") +.fragment_out(0, Type::VEC4, "fragColor") +.fragment_source("workbench_next_composite_frag.glsl") +.additional_info("draw_fullscreen", "draw_view"); // Lighting diff --git a/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl similarity index 94% rename from source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl rename to source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl index 0ca96cc6149..5331ad5f7ae 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl @@ -8,8 +8,7 @@ void main() { - ivec2 texel = ivec2(gl_GlobalInvocationID.xy); - vec2 uv = (vec2(texel) + 0.5) / vec2(textureSize(normal_tx, 0)); + vec2 uv = uvcoordsvar.st; /* Normal and Incident vector are in viewspace. Lighting is evaluated in viewspace. */ vec3 V = get_view_vector_from_screen_uv(uv); vec3 N = workbench_normal_decode(texture(normal_tx, uv)); @@ -78,6 +77,9 @@ void main() #endif if (color != world_data.background_color) { -imageStore(out_color_img, texel, color); +fragColor = color; + } + else { +discard; } } diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index 06f77a0e619..84c7c58f12f 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -119,6 +119,7 @@ void OpaquePass::sync(const SceneState &scene_state, SceneResources &resources) ePipelineType::OPAQUE, scene_state.lighting_type, clip, resources.shader_cache); deferred_ps_.init(); + deferred_ps_.state_set(DRW_STATE_WRITE_COLOR); deferred_ps_.shader_set(resources.shader_cache.resolve_shader_get(ePipelineType::OPAQUE, scene_state.lighting_type,
[Bf-blender-cvs] [64b87737d6a] tmp-worbench-rewrite2-optimizations: Allow disabling gpu logs when --gpu-debug is enabled (for profiling)
Commit: 64b87737d6ad6eefddb35e458c6914aed5ad5c22 Author: Miguel Pozo Date: Fri Dec 30 19:12:37 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB64b87737d6ad6eefddb35e458c6914aed5ad5c22 Allow disabling gpu logs when --gpu-debug is enabled (for profiling) === M source/blender/gpu/opengl/gl_debug.cc === diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc index 5c23286c166..ea9ca0ba115 100644 --- a/source/blender/gpu/opengl/gl_debug.cc +++ b/source/blender/gpu/opengl/gl_debug.cc @@ -80,7 +80,7 @@ static void APIENTRY debug_callback(GLenum /*source*/, const bool use_color = CLG_color_support_get(&LOG); if (ELEM(severity, GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION)) { -if ((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level >= CLG_SEVERITY_INFO)) { +if ((LOG.type->flag & CLG_FLAG_USE) && (LOG.type->level <= CLG_SEVERITY_INFO)) { const char *format = use_color ? "\033[2m%s\033[0m" : "%s"; CLG_logf(LOG.type, CLG_SEVERITY_INFO, "Notification", "", format, message); } @@ -131,6 +131,10 @@ static void APIENTRY debug_callback(GLenum /*source*/, void init_gl_callbacks() { + if (G.log.level >= CLG_SEVERITY_LEN) { +return; + } + CLOG_ENSURE(&LOG); char msg[256] = ""; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b33634f8faf] tmp-worbench-rewrite2-optimizations: Optimization: Remove unused random computation
Commit: b33634f8faf34f67d93c31b3961813f910bfe986 Author: Miguel Pozo Date: Fri Dec 30 17:22:03 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rBb33634f8faf34f67d93c31b3961813f910bfe986 Optimization: Remove unused random computation This is most likely removed in release builds, but not on debug. === M source/blender/draw/intern/draw_resource.hh === diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 654caa878dd..a2de084b900 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -82,15 +82,6 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active SET_FLAG_FROM_TEST( flag, ref.object->transflag & OB_NEG_SCALE, eObjectInfoFlag::OBJECT_NEGATIVE_SCALE); - if (ref.dupli_object == nullptr) { -/* TODO(fclem): this is rather costly to do at draw time. Maybe we can - * put it in ob->runtime and make depsgraph ensure it is up to date. */ -random = BLI_hash_int_2d(BLI_hash_string(ref.object->id.name + 2), 0) * - (1.0f / (float)0x); - } - else { -random = ref.dupli_object->random_id * (1.0f / (float)0x); - } /* Default values. Set if needed. */ random = 0.0f; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1b20a9d383b] tmp-worbench-rewrite2-optimizations: Optimization: Don't use glClearTexImage
Commit: 1b20a9d383ba0659819f58ffcdba7f92a00c859c Author: Miguel Pozo Date: Fri Dec 30 17:18:47 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB1b20a9d383ba0659819f58ffcdba7f92a00c859c Optimization: Don't use glClearTexImage === M source/blender/gpu/opengl/gl_texture.cc === diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc index 6ec079f44b8..e12b15fd071 100644 --- a/source/blender/gpu/opengl/gl_texture.cc +++ b/source/blender/gpu/opengl/gl_texture.cc @@ -385,7 +385,9 @@ void GLTexture::clear(eGPUDataFormat data_format, const void *data) { BLI_assert(validate_data_format(format_, data_format)); - if (GLContext::clear_texture_support) { + /* ClearTexImage can be up to 10 times slower */ + const bool USE_CLEAR_TEX_IMAGE = false; + if (USE_CLEAR_TEX_IMAGE && GLContext::clear_texture_support) { int mip = 0; GLenum gl_format = to_gl_data_format(format_); GLenum gl_type = to_gl(data_format); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [646613c23da] tmp-worbench-rewrite2-optimizations: Optimize Workbench Next Shadows
Commit: 646613c23da8a4bcb3e43aa2257c3f88090ba98f Author: Miguel Pozo Date: Wed Dec 28 18:07:31 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB646613c23da8a4bcb3e43aa2257c3f88090ba98f Optimize Workbench Next Shadows Don't use push constants. Use the same object handle for all passes. === M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index d1e7e0046d8..7ebebdf8c2b 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -11,7 +11,8 @@ GPU_SHADER_INTERFACE_INFO(workbench_shadow_iface, "vData") .smooth(Type::VEC3, "pos") .smooth(Type::VEC4, "frontPosition") -.smooth(Type::VEC4, "backPosition"); +.smooth(Type::VEC4, "backPosition") +.flat(Type::VEC3, "light_direction_os"); /*Workbench Next*/ GPU_SHADER_CREATE_INFO(workbench_shadow_common) .vertex_in(0, Type::VEC3, "pos") @@ -31,7 +32,8 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) .vertex_out(workbench_shadow_iface) .define("WORKBENCH_NEXT") .uniform_buf(1, "ShadowPassData", "pass_data") -.push_constant(Type::VEC3, "lightDirection") +//.push_constant(Type::VEC3, "lightDirection") +.define("lightDirection", "vData[0].light_direction_os") .typedef_source("workbench_shader_shared.h") .additional_info("draw_view") .additional_info("draw_modelmat_new") diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl index c3664da66ad..1df514c9081 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl @@ -6,6 +6,7 @@ void main() vData.pos = pos; vData.frontPosition = point_object_to_ndc(pos); #ifdef WORKBENCH_NEXT + vData.light_direction_os = normal_world_to_object(pass_data.light_direction_ws); vec3 pos_ws = point_object_to_world(pos); float extrude_distance = 1e5f; float LDoFP = dot(pass_data.light_direction_ws, pass_data.far_plane.xyz); diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 0259233cb9f..aaba9a76877 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -420,31 +420,18 @@ void ShadowPass::object_sync(Manager &manager, PassType fail_type = force_fail_pass ? ForcedFail : Fail; - /* TODO(Miguel Pozo): Compute on the visibility compute shader ? */ - float3 light_direction_os = float4x4(ob->world_to_object).ref_3x3() * - pass_data_.light_direction_ws; - /* Unless we force the Fail Method we add draw commands to both methods, * then the visibility compute shader selects the one needed */ + ResourceHandle handle = manager.resource_handle(ob_ref); + if (!force_fail_pass) { PassMain::Sub &ps = *get_pass_ptr(Pass, is_manifold); -ps.push_constant("lightDirection", light_direction_os); -ResourceHandle handle = manager.resource_handle(ob_ref); -ps.draw(geom_shadow, handle); - } - { -PassMain::Sub &ps = *get_pass_ptr(fail_type, is_manifold, true); -ps.push_constant("lightDirection", light_direction_os); -ResourceHandle handle = manager.resource_handle(ob_ref); -ps.draw(DRW_cache_object_surface_get(ob), handle); - } - { -PassMain::Sub &ps = *get_pass_ptr(fail_type, is_manifold, false); -ps.push_constant("lightDirection", light_direction_os); -ResourceHandle handle = manager.resource_handle(ob_ref); ps.draw(geom_shadow, handle); } + + get_pass_ptr(fail_type, is_manifold, true)->draw(DRW_cache_object_surface_get(ob), handle); + get_pass_ptr(fail_type, is_manifold, false)->draw(geom_shadow, handle); } void ShadowPass::draw(Manager &manager, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5c4a5c637c0] tmp-worbench-rewrite2-optimizations: MeshPass replace sub_pass_get() with draw()
Commit: 5c4a5c637c0f8bd7214f0205e49a958840d106aa Author: Miguel Pozo Date: Thu Dec 29 17:21:04 2022 +0100 Branches: tmp-worbench-rewrite2-optimizations https://developer.blender.org/rB5c4a5c637c0f8bd7214f0205e49a958840d106aa MeshPass replace sub_pass_get() with draw() === M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh === diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 9c7bfb7c6c3..fff98692220 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -273,7 +273,7 @@ class Instance { const bool in_front = (ob_ref.object->dtx & OB_DRAW_IN_FRONT) != 0; auto draw = [&](MeshPass &pass) { - pass.sub_pass_get(ob_ref, image, sampler_state, iuser).draw(batch, handle); + pass.draw(ob_ref, batch, handle, image, sampler_state, iuser); }; if (scene_state.xray_mode || material.is_transparent()) { diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index cd71bb7c6a3..06f77a0e619 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -50,12 +50,13 @@ void MeshPass::init_subpasses(ePipelineType pipeline, } } -PassMain::Sub &MeshPass::sub_pass_get(ObjectRef &ref, - ::Image *image /* = nullptr */, - eGPUSamplerState sampler_state /* = GPU_SAMPLER_DEFAULT */, - ImageUser *iuser /* = nullptr */) +void MeshPass::draw(ObjectRef &ref, +GPUBatch *batch, +ResourceHandle handle, +::Image *image /* = nullptr */, +eGPUSamplerState sampler_state /* = GPU_SAMPLER_DEFAULT */, +ImageUser *iuser /* = nullptr */) { - /*TODO(Miguel Pozo): For now we assume retrieving a subpass means it's not empty anymore*/ is_empty_ = false; eGeometryType geometry_type = geometry_type_from_object(ref.object); @@ -90,11 +91,12 @@ PassMain::Sub &MeshPass::sub_pass_get(ObjectRef &ref, return sub_pass; }; - return *texture_subpass_map_.lookup_or_add_cb(TextureSubPassKey(texture, geometry_type), -add_cb); + texture_subpass_map_.lookup_or_add_cb(TextureSubPassKey(texture, geometry_type), add_cb) + ->draw(batch, handle); } } - return *passes_[static_cast(geometry_type)][static_cast(eShaderType::MATERIAL)]; + passes_[static_cast(geometry_type)][static_cast(eShaderType::MATERIAL)]->draw(batch, + handle); } void OpaquePass::sync(const SceneState &scene_state, SceneResources &resources) diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 9173cc089c7..a0bc247798c 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -175,11 +175,12 @@ class MeshPass : public PassMain { bool clip, ShaderCache &shaders); - PassMain::Sub &sub_pass_get( - ObjectRef &ref, - ::Image *image = nullptr, - eGPUSamplerState sampler_state = eGPUSamplerState::GPU_SAMPLER_DEFAULT, - ImageUser *iuser = nullptr); + void draw(ObjectRef &ref, +GPUBatch *batch, +ResourceHandle handle, +::Image *image = nullptr, +eGPUSamplerState sampler_state = eGPUSamplerState::GPU_SAMPLER_DEFAULT, +ImageUser *iuser = nullptr); }; class OpaquePass { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [45103e3a88c] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: 45103e3a88cac0c50784dbc11da31b5e06211f43 Author: Miguel Pozo Date: Tue Dec 20 17:12:43 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB45103e3a88cac0c50784dbc11da31b5e06211f43 Merge branch 'master' into tmp-workbench-rewrite2 === === diff --cc source/blender/gpu/intern/gpu_texture_private.hh index aad56639859,fc5e39a3534..20543391691 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@@ -41,8 -41,21 +41,21 @@@ typedef enum eGPUTextureType GPU_TEXTURE_CUBE_ARRAY = (GPU_TEXTURE_CUBE | GPU_TEXTURE_ARRAY), } eGPUTextureType; -ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_CUBE_ARRAY) +ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_BUFFER) + /* Format types for samplers within the shader. + * This covers the sampler format type permutations within GLSL/MSL.*/ + typedef enum eGPUSamplerFormat { + GPU_SAMPLER_TYPE_FLOAT = 0, + GPU_SAMPLER_TYPE_INT = 1, + GPU_SAMPLER_TYPE_UINT = 2, + /* Special case for depth, as these require differing dummy formats. */ + GPU_SAMPLER_TYPE_DEPTH = 3, + GPU_SAMPLER_TYPE_MAX = 4 + } eGPUSamplerFormat; + + ENUM_OPERATORS(eGPUSamplerFormat, GPU_SAMPLER_TYPE_UINT) + #ifdef DEBUG # define DEBUG_NAME_LEN 64 #else ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [87482b8a9e0] tmp-workbench-rewrite2: Fix GPU debug names
Commit: 87482b8a9e0adce66bbeb44269759f4018c36934 Author: Miguel Pozo Date: Tue Dec 20 16:38:07 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB87482b8a9e0adce66bbeb44269759f4018c36934 Fix GPU debug names === M source/blender/draw/engines/workbench/workbench_mesh_passes.cc === diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index 1a00ef83395..cd71bb7c6a3 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -32,13 +32,18 @@ void MeshPass::init_subpasses(ePipelineType pipeline, { texture_subpass_map_.clear(); + static std::string pass_names[geometry_type_len][shader_type_len] = {}; + for (auto geom : IndexRange(geometry_type_len)) { for (auto shader : IndexRange(shader_type_len)) { eGeometryType geom_type = static_cast(geom); eShaderType shader_type = static_cast(shader); - std::string name = std::string(get_name(geom_type)) + std::string(get_name(shader_type)); + if (pass_names[geom][shader].empty()) { +pass_names[geom][shader] = std::string(get_name(geom_type)) + + std::string(get_name(shader_type)); + } GPUShader *sh = shaders.prepass_shader_get(pipeline, geom_type, shader_type, lighting, clip); - PassMain::Sub *pass = &sub(name.c_str()); + PassMain::Sub *pass = &sub(pass_names[geom][shader].c_str()); pass->shader_set(sh); passes_[geom][shader] = pass; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6b7160ed3bd] tmp-workbench-rewrite2: Fix GPU debug groups
Commit: 6b7160ed3bdd4abdad00cf443eb13c93cad5d01f Author: Miguel Pozo Date: Tue Dec 20 16:30:05 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB6b7160ed3bdd4abdad00cf443eb13c93cad5d01f Fix GPU debug groups === M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index e82f032db8e..0259233cb9f 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -223,6 +223,7 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, } else if (current_pass_type_ == ShadowPass::Fail) { /* Already computed in the ShadowPass::Pass */ +GPU_debug_group_end(); return; } else { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c76d4ddf0bf] tmp-workbench-rewrite2: Cleanup comments
Commit: c76d4ddf0bf1358c0142a8212f3b0d3e567aebc2 Author: Miguel Pozo Date: Mon Dec 19 16:27:29 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBc76d4ddf0bf1358c0142a8212f3b0d3e567aebc2 Cleanup comments === M source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl M source/blender/draw/engines/workbench/workbench_effect_cavity.cc M source/blender/draw/engines/workbench/workbench_effect_dof.cc M source/blender/draw/engines/workbench/workbench_effect_outline.cc M source/blender/draw/engines/workbench/workbench_materials_next.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_resources.cc M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/engines/workbench/workbench_state.cc === diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl index e638e68c80f..aef73672a8a 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl @@ -1,9 +1,4 @@ -/** - * Compute visibility of each resource bounds for a given view. - */ -/* TODO(fclem): This could be augmented by a 2 pass occlusion culling system. */ - #pragma BLENDER_REQUIRE(common_math_lib.glsl) #pragma BLENDER_REQUIRE(common_intersect_lib.glsl) diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc index c0ee7fd60c2..a87c0fa2ba1 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2020 Blender Foundation. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup draw_engine diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index e5282166c26..25b0c6de74e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2016 Blender Foundation. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup draw_engine diff --git a/source/blender/draw/engines/workbench/workbench_effect_outline.cc b/source/blender/draw/engines/workbench/workbench_effect_outline.cc index 4a060153618..18b8b484aef 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_outline.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_outline.cc @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2020 Blender Foundation. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup draw_engine diff --git a/source/blender/draw/engines/workbench/workbench_materials_next.cc b/source/blender/draw/engines/workbench/workbench_materials_next.cc index 6e4085b584e..ec42c696ccc 100644 --- a/source/blender/draw/engines/workbench/workbench_materials_next.cc +++ b/source/blender/draw/engines/workbench/workbench_materials_next.cc @@ -4,10 +4,9 @@ #include "BLI_hash.h" /* get_image */ +#include "BKE_node.h" #include "DNA_node_types.h" #include "ED_uvedit.h" -//#include "BKE_image.h" -#include "BKE_node.h" /* get_image */ namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index b0f3ad2..9173cc089c7 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -119,8 +119,8 @@ class CavityEffect { bool curvature_enabled_; bool cavity_enabled_; - static const int max_samples_ = 512; // This value must be kept in sync with the one declared at -// workbench_composite_info.hh (cavity_samples) + static const int max_samples_ = 512; /* This value must be kept in sync with the one declared at +* workbench_composite_info.hh (cavity_samples) */ UniformArrayBuffer samples_buf; void load_samples_buf(int ssao_samples); @@ -253,7 +253,6 @@ class ShadowPass { UniformBuffer extruded_frustum_; ShadowPass::PassType current_pass_type_; -/* TODO(Miguel Pozo): Use multiple views? */ VisibilityBuf pass_visibility_buf_; VisibilityBuf fail_visibilit
[Bf-blender-cvs] [c38bdceb682] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: c38bdceb682530ece568159719d3e35b9848b918 Author: Miguel Pozo Date: Mon Dec 19 13:58:06 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBc38bdceb682530ece568159719d3e35b9848b918 Merge branch 'master' into tmp-workbench-rewrite2 === === diff --cc source/blender/draw/CMakeLists.txt index 7e51319e681,2093c8a2331..39428d1b93f --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@@ -493,7 -482,7 +498,8 @@@ set(GLSL_SR engines/workbench/shaders/workbench_shadow_debug_frag.glsl engines/workbench/shaders/workbench_shadow_geom.glsl engines/workbench/shaders/workbench_shadow_vert.glsl + engines/workbench/shaders/workbench_shadow_visibility_comp.glsl + engines/workbench/shaders/workbench_shadow_vert_no_geom.glsl engines/workbench/shaders/workbench_transparent_accum_frag.glsl engines/workbench/shaders/workbench_transparent_resolve_frag.glsl engines/workbench/shaders/workbench_volume_frag.glsl diff --cc source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index 04fd4349d65,3d86ef6e78c..d1e7e0046d8 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@@ -15,50 -13,17 +15,54 @@@ GPU_SHADER_INTERFACE_INFO(workbench_sha GPU_SHADER_CREATE_INFO(workbench_shadow_common) .vertex_in(0, Type::VEC3, "pos") - .vertex_out(workbench_shadow_iface) .push_constant(Type::FLOAT, "lightDistance") .push_constant(Type::VEC3, "lightDirection") - .vertex_source("workbench_shadow_vert.glsl") .additional_info("draw_mesh"); + /* `workbench_shadow_vert.glsl` only used by geometry shader path. + * Vertex output iface not needed by non-geometry shader variants, + * as only gl_Position is returned. */ + GPU_SHADER_CREATE_INFO(workbench_shadow_common_geom) + .vertex_out(workbench_shadow_iface) + .vertex_source("workbench_shadow_vert.glsl"); + +GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) +.vertex_in(0, Type::VEC3, "pos") +.vertex_out(workbench_shadow_iface) +.define("WORKBENCH_NEXT") +.uniform_buf(1, "ShadowPassData", "pass_data") +.push_constant(Type::VEC3, "lightDirection") +.typedef_source("workbench_shader_shared.h") - .vertex_source("workbench_shadow_vert.glsl") +.additional_info("draw_view") +.additional_info("draw_modelmat_new") +.additional_info("draw_resource_handle_new"); + +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_common) +.local_group_size(DRW_VISIBILITY_GROUP_SIZE) +.define("DRW_VIEW_LEN", "64") +.storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") +.uniform_buf(2, "ExtrudedFrustum", "extruded_frustum") +.push_constant(Type::INT, "resource_len") +.push_constant(Type::INT, "view_len") +.push_constant(Type::INT, "visibility_word_per_draw") +.push_constant(Type::BOOL, "force_fail_method") +.push_constant(Type::VEC3, "shadow_direction") +.typedef_source("workbench_shader_shared.h") +.compute_source("workbench_shadow_visibility_comp.glsl") +.additional_info("draw_view", "draw_view_culling"); + +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_dynamic_pass_type) +.additional_info("workbench_next_shadow_visibility_compute_common") +.define("DYNAMIC_PASS_SELECTION") +.storage_buf(1, Qualifier::READ_WRITE, "uint", "pass_visibility_buf[]") +.storage_buf(2, Qualifier::READ_WRITE, "uint", "fail_visibility_buf[]") +.do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_static_pass_type) +.additional_info("workbench_next_shadow_visibility_compute_common") +.storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") +.do_static_compilation(true); + /** \} */ /* */ diff --cc source/blender/draw/engines/workbench/workbench_effect_dof.cc index 413cb41d45e,000..e5282166c26 mode 100644,00..100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@@ -1,271 -1,0 +1,271 @@@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2016 Blender Foundation. */ + +/** \file + * \ingroup draw_engine + * + *
[Bf-blender-cvs] [7bc00aeabf2] tmp-wbench-next-shadow-backup: Workbench Next: Shadows: In front integration
Commit: 7bc00aeabf24ae6b8b2a5d99133f9178be953529 Author: Miguel Pozo Date: Fri Dec 16 17:29:36 2022 +0100 Branches: tmp-wbench-next-shadow-backup https://developer.blender.org/rB7bc00aeabf24ae6b8b2a5d99133f9178be953529 Workbench Next: Shadows: In front integration === M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index ecccb2083b1..04fd4349d65 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -38,10 +38,10 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_common) .define("DRW_VIEW_LEN", "64") .storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .uniform_buf(2, "ExtrudedFrustum", "extruded_frustum") -.push_constant(Type::BOOL, "forced_fail_pass") .push_constant(Type::INT, "resource_len") .push_constant(Type::INT, "view_len") .push_constant(Type::INT, "visibility_word_per_draw") +.push_constant(Type::BOOL, "force_fail_method") .push_constant(Type::VEC3, "shadow_direction") .typedef_source("workbench_shader_shared.h") .compute_source("workbench_shadow_visibility_comp.glsl") diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl index ddf655ec006..e638e68c80f 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl @@ -86,7 +86,7 @@ void main() #ifdef DYNAMIC_PASS_SELECTION if (is_visible(box)) { -bool use_fail_pass = intersects_near_plane(box); +bool use_fail_pass = force_fail_method || intersects_near_plane(box); set_visibility(!use_fail_pass, use_fail_pass); } else { diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 8805657acfd..9c7bfb7c6c3 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -336,7 +336,12 @@ class Instance { } } -opaque_ps.draw(manager, view, resources, resolution, &shadow_ps); +opaque_ps.draw(manager, + view, + resources, + resolution, + &shadow_ps, + transparent_ps.accumulation_ps_.is_empty()); transparent_ps.draw(manager, view, resources, resolution); transparent_depth_ps.draw(manager, view, resources, resolution); diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index 7b2d340247f..1a00ef83395 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -122,7 +122,7 @@ void OpaquePass::sync(const SceneState &scene_state, SceneResources &resources) deferred_ps_.bind_texture("normal_tx", &gbuffer_normal_tx); deferred_ps_.bind_texture("material_tx", &gbuffer_material_tx); deferred_ps_.bind_texture("depth_tx", &resources.depth_tx); - deferred_ps_.bind_texture("stencil_tx", resources.depth_tx.stencil_view()); + deferred_ps_.bind_texture("stencil_tx", &deferred_ps_stencil_tx); deferred_ps_.bind_image("out_color_img", &resources.color_tx); resources.cavity.setup_resolve_pass(deferred_ps_, resources); deferred_ps_.dispatch(math::divide_ceil(scene_state.resolution, int2(WB_RESOLVE_GROUP_SIZE))); @@ -133,7 +133,8 @@ void OpaquePass::draw(Manager &manager, View &view, SceneResources &resources, int2 resolution, - ShadowPass *shadow_pass) + ShadowPass *shadow_pass, + bool accumulation_ps_is_empty) { if (is_empty()) { return; @@ -
[Bf-blender-cvs] [dcdf29d936f] tmp-wbench-next-shadow-backup: Workbench Next: Shadows: Compute based culling
Commit: dcdf29d936fd8667ad1ead8c385f6b485911ab0b Author: Miguel Pozo Date: Thu Dec 15 17:51:20 2022 +0100 Branches: tmp-wbench-next-shadow-backup https://developer.blender.org/rBdcdf29d936fd8667ad1ead8c385f6b485911ab0b Workbench Next: Shadows: Compute based culling fix 1 === M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl M source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shader_shared.h M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/intern/draw_manager.cc M source/blender/draw/intern/draw_view.cc M source/blender/draw/intern/draw_view.hh === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index c747e191e3e..7e51319e681 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -299,8 +299,11 @@ set(SRC engines/image/image_space_node.hh engines/image/image_texture_info.hh engines/image/image_usage.hh + engines/workbench/workbench_defines.hh engines/workbench/workbench_engine.h + engines/workbench/workbench_enums.hh engines/workbench/workbench_private.h + engines/workbench/workbench_private.hh engines/workbench/workbench_shader_shared.h engines/select/select_engine.h engines/select/select_private.h @@ -490,6 +493,7 @@ set(GLSL_SRC engines/workbench/shaders/workbench_shadow_debug_frag.glsl engines/workbench/shaders/workbench_shadow_geom.glsl engines/workbench/shaders/workbench_shadow_vert.glsl + engines/workbench/shaders/workbench_shadow_visibility_comp.glsl engines/workbench/shaders/workbench_transparent_accum_frag.glsl engines/workbench/shaders/workbench_transparent_resolve_frag.glsl engines/workbench/shaders/workbench_volume_frag.glsl diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index ad6b3560117..ecccb2083b1 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -24,27 +24,41 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_common) GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) .vertex_in(0, Type::VEC3, "pos") .vertex_out(workbench_shadow_iface) -.push_constant(Type::FLOAT, "lightDistance") +.define("WORKBENCH_NEXT") +.uniform_buf(1, "ShadowPassData", "pass_data") .push_constant(Type::VEC3, "lightDirection") +.typedef_source("workbench_shader_shared.h") .vertex_source("workbench_shadow_vert.glsl") .additional_info("draw_view") .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); -GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute) -.do_static_compilation(true) +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_common) .local_group_size(DRW_VISIBILITY_GROUP_SIZE) .define("DRW_VIEW_LEN", "64") .storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") -.storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") -.storage_buf(2, Qualifier::READ, "uint", "pass_technique_buf[]") +.uniform_buf(2, "ExtrudedFrustum", "extruded_frustum") +.push_constant(Type::BOOL, "forced_fail_pass") .push_constant(Type::INT, "resource_len") .push_constant(Type::INT, "view_len") .push_constant(Type::INT, "visibility_word_per_draw") .push_constant(Type::VEC3, "shadow_direction") -.compute_source("draw_visibility_comp.glsl") +.typedef_source("workbench_shader_shared.h") +.compute_source("workbench_shadow_visibility_comp.glsl") .additional_info("draw_view", "draw_view_culling"); +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute_dynamic_pass_type) +.additional_info("workbench_next_shadow_visibility_compute_common") +.define("DYNAMIC_PASS_SELECTION") +.storage_buf(1, Qualifier::READ_WRITE, "uint", "pass_visibility_buf[]") +.storage_buf(2, Qua
[Bf-blender-cvs] [97b0719f7dc] tmp-workbench-rewrite2: WIP: Compute based culling for workbench shadows
Commit: 97b0719f7dc10159ca45fabc54496647ff070e6f Author: Miguel Pozo Date: Mon Dec 12 12:33:50 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB97b0719f7dc10159ca45fabc54496647ff070e6f WIP: Compute based culling for workbench shadows === M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh A source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/intern/draw_view.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index a77af467ec8..ad6b3560117 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_defines.h" + #include "gpu_shader_create_info.hh" /* */ @@ -29,6 +31,20 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute) +.do_static_compilation(true) +.local_group_size(DRW_VISIBILITY_GROUP_SIZE) +.define("DRW_VIEW_LEN", "64") +.storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") +.storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") +.storage_buf(2, Qualifier::READ, "uint", "pass_technique_buf[]") +.push_constant(Type::INT, "resource_len") +.push_constant(Type::INT, "view_len") +.push_constant(Type::INT, "visibility_word_per_draw") +.push_constant(Type::VEC3, "shadow_direction") +.compute_source("draw_visibility_comp.glsl") +.additional_info("draw_view", "draw_view_culling"); + /** \} */ /* */ diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl new file mode 100644 index 000..7e89120a79f --- /dev/null +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl @@ -0,0 +1,53 @@ + +/** + * Compute visibility of each resource bounds for a given view. + */ +/* TODO(fclem): This could be augmented by a 2 pass occlusion culling system. */ + +#pragma BLENDER_REQUIRE(common_math_lib.glsl) +#pragma BLENDER_REQUIRE(common_intersect_lib.glsl) + +shared uint shared_result; + +void mask_visibility_bit(uint view_id) +{ + if (view_len > 1) { +uint index = gl_GlobalInvocationID.x * uint(visibility_word_per_draw) + (view_id / 32u); +visibility_buf[index] &= ~(1u << view_id); + } + else { +atomicAnd(visibility_buf[gl_WorkGroupID.x], ~(1u << gl_LocalInvocationID.x)); + } +} + +void main() +{ + if (gl_GlobalInvocationID.x >= resource_len) { +return; + } + + ObjectBounds bounds = bounds_buf[gl_GlobalInvocationID.x]; + + if (bounds.bounding_sphere.w != -1.0) { +IsectBox box = isect_data_setup(bounds.bounding_corners[0].xyz, +bounds.bounding_corners[1].xyz, +bounds.bounding_corners[2].xyz, +bounds.bounding_corners[3].xyz); +Sphere bounding_sphere = Sphere(bounds.bounding_sphere.xyz, bounds.bounding_sphere.w); +Sphere inscribed_sphere = Sphere(bounds.bounding_sphere.xyz, bounds._inner_sphere_radius); + +for (drw_view_id = 0; drw_view_id < view_len; drw_view_id++) { + if (intersect_view(inscribed_sphere) == true) { +/* Visible. */ + } + else if (intersect_view(bounding_sphere) == false) { +/* Not visible. */ +mask_visibility_bit(drw_view_id); + } + else if (intersect_view(box) == false) { +/* Not visible. */ +mask_visibility_bit(drw_view_id); + } +} + } +} diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 3632cc54f5a..21d092eaba9 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -17,13 +17,117 @@ #include "BKE_object.h" #include "BLI_math.h" #include "DRW_render.h" +#include "GPU_compute.h"
[Bf-blender-cvs] [bc73c1cd167] tmp-workbench-rewrite2: add TODO
Commit: bc73c1cd16740f3b8a5c9ba58ef50c190158a867 Author: Miguel Pozo Date: Mon Dec 5 19:12:58 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBbc73c1cd16740f3b8a5c9ba58ef50c190158a867 add TODO === M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 61207337d86..3632cc54f5a 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -221,6 +221,10 @@ void ShadowPass::object_sync(Manager &manager, use_shadow_pass_technique = false; } +/* TODO (Miguel Pozo): + * Disable use_shadow_pass_tecnique when there are "in front" objects in the scene. + */ + /* We cannot use Shadow Pass technique on non-manifold object (see T76168). */ if (use_shadow_pass_technique && !is_manifold && (scene_state.cull_state != 0)) { use_shadow_pass_technique = false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8f213e7436f] master: Merge branch 'blender-v3.4-release'
Commit: 8f213e7436fa3055ec6cca116a02dd3baf5ea3b1 Author: Miguel Pozo Date: Tue Dec 6 16:39:51 2022 +0100 Branches: master https://developer.blender.org/rB8f213e7436fa3055ec6cca116a02dd3baf5ea3b1 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [37b02b04324] blender-v3.4-release: Fix T102965: Crash when compiling shader tree with undefined mix nodes
Commit: 37b02b043246b416d66daf8aae60aaf9d9cd2506 Author: Miguel Pozo Date: Tue Dec 6 16:39:21 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB37b02b043246b416d66daf8aae60aaf9d9cd2506 Fix T102965: Crash when compiling shader tree with undefined mix nodes node_set_typeinfo leaves the bNode::type value as-is for nodes with undefined types. === M source/blender/nodes/shader/node_shader_tree.cc === diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index 7b5f150dfef..46ec1cff852 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -1038,10 +1038,10 @@ static void shader_node_disconnect_inactive_mix_branch(bNodeTree *ntree, static void ntree_shader_disconnect_inactive_mix_branches(bNodeTree *ntree) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -if (node->type == SH_NODE_MIX_SHADER) { +if (node->typeinfo->type == SH_NODE_MIX_SHADER) { shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 1, 2, true); } -else if (node->type == SH_NODE_MIX) { +else if (node->typeinfo->type == SH_NODE_MIX) { const NodeShaderMix *storage = static_cast(node->storage); if (storage->data_type == SOCK_FLOAT) { shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 2, 3, storage->clamp_factor); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8cbd045a828] tmp-workbench-rewrite2: wbench next: fix shadows fail pass
Commit: 8cbd045a8280de5fa20b530b9eb30477c1439f28 Author: Miguel Pozo Date: Mon Dec 5 16:08:59 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB8cbd045a8280de5fa20b530b9eb30477c1439f28 wbench next: fix shadows fail pass === M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 3ac514c7da5..ac92cb19eb1 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -260,7 +260,7 @@ struct ShadowPass { PassMain pass_ps = {"Shadow.Pass"}; PassMain fail_ps = {"Shadow.Fail"}; - PassMain::Sub *passes_[2][3]; + PassMain::Sub *passes_[2][2][2] = {{{nullptr}}}; PassMain::Sub *&get_pass_ptr(bool depth_pass, bool manifold, bool cap = false); GPUShader *shaders[2][2][2] = {{{nullptr}}}; diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 6071d484360..61207337d86 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -44,7 +44,7 @@ static void compute_parallel_lines_nor_and_dist(const float2 v1, PassMain::Sub *&ShadowPass::get_pass_ptr(bool depth_pass, bool manifold, bool cap /*= false*/) { - return passes_[depth_pass][manifold ? 0 : (cap ? 1 : 2)]; + return passes_[depth_pass][manifold][cap]; } GPUShader *ShadowPass::get_shader(bool depth_pass, bool manifold, bool cap /*= false*/) @@ -94,11 +94,11 @@ void ShadowPass::init(const SceneState &scene_state, SceneResources &resources) void ShadowPass::update() { - changed = compare_v3v3(direction_ws, cached_direction, 1e-5f); + changed = !compare_v3v3(direction_ws, cached_direction, 1e-5f); if (changed) { const float3 up = {0.0f, 0.0f, 1.0f}; -matrix = float4x4(); +matrix = float4x4::identity(); /* TODO: fix singularity. */ copy_v3_v3(matrix[2], direction_ws); @@ -161,31 +161,30 @@ void ShadowPass::sync() /* TODO(fclem): Merge into one pass with sub-passes. */ pass_ps.init(); pass_ps.state_set(depth_pass_state); + pass_ps.state_stencil(0xFF, 0xFF, 0xFF); /* TODO(Miguel Pozo) */ pass_ps.clear_stencil(0); fail_ps.init(); fail_ps.state_set(depth_fail_state); + fail_ps.state_stencil(0xFF, 0xFF, 0xFF); /* Stencil Shadow passes. */ - for (int manifold = 0; manifold < 2; manifold++) { -std::string start = manifold ? "Manifold " : "Non Manifold "; + for (bool manifold : {false, true}) { { PassMain::Sub *&ps = get_pass_ptr(true, manifold); - ps = &pass_ps.sub((start + "Pass").c_str()); + ps = &pass_ps.sub(manifold ? "manifold" : "non_manifold"); ps->shader_set(get_shader(true, manifold)); - ps->state_stencil(0xFF, 0xFF, 0xFF); } { PassMain::Sub *&ps = get_pass_ptr(false, manifold, false); - ps = &fail_ps.sub((start + "Fail No Caps").c_str()); + ps = &fail_ps.sub(manifold ? "NoCaps.manifold" : "NoCaps.non_manifold"); ps->shader_set(get_shader(false, manifold, false)); - ps->state_stencil(0xFF, 0xFF, 0xFF); } { PassMain::Sub *&ps = get_pass_ptr(false, manifold, true); - ps = &fail_ps.sub((start + "Fail Caps").c_str()); + ps = &fail_ps.sub(manifold ? "Caps.manifold" : "Caps.non_manifold"); ps->shader_set(get_shader(false, manifold, true)); } } @@ -227,8 +226,8 @@ void ShadowPass::object_sync(Manager &manager, use_shadow_pass_technique = false; } -if (true || use_shadow_pass_technique) { - PassMain::Sub &ps = get_pass_ptr(true, is_manifold)->sub(ob->id.name); +if (use_shadow_pass_technique) { + PassMain::Sub &ps = *get_pass_ptr(true, is_manifold); ps.push_constant("lightDirection", object_data.direction); ps.push_constant("lightDistance", 1e5f); ResourceHandle handle = manager.resource_handle(ob_ref); @@ -243,14 +242,14 @@ void ShadowPass::object_sync(Manager &manager, /* TODO(fclem): only use caps if they are in the view frustum. */ const bool need_caps = true; if (need_caps) { -PassMain::Sub &ps = get_pass_ptr(false, is_manifold, true)->sub(ob->id.name); +PassMain::Sub &ps = *get_pass_ptr(false, is_manifold, true); ps.push_constant("lightDirection", object_data.direction); ps.push_
[Bf-blender-cvs] [6fd43f10d7a] tmp-workbench-rewrite2: wbench next: shadows (w.i.p.)
Commit: 6fd43f10d7a3713ea8cafd38818656fbcc31a6cf Author: Miguel Pozo Date: Fri Dec 2 18:39:21 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB6fd43f10d7a3713ea8cafd38818656fbcc31a6cf wbench next: shadows (w.i.p.) === M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh M source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl M source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_private.hh A source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/engines/workbench/workbench_state.cc === diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 92d7d133f2f..c747e191e3e 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -176,6 +176,7 @@ set(SRC engines/workbench/workbench_shader.cc engines/workbench/workbench_shader_cache.cc engines/workbench/workbench_shadow.c + engines/workbench/workbench_shadow.cc engines/workbench/workbench_state.cc engines/workbench/workbench_transparent.c engines/workbench/workbench_volume.c diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh index ffa1adea180..c33218cff1b 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh @@ -51,6 +51,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_composite) .sampler(3, ImageType::FLOAT_2D, "normal_tx") .sampler(4, ImageType::FLOAT_2D, "material_tx") .sampler(5, ImageType::DEPTH_2D, "depth_tx") +.sampler(6, ImageType::UINT_2D, "stencil_tx") .uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") .push_constant(Type::BOOL, "forceShadowing") .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") @@ -72,11 +73,11 @@ GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_flat).define("WORKBENCH_LIG GPU_SHADER_CREATE_INFO(workbench_next_resolve_curvature) .define("WORKBENCH_CURVATURE") -.sampler(6, ImageType::UINT_2D, "object_id_tx"); +.sampler(7, ImageType::UINT_2D, "object_id_tx"); GPU_SHADER_CREATE_INFO(workbench_next_resolve_cavity) .define("WORKBENCH_CAVITY") -.sampler(7, ImageType::FLOAT_2D, "jitter_tx") /* TODO(Miguel Pozo): GPU_SAMPLER_REPEAT is set +.sampler(8, ImageType::FLOAT_2D, "jitter_tx") /* TODO(Miguel Pozo): GPU_SAMPLER_REPEAT is set in CavityEffect, it doesn't work here ? */ .uniform_buf(5, "float4", "cavity_samples[512]"); diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index c66e4d61233..a77af467ec8 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -19,6 +19,16 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_common) .vertex_source("workbench_shadow_vert.glsl") .additional_info("draw_mesh"); +GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) +.vertex_in(0, Type::VEC3, "pos") +.vertex_out(workbench_shadow_iface) +.push_constant(Type::FLOAT, "lightDistance") +.push_constant(Type::VEC3, "lightDirection") +.vertex_source("workbench_shadow_vert.glsl") +.additional_info("draw_view") +.additional_info("draw_modelmat_new") +.additional_info("draw_resource_handle_new"); + /** \} */ /* */ @@ -58,42 +68,64 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_debug) .fragment_out(2, Type::UINT, "objectId") .fragment_source("workbench_shadow_debug_frag.glsl"); +GPU_SHADER_CREATE_INFO(workbench_next_shadow_no_debug) +.additional_info("workbench_shadow_no_debug"); + +GPU_SHADER_CREATE_INFO(workbench_next_shadow_debug).additional_info("workbench_shadow_debug"); + /** \} */ /* -
[Bf-blender-cvs] [d20b672e01c] tmp-workbench-rewrite2: wbench next: render to image
Commit: d20b672e01c2f7b64db3a5b43d3dda1b432bd816 Author: Miguel Pozo Date: Tue Nov 29 20:18:25 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBd20b672e01c2f7b64db3a5b43d3dda1b432bd816 wbench next: render to image === M release/scripts/startup/bl_ui/properties_view_layer.py M source/blender/draw/engines/workbench/workbench_engine.cc M source/blender/draw/engines/workbench/workbench_private.hh M source/blender/draw/engines/workbench/workbench_state.cc === diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py index b18734ea98a..c45cafa07fa 100644 --- a/release/scripts/startup/bl_ui/properties_view_layer.py +++ b/release/scripts/startup/bl_ui/properties_view_layer.py @@ -44,7 +44,7 @@ class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel): class VIEWLAYER_PT_layer_passes(ViewLayerButtonsPanel, Panel): bl_label = "Passes" -COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'} +COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT', 'BLENDER_WORKBENCH_NEXT'} def draw(self, context): pass @@ -94,6 +94,23 @@ class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel): sub.active = not scene.eevee.use_motion_blur sub.prop(view_layer, "use_pass_vector") +class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel): +bl_label = "Data" +bl_parent_id = "VIEWLAYER_PT_layer_passes" + +COMPAT_ENGINES = {'BLENDER_WORKBENCH_NEXT'} + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +layout.use_property_decorate = False + +view_layer = context.view_layer + +col = layout.column() +col.prop(view_layer, "use_pass_combined") +col.prop(view_layer, "use_pass_z") + class VIEWLAYER_PT_eevee_layer_passes_light(ViewLayerButtonsPanel, Panel): bl_label = "Light" diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 0a3d89f37f0..483664b3f66 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -6,6 +6,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pbvh.h" +#include "BKE_report.h" #include "DEG_depsgraph_query.h" #include "DNA_fluid_types.h" #include "ED_paint.h" @@ -34,9 +35,9 @@ class Instance { DofPass dof_ps; AntiAliasingPass anti_aliasing_ps; - void init() + void init(Object *camera_ob = nullptr) { -scene_state.init(); +scene_state.init(camera_ob); resources.init(scene_state); outline_ps.init(scene_state); @@ -462,19 +463,201 @@ static void workbench_id_update(void *vedata, struct ID *id) UNUSED_VARS(vedata, id); } +/* RENDER */ + +static bool workbench_render_framebuffers_init(void) +{ + /* For image render, allocate own buffers because we don't have a viewport. */ + const float2 viewport_size = DRW_viewport_size_get(); + const int2 size = {int(viewport_size.x), int(viewport_size.y)}; + + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + + /* When doing a multi view rendering the first view will allocate the buffers + * the other views will reuse these buffers */ + if (dtxl->color == nullptr) { +BLI_assert(dtxl->depth == nullptr); +dtxl->color = GPU_texture_create_2d("txl.color", size.x, size.y, 1, GPU_RGBA16F, nullptr); +dtxl->depth = GPU_texture_create_2d( +"txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, nullptr); + } + + if (!(dtxl->depth && dtxl->color)) { +return false; + } + + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + + GPU_framebuffer_ensure_config( + &dfbl->default_fb, + {GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(dtxl->color)}); + + GPU_framebuffer_ensure_config(&dfbl->depth_only_fb, +{GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_NONE}); + + GPU_framebuffer_ensure_config(&dfbl->color_only_fb, +{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(dtxl->color)}); + + return GPU_framebuffer_check_valid(dfbl->default_fb, nullptr) && + GPU_framebuffer_check_valid(dfbl->color_only_fb, nullptr) && + GPU_framebuffer_check_valid(dfbl->depth_only_fb, nullptr); +} + +#ifdef DEBUG +/* This is just to ease GPU debugging when the frame delim
[Bf-blender-cvs] [cb7e36cfa58] master: Merge branch 'blender-v3.4-release'
Commit: cb7e36cfa588febfd55bd6e17b707ecbe3cd5cd1 Author: Miguel Pozo Date: Tue Nov 29 21:05:45 2022 +0100 Branches: master https://developer.blender.org/rBcb7e36cfa588febfd55bd6e17b707ecbe3cd5cd1 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6c4c09b2dfa] blender-v3.4-release: Fix T102519: GPU Subdivision : selected vertices not visible in paint mode
Commit: 6c4c09b2dfa3c657fae7187467d71a26a254fa34 Author: Miguel Pozo Date: Tue Nov 29 21:05:14 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB6c4c09b2dfa3c657fae7187467d71a26a254fa34 Fix T102519: GPU Subdivision : selected vertices not visible in paint mode Retrieve and load the vertices selected/hidden state in pos_nor extraction. Reviewed By: fclem Maniphest Tasks: T102519 Differential Revision: https://developer.blender.org/D16594 === M source/blender/draw/intern/draw_cache_impl_subdivision.cc M source/blender/draw/intern/draw_subdivision.h M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc M source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl === diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 67e498a3cc7..a225c931a14 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1408,6 +1408,7 @@ static void drw_subdiv_compute_dispatch(const DRWSubdivCache *cache, } void draw_subdiv_extract_pos_nor(const DRWSubdivCache *cache, + GPUVertBuf *flags_buffer, GPUVertBuf *pos_nor, GPUVertBuf *orco) { @@ -1460,6 +1461,10 @@ void draw_subdiv_extract_pos_nor(const DRWSubdivCache *cache, GPU_vertbuf_bind_as_ssbo(patch_arrays_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(patch_index_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(patch_param_buffer, binding_point++); + if (flags_buffer) { +GPU_vertbuf_bind_as_ssbo(flags_buffer, binding_point); + } + binding_point++; GPU_vertbuf_bind_as_ssbo(pos_nor, binding_point++); if (orco) { GPU_vertbuf_bind_as_ssbo(src_extra_buffer, binding_point++); diff --git a/source/blender/draw/intern/draw_subdivision.h b/source/blender/draw/intern/draw_subdivision.h index aeccba3bc75..5133abc9257 100644 --- a/source/blender/draw/intern/draw_subdivision.h +++ b/source/blender/draw/intern/draw_subdivision.h @@ -242,6 +242,7 @@ void draw_subdiv_finalize_custom_normals(const DRWSubdivCache *cache, GPUVertBuf *pos_nor); void draw_subdiv_extract_pos_nor(const DRWSubdivCache *cache, + GPUVertBuf *flags_buffer, struct GPUVertBuf *pos_nor, struct GPUVertBuf *orco); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc index 492756f30bb..9fd15a2309c 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc @@ -236,7 +236,7 @@ static void extract_edituv_stretch_angle_init_subdiv(const DRWSubdivCache *subdi draw_subdiv_get_pos_nor_format(), subdiv_cache->num_subdiv_loops + loose_geom.loop_len); -draw_subdiv_extract_pos_nor(subdiv_cache, pos_nor, nullptr); +draw_subdiv_extract_pos_nor(subdiv_cache, nullptr, pos_nor, nullptr); } /* UVs are stored contiguously so we need to compute the offset in the UVs buffer for the active diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc index b3bbf3b8b63..8d9e6742d61 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc @@ -200,8 +200,26 @@ static GPUVertFormat *get_custom_normals_format() return &format; } +static void extract_vertex_flags(const MeshRenderData *mr, char *flags) +{ + for (int i = 0; i < mr->vert_len; i++) { +char *flag = &flags[i]; +const bool vert_hidden = mr->hide_vert && mr->hide_vert[i]; +/* Flag for paint mode overlay. */ +if (vert_hidden || ((mr->v_origindex) && (mr->v_origindex[i] == ORIGINDEX_NONE))) { + *flag = -1; +} +else if (mr->select_vert && mr->select_vert[i]) { + *flag = 1; +} +else { + *flag = 0; +} + } +} + static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, -const MeshRenderData * /*mr*/, +const MeshRenderData *mr, MeshBatch
[Bf-blender-cvs] [eec714350fa] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2
Commit: eec714350fa71ff3e486df907ce9acc99ce394cc Author: Miguel Pozo Date: Mon Nov 28 21:18:56 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBeec714350fa71ff3e486df907ce9acc99ce394cc Merge branch 'master' into tmp-workbench-rewrite2 # Conflicts: # release/scripts/startup/bl_ui/space_userpref.py # source/blender/draw/CMakeLists.txt # source/blender/draw/engines/workbench/workbench_materials.cc # source/blender/makesdna/DNA_userdef_types.h === === diff --cc release/scripts/startup/bl_ui/space_userpref.py index 66213c12d97,11f5fdaa348..2f8a4768884 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@@ -2317,8 -2319,6 +2319,7 @@@ class USERPREF_PT_experimental_prototyp ({"property": "use_sculpt_texture_paint"}, "T96225"), ({"property": "use_full_frame_compositor"}, "T88150"), ({"property": "enable_eevee_next"}, "T93220"), +({"property": "enable_workbench_next"}, ""), - ({"property": "use_draw_manager_acquire_lock"}, "T98016"), ), ) diff --cc source/blender/draw/CMakeLists.txt index b2317025199,140354f5888..92d7d133f2f --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@@ -156,25 -158,15 +158,25 @@@ set(SR engines/eevee_next/eevee_world.cc engines/workbench/workbench_data.c engines/workbench/workbench_effect_antialiasing.c + engines/workbench/workbench_effect_antialiasing.cc engines/workbench/workbench_effect_cavity.c + engines/workbench/workbench_effect_cavity.cc engines/workbench/workbench_effect_dof.c + engines/workbench/workbench_effect_dof.cc engines/workbench/workbench_effect_outline.c + engines/workbench/workbench_effect_outline.cc engines/workbench/workbench_engine.c + engines/workbench/workbench_engine.cc - engines/workbench/workbench_materials.c engines/workbench/workbench_materials.cc ++ engines/workbench/workbench_materials_next.cc + engines/workbench/workbench_mesh_passes.cc engines/workbench/workbench_opaque.c engines/workbench/workbench_render.c + engines/workbench/workbench_resources.cc engines/workbench/workbench_shader.cc + engines/workbench/workbench_shader_cache.cc engines/workbench/workbench_shadow.c + engines/workbench/workbench_state.cc engines/workbench/workbench_transparent.c engines/workbench/workbench_volume.c engines/external/external_engine.c diff --cc source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh index 03dd3a266e4,8322d6891b7..56ad367451d --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh @@@ -7,10 -7,5 +7,11 @@@ GPU_SHADER_CREATE_INFO(workbench_merge_ .sampler(0, ImageType::DEPTH_2D, "depthBuffer") .fragment_source("workbench_merge_infront_frag.glsl") .additional_info("draw_fullscreen") + .depth_write(DepthWrite::ANY) .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(workbench_next_merge_depth) +.sampler(0, ImageType::DEPTH_2D, "depth_tx") +.fragment_source("workbench_next_merge_depth_frag.glsl") +.additional_info("draw_fullscreen") +.do_static_compilation(true); diff --cc source/blender/draw/engines/workbench/workbench_materials_next.cc index 000,000..6e4085b584e new file mode 100644 --- /dev/null +++ b/source/blender/draw/engines/workbench/workbench_materials_next.cc @@@ -1,0 -1,0 +1,94 @@@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++ ++#include "workbench_private.hh" ++ ++#include "BLI_hash.h" ++/* get_image */ ++#include "DNA_node_types.h" ++#include "ED_uvedit.h" ++//#include "BKE_image.h" ++#include "BKE_node.h" ++/* get_image */ ++ ++namespace blender::workbench { ++ ++Material::Material() = default; ++ ++Material::Material(float3 color) ++{ ++ base_color = color; ++ packed_data = Material::pack_data(0.0f, 0.4f, 1.0f); ++} ++ ++Material::Material(::Object &ob, bool random) ++{ ++ if (random) { ++uint hash = BLI_ghashutil_strhash_p_murmur(ob.id.name); ++if (ob.id.lib) { ++ hash = (hash * 13) ^ BLI_ghashutil_strhash_p_murmur(ob.id.lib->filepath); ++} ++float3 hsv = float3(BLI_hash_int_01(hash), 0.5f, 0.8f); ++hsv_to_rgb_v(hsv, base_color); ++ } ++ else { ++base_color = ob.color; ++ } ++ packed_data = Material::pack_data(0.0f, 0.4f, ob.
[Bf-blender-cvs] [b81e6ab2f0e] tmp-workbench-rewrite2: Link to Workbench Next Task in user prefs
Commit: b81e6ab2f0e455110e1ab7afaedaff3185bed7bb Author: Miguel Pozo Date: Mon Nov 28 21:22:00 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBb81e6ab2f0e455110e1ab7afaedaff3185bed7bb Link to Workbench Next Task in user prefs === M release/scripts/startup/bl_ui/space_userpref.py === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 2f8a4768884..0e0ceca32e4 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2319,7 +2319,7 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel): ({"property": "use_sculpt_texture_paint"}, "T96225"), ({"property": "use_full_frame_compositor"}, "T88150"), ({"property": "enable_eevee_next"}, "T93220"), -({"property": "enable_workbench_next"}, ""), +({"property": "enable_workbench_next"}, "T101619"), ), ) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d0e9a8c46ab] blender-v3.3-release: Fix T101533: Wrong DoF when a non-camera object is the active camera
Commit: d0e9a8c46aba056144b1bfe8ddd55cc1d6ccc56e Author: Miguel Pozo Date: Mon Nov 7 15:30:15 2022 +0100 Branches: blender-v3.3-release https://developer.blender.org/rBd0e9a8c46aba056144b1bfe8ddd55cc1d6ccc56e Fix T101533: Wrong DoF when a non-camera object is the active camera Make sure non-camera data is not casted to a Camera pointer. Solution suggested by Damien Picard (@pioverfour). === M source/blender/draw/engines/eevee/eevee_depth_of_field.c M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/workbench/workbench_effect_dof.c === diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index 0d14a0c5f61..caa63b9c54c 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -189,7 +189,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); - Camera *cam = (camera != NULL) ? camera->data : NULL; + Camera *cam = (camera != NULL && camera->type == OB_CAMERA) ? camera->data : NULL; if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) { RegionView3D *rv3d = draw_ctx->rv3d; diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 4f520e61936..bb0dd45f320 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -289,7 +289,7 @@ void GPENCIL_cache_init(void *ved) DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } - Camera *cam = (pd->camera != NULL) ? pd->camera->data : NULL; + Camera *cam = (pd->camera != NULL && pd->camera->type == OB_CAMERA) ? pd->camera->data : NULL; /* Pseudo DOF setup. */ if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) { diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index 58d49cf226e..a7247f4e9a6 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -128,7 +128,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata) camera = wpd->cam_original_ob; } - Camera *cam = camera != NULL ? camera->data : NULL; + Camera *cam = camera != NULL && camera->type == OB_CAMERA ? camera->data : NULL; if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) || ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) { wpd->dof_enabled = false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ea384fc0961] master: Merge branch 'blender-v3.4-release'
Commit: ea384fc0961247d6d665df0626f354b9db99817d Author: Miguel Pozo Date: Sun Nov 27 14:41:36 2022 +0100 Branches: master https://developer.blender.org/rBea384fc0961247d6d665df0626f354b9db99817d Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [41733a9c08e] blender-v3.4-release: Fix T102773 & T102777: Regressions in GPU Subdivision
Commit: 41733a9c08ee256293b13f4a370fc09adb915ae1 Author: Miguel Pozo Date: Sun Nov 27 14:40:00 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB41733a9c08ee256293b13f4a370fc09adb915ae1 Fix T102773 & T102777: Regressions in GPU Subdivision Introduced in D16420. SHADER_BUFFER_TRIS and SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS flags were accidentally swapped. === M source/blender/draw/intern/draw_cache_impl_subdivision.cc === diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index b99075b1edd..4a3ab9f4e38 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -289,11 +289,11 @@ static GPUShader *get_subdiv_shader(int shader_type) if (ELEM(shader_type, SHADER_BUFFER_LINES, SHADER_BUFFER_LNOR, - SHADER_BUFFER_TRIS, + SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, SHADER_BUFFER_UV_STRETCH_AREA)) { defines = "#define SUBDIV_POLYGON_OFFSET\n"; } -else if (shader_type == SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS) { +else if (shader_type == SHADER_BUFFER_TRIS) { defines = "#define SUBDIV_POLYGON_OFFSET\n" "#define SINGLE_MATERIAL\n"; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6cd441fdacd] blender-v3.4-release: Draw: GPU Subdivision: Add missing case in get_shader_code
Commit: 6cd441fdacd2d1d1f0eb746c64f586e61499b99a Author: Miguel Pozo Date: Sun Nov 27 14:40:47 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB6cd441fdacd2d1d1f0eb746c64f586e61499b99a Draw: GPU Subdivision: Add missing case in get_shader_code === M source/blender/draw/intern/draw_cache_impl_subdivision.cc === diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 4a3ab9f4e38..67e498a3cc7 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -113,7 +113,8 @@ static const char *get_shader_code(int shader_type) case SHADER_BUFFER_NORMALS_ACCUMULATE: { return datatoc_common_subdiv_normals_accumulate_comp_glsl; } -case SHADER_BUFFER_NORMALS_FINALIZE: { +case SHADER_BUFFER_NORMALS_FINALIZE: +case SHADER_BUFFER_CUSTOM_NORMALS_FINALIZE: { return datatoc_common_subdiv_normals_finalize_comp_glsl; } case SHADER_PATCH_EVALUATION: ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6422f75088a] master: Merge branch 'blender-v3.4-release'
Commit: 6422f75088aa4a75122633bc3c5fea2386295e70 Author: Miguel Pozo Date: Fri Nov 25 12:44:05 2022 +0100 Branches: master https://developer.blender.org/rB6422f75088aa4a75122633bc3c5fea2386295e70 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b918c079daf] blender-v3.4-release: Fix T101402: EEVEE: Wrong Volume transforms
Commit: b918c079daf591ce95d0951a6914f9d80c69ffcb Author: Miguel Pozo Date: Fri Nov 25 12:43:30 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rBb918c079daf591ce95d0951a6914f9d80c69ffcb Fix T101402: EEVEE: Wrong Volume transforms Ensure VolumeUniformPool uses is always incremented when retrieving a buffer in alloc(). Otherwise the same buffer will be retrieved for more than one object when incrementing the pool size. Reviewed By: fclem Maniphest Tasks: T101402 Differential Revision: https://developer.blender.org/D16607 === M source/blender/draw/intern/draw_volume.cc === diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index 5c1ce7c3111..78a7fca4e53 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -56,7 +56,6 @@ struct VolumeUniformBufPool { if (used >= ubos.size()) { VolumeInfosBuf *buf = new VolumeInfosBuf(); ubos.append(buf); - return buf; } return ubos[used++]; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1b7b996e160] master: Merge branch 'blender-v3.4-release'
Commit: 1b7b996e160c0df69d7fab4981c750344bb3bd84 Author: Miguel Pozo Date: Thu Nov 24 13:36:48 2022 +0100 Branches: master https://developer.blender.org/rB1b7b996e160c0df69d7fab4981c750344bb3bd84 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2a53e0f4376] blender-v3.4-release: FIX T102076: Add support for int attributes to draw manager.
Commit: 2a53e0f4376d8c3f91fb404893b2d4040efe3046 Author: Miguel Pozo Date: Thu Nov 24 13:29:53 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB2a53e0f4376d8c3f91fb404893b2d4040efe3046 FIX T102076: Add support for int attributes to draw manager. Add int attributes interpolation support for GPU subdivision. Ensure cached shaders match their intended defines. (The defines parameter was ignored when requesting a second time the same shader with different defines) De-duplicate the extract_attr_init code for subdiv/non-subdiv. Reviewed By: jbakker, fclem Maniphest Tasks: T102076 Differential Revision: https://developer.blender.org/D16420 === M source/blender/draw/intern/draw_cache_impl_subdivision.cc M source/blender/draw/intern/draw_subdivision.h M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc M source/blender/draw/intern/shaders/common_subdiv_custom_data_interp_comp.glsl M source/blender/gpu/GPU_vertex_format.h === diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 6a9e6c126e9..b99075b1edd 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -70,6 +70,7 @@ enum { SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, SHADER_BUFFER_NORMALS_ACCUMULATE, SHADER_BUFFER_NORMALS_FINALIZE, + SHADER_BUFFER_CUSTOM_NORMALS_FINALIZE, SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FVAR, SHADER_PATCH_EVALUATION_FACE_DOTS, @@ -88,6 +89,10 @@ enum { static GPUShader *g_subdiv_shaders[NUM_SHADERS]; +#define SHADER_CUSTOM_DATA_INTERP_MAX_DIMENSIONS 4 +static GPUShader + *g_subdiv_custom_data_shaders[SHADER_CUSTOM_DATA_INTERP_MAX_DIMENSIONS][GPU_COMP_MAX]; + static const char *get_shader_code(int shader_type) { switch (shader_type) { @@ -208,7 +213,12 @@ static GPUShader *get_patch_evaluation_shader(int shader_type) const char *compute_code = get_shader_code(shader_type); const char *defines = nullptr; -if (shader_type == SHADER_PATCH_EVALUATION_FVAR) { +if (shader_type == SHADER_PATCH_EVALUATION) { + defines = + "#define OSD_PATCH_BASIS_GLSL\n" + "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n"; +} +else if (shader_type == SHADER_PATCH_EVALUATION_FVAR) { defines = "#define OSD_PATCH_BASIS_GLSL\n" "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n" @@ -234,9 +244,7 @@ static GPUShader *get_patch_evaluation_shader(int shader_type) "#define ORCO_EVALUATION\n"; } else { - defines = - "#define OSD_PATCH_BASIS_GLSL\n" - "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n"; + BLI_assert_unreachable(); } /* Merge OpenSubdiv library code with our own library code. */ @@ -258,7 +266,7 @@ static GPUShader *get_patch_evaluation_shader(int shader_type) return g_subdiv_shaders[shader_type]; } -static GPUShader *get_subdiv_shader(int shader_type, const char *defines) +static GPUShader *get_subdiv_shader(int shader_type) { if (ELEM(shader_type, SHADER_PATCH_EVALUATION, @@ -267,14 +275,86 @@ static GPUShader *get_subdiv_shader(int shader_type, const char *defines) SHADER_PATCH_EVALUATION_ORCO)) { return get_patch_evaluation_shader(shader_type); } + + BLI_assert(!ELEM(shader_type, + SHADER_COMP_CUSTOM_DATA_INTERP_1D, + SHADER_COMP_CUSTOM_DATA_INTERP_2D, + SHADER_COMP_CUSTOM_DATA_INTERP_3D, + SHADER_COMP_CUSTOM_DATA_INTERP_4D)); + if (g_subdiv_shaders[shader_type] == nullptr) { const char *compute_code = get_shader_code(shader_type); +const char *defines = nullptr; + +if (ELEM(shader_type, + SHADER_BUFFER_LINES, + SHADER_BUFFER_LNOR, + SHADER_BUFFER_TRIS, + SHADER_BUFFER_UV_STRETCH_AREA)) { + defines = "#define SUBDIV_POLYGON_OFFSET\n"; +} +else if (shader_type == SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS) { + defines = + "#define SUBDIV_POLYGON_OFFSET\n" + "#define SINGLE_MATERIAL\n"; +} +else if (shader_type == SHADER_BUFFER_LINES_LOOSE) { + defines = "#define LINES_LOOSE\n"; +} +else if (shader_type == SHADER_BUFFER_EDGE_FAC) { +
[Bf-blender-cvs] [17e562311f9] blender-v3.4-release: Draw: Use 32-bit floats for custom color attributes
Commit: 17e562311f9f273f842bd169c22062dba0ecc618 Author: Miguel Pozo Date: Thu Nov 24 13:36:11 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB17e562311f9f273f842bd169c22062dba0ecc618 Draw: Use 32-bit floats for custom color attributes === M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc === diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 39f6fb6d9a2..f1a0636ceba 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -117,7 +117,6 @@ static GPUVertFetchMode get_fetch_mode_for_type(eCustomDataType type) case CD_PROP_INT8: case CD_PROP_INT32: return GPU_FETCH_INT_TO_FLOAT; -case CD_PROP_COLOR: case CD_PROP_BYTE_COLOR: return GPU_FETCH_INT_TO_FLOAT_UNIT; default: @@ -131,8 +130,9 @@ static GPUVertCompType get_comp_type_for_type(eCustomDataType type) case CD_PROP_INT8: case CD_PROP_INT32: return GPU_COMP_I32; -case CD_PROP_COLOR: case CD_PROP_BYTE_COLOR: + /* This should be u8, + * but u16 is required to store the color in linear space without precission loss */ return GPU_COMP_U16; default: return GPU_COMP_F32; @@ -309,7 +309,7 @@ static void extract_attr(const MeshRenderData *mr, extract_attr_generic(mr, vbo, request); break; case CD_PROP_COLOR: - extract_attr_generic(mr, vbo, request); + extract_attr_generic(mr, vbo, request); break; case CD_PROP_BYTE_COLOR: extract_attr_generic(mr, vbo, request); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [51f56e71cbf] master: Merge branch 'blender-v3.4-release'
Commit: 51f56e71cbf2e12eac910f778b1ef1a53f93d661 Author: Miguel Pozo Date: Tue Nov 22 13:41:07 2022 +0100 Branches: master https://developer.blender.org/rB51f56e71cbf2e12eac910f778b1ef1a53f93d661 Merge branch 'blender-v3.4-release' === === diff --cc source/blender/nodes/shader/node_shader_tree.cc index 188ed232858,7cdeb0c49b8..306701186db --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@@ -992,10 -984,97 +992,97 @@@ static void ntree_shader_shader_to_rgba } } + static void shader_node_disconnect_input(bNodeTree *ntree, bNode *node, int index) + { + bNodeLink *link = ntree_shader_node_input_get(node, index)->link; + if (link) { + nodeRemLink(ntree, link); + } + } + + static void shader_node_disconnect_inactive_mix_branch(bNodeTree *ntree, +bNode *node, +int factor_socket_index, +int a_socket_index, +int b_socket_index, +bool clamp_factor) + { + bNodeSocket *factor_socket = ntree_shader_node_input_get(node, factor_socket_index); + if (factor_socket->link == nullptr) { + float factor = 0.5; + + if (factor_socket->type == SOCK_FLOAT) { + factor = factor_socket->default_value_typed()->value; + if (clamp_factor) { + factor = clamp_f(factor, 0.0f, 1.0f); + } + } + else if (factor_socket->type == SOCK_VECTOR) { + const float *vfactor = factor_socket->default_value_typed()->value; + float vfactor_copy[3]; + for (int i = 0; i < 3; i++) { + if (clamp_factor) { + vfactor_copy[i] = clamp_f(vfactor[i], 0.0f, 1.0f); + } + else { + vfactor_copy[i] = vfactor[i]; + } + } + if (vfactor_copy[0] == vfactor_copy[1] && vfactor_copy[0] == vfactor_copy[2]) { + factor = vfactor_copy[0]; + } + } + + if (factor == 1.0f && a_socket_index >= 0) { + shader_node_disconnect_input(ntree, node, a_socket_index); + } + else if (factor == 0.0f && b_socket_index >= 0) { + shader_node_disconnect_input(ntree, node, b_socket_index); + } + } + } + + static void ntree_shader_disconnect_inactive_mix_branches(bNodeTree *ntree) + { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == SH_NODE_MIX_SHADER) { + shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 1, 2, true); + } + else if (node->type == SH_NODE_MIX) { + const NodeShaderMix *storage = static_cast(node->storage); + if (storage->data_type == SOCK_FLOAT) { + shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 2, 3, storage->clamp_factor); + /* Disconnect links from data_type-specific sockets that are not currently in use */ + for (int i : {1, 4, 5, 6, 7}) { + shader_node_disconnect_input(ntree, node, i); + } + } + else if (storage->data_type == SOCK_VECTOR) { + int factor_socket = storage->factor_mode == NODE_MIX_MODE_UNIFORM ? 0 : 1; + shader_node_disconnect_inactive_mix_branch( + ntree, node, factor_socket, 4, 5, storage->clamp_factor); + /* Disconnect links from data_type-specific sockets that are not currently in use */ + int unused_factor_socket = factor_socket == 0 ? 1 : 0; + for (int i : {unused_factor_socket, 2, 3, 6, 7}) { + shader_node_disconnect_input(ntree, node, i); + } + } + else if (storage->data_type == SOCK_RGBA) { + /* Branch A can't be optimized-out, since its alpha is always used regardless of factor */ + shader_node_disconnect_inactive_mix_branch(ntree, node, 0, -1, 7, storage->clamp_factor); + /* Disconnect links from data_type-specific sockets that are not currently in use */ + for (int i : {1, 2, 3, 4, 5}) { + shader_node_disconnect_input(ntree, node, i); + } + } + } + } + } + static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void * /*userdata*/) { - fromnode->tmp_flag = 1; - tonode->tmp_flag = 1; + fromnode->runtime->tmp_flag = 1; + tonode->runtime->tmp_flag = 1; return true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6d7a067a83b] blender-v3.4-release: Fix T100904: Shader Nodes: Optimize-out inactive mix branches
Commit: 6d7a067a83bbae7ebb965e364eb9a6b8d0f333f3 Author: Miguel Pozo Date: Tue Nov 22 13:39:20 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB6d7a067a83bbae7ebb965e364eb9a6b8d0f333f3 Fix T100904: Shader Nodes: Optimize-out inactive mix branches Ensure inactive mix branches don't modify material flags or generate code. Reviewed By: fclem Maniphest Tasks: T100904 Differential Revision: https://developer.blender.org/D16533 === M source/blender/nodes/shader/node_shader_tree.cc M source/blender/nodes/shader/nodes/node_shader_mix.cc === diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index f177fc95ef8..7cdeb0c49b8 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -984,6 +984,93 @@ static void ntree_shader_shader_to_rgba_branch(bNodeTree *ntree, bNode *output_n } } +static void shader_node_disconnect_input(bNodeTree *ntree, bNode *node, int index) +{ + bNodeLink *link = ntree_shader_node_input_get(node, index)->link; + if (link) { +nodeRemLink(ntree, link); + } +} + +static void shader_node_disconnect_inactive_mix_branch(bNodeTree *ntree, + bNode *node, + int factor_socket_index, + int a_socket_index, + int b_socket_index, + bool clamp_factor) +{ + bNodeSocket *factor_socket = ntree_shader_node_input_get(node, factor_socket_index); + if (factor_socket->link == nullptr) { +float factor = 0.5; + +if (factor_socket->type == SOCK_FLOAT) { + factor = factor_socket->default_value_typed()->value; + if (clamp_factor) { +factor = clamp_f(factor, 0.0f, 1.0f); + } +} +else if (factor_socket->type == SOCK_VECTOR) { + const float *vfactor = factor_socket->default_value_typed()->value; + float vfactor_copy[3]; + for (int i = 0; i < 3; i++) { +if (clamp_factor) { + vfactor_copy[i] = clamp_f(vfactor[i], 0.0f, 1.0f); +} +else { + vfactor_copy[i] = vfactor[i]; +} + } + if (vfactor_copy[0] == vfactor_copy[1] && vfactor_copy[0] == vfactor_copy[2]) { +factor = vfactor_copy[0]; + } +} + +if (factor == 1.0f && a_socket_index >= 0) { + shader_node_disconnect_input(ntree, node, a_socket_index); +} +else if (factor == 0.0f && b_socket_index >= 0) { + shader_node_disconnect_input(ntree, node, b_socket_index); +} + } +} + +static void ntree_shader_disconnect_inactive_mix_branches(bNodeTree *ntree) +{ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { +if (node->type == SH_NODE_MIX_SHADER) { + shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 1, 2, true); +} +else if (node->type == SH_NODE_MIX) { + const NodeShaderMix *storage = static_cast(node->storage); + if (storage->data_type == SOCK_FLOAT) { +shader_node_disconnect_inactive_mix_branch(ntree, node, 0, 2, 3, storage->clamp_factor); +/* Disconnect links from data_type-specific sockets that are not currently in use */ +for (int i : {1, 4, 5, 6, 7}) { + shader_node_disconnect_input(ntree, node, i); +} + } + else if (storage->data_type == SOCK_VECTOR) { +int factor_socket = storage->factor_mode == NODE_MIX_MODE_UNIFORM ? 0 : 1; +shader_node_disconnect_inactive_mix_branch( +ntree, node, factor_socket, 4, 5, storage->clamp_factor); +/* Disconnect links from data_type-specific sockets that are not currently in use */ +int unused_factor_socket = factor_socket == 0 ? 1 : 0; +for (int i : {unused_factor_socket, 2, 3, 6, 7}) { + shader_node_disconnect_input(ntree, node, i); +} + } + else if (storage->data_type == SOCK_RGBA) { +/* Branch A can't be optimized-out, since its alpha is always used regardless of factor */ +shader_node_disconnect_inactive_mix_branch(ntree, node, 0, -1, 7, storage->clamp_factor); +/* Disconnect links from data_type-specific sockets that are not currently in use */ +for (int i : {1, 2, 3, 4, 5}) { + shader_node_disconnect_input(ntree, node, i); +} + } +} + } +} + static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void * /*userdata*/) { fromnode->tmp_flag = 1; @@ -996,6 +1083,8 @@ static bool ntree_branch_node_tag(bNode *fromnode, bNode *tonode, void * /*userd * fir
[Bf-blender-cvs] [b8fd474bb1b] master: Merge branch 'blender-v3.4-release'
Commit: b8fd474bb1b00f025f39422ff142514a14be11b3 Author: Miguel Pozo Date: Tue Nov 15 18:41:24 2022 +0100 Branches: master https://developer.blender.org/rBb8fd474bb1b00f025f39422ff142514a14be11b3 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8831c6f0561] blender-v3.4-release: Fix T101965: Shadow bounds ignore the light Volume Factor
Commit: 8831c6f05618f5405c092449ab514136bfc6f4d7 Author: Miguel Pozo Date: Tue Nov 15 18:40:58 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB8831c6f05618f5405c092449ab514136bfc6f4d7 Fix T101965: Shadow bounds ignore the light Volume Factor Take invsqrdist_volume into account for computing shadow bounds. Reviewed By: fclem Maniphest Tasks: T101965 Differential Revision: https://developer.blender.org/D16513 === M source/blender/draw/engines/eevee/eevee_shadows_cube.c === diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cube.c b/source/blender/draw/engines/eevee/eevee_shadows_cube.c index df9ee253317..b18644c7d98 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows_cube.c +++ b/source/blender/draw/engines/eevee/eevee_shadows_cube.c @@ -38,7 +38,7 @@ void EEVEE_shadows_cube_add(EEVEE_LightsInfo *linfo, EEVEE_Light *evli, Object * /* Saving light bounds for later. */ BoundSphere *cube_bound = linfo->shadow_bounds + linfo->cube_len; copy_v3_v3(cube_bound->center, evli->position); - cube_bound->radius = sqrt(1.0f / evli->invsqrdist); + cube_bound->radius = sqrt(1.0f / min_ff(evli->invsqrdist, evli->invsqrdist_volume)); linfo->shadow_cube_light_indices[linfo->cube_len] = linfo->num_light; evli->shadow_id = linfo->shadow_len++; @@ -87,7 +87,7 @@ bool EEVEE_shadows_cube_setup(EEVEE_LightsInfo *linfo, const EEVEE_Light *evli, eevee_light_matrix_get(evli, cube_data->shadowmat); - shdw_data->far = max_ff(sqrt(1.0f / evli->invsqrdist), 3e-4); + shdw_data->far = max_ff(sqrt(1.0f / min_ff(evli->invsqrdist, evli->invsqrdist_volume)), 3e-4); shdw_data->near = min_ff(shdw_data->near, shdw_data->far - 1e-4); bool update = false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [191a3bf2ad0] master: Merge branch 'blender-v3.4-release'
Commit: 191a3bf2ad0d5383160b6bbd1dc99b024d70297f Author: Miguel Pozo Date: Tue Nov 15 13:05:49 2022 +0100 Branches: master https://developer.blender.org/rB191a3bf2ad0d5383160b6bbd1dc99b024d70297f Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d2728868c01] master: GPU: Improve Codegen variable names
Commit: d2728868c01d97540c9e5cd24adcf5f0ae6b232a Author: Miguel Pozo Date: Tue Nov 15 13:06:58 2022 +0100 Branches: master https://developer.blender.org/rBd2728868c01d97540c9e5cd24adcf5f0ae6b232a GPU: Improve Codegen variable names Include the node name and parameter index in the variable name for easier debugging. (Enabled for debug builds only) Reviewed By: fclem, jbakker Differential Revision: https://developer.blender.org/D16496 === M source/blender/gpu/intern/gpu_codegen.cc === diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 42b2151e75b..465a621e864 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -169,14 +169,22 @@ static bool gpu_pass_is_valid(GPUPass *pass) /** \name Type > string conversion * \{ */ +#ifdef DEBUG +# define SRC_NAME(io, link, list, type) \ +link->node->name << "_" << io << BLI_findindex(&link->node->list, (const void *)link) << "_" \ + << type +#else +# define SRC_NAME(io, list, link, type) type +#endif + static std::ostream &operator<<(std::ostream &stream, const GPUInput *input) { switch (input->source) { case GPU_SOURCE_FUNCTION_CALL: case GPU_SOURCE_OUTPUT: - return stream << "tmp" << input->id; + return stream << SRC_NAME("in", input, inputs, "tmp") << input->id; case GPU_SOURCE_CONSTANT: - return stream << "cons" << input->id; + return stream << SRC_NAME("in", input, inputs, "cons") << input->id; case GPU_SOURCE_UNIFORM: return stream << "node_tree.u" << input->id; case GPU_SOURCE_ATTR: @@ -199,7 +207,7 @@ static std::ostream &operator<<(std::ostream &stream, const GPUInput *input) static std::ostream &operator<<(std::ostream &stream, const GPUOutput *output) { - return stream << "tmp" << output->id; + return stream << SRC_NAME("out", output, outputs, "tmp") << output->id; } /* Trick type to change overload and keep a somewhat nice syntax. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [21eeedfc60b] blender-v3.4-release: Fix T101562: GPU: Update fmod to match Cycles/OSL behavior
Commit: 21eeedfc60b5ea8603a5c74235e736c9d0378aa8 Author: Miguel Pozo Date: Tue Nov 15 13:04:47 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB21eeedfc60b5ea8603a5c74235e736c9d0378aa8 Fix T101562: GPU: Update fmod to match Cycles/OSL behavior Implementation from: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/include/OSL/dual.h#L1283 https://github.com/OpenImageIO/oiio/blob/master/src/include/OpenImageIO/fmath.h#L1605 Reviewed By: fclem Maniphest Tasks: T101562 Differential Revision: https://developer.blender.org/D16497 === M source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl === diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl index 47f8e26db0b..ca9c42f2027 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl @@ -5,11 +5,14 @@ float safe_divide(float a, float b) return (b != 0.0) ? a / b : 0.0; } -/* fmod function compatible with OSL using nvidia reference example. */ +/* fmod function compatible with OSL (copy from OSL/dual.h) */ float compatible_fmod(float a, float b) { - float c = (b != 0.0) ? fract(abs(a / b)) * abs(b) : 0.0; - return (a < 0.0) ? -c : c; + if (b != 0.0f) { +int N = int(a / b); +return a - N * b; + } + return 0.0f; } float compatible_pow(float x, float y) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6a96edce2ed] master: Merge branch 'blender-v3.4-release'
Commit: 6a96edce2ed1cededbb7f90e3f02e175a4b298db Author: Miguel Pozo Date: Mon Nov 14 12:24:45 2022 +0100 Branches: master https://developer.blender.org/rB6a96edce2ed1cededbb7f90e3f02e175a4b298db Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a84c92fc73d] blender-v3.4-release: Fix T98989: Performance regression when using multiple bump nodes
Commit: a84c92fc73d3298c1456ffb26c1e73cd67b56e6d Author: Miguel Pozo Date: Mon Nov 14 12:21:37 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rBa84c92fc73d3298c1456ffb26c1e73cd67b56e6d Fix T98989: Performance regression when using multiple bump nodes Ensure each graph material_function only evaluates the input links that are connected to it. Differential Revision: https://developer.blender.org/D16425 === M source/blender/gpu/intern/gpu_codegen.cc M source/blender/gpu/intern/gpu_node_graph.c M source/blender/gpu/intern/gpu_node_graph.h === diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 4adeac1b49a..42b2151e75b 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -620,11 +620,21 @@ void GPUCodegen::generate_graphs() std::stringstream eval_ss; eval_ss << "\n/* Generated Functions */\n\n"; LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, func_link, &graph.material_functions) { + /* Untag every node in the graph to avoid serializing nodes from other functions */ + LISTBASE_FOREACH (GPUNode *, node, &graph.nodes) { +node->tag &= ~GPU_NODE_TAG_FUNCTION; + } + /* Tag only the nodes needed for the current function */ + gpu_nodes_tag(func_link->outlink, GPU_NODE_TAG_FUNCTION); char *fn = graph_serialize(GPU_NODE_TAG_FUNCTION, func_link->outlink); eval_ss << "float " << func_link->name << "() {\n" << fn << "}\n\n"; MEM_SAFE_FREE(fn); } output.material_functions = extract_c_str(eval_ss); +/* Leave the function tags as they were before serialization */ +LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, funclink, &graph.material_functions) { + gpu_nodes_tag(funclink->outlink, GPU_NODE_TAG_FUNCTION); +} } LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph.attributes) { diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index c72e7097b33..14dfce6ce5e 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -890,7 +890,7 @@ void gpu_node_graph_free(GPUNodeGraph *graph) /* Prune Unused Nodes */ -static void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag) +void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag) { GPUNode *node; diff --git a/source/blender/gpu/intern/gpu_node_graph.h b/source/blender/gpu/intern/gpu_node_graph.h index de0a0687b13..9f919f04160 100644 --- a/source/blender/gpu/intern/gpu_node_graph.h +++ b/source/blender/gpu/intern/gpu_node_graph.h @@ -66,7 +66,7 @@ typedef enum { GPU_NODE_TAG_COMPOSITOR = (1 << 6), } eGPUNodeTag; -ENUM_OPERATORS(eGPUNodeTag, GPU_NODE_TAG_FUNCTION) +ENUM_OPERATORS(eGPUNodeTag, GPU_NODE_TAG_COMPOSITOR) struct GPUNode { struct GPUNode *next, *prev; @@ -186,6 +186,7 @@ typedef struct GPUNodeGraph { /* Node Graph */ +void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag); void gpu_node_graph_prune_unused(GPUNodeGraph *graph); void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [acaa736037e] master: Fix: GPU: Set the last enum in ENUM_OPERATORS
Commit: acaa736037eef7d36d5501622a282169d1bf2a4e Author: Miguel Pozo Date: Thu Nov 10 17:43:53 2022 +0100 Branches: master https://developer.blender.org/rBacaa736037eef7d36d5501622a282169d1bf2a4e Fix: GPU: Set the last enum in ENUM_OPERATORS === M source/blender/gpu/intern/gpu_node_graph.h === diff --git a/source/blender/gpu/intern/gpu_node_graph.h b/source/blender/gpu/intern/gpu_node_graph.h index de0a0687b13..2f617713749 100644 --- a/source/blender/gpu/intern/gpu_node_graph.h +++ b/source/blender/gpu/intern/gpu_node_graph.h @@ -66,7 +66,7 @@ typedef enum { GPU_NODE_TAG_COMPOSITOR = (1 << 6), } eGPUNodeTag; -ENUM_OPERATORS(eGPUNodeTag, GPU_NODE_TAG_FUNCTION) +ENUM_OPERATORS(eGPUNodeTag, GPU_NODE_TAG_COMPOSITOR) struct GPUNode { struct GPUNode *next, *prev; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs