GPU: Shader Create Info GLSL-C++ stubs #3

Closed
Clément Foucault wants to merge 90 commits from create-info-cpp-macros into glsl-include

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 252 additions and 297 deletions
Showing only changes of commit 34fc5cedf6 - Show all commits

View File

@ -12,25 +12,21 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_debug_print) GPU_SHADER_CREATE_INFO(draw_debug_print)
DEFINE("DRW_DEBUG_PRINT") .define("DRW_DEBUG_PRINT")
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
STORAGE_BUF(DRW_DEBUG_PRINT_SLOT, READ_WRITE, uint, drw_debug_print_buf[]) .storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ_WRITE, "uint", "drw_debug_print_buf[]");
GPU_SHADER_CREATE_END()
GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface) GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface).flat(Type::UINT, "char_index");
FLAT(UINT, char_index)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(draw_debug_print_display) GPU_SHADER_CREATE_INFO(draw_debug_print_display)
DO_STATIC_COMPILATION() .do_static_compilation(true)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
STORAGE_BUF(DRW_DEBUG_PRINT_SLOT, READ, uint, drw_debug_print_buf[]) .storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ, "uint", "drw_debug_print_buf[]")
VERTEX_OUT(draw_debug_print_display_iface) .vertex_out(draw_debug_print_display_iface)
FRAGMENT_OUT(0, VEC4, out_color) .fragment_out(0, Type::VEC4, "out_color")
PUSH_CONSTANT(VEC2, viewport_size) .push_constant(Type::VEC2, "viewport_size")
VERTEX_SOURCE("draw_debug_print_display_vert.glsl") .vertex_source("draw_debug_print_display_vert.glsl")
FRAGMENT_SOURCE("draw_debug_print_display_frag.glsl") .fragment_source("draw_debug_print_display_frag.glsl");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -41,24 +37,23 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_debug_draw) GPU_SHADER_CREATE_INFO(draw_debug_draw)
DEFINE("DRW_DEBUG_DRAW") .define("DRW_DEBUG_DRAW")
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
STORAGE_BUF(DRW_DEBUG_DRAW_SLOT, READ_WRITE, DRWDebugVert, drw_debug_verts_buf[]) .storage_buf(DRW_DEBUG_DRAW_SLOT,
GPU_SHADER_CREATE_END() Qualifier::READ_WRITE,
"DRWDebugVert",
"drw_debug_verts_buf[]");
GPU_SHADER_NAMED_INTERFACE_INFO(draw_debug_draw_display_iface, interp) GPU_SHADER_NAMED_INTERFACE_INFO(draw_debug_draw_display_iface, interp).flat(Type::VEC4, "color");
FLAT(VEC4, color)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(draw_debug_draw_display) GPU_SHADER_CREATE_INFO(draw_debug_draw_display)
DO_STATIC_COMPILATION() .do_static_compilation(true)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
STORAGE_BUF(DRW_DEBUG_DRAW_SLOT, READ, DRWDebugVert, drw_debug_verts_buf[]) .storage_buf(DRW_DEBUG_DRAW_SLOT, Qualifier::READ, "DRWDebugVert", "drw_debug_verts_buf[]")
VERTEX_OUT(draw_debug_draw_display_iface) .vertex_out(draw_debug_draw_display_iface)
FRAGMENT_OUT(0, VEC4, out_color) .fragment_out(0, Type::VEC4, "out_color")
PUSH_CONSTANT(MAT4, persmat) .push_constant(Type::MAT4, "persmat")
VERTEX_SOURCE("draw_debug_draw_display_vert.glsl") .vertex_source("draw_debug_draw_display_vert.glsl")
FRAGMENT_SOURCE("draw_debug_draw_display_frag.glsl") .fragment_source("draw_debug_draw_display_frag.glsl");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */

View File

@ -4,11 +4,8 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_INTERFACE_INFO(fullscreen_iface) GPU_SHADER_INTERFACE_INFO(fullscreen_iface).smooth(Type::VEC4, "uvcoordsvar");
SMOOTH(VEC4, uvcoordsvar)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(draw_fullscreen) GPU_SHADER_CREATE_INFO(draw_fullscreen)
VERTEX_OUT(fullscreen_iface) .vertex_out(fullscreen_iface)
VERTEX_SOURCE("common_fullscreen_vert.glsl") .vertex_source("common_fullscreen_vert.glsl");
GPU_SHADER_CREATE_END()

View File

@ -9,22 +9,21 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(draw_hair_refine_compute) GPU_SHADER_CREATE_INFO(draw_hair_refine_compute)
LOCAL_GROUP_SIZE(1, 1) .local_group_size(1, 1)
STORAGE_BUF(0, WRITE, vec4, posTime[]) .storage_buf(0, Qualifier::WRITE, "vec4", "posTime[]")
SAMPLER(0, FLOAT_BUFFER, hairPointBuffer) .sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer")
SAMPLER(1, UINT_BUFFER, hairStrandBuffer) .sampler(1, ImageType::UINT_BUFFER, "hairStrandBuffer")
SAMPLER(2, UINT_BUFFER, hairStrandSegBuffer) .sampler(2, ImageType::UINT_BUFFER, "hairStrandSegBuffer")
PUSH_CONSTANT(MAT4, hairDupliMatrix) .push_constant(Type::MAT4, "hairDupliMatrix")
PUSH_CONSTANT(BOOL, hairCloseTip) .push_constant(Type::BOOL, "hairCloseTip")
PUSH_CONSTANT(FLOAT, hairRadShape) .push_constant(Type::FLOAT, "hairRadShape")
PUSH_CONSTANT(FLOAT, hairRadTip) .push_constant(Type::FLOAT, "hairRadTip")
PUSH_CONSTANT(FLOAT, hairRadRoot) .push_constant(Type::FLOAT, "hairRadRoot")
PUSH_CONSTANT(INT, hairThicknessRes) .push_constant(Type::INT, "hairThicknessRes")
PUSH_CONSTANT(INT, hairStrandsRes) .push_constant(Type::INT, "hairStrandsRes")
PUSH_CONSTANT(INT, hairStrandOffset) .push_constant(Type::INT, "hairStrandOffset")
COMPUTE_SOURCE("common_hair_refine_comp.glsl") .compute_source("common_hair_refine_comp.glsl")
DEFINE("HAIR_PHASE_SUBDIV") .define("HAIR_PHASE_SUBDIV")
DEFINE("HAIR_SHADER") .define("HAIR_SHADER")
DEFINE("DRW_HAIR_INFO") .define("DRW_HAIR_INFO")
DO_STATIC_COMPILATION() .do_static_compilation(true);
GPU_SHADER_CREATE_END()

View File

@ -6,49 +6,46 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(draw_object_infos) GPU_SHADER_CREATE_INFO(draw_object_infos)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
DEFINE("OBINFO_LIB") .define("OBINFO_LIB")
DEFINE_VALUE("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") .define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)")
DEFINE_VALUE("ObjectInfo", "(drw_infos[resource_id].infos)") .define("ObjectInfo", "(drw_infos[resource_id].infos)")
DEFINE_VALUE("ObjectColor", "(drw_infos[resource_id].ob_color)") .define("ObjectColor", "(drw_infos[resource_id].ob_color)")
UNIFORM_BUF_FREQ(DRW_OBJ_INFOS_UBO_SLOT, ObjectInfos, drw_infos[DRW_RESOURCE_CHUNK_LEN], BATCH) .uniform_buf(DRW_OBJ_INFOS_UBO_SLOT,
GPU_SHADER_CREATE_END() "ObjectInfos",
"drw_infos[DRW_RESOURCE_CHUNK_LEN]",
Frequency::BATCH);
GPU_SHADER_CREATE_INFO(draw_volume_infos) GPU_SHADER_CREATE_INFO(draw_volume_infos)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
DEFINE("VOLUME_INFO_LIB") .define("VOLUME_INFO_LIB")
UNIFORM_BUF_FREQ(DRW_OBJ_DATA_INFO_UBO_SLOT, VolumeInfos, drw_volume, BATCH) .uniform_buf(DRW_OBJ_DATA_INFO_UBO_SLOT, "VolumeInfos", "drw_volume", Frequency::BATCH);
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_curves_infos) GPU_SHADER_CREATE_INFO(draw_curves_infos)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
UNIFORM_BUF_FREQ(DRW_OBJ_DATA_INFO_UBO_SLOT, CurvesInfos, drw_curves, BATCH) .uniform_buf(DRW_OBJ_DATA_INFO_UBO_SLOT, "CurvesInfos", "drw_curves", Frequency::BATCH);
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_layer_attributes) GPU_SHADER_CREATE_INFO(draw_layer_attributes)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
DEFINE("VLATTR_LIB") .define("VLATTR_LIB")
UNIFORM_BUF_FREQ(DRW_LAYER_ATTR_UBO_SLOT, .uniform_buf(DRW_LAYER_ATTR_UBO_SLOT,
LayerAttribute, "LayerAttribute",
drw_layer_attrs[DRW_RESOURCE_CHUNK_LEN], "drw_layer_attrs[DRW_RESOURCE_CHUNK_LEN]",
BATCH) Frequency::BATCH);
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_object_infos_new) GPU_SHADER_CREATE_INFO(draw_object_infos_new)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
DEFINE("OBINFO_LIB") .define("OBINFO_LIB")
DEFINE("OBINFO_NEW") .define("OBINFO_NEW")
DEFINE_VALUE("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") .define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)")
DEFINE_VALUE("ObjectInfo", "(drw_infos[resource_id].infos)") .define("ObjectInfo", "(drw_infos[resource_id].infos)")
DEFINE_VALUE("ObjectColor", "(drw_infos[resource_id].ob_color)") .define("ObjectColor", "(drw_infos[resource_id].ob_color)")
STORAGE_BUF(DRW_OBJ_INFOS_SLOT, READ, ObjectInfos, drw_infos[]) .storage_buf(DRW_OBJ_INFOS_SLOT, Qualifier::READ, "ObjectInfos", "drw_infos[]");
GPU_SHADER_CREATE_END()
/** \note Requires draw_object_infos_new. */ /** \note Requires draw_object_infos_new. */
GPU_SHADER_CREATE_INFO(draw_object_attribute_new) GPU_SHADER_CREATE_INFO(draw_object_attribute_new)
DEFINE("OBATTR_LIB") .define("OBATTR_LIB")
DEFINE_VALUE("ObjectAttributeStart", "(drw_infos[resource_id].orco_mul_bias[0].w)") .define("ObjectAttributeStart", "(drw_infos[resource_id].orco_mul_bias[0].w)")
DEFINE_VALUE("ObjectAttributeLen", "(drw_infos[resource_id].orco_mul_bias[1].w)") .define("ObjectAttributeLen", "(drw_infos[resource_id].orco_mul_bias[1].w)")
STORAGE_BUF(DRW_OBJ_ATTR_SLOT, READ, ObjectAttribute, drw_attrs[]) .storage_buf(DRW_OBJ_ATTR_SLOT, Qualifier::READ, "ObjectAttribute", "drw_attrs[]")
ADDITIONAL_INFO(draw_object_infos_new) .additional_info("draw_object_infos_new");
GPU_SHADER_CREATE_END()

View File

@ -14,37 +14,31 @@
* \{ */ * \{ */
/* Standard way. Use gpu_InstanceIndex to index the object data. */ /* Standard way. Use gpu_InstanceIndex to index the object data. */
GPU_SHADER_CREATE_INFO(draw_resource_id) GPU_SHADER_CREATE_INFO(draw_resource_id).define("DYNAMIC_RESOURCE_ID");
DEFINE("DYNAMIC_RESOURCE_ID")
GPU_SHADER_CREATE_END()
/** /**
* Used if the resource index needs to be passed to the fragment shader. * Used if the resource index needs to be passed to the fragment shader.
* IMPORTANT: Vertex and Geometry shaders need to use PASS_RESOURCE_ID in main(). * IMPORTANT: Vertex and Geometry shaders need to use PASS_RESOURCE_ID in main().
*/ */
GPU_SHADER_NAMED_INTERFACE_INFO(draw_resource_id_iface, drw_ResourceID_iface) GPU_SHADER_NAMED_INTERFACE_INFO(draw_resource_id_iface, drw_ResourceID_iface)
FLAT(INT, resource_index) .flat(Type::INT, "resource_index");
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(draw_resource_id_varying) GPU_SHADER_CREATE_INFO(draw_resource_id_varying)
VERTEX_OUT(draw_resource_id_iface) .vertex_out(draw_resource_id_iface)
GEOMETRY_OUT(draw_resource_id_iface) .geometry_out(draw_resource_id_iface); /* Used if needed. */
GPU_SHADER_CREATE_END() /* Used if needed. */
/* Variation used when drawing multiple instances for one object. */ /* Variation used when drawing multiple instances for one object. */
GPU_SHADER_CREATE_INFO(draw_resource_id_uniform) GPU_SHADER_CREATE_INFO(draw_resource_id_uniform)
DEFINE("UNIFORM_RESOURCE_ID") .define("UNIFORM_RESOURCE_ID")
PUSH_CONSTANT(INT, drw_ResourceID) .push_constant(Type::INT, "drw_ResourceID");
GPU_SHADER_CREATE_END()
/** /**
* Declare a resource handle that identify a unique object. * Declare a resource handle that identify a unique object.
* Requires draw_resource_id[_uniform]. * Requires draw_resource_id[_uniform].
*/ */
GPU_SHADER_CREATE_INFO(draw_resource_handle) GPU_SHADER_CREATE_INFO(draw_resource_handle)
DEFINE_VALUE("resource_handle", "(drw_resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)") .define("resource_handle", "(drw_resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)")
PUSH_CONSTANT(INT, drw_resourceChunk) .push_constant(Type::INT, "drw_resourceChunk");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -53,38 +47,36 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_view) GPU_SHADER_CREATE_INFO(draw_view)
UNIFORM_BUF_FREQ(DRW_VIEW_UBO_SLOT, ViewMatrices, drw_view_[DRW_VIEW_LEN], PASS) .uniform_buf(DRW_VIEW_UBO_SLOT, "ViewMatrices", "drw_view_[DRW_VIEW_LEN]", Frequency::PASS)
DEFINE("DRAW_VIEW_CREATE_INFO") .define("DRAW_VIEW_CREATE_INFO")
DEFINE_VALUE("drw_view", "drw_view_[drw_view_id]") .define("drw_view", "drw_view_[drw_view_id]")
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_view_culling) GPU_SHADER_CREATE_INFO(draw_view_culling)
UNIFORM_BUF(DRW_VIEW_CULLING_UBO_SLOT, ViewCullingData, drw_view_culling_[DRW_VIEW_LEN]) .uniform_buf(DRW_VIEW_CULLING_UBO_SLOT, "ViewCullingData", "drw_view_culling_[DRW_VIEW_LEN]")
DEFINE("DRW_VIEW_CULLING_INFO") .define("DRW_VIEW_CULLING_INFO")
DEFINE_VALUE("drw_view_culling", "drw_view_culling_[drw_view_id]") .define("drw_view_culling", "drw_view_culling_[drw_view_id]")
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_modelmat) GPU_SHADER_CREATE_INFO(draw_modelmat)
UNIFORM_BUF_FREQ(DRW_OBJ_MAT_UBO_SLOT, ObjectMatrices, drw_matrices[DRW_RESOURCE_CHUNK_LEN], BATCH) .uniform_buf(DRW_OBJ_MAT_UBO_SLOT,
DEFINE_VALUE("ModelMatrix", "(drw_matrices[resource_id].model)") "ObjectMatrices",
DEFINE_VALUE("ModelMatrixInverse", "(drw_matrices[resource_id].model_inverse)") "drw_matrices[DRW_RESOURCE_CHUNK_LEN]",
ADDITIONAL_INFO(draw_view) Frequency::BATCH)
GPU_SHADER_CREATE_END() .define("ModelMatrix", "(drw_matrices[resource_id].model)")
.define("ModelMatrixInverse", "(drw_matrices[resource_id].model_inverse)")
.additional_info("draw_view");
GPU_SHADER_CREATE_INFO(draw_modelmat_legacy) GPU_SHADER_CREATE_INFO(draw_modelmat_legacy)
DEFINE("DRW_LEGACY_MODEL_MATRIX") .define("DRW_LEGACY_MODEL_MATRIX")
PUSH_CONSTANT(MAT4, ModelMatrix) .push_constant(Type::MAT4, "ModelMatrix")
PUSH_CONSTANT(MAT4, ModelMatrixInverse) .push_constant(Type::MAT4, "ModelMatrixInverse")
ADDITIONAL_INFO(draw_view) .additional_info("draw_view");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_modelmat_instanced_attr) GPU_SHADER_CREATE_INFO(draw_modelmat_instanced_attr)
PUSH_CONSTANT(MAT4, ModelMatrix) .push_constant(Type::MAT4, "ModelMatrix")
PUSH_CONSTANT(MAT4, ModelMatrixInverse) .push_constant(Type::MAT4, "ModelMatrixInverse")
ADDITIONAL_INFO(draw_view) .additional_info("draw_view");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -93,10 +85,9 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(drw_clipped) GPU_SHADER_CREATE_INFO(drw_clipped)
/* TODO(fclem): Move to engine side. */ /* TODO(fclem): Move to engine side. */
UNIFORM_BUF_FREQ(DRW_CLIPPING_UBO_SLOT, vec4, drw_clipping_[6], PASS) .uniform_buf(DRW_CLIPPING_UBO_SLOT, "vec4", "drw_clipping_[6]", Frequency::PASS)
DEFINE("USE_WORLD_CLIP_PLANES") .define("USE_WORLD_CLIP_PLANES");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -105,9 +96,8 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_globals) GPU_SHADER_CREATE_INFO(draw_globals)
TYPEDEF_SOURCE("draw_common_shader_shared.hh") .typedef_source("draw_common_shader_shared.hh")
UNIFORM_BUF_FREQ(7, GlobalsUboStorage, globalsBlock, PASS) .uniform_buf(7, "GlobalsUboStorage", "globalsBlock", Frequency::PASS);
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -116,101 +106,91 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_mesh) GPU_SHADER_CREATE_INFO(draw_mesh)
ADDITIONAL_INFO(draw_modelmat) .additional_info("draw_modelmat")
ADDITIONAL_INFO(draw_resource_id) .additional_info("draw_resource_id");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_mesh_new) GPU_SHADER_CREATE_INFO(draw_mesh_new)
ADDITIONAL_INFO(draw_modelmat_new) .additional_info("draw_modelmat_new")
ADDITIONAL_INFO(draw_resource_id) .additional_info("draw_resource_id");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_hair) GPU_SHADER_CREATE_INFO(draw_hair)
DEFINE("HAIR_SHADER") .define("HAIR_SHADER")
DEFINE("DRW_HAIR_INFO") .define("DRW_HAIR_INFO")
SAMPLER(15, FLOAT_BUFFER, hairPointBuffer) .sampler(15, ImageType::FLOAT_BUFFER, "hairPointBuffer")
/* TODO(@fclem): Pack these into one UBO. */ /* TODO(@fclem): Pack these into one UBO. */
PUSH_CONSTANT(INT, hairStrandsRes) .push_constant(Type::INT, "hairStrandsRes")
PUSH_CONSTANT(INT, hairThicknessRes) .push_constant(Type::INT, "hairThicknessRes")
PUSH_CONSTANT(FLOAT, hairRadRoot) .push_constant(Type::FLOAT, "hairRadRoot")
PUSH_CONSTANT(FLOAT, hairRadTip) .push_constant(Type::FLOAT, "hairRadTip")
PUSH_CONSTANT(FLOAT, hairRadShape) .push_constant(Type::FLOAT, "hairRadShape")
PUSH_CONSTANT(BOOL, hairCloseTip) .push_constant(Type::BOOL, "hairCloseTip")
PUSH_CONSTANT(INT, hairStrandOffset) .push_constant(Type::INT, "hairStrandOffset")
PUSH_CONSTANT(MAT4, hairDupliMatrix) .push_constant(Type::MAT4, "hairDupliMatrix")
ADDITIONAL_INFO(draw_modelmat) .additional_info("draw_modelmat")
ADDITIONAL_INFO(draw_resource_id) .additional_info("draw_resource_id");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_hair_new) GPU_SHADER_CREATE_INFO(draw_hair_new)
DEFINE("HAIR_SHADER") .define("HAIR_SHADER")
DEFINE("DRW_HAIR_INFO") .define("DRW_HAIR_INFO")
SAMPLER(0, FLOAT_BUFFER, hairPointBuffer) .sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer")
/* TODO(@fclem): Pack these into one UBO. */ /* TODO(@fclem): Pack these into one UBO. */
PUSH_CONSTANT(INT, hairStrandsRes) .push_constant(Type::INT, "hairStrandsRes")
PUSH_CONSTANT(INT, hairThicknessRes) .push_constant(Type::INT, "hairThicknessRes")
PUSH_CONSTANT(FLOAT, hairRadRoot) .push_constant(Type::FLOAT, "hairRadRoot")
PUSH_CONSTANT(FLOAT, hairRadTip) .push_constant(Type::FLOAT, "hairRadTip")
PUSH_CONSTANT(FLOAT, hairRadShape) .push_constant(Type::FLOAT, "hairRadShape")
PUSH_CONSTANT(BOOL, hairCloseTip) .push_constant(Type::BOOL, "hairCloseTip")
PUSH_CONSTANT(INT, hairStrandOffset) .push_constant(Type::INT, "hairStrandOffset")
PUSH_CONSTANT(MAT4, hairDupliMatrix) .push_constant(Type::MAT4, "hairDupliMatrix");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_pointcloud) GPU_SHADER_CREATE_INFO(draw_pointcloud)
SAMPLER_FREQ(0, FLOAT_BUFFER, ptcloud_pos_rad_tx, BATCH) .sampler(0, ImageType::FLOAT_BUFFER, "ptcloud_pos_rad_tx", Frequency::BATCH)
DEFINE("POINTCLOUD_SHADER") .define("POINTCLOUD_SHADER")
DEFINE("DRW_POINTCLOUD_INFO") .define("DRW_POINTCLOUD_INFO")
ADDITIONAL_INFO(draw_modelmat_instanced_attr) .additional_info("draw_modelmat_instanced_attr")
ADDITIONAL_INFO(draw_resource_id_uniform) .additional_info("draw_resource_id_uniform");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_pointcloud_new) GPU_SHADER_CREATE_INFO(draw_pointcloud_new)
SAMPLER_FREQ(0, FLOAT_BUFFER, ptcloud_pos_rad_tx, BATCH) .sampler(0, ImageType::FLOAT_BUFFER, "ptcloud_pos_rad_tx", Frequency::BATCH)
DEFINE("POINTCLOUD_SHADER") .define("POINTCLOUD_SHADER")
DEFINE("DRW_POINTCLOUD_INFO") .define("DRW_POINTCLOUD_INFO");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_volume) GPU_SHADER_CREATE_INFO(draw_volume)
ADDITIONAL_INFO(draw_modelmat) .additional_info("draw_modelmat")
ADDITIONAL_INFO(draw_resource_id_uniform) .additional_info("draw_resource_id_uniform");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_volume_new) GPU_SHADER_CREATE_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_modelmat_new) .additional_info("draw_modelmat_new")
ADDITIONAL_INFO(draw_resource_handle_new) .additional_info("draw_resource_handle_new");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_gpencil) GPU_SHADER_CREATE_INFO(draw_gpencil)
TYPEDEF_SOURCE("gpencil_shader_shared.h") .typedef_source("gpencil_shader_shared.h")
DEFINE("DRW_GPENCIL_INFO") .define("DRW_GPENCIL_INFO")
SAMPLER(0, FLOAT_BUFFER, gp_pos_tx) .sampler(0, ImageType::FLOAT_BUFFER, "gp_pos_tx")
SAMPLER(1, FLOAT_BUFFER, gp_col_tx) .sampler(1, ImageType::FLOAT_BUFFER, "gp_col_tx")
/* Per Object */ /* Per Object */
PUSH_CONSTANT(FLOAT, gpThicknessScale) /* TODO(fclem): Replace with object info. */ .push_constant(Type::FLOAT, "gpThicknessScale") /* TODO(fclem): Replace with object info. */
PUSH_CONSTANT(FLOAT, gpThicknessWorldScale) /* TODO(fclem): Same as above. */ .push_constant(Type::FLOAT, "gpThicknessWorldScale") /* TODO(fclem): Same as above. */
DEFINE_VALUE("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") .define("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)")
/* Per Layer */ /* Per Layer */
PUSH_CONSTANT(FLOAT, gpThicknessOffset) .push_constant(Type::FLOAT, "gpThicknessOffset")
ADDITIONAL_INFO(draw_modelmat) .additional_info("draw_modelmat")
ADDITIONAL_INFO(draw_object_infos) .additional_info("draw_object_infos");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_gpencil_new) GPU_SHADER_CREATE_INFO(draw_gpencil_new)
TYPEDEF_SOURCE("gpencil_shader_shared.h") .typedef_source("gpencil_shader_shared.h")
DEFINE("DRW_GPENCIL_INFO") .define("DRW_GPENCIL_INFO")
SAMPLER(0, FLOAT_BUFFER, gp_pos_tx) .sampler(0, ImageType::FLOAT_BUFFER, "gp_pos_tx")
SAMPLER(1, FLOAT_BUFFER, gp_col_tx) .sampler(1, ImageType::FLOAT_BUFFER, "gp_col_tx")
/* Per Object */ /* Per Object */
PUSH_CONSTANT(FLOAT, gpThicknessScale) /* TODO(fclem): Replace with object info. */ .push_constant(Type::FLOAT, "gpThicknessScale") /* TODO(fclem): Replace with object info. */
PUSH_CONSTANT(FLOAT, gpThicknessWorldScale) /* TODO(fclem): Same as above. */ .push_constant(Type::FLOAT, "gpThicknessWorldScale") /* TODO(fclem): Same as above. */
DEFINE_VALUE("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") .define("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)")
/* Per Layer */ /* Per Layer */
PUSH_CONSTANT(FLOAT, gpThicknessOffset) .push_constant(Type::FLOAT, "gpThicknessOffset")
ADDITIONAL_INFO(draw_resource_id_varying) .additional_info("draw_resource_id_varying")
ADDITIONAL_INFO(draw_view) .additional_info("draw_view")
ADDITIONAL_INFO(draw_object_infos_new) .additional_info("draw_object_infos_new");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -219,56 +199,52 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_resource_finalize) GPU_SHADER_CREATE_INFO(draw_resource_finalize)
DO_STATIC_COMPILATION() .do_static_compilation(true)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
DEFINE("DRAW_FINALIZE_SHADER") .define("DRAW_FINALIZE_SHADER")
LOCAL_GROUP_SIZE(DRW_FINALIZE_GROUP_SIZE) .local_group_size(DRW_FINALIZE_GROUP_SIZE)
STORAGE_BUF(0, READ, ObjectMatrices, matrix_buf[]) .storage_buf(0, Qualifier::READ, "ObjectMatrices", "matrix_buf[]")
STORAGE_BUF(1, READ_WRITE, ObjectBounds, bounds_buf[]) .storage_buf(1, Qualifier::READ_WRITE, "ObjectBounds", "bounds_buf[]")
STORAGE_BUF(2, READ_WRITE, ObjectInfos, infos_buf[]) .storage_buf(2, Qualifier::READ_WRITE, "ObjectInfos", "infos_buf[]")
PUSH_CONSTANT(INT, resource_len) .push_constant(Type::INT, "resource_len")
COMPUTE_SOURCE("draw_resource_finalize_comp.glsl") .compute_source("draw_resource_finalize_comp.glsl");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_view_finalize) GPU_SHADER_CREATE_INFO(draw_view_finalize)
DO_STATIC_COMPILATION() .do_static_compilation(true)
LOCAL_GROUP_SIZE(DRW_VIEW_MAX) .local_group_size(DRW_VIEW_MAX)
DEFINE_VALUE("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) .define("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX))
STORAGE_BUF(0, READ_WRITE, ViewCullingData, view_culling_buf[DRW_VIEW_LEN]) .storage_buf(0, Qualifier::READ_WRITE, "ViewCullingData", "view_culling_buf[DRW_VIEW_LEN]")
COMPUTE_SOURCE("draw_view_finalize_comp.glsl") .compute_source("draw_view_finalize_comp.glsl")
ADDITIONAL_INFO(draw_view) .additional_info("draw_view");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_visibility_compute) GPU_SHADER_CREATE_INFO(draw_visibility_compute)
DO_STATIC_COMPILATION() .do_static_compilation(true)
LOCAL_GROUP_SIZE(DRW_VISIBILITY_GROUP_SIZE) .local_group_size(DRW_VISIBILITY_GROUP_SIZE)
DEFINE_VALUE("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) .define("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX))
STORAGE_BUF(0, READ, ObjectBounds, bounds_buf[]) .storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]")
STORAGE_BUF(1, READ_WRITE, uint, visibility_buf[]) .storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]")
PUSH_CONSTANT(INT, resource_len) .push_constant(Type::INT, "resource_len")
PUSH_CONSTANT(INT, view_len) .push_constant(Type::INT, "view_len")
PUSH_CONSTANT(INT, visibility_word_per_draw) .push_constant(Type::INT, "visibility_word_per_draw")
COMPUTE_SOURCE("draw_visibility_comp.glsl") .compute_source("draw_visibility_comp.glsl")
ADDITIONAL_INFO(draw_view) .additional_info("draw_view")
ADDITIONAL_INFO(draw_view_culling) .additional_info("draw_view_culling");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_command_generate) GPU_SHADER_CREATE_INFO(draw_command_generate)
DO_STATIC_COMPILATION() .do_static_compilation(true)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
TYPEDEF_SOURCE("draw_command_shared.hh") .typedef_source("draw_command_shared.hh")
LOCAL_GROUP_SIZE(DRW_COMMAND_GROUP_SIZE) .local_group_size(DRW_COMMAND_GROUP_SIZE)
STORAGE_BUF(0, READ_WRITE, DrawGroup, group_buf[]) .storage_buf(0, Qualifier::READ_WRITE, "DrawGroup", "group_buf[]")
STORAGE_BUF(1, READ, uint, visibility_buf[]) .storage_buf(1, Qualifier::READ, "uint", "visibility_buf[]")
STORAGE_BUF(2, READ, DrawPrototype, prototype_buf[]) .storage_buf(2, Qualifier::READ, "DrawPrototype", "prototype_buf[]")
STORAGE_BUF(3, WRITE, DrawCommand, command_buf[]) .storage_buf(3, Qualifier::WRITE, "DrawCommand", "command_buf[]")
STORAGE_BUF(DRW_RESOURCE_ID_SLOT, WRITE, uint, resource_id_buf[]) .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::WRITE, "uint", "resource_id_buf[]")
PUSH_CONSTANT(INT, prototype_len) .push_constant(Type::INT, "prototype_len")
PUSH_CONSTANT(INT, visibility_word_per_draw) .push_constant(Type::INT, "visibility_word_per_draw")
PUSH_CONSTANT(INT, view_shift) .push_constant(Type::INT, "view_shift")
PUSH_CONSTANT(BOOL, use_custom_ids) .push_constant(Type::BOOL, "use_custom_ids")
COMPUTE_SOURCE("draw_command_generate_comp.glsl") .compute_source("draw_command_generate_comp.glsl");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -278,41 +254,35 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_resource_id_new) GPU_SHADER_CREATE_INFO(draw_resource_id_new)
DEFINE("UNIFORM_RESOURCE_ID_NEW") .define("UNIFORM_RESOURCE_ID_NEW")
/* TODO (Miguel Pozo): This is an int for compatibility. /* TODO (Miguel Pozo): This is an int for compatibility.
* It should become uint once the "Next" ports are complete. */ * It should become uint once the "Next" ports are complete. */
STORAGE_BUF(DRW_RESOURCE_ID_SLOT, READ, int, resource_id_buf[]) .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::READ, "int", "resource_id_buf[]")
DEFINE_VALUE("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID]") .define("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID]");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_new) GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_new)
DEFINE("UNIFORM_RESOURCE_ID_NEW") .define("UNIFORM_RESOURCE_ID_NEW")
DEFINE("WITH_CUSTOM_IDS") .define("WITH_CUSTOM_IDS")
STORAGE_BUF(DRW_RESOURCE_ID_SLOT, READ, int2, resource_id_buf[]) .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::READ, "int2", "resource_id_buf[]")
DEFINE_VALUE("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].x") .define("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].x")
DEFINE_VALUE("drw_CustomID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].y") .define("drw_CustomID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].y");
GPU_SHADER_CREATE_END()
/** /**
* Workaround the lack of gl_BaseInstance by binding the resource_id_buf as vertex buf. * Workaround the lack of gl_BaseInstance by binding the resource_id_buf as vertex buf.
*/ */
GPU_SHADER_CREATE_INFO(draw_resource_id_fallback) GPU_SHADER_CREATE_INFO(draw_resource_id_fallback)
DEFINE("UNIFORM_RESOURCE_ID_NEW") .define("UNIFORM_RESOURCE_ID_NEW")
VERTEX_IN(15, INT, drw_ResourceID) .vertex_in(15, Type::INT, "drw_ResourceID");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_fallback) GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_fallback)
DEFINE("UNIFORM_RESOURCE_ID_NEW") .define("UNIFORM_RESOURCE_ID_NEW")
DEFINE("WITH_CUSTOM_IDS") .define("WITH_CUSTOM_IDS")
VERTEX_IN(15, IVEC2, vertex_in_drw_ResourceID) .vertex_in(15, Type::IVEC2, "vertex_in_drw_ResourceID")
DEFINE_VALUE("drw_ResourceID", "vertex_in_drw_ResourceID.x") .define("drw_ResourceID", "vertex_in_drw_ResourceID.x")
DEFINE_VALUE("drw_CustomID", "vertex_in_drw_ResourceID.y") .define("drw_CustomID", "vertex_in_drw_ResourceID.y");
GPU_SHADER_CREATE_END()
/** TODO mask view id bits. */ /** TODO mask view id bits. */
GPU_SHADER_CREATE_INFO(draw_resource_handle_new) GPU_SHADER_CREATE_INFO(draw_resource_handle_new).define("resource_handle", "drw_ResourceID");
DEFINE_VALUE("resource_handle", "drw_ResourceID")
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -321,24 +291,21 @@ GPU_SHADER_CREATE_END()
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(draw_modelmat_new_common) GPU_SHADER_CREATE_INFO(draw_modelmat_new_common)
TYPEDEF_SOURCE("draw_shader_shared.hh") .typedef_source("draw_shader_shared.hh")
STORAGE_BUF(DRW_OBJ_MAT_SLOT, READ, ObjectMatrices, drw_matrix_buf[]) .storage_buf(DRW_OBJ_MAT_SLOT, Qualifier::READ, "ObjectMatrices", "drw_matrix_buf[]")
DEFINE("DRAW_MODELMAT_CREATE_INFO") .define("DRAW_MODELMAT_CREATE_INFO")
DEFINE_VALUE("drw_ModelMatrixInverse", "drw_matrix_buf[resource_id].model_inverse") .define("drw_ModelMatrixInverse", "drw_matrix_buf[resource_id].model_inverse")
DEFINE_VALUE("drw_ModelMatrix", "drw_matrix_buf[resource_id].model") .define("drw_ModelMatrix", "drw_matrix_buf[resource_id].model")
/* TODO For compatibility with old shaders. To be removed. */ /* TODO For compatibility with old shaders. To be removed. */
DEFINE_VALUE("ModelMatrixInverse", "drw_ModelMatrixInverse") .define("ModelMatrixInverse", "drw_ModelMatrixInverse")
DEFINE_VALUE("ModelMatrix", "drw_ModelMatrix") .define("ModelMatrix", "drw_ModelMatrix");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_modelmat_new) GPU_SHADER_CREATE_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_modelmat_new_common) .additional_info("draw_modelmat_new_common")
ADDITIONAL_INFO(draw_resource_id_new) .additional_info("draw_resource_id_new");
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(draw_modelmat_new_with_custom_id) GPU_SHADER_CREATE_INFO(draw_modelmat_new_with_custom_id)
ADDITIONAL_INFO(draw_modelmat_new_common) .additional_info("draw_modelmat_new_common")
ADDITIONAL_INFO(draw_resource_with_custom_id_new) .additional_info("draw_resource_with_custom_id_new");
GPU_SHADER_CREATE_END()
/** \} */ /** \} */