From 3652e26197277839bc8ba6cb53088f9d4f70770c Mon Sep 17 00:00:00 2001 From: Robin Liu Date: Tue, 13 Aug 2024 09:44:19 -0400 Subject: [PATCH] run randomcompute on both vs and ps --- assets/benchmarks/shaders/Benchmark_Quad.hlsli | 11 ++++++++++- assets/benchmarks/shaders/Benchmark_SolidColor.hlsl | 4 +++- .../benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl | 9 --------- benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp | 8 ++++---- benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/assets/benchmarks/shaders/Benchmark_Quad.hlsli b/assets/benchmarks/shaders/Benchmark_Quad.hlsli index 1c3c30ae6..019b955f8 100644 --- a/assets/benchmarks/shaders/Benchmark_Quad.hlsli +++ b/assets/benchmarks/shaders/Benchmark_Quad.hlsli @@ -30,4 +30,13 @@ struct VSOutputPos { float4 position : SV_POSITION; }; -#endif // BENCHMARKS_VS_OUTPUT_HLSLI \ No newline at end of file +float randomCompute(uint32_t instCount, float4 Position) { + float randNum = frac(float(instCount) * 123.456f); + for (uint32_t i = 0; i < instCount; i++) { + Position.z += Position.x * (1 - randNum) + randNum * Position.y; + } + + return frac(Position.z);; +} + +#endif // BENCHMARKS_QUAD_HLSLI \ No newline at end of file diff --git a/assets/benchmarks/shaders/Benchmark_SolidColor.hlsl b/assets/benchmarks/shaders/Benchmark_SolidColor.hlsl index 9eb1dceff..d423b7cbf 100644 --- a/assets/benchmarks/shaders/Benchmark_SolidColor.hlsl +++ b/assets/benchmarks/shaders/Benchmark_SolidColor.hlsl @@ -16,5 +16,7 @@ float4 psmain(VSOutputPos input) : SV_TARGET { - return float4(Config.ColorValue, 1.0f); + float4 color = float4(Config.ColorValue, 1.0f); + color.a = randomCompute(Config.InstCount, input.position); + return color; } \ No newline at end of file diff --git a/assets/benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl b/assets/benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl index d265ef093..88edecab3 100644 --- a/assets/benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl +++ b/assets/benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl @@ -14,15 +14,6 @@ #include "Benchmark_Quad.hlsli" -float randomCompute(uint32_t instCount, float4 Position) { - float randNum = frac(float(instCount) * 123.456f); - for (uint32_t i = 0; i < instCount; i++) { - Position.z += Position.x * (1 - randNum) + randNum * Position.y; - } - - return frac(Position.z);; -} - VSOutputPos vsmain(float4 Position : POSITION) { VSOutputPos result; result.position = Position; diff --git a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp index 13db124a5..b02ff99ae 100644 --- a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp +++ b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp @@ -183,9 +183,9 @@ void GraphicsBenchmarkApp::InitKnobs() pResolution->SetIndent(1); } - GetKnobManager().InitKnob(&pKnobVsAluCount, "vs-alu-instruction-count", /* defaultValue = */ 100, /* minValue = */ 100, 400); - pFullscreenQuadsCount->SetDisplayName("Number of ALU instructions in the vertex shader"); - pFullscreenQuadsCount->SetFlagDescription("Select the number of ALU instructions in the vertex shader."); + GetKnobManager().InitKnob(&pKnobAluCount, "alu-instruction-count", /* defaultValue = */ 100, /* minValue = */ 100, 400); + pKnobAluCount->SetDisplayName("Number of ALU instructions in the shader"); + pKnobAluCount->SetFlagDescription("Select the number of ALU instructions in the shader."); } void GraphicsBenchmarkApp::Config(ppx::ApplicationSettings& settings) @@ -1736,7 +1736,7 @@ void GraphicsBenchmarkApp::RecordCommandBufferFullscreenQuad(PerFrame& frame, si { // Vertex shader push constant { - mQuadPushConstant.InstCount = pKnobVsAluCount->GetValue(); + mQuadPushConstant.InstCount = pKnobAluCount->GetValue(); frame.cmd->PushGraphicsConstants(mQuadsPipelineInterfaces[0], GetPushConstCount(mQuadPushConstant.InstCount), &mQuadPushConstant.InstCount, offsetof(QuadPushConstant, InstCount) / sizeof(uint32_t)); } switch (pFullscreenQuadsType->GetValue()) { diff --git a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h index b014be134..27c505334 100644 --- a/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h +++ b/benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h @@ -528,7 +528,7 @@ class GraphicsBenchmarkApp std::shared_ptr> pFramebufferFormat; std::shared_ptr>> pResolution; - std::shared_ptr> pKnobVsAluCount; + std::shared_ptr> pKnobAluCount; private: // =====================================================================