diff --git a/Apps/02-HelloCube/HelloCubeApp.cpp b/Apps/02-HelloCube/HelloCubeApp.cpp index 3744b066a..b847b0c2f 100644 --- a/Apps/02-HelloCube/HelloCubeApp.cpp +++ b/Apps/02-HelloCube/HelloCubeApp.cpp @@ -155,11 +155,7 @@ class HelloCubeApp final // NOSONAR - destructor required Rhi::ProgramArgumentAccessors { #ifdef UNIFORMS_ENABLED - { // Uniforms argument is declared as root constant - { Rhi::ShaderType::Vertex, "g_uniforms" }, - Rhi::ProgramArgumentAccessType::FrameConstant, - Rhi::ProgramArgumentValueType::RootConstant - } + META_PROGRAM_ARG_ROOT_FRAME_CONSTANT(Rhi::ShaderType::Vertex, "g_uniforms") #endif }, GetScreenRenderPattern().GetAttachmentFormats() diff --git a/Apps/03-TexturedCube/TexturedCubeApp.cpp b/Apps/03-TexturedCube/TexturedCubeApp.cpp index 8714c73d7..33c702f32 100644 --- a/Apps/03-TexturedCube/TexturedCubeApp.cpp +++ b/Apps/03-TexturedCube/TexturedCubeApp.cpp @@ -125,17 +125,9 @@ void TexturedCubeApp::Init() } }, rhi::ProgramArgumentAccessors - { // Define arguments as root constants - { - { rhi::ShaderType::Pixel, "g_constants" }, - rhi::ProgramArgumentAccessType::Constant, - rhi::ProgramArgumentValueType::RootConstant - }, - { - { rhi::ShaderType::All, "g_uniforms" }, - rhi::ProgramArgumentAccessType::FrameConstant, - rhi::ProgramArgumentValueType::RootConstant - } + { + META_PROGRAM_ARG_ROOT_CONSTANT(rhi::ShaderType::Pixel, "g_constants"), + META_PROGRAM_ARG_ROOT_FRAME_CONSTANT(rhi::ShaderType::All, "g_uniforms") }, GetScreenRenderPattern().GetAttachmentFormats() } diff --git a/Apps/04-ShadowCube/ShadowCubeApp.cpp b/Apps/04-ShadowCube/ShadowCubeApp.cpp index 629345788..b72398910 100644 --- a/Apps/04-ShadowCube/ShadowCubeApp.cpp +++ b/Apps/04-ShadowCube/ShadowCubeApp.cpp @@ -147,21 +147,9 @@ void ShadowCubeApp::Init() }, rhi::ProgramArgumentAccessors { - { - { rhi::ShaderType::Pixel, "g_constants" }, - rhi::ProgramArgumentAccessType::Constant, - rhi::ProgramArgumentValueType::RootConstant - }, - { - { rhi::ShaderType::Pixel, "g_scene_uniforms" }, - rhi::ProgramArgumentAccessType::FrameConstant, - rhi::ProgramArgumentValueType::RootConstant - }, - { - { rhi::ShaderType::Vertex, "g_mesh_uniforms" }, - rhi::ProgramArgumentAccessType::Mutable, - rhi::ProgramArgumentValueType::RootConstant - } + META_PROGRAM_ARG_ROOT_CONSTANT(rhi::ShaderType::Pixel, "g_constants"), + META_PROGRAM_ARG_ROOT_FRAME_CONSTANT(rhi::ShaderType::Pixel, "g_scene_uniforms"), + META_PROGRAM_ARG_ROOT_MUTABLE(rhi::ShaderType::Vertex, "g_mesh_uniforms") }, GetScreenRenderPattern().GetAttachmentFormats() } diff --git a/Modules/Graphics/RHI/Interface/Include/Methane/Graphics/RHI/ProgramArgument.h b/Modules/Graphics/RHI/Interface/Include/Methane/Graphics/RHI/ProgramArgument.h index 527403276..fc80861a2 100644 --- a/Modules/Graphics/RHI/Interface/Include/Methane/Graphics/RHI/ProgramArgument.h +++ b/Modules/Graphics/RHI/Interface/Include/Methane/Graphics/RHI/ProgramArgument.h @@ -147,3 +147,44 @@ using ProgramArgumentBindingValue = std::variant; } // namespace Methane::Graphics::Rhi + +// Helper macroses for program argument accessors initialization in program descriptor: + +#define META_PROGRAM_ARG(shader_type, arg_name, access_type, value_type) \ + Methane::Graphics::Rhi::ProgramArgumentAccessor{ { shader_type, arg_name }, access_type, value_type } + +#define META_PROGRAM_ARG_ROOT(shader_type, arg_name, access_type) \ + META_PROGRAM_ARG(shader_type, arg_name, access_type, Methane::Graphics::Rhi::ProgramArgumentValueType::RootConstant) + +#define META_PROGRAM_ARG_ROOT_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_ROOT(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Constant) + +#define META_PROGRAM_ARG_ROOT_FRAME_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_ROOT(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::FrameConstant) + +#define META_PROGRAM_ARG_ROOT_MUTABLE(shader_type, arg_name) \ + META_PROGRAM_ARG_ROOT(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Mutable) + +#define META_PROGRAM_ARG_RESOURCE(shader_type, arg_name, access_type) \ + META_PROGRAM_ARG(shader_type, arg_name, access_type, Methane::Graphics::Rhi::ProgramArgumentValueType::ResourceView) + +#define META_PROGRAM_ARG_RESOURCE_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCE(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Constant) + +#define META_PROGRAM_ARG_RESOURCE_FRAME_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCE(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::FrameConstant) + +#define META_PROGRAM_ARG_RESOURCE_MUTABLE(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCE(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Mutable) + +#define META_PROGRAM_ARG_RESOURCES(shader_type, arg_name, access_type) \ + META_PROGRAM_ARG(shader_type, arg_name, access_type, Methane::Graphics::Rhi::ProgramArgumentValueType::ResourceViews) + +#define META_PROGRAM_ARG_RESOURCES_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCES(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Constant) + +#define META_PROGRAM_ARG_RESOURCES_FRAME_CONSTANT(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCES(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::FrameConstant) + +#define META_PROGRAM_ARG_RESOURCES_MUTABLE(shader_type, arg_name) \ + META_PROGRAM_ARG_RESOURCES(shader_type, arg_name, Methane::Graphics::Rhi::ProgramArgumentAccessType::Mutable)