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.
9 changed files with 341 additions and 270 deletions
Showing only changes of commit 1550f62b3d - Show all commits

View File

@ -10,43 +10,52 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_composite) GPU_SHADER_CREATE_INFO(workbench_composite)
.sampler(3, ImageType::DEPTH_2D, "depth_tx") SAMPLER(3, DEPTH_2D, depth_tx)
.sampler(4, ImageType::FLOAT_2D, "normal_tx") SAMPLER(4, FLOAT_2D, normal_tx)
.sampler(5, ImageType::FLOAT_2D, "material_tx") SAMPLER(5, FLOAT_2D, material_tx)
.uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.push_constant(Type::BOOL, "forceShadowing") PUSH_CONSTANT(BOOL, forceShadowing)
.fragment_out(0, Type::VEC4, "fragColor") FRAGMENT_OUT(0, VEC4, fragColor)
.fragment_source("workbench_composite_frag.glsl") FRAGMENT_SOURCE("workbench_composite_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.additional_info("draw_view"); ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
/* Lighting */ /* Lighting */
GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_studio).define("WORKBENCH_LIGHTING_STUDIO"); GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_studio)
DEFINE("WORKBENCH_LIGHTING_STUDIO")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_matcap) GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_matcap)
.define("WORKBENCH_LIGHTING_MATCAP") DEFINE("WORKBENCH_LIGHTING_MATCAP")
.sampler(WB_MATCAP_SLOT, ImageType::FLOAT_2D_ARRAY, "matcap_tx"); SAMPLER(WB_MATCAP_SLOT, FLOAT_2D_ARRAY, matcap_tx)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_flat).define("WORKBENCH_LIGHTING_FLAT"); GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_flat)
DEFINE("WORKBENCH_LIGHTING_FLAT")
GPU_SHADER_CREATE_END()
/* Effects */ /* Effects */
GPU_SHADER_CREATE_INFO(workbench_resolve_curvature) GPU_SHADER_CREATE_INFO(workbench_resolve_curvature)
.define("WORKBENCH_CURVATURE") DEFINE("WORKBENCH_CURVATURE")
.sampler(6, ImageType::UINT_2D, "object_id_tx"); SAMPLER(6, UINT_2D, object_id_tx)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_resolve_cavity) GPU_SHADER_CREATE_INFO(workbench_resolve_cavity)
.define("WORKBENCH_CAVITY") DEFINE("WORKBENCH_CAVITY")
/* TODO(@pragma37): GPU_SAMPLER_EXTEND_MODE_REPEAT is set in CavityEffect, /* TODO(@pragma37): GPU_SAMPLER_EXTEND_MODE_REPEAT is set in CavityEffect,
* it doesn't work here? */ * it doesn't work here? */
.sampler(7, ImageType::FLOAT_2D, "jitter_tx") SAMPLER(7, FLOAT_2D, jitter_tx)
.uniform_buf(5, "vec4", "cavity_samples[512]"); UNIFORM_BUF(5, vec4, cavity_samples[512])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_resolve_shadow) GPU_SHADER_CREATE_INFO(workbench_resolve_shadow)
.define("WORKBENCH_SHADOW") DEFINE("WORKBENCH_SHADOW")
.sampler(8, ImageType::UINT_2D, "stencil_tx"); SAMPLER(8, UINT_2D, stencil_tx)
GPU_SHADER_CREATE_END()
/* Variations */ /* Variations */

View File

@ -5,20 +5,23 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(workbench_merge_depth) GPU_SHADER_CREATE_INFO(workbench_merge_depth)
.sampler(0, ImageType::DEPTH_2D, "depth_tx") SAMPLER(0, DEPTH_2D, depth_tx)
.fragment_source("workbench_merge_depth_frag.glsl") FRAGMENT_SOURCE("workbench_merge_depth_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.depth_write(DepthWrite::ANY) DEPTH_WRITE(DepthWrite::ANY)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_overlay_depth) GPU_SHADER_CREATE_INFO(workbench_overlay_depth)
.fragment_source("workbench_overlay_depth_frag.glsl") FRAGMENT_SOURCE("workbench_overlay_depth_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.depth_write(DepthWrite::ANY) DEPTH_WRITE(DepthWrite::ANY)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_extract_stencil) GPU_SHADER_CREATE_INFO(workbench_extract_stencil)
.fragment_out(0, Type::UINT, "out_stencil_value") FRAGMENT_OUT(0, UINT, out_stencil_value)
.fragment_source("workbench_extract_stencil.glsl") FRAGMENT_SOURCE("workbench_extract_stencil.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()

View File

@ -9,12 +9,13 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_taa) GPU_SHADER_CREATE_INFO(workbench_taa)
.sampler(0, ImageType::FLOAT_2D, "colorBuffer") SAMPLER(0, FLOAT_2D, colorBuffer)
.push_constant(Type::FLOAT, "samplesWeights", 9) PUSH_CONSTANT_ARRAY(FLOAT, samplesWeights, 9)
.fragment_out(0, Type::VEC4, "fragColor") FRAGMENT_OUT(0, VEC4, fragColor)
.fragment_source("workbench_effect_taa_frag.glsl") FRAGMENT_SOURCE("workbench_effect_taa_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -23,45 +24,50 @@ GPU_SHADER_CREATE_INFO(workbench_taa)
* \{ */ * \{ */
GPU_SHADER_INTERFACE_INFO(workbench_smaa_iface) GPU_SHADER_INTERFACE_INFO(workbench_smaa_iface)
.smooth(Type::VEC2, "uvs") SMOOTH(VEC2, uvs)
.smooth(Type::VEC2, "pixcoord") SMOOTH(VEC2, pixcoord)
.smooth(Type::VEC4, "offset[3]"); SMOOTH(VEC4, offset[3])
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(workbench_smaa) GPU_SHADER_CREATE_INFO(workbench_smaa)
.define("SMAA_GLSL_3") DEFINE("SMAA_GLSL_3")
.define("SMAA_RT_METRICS", "viewportMetrics") DEFINE_VALUE("SMAA_RT_METRICS", "viewportMetrics")
.define("SMAA_PRESET_HIGH") DEFINE("SMAA_PRESET_HIGH")
.define("SMAA_LUMA_WEIGHT", "float4(1.0, 1.0, 1.0, 1.0)") DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(1.0, 1.0, 1.0, 1.0)")
.define("SMAA_NO_DISCARD") DEFINE("SMAA_NO_DISCARD")
.vertex_out(workbench_smaa_iface) VERTEX_OUT(workbench_smaa_iface)
.push_constant(Type::VEC4, "viewportMetrics") PUSH_CONSTANT(VEC4, viewportMetrics)
.vertex_source("workbench_effect_smaa_vert.glsl") VERTEX_SOURCE("workbench_effect_smaa_vert.glsl")
.fragment_source("workbench_effect_smaa_frag.glsl"); FRAGMENT_SOURCE("workbench_effect_smaa_frag.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_smaa_stage_0) GPU_SHADER_CREATE_INFO(workbench_smaa_stage_0)
.define("SMAA_STAGE", "0") DEFINE_VALUE("SMAA_STAGE", "0")
.sampler(0, ImageType::FLOAT_2D, "colorTex") SAMPLER(0, FLOAT_2D, colorTex)
.fragment_out(0, Type::VEC2, "out_edges") FRAGMENT_OUT(0, VEC2, out_edges)
.additional_info("workbench_smaa") ADDITIONAL_INFO(workbench_smaa)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_smaa_stage_1) GPU_SHADER_CREATE_INFO(workbench_smaa_stage_1)
.define("SMAA_STAGE", "1") DEFINE_VALUE("SMAA_STAGE", "1")
.sampler(0, ImageType::FLOAT_2D, "edgesTex") SAMPLER(0, FLOAT_2D, edgesTex)
.sampler(1, ImageType::FLOAT_2D, "areaTex") SAMPLER(1, FLOAT_2D, areaTex)
.sampler(2, ImageType::FLOAT_2D, "searchTex") SAMPLER(2, FLOAT_2D, searchTex)
.fragment_out(0, Type::VEC4, "out_weights") FRAGMENT_OUT(0, VEC4, out_weights)
.additional_info("workbench_smaa") ADDITIONAL_INFO(workbench_smaa)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_smaa_stage_2) GPU_SHADER_CREATE_INFO(workbench_smaa_stage_2)
.define("SMAA_STAGE", "2") DEFINE_VALUE("SMAA_STAGE", "2")
.sampler(0, ImageType::FLOAT_2D, "colorTex") SAMPLER(0, FLOAT_2D, colorTex)
.sampler(1, ImageType::FLOAT_2D, "blendTex") SAMPLER(1, FLOAT_2D, blendTex)
.push_constant(Type::FLOAT, "mixFactor") PUSH_CONSTANT(FLOAT, mixFactor)
.push_constant(Type::FLOAT, "taaAccumulatedWeight") PUSH_CONSTANT(FLOAT, taaAccumulatedWeight)
.fragment_out(0, Type::VEC4, "out_color") FRAGMENT_OUT(0, VEC4, out_color)
.additional_info("workbench_smaa") ADDITIONAL_INFO(workbench_smaa)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
/** \} */ /** \} */

View File

@ -5,54 +5,60 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(workbench_effect_dof) GPU_SHADER_CREATE_INFO(workbench_effect_dof)
/* TODO(fclem): Split resources per stage. */ /* TODO(fclem): Split resources per stage. */
.sampler(0, ImageType::FLOAT_2D, "inputCocTex") SAMPLER(0, FLOAT_2D, inputCocTex)
.sampler(1, ImageType::FLOAT_2D, "maxCocTilesTex") SAMPLER(1, FLOAT_2D, maxCocTilesTex)
.sampler(2, ImageType::FLOAT_2D, "sceneColorTex") SAMPLER(2, FLOAT_2D, sceneColorTex)
.sampler(3, ImageType::FLOAT_2D, "sceneDepthTex") SAMPLER(3, FLOAT_2D, sceneDepthTex)
.sampler(4, ImageType::FLOAT_2D, "backgroundTex") SAMPLER(4, FLOAT_2D, backgroundTex)
.sampler(5, ImageType::FLOAT_2D, "halfResColorTex") SAMPLER(5, FLOAT_2D, halfResColorTex)
.sampler(6, ImageType::FLOAT_2D, "blurTex") SAMPLER(6, FLOAT_2D, blurTex)
.sampler(7, ImageType::FLOAT_2D, "noiseTex") SAMPLER(7, FLOAT_2D, noiseTex)
.push_constant(Type::VEC2, "invertedViewportSize") PUSH_CONSTANT(VEC2, invertedViewportSize)
.push_constant(Type::VEC2, "nearFar") PUSH_CONSTANT(VEC2, nearFar)
.push_constant(Type::VEC3, "dofParams") PUSH_CONSTANT(VEC3, dofParams)
.push_constant(Type::FLOAT, "noiseOffset") PUSH_CONSTANT(FLOAT, noiseOffset)
.fragment_source("workbench_effect_dof_frag.glsl") FRAGMENT_SOURCE("workbench_effect_dof_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.additional_info("draw_view"); ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_effect_dof_prepare) GPU_SHADER_CREATE_INFO(workbench_effect_dof_prepare)
.define("PREPARE") DEFINE("PREPARE")
.fragment_out(0, Type::VEC4, "halfResColor") FRAGMENT_OUT(0, VEC4, halfResColor)
.fragment_out(1, Type::VEC2, "normalizedCoc") FRAGMENT_OUT(1, VEC2, normalizedCoc)
.additional_info("workbench_effect_dof") ADDITIONAL_INFO(workbench_effect_dof)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_effect_dof_downsample) GPU_SHADER_CREATE_INFO(workbench_effect_dof_downsample)
.define("DOWNSAMPLE") DEFINE("DOWNSAMPLE")
.fragment_out(0, Type::VEC4, "outColor") FRAGMENT_OUT(0, VEC4, outColor)
.fragment_out(1, Type::VEC2, "outCocs") FRAGMENT_OUT(1, VEC2, outCocs)
.additional_info("workbench_effect_dof") ADDITIONAL_INFO(workbench_effect_dof)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur1) GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur1)
.define("BLUR1") DEFINE("BLUR1")
.define("NUM_SAMPLES", "49") DEFINE_VALUE("NUM_SAMPLES", "49")
.uniform_buf(1, "vec4", "samples[49]") UNIFORM_BUF(1, vec4, samples[49])
.fragment_out(0, Type::VEC4, "blurColor") FRAGMENT_OUT(0, VEC4, blurColor)
.additional_info("workbench_effect_dof") ADDITIONAL_INFO(workbench_effect_dof)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur2) GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur2)
.define("BLUR2") DEFINE("BLUR2")
.fragment_out(0, Type::VEC4, "finalColor") FRAGMENT_OUT(0, VEC4, finalColor)
.additional_info("workbench_effect_dof") ADDITIONAL_INFO(workbench_effect_dof)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_effect_dof_resolve) GPU_SHADER_CREATE_INFO(workbench_effect_dof_resolve)
.define("RESOLVE") DEFINE("RESOLVE")
.fragment_out(0, Type::VEC4, "finalColorAdd", DualBlend::SRC_0) FRAGMENT_OUT_DUAL(0, VEC4, finalColorAdd, SRC_0)
.fragment_out(0, Type::VEC4, "finalColorMul", DualBlend::SRC_1) FRAGMENT_OUT_DUAL(0, VEC4, finalColorMul, SRC_1)
.additional_info("workbench_effect_dof") ADDITIONAL_INFO(workbench_effect_dof)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()

View File

@ -5,10 +5,11 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(workbench_effect_outline) GPU_SHADER_CREATE_INFO(workbench_effect_outline)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.fragment_source("workbench_effect_outline_frag.glsl") FRAGMENT_SOURCE("workbench_effect_outline_frag.glsl")
.sampler(0, ImageType::UINT_2D, "objectIdBuffer") SAMPLER(0, UINT_2D, objectIdBuffer)
.uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data)
.fragment_out(0, Type::VEC4, "fragColor") FRAGMENT_OUT(0, VEC4, fragColor)
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()

View File

@ -10,28 +10,31 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_mesh) GPU_SHADER_CREATE_INFO(workbench_mesh)
.vertex_in(0, Type::VEC3, "pos") VERTEX_IN(0, VEC3, pos)
.vertex_in(1, Type::VEC3, "nor") VERTEX_IN(1, VEC3, nor)
.vertex_in(2, Type::VEC4, "ac") VERTEX_IN(2, VEC4, ac)
.vertex_in(3, Type::VEC2, "au") VERTEX_IN(3, VEC2, au)
.vertex_source("workbench_prepass_vert.glsl") VERTEX_SOURCE("workbench_prepass_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id") ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
.additional_info("draw_resource_handle_new"); ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_curves) GPU_SHADER_CREATE_INFO(workbench_curves)
.sampler(WB_CURVES_COLOR_SLOT, ImageType::FLOAT_BUFFER, "ac", Frequency::BATCH) SAMPLER_FREQ(WB_CURVES_COLOR_SLOT, FLOAT_BUFFER, ac, BATCH)
.sampler(WB_CURVES_UV_SLOT, ImageType::FLOAT_BUFFER, "au", Frequency::BATCH) SAMPLER_FREQ(WB_CURVES_UV_SLOT, FLOAT_BUFFER, au, BATCH)
.push_constant(Type::INT, "emitter_object_id") PUSH_CONSTANT(INT, emitter_object_id)
.vertex_source("workbench_prepass_hair_vert.glsl") VERTEX_SOURCE("workbench_prepass_hair_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id") ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
.additional_info("draw_resource_handle_new") ADDITIONAL_INFO(draw_resource_handle_new)
.additional_info("draw_hair_new"); ADDITIONAL_INFO(draw_hair_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_pointcloud) GPU_SHADER_CREATE_INFO(workbench_pointcloud)
.vertex_source("workbench_prepass_pointcloud_vert.glsl") VERTEX_SOURCE("workbench_prepass_pointcloud_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id") ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
.additional_info("draw_resource_handle_new") ADDITIONAL_INFO(draw_resource_handle_new)
.additional_info("draw_pointcloud_new"); ADDITIONAL_INFO(draw_pointcloud_new)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -39,11 +42,16 @@ GPU_SHADER_CREATE_INFO(workbench_pointcloud)
/** \name Lighting Type (only for transparent) /** \name Lighting Type (only for transparent)
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_lighting_flat).define("WORKBENCH_LIGHTING_FLAT"); GPU_SHADER_CREATE_INFO(workbench_lighting_flat)
GPU_SHADER_CREATE_INFO(workbench_lighting_studio).define("WORKBENCH_LIGHTING_STUDIO"); DEFINE("WORKBENCH_LIGHTING_FLAT")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_lighting_studio)
DEFINE("WORKBENCH_LIGHTING_STUDIO")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_lighting_matcap) GPU_SHADER_CREATE_INFO(workbench_lighting_matcap)
.define("WORKBENCH_LIGHTING_MATCAP") DEFINE("WORKBENCH_LIGHTING_MATCAP")
.sampler(WB_MATCAP_SLOT, ImageType::FLOAT_2D_ARRAY, "matcap_tx"); SAMPLER(WB_MATCAP_SLOT, FLOAT_2D_ARRAY, matcap_tx)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -52,37 +60,43 @@ GPU_SHADER_CREATE_INFO(workbench_lighting_matcap)
* \{ */ * \{ */
GPU_SHADER_INTERFACE_INFO(workbench_material_iface) GPU_SHADER_INTERFACE_INFO(workbench_material_iface)
.smooth(Type::VEC3, "normal_interp") SMOOTH(VEC3, normal_interp)
.smooth(Type::VEC3, "color_interp") SMOOTH(VEC3, color_interp)
.smooth(Type::FLOAT, "alpha_interp") SMOOTH(FLOAT, alpha_interp)
.smooth(Type::VEC2, "uv_interp") SMOOTH(VEC2, uv_interp)
.flat(Type::INT, "object_id") FLAT(INT, object_id)
.flat(Type::FLOAT, "_roughness") FLAT(FLOAT, _roughness)
.flat(Type::FLOAT, "metallic"); FLAT(FLOAT, metallic)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(workbench_color_material) GPU_SHADER_CREATE_INFO(workbench_color_material)
.define("WORKBENCH_COLOR_MATERIAL") DEFINE("WORKBENCH_COLOR_MATERIAL")
.storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]"); STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_color_texture) GPU_SHADER_CREATE_INFO(workbench_color_texture)
.define("WORKBENCH_COLOR_TEXTURE") DEFINE("WORKBENCH_COLOR_TEXTURE")
.define("WORKBENCH_TEXTURE_IMAGE_ARRAY") DEFINE("WORKBENCH_TEXTURE_IMAGE_ARRAY")
.define("WORKBENCH_COLOR_MATERIAL") DEFINE("WORKBENCH_COLOR_MATERIAL")
.storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]") STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[])
.sampler(WB_TEXTURE_SLOT, ImageType::FLOAT_2D, "imageTexture", Frequency::BATCH) SAMPLER_FREQ(WB_TEXTURE_SLOT, FLOAT_2D, imageTexture, BATCH)
.sampler(WB_TILE_ARRAY_SLOT, ImageType::FLOAT_2D_ARRAY, "imageTileArray", Frequency::BATCH) SAMPLER_FREQ(WB_TILE_ARRAY_SLOT, FLOAT_2D_ARRAY, imageTileArray, BATCH)
.sampler(WB_TILE_DATA_SLOT, ImageType::FLOAT_1D_ARRAY, "imageTileData", Frequency::BATCH) SAMPLER_FREQ(WB_TILE_DATA_SLOT, FLOAT_1D_ARRAY, imageTileData, BATCH)
.push_constant(Type::BOOL, "isImageTile") PUSH_CONSTANT(BOOL, isImageTile)
.push_constant(Type::BOOL, "imagePremult") PUSH_CONSTANT(BOOL, imagePremult)
.push_constant(Type::FLOAT, "imageTransparencyCutoff"); PUSH_CONSTANT(FLOAT, imageTransparencyCutoff)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_color_vertex).define("WORKBENCH_COLOR_VERTEX"); GPU_SHADER_CREATE_INFO(workbench_color_vertex)
DEFINE("WORKBENCH_COLOR_VERTEX")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_prepass) GPU_SHADER_CREATE_INFO(workbench_prepass)
.define("WORKBENCH_NEXT") DEFINE("WORKBENCH_NEXT")
.uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data)
.vertex_out(workbench_material_iface) VERTEX_OUT(workbench_material_iface)
.additional_info("draw_view"); ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -91,21 +105,23 @@ GPU_SHADER_CREATE_INFO(workbench_prepass)
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_transparent_accum) GPU_SHADER_CREATE_INFO(workbench_transparent_accum)
/* NOTE: Blending will be skipped on objectId because output is a /* NOTE: Blending will be skipped on objectId because output is a
* non-normalized integer buffer. */ * non-normalized integer buffer. */
.fragment_out(0, Type::VEC4, "out_transparent_accum") FRAGMENT_OUT(0, VEC4, out_transparent_accum)
.fragment_out(1, Type::VEC4, "out_revealage_accum") FRAGMENT_OUT(1, VEC4, out_revealage_accum)
.fragment_out(2, Type::UINT, "out_object_id") FRAGMENT_OUT(2, UINT, out_object_id)
.push_constant(Type::BOOL, "forceShadowing") PUSH_CONSTANT(BOOL, forceShadowing)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.fragment_source("workbench_transparent_accum_frag.glsl"); FRAGMENT_SOURCE("workbench_transparent_accum_frag.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_opaque) GPU_SHADER_CREATE_INFO(workbench_opaque)
.fragment_out(0, Type::VEC4, "out_material") FRAGMENT_OUT(0, VEC4, out_material)
.fragment_out(1, Type::VEC2, "out_normal") FRAGMENT_OUT(1, VEC2, out_normal)
.fragment_out(2, Type::UINT, "out_object_id") FRAGMENT_OUT(2, UINT, out_object_id)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.fragment_source("workbench_prepass_frag.glsl"); FRAGMENT_SOURCE("workbench_prepass_frag.glsl")
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -113,9 +129,15 @@ GPU_SHADER_CREATE_INFO(workbench_opaque)
/** \name Variations Declaration /** \name Variations Declaration
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_flat).define("WORKBENCH_SHADING_FLAT"); GPU_SHADER_CREATE_INFO(workbench_flat)
GPU_SHADER_CREATE_INFO(workbench_studio).define("WORKBENCH_SHADING_STUDIO"); DEFINE("WORKBENCH_SHADING_FLAT")
GPU_SHADER_CREATE_INFO(workbench_matcap).define("WORKBENCH_SHADING_MATCAP"); GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_studio)
DEFINE("WORKBENCH_SHADING_STUDIO")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_matcap)
DEFINE("WORKBENCH_SHADING_MATCAP")
GPU_SHADER_CREATE_END()
#define WORKBENCH_CLIPPING_VARIATIONS(prefix, ...) \ #define WORKBENCH_CLIPPING_VARIATIONS(prefix, ...) \
CREATE_INFO_VARIANT(prefix##_clip, drw_clipped, __VA_ARGS__) \ CREATE_INFO_VARIANT(prefix##_clip, drw_clipped, __VA_ARGS__) \

View File

@ -11,42 +11,46 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_shadow_common) GPU_SHADER_CREATE_INFO(workbench_shadow_common)
.storage_buf(3, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) STORAGE_BUF_FREQ(3, READ, float, pos[], GEOMETRY)
/* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */ /* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */
.push_constant(Type::IVEC2, "gpu_attr_3") PUSH_CONSTANT(IVEC2, gpu_attr_3)
.uniform_buf(1, "ShadowPassData", "pass_data") UNIFORM_BUF(1, ShadowPassData, pass_data)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.additional_info("gpu_index_load") ADDITIONAL_INFO(gpu_index_load)
.additional_info("draw_view") ADDITIONAL_INFO(draw_view)
.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(workbench_shadow_visibility_compute_common) GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_common)
.local_group_size(DRW_VISIBILITY_GROUP_SIZE) LOCAL_GROUP_SIZE(DRW_VISIBILITY_GROUP_SIZE)
.define("DRW_VIEW_LEN", "64") DEFINE_VALUE("DRW_VIEW_LEN", "64")
.storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") STORAGE_BUF(0, READ, ObjectBounds, bounds_buf[])
.uniform_buf(2, "ExtrudedFrustum", "extruded_frustum") UNIFORM_BUF(2, ExtrudedFrustum, extruded_frustum)
.push_constant(Type::INT, "resource_len") PUSH_CONSTANT(INT, resource_len)
.push_constant(Type::INT, "view_len") PUSH_CONSTANT(INT, view_len)
.push_constant(Type::INT, "visibility_word_per_draw") PUSH_CONSTANT(INT, visibility_word_per_draw)
.push_constant(Type::BOOL, "force_fail_method") PUSH_CONSTANT(BOOL, force_fail_method)
.push_constant(Type::VEC3, "shadow_direction") PUSH_CONSTANT(VEC3, shadow_direction)
.typedef_source("workbench_shader_shared.h") TYPEDEF_SOURCE("workbench_shader_shared.h")
.compute_source("workbench_shadow_visibility_comp.glsl") COMPUTE_SOURCE("workbench_shadow_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(workbench_shadow_visibility_compute_dynamic_pass_type) GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_dynamic_pass_type)
.additional_info("workbench_shadow_visibility_compute_common") ADDITIONAL_INFO(workbench_shadow_visibility_compute_common)
.define("DYNAMIC_PASS_SELECTION") DEFINE("DYNAMIC_PASS_SELECTION")
.storage_buf(1, Qualifier::READ_WRITE, "uint", "pass_visibility_buf[]") STORAGE_BUF(1, READ_WRITE, uint, pass_visibility_buf[])
.storage_buf(2, Qualifier::READ_WRITE, "uint", "fail_visibility_buf[]") STORAGE_BUF(2, READ_WRITE, uint, fail_visibility_buf[])
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_static_pass_type) GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_static_pass_type)
.additional_info("workbench_shadow_visibility_compute_common") ADDITIONAL_INFO(workbench_shadow_visibility_compute_common)
.storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") STORAGE_BUF(1, READ_WRITE, uint, visibility_buf[])
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -55,11 +59,13 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_static_pass_type)
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_shadow_no_debug) GPU_SHADER_CREATE_INFO(workbench_shadow_no_debug)
.fragment_source("gpu_shader_depth_only_frag.glsl"); FRAGMENT_SOURCE("gpu_shader_depth_only_frag.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_shadow_debug) GPU_SHADER_CREATE_INFO(workbench_shadow_debug)
.fragment_out(0, Type::VEC4, "out_debug_color") FRAGMENT_OUT(0, VEC4, out_debug_color)
.fragment_source("workbench_shadow_debug_frag.glsl"); FRAGMENT_SOURCE("workbench_shadow_debug_frag.glsl")
GPU_SHADER_CREATE_END()
/** \} */ /** \} */

View File

@ -5,9 +5,10 @@
#include "gpu_shader_create_info.hh" #include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(workbench_transparent_resolve) GPU_SHADER_CREATE_INFO(workbench_transparent_resolve)
.fragment_out(0, Type::VEC4, "fragColor") FRAGMENT_OUT(0, VEC4, fragColor)
.sampler(0, ImageType::FLOAT_2D, "transparentAccum") SAMPLER(0, FLOAT_2D, transparentAccum)
.sampler(1, ImageType::FLOAT_2D, "transparentRevealage") SAMPLER(1, FLOAT_2D, transparentRevealage)
.fragment_source("workbench_transparent_resolve_frag.glsl") FRAGMENT_SOURCE("workbench_transparent_resolve_frag.glsl")
.additional_info("draw_fullscreen") ADDITIONAL_INFO(draw_fullscreen)
.do_static_compilation(true); DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()

View File

@ -9,24 +9,26 @@
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_volume_common) GPU_SHADER_CREATE_INFO(workbench_volume_common)
.vertex_in(0, Type::VEC3, "pos") VERTEX_IN(0, VEC3, pos)
.fragment_out(0, Type::VEC4, "fragColor") FRAGMENT_OUT(0, VEC4, fragColor)
.sampler(0, ImageType::DEPTH_2D, "depthBuffer") SAMPLER(0, DEPTH_2D, depthBuffer)
.sampler(1, ImageType::FLOAT_3D, "densityTexture") SAMPLER(1, FLOAT_3D, densityTexture)
.push_constant(Type::INT, "samplesLen") PUSH_CONSTANT(INT, samplesLen)
.push_constant(Type::FLOAT, "noiseOfs") PUSH_CONSTANT(FLOAT, noiseOfs)
.push_constant(Type::FLOAT, "stepLength") PUSH_CONSTANT(FLOAT, stepLength)
.push_constant(Type::FLOAT, "densityScale") PUSH_CONSTANT(FLOAT, densityScale)
.push_constant(Type::BOOL, "do_depth_test") PUSH_CONSTANT(BOOL, do_depth_test)
.vertex_source("workbench_volume_vert.glsl") VERTEX_SOURCE("workbench_volume_vert.glsl")
.fragment_source("workbench_volume_frag.glsl"); FRAGMENT_SOURCE("workbench_volume_frag.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume) GPU_SHADER_CREATE_INFO(workbench_volume)
.define("WORKBENCH_NEXT") DEFINE("WORKBENCH_NEXT")
.sampler(6, ImageType::UINT_2D, "stencil_tx") SAMPLER(6, UINT_2D, stencil_tx)
.additional_info("workbench_volume_common") ADDITIONAL_INFO(workbench_volume_common)
.additional_info("draw_object_infos_new") ADDITIONAL_INFO(draw_object_infos_new)
.additional_info("draw_view"); ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
@ -34,25 +36,29 @@ GPU_SHADER_CREATE_INFO(workbench_volume)
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_volume_smoke_common) GPU_SHADER_CREATE_INFO(workbench_volume_smoke_common)
.define("VOLUME_SMOKE") DEFINE("VOLUME_SMOKE")
.sampler(2, ImageType::FLOAT_3D, "flameTexture") SAMPLER(2, FLOAT_3D, flameTexture)
.sampler(3, ImageType::FLOAT_1D, "flameColorTexture") SAMPLER(3, FLOAT_1D, flameColorTexture)
.additional_info("draw_resource_id_varying"); ADDITIONAL_INFO(draw_resource_id_varying)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_object_common) GPU_SHADER_CREATE_INFO(workbench_volume_object_common)
.define("VOLUME_OBJECT") DEFINE("VOLUME_OBJECT")
.push_constant(Type::MAT4, "volumeTextureToObject") PUSH_CONSTANT(MAT4, volumeTextureToObject)
/* FIXME(fclem): This overflow the push_constant limit. */ /* FIXME(fclem): This overflow the push_constant limit. */
.push_constant(Type::MAT4, "volumeObjectToTexture") PUSH_CONSTANT(MAT4, volumeObjectToTexture)
.additional_info("draw_resource_id_varying"); ADDITIONAL_INFO(draw_resource_id_varying)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_smoke) GPU_SHADER_CREATE_INFO(workbench_volume_smoke)
.additional_info("workbench_volume_smoke_common") ADDITIONAL_INFO(workbench_volume_smoke_common)
.additional_info("draw_modelmat_new"); ADDITIONAL_INFO(draw_modelmat_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_object) GPU_SHADER_CREATE_INFO(workbench_volume_object)
.additional_info("workbench_volume_object_common") ADDITIONAL_INFO(workbench_volume_object_common)
.additional_info("draw_volume_new"); ADDITIONAL_INFO(draw_volume_new)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -61,17 +67,19 @@ GPU_SHADER_CREATE_INFO(workbench_volume_object)
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_volume_coba) GPU_SHADER_CREATE_INFO(workbench_volume_coba)
.define("USE_COBA") DEFINE("USE_COBA")
.sampler(4, ImageType::UINT_3D, "flagTexture") SAMPLER(4, UINT_3D, flagTexture)
.sampler(5, ImageType::FLOAT_1D, "transferTexture") SAMPLER(5, FLOAT_1D, transferTexture)
.push_constant(Type::BOOL, "showPhi") PUSH_CONSTANT(BOOL, showPhi)
.push_constant(Type::BOOL, "showFlags") PUSH_CONSTANT(BOOL, showFlags)
.push_constant(Type::BOOL, "showPressure") PUSH_CONSTANT(BOOL, showPressure)
.push_constant(Type::FLOAT, "gridScale"); PUSH_CONSTANT(FLOAT, gridScale)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_no_coba) GPU_SHADER_CREATE_INFO(workbench_volume_no_coba)
.sampler(4, ImageType::FLOAT_3D, "shadowTexture") SAMPLER(4, FLOAT_3D, shadowTexture)
.push_constant(Type::VEC3, "activeColor"); PUSH_CONSTANT(VEC3, activeColor)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -79,9 +87,15 @@ GPU_SHADER_CREATE_INFO(workbench_volume_no_coba)
/** \name Sampling variation /** \name Sampling variation
* \{ */ * \{ */
GPU_SHADER_CREATE_INFO(workbench_volume_linear).define("USE_TRILINEAR"); GPU_SHADER_CREATE_INFO(workbench_volume_linear)
GPU_SHADER_CREATE_INFO(workbench_volume_cubic).define("USE_TRICUBIC"); DEFINE("USE_TRILINEAR")
GPU_SHADER_CREATE_INFO(workbench_volume_closest).define("USE_CLOSEST"); GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_cubic)
DEFINE("USE_TRICUBIC")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_closest)
DEFINE("USE_CLOSEST")
GPU_SHADER_CREATE_END()
/** \} */ /** \} */
@ -89,14 +103,17 @@ GPU_SHADER_CREATE_INFO(workbench_volume_closest).define("USE_CLOSEST");
/** \name Slice variation /** \name Slice variation
* \{ */ * \{ */
GPU_SHADER_INTERFACE_INFO(workbench_volume_iface).smooth(Type::VEC3, "localPos"); GPU_SHADER_INTERFACE_INFO(workbench_volume_iface)
SMOOTH(VEC3, localPos)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(workbench_volume_slice) GPU_SHADER_CREATE_INFO(workbench_volume_slice)
.define("VOLUME_SLICE") DEFINE("VOLUME_SLICE")
.vertex_in(1, Type::VEC3, "uvs") VERTEX_IN(1, VEC3, uvs)
.vertex_out(workbench_volume_iface) VERTEX_OUT(workbench_volume_iface)
.push_constant(Type::INT, "sliceAxis") /* -1 is no slice. */ PUSH_CONSTANT(INT, sliceAxis) /* -1 is no slice. */
.push_constant(Type::FLOAT, "slicePosition"); PUSH_CONSTANT(FLOAT, slicePosition)
GPU_SHADER_CREATE_END()
/** \} */ /** \} */