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.
2 changed files with 30 additions and 24 deletions
Showing only changes of commit 5554ffd998 - Show all commits

View File

@ -24,6 +24,7 @@
#include "gpu_shader_create_info_private.hh"
#include "gpu_shader_dependency_private.hh"
#undef GPU_SHADER_NAMED_INTERFACE_INFO
#undef GPU_SHADER_INTERFACE_INFO
#undef GPU_SHADER_CREATE_INFO
@ -446,8 +447,14 @@ void gpu_shader_create_info_init()
g_create_infos = new CreateInfoDictionnary();
g_interfaces = new InterfaceDictionnary();
#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name) \
StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface, _inst_name); \
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \
StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface, #_inst_name); \
StageInterfaceInfo &_interface = *ptr_##_interface; \
g_interfaces->add_new(#_interface, ptr_##_interface); \
_interface
#define GPU_SHADER_INTERFACE_INFO(_interface) \
StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface); \
StageInterfaceInfo &_interface = *ptr_##_interface; \
g_interfaces->add_new(#_interface, ptr_##_interface); \
_interface

View File

@ -39,6 +39,7 @@
namespace blender::gpu::shader {
#if defined(GLSL_CPP_STUBS)
# error
# define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \
namespace _interface { \
struct {
@ -74,54 +75,52 @@ namespace blender::gpu::shader {
#endif
#ifndef GLSL_CPP_STUBS
# define SMOOTH(type, name) .smooth(type, name)
# define FLAT(type, name) .flat(type, name)
# define NO_PERSPECTIVE(type, name) .no_perspective(type, name)
# define SMOOTH(type, name) .smooth(Type::type, #name)
# define FLAT(type, name) .flat(Type::type, #name)
# define NO_PERSPECTIVE(type, name) .no_perspective(Type::type, #name)
/* LOCAL_GROUP_SIZE(int size_x, int size_y = -1, int size_z = -1) */
# define LOCAL_GROUP_SIZE(...) .local_group_size(__VA_ARGS__)
# define VERTEX_IN(slot, type, name) .vertex_in(slot, Type::##type, #name)
# define VERTEX_IN(slot, type, name) .vertex_in(slot, Type::type, #name)
# define VERTEX_OUT(stage_interface) .vertex_out(stage_interface)
/* TO REMOVE. */
# define GEOMETRY_LAYOUT(...) .geometry_layout(__VA_ARGS__)
# define GEOMETRY_OUT(stage_interface) .geometry_out(stage_interface)
# define SUBPASS_IN(slot, type, name, rog) .subpass_in(slot, Type::##type, #name, rog)
# define SUBPASS_IN(slot, type, name, rog) .subpass_in(slot, Type::type, #name, rog)
# define FRAGMENT_OUT(slot, type, name) .fragment_out(slot, Type::##type, #name)
# define FRAGMENT_OUT_DUAL(slot, type, name, blend) \
.fragment_out(slot, Type::##type, #name, blend)
# define FRAGMENT_OUT(slot, type, name) .fragment_out(slot, Type::type, #name)
# define FRAGMENT_OUT_DUAL(slot, type, name, blend) .fragment_out(slot, Type::type, #name, blend)
# define FRAGMENT_OUT_ROG(slot, type, name, rog) \
.fragment_out(slot, Type::##type, #name, DualBlend::NONE, rog)
.fragment_out(slot, Type::type, #name, DualBlend::NONE, rog)
# define EARLY_FRAGMENT_TEST(enable) .early_fragment_test(enable)
# define DEPTH_WRITE(value) .depth_write(value)
# define SPECIALIZATION_CONSTANT(type, name, default_value) \
.specialization_constant(Type::##type, #name, default_value)
.specialization_constant(Type::type, #name, default_value)
# define PUSH_CONSTANT(type, name) .push_constant(Type::##type, #name)
# define PUSH_CONSTANT_ARRAY(type, name, array_size) \
.push_constant(Type::##type, #name, array_size)
# define PUSH_CONSTANT(type, name) .push_constant(Type::type, #name)
# define PUSH_CONSTANT_ARRAY(type, name, array_size) .push_constant(Type::type, #name, array_size)
# define UNIFORM_BUF(slot, type_name, name, freq) .uniform_buf(slot, #type_name, #name)
# define UNIFORM_BUF(slot, type_name, name) .uniform_buf(slot, #type_name, #name)
# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) \
.uniform_buf(slot, #type_name, #name, Frequency::##freq)
.uniform_buf(slot, #type_name, #name, Frequency::freq)
# define STORAGE_BUF(slot, qualifiers, type_name, name) \
.storage_buf(slot, Qualifier::##qualifiers, #type_name, #name, freq)
.storage_buf(slot, Qualifier::qualifiers, #type_name, #name, freq)
# define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq) \
.storage_buf(slot, Qualifier::##qualifiers, #type_name, #name, Frequency::##freq)
.storage_buf(slot, Qualifier::qualifiers, #type_name, #name, Frequency::freq)
# define SAMPLER(slot, type, name) .sampler(slot, ImageType::##type, #name)
# define SAMPLER(slot, type, name) .sampler(slot, ImageType::type, #name)
# define SAMPLER_FREQ(slot, type, name, freq) \
.sampler(slot, ImageType::##type, #name, Frequency::##freq)
.sampler(slot, ImageType::type, #name, Frequency::freq)
# define IMAGE(slot, format, qualifiers, type, name) \
.image(slot, format, Qualifier::##qualifiers, ImageType::##type, #name)
.image(slot, format, Qualifier::qualifiers, ImageType::type, #name)
# define IMAGE_FREQ(slot, format, qualifiers, type, name, freq) \
.image(slot, format, Qualifier::##qualifiers, ImageType::##type, #name, Frequency::##freq)
.image(slot, format, Qualifier::qualifiers, ImageType::type, #name, Frequency::freq)
# define BUILTINS(builtin) .builtins(builtin)
@ -211,7 +210,7 @@ namespace blender::gpu::shader {
# define PUSH_CONSTANT(type, name) const type name = {};
# define PUSH_CONSTANT_ARRAY(type, name, array_size) const type name[array_size] = {};
# define UNIFORM_BUF(slot, type_name, name, freq) const type_name name;
# define UNIFORM_BUF(slot, type_name, name) const type_name name;
# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) const type_name name;
# define STORAGE_BUF(slot, qualifiers, type_name, name) qualifiers type_name name;