Skip to content

Commit

Permalink
Testcase: Alpha blending
Browse files Browse the repository at this point in the history
  • Loading branch information
RenfengLiu committed Aug 15, 2024
1 parent 6d643cd commit c21fe09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ppx/graphics_util.h"
#include "ppx/grfx/grfx_enums.h"
#include "ppx/grfx/grfx_format.h"
#include "ppx/log.h"
#include "ppx/math_config.h"
#include "ppx/timer.h"
#include <cstdint>
Expand Down Expand Up @@ -193,17 +194,17 @@ void GraphicsBenchmarkApp::InitKnobs()
pKnobTextureCount->SetDisplayName("Number of texture to load in the shader");
pKnobTextureCount->SetFlagDescription("Select the number of texture to load in the shader.");

GetKnobManager().InitKnob(&pKnobDisablePsOutput, "disable-ps-output", false);
pKnobDisablePsOutput->SetDisplayName("Disable PS output");
pKnobDisablePsOutput->SetFlagDescription("Disable PS output.");

GetKnobManager().InitKnob(&pKnobViewportHeightScale, "viewport_height_scale", 0, kAvailableViewportScales);
pKnobViewportHeightScale->SetDisplayName("Scale viewport height");
pKnobViewportHeightScale->SetFlagDescription("Scale viewport height to 1, 1/2, 1/4");

GetKnobManager().InitKnob(&pKnobViewportWidthScale, "viewport_width_scale", 0, kAvailableViewportScales);
pKnobViewportWidthScale->SetDisplayName("Scale viewport width");
pKnobViewportWidthScale->SetFlagDescription("Scale viewport width to 1, 1/2, 1/4");

GetKnobManager().InitKnob(&pKnobQuadBlendMode, "quad_blend_mode", 0, kQuadBlendModes);
pKnobQuadBlendMode->SetDisplayName("Blend mode for quad");
pKnobQuadBlendMode->SetFlagDescription("Bend mode for quad to none, alpha, disable_output");
}

void GraphicsBenchmarkApp::Config(ppx::ApplicationSettings& settings)
Expand Down Expand Up @@ -787,7 +788,7 @@ Result GraphicsBenchmarkApp::CompilePipeline(const QuadPipelineKey& key)
gpCreateInfo.frontFace = grfx::FRONT_FACE_CW;
gpCreateInfo.depthReadEnable = false;
gpCreateInfo.depthWriteEnable = false;
gpCreateInfo.blendModes[0] = pKnobDisablePsOutput->GetValue() ? grfx::BLEND_MODE_DISABLE_OUTPUT : grfx::BLEND_MODE_NONE;
gpCreateInfo.blendModes[0] = pKnobQuadBlendMode->GetValue();
gpCreateInfo.outputState.renderTargetCount = 1;
gpCreateInfo.outputState.renderTargetFormats[0] = key.renderFormat;
gpCreateInfo.outputState.depthStencilFormat = GetSwapchain()->GetDepthFormat();
Expand Down
9 changes: 8 additions & 1 deletion benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "MultiDimensionalIndexer.h"

#include "ppx/grfx/grfx_config.h"
#include "ppx/grfx/grfx_enums.h"
#include "ppx/grfx/grfx_format.h"
#include "ppx/knob.h"
#include "ppx/math_config.h"
Expand Down Expand Up @@ -231,6 +232,12 @@ static constexpr std::array<DropdownEntry<QuadViewportScale>, 3> kAvailableViewp
{"1/4", 0.25}, // scale to 1/4
}};

static constexpr std::array<DropdownEntry<grfx::BlendMode>, 3> kQuadBlendModes = {{
{"none", grfx::BLEND_MODE_NONE},
{"alpha", grfx::BLEND_MODE_ALPHA},
{"disable_output", grfx::BLEND_MODE_DISABLE_OUTPUT},
}};

class GraphicsBenchmarkApp
: public ppx::Application
{
Expand Down Expand Up @@ -544,9 +551,9 @@ class GraphicsBenchmarkApp

std::shared_ptr<KnobFlag<int>> pKnobAluCount;
std::shared_ptr<KnobFlag<int>> pKnobTextureCount;
std::shared_ptr<KnobCheckbox> pKnobDisablePsOutput;
std::shared_ptr<KnobDropdown<QuadViewportScale>> pKnobViewportHeightScale;
std::shared_ptr<KnobDropdown<QuadViewportScale>> pKnobViewportWidthScale;
std::shared_ptr<KnobDropdown<grfx::BlendMode>> pKnobQuadBlendMode;

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

0 comments on commit c21fe09

Please sign in to comment.