diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-01-17 16:34:28 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-17 16:34:28 +0300 |
commit | edee5a947b7ea3e1324aa334a22c7c9bbf47f5f7 (patch) | |
tree | b8f15e66277700ccdc5d6c8b7c7eb3728f91182f /source/blender/draw/intern | |
parent | 8fb2ff458ba579dba08bfdf57d043ad158b5db07 (diff) |
Revert "GPUShaderCreateInfo for interface abstraction"
This reverts commit 8fb2ff458ba579dba08bfdf57d043ad158b5db07.
Missing some files.
Diffstat (limited to 'source/blender/draw/intern')
8 files changed, 9 insertions, 133 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 276a8cc3a13..7365ebf59c2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -70,7 +70,6 @@ #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_matrix.h" -#include "GPU_shader_shared.h" #include "GPU_state.h" #include "GPU_uniform_buffer.h" #include "GPU_viewport.h" @@ -2757,15 +2756,11 @@ void DRW_draw_depth_object( GPU_framebuffer_clear_depth(depth_fb, 1.0f); GPU_depth_test(GPU_DEPTH_LESS_EQUAL); - struct GPUClipPlanes planes; - const bool use_clipping_planes = RV3D_CLIPPING_ENABLED(v3d, rv3d); - if (use_clipping_planes) { + const float(*world_clip_planes)[4] = NULL; + if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { GPU_clip_distances(6); ED_view3d_clipping_local(rv3d, object->obmat); - for (int i = 0; i < 6; i++) { - copy_v4_v4(planes.world[i], rv3d->clip_local[i]); - } - copy_m4_m4(planes.ModelMatrix, object->obmat); + world_clip_planes = rv3d->clip_local; } drw_batch_cache_validate(object); @@ -2787,19 +2782,14 @@ void DRW_draw_depth_object( BLI_task_graph_work_and_wait(task_graph); BLI_task_graph_free(task_graph); - const eGPUShaderConfig sh_cfg = use_clipping_planes ? GPU_SHADER_CFG_CLIPPED : - GPU_SHADER_CFG_DEFAULT; + const eGPUShaderConfig sh_cfg = world_clip_planes ? GPU_SHADER_CFG_CLIPPED : + GPU_SHADER_CFG_DEFAULT; GPU_batch_program_set_builtin_with_config(batch, GPU_SHADER_3D_DEPTH_ONLY, sh_cfg); - - GPUUniformBuf *ubo = NULL; - if (use_clipping_planes) { - ubo = GPU_uniformbuf_create_ex(sizeof(struct GPUClipPlanes), &planes, __func__); - GPU_batch_uniformbuf_bind(batch, "clipPlanes", ubo); + if (world_clip_planes != NULL) { + GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes); } GPU_batch_draw(batch); - GPU_uniformbuf_free(ubo); - } break; case OB_CURVE: case OB_SURF: diff --git a/source/blender/draw/intern/draw_shader_shared.h b/source/blender/draw/intern/draw_shader_shared.h deleted file mode 100644 index aa117f44e84..00000000000 --- a/source/blender/draw/intern/draw_shader_shared.h +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef GPU_SHADER -# include "gpu_shader_shared_utils.h" -#endif - -#define DRW_SHADER_SHARED_H - -#define DRW_RESOURCE_CHUNK_LEN 512 - -struct ViewInfos { - /* View matrices */ - float4x4 persmat; - float4x4 persinv; - float4x4 viewmat; - float4x4 viewinv; - float4x4 winmat; - float4x4 wininv; - - float4 clipplanes[6]; - float4 viewvecs[2]; - /* Should not be here. Not view dependent (only main view). */ - float4 viewcamtexcofac; -}; -BLI_STATIC_ASSERT_ALIGN(ViewInfos, 16) - -/* TODO(fclem) Mass rename. */ -#define ViewProjectionMatrix drw_view.persmat -#define ViewProjectionMatrixInverse drw_view.persinv -#define ViewMatrix drw_view.viewmat -#define ViewMatrixInverse drw_view.viewinv -#define ProjectionMatrix drw_view.winmat -#define ProjectionMatrixInverse drw_view.wininv -#define clipPlanes drw_view.clipplanes -#define ViewVecs drw_view.viewvecs -#define CameraTexCoFactors drw_view.viewcamtexcofac - -struct ObjectMatrices { - float4x4 drw_modelMatrix; - float4x4 drw_modelMatrixInverse; -}; -BLI_STATIC_ASSERT_ALIGN(ViewInfos, 16) diff --git a/source/blender/draw/intern/shaders/common_fullscreen_vert.glsl b/source/blender/draw/intern/shaders/common_fullscreen_vert.glsl index 53ec38fea0b..8a7fb97d98c 100644 --- a/source/blender/draw/intern/shaders/common_fullscreen_vert.glsl +++ b/source/blender/draw/intern/shaders/common_fullscreen_vert.glsl @@ -1,7 +1,5 @@ -#ifndef USE_GPU_SHADER_CREATE_INFO out vec4 uvcoordsvar; -#endif void main() { diff --git a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl index 2da16d3f6a9..74b989441a2 100644 --- a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl +++ b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl @@ -2,8 +2,6 @@ /* NOTE: To be used with UNIFORM_RESOURCE_ID and INSTANCED_ATTR as define. */ #pragma BLENDER_REQUIRE(common_view_lib.glsl) -#ifndef DRW_SHADER_SHARED_H - in vec4 pos; /* Position and radius. */ /* ---- Instanced attribs ---- */ @@ -11,8 +9,6 @@ in vec4 pos; /* Position and radius. */ in vec3 pos_inst; in vec3 nor; -#endif - mat3 pointcloud_get_facing_matrix(vec3 p) { mat3 facing_mat; diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl b/source/blender/draw/intern/shaders/common_view_lib.glsl index b0d405165f2..e9912ba7d9a 100644 --- a/source/blender/draw/intern/shaders/common_view_lib.glsl +++ b/source/blender/draw/intern/shaders/common_view_lib.glsl @@ -1,7 +1,5 @@ -/* Temporary until we fully make the switch. */ -#ifndef DRW_SHADER_SHARED_H - -# define DRW_RESOURCE_CHUNK_LEN 512 +#define COMMON_VIEW_LIB +#define DRW_RESOURCE_CHUNK_LEN 512 /* keep in sync with DRWManager.view_data */ layout(std140) uniform viewBlock @@ -24,8 +22,6 @@ layout(std140) uniform viewBlock vec4 CameraTexCoFactors; }; -#endif /* DRW_SHADER_SHARED_H */ - #define ViewNear (ViewVecs[0].w) #define ViewFar (ViewVecs[1].w) @@ -145,10 +141,6 @@ flat in int resourceIDFrag; /* clang-format off */ #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTR) /* clang-format on */ - -/* Temporary until we fully make the switch. */ -# ifndef DRW_SHADER_SHARED_H - struct ObjectMatrices { mat4 drw_modelMatrix; mat4 drw_modelMatrixInverse; @@ -158,23 +150,17 @@ layout(std140) uniform modelBlock { ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN]; }; -# endif /* DRW_SHADER_SHARED_H */ # define ModelMatrix (drw_matrices[resource_id].drw_modelMatrix) # define ModelMatrixInverse (drw_matrices[resource_id].drw_modelMatrixInverse) #else /* GPU_INTEL */ - -/* Temporary until we fully make the switch. */ -# ifndef DRW_SHADER_SHARED_H /* Intel GPU seems to suffer performance impact when the model matrix is in UBO storage. * So for now we just force using the legacy path. */ /* Note that this is also a workaround of a problem on osx (amd or nvidia) * and older amd driver on windows. */ uniform mat4 ModelMatrix; uniform mat4 ModelMatrixInverse; -# endif /* DRW_SHADER_SHARED_H */ - #endif #define resource_handle (resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id) diff --git a/source/blender/draw/intern/shaders/draw_fullscreen_info.hh b/source/blender/draw/intern/shaders/draw_fullscreen_info.hh deleted file mode 100644 index 803ad69ffb7..00000000000 --- a/source/blender/draw/intern/shaders/draw_fullscreen_info.hh +++ /dev/null @@ -1,8 +0,0 @@ - -#include "gpu_shader_create_info.hh" - -GPU_SHADER_INTERFACE_INFO(fullscreen_iface, "").smooth(Type::VEC4, "uvcoordsvar"); - -GPU_SHADER_CREATE_INFO(draw_fullscreen) - .vertex_out(fullscreen_iface) - .vertex_source("common_fullscreen_vert.glsl"); diff --git a/source/blender/draw/intern/shaders/draw_object_infos_info.hh b/source/blender/draw/intern/shaders/draw_object_infos_info.hh deleted file mode 100644 index 10b3754eebb..00000000000 --- a/source/blender/draw/intern/shaders/draw_object_infos_info.hh +++ /dev/null @@ -1,5 +0,0 @@ - -#include "gpu_shader_create_info.hh" - -GPU_SHADER_CREATE_INFO(draw_object_infos) - .uniform_buf(1, "ObjectInfos", "drw_infos[DRW_RESOURCE_CHUNK_LEN]", Frequency::BATCH); diff --git a/source/blender/draw/intern/shaders/draw_view_info.hh b/source/blender/draw/intern/shaders/draw_view_info.hh deleted file mode 100644 index a92284efa5b..00000000000 --- a/source/blender/draw/intern/shaders/draw_view_info.hh +++ /dev/null @@ -1,40 +0,0 @@ - -#include "gpu_shader_create_info.hh" - -/* -------------------------------------------------------------------- */ -/** \name Draw View - * \{ */ - -GPU_SHADER_CREATE_INFO(draw_view) - .uniform_buf(0, "ViewInfos", "drw_view", Frequency::PASS) - .typedef_source("draw_shader_shared.h"); - -GPU_SHADER_CREATE_INFO(draw_view_instanced_attr) - .push_constant(0, Type::MAT4, "ModelMatrix") - .push_constant(16, Type::MAT4, "ModelMatrixInverse") - .additional_info("draw_view"); - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Geometry Type - * \{ */ - -GPU_SHADER_CREATE_INFO(draw_mesh) - .uniform_buf(8, "ObjectMatrices", "drw_matrices[DRW_RESOURCE_CHUNK_LEN]", Frequency::BATCH) - .additional_info("draw_view"); - -GPU_SHADER_CREATE_INFO(draw_hair) - /* TODO(fclem) Finish */ - .uniform_buf(8, "ObjectMatrices", "drw_matrices[DRW_RESOURCE_CHUNK_LEN]", Frequency::BATCH) - .additional_info("draw_view"); - -GPU_SHADER_CREATE_INFO(draw_pointcloud) - .vertex_in(0, Type::VEC4, "pos") - .vertex_in(1, Type::VEC3, "pos_inst") - .vertex_in(2, Type::VEC3, "nor") - .define("UNIFORM_RESOURCE_ID") - .define("INSTANCED_ATTR") - .additional_info("draw_view_instanced_attr"); - -/** \} */ |