shader constant tweak vars
This commit is contained in:
parent
003a77d410
commit
8aa44b5deb
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<typename T> u32 countof(StructuredBuffer<T> buff) { u32 result; buff.GetDimensions(result); return result; }
|
||||
template<typename T> u32 countof(RWStructuredBuffer<T> 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<typename T> u32 countof(RWTexture1D<T> tex) { u32 result; tex.GetDimensions(result); return result; }
|
||||
Vec2U32 countof(Texture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; }
|
||||
template<typename T> Vec2U32 countof(RWTexture2D<T> 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<typename T> Vec3U32 countof(RWTexture3D<T> tex) { Vec3U32 result; tex.GetDimensions(result.x, result.y, result.z); return result; }
|
||||
template<typename T> u32 countof(StructuredBuffer<T> buff) { u32 result; buff.GetDimensions(result); return result; }
|
||||
template<typename T> u32 countof(RWStructuredBuffer<T> 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<typename T> u32 countof(RWTexture1D<T> tex) { u32 result; tex.GetDimensions(result); return result; }
|
||||
Vec2U32 countof(Texture2D tex) { Vec2U32 result; tex.GetDimensions(result.x, result.y); return result; }
|
||||
template<typename T> Vec2U32 countof(RWTexture2D<T> 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<typename T> Vec3U32 countof(RWTexture3D<T> 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
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user