Skip to content

Commit

Permalink
run randomcompute on both vs and ps
Browse files Browse the repository at this point in the history
  • Loading branch information
RenfengLiu committed Aug 13, 2024
1 parent c728d6b commit 3652e26
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
11 changes: 10 additions & 1 deletion assets/benchmarks/shaders/Benchmark_Quad.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ struct VSOutputPos {
float4 position : SV_POSITION;
};

#endif // BENCHMARKS_VS_OUTPUT_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);;
}

#endif // BENCHMARKS_QUAD_HLSLI
4 changes: 3 additions & 1 deletion assets/benchmarks/shaders/Benchmark_SolidColor.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 0 additions & 9 deletions assets/benchmarks/shaders/Benchmark_VsSimpleQuads.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class GraphicsBenchmarkApp
std::shared_ptr<KnobDropdown<grfx::Format>> pFramebufferFormat;
std::shared_ptr<KnobDropdown<std::pair<int, int>>> pResolution;

std::shared_ptr<KnobFlag<int>> pKnobVsAluCount;
std::shared_ptr<KnobFlag<int>> pKnobAluCount;

private:
// =====================================================================
Expand Down

0 comments on commit 3652e26

Please sign in to comment.