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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,28 +10,31 @@
* \{ */
GPU_SHADER_CREATE_INFO(workbench_mesh)
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::VEC3, "nor")
.vertex_in(2, Type::VEC4, "ac")
.vertex_in(3, Type::VEC2, "au")
.vertex_source("workbench_prepass_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id")
.additional_info("draw_resource_handle_new");
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC3, nor)
VERTEX_IN(2, VEC4, ac)
VERTEX_IN(3, VEC2, au)
VERTEX_SOURCE("workbench_prepass_vert.glsl")
ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_curves)
.sampler(WB_CURVES_COLOR_SLOT, ImageType::FLOAT_BUFFER, "ac", Frequency::BATCH)
.sampler(WB_CURVES_UV_SLOT, ImageType::FLOAT_BUFFER, "au", Frequency::BATCH)
.push_constant(Type::INT, "emitter_object_id")
.vertex_source("workbench_prepass_hair_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id")
.additional_info("draw_resource_handle_new")
.additional_info("draw_hair_new");
SAMPLER_FREQ(WB_CURVES_COLOR_SLOT, FLOAT_BUFFER, ac, BATCH)
SAMPLER_FREQ(WB_CURVES_UV_SLOT, FLOAT_BUFFER, au, BATCH)
PUSH_CONSTANT(INT, emitter_object_id)
VERTEX_SOURCE("workbench_prepass_hair_vert.glsl")
ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_hair_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_pointcloud)
.vertex_source("workbench_prepass_pointcloud_vert.glsl")
.additional_info("draw_modelmat_new_with_custom_id")
.additional_info("draw_resource_handle_new")
.additional_info("draw_pointcloud_new");
VERTEX_SOURCE("workbench_prepass_pointcloud_vert.glsl")
ADDITIONAL_INFO(draw_modelmat_new_with_custom_id)
ADDITIONAL_INFO(draw_resource_handle_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)
* \{ */
GPU_SHADER_CREATE_INFO(workbench_lighting_flat).define("WORKBENCH_LIGHTING_FLAT");
GPU_SHADER_CREATE_INFO(workbench_lighting_studio).define("WORKBENCH_LIGHTING_STUDIO");
GPU_SHADER_CREATE_INFO(workbench_lighting_flat)
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)
.define("WORKBENCH_LIGHTING_MATCAP")
.sampler(WB_MATCAP_SLOT, ImageType::FLOAT_2D_ARRAY, "matcap_tx");
DEFINE("WORKBENCH_LIGHTING_MATCAP")
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)
.smooth(Type::VEC3, "normal_interp")
.smooth(Type::VEC3, "color_interp")
.smooth(Type::FLOAT, "alpha_interp")
.smooth(Type::VEC2, "uv_interp")
.flat(Type::INT, "object_id")
.flat(Type::FLOAT, "_roughness")
.flat(Type::FLOAT, "metallic");
SMOOTH(VEC3, normal_interp)
SMOOTH(VEC3, color_interp)
SMOOTH(FLOAT, alpha_interp)
SMOOTH(VEC2, uv_interp)
FLAT(INT, object_id)
FLAT(FLOAT, _roughness)
FLAT(FLOAT, metallic)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(workbench_color_material)
.define("WORKBENCH_COLOR_MATERIAL")
.storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]");
DEFINE("WORKBENCH_COLOR_MATERIAL")
STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[])
GPU_SHADER_CREATE_END()
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(WB_TEXTURE_SLOT, ImageType::FLOAT_2D, "imageTexture", Frequency::BATCH)
.sampler(WB_TILE_ARRAY_SLOT, ImageType::FLOAT_2D_ARRAY, "imageTileArray", Frequency::BATCH)
.sampler(WB_TILE_DATA_SLOT, ImageType::FLOAT_1D_ARRAY, "imageTileData", Frequency::BATCH)
.push_constant(Type::BOOL, "isImageTile")
.push_constant(Type::BOOL, "imagePremult")
.push_constant(Type::FLOAT, "imageTransparencyCutoff");
DEFINE("WORKBENCH_COLOR_TEXTURE")
DEFINE("WORKBENCH_TEXTURE_IMAGE_ARRAY")
DEFINE("WORKBENCH_COLOR_MATERIAL")
STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[])
SAMPLER_FREQ(WB_TEXTURE_SLOT, FLOAT_2D, imageTexture, BATCH)
SAMPLER_FREQ(WB_TILE_ARRAY_SLOT, FLOAT_2D_ARRAY, imageTileArray, BATCH)
SAMPLER_FREQ(WB_TILE_DATA_SLOT, FLOAT_1D_ARRAY, imageTileData, BATCH)
PUSH_CONSTANT(BOOL, isImageTile)
PUSH_CONSTANT(BOOL, imagePremult)
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)
.define("WORKBENCH_NEXT")
.uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data")
.vertex_out(workbench_material_iface)
.additional_info("draw_view");
DEFINE("WORKBENCH_NEXT")
UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data)
VERTEX_OUT(workbench_material_iface)
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)
/* 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. */
.fragment_out(0, Type::VEC4, "out_transparent_accum")
.fragment_out(1, Type::VEC4, "out_revealage_accum")
.fragment_out(2, Type::UINT, "out_object_id")
.push_constant(Type::BOOL, "forceShadowing")
.typedef_source("workbench_shader_shared.h")
.fragment_source("workbench_transparent_accum_frag.glsl");
FRAGMENT_OUT(0, VEC4, out_transparent_accum)
FRAGMENT_OUT(1, VEC4, out_revealage_accum)
FRAGMENT_OUT(2, UINT, out_object_id)
PUSH_CONSTANT(BOOL, forceShadowing)
TYPEDEF_SOURCE("workbench_shader_shared.h")
FRAGMENT_SOURCE("workbench_transparent_accum_frag.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(workbench_opaque)
.fragment_out(0, Type::VEC4, "out_material")
.fragment_out(1, Type::VEC2, "out_normal")
.fragment_out(2, Type::UINT, "out_object_id")
.typedef_source("workbench_shader_shared.h")
.fragment_source("workbench_prepass_frag.glsl");
FRAGMENT_OUT(0, VEC4, out_material)
FRAGMENT_OUT(1, VEC2, out_normal)
FRAGMENT_OUT(2, UINT, out_object_id)
TYPEDEF_SOURCE("workbench_shader_shared.h")
FRAGMENT_SOURCE("workbench_prepass_frag.glsl")
GPU_SHADER_CREATE_END()
/** \} */
@ -113,9 +129,15 @@ GPU_SHADER_CREATE_INFO(workbench_opaque)
/** \name Variations Declaration
* \{ */
GPU_SHADER_CREATE_INFO(workbench_flat).define("WORKBENCH_SHADING_FLAT");
GPU_SHADER_CREATE_INFO(workbench_studio).define("WORKBENCH_SHADING_STUDIO");
GPU_SHADER_CREATE_INFO(workbench_matcap).define("WORKBENCH_SHADING_MATCAP");
GPU_SHADER_CREATE_INFO(workbench_flat)
DEFINE("WORKBENCH_SHADING_FLAT")
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, ...) \
CREATE_INFO_VARIANT(prefix##_clip, drw_clipped, __VA_ARGS__) \

View File

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

View File

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

View File

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