Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case 3/4: Disable PS output for ALU and memfetch #502

Merged
merged 6 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/benchmarks/shaders/Benchmark_Texture.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Benchmark_Quad.hlsli"

Texture2D Tex[10] : register(t1); // Slot 0 is used by push constant.
RWStructuredBuffer<float> dataBuffer : register(u11);

float4 psmain(VSOutputPos input) : SV_TARGET
{
Expand All @@ -24,5 +25,7 @@ float4 psmain(VSOutputPos input) : SV_TARGET
{
color += Tex[i].Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
}
if (!any(color))
dataBuffer[0] = color.r;
return color;
}
29 changes: 28 additions & 1 deletion benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static constexpr size_t SPHERE_METAL_ROUGHNESS_SAMPLER_REGISTER = 7;

static constexpr size_t QUADS_CONFIG_UNIFORM_BUFFER_REGISTER = 0;
static constexpr size_t QUADS_SAMPLED_IMAGE_REGISTER = 1;
static constexpr size_t QUADS_DUMMY_BUFFER_REGISTER = QUADS_SAMPLED_IMAGE_REGISTER + kMaxTextureCount;

#if defined(USE_DX12)
const grfx::Api kApi = grfx::API_DX_12_0;
Expand Down Expand Up @@ -190,6 +191,10 @@ void GraphicsBenchmarkApp::InitKnobs()
GetKnobManager().InitKnob(&pKnobTextureCount, "texture-count", /* defaultValue = */ 1, /* minValue = */ 1, kMaxTextureCount);
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.");
}

void GraphicsBenchmarkApp::Config(ppx::ApplicationSettings& settings)
Expand Down Expand Up @@ -243,6 +248,7 @@ void GraphicsBenchmarkApp::Setup()
createInfo.sampler = 5 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 1 for blit
createInfo.sampledImage = 15 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 10 for quads, 1 for blit
RenfengLiu marked this conversation as resolved.
Show resolved Hide resolved
createInfo.uniformBuffer = 2 * GetNumFramesInFlight(); // 1 for skybox, 1 for spheres
createInfo.structuredBuffer = 1; // 1 for quads dummy buffer

PPX_CHECKED_CALL(GetDevice()->CreateDescriptorPool(&createInfo, &mDescriptorPool));
}
Expand Down Expand Up @@ -482,10 +488,22 @@ void GraphicsBenchmarkApp::SetupFullscreenQuadsResources()
}
}

// dummy buffer
{
grfx::BufferCreateInfo bufferCreateInfo = {};
bufferCreateInfo.size = PPX_MINIMUM_STRUCTURED_BUFFER_SIZE;
bufferCreateInfo.structuredElementStride = static_cast<uint32_t>(sizeof(float));
bufferCreateInfo.usageFlags.bits.rwStructuredBuffer = true;
bufferCreateInfo.memoryUsage = grfx::MEMORY_USAGE_GPU_ONLY;
bufferCreateInfo.initialState = grfx::RESOURCE_STATE_GENERAL;
PPX_CHECKED_CALL(GetDevice()->CreateBuffer(&bufferCreateInfo, &mQuadsDummyBuffer));
}

// Descriptor set layout for texture shader
{
grfx::DescriptorSetLayoutCreateInfo layoutCreateInfo = {};
layoutCreateInfo.bindings.push_back(grfx::DescriptorBinding(QUADS_SAMPLED_IMAGE_REGISTER, grfx::DESCRIPTOR_TYPE_SAMPLED_IMAGE, kMaxTextureCount));
layoutCreateInfo.bindings.push_back(grfx::DescriptorBinding(QUADS_DUMMY_BUFFER_REGISTER, grfx::DESCRIPTOR_TYPE_RW_STRUCTURED_BUFFER));
PPX_CHECKED_CALL(GetDevice()->CreateDescriptorSetLayout(&layoutCreateInfo, &mFullscreenQuads.descriptorSetLayout));
}

Expand Down Expand Up @@ -552,6 +570,15 @@ void GraphicsBenchmarkApp::UpdateFullscreenQuadsDescriptors()
for (uint32_t j = 0; j < kMaxTextureCount; j++) {
PPX_CHECKED_CALL(pDescriptorSet->UpdateSampledImage(QUADS_SAMPLED_IMAGE_REGISTER, j, mQuadsTextures[j]));
}
grfx::WriteDescriptor write = {};
write.binding = QUADS_DUMMY_BUFFER_REGISTER;
write.arrayIndex = 0;
write.type = grfx::DESCRIPTOR_TYPE_RW_STRUCTURED_BUFFER;
write.bufferOffset = 0;
write.bufferRange = PPX_WHOLE_SIZE;
write.structuredElementCount = 1;
write.pBuffer = mQuadsDummyBuffer;
PPX_CHECKED_CALL(pDescriptorSet->UpdateDescriptors(1, &write));
}
}

Expand Down Expand Up @@ -751,7 +778,7 @@ Result GraphicsBenchmarkApp::CompilePipeline(const QuadPipelineKey& key)
gpCreateInfo.frontFace = grfx::FRONT_FACE_CW;
gpCreateInfo.depthReadEnable = false;
gpCreateInfo.depthWriteEnable = false;
gpCreateInfo.blendModes[0] = grfx::BLEND_MODE_NONE;
gpCreateInfo.blendModes[0] = pKnobDisablePsOutput->GetValue() ? grfx::BLEND_MODE_PREMULT_ALPHA : grfx::BLEND_MODE_NONE;
gpCreateInfo.outputState.renderTargetCount = 1;
gpCreateInfo.outputState.renderTargetFormats[0] = key.renderFormat;
gpCreateInfo.outputState.depthStencilFormat = GetSwapchain()->GetDepthFormat();
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ class GraphicsBenchmarkApp
Entity2D mFullscreenQuads;
grfx::ShaderModulePtr mVSQuads;
std::array<grfx::TexturePtr, kMaxTextureCount> mQuadsTextures;
grfx::BufferPtr mQuadsDummyBuffer;
QuadPipelineMap mQuadsPipelines;
std::array<grfx::PipelineInterfacePtr, kFullscreenQuadsTypes.size()> mQuadsPipelineInterfaces;
std::array<grfx::ShaderModulePtr, kFullscreenQuadsTypes.size()> mQuadsPs;
Expand Down Expand Up @@ -532,6 +533,7 @@ class GraphicsBenchmarkApp

std::shared_ptr<KnobFlag<int>> pKnobAluCount;
std::shared_ptr<KnobFlag<int>> pKnobTextureCount;
std::shared_ptr<KnobCheckbox> pKnobDisablePsOutput;

private:
// =====================================================================
Expand Down
14 changes: 8 additions & 6 deletions src/ppx/grfx/grfx_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ grfx::BlendAttachmentState BlendAttachmentState::BlendModeUnder()
grfx::BlendAttachmentState BlendAttachmentState::BlendModePremultAlpha()
{
grfx::BlendAttachmentState state = {};
wangra-google marked this conversation as resolved.
Show resolved Hide resolved
state.blendEnable = true;
state.blendEnable = false;
state.srcColorBlendFactor = grfx::BLEND_FACTOR_ONE;
RenfengLiu marked this conversation as resolved.
Show resolved Hide resolved
state.dstColorBlendFactor = grfx::BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
state.dstColorBlendFactor = grfx::BLEND_FACTOR_ONE;
state.colorBlendOp = grfx::BLEND_OP_ADD;
state.srcAlphaBlendFactor = grfx::BLEND_FACTOR_ONE;
state.dstAlphaBlendFactor = grfx::BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
state.dstAlphaBlendFactor = grfx::BLEND_FACTOR_ONE;
state.alphaBlendOp = grfx::BLEND_OP_ADD;
state.colorWriteMask = grfx::ColorComponentFlags::RGBA();
state.colorWriteMask = grfx::ColorComponentFlags(0);

return state;
}
Expand Down Expand Up @@ -153,7 +153,10 @@ void FillOutGraphicsPipelineCreateInfo(
pDstCreateInfo->colorBlendState.blendAttachmentCount = pSrcCreateInfo->outputState.renderTargetCount;
for (uint32_t i = 0; i < pDstCreateInfo->colorBlendState.blendAttachmentCount; ++i) {
switch (pSrcCreateInfo->blendModes[i]) {
default: break;
default: {
pDstCreateInfo->colorBlendState.blendAttachments[i].colorWriteMask = grfx::ColorComponentFlags::RGBA();
RenfengLiu marked this conversation as resolved.
Show resolved Hide resolved
break;
}

case grfx::BLEND_MODE_ADDITIVE: {
pDstCreateInfo->colorBlendState.blendAttachments[i] = grfx::BlendAttachmentState::BlendModeAdditive();
Expand All @@ -175,7 +178,6 @@ void FillOutGraphicsPipelineCreateInfo(
pDstCreateInfo->colorBlendState.blendAttachments[i] = grfx::BlendAttachmentState::BlendModePremultAlpha();
} break;
}
pDstCreateInfo->colorBlendState.blendAttachments[i].colorWriteMask = grfx::ColorComponentFlags::RGBA();
}
}

Expand Down
Loading