SubDiv: Add base for polygon offset

Subdiv shader library contains an optional part that shaders can include.
As we are migrating each shader at a time there are now multiple PRs doing
the same thing. Best to add the changes to main already so it doesn't add
confusion during review.

Pull Request: https://projects.blender.org/blender/blender/pulls/134906
This commit is contained in:
Jeroen Bakker
2025-02-21 10:21:44 +01:00
parent d0ade434f7
commit 3969e30c6f
5 changed files with 16 additions and 3 deletions

View File

@@ -187,6 +187,8 @@ set(SRC
intern/draw_view.hh
intern/draw_view_c.hh
intern/draw_view_data.hh
intern/draw_subdiv_defines.hh
intern/draw_subdiv_shader_shared.hh
intern/mesh_extractors/extract_mesh.hh
engines/compositor/compositor_engine.h
engines/eevee_next/eevee_ambient_occlusion.hh

View File

@@ -361,9 +361,6 @@ GPUShader *DRW_shader_subdiv_get(SubdivShaderType shader_type)
defines = "#define GPU_AMD_DRIVER_BYTE_BUG\n";
}
}
else if (shader_type == SubdivShaderType::BUFFER_CUSTOM_NORMALS_FINALIZE) {
defines = "#define CUSTOM_NORMALS\n";
}
e_data.subdiv_sh[uint(shader_type)] = GPU_shader_create_compute(
compute_code, datatoc_subdiv_lib_glsl, defines, get_subdiv_shader_name(shader_type));

View File

@@ -16,6 +16,8 @@
#define SHADER_DATA_BUF_SLOT 0
/* Storage buffer bindings */
#define SUBDIV_FACE_OFFSET_BUF_SLOT 0
#define NORMALS_FINALIZE_VERTEX_NORMALS_BUF_SLOT 0
#define NORMALS_FINALIZE_VERTEX_LOOP_MAP_BUF_SLOT 1
#define NORMALS_FINALIZE_POS_NOR_BUF_SLOT 2

View File

@@ -19,6 +19,12 @@ TYPEDEF_SOURCE("draw_subdiv_shader_shared.hh")
UNIFORM_BUF(SHADER_DATA_BUF_SLOT, DRWSubdivUboStorage, shader_data)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(subdiv_polygon_offset_base)
DEFINE("SUBDIV_POLYGON_OFFSET")
STORAGE_BUF(SUBDIV_FACE_OFFSET_BUF_SLOT, READ, uint, subdiv_face_offset[])
ADDITIONAL_INFO(subdiv_base)
GPU_SHADER_CREATE_END()
/* -------------------------------------------------------------------- */
/** \name Normals Finalize
* \{ */

View File

@@ -8,7 +8,11 @@
#ifdef USE_GPU_SHADER_CREATE_INFO
/* TODO: Do not use compute variables directly in a library. */
# ifdef SUBDIV_POLYGON_OFFSET
COMPUTE_SHADER_CREATE_INFO(subdiv_polygon_offset_base)
# else
COMPUTE_SHADER_CREATE_INFO(subdiv_base)
# endif
#else
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
@@ -210,4 +214,6 @@ uint coarse_face_index_from_subdiv_quad_index(uint subdiv_quad_index, uint coars
return first - 1;
}
#else
uint coarse_face_index_from_subdiv_quad_index(uint subdiv_quad_index, uint coarse_face_count);
#endif