/* Determine if file was included from C or from HLSL */ #if LanguageIsC # define K_IS_CPU 1 #else # define K_IS_CPU 0 #endif #if !K_IS_CPU /* ========================== * * Root signature * ========================== */ #define K_ROOTSIG \ "RootFlags(CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | SAMPLER_HEAP_DIRECTLY_INDEXED | ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), " \ "RootConstants(b0, num32BitConstants = 64), " \ \ "StaticSampler(s0, " \ "filter = FILTER_MIN_MAG_MIP_POINT, " \ "addressU = TEXTURE_ADDRESS_CLAMP, " \ "addressV = TEXTURE_ADDRESS_CLAMP, " \ "addressW = TEXTURE_ADDRESS_CLAMP, " \ "maxAnisotropy = 1)" SamplerState s_point_clamp : register(s0); #define K_ENTRY [RootSignature(K_ROOTSIG)] #endif /* ========================== * * Global textures * ========================== */ /* Blue noise */ #define K_BLUE_NOISE_TEX_ID 0 #define K_BLUE_NOISE_TEX_WIDTH 128 #define K_BLUE_NOISE_TEX_HEIGHT 128 #define K_BLUE_NOISE_TEX_DEPTH 64 /* ========================== * * Material shader structs * ========================== */ Struct(K_MaterialSig) { /* ----------------------------------------------------- */ Mat4x4 projection; /* 16 consts */ /* ----------------------------------------------------- */ u32 instances_urid; /* 01 consts */ u32 grids_urid; /* 01 consts */ u32 _pad0; /* 01 consts (padding) */ u32 _pad1; /* 01 consts (padding) */ /* ----------------------------------------------------- */ }; AssertRootConst(K_MaterialSig, 20); Struct(K_MaterialInstance) { u32 tex_nurid; u32 grid_id; Xform xf; Vec2 uv0; Vec2 uv1; u32 tint_srgb; u32 is_light; Vec3 light_emittance_srgb; }; Struct(K_MaterialGrid) { f32 line_thickness; f32 line_spacing; Vec2 offset; u32 bg0_srgb; u32 bg1_srgb; u32 line_srgb; u32 x_srgb; u32 y_srgb; }; /* ========================== * * Flood shader structs * ========================== */ Struct(K_FloodSig) { /* ----------------------------------------------------- */ i32 step_len; /* 01 consts */ u32 emittance_tex_urid; /* 01 consts */ u32 read_flood_tex_urid; /* 01 consts */ u32 target_flood_tex_urid; /* 01 consts */ /* ----------------------------------------------------- */ u32 tex_width; /* 01 consts */ u32 tex_height; /* 01 consts */ u32 _pad0; /* 01 consts (padding) */ u32 _pad1; /* 01 consts (padding) */ /* ----------------------------------------------------- */ }; AssertRootConst(K_FloodSig, 8); /* ========================== * * Shade shader structs * ========================== */ #define K_SHADE_FLAG_NONE (0 << 0) #define K_SHADE_FLAG_DISABLE_EFFECTS (1 << 0) Struct(K_ShadeSig) { /* ----------------------------------------------------- */ Vec4I32 frame_seed; /* 04 consts */ /* ----------------------------------------------------- */ u32 flags; /* 01 consts */ u32 _pad0; /* 01 consts (padding) */ u32 tex_width; /* 01 consts */ u32 tex_height; /* 01 consts */ /* ----------------------------------------------------- */ Vec2 camera_offset; /* 02 consts */ u32 frame_index; /* 01 consts */ u32 albedo_tex_urid; /* 01 consts */ /* ----------------------------------------------------- */ u32 emittance_tex_urid; /* 01 consts */ u32 emittance_flood_tex_urid; /* 01 consts */ u32 read_tex_urid; /* 01 consts */ u32 target_tex_urid; /* 01 consts */ /* ----------------------------------------------------- */ }; AssertRootConst(K_ShadeSig, 16); /* ========================== * * Shape shader structs * ========================== */ Struct(K_ShapeSig) { /* ----------------------------------------------------- */ Mat4x4 projection; /* 16 consts */ /* ----------------------------------------------------- */ u32 verts_urid; /* 01 consts */ u32 _pad0; /* 01 consts (padding) */ u32 _pad1; /* 01 consts (padding) */ u32 _pad2; /* 01 consts (padding) */ /* ----------------------------------------------------- */ }; AssertRootConst(K_ShapeSig, 20); Struct(K_ShapeVert) { Vec2 pos; u32 color_srgb; }; /* ========================== * * UI shader structs * ========================== */ Struct(K_UiSig) { /* ----------------------------------------------------- */ Mat4x4 projection; /* 16 consts */ /* ----------------------------------------------------- */ u32 instances_urid; /* 01 consts */ u32 _pad0; /* 01 consts (padding) */ u32 _pad1; /* 01 consts (padding) */ u32 _pad2; /* 01 consts (padding) */ /* ----------------------------------------------------- */ }; AssertRootConst(K_UiSig, 20); Struct(K_UiInstance) { u32 tex_nurid; u32 grid_id; Xform xf; Vec2 uv0; Vec2 uv1; u32 tint_srgb; }; /* ========================== * * Blit shader structs * ========================== */ #define K_BLIT_FLAG_NONE (0 << 0) #define K_BLIT_FLAG_TONE_MAP (1 << 0) #define K_BLIT_FLAG_GAMMA_CORRECT (1 << 1) Struct(K_BlitSig) { /* ----------------------------------------------------- */ Mat4x4 projection; /* 16 consts */ /* ----------------------------------------------------- */ u32 flags; /* 01 consts */ u32 tex_urid; /* 01 consts */ f32 exposure; /* 01 consts */ f32 gamma; /* 01 consts */ /* ----------------------------------------------------- */ }; AssertRootConst(K_BlitSig, 20);