diff --git a/src/base/base_shader.gh b/src/base/base_shader.gh index 5730680e..046f3df1 100644 --- a/src/base/base_shader.gh +++ b/src/base/base_shader.gh @@ -79,7 +79,7 @@ u32 countof(T arr[N]) //////////////////////////////////////////////////////////// //~ Derivative helpers -#define fwidth_fine(v) (abs(ddx_fine((v))) + abs(ddx_fine((v)))) +#define fwidth_fine(v) (abs(ddx_fine((v))) + abs(ddy_fine((v)))) //////////////////////////////////////////////////////////// //~ Color helpers diff --git a/src/glyph_cache/glyph_cache.c b/src/glyph_cache/glyph_cache.c index 3f3c807a..180ead43 100644 --- a/src/glyph_cache/glyph_cache.c +++ b/src/glyph_cache/glyph_cache.c @@ -171,20 +171,7 @@ GC_Run GC_RunFromString32(Arena *arena, String32 str32, GC_FontKey font, f32 fon GC_Glyph *glyph = ready_glyphs[glyph_idx]; GC_RunRect *rect = &result.rects[glyph_idx]; - f32 advance = glyph->advance; - if (TweakBool("Ceil glyph advances", 0)) - { - advance = CeilF32(advance); - } - if (TweakBool("Floor glyph advances", 0)) - { - advance = FloorF32(advance); - } - if (TweakBool("Round glyph advances", 1)) - { - advance = RoundF32(advance); - } - + f32 advance = RoundF32(glyph->advance); Rng2 bounds = glyph->bounds; rect->tex = glyph->atlas->tex_ref; diff --git a/src/gpu/gpu_dx12/gpu_dx12_core.c b/src/gpu/gpu_dx12/gpu_dx12_core.c index 26de42a9..d618a56f 100644 --- a/src/gpu/gpu_dx12/gpu_dx12_core.c +++ b/src/gpu/gpu_dx12/gpu_dx12_core.c @@ -1720,10 +1720,17 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle) for (i32 i = 0; i < countof(bound_compute_constants); ++i) { bound_compute_constants[i] = U64Max; } for (i32 i = 0; i < countof(bound_graphics_constants); ++i) { bound_graphics_constants[i] = U64Max; } + // Fill built-in constants if (!G_IsRefNil(queue->print_buffer_ref)) { slotted_constants[G_ShaderConst_PrintBufferRef] = queue->print_buffer_ref.v; } + { + b32 tweak_b32 = TweakBool("GPU tweak-bool", 1); + f32 tweak_f32 = TweakFloat("GPU tweak-float", 1, 0, 1, .precision = 3); + slotted_constants[G_ShaderConst_TweakB32] = tweak_b32; + slotted_constants[G_ShaderConst_TweakF32] = *(u32 *)&tweak_f32; + } // Rasterizer state D3D12_VIEWPORT bound_viewport = Zi; diff --git a/src/gpu/gpu_shader_core.cgh b/src/gpu/gpu_shader_core.cgh index 4370081e..d7141116 100644 --- a/src/gpu/gpu_shader_core.cgh +++ b/src/gpu/gpu_shader_core.cgh @@ -35,11 +35,11 @@ Struct(G_SamplerStateRef) { u32 v; }; // // D3D12 exposes 64 root constants and Vulkan exposes 32 push constants. -// Supposedly amd hardware will spill constants to scratch memory once there -// are more than 13: https://gpuopen.com/learn/rdna-performance-guide/ +// Supposedly amd hardware will start spilling constants once there +// are more than 12: https://gpuopen.com/learn/rdna-performance-guide/ // #define G_NumGeneralPurposeConstants (8) // Constants available for any usage -#define G_NumReservedConstants (1) // Constants reserved for usage by the GPU layer +#define G_NumReservedConstants (4) // Constants reserved for internal usage by the GPU layer #define G_NumConstants (G_NumGeneralPurposeConstants + G_NumReservedConstants) #if IsLanguageC @@ -55,6 +55,22 @@ Struct(G_SamplerStateRef) { u32 v; }; #define G_DeclConstant(type, name, slot) G_ForceDeclConstant(type, name, slot) #endif +//////////////////////////////////////////////////////////// +//~ Reserved constants + +// The constants declared below assume this configuration is accurate for slot usage +StaticAssert(G_NumGeneralPurposeConstants == 8); +StaticAssert(G_NumReservedConstants >= 3); + +G_ForceDeclConstant(G_RWByteAddressBufferRef, G_ShaderConst_PrintBufferRef, 8); +G_ForceDeclConstant(b32, G_ShaderConst_TweakB32, 9); +G_ForceDeclConstant(f32, G_ShaderConst_TweakF32, 10); + +#if IsLanguageG + #define G_TweakBool G_ShaderConst_TweakB32 + #define G_TweakFloat G_ShaderConst_TweakF32 +#endif + //////////////////////////////////////////////////////////// //~ Resource dereference @@ -83,27 +99,18 @@ Struct(G_SamplerStateRef) { u32 v; }; //~ Size helpers #if IsLanguageG - template u32 countof(StructuredBuffer buff) { u32 result; buff.GetDimensions(result); return result; } - template u32 countof(RWStructuredBuffer buff) { u32 result; buff.GetDimensions(result); return result; } - u32 countof(ByteAddressBuffer buff) { u32 result; buff.GetDimensions(result); return result; } - u32 countof(RWByteAddressBuffer buff) { u32 result; buff.GetDimensions(result); return result; } - u32 countof(Texture1D tex) { u32 result; tex.GetDimensions(result); return result; } - template u32 countof(RWTexture1D tex) { u32 result; tex.GetDimensions(result); return result; } - Vec2U32 countof(Texture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; } - template Vec2U32 countof(RWTexture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; } - Vec3U32 countof(Texture3D tex) { Vec3U32 result; tex.GetDimensions(result.x, result.y, result.z); return result; } - template Vec3U32 countof(RWTexture3D tex) { Vec3U32 result; tex.GetDimensions(result.x, result.y, result.z); return result; } + template u32 countof(StructuredBuffer buff) { u32 result; buff.GetDimensions(result); return result; } + template u32 countof(RWStructuredBuffer buff) { u32 result; buff.GetDimensions(result); return result; } + u32 countof(ByteAddressBuffer buff) { u32 result; buff.GetDimensions(result); return result; } + u32 countof(RWByteAddressBuffer buff) { u32 result; buff.GetDimensions(result); return result; } + u32 countof(Texture1D tex) { u32 result; tex.GetDimensions(result); return result; } + template u32 countof(RWTexture1D tex) { u32 result; tex.GetDimensions(result); return result; } + Vec2U32 countof(Texture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; } + template Vec2U32 countof(RWTexture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; } + Vec3U32 countof(Texture3D tex) { Vec3U32 result; tex.GetDimensions(result.x, result.y, result.z); return result; } + template Vec3U32 countof(RWTexture3D tex) { Vec3U32 result; tex.GetDimensions(result.x, result.y, result.z); return result; } #endif -//////////////////////////////////////////////////////////// -//~ Reserved constants - -// The constants declared below assume this configuration is accurate for slot usage -StaticAssert(G_NumGeneralPurposeConstants == 8); -StaticAssert(G_NumReservedConstants == 1); - -G_ForceDeclConstant(G_RWByteAddressBufferRef, G_ShaderConst_PrintBufferRef, 8); - //////////////////////////////////////////////////////////// //~ Debug printf diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 2f623a4c..d75eabef 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -1298,7 +1298,7 @@ void V_TickForever(WaveLaneCtx *lane) V_Palette *palette = &frame->palette; { - f32 palette_ease = TweakFloat("Command palette ease", 30, 1, 100) * frame->dt; + f32 palette_ease = TweakFloat("Debug palette ease", 30, 1, 100) * frame->dt; palette->show = LerpF32(palette->show, palette->pref_show, palette_ease); } if (palette->show > 0.001) @@ -1330,8 +1330,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_Push(BackgroundColor, window_background_color); UI_Push(BorderColor, window_border_color); UI_Push(BorderSize, theme.window_bd_sz); - // UI_Push(Rounding, UI_RPIX(15 * theme.rounding)); - UI_Push(Rounding, UI_RGROW(0.075 * theme.rounding)); + UI_Push(Rounding, UI_RGROW(0.095 * theme.rounding)); UI_Push(Width, UI_FNT(40, 0)); UI_Push(Height, UI_SHRINK(0, 0)); UI_Push(ChildLayoutAxis, Axis_Y); @@ -1362,7 +1361,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(FontSize, UI_Top(FontSize) * theme.h2); UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Width, UI_SHRINK(0, 1)); - UI_SetNext(Text, Lit("Command Palette")); + UI_SetNext(Text, Lit("Debug Palette")); UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_BuildBox(); diff --git a/src/ui/ui_shaders.g b/src/ui/ui_shaders.g index abe1cfc8..797ecaf3 100644 --- a/src/ui/ui_shaders.g +++ b/src/ui/ui_shaders.g @@ -98,7 +98,7 @@ PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input) // Border color { - f32 half_border_dist_fwidth = fwidth_fine(border_dist) * 0.5; + f32 half_border_dist_fwidth = fwidth(border_dist) * 0.5; f32 border_alpha = smoothstep(half_border_dist_fwidth, -half_border_dist_fwidth, border_dist); final_color = lerp(final_color, border_color, border_alpha); }