From af64a488c95708c57e356c45a5aa44ff835a0381 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 3 Mar 2026 15:36:50 -0600 Subject: [PATCH] move type name out of shader semantic macro --- src/base/base.cgh | 20 ++++++++-------- src/pp/pp_vis/pp_vis_gpu.gh | 20 ++++++++-------- src/proto/proto.lay | 4 ++-- src/proto/{proto_shaders.g => proto_gpu.g} | 10 ++++---- src/proto/{proto_shaders.gh => proto_gpu.gh} | 6 ++--- src/ui/ui_gpu.gh | 24 ++++++++++---------- 6 files changed, 42 insertions(+), 42 deletions(-) rename src/proto/{proto_shaders.g => proto_gpu.g} (74%) rename src/proto/{proto_shaders.gh => proto_gpu.gh} (85%) diff --git a/src/base/base.cgh b/src/base/base.cgh index 90309393..325e7840 100644 --- a/src/base/base.cgh +++ b/src/base/base.cgh @@ -741,16 +741,16 @@ Inline b32 MatchU128(u128 a, u128 b) { return a.lo == b.lo && a.hi == b.hi; } Struct(PixelShader) { ResourceKey resource; }; Struct(ComputeShader) { ResourceKey resource; }; #elif IsGpu - #define Semantic(type, name) type name : name - #define DeclComputeShader(name, x) [numthreads(x, 1, 1)] void name(Semantic(u32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define DeclComputeShader2D(name, x, y) [numthreads(x, y, 1)] void name(Semantic(Vec2U32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define DeclComputeShader3D(name, x, y, z) [numthreads(x, y, z)] void name(Semantic(Vec3U32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define DeclVertexShader(name, return_type) return_type name(Semantic(u32, SV_InstanceID), Semantic(u32, SV_VertexID)) - #define DeclPixelShader(name, return_type, ...) return_type name(__VA_ARGS__) - #define ImplComputeShader(name) void name(Semantic(u32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define ImplComputeShader2D(name) void name(Semantic(Vec2U32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define ImplComputeShader3D(name) void name(Semantic(Vec3U32, SV_DispatchThreadID), Semantic(u32, SV_GroupIndex)) - #define ImplVertexShader(name, return_type) return_type name(Semantic(u32, SV_InstanceID), Semantic(u32, SV_VertexID)) + #define Semantic(name) name : name + #define DeclComputeShader(name, x) [numthreads(x, 1, 1)] ImplComputeShader(name) + #define DeclComputeShader2D(name, x, y) [numthreads(x, y, 1)] ImplComputeShader2D(name) + #define DeclComputeShader3D(name, x, y, z) [numthreads(x, y, z)] ImplComputeShader3D(name) + #define DeclVertexShader(name, return_type) ImplVertexShader(name, return_type) + #define DeclPixelShader(name, return_type, ...) ImplPixelShader(name, return_type, __VA_ARGS__) + #define ImplComputeShader(name) void name(u32 Semantic(SV_DispatchThreadID), u32 Semantic(SV_GroupThreadID), u32 Semantic(SV_GroupIndex), u32 Semantic(SV_GroupID)) + #define ImplComputeShader2D(name) void name(Vec2U32 Semantic(SV_DispatchThreadID), Vec2U32 Semantic(SV_GroupThreadID), u32 Semantic(SV_GroupIndex), Vec2U32 Semantic(SV_GroupID)) + #define ImplComputeShader3D(name) void name(Vec3U32 Semantic(SV_DispatchThreadID), Vec3U32 Semantic(SV_GroupThreadID), u32 Semantic(SV_GroupIndex), Vec3U32 Semantic(SV_GroupID)) + #define ImplVertexShader(name, return_type) return_type name(u32 Semantic(SV_InstanceID), u32 Semantic(SV_VertexID)) #define ImplPixelShader(name, return_type, ...) return_type name(__VA_ARGS__) #endif diff --git a/src/pp/pp_vis/pp_vis_gpu.gh b/src/pp/pp_vis/pp_vis_gpu.gh index d1cfb891..1ba90fb0 100644 --- a/src/pp/pp_vis/pp_vis_gpu.gh +++ b/src/pp/pp_vis/pp_vis_gpu.gh @@ -3,15 +3,15 @@ Struct(V_QuadPSInput) { - Semantic(Vec4, sv_position); - Semantic(Vec2, world_pos); - Semantic(Vec2, samp_uv); - Semantic(nointerpolation V_Quad, quad); + Vec4 Semantic(sv_position); + Vec2 Semantic(world_pos); + Vec2 Semantic(samp_uv); + nointerpolation V_Quad Semantic(quad); }; Struct(V_QuadPSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; //////////////////////////////////////////////////////////// @@ -19,12 +19,12 @@ Struct(V_QuadPSOutput) Struct(V_CompositePSInput) { - Semantic(Vec4, sv_position); + Vec4 Semantic(sv_position); }; Struct(V_CompositePSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; //////////////////////////////////////////////////////////// @@ -32,13 +32,13 @@ Struct(V_CompositePSOutput) Struct(V_DVertPSInput) { - Semantic(Vec4, sv_position); - Semantic(Vec4, color_lin); + Vec4 Semantic(sv_position); + Vec4 Semantic(color_lin); }; Struct(V_DVertPSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; //////////////////////////////////////////////////////////// diff --git a/src/proto/proto.lay b/src/proto/proto.lay index 474b5569..d773b538 100644 --- a/src/proto/proto.lay +++ b/src/proto/proto.lay @@ -26,5 +26,5 @@ @IncludeC proto.c -@IncludeG proto_shaders.gh -@IncludeG proto_shaders.g +@IncludeG proto_gpu.gh +@IncludeG proto_gpu.g diff --git a/src/proto/proto_shaders.g b/src/proto/proto_gpu.g similarity index 74% rename from src/proto/proto_shaders.g rename to src/proto/proto_gpu.g index c86d6aaa..30b23a32 100644 --- a/src/proto/proto_shaders.g +++ b/src/proto/proto_gpu.g @@ -3,9 +3,9 @@ ImplComputeShader2D(PT_TestCS) { - StructuredBuffer sb = G_Dereference(PT_ShaderConst_TestBuff); + StructuredBuffer sb = G_SDeref(PT_ShaderConst_TestBuff); + RWTexture2D target_tex = G_SDerefRW(PT_ShaderConst_TestTarget); - RWTexture2D target_tex = G_DereferenceRW(PT_ShaderConst_TestTarget); Vec2U32 target_tex_size = countof(target_tex); Vec2I32 id = SV_DispatchThreadID; @@ -35,9 +35,9 @@ ImplVertexShader(PT_BlitVS, PT_BlitPSInput) ImplPixelShader(PT_BlitPS, PT_BlitPSOutput, PT_BlitPSInput input) { - SamplerState sampler = G_Dereference(PT_ShaderConst_BlitSampler); - Texture2D tex = G_Dereference(PT_ShaderConst_BlitSrc); - Texture3D noise = G_Dereference(PT_ShaderConst_NoiseTex); + SamplerState sampler = G_SDeref(PT_ShaderConst_BlitSampler); + Texture2D tex = G_SDeref(PT_ShaderConst_BlitSrc); + Texture3D noise = G_SDeref(PT_ShaderConst_NoiseTex); Vec2 uv = input.src_uv; Vec4 tex_col = tex.Sample(sampler, uv); diff --git a/src/proto/proto_shaders.gh b/src/proto/proto_gpu.gh similarity index 85% rename from src/proto/proto_shaders.gh rename to src/proto/proto_gpu.gh index 805636f6..75e0c312 100644 --- a/src/proto/proto_shaders.gh +++ b/src/proto/proto_gpu.gh @@ -11,13 +11,13 @@ Struct(TestStruct) Struct(PT_BlitPSInput) { - Semantic(Vec4, sv_position); - Semantic(Vec2, src_uv); + Vec4 Semantic(sv_position); + Vec2 Semantic(src_uv); }; Struct(PT_BlitPSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; //////////////////////////////////////////////////////////// diff --git a/src/ui/ui_gpu.gh b/src/ui/ui_gpu.gh index 93ee8fc5..764e2772 100644 --- a/src/ui/ui_gpu.gh +++ b/src/ui/ui_gpu.gh @@ -3,19 +3,19 @@ Struct(UI_DRectPSInput) { - Semantic(Vec4, sv_position); - Semantic(Vec4, base_background_premul); - Semantic(Vec4, base_border_premul); - Semantic(Vec4, tint_premul); - Semantic(Vec4, debug_premul); - Semantic(Vec2, rect_uv); - Semantic(Vec2, tex_uv); - nointerpolation Semantic(UI_GpuRect, rect); + Vec4 Semantic(sv_position); + Vec4 Semantic(base_background_premul); + Vec4 Semantic(base_border_premul); + Vec4 Semantic(tint_premul); + Vec4 Semantic(debug_premul); + Vec2 Semantic(rect_uv); + Vec2 Semantic(tex_uv); + nointerpolation UI_GpuRect Semantic(rect); }; Struct(UI_DRectPSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; //////////////////////////////////////////////////////////// @@ -23,13 +23,13 @@ Struct(UI_DRectPSOutput) Struct(UI_BlitPSInput) { - Semantic(Vec4, sv_position); - Semantic(Vec2, src_uv); + Vec4 Semantic(sv_position); + Vec2 Semantic(src_uv); }; Struct(UI_BlitPSOutput) { - Semantic(Vec4, sv_target0); + Vec4 Semantic(sv_target0); }; ////////////////////////////////////////////////////////////